-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaco.l
More file actions
55 lines (51 loc) · 1.41 KB
/
paco.l
File metadata and controls
55 lines (51 loc) · 1.41 KB
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
%{
#include "operations/include/operations.h"
#include "types/include/object.h"
#include "yaccObjects.h"
#include "y.tab.h"
%}
alpha [A-Za-z]
digit [0-9]
varName [A-Za-z][0-9A-Za-z_]*
%%
if return IF;
bloque_si return IF;
while return WHILE;
ciclo_mientras return WHILE;
end return END;
[\t ] ;
[\n] return ENTER;
\+ return PLUS;
\+= return PLUSEQ;
- return MINUS;
-= return MINUSEQ;
\* return MULT;
\*= return MULTEQ;
\/ return DIV;
\/= return DIVEQ;
\^ return POW;
== return EQLS;
= return EQ;
!= return DIFF;
{digit}+ { yylval.num = atoi(yytext); return INT; }
{digit}+\.{digit}+ { yylval.fl = atof(yytext); return FLOAT; }
{varName} {
yylval.str = malloc(strlen(yytext)+1);
strcpy(yylval.str, yytext);
return VAR;
}
\<\<n return STDNUM;
\<\<d return STDDEC;
\<\<s return STDSTR;
\< return LT;
\<= return LE;
\> return GT;
\>= return GE;
\"[^\"]*\" {
char * str = malloc(strlen(yytext) - 1);
strncpy(str, yytext + 1, strlen(yytext) - 2);
yylval.str = str;
return STRING;
}
. return yytext[0];
%%