-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlimbaj.l
More file actions
41 lines (32 loc) · 1.59 KB
/
limbaj.l
File metadata and controls
41 lines (32 loc) · 1.59 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
%{
#include <stdio.h>
#include "code.h"
#include "y.tab.h"
%}
%option noyywrap
%%
"#include"[ ]*<.+\.h> {yylval.value = strdup(yytext); return INCLUDE;}
"Eval" {return EVAL;}
"TypeOf" {return TYPEOF;}
"class" {return CLASS;}
"main" {return MAIN;}
"int"|"float"|"char"|"string"|"bool"|"void" {yylval.value = strdup(yytext); return TIP;}
"const" {return CONST;}
"++"|"--" {return DIGIT;}
"if" {return IF;}
"else" {return ELSE;}
"while" {return WHILE;}
"do" {return DO;}
"for" {return FOR;}
"<="|"<"|">="|">"|"=="|"!=" {return OPR;}
"&&" {return AND;}
"||" {return OR;}
"return" {return RETURN;}
"true"|"false" {yylval.value = strdup(yytext); return VARBOOL;}
\"[^\"]*\" {yylval.value = strdup(yytext); return STRING;}
[a-zA-Z][a-z0-9A-Z]* {yylval.value = strdup(yytext); return ID;}
0|[1-9]+([0-9])?("."[0-9]+)? {yylval.value = strdup(yytext); return NR;}
"=" {return ASSIGN;}
[ \t] ;
\n {yylineno++;}
. {return yytext[0];}