2
#include "adsedgelabelevaluationparse.h"
8
#define YYERROR_VERBOSE
10
int proptype[200]; /* should be initialised by caller */
11
char *propname[200];/* should be initialised by caller */
12
int boollist[200];/* should be initialised by caller */
13
int count;/* should be initialised by caller */
14
int isin; /* true if IN predicate is part of label */
16
int outcome; /* result */
19
int isintexp,isstrexp;
23
int GetBool(char *s, int t){
26
if ((!strcmp(propname[i],s))&& (proptype[i]==t)) return boollist[i];
40
/* BISON Declarations */
41
%token <str> QUOTE OPEN CLOSE OPENB CLOSEB NL INTEGER IDENTIFIER TRUE LEQ GEQ EQ NEQ GT LT
42
%left <i> MINUS PLUS OR
43
%left <i> TIMES DIV AND
44
%left <i> NEG NOT IN /* negation--unary minus */
45
%right <i> '^' /* exponentiation */
52
line: event guard action {if ($<i>1>=0 && $<i>2>=0) outcome= ($<i>1) && ($<i>2); else outcome=0; }
61
b=GetBool($<str>1,EVENT);
64
b=GetBool($<str>1,SENDEVENT);
65
if (b>=0) $<i>$=b; else $<i>$=-1;
72
| OPENB pexp CLOSEB {if ($<i>2 >=0) $<i>$=$<i>2;else $<i>$=1;}
76
pexp: orexp {$<i>$=$<i>1;}
78
| IN OPEN IDENTIFIER CLOSE {$<i>$=1;isin=1; / IN clause checked elsewhere /}
79
| pexp OR pexp {if ($<i>1>=0 && $<i>3>=0) $<i>$=($<i>1 || $<i>3); else $<i>$=-1;}
80
| pexp AND pexp {if ($<i>1>=0 && $<i>3>=0) $<i>$=($<i>1 && $<i>3); else $<i>$=-1;}
81
| NOT pexp {if ($<i>2>=0) $<i>$=(!$<i>2);else $<i>$=-1;if (isin) $<i>$=1;}
82
| OPEN pexp CLOSE {$<i>$=$<i>2;}
87
orexp : andexp {$<i>$=$<i>1;}
89
{ if (($<i>3 >= 0) && ($<i>1>=0)) $<i>$=($<i>3 || $<i>1);
90
if (($<i>3 < 0) && ($<i>1>=0)) $<i>$=($<i>1);
91
if (($<i>3 >= 0) && ($<i>1 < 0)) $<i>$=($<i>3);
92
if (($<i>3 < 0) && ($<i>1 < 0)) $<i>$=-1;
96
andexp : literal {$<i>$=$<i>1;}
98
{ if (($<i>3 >= 0) && ($<i>1>=0)) $<i>$=($<i>3 && $<i>1);
99
if (($<i>3 < 0) && ($<i>1>=0)) $<i>$=($<i>1);
100
if (($<i>3 >= 0) && ($<i>1 < 0)) $<i>$=($<i>3);
101
if (($<i>3 < 0) && ($<i>1 < 0)) $<i>$=-1;
105
literal: atomic {if ($<i>1>=0) $<i>$=$<i>1;else $<i>$=-1;}
106
| NOT literal {if ($<i>2>=0) $<i>$=(!$<i>2);else $<i>$=-1;if (isin) $<i>$=1;}
107
| OPEN pexp CLOSE {$<i>$=$<i>2;}
108
| IN OPEN IDENTIFIER CLOSE {$<i>$=1;isin=1; /* IN clause checked elsewhere */}
111
atomic: TRUE {$<i>$=1;}
113
strcpy(temp,$<str>1);
119
strcpy(temp,$<str>1);
121
if (b==-1) b=GetBool(temp,INTERNAL_INT);
122
if (b>=0) $<i>$=b; else $<i>$=-1;
126
strcpy(temp,$<str>1);
127
b=GetBool(temp,STRING);
128
if (b==-1) b=GetBool(temp,INTERNAL_STRING);
129
if (b>=0) $<i>$=b; else $<i>$=-1;
133
b = GetBool(temp,PROP);
134
if (b==-1) b=GetBool(temp,INTERNAL_PROP);
135
if (b>=0) $<i>$=b; else {$<i>$=-1;}
142
isexp: /* empty */ {isintexp=0;isstrexp=0;}
143
| irel INTEGER {strcpy($<str>$,$<str>1);
144
isintexp =1;isstrexp=0;}
145
| srel QUOTE { strcpy($<str>$,$<str>1);
146
isintexp=0;isstrexp=1;}
149
irel: EQ {strcpy($<str>$,$<str>1);}
150
| NEQ {strcpy($<str>$,$<str>1);}
151
| GT {strcpy($<str>$,$<str>1);}
152
| LT {strcpy($<str>$,$<str>1);}
153
| GEQ {strcpy($<str>$,$<str>1);}
154
| LEQ {strcpy($<str>$,$<str>1);}
159
srel: EQ {strcpy($<str>$,$<str>1);}
160
| NEQ {strcpy($<str>$,$<str>1);}
166
action: /* empty */ {$<i>$=1;}
167
| DIV IDENTIFIER {$<i>$=1;}