27
27
* Licensed Material - Property of Matthew Hawkins (hawkini@4email.net)
30
public class TAPAALQueryParser implements GPMessageConstants
33
public interface SymbolConstants
35
final int SYMBOL_EOF = 0; // (EOF)
36
final int SYMBOL_ERROR = 1; // (Error)
37
final int SYMBOL_WHITESPACE = 2; // (Whitespace)
38
final int SYMBOL_EXCLAM = 3; // '!'
39
final int SYMBOL_AMPAMP = 4; // '&&'
40
final int SYMBOL_LPARAN = 5; // '('
41
final int SYMBOL_RPARAN = 6; // ')'
42
final int SYMBOL_PIPEPIPE = 7; // '||'
43
final int SYMBOL_LT = 8; // '<'
44
final int SYMBOL_LTEQ = 9; // '<='
45
final int SYMBOL_EQ = 10; // '='
46
final int SYMBOL_EQEQ = 11; // '=='
47
final int SYMBOL_GT = 12; // '>'
48
final int SYMBOL_GTEQ = 13; // '>='
49
final int SYMBOL_ALBRACKETRBRACKET = 14; // 'A[]'
50
final int SYMBOL_ALTGT = 15; // 'A<>'
51
final int SYMBOL_AF = 16; // AF
52
final int SYMBOL_AG = 17; // AG
53
final int SYMBOL_AND = 18; // and
54
final int SYMBOL_ELBRACKETRBRACKET = 19; // 'E[]'
55
final int SYMBOL_ELTGT = 20; // 'E<>'
56
final int SYMBOL_EF = 21; // EF
57
final int SYMBOL_EG = 22; // EG
58
final int SYMBOL_IDENTIFIER = 23; // Identifier
59
final int SYMBOL_NOT = 24; // not
60
final int SYMBOL_NUM = 25; // Num
61
final int SYMBOL_OR = 26; // or
62
final int SYMBOL_ABSTRACTPROPERTY = 27; // <AbstractProperty>
63
final int SYMBOL_AND2 = 28; // <And>
64
final int SYMBOL_ATOMICPROPOSITION = 29; // <AtomicProposition>
65
final int SYMBOL_EXPR = 30; // <Expr>
66
final int SYMBOL_FACTOR = 31; // <Factor>
67
final int SYMBOL_NOT2 = 32; // <Not>
68
final int SYMBOL_OR2 = 33; // <Or>
72
public interface RuleConstants
74
final int RULE_ABSTRACTPROPERTY_EF = 0; // <AbstractProperty> ::= EF <Expr>
75
final int RULE_ABSTRACTPROPERTY_ELTGT = 1; // <AbstractProperty> ::= 'E<>' <Expr>
76
final int RULE_ABSTRACTPROPERTY_EG = 2; // <AbstractProperty> ::= EG <Expr>
77
final int RULE_ABSTRACTPROPERTY_ELBRACKETRBRACKET = 3; // <AbstractProperty> ::= 'E[]' <Expr>
78
final int RULE_ABSTRACTPROPERTY_AF = 4; // <AbstractProperty> ::= AF <Expr>
79
final int RULE_ABSTRACTPROPERTY_ALTGT = 5; // <AbstractProperty> ::= 'A<>' <Expr>
80
final int RULE_ABSTRACTPROPERTY_AG = 6; // <AbstractProperty> ::= AG <Expr>
81
final int RULE_ABSTRACTPROPERTY_ALBRACKETRBRACKET = 7; // <AbstractProperty> ::= 'A[]' <Expr>
82
final int RULE_EXPR = 8; // <Expr> ::= <Or>
83
final int RULE_OR_OR = 9; // <Or> ::= <Or> or <And>
84
final int RULE_OR_PIPEPIPE = 10; // <Or> ::= <Or> '||' <And>
85
final int RULE_OR = 11; // <Or> ::= <And>
86
final int RULE_AND_AND = 12; // <And> ::= <And> and <Not>
87
final int RULE_AND_AMPAMP = 13; // <And> ::= <And> '&&' <Not>
88
final int RULE_AND = 14; // <And> ::= <Not>
89
final int RULE_NOT_NOT_LPARAN_RPARAN = 15; // <Not> ::= not '(' <Expr> ')'
90
final int RULE_NOT_EXCLAM_LPARAN_RPARAN = 16; // <Not> ::= '!' '(' <Expr> ')'
91
final int RULE_NOT = 17; // <Not> ::= <Factor>
92
final int RULE_FACTOR = 18; // <Factor> ::= <AtomicProposition>
93
final int RULE_FACTOR_LPARAN_RPARAN = 19; // <Factor> ::= '(' <Expr> ')'
94
final int RULE_ATOMICPROPOSITION_IDENTIFIER_LT_NUM = 20; // <AtomicProposition> ::= Identifier '<' Num
95
final int RULE_ATOMICPROPOSITION_IDENTIFIER_LTEQ_NUM = 21; // <AtomicProposition> ::= Identifier '<=' Num
96
final int RULE_ATOMICPROPOSITION_IDENTIFIER_EQ_NUM = 22; // <AtomicProposition> ::= Identifier '=' Num
97
final int RULE_ATOMICPROPOSITION_IDENTIFIER_EQEQ_NUM = 23; // <AtomicProposition> ::= Identifier '==' Num
98
final int RULE_ATOMICPROPOSITION_IDENTIFIER_GTEQ_NUM = 24; // <AtomicProposition> ::= Identifier '>=' Num
99
final int RULE_ATOMICPROPOSITION_IDENTIFIER_GT_NUM = 25; // <AtomicProposition> ::= Identifier '>' Num
30
public class TAPAALQueryParser implements GPMessageConstants {
32
private static final String ERROR_PARSING_QUERY_MESSAGE = "TAPAAL countered an error trying to parse the query";
34
public interface SymbolConstants {
35
final int SYMBOL_EOF = 0; // (EOF)
36
final int SYMBOL_ERROR = 1; // (Error)
37
final int SYMBOL_WHITESPACE = 2; // (Whitespace)
38
final int SYMBOL_EXCLAM = 3; // '!'
39
final int SYMBOL_AMPAMP = 4; // '&&'
40
final int SYMBOL_LPARAN = 5; // '('
41
final int SYMBOL_RPARAN = 6; // ')'
42
final int SYMBOL_DOT = 7; // '.'
43
final int SYMBOL_PIPEPIPE = 8; // '||'
44
final int SYMBOL_LT = 9; // '<'
45
final int SYMBOL_LTEQ = 10; // '<='
46
final int SYMBOL_EQ = 11; // '='
47
final int SYMBOL_EQEQ = 12; // '=='
48
final int SYMBOL_GT = 13; // '>'
49
final int SYMBOL_GTEQ = 14; // '>='
50
final int SYMBOL_ALBRACKETRBRACKET = 15; // 'A[]'
51
final int SYMBOL_ALTGT = 16; // 'A<>'
52
final int SYMBOL_AF = 17; // AF
53
final int SYMBOL_AG = 18; // AG
54
final int SYMBOL_AND = 19; // and
55
final int SYMBOL_ELBRACKETRBRACKET = 20; // 'E[]'
56
final int SYMBOL_ELTGT = 21; // 'E<>'
57
final int SYMBOL_EF = 22; // EF
58
final int SYMBOL_EG = 23; // EG
59
final int SYMBOL_IDENTIFIER = 24; // Identifier
60
final int SYMBOL_NOT = 25; // not
61
final int SYMBOL_NUM = 26; // Num
62
final int SYMBOL_OR = 27; // or
63
final int SYMBOL_ABSTRACTPROPERTY = 28; // <AbstractProperty>
64
final int SYMBOL_AND2 = 29; // <And>
65
final int SYMBOL_ATOMICPROPOSITION1 = 30; // <AtomicProposition1>
66
final int SYMBOL_ATOMICPROPOSITION2 = 31; // <AtomicProposition2>
67
final int SYMBOL_EXPR = 32; // <Expr>
68
final int SYMBOL_FACTOR = 33; // <Factor>
69
final int SYMBOL_NOT2 = 34; // <Not>
70
final int SYMBOL_OR2 = 35; // <Or>
73
public interface RuleConstants {
74
final int RULE_ABSTRACTPROPERTY_EF = 0; // <AbstractProperty> ::= EF <Expr>
75
final int RULE_ABSTRACTPROPERTY_ELTGT = 1; // <AbstractProperty> ::= 'E<>' <Expr>
76
final int RULE_ABSTRACTPROPERTY_EG = 2; // <AbstractProperty> ::= EG <Expr>
77
final int RULE_ABSTRACTPROPERTY_ELBRACKETRBRACKET = 3; // <AbstractProperty> ::= 'E[]' <Expr>
78
final int RULE_ABSTRACTPROPERTY_AF = 4; // <AbstractProperty> ::= AF <Expr>
79
final int RULE_ABSTRACTPROPERTY_ALTGT = 5; // <AbstractProperty> ::= 'A<>' <Expr>
80
final int RULE_ABSTRACTPROPERTY_AG = 6; // <AbstractProperty> ::= AG <Expr>
81
final int RULE_ABSTRACTPROPERTY_ALBRACKETRBRACKET = 7; // <AbstractProperty> ::= 'A[]' <Expr>
82
final int RULE_EXPR = 8; // <Expr> ::= <Or>
83
final int RULE_OR_OR = 9; // <Or> ::= <Or> or <And>
84
final int RULE_OR_PIPEPIPE = 10; // <Or> ::= <Or> '||' <And>
85
final int RULE_OR = 11; // <Or> ::= <And>
86
final int RULE_AND_AND = 12; // <And> ::= <And> and <Not>
87
final int RULE_AND_AMPAMP = 13; // <And> ::= <And> '&&' <Not>
88
final int RULE_AND = 14; // <And> ::= <Not>
89
final int RULE_NOT_NOT_LPARAN_RPARAN = 15; // <Not> ::= not '(' <Expr>
91
final int RULE_NOT_EXCLAM_LPARAN_RPARAN = 16; // <Not> ::= '!' '(' <Expr> ')'
92
final int RULE_NOT = 17; // <Not> ::= <Factor>
93
final int RULE_FACTOR = 18; // <Factor> ::= <AtomicProposition1>
94
final int RULE_FACTOR2 = 19; // <Factor> ::= <AtomicProposition2>
95
final int RULE_FACTOR_LPARAN_RPARAN = 20; // <Factor> ::= '(' <Expr> ')'
96
final int RULE_ATOMICPROPOSITION1_IDENTIFIER_LT_NUM = 21; // <AtomicProposition1> ::= Identifier '<' Num
97
final int RULE_ATOMICPROPOSITION1_IDENTIFIER_LTEQ_NUM = 22; // <AtomicProposition1> ::= Identifier '<=' Num
98
final int RULE_ATOMICPROPOSITION1_IDENTIFIER_EQ_NUM = 23; // <AtomicProposition1> ::= Identifier '=' Num
99
final int RULE_ATOMICPROPOSITION1_IDENTIFIER_EQEQ_NUM = 24; // <AtomicProposition1> ::= Identifier '==' Num
100
final int RULE_ATOMICPROPOSITION1_IDENTIFIER_GTEQ_NUM = 25; // <AtomicProposition1> ::= Identifier '>=' Num
101
final int RULE_ATOMICPROPOSITION1_IDENTIFIER_GT_NUM = 26; // <AtomicProposition1> ::= Identifier '>' Num
102
final int RULE_ATOMICPROPOSITION2_IDENTIFIER_DOT = 27; // <AtomicProposition2> ::= Identifier '.' <AtomicProposition1>
103
105
private Stack<TCTLAbstractStateProperty> parseStack;
105
107
/***************************************************************
106
* This class will run the engine, and needs a file called config.dat
107
* in the current directory. This file should contain two lines,
108
* The first should be the absolute path name to the .cgt file, the second
109
* should be the source file you wish to parse.
110
* @param text Array of arguments.
108
* This class will run the engine, and needs a file called config.dat in the
109
* current directory. This file should contain two lines, The first should
110
* be the absolute path name to the .cgt file, the second should be the
111
* source file you wish to parse.
114
* Array of arguments.
112
* @throws IOException
116
* @throws IOException
113
117
***************************************************************/
114
public TCTLAbstractProperty parse(String query) throws ParseException
118
public TCTLAbstractProperty parse(String query) throws ParseException {
117
120
String textToParse = query, compiledGrammar = this.getClass().getResource("/dk/aau/cs/TCTL/Parsing/TAPAALQuery.cgt").getFile();
119
122
GOLDParser parser = new GOLDParser();
121
124
parseStack = new Stack<TCTLAbstractStateProperty>();
128
130
parser.loadCompiledGrammar(compiledGrammar);
130
// put the text to parse in a temp file since parser requires it to be in a file
132
// put the text to parse in a temp file since parser requires it to
131
134
temp = File.createTempFile("queryToParse", ".q");
132
135
temp.deleteOnExit();
133
PrintStream out = new PrintStream(temp);
136
PrintStream out = new PrintStream(temp);
134
137
out.append(textToParse);
135
138
out.append("\n");
138
141
// open temp file
139
142
parser.openFile(temp.getPath());
140
// parser.openFile("/home/lassejac/Desktop/test_queries/test");
142
catch(ParserException parse)
143
// parser.openFile("/home/lassejac/Desktop/test_queries/test");
144
} catch (ParserException parse) {
144
145
System.out.println("**PARSER ERROR**\n" + parse.toString());
146
147
} catch (IOException e) {
153
154
int response = -1;
154
155
TCTLAbstractProperty root = null;
161
159
response = parser.parse();
163
catch(ParserException parse)
160
} catch (ParserException parse) {
165
161
System.out.println("**PARSER ERROR**\n" + parse.toString());
171
166
case gpMsgTokenRead:
172
/* A token was read by the parser. The Token Object can be accessed
173
through the CurrentToken() property: Parser.CurrentToken */
168
* A token was read by the parser. The Token Object can be
169
* accessed through the CurrentToken() property:
170
* Parser.CurrentToken
176
174
case gpMsgReduction:
177
/* This message is returned when a rule was reduced by the parse engine.
178
The CurrentReduction property is assigned a Reduction object
179
containing the rule and its related tokens. You can reassign this
180
property to your own customized class. If this is not the case,
181
this message can be ignored and the Reduction object will be used
182
to store the parse tree. */
184
switch(parser.currentReduction().getParentRule().getTableIndex())
176
* This message is returned when a rule was reduced by the parse
177
* engine. The CurrentReduction property is assigned a Reduction
178
* object containing the rule and its related tokens. You can
179
* reassign this property to your own customized class. If this
180
* is not the case, this message can be ignored and the
181
* Reduction object will be used to store the parse tree.
184
switch (parser.currentReduction().getParentRule()
187
187
case RuleConstants.RULE_ABSTRACTPROPERTY_EF: // <AbstractProperty> ::= EF <Expr>
188
case RuleConstants.RULE_ABSTRACTPROPERTY_ELTGT: // <AbstractProperty> ::= 'E<>' <Expr>
188
case RuleConstants.RULE_ABSTRACTPROPERTY_ELTGT: // <AbstractProperty> ::= 'E<>' <Expr>
189
189
root = new TCTLEFNode(parseStack.pop());
191
case RuleConstants.RULE_ABSTRACTPROPERTY_EG: // <AbstractProperty> ::= EG <Expr>
192
case RuleConstants.RULE_ABSTRACTPROPERTY_ELBRACKETRBRACKET: // <AbstractProperty> ::= 'E[]' <Expr>
191
case RuleConstants.RULE_ABSTRACTPROPERTY_EG: // <AbstractProperty> ::= EG <Expr>
192
case RuleConstants.RULE_ABSTRACTPROPERTY_ELBRACKETRBRACKET: // <AbstractProperty> ::= 'E[]' <Expr>
193
193
root = new TCTLEGNode(parseStack.pop());
195
case RuleConstants.RULE_ABSTRACTPROPERTY_AF: // <AbstractProperty> ::= AF <Expr>
196
case RuleConstants.RULE_ABSTRACTPROPERTY_ALTGT: // <AbstractProperty> ::= 'A<>' <Expr>
195
case RuleConstants.RULE_ABSTRACTPROPERTY_AF: // <AbstractProperty> ::= AF <Expr>
196
case RuleConstants.RULE_ABSTRACTPROPERTY_ALTGT: // <AbstractProperty> ::= 'A<>' <Expr>
197
197
root = new TCTLAFNode(parseStack.pop());
199
case RuleConstants.RULE_ABSTRACTPROPERTY_AG: // <AbstractProperty> ::= AG <Expr>
199
case RuleConstants.RULE_ABSTRACTPROPERTY_AG: // <AbstractProperty>::= AG <Expr>
200
200
case RuleConstants.RULE_ABSTRACTPROPERTY_ALBRACKETRBRACKET: // <AbstractProperty> ::= 'A[]' <Expr>
201
201
root = new TCTLAGNode(parseStack.pop());
204
204
case RuleConstants.RULE_OR_OR: // <Or> ::= <Or> or <And>
205
case RuleConstants.RULE_OR_PIPEPIPE: // <Or> ::= <Or> '||' <And>
205
case RuleConstants.RULE_OR_PIPEPIPE: // <Or> ::= <Or> '||' <And>
206
206
TCTLAbstractStateProperty orProp2 = parseStack.pop();
207
207
TCTLAbstractStateProperty orProp1 = parseStack.pop();
208
208
ArrayList<TCTLAbstractStateProperty> disjunctions = new ArrayList<TCTLAbstractStateProperty>();
209
if(orProp1 instanceof TCTLOrListNode) {
210
TCTLOrListNode node1 = (TCTLOrListNode)orProp1;
209
if (orProp1 instanceof TCTLOrListNode) {
210
TCTLOrListNode node1 = (TCTLOrListNode) orProp1;
212
212
for (TCTLAbstractStateProperty p : node1.getProperties()) {
213
213
disjunctions.add(p);
217
216
disjunctions.add(orProp1);
220
if(orProp2 instanceof TCTLOrListNode) {
221
TCTLOrListNode node2 = (TCTLOrListNode)orProp2;
219
if (orProp2 instanceof TCTLOrListNode) {
220
TCTLOrListNode node2 = (TCTLOrListNode) orProp2;
223
222
for (TCTLAbstractStateProperty p : node2.getProperties()) {
224
223
disjunctions.add(p);
228
226
disjunctions.add(orProp2);
230
228
TCTLOrListNode orListNode = new TCTLOrListNode(disjunctions);
231
229
parseStack.push(orListNode);
234
232
case RuleConstants.RULE_AND_AND: // <And> ::= <And> and <Not>
235
case RuleConstants.RULE_AND_AMPAMP: // <And> ::= <And> '&&' <Not>
233
case RuleConstants.RULE_AND_AMPAMP: // <And> ::= <And> '&&'
236
235
TCTLAbstractStateProperty andProp2 = parseStack.pop();
237
236
TCTLAbstractStateProperty andProp1 = parseStack.pop();
238
237
ArrayList<TCTLAbstractStateProperty> conjunctions = new ArrayList<TCTLAbstractStateProperty>();
239
if(andProp1 instanceof TCTLAndListNode) {
240
TCTLAndListNode node1 = (TCTLAndListNode)andProp1;
238
if (andProp1 instanceof TCTLAndListNode) {
239
TCTLAndListNode node1 = (TCTLAndListNode) andProp1;
242
241
for (TCTLAbstractStateProperty p : node1.getProperties()) {
243
242
conjunctions.add(p);
247
245
conjunctions.add(andProp1);
250
if(andProp2 instanceof TCTLAndListNode) {
251
TCTLAndListNode node2 = (TCTLAndListNode)andProp2;
248
if (andProp2 instanceof TCTLAndListNode) {
249
TCTLAndListNode node2 = (TCTLAndListNode) andProp2;
253
251
for (TCTLAbstractStateProperty p : node2.getProperties()) {
254
252
conjunctions.add(p);
258
255
conjunctions.add(andProp2);
260
257
TCTLAndListNode andListNode = new TCTLAndListNode(conjunctions);
266
263
TCTLNotNode notNode = new TCTLNotNode(parseStack.pop());
267
264
parseStack.push(notNode);
270
267
case RuleConstants.RULE_EXPR: // <Expr> ::= <Or>
271
268
case RuleConstants.RULE_OR: // <Or> ::= <And>
272
269
case RuleConstants.RULE_AND: // <And> ::= <Not>
273
270
case RuleConstants.RULE_NOT: // <Not> ::= <Factor>
274
271
case RuleConstants.RULE_FACTOR: // <Factor> ::= <AtomicProposition>
275
case RuleConstants.RULE_FACTOR_LPARAN_RPARAN: // <Factor> ::= '(' <Expr> ')'
272
case RuleConstants.RULE_FACTOR2:
273
case RuleConstants.RULE_FACTOR_LPARAN_RPARAN: // <Factor> ::= '(' <Expr>')'
277
case RuleConstants.RULE_ATOMICPROPOSITION_IDENTIFIER_LT_NUM: // <AtomicProposition> ::= Identifier '<' Num
278
case RuleConstants.RULE_ATOMICPROPOSITION_IDENTIFIER_LTEQ_NUM: // <AtomicProposition> ::= Identifier '<=' Num
279
case RuleConstants.RULE_ATOMICPROPOSITION_IDENTIFIER_EQ_NUM: // <AtomicProposition> ::= Identifier '=' Num
280
case RuleConstants.RULE_ATOMICPROPOSITION_IDENTIFIER_EQEQ_NUM: // <AtomicProposition> ::= Identifier '==' Num
281
case RuleConstants.RULE_ATOMICPROPOSITION_IDENTIFIER_GTEQ_NUM: // <AtomicProposition> ::= Identifier '>=' Num
282
case RuleConstants.RULE_ATOMICPROPOSITION_IDENTIFIER_GT_NUM: // <AtomicProposition> ::= Identifier '>' Num
283
String place = (String)createObjectFromTerminal(parser.currentReduction().getToken(0));
284
String op = (String)createObjectFromTerminal(parser.currentReduction().getToken(1));
285
Integer n = (Integer)createObjectFromTerminal(parser.currentReduction().getToken(2));
276
case RuleConstants.RULE_ATOMICPROPOSITION1_IDENTIFIER_LT_NUM: // <AtomicProposition> ::= Identifier '<' Num
277
case RuleConstants.RULE_ATOMICPROPOSITION1_IDENTIFIER_LTEQ_NUM: // <AtomicProposition> ::= Identifier '<=' Num
278
case RuleConstants.RULE_ATOMICPROPOSITION1_IDENTIFIER_EQ_NUM: // <AtomicProposition> ::= Identifier '=' Num
279
case RuleConstants.RULE_ATOMICPROPOSITION1_IDENTIFIER_EQEQ_NUM: // <AtomicProposition> ::= Identifier '==' Num
280
case RuleConstants.RULE_ATOMICPROPOSITION1_IDENTIFIER_GTEQ_NUM: // <AtomicProposition> ::= Identifier '>=' Num
281
case RuleConstants.RULE_ATOMICPROPOSITION1_IDENTIFIER_GT_NUM: // <AtomicProposition> ::= Identifier '>' Num
282
String place = (String) createObjectFromTerminal(parser.currentReduction().getToken(0));
283
String op = (String) createObjectFromTerminal(parser.currentReduction().getToken(1));
284
Integer n = (Integer) createObjectFromTerminal(parser.currentReduction().getToken(2));
286
285
parseStack.push(new TCTLAtomicPropositionNode(place, op, n));
287
case RuleConstants.RULE_ATOMICPROPOSITION2_IDENTIFIER_DOT: // <AtomicProposition> ::= Identifier '.' <AtomicProposition1>
288
TCTLAtomicPropositionNode node = (TCTLAtomicPropositionNode) parseStack.pop();
289
String template = (String) createObjectFromTerminal(parser.currentReduction().getToken(0));
290
node.setTemplate(template);
291
parseStack.push(node);
291
// // ************************************** log file
292
// System.out.println("gpMsgReduction");
293
// Reduction myRed = parser.currentReduction();
294
// System.out.println(myRed.getParentRule().getText());
295
// // ************************************** end log
295
// // ************************************** log file
296
// System.out.println("gpMsgReduction");
297
// Reduction myRed = parser.currentReduction();
298
// System.out.println(myRed.getParentRule().getText());
299
// // ************************************** end log
299
303
case gpMsgAccept:
300
304
/* The program was accepted by the parsing engine */
302
// // ************************************** log file
303
// System.out.println("gpMsgAccept");
304
// // ************************************** end log
306
// // ************************************** log file
307
// System.out.println("gpMsgAccept");
308
// // ************************************** end log
310
case gpMsgLexicalError:
311
/* Place code here to handle a illegal or unrecognized token
312
To recover, pop the token from the stack: Parser.PopInputToken */
314
// // ************************************** log file
315
// System.out.println("gpMsgLexicalError");
316
// // ************************************** end log
318
parser.popInputToken();
322
314
case gpMsgNotLoadedError:
323
315
/* Load the Compiled Grammar Table file first. */
325
// // ************************************** log file
326
// System.out.println("gpMsgNotLoadedError");
327
// // ************************************** end log
317
// // ************************************** log file
318
// System.out.println("gpMsgNotLoadedError");
319
// // ************************************** end log
329
throw new ParseException("TAPAAL countered an error trying to parse the query", 0);
321
throw new ParseException(ERROR_PARSING_QUERY_MESSAGE,0);
322
case gpMsgLexicalError: /* Place code here to handle a illegal or unrecognized token To recover, pop the token from the stack: Parser.PopInputToken */
331
323
case gpMsgSyntaxError:
332
/* This is a syntax error: the source has produced a token that was
333
not expected by the LALR State Machine. The expected tokens are stored
334
into the Tokens() list. To recover, push one of the
335
expected tokens onto the parser's input queue (the first in this case):
336
You should limit the number of times this type of recovery can take
325
* This is a syntax error: the source has produced a token that
326
* was not expected by the LALR State Machine. The expected
327
* tokens are stored into the Tokens() list. To recover, push
328
* one of the expected tokens onto the parser's input queue (the
329
* first in this case): You should limit the number of times
330
* this type of recovery can take place.
339
333
Token theTok = parser.currentToken();
340
System.out.println("Token not expected: " + (String)theTok.getData());
341
throw new ParseException("TAPAAL countered an error trying to parse the query", 0);
343
// // ************************************** log file
344
// System.out.println("gpMsgSyntaxError");
345
// // ************************************** end log
334
System.out.println("Token not expected: "+ (String) theTok.getData());
335
throw new ParseException(ERROR_PARSING_QUERY_MESSAGE,0);
337
// // ************************************** log file
338
// System.out.println("gpMsgSyntaxError");
339
// // ************************************** end log
347
341
case gpMsgCommentError:
348
/* The end of the input was reached while reading a comment.
349
This is caused by a comment that was not terminated */
343
* The end of the input was reached while reading a comment.
344
* This is caused by a comment that was not terminated
351
// // ************************************** log file
352
// System.out.println("gpMsgCommentError");
353
// // ************************************** end log
347
// // ************************************** log file
348
// System.out.println("gpMsgCommentError");
349
// // ************************************** end log
359
355
case gpMsgInternalError:
360
/* Something horrid happened inside the parser. You cannot recover */
357
* Something horrid happened inside the parser. You cannot
362
// // ************************************** log file
363
// System.out.println("gpMsgInternalError");
364
// // ************************************** end log
361
// // ************************************** log file
362
// System.out.println("gpMsgInternalError");
363
// // ************************************** end log
366
throw new ParseException("TAPAAL countered an error trying to parse the query", 0);
365
throw new ParseException(ERROR_PARSING_QUERY_MESSAGE,0);
373
370
parser.closeFile();
375
catch(ParserException parse)
371
} catch (ParserException parse) {
377
372
System.out.println("**PARSER ERROR**\n" + parse.toString());