Skip to content

Commit 83d9bd8

Browse files
author
Rodrigo Chavez
committed
A01635547-homework-04
Signed-off-by: Rodrigo Chavez <rodrigo.chavez@oracle.com>
1 parent 88a21fc commit 83d9bd8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

labs/04/language_ac.l

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
%{
2+
#include <stdio.h>
3+
%}
4+
5+
%option noyywrap
6+
7+
letter [a-zA-Z]
8+
digit [0-9]
9+
number {digit}+
10+
11+
%%
12+
\/{2}.* { printf("COMMENT "); }
13+
^f { printf("floatdcl "); }
14+
^i { printf("intdcl "); }
15+
= { printf("assign "); }
16+
\+ { printf("plus "); }
17+
\- { printf("minus "); }
18+
\* { printf("multiplication "); }
19+
\/ { printf("division "); }
20+
^p { printf("print "); }
21+
({letter}{digit}*)+ { printf("id "); }
22+
(0|([1-9]{digit}*))\.(({digit}*[1-9])|0) { printf("fnum "); }
23+
{number} { printf("inum "); }
24+
[ \t]+ /* ignore whitespace */
25+
%%
26+
27+
int main() {
28+
yylex();
29+
return 0;
30+
}

0 commit comments

Comments
 (0)