-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyprogram.l
46 lines (34 loc) · 1.25 KB
/
myprogram.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
%{
#include <stdio.h>
%}
%%
\+ {printf("ADDITION");}
\- {printf("SUBSTRACTION");}
\* {printf("MULTIPLICATION ");}
\/ {printf("DIVISION");}
\% {printf("MODULUS");}
\< {printf("LESSTHAN");}
\> {printf("GREATERTHAN");}
\= {printf("EQUAL");}
\: {printf("COLON");}
\; {printf("SEMICOLON");}
. {printf("Syntax Error!");}
if {printf("IF");}
else {printf("ELSE");}
while {printf("WHILE");}
and {printf("AND");}
or {printf("OR");}
do {printf("DO");}
print {printf("PRINT");}
then {printf("THEN");}
true {printf("BOOLEAN");}
false {printf("BOOLEAN");}
int {printf("INTEGER ");}
[a-z][A-Z0-9]* {printf("WORD");}
[0-9]* {printf("DIGIT");}
[ \t\n]
%%
int yywrap(void)
{
return 1;
}