-
Notifications
You must be signed in to change notification settings - Fork 0
/
coins.lex
54 lines (47 loc) · 959 Bytes
/
coins.lex
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
%{
#include "shared.h"
#include "coins.tab.hpp"
#include <stdlib.h>
%}
%option noyywrap
%option yylineno
whitespace ([\t\n ])
%%
")" return RP;
"(" return LP;
"{" return LC;
"}" return RC;
";" return SC;
"=" return ASSIGN;
[+] return PLUS;
[-] return MINUS;
[*] return MULT;
[/] return DIV;
"<=" return SE;
">=" return GE;
"==" return EQ;
"!=" return NEQ;
">" return GT;
"<" return ST;
"and" return AND;
"or" return OR;
"int" return INT;
"NIS" return NIS;
"AGORA" return AGORA;
"print" return PRINT;
"input" return INPUT;
"true" return TRUE;
"false" return FALSE;
"if" return IF;
"else" return ELSE;
"while" return WHILE;
"break" return BREAK;
"not" return NOT;
"bool" return BOOL;
[a-zA-Z]+ { yylval.varTraits.idName = yytext; return ID;}
\"[^"]*\" { yylval.stringValue = yytext; return STRING;}
([1-9][0-9]*)|0 { yylval.numValue = atoi(yytext) ; return NUM;}
{whitespace} ;
"//"[^\n]*\n ; // Comments
. ;
%%