-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquarantine.l
60 lines (49 loc) · 1.16 KB
/
quarantine.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
%{
#include <stdlib.h>
#include "quarantine.h"
#include "y.tab.h"
void yyerror(char *);
%}
num [1-9][0-9]*
id [a-z]
comment "/*"([^*]|\*+[^*/])*\*+"/"
bop [()=;{}.]
%%
{id} {
yylval.sIndex = *yytext - 'a';
return VARIABLE;
}
0 {
yylval.iValue = atoi(yytext);
return INTEGER;
}
{num} {
yylval.iValue = atoi(yytext);
return INTEGER;
}
{bop} {
return *yytext;
}
{comment} return COMMENT;
[//][^\r\n]* return COMMENT;
"true" return TRUE;
"false" return FALSE;
"+" return PLUS;
"-" return MINUS;
"*" return TIMES;
\< return LT;
\> return GT;
">=" return GE;
"<=" return LE;
"==" return EQ;
"!=" return NE;
"while" return WHILE;
"if" return IF;
"else" return ELSE;
"print" return PRINT;
[ \t\n]+ ; /* ignore whitespace */
. yyerror("Unknown character");
%%
int yywrap(void) {
return 1;
}