-
Notifications
You must be signed in to change notification settings - Fork 1
/
TL.y
144 lines (118 loc) · 4.51 KB
/
TL.y
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
%{ /* DO NOT EDIT THIS LINE!!! */
/*
* File: TL.y
* Project: QUEST
* Author: Marc Diefenbruch, Axel M. Hirche
* Date: (C) 1997, 1998 University of Essen, Germany
*/
//#include <string.h>
#include "TL.h"
#include "TLParserHelp.h"
#include "TLParser.h"
#include "TLHelp.h"
#include "TLFormulaALWAYS.h"
#include "TLFormulaAND.h"
#include "TLFormulaAtomic.h"
#include "TLFormulaEQUIVALENT.h"
#include "TLFormulaEVENTUALLY.h"
#include "TLFormulaFALSE.h"
#include "TLFormulaIMPLIES.h"
#include "TLFormulaNEXTTIME.h"
#include "TLFormulaNOT.h"
#include "TLFormulaOR.h"
#include "TLFormulaTRUE.h"
#include "TLFormulaUNTIL.h"
#include "TLFormulaV_OPER.h"
#include "TLFormulaWAITFOR.h"
#ifdef DMALLOC
#include <dmalloc.h>
#endif
#define YYERROR_VERBOSE 1 /* Makes parser issue verbose
error messages indicating
the token that lead to the
parse error. */
#define YYDEBUG 1 /* Enable debugging code. */
TLFormula* result = NULL; /* Use this to retrieve
the result, as the top rule
is recursive and can´t
return a result. */
SCName2PropFuncPtr* name2FuncTable; /* Translation table to
translate names to
propFuncPtr. */
SCNatural name2FuncTableElems = 0; /* Number of entries in
translation table. */
%}
%union{
TLFormula* formulaPtr;
TLLetter byteVal;
char* stringVal;
}
%token <stringVal> ATOMICtoken
%token <byteVal> ALWAYStoken
%token <byteVal> ANDtoken
%token <byteVal> EQUIVALENTtoken
%token <byteVal> EVENTUALLYtoken
%token <byteVal> FALSEtoken
%token <byteVal> LRIMPLIEStoken
%token <byteVal> RLIMPLIEStoken
%token <byteVal> NEXTTIMEtoken
%token <byteVal> NOTtoken
%token <byteVal> ORtoken
%token <byteVal> TRUEtoken
%token <byteVal> UNTILtoken
%token <byteVal> V_OPERtoken
%token <byteVal> WAITFORtoken
%token <byteval> Z_OPERtoken
%token LEFTPARtoken
%token RIGHTPARtoken
%type <formulaPtr> expr0
%type <byteVal> expr0_op
%type <formulaPtr> expr1
%type <byteVal> expr1_op
%type <formulaPtr> expr2
%type <byteVal> expr2_op
%type <formulaPtr> expr3
%start expr0
%%
expr0: expr1 { result = $1;
$$ = result; } |
expr1 expr0_op expr0 { result = NewBinaryFormula ($1, $2, $3);
$$ = result; }
/* Use result to retrieve
the formula after parsing
is done. yyparse has no
return value ;-) */
;
expr0_op: ANDtoken { $$ = AND; } |
ORtoken { $$ = OR; }
;
expr1: expr2 |
expr2 expr1_op expr1 { $$ = NewBinaryFormula ($1, $2, $3); }
;
expr1_op: UNTILtoken { $$ = UNTIL;} |
V_OPERtoken { $$ = V_OPER; }|
WAITFORtoken { $$ = WAITFOR; } |
Z_OPERtoken { $$ = Z_OPER; } |
LRIMPLIEStoken { $$ = LRIMPLIES; } |
RLIMPLIEStoken { $$ = RLIMPLIES; } |
EQUIVALENTtoken { $$ = EQUIVALENT; }
;
expr2: expr3 |
expr2_op expr2 { $$ = NewUnaryFormula ($1, $2); }
;
expr2_op: ALWAYStoken { $$ = ALWAYS; } |
EVENTUALLYtoken { $$ = EVENTUALLY; } |
NEXTTIMEtoken { $$ = NEXTTIME; } |
NOTtoken { $$ = NOT; }
;
expr3: ATOMICtoken { $$ = new TLFormulaAtomic ($1,
Name2PropFuncPtr ($1)); }
/* NOTE: $1 has been allocated
with new in TL.l, and
must be deleted by the
new formula! */ |
TRUEtoken { $$ = new TLFormulaTRUE(); } |
FALSEtoken { $$ = new TLFormulaFALSE(); } |
LEFTPARtoken expr0 RIGHTPARtoken { $$ = $2; }
;
%%