-
Notifications
You must be signed in to change notification settings - Fork 0
/
java.l
61 lines (47 loc) · 973 Bytes
/
java.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
%option noyywrap nodefault yylineno
%{
#include "declarations.h"
#include "java.tab.h"
#include "symtab.h"
%}
/* float exponent */
EXP ([Ee][-+]?[0-9]+)
%%
"+" |
"-" |
"*" |
"/" |
"=" |
";" |
"," |
"(" |
")" |
"{" |
"}" { return yytext[0]; }
">" {yylval.fn = 1 ; return CMP ;}
"<" {yylval.fn = 2 ; return CMP ;}
"!=" {yylval.fn = 3 ; return CMP ;}
"==" {yylval.fn = 4 ; return CMP ;}
">=" {yylval.fn = 5 ; return CMP ;}
"<=" {yylval.fn = 6 ; return CMP ;}
"class" { return CLASS ; }
"if" { return IF ; }
"else" { return ELSE ; }
"while" { return WHILE ; }
"return" { return RETURN ; }
"public" |
"private" |
"static" |
"protected" {return MODIFIER ;}
"void" |
"String" |
"int" |
"boolean" { return TYPE ; }
[a-zA-Z][a-zA-Z0-9]* { yylval.s = new_symbol(yytext) ; return NAME; }
[0-9]+"."[0-9]*{EXP}? |
"."?[0-9]+{EXP}? { yylval.d = atof(yytext); return NUMBER; }
\n
"//".*
[ \t]
. { yyerror("Mystery character %c\n", *yytext); }
%%