-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfloc.lpp
40 lines (33 loc) · 828 Bytes
/
floc.lpp
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
%option noyywrap
%option yylineno
%{
#include <stdio.h>
#define YY_DECL int yylex()
#include "floc.tab.hpp"
%}
%%
[ \t] ; // ignore all whitespace
[0-9]+ { yylval.val = atoi(yytext); return T_INT;}
\n+ {return T_NEWLINE;}
"+" {return '+';}
"-" {return '-';}
"*" {return '*';}
"/" {return '/';}
"(" {return '(';}
")" {return ')';}
"{" {return '{';}
"}" {return '}';}
"|" {return '|';}
":" {return ':';}
"?" {return '?';}
"&" {return '&';}
"<" {return '<';}
">" {return '>';}
"=" {return '=';}
">=" {return T_GE;}
"<=" {return T_LE;}
"==" {return T_EQ;}
"!=" {return T_NE;}
"def" {return T_DEF;}
[a-zA-Z]+ { yylval.name = yytext; return T_ID;}
%%