-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode.l
42 lines (36 loc) · 952 Bytes
/
Code.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
%{
#include "Final.tab.h"
%}
separator [\t\n\r ]
letter [a-z]
digit [0-9]
number 0|[1-9]{digit}*|-[1-9]{digit}*
ID {letter}({letter}|{digit}|-)*
true #t
false #f
%%
{number} { yylval.ival = atoi(yytext); return(NUMBER); }
{true} { yylval.ival = 1; return(BOOL_VAL); }
{false} { yylval.ival = 0; return(BOOL_VAL); }
"if" { return(IF); }
"or" { return(OR); }
"and" { return(AND); }
"not" { return(NOT); }
"mod" { return(MOD); }
"define" { return(DEFINE); }
"print-num" { return(PRINTNUM); }
"print-bool" { return(PRINTBOOL); }
"("|")"|"+"|"-"|"*"|"/"|">"|"<"|"=" { return yytext[0]; }
{ID} { yylval.sval = strdup(yytext); return(ID); }
. { }
%%
/*
sudo mount -t vboxsf share /home/user/Desktop/DomjudgeHW2
bison -d -o Final.tab.c Final.y
gcc -c -g -I.. Final.tab.c
flex -o Final.yy.c Final.l
gcc -c -g -I.. Final.yy.c
gcc -o Final Final.tab.o Final.yy.o -ll
./Final < 01_1.lsp
./smli < 01_1.lsp
*/