blob: 4332c6b2e10bb4e41163bd932ce7b6f64bc708f5 (
plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/* see: http://www.phpcompiler.org/articles/reentrantparser.html */
/* see: http://spinroot.com/spin/Man/operators.html */
%option reentrant
%option bison-bridge
%option prefix="promela_"
%option outfile="promela.lex.yy.cpp"
%option noyywrap
%option debug
%option never-interactive nounistd
%{
#include "../PromelaParser.h"
#include "promela.tab.hpp"
#define YYSTYPE PROMELA_STYPE
%}
DIGIT [0-9]
ID [_a-zA-Z][_a-zA-Z0-9]*
%%
bit|bool|byte|int|mtype|short|unsigned {
//printf("TYPE: %s\n", yytext);
yylval->value = strdup(yytext);
return TYPE;
}
len { return LEN; }
false|skip|true { yylval->value = strdup(yytext); return CONST; }
"!" { return NEG; }
"~" { return COMPL; }
"*" { return TIMES; }
"/" { return DIVIDE; }
"%" { return MODULO; }
"+" { return PLUS; }
"-" { return MINUS; }
"<<" { return LSHIFT; }
">>" { return RSHIFT; }
"<=" { return LE; }
">=" { return GE; }
"<" { return LT; }
">" { return GT; }
"!=" { return NE; }
"==" { return EQ; }
"&" { return BITAND; }
"^" { return BITXOR; }
"|" { return BITOR; }
"&&" { return AND; }
"||" { return OR; }
"." { return DOT; }
"(" { return LBRACKET; }
")" { return RBRACKET; }
"=" { return ASGN; }
{DIGIT}+ { yylval->value = strdup(yytext); return CONST; }
{ID} { yylval->value = strdup(yytext); return NAME; }
\'(\\.|[^'])*\' { }
"{"[^}\n]*"}" /* eat up one-line comments */
[ \t\n]+ /* eat up whitespace */
. { /*printf( "Unrecognized character: %s\n", yytext ); */ }
|