-
Notifications
You must be signed in to change notification settings - Fork 0
/
flex.l
53 lines (49 loc) · 1.02 KB
/
flex.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
%option noyywrap
%option yylineno
%{
#include "bison.tab.h"
int yylex();
%}
%x comment
%%
"(*" BEGIN(comment);
<comment>[^*\n]* ;
<comment>"*"+[^*)\n]* ;
<comment>\n ;
<comment>"*"+")" BEGIN(INITIAL);
[ \t\r\n]+ {}
CONST { return(CONST); }
"=" { return(CASSIGN); }
VAR { return(VAR); }
BEGIN { return(START); }
END { return(END); }
":=" { return(ASSIGN); }
WHILE { return(WHILE); }
DO { return(DO); }
IF { return(IF); }
THEN { return(THEN); }
ELSE { return(ELSE); }
WRITE { return(WRITE); }
READ { return(READ); }
"==" { return(EQ); }
"<" { return(LT); }
"<=" { return(LET); }
">" { return(GT); }
">=" { return(GET); }
"!=" { return(NEQ); }
"+" { return(PLUS); }
"-" { return(MINUS); }
"*" { return(MULT); }
"/" { return(DIV); }
"%" { return(MOD); }
[0-9]+ {
yylval.numu = (char *) strdup(yytext);
return(NUM);
}
[_a-z]+ {
yylval.stru = (char *) strdup(yytext);
return(IDENTIFIER);
}
";" { return(SEMICOLON); }
. ;
%%