-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtema1.l
More file actions
33 lines (31 loc) · 774 Bytes
/
tema1.l
File metadata and controls
33 lines (31 loc) · 774 Bytes
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
%{
#include <stdio.h>
#include "y.tab.h"
%}
%x S
%%
"/*" {BEGIN S;}
<S>[^"*/"] {}
<S>"*/" {BEGIN 0;return COMM;}
"@add"<[a-z]+".h"> {return LIB;}
"@define" {return DEF;}
"intreg"|"real"|"caracter"|"sir"|"const intreg"|"const caracter"|"const real"|"const intreg"|"vid" {return TIP;}
"@{" {return BGIN;}
"}@" {return END;}
"daca" {return IFF;}
"altfel" {return ELSEE;}
"pentru" {return FOR;}
"cat_timp" {return WHILE;}
"//"[a-zA-Z0-9 ]* {return COMM;}
"clasa"|"structura" {return STRUCT;}
"return" {return RETURN;}
>|<|>=|<= {return CMP_OP_ING;}
== {return CMP_OP_EG;}
"++"|"--" {return INC_DEC;}
[A-Z]+ {return MCRO;}
_[_a-zA-Z][_a-zA-Z0-9]* {yylval.string=strdup(yytext);return ID;}
"=" {return ASSIGN;}
[0-9]+ {return NR;}
[ \t] ;
\n {yylineno++;}
. {return yytext[0];}