5
#include "Expressions.h"
6
using namespace PetriEngine::PQL;
12
extern char* sumotext;
13
void sumoerror(const char *s) {printf("ERROR: %s: %s\n", s, sumotext);}
18
/* Data representation */
20
PetriEngine::PQL::Expr* expr;
21
PetriEngine::PQL::Condition* cond;
26
/* Terminal type definition */
27
%token <string> ID INT
28
%token <token> LPAREN RPAREN LBRACKET RBRACKET
29
%token <token> AND OR NOT REACHABLE INVARIANT
30
%token <token> CONTAINS EQUALS STAR VALUE EQUAL
32
/* Terminal associativity */
36
/* Nonterminal type definition */
37
%type <cond> subformula atomic
38
%type <expr> idexpr expr
47
root : ID EQUAL REACHABLE subformula { sumoQuery = $4; isInvariant = false; sumoName = *$1; delete $1;}
48
| ID EQUAL INVARIANT subformula { sumoQuery = new NotCondition($4); isInvariant = true; sumoName = *$1; delete $1; }
51
subformula : subformula AND subformula { $$ = new AndCondition($1, $3); }
52
| subformula OR subformula { $$ = new OrCondition($1, $3); }
53
| NOT subformula { $$ = new NotCondition($2); }
54
| LPAREN subformula RPAREN { $$ = $2; }
58
atomic : idexpr CONTAINS LBRACKET expr RBRACKET { $$ = new GreaterThanOrEqualCondition($1, $4); }
59
| idexpr EQUALS LBRACKET expr RBRACKET { $$ = new EqualCondition($1, $4); }
60
| idexpr EQUALS LBRACKET RBRACKET { $$ = new EqualCondition($1, new LiteralExpr(0)); }
63
idexpr : ID { $$ = new IdentifierExpr(*$1, @1.first_column); delete $1; }
66
expr : INT STAR VALUE { $$ = new LiteralExpr(atol($1->c_str())); delete $1; }