/
bgscanner.ll
155 lines (143 loc) · 3.88 KB
/
bgscanner.ll
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
%{
/*******************************************************************************
*
* Copyright (C) 2011 Gian Perrone (http://itu.dk/~gdpe)
*
* BigMC - A bigraphical model checker (http://bigraph.org/bigmc).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*********************************************************************************/
#include<sstream>
#include "bigmc.h"
#include "bgparser.h"
int line = 0;
int column = 0;
#define YY_INPUT(buf, result, max_size) \
{ \
int yyc = parser_next_char(); \
result = (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \
}
int yycolumn = 1;
#define YY_USER_ACTION yylloc.first_line = yylloc.last_line = yylineno; \
yylloc.first_column = yycolumn; yylloc.last_column = yycolumn+yyleng-1; \
yycolumn += yyleng;
%}
%option noyywrap
%option yylineno
%x COMMENT
DIGIT [0-9]
IDENT1 [a-zA-Z]
IDENTR [a-zA-Z0-9_]
%%
" " {
}
"\t" {
}
"\n" {
yycolumn = 1;
}
";" {
return SEMI;
}
"->" {
return ARROW;
}
"||" {
return LOR;
}
"|" {
return PAR;
}
"." {
return PREF;
}
"," {
return COMMA;
}
"[" {
return LSQ;
}
"]" {
return RSQ;
}
"(" {
return LPAR;
}
")" {
return RPAR;
}
"%inner" {
return INNER;
}
"%outer" {
return OUTER;
}
"%name" {
return OUTER;
}
"%active" {
return ACTIVE;
}
"%passive" {
return PASSIVE;
}
"%property" {
return PROPERTY;
}
"&&" {
return LAND;
}
"!" {
return LNOT;
}
"%check" {
yyterminate();
}
":" {
return COLON;
}
"<=" { return LEQ; }
">=" { return GEQ; }
"<" { return LT; }
">" { return GT; }
"==" { return EQ; }
"!=" { return NEQ; }
"forall" { return FORALL; }
"exists" { return EXISTS; }
"$" { return DOLLAR; }
"true" { return BTRUE; }
"if" { return IF; }
"then" { return THEN; }
"else" { return ELSE; }
"#" { BEGIN COMMENT; }
"-" { return UNLINKED; }
{DIGIT}+ {
std::istringstream(yytext) >> yylval.value;
return NUM;
}
{IDENT1}{IDENTR}* {
yylval.ident = strdup(yytext);
return IDENT;
}
. {
return UNKNOWN;
}
<<EOF>> {
yyterminate();
}
<COMMENT>"\n" { yycolumn = 1; BEGIN 0; }
<COMMENT>. { ; }
%%