-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogo.l
105 lines (93 loc) · 2.59 KB
/
logo.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
%{
#include "structures.h"
#include "hashFunctions.h"
#include "y.tab.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
%}
%option yylineno
PROGRAM [Pp][Rr][Oo][Gg][Rr][Aa][Mm]
DECLARATIONS [Dd][Ee][Cc][Ll][Aa][Rr][Aa][Tt][Ii][Oo][Nn][Ss]
STATEMENTS [Ss][Tt][Aa][Tt][Ee][Mm][Ee][Nn][Tt][Ss]
SUCC [Ss][Uu][Cc][Cc]
PRED [Pp][Rr][Ee][Dd]
IF [Ii][Ff]
ELSE [Ee][Ll][Ss][Ee]
THEN [Tt][Hh][Ee][Nn]
WHILE [Ww][Hh][Ii][Ll][Ee]
INTEGER [Ii][Nn][Tt][Ee][Gg][Ee][Rr]
BOOLEAN [Bb][Oo][Oo][Ll][Ee][Aa][Nn]
STRING [Ss][Tt][Rr][Ii][Nn][Gg]
ARRAY [Aa][Rr][Rr][Aa][Yy]
SIZE [Ss][Ii][Zz][Ee]
TRUE [T][R][U][E]
FALSE [F][A][L][S][E]
FORWARD [Ff][Oo][Rr][Ww][Aa][Rr][Dd]
BACKWARD [Bb][Aa][Cc][Kk][Ww][Aa][Rr][Dd]
RRIGHT [Rr][Rr][Ii][Gg][Hh][Tt]
RLEFT [Rr][Ll][Ee][Ff][Tt]
PEN [Pp][Ee][Nn]
UP [Uu][Pp]
DOWN [Dd][Oo][Ww][Nn]
GOTO [Gg][Oo][Tt][Oo]
WHERE [Ww][Hh][Ee][Rr][Ee]
SAY [Ss][Aa][Yy]
ASK [Aa][Ss][Kk]
IN [Ii][Nn]
NUMBER [0-9]+
IDENTIFIER [a-zA-Z][a-zA-Z0-9]*
STR \"([^"\n]|\\\")*\"
%%
{PROGRAM} { return PROGRAM; }
{DECLARATIONS} { return DECLARATIONS; }
{STATEMENTS} { return STATEMENTS; }
"->" { return ARROW; }
{INTEGER} { return INTEGER; }
{BOOLEAN} { return BOOLEAN; }
{STRING} { return STRING; }
{ARRAY} { /*return ARRAY;*/ }
{SIZE} { /*return SIZE;*/ }
{TRUE} { return TRUE; }
{FALSE} { return FALSE; }
{FORWARD} { return FORWARD; }
{BACKWARD} { return BACKWARD; }
{RRIGHT} { return RRIGHT; }
{RLEFT} { return RLEFT; }
{PEN} { return PEN; }
{UP} { return UP; }
{DOWN} { return DOWN; }
{GOTO} { return GOTO; }
{WHERE} { return WHERE; }
"||" { return OR; }
"&&" { return AND; }
"**" { return POW; }
"==" { return EQUAL; }
"!=" { return DIF; }
"<" { return MINOR; }
">" { return MAJOR; }
"<=" { return MINOREQUAL; }
">=" { return MAJOREQUAL; }
{IN} { return IN; }
[=\-,;!?/()\[\]\{\}*+] { return(yytext[0]);}
{SUCC} { return SUCC; }
{PRED} { return PRED; }
{SAY} { return SAY; }
{ASK} { return ASK; }
{IF} { return IF; }
{THEN} { return THEN; }
{ELSE} { return ELSE; }
{WHILE} { return WHILE; }
{NUMBER} { yylval.stringvalue = strdup(yytext); return NUMBER; }
{IDENTIFIER} { yylval.stringvalue = strdup(yytext); return IDENTIFIER; }
{STR} { yylval.stringvalue = strdup(yytext); return STR; }
[\ \n\t\r]+ {;}
<*>.|\n { fprintf(stderr,"ERRO: %d '%s'\n",yylineno, yytext);}
%%
int yywrap() {
return 1;
}
/*int yyerror(char *s){
fprintf(stderr,"ERRO: %d %s\n",yylineno, s);
return 0;
}*/