-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlimbaj.l
More file actions
57 lines (47 loc) · 1.48 KB
/
limbaj.l
File metadata and controls
57 lines (47 loc) · 1.48 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
56
57
%{
#include <stdio.h>
#include <string>
#include "limbaj.tab.h"
%}
%option noyywrap
%%
"//".* ;
"begin_xmas" { return BGIN; }
"end_xmas" { return END; }
"class" { return CLASS_BC; }
"if" { return IF_BC; }
"else" { return ELSE_BC; }
"while" { return WHILE_BC; }
"return" { return RETURN_BC; }
"Print" { return PRINT_BC; }
"elf" { return FN_BC; }
"create_gift" { return NEW_BC; }
"and" { return ATELIER_AND_COR; }
"or" { return DECORATIUNI_OR_COLINDE; }
"int_gift" { yylval.Str = new std::string(yytext); return INT_BC; }
"float_snow" { yylval.Str = new std::string(yytext); return FLOAT_BC; }
"str_letter" { yylval.Str = new std::string(yytext); return STRING_BC; }
"bool" { yylval.Str = new std::string(yytext); return BOOL_BC; }
"nice"|"naughty" {
yylval.Str = new std::string(yytext);
return BOOL_VAL_BC;
}
[a-zA-Z][a-zA-Z0-9]* {
yylval.Str = new std::string(yytext);
return ID_BC;
}
"=" { return ASSIGN_GIFT; }
"==" { return EQ_GIFTS; }
"!=" { return NEQ_GIFTS; }
"<=" { return LE_GIFTS; }
">=" { return GE_GIFTS; }
"<" { return LT; }
">" { return GT; }
"->" { return ACCES; }
[0-9]+\.[0-9]+ { yylval.Str = new std::string(yytext); return FLOAT_NR; }
[0-9]+ { yylval.Str = new std::string(yytext); return NR; }
\"[^\"]*\" { yylval.Str = new std::string(yytext); return STRING_VAL; }
[ \t] ;
\n { yylineno++; }
. { return yytext[0]; }
%%