blob: d82df4e0fee87d23bb5d2b270043a61d726497c2 (
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
81
82
83
84
85
86
87
88
89
90
91
92
|
/* 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]*
L [a-zA-Z_]
%%
bit|bool|byte|int|mtype|short|unsigned {
yylval->value = strdup(yytext);
return TYPE;
}
len { return LEN; }
false|skip|true { yylval->value = strdup(yytext); return CONST; }
printf { return PRINT; }
printm { return PRINTM; }
"!" { return NEG; }
"~" { return COMPL; }
"++" { return INCR; }
"--" { return DECR; }
"*" { 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 COMMA; }
";" { return SEMI; }
"(" { return '('; }
")" { return ')'; }
"[" { return '['; }
"]" { return ']'; }
"{" { return '{'; }
"}" { return '}'; }
"=" { return ASGN; }
L?\"(\\.|[^\\"])*\" { yylval->value = strdup(yytext); return(STRING); }
{DIGIT}+ { yylval->value = strdup(yytext); return CONST; }
{ID} { yylval->value = strdup(yytext); return NAME; }
\'(\\.|[^'])*\' { }
[ \t\n]+ /* eat up whitespace */
. { /*printf( "Unrecognized character: %s\n", yytext ); */ }
|