scanner: remove linker dependency
[uebersetzerbau-ss10.git] / gesamt_arm64 / scanner.lex
1         #include <stdio.h>
2         #include <stdlib.h>
3         #include <string.h>
4         #include "parser.h"
5
6 KEYWORD struct|end|method|var|if|then|else|while|do|return|not|or|this
7 IDENTIFIER [a-zA-Z_][0-9a-zA-Z_]*
8 NUMBER_HEX 0x[0-9A-Fa-f]+
9 NUMBER_DEC [0-9]+
10 WHITESPACE [\t\n\r ]
11 COMMENT_START \/\*
12 COMMENT_END     \*\/
13
14 %x COMMENT
15 %option yylineno
16 %option noyywrap
17 %%
18
19 {COMMENT_START} BEGIN(COMMENT);
20
21 <COMMENT>{COMMENT_END} BEGIN(INITIAL);
22
23 <COMMENT>(.|\n) /* alles im kommentar wird ignoriert */
24
25 struct return(STRUCT);
26 end return(END);
27 method return(METHOD);
28 var return(VAR);
29 if return(IF);
30 then return(THEN);
31 else return(ELSE);
32 while return(WHILE);
33 do return(DO);
34 return return(RETURN);
35 not return(NOT);
36 or return(OR);
37 this return(THIS);
38
39 {IDENTIFIER} return(IDENT); @{ @IDENT.name@ = strdup(yytext); @}
40
41 {NUMBER_DEC} return(NUM); @{ @NUM.val@ = strtol(yytext, (char **)NULL, 10); @}
42 {NUMBER_HEX} return(NUM); @{ @NUM.val@ = strtol(yytext, (char **)NULL, 16); @}
43
44 \:= return(ASSIGN);
45 \; return(';');
46 \( return('(');
47 \) return(')');
48 \. return('.');
49 \- return('-');
50 \* return('*');
51 \< return('<');
52 \= return('=');
53 \, return(',');
54
55 {WHITESPACE} /* ignore */
56
57 . {
58                 fprintf(stderr, "Lexical error on line %i\n", yylineno);
59                 exit(1);
60 }
61
62 %%
63