-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompila.l
57 lines (44 loc) · 931 Bytes
/
compila.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
D [0-9]
L [a-zA-Z_]
H [a-zA-Z_0-9]
E [Ee][+-]?{D}+
%{
#include <math.h>
#include "compila.tab.h"
%}
%%
{D}*[.]?{D}+{E}? { yylval.val = atof(yytext); return NUMt; }
ret(urn)? { return RETt; }
if { return IF; }
else { return ELSE; }
while { return WHILE; }
func|def { return FUNC; }
print { return PRINT; }
{L}{H}* {
strncpy(yylval.cod, yytext, 30);
return ID;
}
[ \t\n]+ /* pula espacos em branco */
#.* /* comentarios simples */
; { return EOL; }
, { return SEP; }
= { return ASGN; }
[(] { return OPEN; }
[)] { return CLOSE; }
[{] { return ABRE; }
[}] { return FECHA; }
[+] { return ADDt; }
[-] { return SUBt; }
[*] { return MULt; }
[/] { return DIVt; }
== { return EQt; }
!= { return NEt; }
"<" { return LTt; }
"<=" { return LEt; }
">" { return GTt; }
">=" { return GEt; }
. { fprintf(stderr, "Entrada ignorada\n-->%s\n", yytext); }
%%
/* Local Variables: */
/* mode: c */
/* End: */