Advanced Strategic Command
parser.cpp
Go to the documentation of this file.
1 // Generated by Bisonc++ V2.4.2 on Sat Jul 26 23:16:51 2008 +0100
2 
3 // $insert class.ih
4 #include "parser.ih"
5 
6 // The FIRST element of SR arrays shown below uses `d_type', defining the
7 // state's type, and `d_lastIdx' containing the last element's index. If
8 // d_lastIdx contains the REQ_TOKEN bitflag (see below) then the state needs
9 // a token: if in this state d_token__ is _UNDETERMINED_, nextToken() will be
10 // called
11 
12 // The LAST element of SR arrays uses `d_token' containing the last retrieved
13 // token to speed up the (linear) seach. Except for the first element of SR
14 // arrays, the field `d_action' is used to determine what to do next. If
15 // positive, it represents the next state (used with SHIFT); if zero, it
16 // indicates `ACCEPT', if negative, -d_action represents the number of the
17 // rule to reduce to.
18 
19 // `lookup()' tries to find d_token__ in the current SR array. If it fails, and
20 // there is no default reduction UNEXPECTED_TOKEN__ is thrown, which is then
21 // caught by the error-recovery function.
22 
23 // The error-recovery function will pop elements off the stack until a state
24 // having bit flag ERR_ITEM is found. This state has a transition on _error_
25 // which is applied. In this _error_ state, while the current token is not a
26 // proper continuation, new tokens are obtained by nextToken(). If such a
27 // token is found, error recovery is successful and the token is
28 // handled according to the error state's SR table and parsing continues.
29 // During error recovery semantic actions are ignored.
30 
31 // A state flagged with the DEF_RED flag will perform a default
32 // reduction if no other continuations are available for the current token.
33 
34 // The ACCEPT STATE never shows a default reduction: when it is reached the
35 // parser returns ACCEPT(). During the grammar
36 // analysis phase a default reduction may have been defined, but it is
37 // removed during the state-definition phase.
38 
39 // So:
40 // s_x[] =
41 // {
42 // [_field_1_] [_field_2_]
43 //
44 // First element: {state-type, idx of last element},
45 // Other elements: {required token, action to perform},
46 // ( < 0: reduce,
47 // 0: ACCEPT,
48 // > 0: next state)
49 // Last element: {set to d_token__, action to perform}
50 // }
51 
52 // When the --thread-safe option is specified, all static data are defined as
53 // const. If --thread-safe is not provided, the state-tables are not defined
54 // as const, since the lookup() function below will modify them
55 
56 // $insert debugincludes
57 #include <iostream>
58 #include <sstream>
59 #include <string>
60 #include <map>
61 #include <iomanip>
62 
63 namespace // anonymous
64 {
65  char const author[] = "Frank B. Brokken (f.b.brokken@rug.nl)";
66 
67  enum
68  {
69  STACK_EXPANSION = 5 // size to expand the state-stack with when
70  // full
71  };
72 
74  {
75  PARSE_ACCEPT = 0, // `ACCEPT' TRANSITION
76  _UNDETERMINED_ = -2,
77  _EOF_ = -1,
78  _error_ = 256
79  };
80  enum StateType // modify statetype/data.cc when this enum changes
81  {
82  NORMAL,
83  ERR_ITEM,
84  REQ_TOKEN,
85  ERR_REQ, // ERR_ITEM | REQ_TOKEN
86  DEF_RED, // state having default reduction
87  ERR_DEF, // ERR_ITEM | DEF_RED
88  REQ_DEF, // REQ_TOKEN | DEF_RED
89  ERR_REQ_DEF // ERR_ITEM | REQ_TOKEN | DEF_RED
90  };
91  struct PI__ // Production Info
92  {
93  size_t d_nonTerm; // identification number of this production's
94  // non-terminal
95  size_t d_size; // number of elements in this production
96  };
97 
98  struct SR__ // Shift Reduce info, see its description above
99  {
100  union
101  {
102  int _field_1_; // initializer, allowing initializations
103  // of the SR s_[] arrays
104  int d_type;
105  int d_token;
106  };
107  union
108  {
109  int _field_2_;
110 
111  int d_lastIdx; // if negative, the state uses SHIFT
112  int d_action; // may be negative (reduce),
113  // postive (shift), or 0 (accept)
114  size_t d_errorState; // used with Error states
115  };
116  };
117 
118  // $insert staticdata
119 
120 // Productions Info Records:
121 PI__ const s_productionInfo[] =
122 {
123  {0, 0}, // not used: reduction values are negative
124  {260, 1}, // 1: asctextfile -> blocks
125  {261, 1}, // 2: blocks -> block
126  {261, 2}, // 3: blocks -> blocks block
127  {262, 1}, // 4: block -> testblock
128  {263, 5}, // 5: testblock -> TESTCASE '{' commands '}' TESTCASE
129  {264, 2}, // 6: commands -> command ';'
130  {264, 2}, // 7: commands -> commands command
131  {265, 1}, // 8: command -> MOVEUNIT
132  {265, 1}, // 9: command -> loadmapcommand
133  {266, 4}, // 10: loadmapcommand -> LOADMAP '(' filename ')'
134  {267, 0}, // 11: filename -> <empty>
135  {268, 1}, // 12: asctextfile_$ -> asctextfile
136 };
137 
138 // State info and SR__ transitions for each state.
139 
140 
141 SR__ const s_0[] =
142 {
143  { { REQ_TOKEN}, { 6} },
144  { { 260}, { 1} }, // asctextfile
145  { { 261}, { 2} }, // blocks
146  { { 262}, { 3} }, // block
147  { { 263}, { 4} }, // testblock
148  { { 259}, { 5} }, // TESTCASE
149  { { 0}, { 0} },
150 };
151 
152 SR__ const s_1[] =
153 {
154  { { REQ_TOKEN}, { 2} },
155  { { _EOF_}, { PARSE_ACCEPT} },
156  { { 0}, { 0} },
157 };
158 
159 SR__ const s_2[] =
160 {
161  { { REQ_DEF}, { 4} },
162  { { 262}, { 6} }, // block
163  { { 263}, { 4} }, // testblock
164  { { 259}, { 5} }, // TESTCASE
165  { { 0}, { -1} },
166 };
167 
168 SR__ const s_3[] =
169 {
170  { { DEF_RED}, { 1} },
171  { { 0}, { -2} },
172 };
173 
174 SR__ const s_4[] =
175 {
176  { { DEF_RED}, { 1} },
177  { { 0}, { -4} },
178 };
179 
180 SR__ const s_5[] =
181 {
182  { { REQ_TOKEN}, { 2} },
183  { { 123}, { 7} }, // '{'
184  { { 0}, { 0} },
185 };
186 
187 SR__ const s_6[] =
188 {
189  { { DEF_RED}, { 1} },
190  { { 0}, { -3} },
191 };
192 
193 SR__ const s_7[] =
194 {
195  { { REQ_TOKEN}, { 6} },
196  { { 264}, { 8} }, // commands
197  { { 265}, { 9} }, // command
198  { { 257}, { 10} }, // MOVEUNIT
199  { { 266}, { 11} }, // loadmapcommand
200  { { 258}, { 12} }, // LOADMAP
201  { { 0}, { 0} },
202 };
203 
204 SR__ const s_8[] =
205 {
206  { { REQ_TOKEN}, { 6} },
207  { { 125}, { 13} }, // '}'
208  { { 265}, { 14} }, // command
209  { { 257}, { 10} }, // MOVEUNIT
210  { { 266}, { 11} }, // loadmapcommand
211  { { 258}, { 12} }, // LOADMAP
212  { { 0}, { 0} },
213 };
214 
215 SR__ const s_9[] =
216 {
217  { { REQ_TOKEN}, { 2} },
218  { { 59}, { 15} }, // ';'
219  { { 0}, { 0} },
220 };
221 
222 SR__ const s_10[] =
223 {
224  { { DEF_RED}, { 1} },
225  { { 0}, { -8} },
226 };
227 
228 SR__ const s_11[] =
229 {
230  { { DEF_RED}, { 1} },
231  { { 0}, { -9} },
232 };
233 
234 SR__ const s_12[] =
235 {
236  { { REQ_TOKEN}, { 2} },
237  { { 40}, { 16} }, // '('
238  { { 0}, { 0} },
239 };
240 
241 SR__ const s_13[] =
242 {
243  { { REQ_TOKEN}, { 2} },
244  { { 259}, { 17} }, // TESTCASE
245  { { 0}, { 0} },
246 };
247 
248 SR__ const s_14[] =
249 {
250  { { DEF_RED}, { 1} },
251  { { 0}, { -7} },
252 };
253 
254 SR__ const s_15[] =
255 {
256  { { DEF_RED}, { 1} },
257  { { 0}, { -6} },
258 };
259 
260 SR__ const s_16[] =
261 {
262  { { DEF_RED}, { 2} },
263  { { 267}, { 18} }, // filename
264  { { 0}, { -11} },
265 };
266 
267 SR__ const s_17[] =
268 {
269  { { DEF_RED}, { 1} },
270  { { 0}, { -5} },
271 };
272 
273 SR__ const s_18[] =
274 {
275  { { REQ_TOKEN}, { 2} },
276  { { 41}, { 19} }, // ')'
277  { { 0}, { 0} },
278 };
279 
280 SR__ const s_19[] =
281 {
282  { { DEF_RED}, { 1} },
283  { { 0}, { -10} },
284 };
285 
286 
287 // State array:
288 SR__ const *s_state[] =
289 {
290  s_0, s_1, s_2, s_3, s_4, s_5, s_6, s_7, s_8, s_9,
291  s_10, s_11, s_12, s_13, s_14, s_15, s_16, s_17, s_18, s_19,
292 };
293 
294 typedef std::map<int, char const *> SMap;
295 typedef SMap::value_type SMapVal;
296 
297 SMapVal s_symArr[] =
298 {
299  SMapVal(-2, "_UNDETERMINED_"), // predefined symbols
300  SMapVal(-1, "_EOF_"),
301  SMapVal(256, "_error_"),
302 
303  SMapVal(257, "MOVEUNIT"),
304  SMapVal(258, "LOADMAP"),
305  SMapVal(259, "TESTCASE"),
306  SMapVal(260, "asctextfile"),
307  SMapVal(261, "blocks"),
308  SMapVal(262, "block"),
309  SMapVal(263, "testblock"),
310  SMapVal(264, "commands"),
311  SMapVal(265, "command"),
312  SMapVal(266, "loadmapcommand"),
313  SMapVal(267, "filename"),
314  SMapVal(268, "asctextfile_$"),
315 };
316 
317 SMap s_symbol
318 (
319  s_symArr, s_symArr + sizeof(s_symArr) / sizeof(SMapVal)
320 );
321 
322 } // anonymous namespace ends
323 
324 
325 
326 // If the parsing function call uses arguments, then provide an overloaded
327 // function. The code below doesn't rely on parameters, so no arguments are
328 // required. Furthermore, parse uses a function try block to allow us to do
329 // ACCEPT and ABORT from anywhere, even from within members called by actions,
330 // simply throwing the appropriate exceptions.
331 
332 ParserBase::ParserBase()
333 :
334  d_stackIdx__(-1),
335  // $insert debuginit
336  d_debug__(true),
337  d_nErrors__(0),
338  // $insert requiredtokens
339  d_requiredTokens__(0),
340  d_acceptedTokens__(d_requiredTokens__),
341  d_token__(_UNDETERMINED_),
342  d_nextToken__(_UNDETERMINED_)
343 {}
344 
345 // $insert debugfunctions
346 
347 std::ostringstream ParserBase::s_out__;
348 
349 std::ostream &ParserBase::dflush(std::ostream &out)
350 {
351  std::ostringstream &s_out__ = dynamic_cast<std::ostringstream &>(out);
352 
353  std::cout << " " << s_out__.str() << std::flush;
354  s_out__.clear();
355  s_out__.str("");
356  return out;
357 }
358 
359 std::string ParserBase::symbol(int value) const
360 {
361  using namespace std;
362  ostringstream ostr;
363  SMap::const_iterator it = s_symbol.find(value);
364  if (it != s_symbol.end())
365  ostr << "`" << it->second << "'";
366  else if (isprint(value))
367  ostr << "`" << static_cast<char>(value) << "' (" << value << ")";
368  else
369  ostr << "'\\x" << setfill('0') << hex << setw(2) << value << "'";
370  return ostr.str();
371 }
372 
373 std::string ParserBase::stype__(char const *pre, STYPE__ const &semVal, char const *post) const
374 {
375  return "";
376 }
377 
378 void ParserBase::clearin()
379 {
380  d_token__ = d_nextToken__ = _UNDETERMINED_;
381 }
382 
383 void ParserBase::push__(size_t state)
384 {
385  if (static_cast<size_t>(d_stackIdx__ + 1) == d_stateStack__.size())
386  {
387  size_t newSize = d_stackIdx__ + STACK_EXPANSION;
388  d_stateStack__.resize(newSize);
389  d_valueStack__.resize(newSize);
390  }
391  ++d_stackIdx__;
392  d_stateStack__[d_stackIdx__] = d_state__ = state;
393  *(d_vsp__ = &d_valueStack__[d_stackIdx__]) = d_val__;
394  // $insert debug
395  if (d_debug__)
396  s_out__ << "push(state " << state << stype__(", semantic TOS = ", d_val__, ")") << ')' << "\n" << dflush;
397 }
398 
399 void ParserBase::popToken__()
400 {
401  d_token__ = d_nextToken__;
402 
403  d_val__ = d_nextVal__;
404  d_nextVal__ = STYPE__();
405 
406  d_nextToken__ = _UNDETERMINED_;
407 }
408 
409 void ParserBase::pushToken__(int token)
410 {
411  d_nextToken__ = d_token__;
412  d_nextVal__ = d_val__;
413  d_token__ = token;
414 }
415 
416 void ParserBase::pop__(size_t count)
417 {
418  // $insert debug
419  if (d_debug__)
420  s_out__ << "pop(" << count << ") from stack having size " << (d_stackIdx__ + 1) << "\n" << dflush;
421  if (d_stackIdx__ < static_cast<int>(count))
422  {
423  // $insert debug
424  if (d_debug__)
425  s_out__ << "Terminating parse(): unrecoverable input error at token " << symbol(d_token__) << "\n" << dflush;
426  ABORT();
427  }
428 
429  d_stackIdx__ -= count;
430  d_state__ = d_stateStack__[d_stackIdx__];
431  d_vsp__ = &d_valueStack__[d_stackIdx__];
432  // $insert debug
433  if (d_debug__)
434  s_out__ << "pop(): next state: " << d_state__ << ", token: " << symbol(d_token__) ;
435  // $insert debug
436  if (d_debug__)
437  s_out__ << stype__("semantic: ", d_val__) << "\n" << dflush;
438 }
439 
440 inline size_t ParserBase::top__() const
441 {
442  return d_stateStack__[d_stackIdx__];
443 }
444 
445 void Parser::executeAction(int production)
446 {
447  if (d_token__ != _UNDETERMINED_)
448  pushToken__(d_token__); // save an already available token
449 
450  // save default non-nested block $$
451  if (int size = s_productionInfo[production].d_size)
452  d_val__ = d_vsp__[1 - size];
453 
454  // $insert debug
455  if (d_debug__)
456  s_out__ << "executeAction(): of rule " << production ;
457  // $insert debug
458  if (d_debug__)
459  s_out__ << stype__(", semantic [TOS]: ", d_val__) << " ..." << "\n" << dflush;
460  switch (production)
461  {
462  // $insert actioncases
463 
464  }
465  // $insert debug
466  if (d_debug__)
467  s_out__ << "... action of rule " << production << " completed" ;
468  // $insert debug
469  if (d_debug__)
470  s_out__ << stype__(", semantic: ", d_val__) << "\n" << dflush;
471 }
472 
473 inline void ParserBase::reduce__(PI__ const &pi)
474 {
475  d_token__ = pi.d_nonTerm;
476  pop__(pi.d_size);
477 
478  // $insert debug
479  if (d_debug__)
480  s_out__ << "reduce(): by rule " << (&pi - s_productionInfo) ;
481  // $insert debug
482  if (d_debug__)
483  s_out__ << " to N-terminal " << symbol(d_token__) << stype__(", semantic = ", d_val__) << "\n" << dflush;
484 }
485 
486 // If d_token__ is _UNDETERMINED_ then if d_nextToken__ is _UNDETERMINED_ another
487 // token is obtained from lex(). Then d_nextToken__ is assigned to d_token__.
488 void Parser::nextToken()
489 {
490  if (d_token__ != _UNDETERMINED_) // no need for a token: got one
491  return; // already
492 
493  if (d_nextToken__ != _UNDETERMINED_)
494  {
495  popToken__(); // consume pending token
496  // $insert debug
497  if (d_debug__)
498  s_out__ << "nextToken(): popped " << symbol(d_token__) << stype__(", semantic = ", d_val__) << "\n" << dflush;
499  }
500  else
501  {
502  ++d_acceptedTokens__; // accept another token (see
503  // errorRecover())
504  d_token__ = lex();
505  if (d_token__ <= 0)
506  d_token__ = _EOF_;
507  }
508  print();
509  // $insert debug
510  if (d_debug__)
511  s_out__ << "nextToken(): using " << symbol(d_token__) << stype__(", semantic = ", d_val__) << "\n" << dflush;
512 }
513 
514 // if the final transition is negative, then we should reduce by the rule
515 // given by its positive value. Note that the `recovery' parameter is only
516 // used with the --debug option
517 int Parser::lookup(bool recovery)
518 {
519  // $insert threading
520  SR__ const *sr = s_state[d_state__]; // get the appropriate state-table
521  int lastIdx = sr->d_lastIdx; // sentinel-index in the SR_ array
522 
523  SR__ const *lastElementPtr = sr + lastIdx;
524  SR__ const *elementPtr = sr + 1; // start the search at s_xx[1]
525 
526  while (elementPtr != lastElementPtr && elementPtr->d_token != d_token__)
527  ++elementPtr;
528 
529  if (elementPtr == lastElementPtr) // reached the last element
530  {
531  if (elementPtr->d_action < 0) // default reduction
532  {
533  // $insert debug
534  if (d_debug__)
535  s_out__ << "lookup(" << d_state__ << ", " << symbol(d_token__) ;
536  // $insert debug
537  if (d_debug__)
538  s_out__ << "): default reduction by rule " << -elementPtr->d_action << "\n" << dflush;
539  return elementPtr->d_action;
540  }
541  // $insert debug
542  if (d_debug__)
543  s_out__ << "lookup(" << d_state__ << ", " << symbol(d_token__) << "): Not " ;
544  // $insert debug
545  if (d_debug__)
546  s_out__ << "found. " << (recovery ? "Continue" : "Start") << " error recovery." << "\n" << dflush;
547 
548  // No default reduction, so token not found, so error.
549  throw UNEXPECTED_TOKEN__;
550  }
551 
552  // not at the last element: inspect the nature of the action
553  // (< 0: reduce, 0: ACCEPT, > 0: shift)
554 
555  int action = elementPtr->d_action;
556 
557 // $insert debuglookup
558  if (d_debug__)
559  {
560  s_out__ << "lookup(" << d_state__ << ", " << symbol(d_token__);
561 
562  if (action < 0) // a reduction is found
563  s_out__ << "): reduce by rule " << -action;
564  else if (action == 0)
565  s_out__ << "): ACCEPT";
566  else
567  s_out__ << "): shift " << action << " (" << symbol(d_token__) <<
568  " processed)";
569 
570  s_out__ << "\n" << dflush;
571  }
572 
573  return action;
574 }
575 
576  // When an error has occurred, pop elements off the stack until the top
577  // state has an error-item. If none is found, the default recovery
578  // mode (which is to abort) is activated.
579  //
580  // If EOF is encountered without being appropriate for the current state,
581  // then the error recovery will fall back to the default recovery mode.
582  // (i.e., parsing terminates)
583 void Parser::errorRecovery()
584 try
585 {
586  if (d_acceptedTokens__ >= d_requiredTokens__)// only generate an error-
587  { // message if enough tokens
588  ++d_nErrors__; // were accepted. Otherwise
589  error("Syntax error"); // simply skip input
590 
591  }
592 
593  // $insert debug
594  if (d_debug__)
595  s_out__ << "errorRecovery(): " << d_nErrors__ << " error(s) so far. State = " << top__() << "\n" << dflush;
596 
597  // get the error state
598  while (not (s_state[top__()][0].d_type & ERR_ITEM))
599  {
600  // $insert debug
601  if (d_debug__)
602  s_out__ << "errorRecovery(): pop state " << top__() << "\n" << dflush;
603  pop__();
604  }
605  // $insert debug
606  if (d_debug__)
607  s_out__ << "errorRecovery(): state " << top__() << " is an ERROR state" << "\n" << dflush;
608 
609  // In the error state, lookup a token allowing us to proceed.
610  // Continuation may be possible following multiple reductions,
611  // but eventuall a shift will be used, requiring the retrieval of
612  // a terminal token. If a retrieved token doesn't match, the catch below
613  // will ensure the next token is requested in the while(true) block
614  // implemented below:
615 
616  int lastToken = d_token__; // give the unexpected token a
617  // chance to be processed
618  // again.
619 
620  pushToken__(_error_); // specify _error_ as next token
621  push__(lookup(true)); // push the error state
622 
623  d_token__ = lastToken; // reactivate the unexpected
624  // token (we're now in an
625  // ERROR state).
626 
627  bool gotToken = true; // the next token is a terminal
628 
629  while (true)
630  {
631  try
632  {
633  if (s_state[d_state__]->d_type & REQ_TOKEN)
634  {
635  gotToken = d_token__ == _UNDETERMINED_;
636  nextToken(); // obtain next token
637  }
638 
639  int action = lookup(true);
640 
641  if (action > 0) // push a new state
642  {
643  push__(action);
644  popToken__();
645  // $insert debug
646  if (d_debug__)
647  s_out__ << "errorRecovery() SHIFT state " << action ;
648  // $insert debug
649  if (d_debug__)
650  s_out__ << ", continue with " << symbol(d_token__) << "\n" << dflush;
651 
652  if (gotToken)
653  {
654  // $insert debug
655  if (d_debug__)
656  s_out__ << "errorRecovery() COMPLETED: next state " ;
657  // $insert debug
658  if (d_debug__)
659  s_out__ << action << ", no token yet" << "\n" << dflush;
660 
661  d_acceptedTokens__ = 0;
662  return;
663  }
664  }
665  else if (action < 0)
666  {
667  // no actions executed on recovery but save an already
668  // available token:
669  if (d_token__ != _UNDETERMINED_)
670  pushToken__(d_token__);
671 
672  // next token is the rule's LHS
673  reduce__(s_productionInfo[-action]);
674  // $insert debug
675  if (d_debug__)
676  s_out__ << "errorRecovery() REDUCE by rule " << -action ;
677  // $insert debug
678  if (d_debug__)
679  s_out__ << ", token = " << symbol(d_token__) << "\n" << dflush;
680  }
681  else
682  ABORT(); // abort when accepting during
683  // error recovery
684  }
685  catch (...)
686  {
687  if (d_token__ == _EOF_)
688  ABORT(); // saw inappropriate _EOF_
689 
690  popToken__(); // failing token now skipped
691  }
692  }
693 }
694 catch (ErrorRecovery__) // This is: DEFAULT_RECOVERY_MODE
695 {
696  ABORT();
697 }
698 
699  // The parsing algorithm:
700  // Initially, state 0 is pushed on the stack, and d_token__ as well as
701  // d_nextToken__ are initialized to _UNDETERMINED_.
702  //
703  // Then, in an eternal loop:
704  //
705  // 1. If a state does not have REQ_TOKEN no token is assigned to
706  // d_token__. If the state has REQ_TOKEN, nextToken() is called to
707  // determine d_nextToken__ and d_token__ is set to
708  // d_nextToken__. nextToken() will not call lex() unless d_nextToken__ is
709  // _UNDETERMINED_.
710  //
711  // 2. lookup() is called:
712  // d_token__ is stored in the final element's d_token field of the
713  // state's SR_ array.
714  //
715  // 3. The current token is looked up in the state's SR_ array
716  //
717  // 4. Depending on the result of the lookup() function the next state is
718  // shifted on the parser's stack, a reduction by some rule is applied,
719  // or the parsing function returns ACCEPT(). When a reduction is
720  // called for, any action that may have been defined for that
721  // reduction is executed.
722  //
723  // 5. An error occurs if d_token__ is not found, and the state has no
724  // default reduction. Error handling was described at the top of this
725  // file.
726 
728 try
729 {
730  // $insert debug
731  if (d_debug__)
732  s_out__ << "parse(): Parsing starts" << "\n" << dflush;
733  push__(0); // initial state
734  clearin(); // clear the tokens.
735 
736  while (true)
737  {
738  // $insert debug
739  if (d_debug__)
740  s_out__ << "==" << "\n" << dflush;
741  try
742  {
743  if (s_state[d_state__]->d_type & REQ_TOKEN)
744  nextToken(); // obtain next token
745 
746 
747  int action = lookup(false); // lookup d_token__ in d_state__
748 
749  if (action > 0) // SHIFT: push a new state
750  {
751  push__(action);
752  popToken__(); // token processed
753  }
754  else if (action < 0) // REDUCE: execute and pop.
755  {
756  executeAction(-action);
757  // next token is the rule's LHS
758  reduce__(s_productionInfo[-action]);
759  }
760  else
761  ACCEPT();
762  }
763  catch (ErrorRecovery__)
764  {
765  errorRecovery();
766  }
767  }
768 }
769 catch (Return__ retValue)
770 {
771  // $insert debug
772  if (d_debug__)
773  s_out__ << "parse(): returns " << retValue << "\n" << dflush;
774  return retValue;
775 }
776 
if(!yyg->yy_init)
Definition: scanner.cpp:695
ReservedTokens
Definition: parser.cpp:73
int parse()
Definition: parser.cpp:727
const float pi
Definition: basegfx.cpp:551
StateType
Definition: parser.cpp:80