-
Notifications
You must be signed in to change notification settings - Fork 0
/
lexico.l
77 lines (67 loc) · 1.29 KB
/
lexico.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
66
67
68
69
70
71
72
73
74
75
76
77
%{
#include "global.h"
#include "sintatico.h"
#include <stdlib.h>
char buffer[500];
char buffer2[500];
%}
white [ \t]+
digit [0-9]
integer {digit}+
real {integer}("."{integer})
string \"[a-zA-Z ][a-zA-Z{integer} ]*\"
variable [a-zA-Z][a-zA-Z{integer}]*
%%
{white} { }
{integer} {
yylval=atof(yytext);
return (INTEGER);
};
{real} {
yylval=atof(yytext);
return (FLOAT);
};
"then" return (THEN);
"else" return (ELSE);
"if" return (IF);
"not" return (NOT);
"putStrLn" return (PRINT);
"getLine" return (SCANF);
"otherwise" return (DEFAULT);
"<-" return (ARROW);
"+" return (PLUS);
"-" return (MINUS);
"*" return (TIMES);
"/" return (DIVIDE);
"^" return (POWER);
"(" return (LEFT_PARENTHESIS);
")" return (RIGHT_PARENTHESIS);
"[" return (LEFT_COLCHETES);
"]" return (RIGHT_COLCHETES);
"{" return (LEFT_KEYS);
"}" return (RIGHT_KEYS);
"\n" return (END_LINE);
"|" return (IF2);
"&&" return (AND);
"||" return (OR);
"=" return (EQUALS);
"==" return (COMPARATION);
"<" return (SMALLER_THAN);
"<=" return(SMALLER_EQUALS);
">" return (BIGGER_THAN);
">=" return (BIGGER_EQUALS);
"::" return (TYPING);
"\"" return (QUOTATION);
"," return (VIRGULA);
{variable} {
strcpy(buffer2,yytext);
return (VARIABLE);
};
{string} {
strcpy(buffer,yytext);
return (STRING);
};
%%
yywrap(){
return 0;
}