2
#include "adsltlformulaparse.h"
10
/* adapted from the nusmv ltl parser */
15
typedef char *CHAR_PTR;
16
#define YYSTYPE CHAR_PTR
20
char *ltlprop; /* the temporal property */
21
char *initial; /* predicate characterising initial configuration */
22
/* char *final; */ /*predicate characterising final configuration */
23
int isfinal; /* true iff FINAL is part of requirement */
25
char *identifier[100]; /* name of var */
28
char *mycpy(char *text);
29
char *Mymalloc(unsigned size);
30
char *mystrconcat3(char *s1, char *s2, char *s3);
31
char *mystrconcat2(char *s1, char *s2);
33
extern char adsltlformulatext[];
35
int isltl; /* if true, then formula is ltl formula*/
40
/* BISON Declarations */
41
%token QUOTE OPEN CLOSE NL IDENTIFIER COLON TRUE FALSE LEQ GEQ EQ NEQ GT LT FUTURE GLOBALLY NEXT UNTIL IMPLIES EQUIV INITI FINAL AF EG AG EF
44
%left NEG NOT IN /* negation--unary minus */
45
%right '^' /* exponentiation */
50
%type <str_ptr> input line simple_expr ident ltlexpr orexpr andexpr untilexpr atomexpr
58
input: line {ltlprop=mycpy($1);}
67
simple_expr: TRUE {$$=mycpy("TRUE");}
68
| FALSE {$$=mycpy("FALSE");}
69
| INITI {$$=mycpy(initial);}
70
| FINAL {$$=mycpy("FINAL");isfinal=1;}
71
| IN OPEN ident CLOSE { $$=mystrconcat2($3,">0");}
79
$$ = mycpy(adsltlformulalval.str_ptr);
82
if ($$[i-1]==' ') $$[i-1]='_'; /* replace spaces by underscores for model checker */
83
if ($$[i-1]=='-') $$[i-1]='_'; /* replace dashes by underscores for model checker */
86
identifier[identifier_count]=mycpy(adsltlformulalval.str_ptr);
91
ltlexpr : orexpr {$$=$1;}
92
| ltlexpr IMPLIES orexpr {$$ = mystrconcat3($1," -> ",$3);}
93
| ltlexpr EQUIV orexpr {$$ = mystrconcat3($1," <-> ",$3);}
95
orexpr : andexpr {$$ = $1;}
96
| orexpr OR andexpr {$$ = mystrconcat3($1," | ",$3);}
98
andexpr : untilexpr {$$=$1;}
99
| andexpr AND untilexpr {$$ = mystrconcat3($1," & ",$3);}
101
untilexpr : atomexpr {$$=$1;}
102
| untilexpr UNTIL atomexpr {$$ = mystrconcat3($1," U ",$3);}
104
atomexpr : NOT atomexpr {$$ = mystrconcat2("! ",$2);}
105
| NEXT atomexpr {$$ = mystrconcat2("X ",$2);}
106
| GLOBALLY atomexpr {$$ = mystrconcat2("G ",$2);}
107
| FUTURE atomexpr {$$ = mystrconcat2("F ",$2);}
108
| EF atomexpr {$$ = mystrconcat2("EF ",$2);isltl=0;}
109
| AF atomexpr {$$ = mystrconcat2("AF ",$2);isltl=0;}
110
| AG atomexpr {$$ = mystrconcat2("AG ",$2);isltl=0;}
111
| EG atomexpr {$$ = mystrconcat2("EG ",$2);isltl=0;}
112
| OPEN ltlexpr CLOSE {$$ = mystrconcat3("(",$2,")");}
113
| simple_expr {$$ = $1;}
123
char *mystrconcat2(char *s1, char *s2)
129
ret = (char *)malloc(sizeof(char)*(len+1));
136
char *mystrconcat3(char *s1, char *s2, char *s3)
143
ret = (char*)malloc(sizeof(char)*(len+3));
153
char *mycpy(char *text)
156
cptr = (char *) Mymalloc(strlen(text) + 1);
161
char *Mymalloc(unsigned size)
167
printf("malloc returns NULL\n");