-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlexer.l
65 lines (55 loc) · 924 Bytes
/
lexer.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
60
61
62
63
64
65
%{
#include <stdlib.h>
#include "include.h"
#include "y.tab.h"
void yyerror(char *);
%}
%%
"int" return INT;
"bool" return BOOLEAN;
"pre" return PRE;
"post" return POST;
"true" return TRUE;
"false" return FALSE;
"&&" return AND;
"||" return OR;
"~" return NOT;
"@" return FORALL;
"#" return EXISTS;
"inv" return INV;
[a-z] {
yylval.sIndex = *yytext - 'a';
return VARIABLE;
}
[A-Z] {
yylval.sIndex = *yytext - 'A';
return ARR_VAR;
}
0 {
yylval.iValue = atoi(yytext);
return INTEGER;
}
[1-9][0-9]* {
yylval.iValue = atoi(yytext);
return INTEGER;
}
[-()<>=+*/%;{}.] {
return *yytext;
}
"[" return *yytext;
"]" return *yytext;
">=" return GE;
"<=" return LE;
"==" return EQ;
"!=" return NE;
"while" return WHILE;
"if" return IF;
"else" return ELSE;
"print" return PRINT;
\n {lineno++;}
[ \t]+ ; /* ignore whitespace */
. yyerror("Unknown character");
%%
int yywrap(void) {
return 1;
}