-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLimbaj.l
More file actions
65 lines (53 loc) · 1.64 KB
/
Limbaj.l
File metadata and controls
65 lines (53 loc) · 1.64 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
58
59
60
61
62
63
64
65
%{
#include <stdio.h>
#include "limbaj.tab.h"
#include <string>
%}
%option noyywrap
%%
"//".* ; /*asta i pt comentarii*/
/* --- CUVINTE CHEIE --- */
"begin_xmas" { return BGIN; }
"end_xmas" { return END; }
"class" { return CLASS_BC; }
"public" { return PUBLIC_BC; }
"private" { return SECRET_SANTA; }
"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;}
/* data types */
"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; }
"void_magic" { yylval.Str = new std::string(yytext); return VOID_BC; }
/* val bool */
"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; }
"and" { return ATELIER_AND_COR; }
"or" { return DECORATIUNI_OR_COLINDE; }
"<" { return LT; }
">" { return GT; }
"->" {return ACCES;}
[0-9]+\.[0-9]+ { return FLOAT_NR; }
[0-9]+ { return NR; }
\"[^\"]*\" { yylval.Str = new std::string(yytext); return STRING_VAL; }
[ \t] ;
\n {yylineno++;}
. { return yytext[0]; }
%%