parser/calc/lexer.l
author Markus Bröker <mbroeker@largo.dyndns.tv>
Thu, 28 May 2009 17:41:18 +0200
changeset 97 f883331a1bf2
parent 39 46d7ec9d63bd
permissions -rw-r--r--
alpha_beta ui: removed a redundant line The original print routine was from an open book by galileo computing and the redundant line was introduced there. committer: Markus Bröker <mbroeker@largo.homelinux.org>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     1
/**
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     2
 * test/demos/parser/lexer.ll
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     3
 * Copyright (C) 2008 Markus Broeker
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     4
 */
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     5
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     6
%{
39
46d7ec9d63bd Project Parser
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 38
diff changeset
     7
    #include <stdio.h>
46d7ec9d63bd Project Parser
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 38
diff changeset
     8
    #include "parser.h"
37
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     9
%}
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    10
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    11
%%
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    12
39
46d7ec9d63bd Project Parser
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 38
diff changeset
    13
[0-9]+         { yylval = atoi(yytext); return DIGIT; }
46d7ec9d63bd Project Parser
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 38
diff changeset
    14
[a-zA-Z]       { yylval = yytext[0]; return LETTER; }
46d7ec9d63bd Project Parser
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 38
diff changeset
    15
"+"            { return PLUS; }
46d7ec9d63bd Project Parser
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 38
diff changeset
    16
"-"            { return MINUS; }
46d7ec9d63bd Project Parser
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 38
diff changeset
    17
"*"            { return MUL; }
46d7ec9d63bd Project Parser
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 38
diff changeset
    18
"/"            { return DIV; }
46d7ec9d63bd Project Parser
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 38
diff changeset
    19
"("|")"|"="    { return yytext[0]; }
46d7ec9d63bd Project Parser
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 38
diff changeset
    20
[ \t]+         {}
46d7ec9d63bd Project Parser
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 38
diff changeset
    21
\n             { return yytext[0]; }
46d7ec9d63bd Project Parser
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 38
diff changeset
    22
.              { printf("FEHLER: %s\n", yytext); }
37
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    23
%%