blob: 2aaef062ace7ef7001549d02d4542a1b0775535a (
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 PML_TYPE;
}
len { return PML_LEN; }
false|skip|true { yylval->value = strdup(yytext); return PML_CONST; }
printf { return PML_PRINT; }
printm { return PML_PRINTM; }
"!" { return PML_NEG; }
"~" { return PML_COMPL; }
"++" { return PML_INCR; }
"--" { return PML_DECR; }
"*" { return PML_TIMES; }
"/" { return PML_DIVIDE; }
"%" { return PML_MODULO; }
"+" { return PML_PLUS; }
"-" { return PML_MINUS; }
"<<" { return PML_LSHIFT; }
">>" { return PML_RSHIFT; }
"<=" { return PML_LE; }
">=" { return PML_GE; }
"<" { return PML_LT; }
">" { return PML_GT; }
"!=" { return PML_NE; }
"==" { return PML_EQ; }
"&" { return PML_BITAND; }
"^" { return PML_BITXOR; }
"|" { return PML_BITOR; }
"&&" { return PML_AND; }
"||" { return PML_OR; }
"." { return PML_DOT; }
"," { return PML_COMMA; }
";" { return PML_SEMI; }
"(" { return '('; }
")" { return ')'; }
"[" { return '['; }
"]" { return ']'; }
"{" { return '{'; }
"}" { return '}'; }
"=" { return PML_ASGN; }
L?\"(\\.|[^\\"])*\" { yylval->value = strdup(yytext); return(PML_STRING); }
{DIGIT}+ { yylval->value = strdup(yytext); return PML_CONST; }
{ID} { yylval->value = strdup(yytext); return PML_NAME; }
\'(\\.|[^'])*\' { }
[ \t\n]+ /* eat up whitespace */
. { /*printf( "Unrecognized character: %s\n", yytext ); */ }
|