source: cpp/f8-to-f1/conv_f8tof1_grammar.c @ 1

Last change on this file since 1 was 1, checked in by Maciej Komosinski, 15 years ago

added f8 (L-systems) representation and converter f8->f1

File size: 58.3 KB
Line 
1/* Driver template for the LEMON parser generator.
2** The author disclaims copyright to this source code.
3*/
4/* First off, code is include which follows the "include" declaration
5** in the input file. */
6#include <stdio.h>
7#include <assert.h>
8#line 1 "conv_f8tof1_grammar.y"
9
10#include <iostream>
11#include <sstream>
12#include "lemonglobal.h"
13#include "conv_f8tof1.h"
14#include "conv_f8_utils.h"
15#define PARSER_DEBUG 0
16#line 18 "conv_f8tof1_grammar.c"
17/* Next is all token values, in a form suitable for use by makeheaders.
18** This section will be null unless lemon is run with the -m switch.
19*/
20/*
21** These constants (all generated automatically by the parser generator)
22** specify the various kinds of tokens (terminals) that the parser
23** understands.
24**
25** Each symbol here is a terminal symbol in the grammar.
26*/
27/* Make sure the INTERFACE macro is defined.
28*/
29#ifndef INTERFACE
30# define INTERFACE 1
31#endif
32/* The next thing included is series of defines which control
33** various aspects of the generated parser.
34**    YYCODETYPE         is the data type used for storing terminal
35**                       and nonterminal numbers.  "unsigned char" is
36**                       used if there are fewer than 250 terminals
37**                       and nonterminals.  "int" is used otherwise.
38**    YYNOCODE           is a number of type YYCODETYPE which corresponds
39**                       to no legal terminal or nonterminal number.  This
40**                       number is used to fill in empty slots of the hash
41**                       table.
42**    YYFALLBACK         If defined, this indicates that one or more tokens
43**                       have fall-back values which should be used if the
44**                       original value of the token will not parse.
45**    YYACTIONTYPE       is the data type used for storing terminal
46**                       and nonterminal numbers.  "unsigned char" is
47**                       used if there are fewer than 250 rules and
48**                       states combined.  "int" is used otherwise.
49**    ParseTOKENTYPE     is the data type used for minor tokens given
50**                       directly to the parser from the tokenizer.
51**    YYMINORTYPE        is the data type used for all minor tokens.
52**                       This is typically a union of many types, one of
53**                       which is ParseTOKENTYPE.  The entry in the union
54**                       for base tokens is called "yy0".
55**    YYSTACKDEPTH       is the maximum depth of the parser's stack.  If
56**                       zero the stack is dynamically sized using realloc()
57**    ParseARG_SDECL     A static variable declaration for the %extra_argument
58**    ParseARG_PDECL     A parameter declaration for the %extra_argument
59**    ParseARG_STORE     Code to store %extra_argument into yypParser
60**    ParseARG_FETCH     Code to extract %extra_argument from yypParser
61**    YYNSTATE           the combined number of states.
62**    YYNRULE            the number of rules in the grammar
63**    YYERRORSYMBOL      is the code number of the error symbol.  If not
64**                       defined, then do no error processing.
65*/
66#define YYCODETYPE unsigned char
67#define YYNOCODE 51
68#define YYACTIONTYPE unsigned char
69#define ParseTOKENTYPE Token
70typedef union {
71  ParseTOKENTYPE yy0;
72  ProductionTailToken yy11;
73  Token yy78;
74  ProdPieceToken yy89;
75} YYMINORTYPE;
76#ifndef YYSTACKDEPTH
77#define YYSTACKDEPTH 100
78#endif
79#define ParseARG_SDECL
80#define ParseARG_PDECL
81#define ParseARG_FETCH
82#define ParseARG_STORE
83#define YYNSTATE 91
84#define YYNRULE 47
85#define YY_NO_ACTION      (YYNSTATE+YYNRULE+2)
86#define YY_ACCEPT_ACTION  (YYNSTATE+YYNRULE+1)
87#define YY_ERROR_ACTION   (YYNSTATE+YYNRULE)
88
89/* Next are that tables used to determine what action to take based on the
90** current state and lookahead token.  These tables are used to implement
91** functions that take a state number and lookahead value and return an
92** action integer. 
93**
94** Suppose the action integer is N.  Then the action is determined as
95** follows
96**
97**   0 <= N < YYNSTATE                  Shift N.  That is, push the lookahead
98**                                      token onto the stack and goto state N.
99**
100**   YYNSTATE <= N < YYNSTATE+YYNRULE   Reduce by rule N-YYNSTATE.
101**
102**   N == YYNSTATE+YYNRULE              A syntax error has occurred.
103**
104**   N == YYNSTATE+YYNRULE+1            The parser accepts its input.
105**
106**   N == YYNSTATE+YYNRULE+2            No such action.  Denotes unused
107**                                      slots in the yy_action[] table.
108**
109** The action table is constructed as a single large table named yy_action[].
110** Given state S and lookahead X, the action is computed as
111**
112**      yy_action[ yy_shift_ofst[S] + X ]
113**
114** If the index value yy_shift_ofst[S]+X is out of range or if the value
115** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
116** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
117** and that yy_default[S] should be used instead. 
118**
119** The formula above is for computing the action when the lookahead is
120** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
121** a reduce action) then the yy_reduce_ofst[] array is used in place of
122** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
123** YY_SHIFT_USE_DFLT.
124**
125** The following are the tables generated in this section:
126**
127**  yy_action[]        A single table containing all actions.
128**  yy_lookahead[]     A table containing the lookahead for each entry in
129**                     yy_action.  Used to detect hash collisions.
130**  yy_shift_ofst[]    For each state, the offset into yy_action for
131**                     shifting terminals.
132**  yy_reduce_ofst[]   For each state, the offset into yy_action for
133**                     shifting non-terminals after a reduce.
134**  yy_default[]       Default action for each state.
135*/
136static const YYACTIONTYPE yy_action[] = {
137 /*     0 */    40,    4,   23,   24,   25,   26,   27,   28,   64,   67,
138 /*    10 */    31,   71,   44,   55,    4,   41,   34,   82,   75,   64,
139 /*    20 */    65,   68,   70,   31,   65,   44,   84,    4,   41,   34,
140 /*    30 */    82,   75,   64,   65,   68,   70,   69,   65,   44,   20,
141 /*    40 */    60,    4,   61,   56,    4,   47,    8,   68,   70,   46,
142 /*    50 */    69,   32,   44,   69,   49,   44,   59,   57,    4,   47,
143 /*    60 */    42,   68,   70,   85,   68,   70,   38,   69,   76,   44,
144 /*    70 */    10,   45,   39,   77,   58,   15,   14,    5,   68,   70,
145 /*    80 */    65,   71,   72,   73,   12,   13,   15,   14,   60,    9,
146 /*    90 */    61,   91,   78,    6,   60,   48,   61,   53,    1,   33,
147 /*   100 */    35,   10,   45,   39,   79,   33,   66,   80,   12,   13,
148 /*   110 */    15,   14,  139,   16,   60,   60,   61,   61,   52,   60,
149 /*   120 */    60,   61,   61,   81,   17,   36,   37,   54,   22,   51,
150 /*   130 */    62,   63,   30,   18,   50,    3,    2,   43,   74,   11,
151 /*   140 */    75,   88,    7,   19,   21,   83,   18,   50,   86,   29,
152 /*   150 */    87,   89,   90,
153};
154static const YYCODETYPE yy_lookahead[] = {
155 /*     0 */    27,   28,   13,   14,   15,   16,   17,   18,   21,   11,
156 /*    10 */    37,   23,   39,   27,   28,   42,   43,   44,   45,   21,
157 /*    20 */    22,   48,   49,   37,   22,   39,   11,   28,   42,   43,
158 /*    30 */    44,   45,   21,   22,   48,   49,   37,   22,   39,   32,
159 /*    40 */    35,   28,   37,   44,   28,   37,    1,   48,   49,   41,
160 /*    50 */    37,   46,   39,   37,    7,   39,   11,   44,   28,   37,
161 /*    60 */    44,   48,   49,   41,   48,   49,   34,   37,   35,   39,
162 /*    70 */    38,   39,   40,   35,   44,    4,    5,   19,   48,   49,
163 /*    80 */    22,   23,   24,   25,    2,    3,    4,    5,   35,   33,
164 /*    90 */    37,    0,   35,   11,   35,   39,   37,   34,    9,   46,
165 /*   100 */    47,   38,   39,   40,   35,   46,   47,   35,    2,    3,
166 /*   110 */     4,    5,   29,   30,   35,   35,   37,   37,   35,   35,
167 /*   120 */    35,   37,   37,   35,    1,   46,   46,    6,   31,   35,
168 /*   130 */    46,   46,   37,   36,   37,   12,    9,   20,   43,   10,
169 /*   140 */    45,   31,   10,   10,    1,   11,   36,   37,    6,    8,
170 /*   150 */     6,    6,    6,
171};
172#define YY_SHIFT_USE_DFLT (-14)
173#define YY_SHIFT_MAX 52
174static const short yy_shift_ofst[] = {
175 /*     0 */   -13,   58,   58,   58,   58,   58,   58,   -2,   11,  -12,
176 /*    10 */   -12,   11,   11,   11,   11,   11,    2,    2,    2,   15,
177 /*    20 */   -12,    2,   47,  -13,  -13,  -13,  -13,  -13,  -13,  -13,
178 /*    30 */   -11,  -11,   82,  106,  123,   45,   71,   71,   91,   89,
179 /*    40 */   121,  127,  117,  129,  132,  133,  134,  143,  142,  144,
180 /*    50 */   141,  145,  146,
181};
182#define YY_REDUCE_USE_DFLT (-28)
183#define YY_REDUCE_MAX 29
184static const signed char yy_reduce_ofst[] = {
185 /*     0 */    83,  -27,  -14,   -1,   13,   16,   30,   53,   59,   32,
186 /*    10 */    63,    5,   79,   80,   84,   85,   97,   95,  110,    8,
187 /*    20 */    56,   22,    7,   33,   38,   57,   69,   72,   88,   94,
188};
189static const YYACTIONTYPE yy_default[] = {
190 /*     0 */   138,  117,  117,  117,  117,  117,  117,  138,  138,   98,
191 /*    10 */    98,  138,  138,  138,  138,  138,   95,  138,   95,  138,
192 /*    20 */   138,  138,  138,  138,  138,  138,  138,  138,  138,  138,
193 /*    30 */   138,  123,  138,  125,  138,  138,  129,  130,  138,  138,
194 /*    40 */   138,  106,  138,  138,  138,  138,  138,  104,  138,  138,
195 /*    50 */   138,  138,  138,   97,  100,  105,  107,  118,  119,  120,
196 /*    60 */   127,  128,  131,  132,  133,  134,  126,  121,  122,  123,
197 /*    70 */   124,  135,  136,  137,  109,  110,  111,  112,  113,  114,
198 /*    80 */   115,  116,  108,  101,  102,  103,   99,   93,   94,   96,
199 /*    90 */    92,
200};
201#define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
202
203/* The next table maps tokens into fallback tokens.  If a construct
204** like the following:
205**
206**      %fallback ID X Y Z.
207**
208** appears in the grammer, then ID becomes a fallback token for X, Y,
209** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser
210** but it does not parse, the type of the token is changed to ID and
211** the parse is retried before an error is thrown.
212*/
213#ifdef YYFALLBACK
214static const YYCODETYPE yyFallback[] = {
215};
216#endif /* YYFALLBACK */
217
218/* The following structure represents a single element of the
219** parser's stack.  Information stored includes:
220**
221**   +  The state number for the parser at this level of the stack.
222**
223**   +  The value of the token stored at this level of the stack.
224**      (In other words, the "major" token.)
225**
226**   +  The semantic value stored at this level of the stack.  This is
227**      the information used by the action routines in the grammar.
228**      It is sometimes called the "minor" token.
229*/
230struct yyStackEntry {
231  int stateno;       /* The state-number */
232  int major;         /* The major token value.  This is the code
233                     ** number for the token at this stack level */
234  YYMINORTYPE minor; /* The user-supplied minor token value.  This
235                     ** is the value of the token  */
236};
237typedef struct yyStackEntry yyStackEntry;
238
239/* The state of the parser is completely contained in an instance of
240** the following structure */
241struct yyParser {
242  int yyidx;                    /* Index of top element in stack */
243  int yyerrcnt;                 /* Shifts left before out of the error */
244  ParseARG_SDECL                /* A place to hold %extra_argument */
245#if YYSTACKDEPTH<=0
246  int yystksz;                  /* Current side of the stack */
247  yyStackEntry *yystack;        /* The parser's stack */
248#else
249  yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
250#endif
251};
252typedef struct yyParser yyParser;
253
254#ifndef NDEBUG
255#include <stdio.h>
256static FILE *yyTraceFILE = 0;
257static char *yyTracePrompt = 0;
258#endif /* NDEBUG */
259
260#ifndef NDEBUG
261/*
262** Turn parser tracing on by giving a stream to which to write the trace
263** and a prompt to preface each trace message.  Tracing is turned off
264** by making either argument NULL
265**
266** Inputs:
267** <ul>
268** <li> A FILE* to which trace output should be written.
269**      If NULL, then tracing is turned off.
270** <li> A prefix string written at the beginning of every
271**      line of trace output.  If NULL, then tracing is
272**      turned off.
273** </ul>
274**
275** Outputs:
276** None.
277*/
278void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
279  yyTraceFILE = TraceFILE;
280  yyTracePrompt = zTracePrompt;
281  if( yyTraceFILE==0 ) yyTracePrompt = 0;
282  else if( yyTracePrompt==0 ) yyTraceFILE = 0;
283}
284#endif /* NDEBUG */
285
286#ifndef NDEBUG
287/* For tracing shifts, the names of all terminals and nonterminals
288** are required.  The following table supplies these names */
289static const char *const yyTokenName[] = {
290  "$",             "COMMA",         "PLUS",          "MINUS",       
291  "DIV",           "TIMES",         "NEWLINE",       "DELIMETER",   
292  "ASSIGN",        "SEMICOLON",     "LPAREN",        "RPAREN",     
293  "PIPE",          "LESS",          "LESS_EQUAL",    "NOT_EQUAL",   
294  "EQUAL",         "GREATER_EQUAL",  "GREATER",       "FORLOOP_BEGIN",
295  "FORLOOP_END",   "DOUBLE_VAL",    "PARAM_NAME",    "PROD_NAME",   
296  "COMMAND",       "NEURON",        "error",         "production_tail",
297  "prod_piece",    "program",       "counter",       "start_params",
298  "delim",         "first_prod",    "productions",   "double_val", 
299  "start_parameter",  "param_name",    "production",    "prod_name",   
300  "production_head",  "prod_params",   "subproduction",  "conditions", 
301  "real_prod",     "condition",     "single_val",    "multiple_val",
302  "command",       "neuron",     
303};
304#endif /* NDEBUG */
305
306#ifndef NDEBUG
307/* For tracing reduce actions, the names of all rules are required.
308*/
309static const char *const yyRuleName[] = {
310 /*   0 */ "program ::= counter start_params delim first_prod productions",
311 /*   1 */ "counter ::= double_val NEWLINE",
312 /*   2 */ "delim ::= DELIMETER NEWLINE",
313 /*   3 */ "start_params ::= start_parameter start_params",
314 /*   4 */ "start_params ::=",
315 /*   5 */ "start_parameter ::= param_name ASSIGN double_val NEWLINE",
316 /*   6 */ "productions ::= production productions",
317 /*   7 */ "productions ::=",
318 /*   8 */ "first_prod ::= prod_name NEWLINE",
319 /*   9 */ "production ::= production_head SEMICOLON production_tail NEWLINE",
320 /*  10 */ "production_head ::= prod_name LPAREN prod_params RPAREN",
321 /*  11 */ "production_head ::= prod_name LPAREN RPAREN",
322 /*  12 */ "prod_params ::= param_name COMMA prod_params",
323 /*  13 */ "prod_params ::= param_name",
324 /*  14 */ "production_tail ::= subproduction SEMICOLON production_tail",
325 /*  15 */ "production_tail ::= subproduction",
326 /*  16 */ "subproduction ::= conditions PIPE real_prod",
327 /*  17 */ "subproduction ::= real_prod",
328 /*  18 */ "conditions ::= conditions COMMA conditions",
329 /*  19 */ "conditions ::= condition",
330 /*  20 */ "condition ::= param_name LESS double_val",
331 /*  21 */ "condition ::= param_name LESS_EQUAL double_val",
332 /*  22 */ "condition ::= param_name NOT_EQUAL double_val",
333 /*  23 */ "condition ::= param_name EQUAL double_val",
334 /*  24 */ "condition ::= param_name GREATER_EQUAL double_val",
335 /*  25 */ "condition ::= param_name GREATER double_val",
336 /*  26 */ "real_prod ::=",
337 /*  27 */ "real_prod ::= prod_piece real_prod",
338 /*  28 */ "real_prod ::= FORLOOP_BEGIN real_prod FORLOOP_END LPAREN single_val RPAREN real_prod",
339 /*  29 */ "prod_piece ::= prod_name LPAREN multiple_val RPAREN",
340 /*  30 */ "prod_piece ::= prod_name LPAREN RPAREN",
341 /*  31 */ "prod_piece ::= command",
342 /*  32 */ "prod_piece ::= param_name",
343 /*  33 */ "prod_piece ::= neuron",
344 /*  34 */ "multiple_val ::= single_val",
345 /*  35 */ "multiple_val ::= multiple_val COMMA multiple_val",
346 /*  36 */ "single_val ::= double_val",
347 /*  37 */ "single_val ::= param_name",
348 /*  38 */ "single_val ::= single_val PLUS single_val",
349 /*  39 */ "single_val ::= single_val MINUS single_val",
350 /*  40 */ "single_val ::= single_val TIMES single_val",
351 /*  41 */ "single_val ::= single_val DIV single_val",
352 /*  42 */ "double_val ::= DOUBLE_VAL",
353 /*  43 */ "param_name ::= PARAM_NAME",
354 /*  44 */ "prod_name ::= PROD_NAME",
355 /*  45 */ "command ::= COMMAND",
356 /*  46 */ "neuron ::= NEURON",
357};
358#endif /* NDEBUG */
359
360
361#if YYSTACKDEPTH<=0
362/*
363** Try to increase the size of the parser stack.
364*/
365static void yyGrowStack(yyParser *p){
366  int newSize;
367  yyStackEntry *pNew;
368
369  newSize = p->yystksz*2 + 100;
370  pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
371  if( pNew ){
372    p->yystack = pNew;
373    p->yystksz = newSize;
374#ifndef NDEBUG
375    if( yyTraceFILE ){
376      fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
377              yyTracePrompt, p->yystksz);
378    }
379#endif
380  }
381}
382#endif
383
384/* MW */
385Lsystem *lsys;
386bool syntaxOnly;
387bool *syntaxOk;
388
389/*
390** This function allocates a new parser.
391** The only argument is a pointer to a function which works like
392** malloc.
393**
394** Inputs:
395** A pointer to the function used to allocate memory.
396**
397** Outputs:
398** A pointer to a parser.  This pointer is used in subsequent calls
399** to Parse and ParseFree.
400*/
401void *ParseAlloc(void *(*mallocProc)(size_t), Lsystem *lsystem, bool checkSyntaxOnly = false, bool *isSyntaxOk = NULL){
402  yyParser *pParser;
403  pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );
404  if( pParser ){
405    pParser->yyidx = -1;
406#if YYSTACKDEPTH<=0
407    yyGrowStack(pParser);
408#endif
409          //input = new Lsystem();
410          lsys = lsystem;
411          syntaxOnly = checkSyntaxOnly;
412          syntaxOk = isSyntaxOk;
413  }
414  return pParser;
415}
416
417/* The following function deletes the value associated with a
418** symbol.  The symbol can be either a terminal or nonterminal.
419** "yymajor" is the symbol code, and "yypminor" is a pointer to
420** the value.
421*/
422static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){
423  switch( yymajor ){
424    /* Here is inserted the actions which take place when a
425    ** terminal or non-terminal is destroyed.  This can happen
426    ** when the symbol is popped from the stack during a
427    ** reduce or during error processing or when a parser is
428    ** being destroyed before it is finished parsing.
429    **
430    ** Note: during a reduce, the only symbols destroyed are those
431    ** which appear on the RHS of the rule, but which are not used
432    ** inside the C code.
433    */
434    default:  break;   /* If no destructor action specified: do nothing */
435  }
436}
437
438/*
439** Pop the parser's stack once.
440**
441** If there is a destructor routine associated with the token which
442** is popped from the stack, then call it.
443**
444** Return the major token number for the symbol popped.
445*/
446static int yy_pop_parser_stack(yyParser *pParser){
447  YYCODETYPE yymajor;
448  yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
449
450  if( pParser->yyidx<0 ) return 0;
451#ifndef NDEBUG
452  if( yyTraceFILE && pParser->yyidx>=0 ){
453    fprintf(yyTraceFILE,"%sPopping %s\n",
454      yyTracePrompt,
455      yyTokenName[yytos->major]);
456  }
457#endif
458  yymajor = yytos->major;
459  yy_destructor( yymajor, &yytos->minor);
460  pParser->yyidx--;
461  return yymajor;
462}
463
464/*
465** Deallocate and destroy a parser.  Destructors are all called for
466** all stack elements before shutting the parser down.
467**
468** Inputs:
469** <ul>
470** <li>  A pointer to the parser.  This should be a pointer
471**       obtained from ParseAlloc.
472** <li>  A pointer to a function used to reclaim memory obtained
473**       from malloc.
474** </ul>
475*/
476void ParseFree(
477  void *p,                    /* The parser to be deleted */
478  void (*freeProc)(void*)     /* Function used to reclaim memory */
479){
480  yyParser *pParser = (yyParser*)p;
481  if( pParser==0 ) return;
482  while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
483#if YYSTACKDEPTH<=0
484  free(pParser->yystack);
485#endif
486  (*freeProc)((void*)pParser);
487        //delete lsys;
488}
489
490/*
491** Find the appropriate action for a parser given the terminal
492** look-ahead token iLookAhead.
493**
494** If the look-ahead token is YYNOCODE, then check to see if the action is
495** independent of the look-ahead.  If it is, return the action, otherwise
496** return YY_NO_ACTION.
497*/
498static int yy_find_shift_action(
499  yyParser *pParser,        /* The parser */
500  YYCODETYPE iLookAhead     /* The look-ahead token */
501){
502  int i;
503  int stateno = pParser->yystack[pParser->yyidx].stateno;
504 
505  if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
506    return yy_default[stateno];
507  }
508  assert( iLookAhead!=YYNOCODE );
509  i += iLookAhead;
510  if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
511    if( iLookAhead>0 ){
512#ifdef YYFALLBACK
513      int iFallback;            /* Fallback token */
514      if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
515             && (iFallback = yyFallback[iLookAhead])!=0 ){
516#ifndef NDEBUG
517        if( yyTraceFILE ){
518          fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
519             yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
520        }
521#endif
522        return yy_find_shift_action(pParser, iFallback);
523      }
524#endif
525#ifdef YYWILDCARD
526      {
527        int j = i - iLookAhead + YYWILDCARD;
528        if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){
529#ifndef NDEBUG
530          if( yyTraceFILE ){
531            fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
532               yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
533          }
534#endif /* NDEBUG */
535          return yy_action[j];
536        }
537      }
538#endif /* YYWILDCARD */
539    }
540    return yy_default[stateno];
541  }else{
542    return yy_action[i];
543  }
544}
545
546/*
547** Find the appropriate action for a parser given the non-terminal
548** look-ahead token iLookAhead.
549**
550** If the look-ahead token is YYNOCODE, then check to see if the action is
551** independent of the look-ahead.  If it is, return the action, otherwise
552** return YY_NO_ACTION.
553*/
554static int yy_find_reduce_action(
555  int stateno,              /* Current state number */
556  YYCODETYPE iLookAhead     /* The look-ahead token */
557){
558  int i;
559  assert( stateno<=YY_REDUCE_MAX );
560  i = yy_reduce_ofst[stateno];
561  assert( i!=YY_REDUCE_USE_DFLT );
562  assert( iLookAhead!=YYNOCODE );
563  i += iLookAhead;
564  assert( i>=0 && i<YY_SZ_ACTTAB );
565  assert( yy_lookahead[i]==iLookAhead );
566  return yy_action[i];
567}
568
569/*
570** The following routine is called if the stack overflows.
571*/
572static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
573   ParseARG_FETCH;
574   yypParser->yyidx--;
575#ifndef NDEBUG
576   if( yyTraceFILE ){
577     fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
578   }
579#endif
580   while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
581   /* Here code is inserted which will execute if the parser
582   ** stack every overflows */
583   ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
584}
585
586/*
587** Perform a shift action.
588*/
589static void yy_shift(
590  yyParser *yypParser,          /* The parser to be shifted */
591  int yyNewState,               /* The new state to shift in */
592  int yyMajor,                  /* The major token to shift in */
593  YYMINORTYPE *yypMinor         /* Pointer ot the minor token to shift in */
594){
595  yyStackEntry *yytos;
596  yypParser->yyidx++;
597#if YYSTACKDEPTH>0
598  if( yypParser->yyidx>=YYSTACKDEPTH ){
599    yyStackOverflow(yypParser, yypMinor);
600    return;
601  }
602#else
603  if( yypParser->yyidx>=yypParser->yystksz ){
604    yyGrowStack(yypParser);
605    if( yypParser->yyidx>=yypParser->yystksz ){
606      yyStackOverflow(yypParser, yypMinor);
607      return;
608    }
609  }
610#endif
611  yytos = &yypParser->yystack[yypParser->yyidx];
612  yytos->stateno = yyNewState;
613  yytos->major = yyMajor;
614  yytos->minor = *yypMinor;
615#ifndef NDEBUG
616  if( yyTraceFILE && yypParser->yyidx>0 ){
617    int i;
618    fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState);
619    fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
620    for(i=1; i<=yypParser->yyidx; i++)
621      fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]);
622    fprintf(yyTraceFILE,"\n");
623  }
624#endif
625}
626
627/* The following table contains information about every rule that
628** is used during the reduce.
629*/
630static const struct {
631  YYCODETYPE lhs;         /* Symbol on the left-hand side of the rule */
632  unsigned char nrhs;     /* Number of right-hand side symbols in the rule */
633} yyRuleInfo[] = {
634  { 29, 5 },
635  { 30, 2 },
636  { 32, 2 },
637  { 31, 2 },
638  { 31, 0 },
639  { 36, 4 },
640  { 34, 2 },
641  { 34, 0 },
642  { 33, 2 },
643  { 38, 4 },
644  { 40, 4 },
645  { 40, 3 },
646  { 41, 3 },
647  { 41, 1 },
648  { 27, 3 },
649  { 27, 1 },
650  { 42, 3 },
651  { 42, 1 },
652  { 43, 3 },
653  { 43, 1 },
654  { 45, 3 },
655  { 45, 3 },
656  { 45, 3 },
657  { 45, 3 },
658  { 45, 3 },
659  { 45, 3 },
660  { 44, 0 },
661  { 44, 2 },
662  { 44, 7 },
663  { 28, 4 },
664  { 28, 3 },
665  { 28, 1 },
666  { 28, 1 },
667  { 28, 1 },
668  { 47, 1 },
669  { 47, 3 },
670  { 46, 1 },
671  { 46, 1 },
672  { 46, 3 },
673  { 46, 3 },
674  { 46, 3 },
675  { 46, 3 },
676  { 35, 1 },
677  { 37, 1 },
678  { 39, 1 },
679  { 48, 1 },
680  { 49, 1 },
681};
682
683static void yy_accept(yyParser*);  /* Forward Declaration */
684
685/*
686** Perform a reduce action and the shift that must immediately
687** follow the reduce.
688*/
689static void yy_reduce(
690  yyParser *yypParser,         /* The parser */
691  int yyruleno                 /* Number of the rule by which to reduce */
692){
693  int yygoto;                     /* The next state */
694  int yyact;                      /* The next action */
695  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
696  yyStackEntry *yymsp;            /* The top of the parser's stack */
697  int yysize;                     /* Amount to pop the stack */
698  ParseARG_FETCH;
699  yymsp = &yypParser->yystack[yypParser->yyidx];
700#ifndef NDEBUG
701  if( yyTraceFILE && yyruleno>=0
702        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
703    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
704      yyRuleName[yyruleno]);
705  }
706#endif /* NDEBUG */
707
708  /* Silence complaints from purify about yygotominor being uninitialized
709  ** in some cases when it is copied into the stack after the following
710  ** switch.  yygotominor is uninitialized when a rule reduces that does
711  ** not set the value of its left-hand side nonterminal.  Leaving the
712  ** value of the nonterminal uninitialized is utterly harmless as long
713  ** as the value is never used.  So really the only thing this code
714  ** accomplishes is to quieten purify. 
715  **
716  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
717  ** without this code, their parser segfaults.  I'm not sure what there
718  ** parser is doing to make this happen.  This is the second bug report
719  ** from wireshark this week.  Clearly they are stressing Lemon in ways
720  ** that it has not been previously stressed...  (SQLite ticket #2172)
721  */
722  memset(&yygotominor, 0, sizeof(yygotominor));
723
724
725  switch( yyruleno ){
726  /* Beginning here are the reduction cases.  A typical example
727  ** follows:
728  **   case 0:
729  **  #line <lineno> <grammarfile>
730  **     { ... }           // User supplied code
731  **  #line <lineno> <thisfile>
732  **     break;
733  */
734      case 0: /* program ::= counter start_params delim first_prod productions */
735#line 18 "conv_f8tof1_grammar.y"
736{
737        *syntaxOk = true;       
738}
739#line 741 "conv_f8tof1_grammar.c"
740        break;
741      case 1: /* counter ::= double_val NEWLINE */
742#line 22 "conv_f8tof1_grammar.y"
743{
744        if (!syntaxOnly) {
745                {
746#if PARSER_DEBUG > 0
747                        std::cout << "counter ::= double_val NEWLINE." << std::endl;
748#endif
749                }
750                lsys->iterations = (int) yymsp[-1].minor.yy78.dblValue;
751        }
752}
753#line 755 "conv_f8tof1_grammar.c"
754        break;
755      case 2: /* delim ::= DELIMETER NEWLINE */
756      case 3: /* start_params ::= start_parameter start_params */
757      case 4: /* start_params ::= */
758      case 6: /* productions ::= production productions */
759      case 7: /* productions ::= */
760#line 33 "conv_f8tof1_grammar.y"
761{
762}
763#line 765 "conv_f8tof1_grammar.c"
764        break;
765      case 5: /* start_parameter ::= param_name ASSIGN double_val NEWLINE */
766#line 38 "conv_f8tof1_grammar.y"
767{
768        if (!syntaxOnly) {
769                {       
770#if PARSER_DEBUG > 0
771                        std::cout << "start_parameter ::= param_name ASSIGN double_val NEWLINE." << std::endl;
772#endif
773                }
774                lsys->startParams[sstringToString(*(yymsp[-3].minor.yy78.strValue))] = yymsp[-1].minor.yy78.dblValue;
775#if PARSER_DEBUG > 0
776                cout << "**** " << lsys->startParams["n0"] << endl;
777                cout << "**** " << lsys->startParams["n1"] << endl;
778#endif
779                delete yymsp[-3].minor.yy78.strValue;
780        }
781}
782#line 784 "conv_f8tof1_grammar.c"
783        break;
784      case 8: /* first_prod ::= prod_name NEWLINE */
785#line 57 "conv_f8tof1_grammar.y"
786{
787        if (!syntaxOnly) {
788                {
789#if PARSER_DEBUG > 0
790                        std::cout << "first_prod ::= prod_name NEWLINE." << std::endl;
791#endif
792                }
793                lsys->firstProductionName = sstringToString(*(yymsp[-1].minor.yy78.strValue));
794                delete yymsp[-1].minor.yy78.strValue;
795        }
796}
797#line 799 "conv_f8tof1_grammar.c"
798        break;
799      case 9: /* production ::= production_head SEMICOLON production_tail NEWLINE */
800#line 69 "conv_f8tof1_grammar.y"
801{
802        if (!syntaxOnly) {
803                {
804#if PARSER_DEBUG > 0
805                        std::cout << "production ::= production_head SEMICOLON production_tail NEWLINE." << std::endl;
806#endif
807                }
808                Production *p = lsys->productions[sstringToString(*(yymsp[-3].minor.yy78.strValue))];
809                for (vector<SString>::iterator paramIter = yymsp[-3].minor.yy78.vectorStr->begin(); paramIter != yymsp[-3].minor.yy78.vectorStr->end(); paramIter++) {
810#if PARSER_DEBUG > 0
811                        std::cout << "1.1 " << *paramIter << std::endl;
812                        std::cout << *(yymsp[-3].minor.yy78.strValue) << " # " << (p == NULL) << " # " << true << std::endl;
813#endif
814                        p->parameters.addParameter(*paramIter);
815                }
816                p->subproductions = *(yymsp[-1].minor.yy11.subproductions);
817                delete yymsp[-3].minor.yy78.strValue;
818                delete yymsp[-3].minor.yy78.vectorStr;
819                delete yymsp[-1].minor.yy11.subproductions;
820        }
821}
822#line 824 "conv_f8tof1_grammar.c"
823        break;
824      case 10: /* production_head ::= prod_name LPAREN prod_params RPAREN */
825#line 91 "conv_f8tof1_grammar.y"
826{
827        if (!syntaxOnly) {
828                {
829#if PARSER_DEBUG > 0
830                        std::cout << "production_head ::= prod_name LPAREN prod_params RPAREN." << std::endl;
831#endif
832                }
833#if PARSER_DEBUG > 0
834                std::cout << "---------" << *(yymsp[-3].minor.yy78.strValue) << std::endl;
835#endif
836                yygotominor.yy78.strValue = new SString(*(yymsp[-3].minor.yy78.strValue));
837                yygotominor.yy78.vectorStr = new vector<SString>(*(yymsp[-1].minor.yy78.vectorStr));
838                delete yymsp[-3].minor.yy78.strValue;
839                delete yymsp[-1].minor.yy78.vectorStr;
840        }
841}
842#line 844 "conv_f8tof1_grammar.c"
843        break;
844      case 11: /* production_head ::= prod_name LPAREN RPAREN */
845#line 107 "conv_f8tof1_grammar.y"
846{
847        if (!syntaxOnly) {
848                {
849#if PARSER_DEBUG > 0
850                        std::cout << "production_head ::= prod_name LPAREN RPAREN." << std::endl;
851#endif
852                }
853#if PARSER_DEBUG > 0
854                std::cout << "---------" << *(yymsp[-2].minor.yy78.strValue) << std::endl;
855#endif
856                yygotominor.yy78.strValue = new SString(*(yymsp[-2].minor.yy78.strValue));
857                yygotominor.yy78.vectorStr = new vector<SString>();
858                delete yymsp[-2].minor.yy78.strValue;
859        }
860}
861#line 863 "conv_f8tof1_grammar.c"
862        break;
863      case 12: /* prod_params ::= param_name COMMA prod_params */
864#line 123 "conv_f8tof1_grammar.y"
865{
866        if (!syntaxOnly) {
867                {
868#if PARSER_DEBUG > 0
869                        std::cout << "prod_params ::= param_name COMMA prod_params." << std::endl;
870#endif
871                }
872                yygotominor.yy78.vectorStr = new vector<SString>();
873                yygotominor.yy78.vectorStr->push_back(*(yymsp[-2].minor.yy78.strValue));
874                for (vector<SString>::iterator iter = yymsp[0].minor.yy78.vectorStr->begin(); iter != yymsp[0].minor.yy78.vectorStr->end(); iter++) {
875                        yygotominor.yy78.vectorStr->push_back(*iter);
876                }
877                delete yymsp[-2].minor.yy78.strValue;
878                delete yymsp[0].minor.yy78.vectorStr;
879        }
880}
881#line 883 "conv_f8tof1_grammar.c"
882        break;
883      case 13: /* prod_params ::= param_name */
884#line 139 "conv_f8tof1_grammar.y"
885{
886        if (!syntaxOnly) {
887                {
888#if PARSER_DEBUG > 0
889                        std::cout << "prod_params ::= param_name." << std::endl;
890#endif
891                }
892                yygotominor.yy78.vectorStr = new vector<SString>();
893                yygotominor.yy78.vectorStr->push_back(*(yymsp[0].minor.yy78.strValue));
894                delete yymsp[0].minor.yy78.strValue;
895        }
896}
897#line 899 "conv_f8tof1_grammar.c"
898        break;
899      case 14: /* production_tail ::= subproduction SEMICOLON production_tail */
900#line 152 "conv_f8tof1_grammar.y"
901{
902        if (!syntaxOnly) {
903                {
904#if PARSER_DEBUG > 0
905                        std::cout << "production_tail ::= subproduction SEMICOLON production_tail." << std::endl;
906#endif
907                }
908                SubProduction sp;
909                sp.conditions = *(yymsp[-2].minor.yy78.vectorConditions);
910                vector<ActionStrP> actions;
911                actions.reserve(yymsp[-2].minor.yy78.vectorActions->size());
912                for (int i = 0; i < yymsp[-2].minor.yy78.vectorActions->size() && i < yymsp[-2].minor.yy78.parameters->size(); i++) {
913                        ActionStrP ap;
914                        ap.action = (*(yymsp[-2].minor.yy78.vectorActions)).at(i);
915                        ap.params = (*(yymsp[-2].minor.yy78.parameters)).at(i);
916                        actions.push_back(ap);
917                }
918                sp.actions = actions;
919                yygotominor.yy11.subproductions = new vector<SubProduction>();
920                yygotominor.yy11.subproductions->push_back(sp);
921                for (vector<SubProduction>::iterator iter = yymsp[0].minor.yy11.subproductions->begin(); iter != yymsp[0].minor.yy11.subproductions->end(); iter++) {
922                        yygotominor.yy11.subproductions->push_back(*iter);
923                }
924                delete yymsp[-2].minor.yy78.vectorConditions;
925                delete yymsp[-2].minor.yy78.vectorActions;
926                delete yymsp[-2].minor.yy78.parameters;
927                delete yymsp[0].minor.yy11.subproductions;
928        }
929}
930#line 932 "conv_f8tof1_grammar.c"
931        break;
932      case 15: /* production_tail ::= subproduction */
933#line 181 "conv_f8tof1_grammar.y"
934{
935        if (!syntaxOnly) {
936                {
937#if PARSER_DEBUG > 0
938                        std::cout << "production_tail ::= subproduction." << std::endl;
939#endif
940                }
941                SubProduction sp;
942                sp.conditions = *(yymsp[0].minor.yy78.vectorConditions);
943                vector<ActionStrP> actions;
944                actions.reserve(yymsp[0].minor.yy78.vectorActions->size());
945                for (int i = 0; i < yymsp[0].minor.yy78.vectorActions->size() && i < yymsp[0].minor.yy78.parameters->size(); i++) {
946                        ActionStrP ap;
947                        ap.action = (*(yymsp[0].minor.yy78.vectorActions)).at(i);
948                        ap.params = (*(yymsp[0].minor.yy78.parameters)).at(i);
949                        actions.push_back(ap);
950                }
951                sp.actions = actions;
952                yygotominor.yy11.subproductions = new vector<SubProduction>();
953                yygotominor.yy11.subproductions->push_back(sp);
954                delete yymsp[0].minor.yy78.vectorConditions;
955                delete yymsp[0].minor.yy78.vectorActions;
956                delete yymsp[0].minor.yy78.parameters;
957        }
958}
959#line 961 "conv_f8tof1_grammar.c"
960        break;
961      case 16: /* subproduction ::= conditions PIPE real_prod */
962#line 207 "conv_f8tof1_grammar.y"
963{
964        if (!syntaxOnly) {
965                {
966#if PARSER_DEBUG > 0
967                        std::cout << "subproduction ::= conditions PIPE real_prod." << std::endl;
968#endif
969                }
970                yygotominor.yy78.vectorConditions = new vector<Condition>(*(yymsp[-2].minor.yy78.vectorConditions));
971                yygotominor.yy78.vectorActions = new vector<Action*>(*(yymsp[0].minor.yy78.vectorActions));
972                yygotominor.yy78.parameters = new vector<vector<SString> >(*(yymsp[0].minor.yy78.parameters));
973                delete yymsp[-2].minor.yy78.vectorConditions;
974                delete yymsp[0].minor.yy78.vectorActions;
975                delete yymsp[0].minor.yy78.parameters;
976        }
977}
978#line 980 "conv_f8tof1_grammar.c"
979        break;
980      case 17: /* subproduction ::= real_prod */
981#line 222 "conv_f8tof1_grammar.y"
982{
983        if (!syntaxOnly) {
984                {
985#if PARSER_DEBUG > 0
986                        std::cout << "subproduction ::= real_prod." << std::endl;
987#endif
988                }
989                yygotominor.yy78.vectorConditions = new vector<Condition>();
990                yygotominor.yy78.vectorActions = new vector<Action*>(*(yymsp[0].minor.yy78.vectorActions));
991                yygotominor.yy78.parameters = new vector<vector<SString> >(*(yymsp[0].minor.yy78.parameters));
992                delete yymsp[0].minor.yy78.vectorActions;
993                delete yymsp[0].minor.yy78.parameters;
994        }
995}
996#line 998 "conv_f8tof1_grammar.c"
997        break;
998      case 18: /* conditions ::= conditions COMMA conditions */
999#line 237 "conv_f8tof1_grammar.y"
1000{
1001        if (!syntaxOnly) {
1002                {
1003#if PARSER_DEBUG > 0
1004                        std::cout << "conditions ::= condition COMMA conditions." << std::endl;
1005#endif
1006                }
1007                yygotominor.yy78.vectorConditions = new vector<Condition>(*(yymsp[-2].minor.yy78.vectorConditions));
1008                for (vector<Condition>::iterator iter = yymsp[0].minor.yy78.vectorConditions->begin();
1009                         iter != yymsp[0].minor.yy78.vectorConditions->end(); iter++) {
1010                        yygotominor.yy78.vectorConditions->push_back(*iter);
1011                }       
1012                delete yymsp[-2].minor.yy78.vectorConditions;
1013                delete yymsp[0].minor.yy78.vectorConditions;
1014        }
1015}
1016#line 1018 "conv_f8tof1_grammar.c"
1017        break;
1018      case 19: /* conditions ::= condition */
1019#line 253 "conv_f8tof1_grammar.y"
1020{
1021        if (!syntaxOnly) {
1022                {
1023#if PARSER_DEBUG > 0
1024                        std::cout << "conditions ::= condition." << std::endl;
1025#endif
1026                }
1027                yygotominor.yy78.vectorConditions = new vector<Condition>();
1028                yygotominor.yy78.vectorConditions->push_back(*(yymsp[0].minor.yy78.cond));
1029                delete yymsp[0].minor.yy78.cond;
1030        }
1031}
1032#line 1034 "conv_f8tof1_grammar.c"
1033        break;
1034      case 20: /* condition ::= param_name LESS double_val */
1035#line 266 "conv_f8tof1_grammar.y"
1036{
1037        if (!syntaxOnly) {
1038                {
1039#if PARSER_DEBUG > 0
1040                        std::cout << "condition ::= param_name LESS double_val." << std::endl;
1041#endif
1042                }
1043                yygotominor.yy78.cond = new Condition();
1044                yygotominor.yy78.cond->relation = r_less;
1045                yygotominor.yy78.cond->parameter = *(yymsp[-2].minor.yy78.strValue);
1046                yygotominor.yy78.cond->value = yymsp[0].minor.yy78.dblValue;
1047                delete yymsp[-2].minor.yy78.strValue;
1048        }
1049}
1050#line 1052 "conv_f8tof1_grammar.c"
1051        break;
1052      case 21: /* condition ::= param_name LESS_EQUAL double_val */
1053#line 280 "conv_f8tof1_grammar.y"
1054{
1055        if (!syntaxOnly) {
1056                {
1057#if PARSER_DEBUG > 0
1058                        std::cout << "condition ::= param_name LESS_EQUAL double_val." << std::endl;
1059#endif
1060                }
1061                yygotominor.yy78.cond = new Condition();
1062                yygotominor.yy78.cond->relation = r_lessEqual;
1063                yygotominor.yy78.cond->parameter = *(yymsp[-2].minor.yy78.strValue);
1064                yygotominor.yy78.cond->value = yymsp[0].minor.yy78.dblValue;
1065                delete yymsp[-2].minor.yy78.strValue;
1066        }
1067}
1068#line 1070 "conv_f8tof1_grammar.c"
1069        break;
1070      case 22: /* condition ::= param_name NOT_EQUAL double_val */
1071#line 294 "conv_f8tof1_grammar.y"
1072{
1073        if (!syntaxOnly) {
1074                {
1075#if PARSER_DEBUG > 0
1076                        std::cout << "condition ::= param_name NOT_EQUAL double_val." << std::endl;
1077#endif
1078                }
1079                yygotominor.yy78.cond = new Condition();
1080                yygotominor.yy78.cond->relation = r_different;
1081                yygotominor.yy78.cond->parameter = *(yymsp[-2].minor.yy78.strValue);
1082                yygotominor.yy78.cond->value = yymsp[0].minor.yy78.dblValue;
1083                delete yymsp[-2].minor.yy78.strValue;
1084        }
1085}
1086#line 1088 "conv_f8tof1_grammar.c"
1087        break;
1088      case 23: /* condition ::= param_name EQUAL double_val */
1089#line 308 "conv_f8tof1_grammar.y"
1090{
1091        if (!syntaxOnly) {
1092                {
1093#if PARSER_DEBUG > 0
1094                        std::cout << "condition ::= param_name EQUAL double_val." << std::endl;
1095#endif
1096                }
1097                yygotominor.yy78.cond = new Condition();
1098                yygotominor.yy78.cond->relation = r_equal;
1099                yygotominor.yy78.cond->parameter = *(yymsp[-2].minor.yy78.strValue);
1100                yygotominor.yy78.cond->value = yymsp[0].minor.yy78.dblValue;
1101                delete yymsp[-2].minor.yy78.strValue;
1102        }
1103}
1104#line 1106 "conv_f8tof1_grammar.c"
1105        break;
1106      case 24: /* condition ::= param_name GREATER_EQUAL double_val */
1107#line 322 "conv_f8tof1_grammar.y"
1108{
1109        if (!syntaxOnly) {
1110                {
1111#if PARSER_DEBUG > 0
1112                        std::cout << "condition ::= param_name GREATER_EQUAL double_val." << std::endl;
1113#endif
1114                }
1115                yygotominor.yy78.cond = new Condition();
1116                yygotominor.yy78.cond->relation = r_greaterEqual;
1117                yygotominor.yy78.cond->parameter = *(yymsp[-2].minor.yy78.strValue);
1118                yygotominor.yy78.cond->value = yymsp[0].minor.yy78.dblValue;
1119                delete yymsp[-2].minor.yy78.strValue;
1120        }
1121}
1122#line 1124 "conv_f8tof1_grammar.c"
1123        break;
1124      case 25: /* condition ::= param_name GREATER double_val */
1125#line 336 "conv_f8tof1_grammar.y"
1126{
1127        if (!syntaxOnly) {
1128                {
1129#if PARSER_DEBUG > 0
1130                        std::cout << "condition ::= param_name GREATER double_val." << std::endl;
1131#endif
1132                }
1133                yygotominor.yy78.cond = new Condition();
1134                yygotominor.yy78.cond->relation = r_greater;
1135                yygotominor.yy78.cond->parameter = *(yymsp[-2].minor.yy78.strValue);
1136                yygotominor.yy78.cond->value = yymsp[0].minor.yy78.dblValue;
1137                delete yymsp[-2].minor.yy78.strValue;
1138        }
1139}
1140#line 1142 "conv_f8tof1_grammar.c"
1141        break;
1142      case 26: /* real_prod ::= */
1143#line 351 "conv_f8tof1_grammar.y"
1144{
1145        if (!syntaxOnly) {
1146                {
1147#if PARSER_DEBUG > 0
1148                        std::cout << "real_prod ::= ." << std::endl;
1149#endif
1150                }
1151                yygotominor.yy78.vectorActions = new vector<Action*>();
1152                yygotominor.yy78.parameters = new vector<vector<SString> >();
1153        }
1154}
1155#line 1157 "conv_f8tof1_grammar.c"
1156        break;
1157      case 27: /* real_prod ::= prod_piece real_prod */
1158#line 362 "conv_f8tof1_grammar.y"
1159{
1160        if (!syntaxOnly) {
1161                {
1162#if PARSER_DEBUG > 0
1163                        std::cout << "real_prod ::= prod_piece real_prod." << std::endl;
1164                        for (vector<Action*>::iterator actIter = yymsp[-1].minor.yy89.actions->begin(); actIter != yymsp[-1].minor.yy89.actions->end(); actIter++) {
1165                                cout << "\t" << (*actIter)->name << endl;
1166                        }
1167#endif
1168                }
1169                //yygotominor.yy78 = yymsp[-1].minor.yy89.clone() && yygotominor.yy78.append(yymsp[0].minor.yy78)
1170                yygotominor.yy78.vectorActions = new vector<Action*>(*(yymsp[-1].minor.yy89.actions));
1171                yygotominor.yy78.parameters = new vector<vector<SString> >(*(yymsp[-1].minor.yy89.parameters));
1172                if (yymsp[0].minor.yy78.vectorActions != NULL && yymsp[0].minor.yy78.parameters != NULL) {
1173                        for (vector<Action*>::iterator iter = yymsp[0].minor.yy78.vectorActions->begin(); iter != yymsp[0].minor.yy78.vectorActions->end(); iter++) {
1174                                yygotominor.yy78.vectorActions->push_back(*iter);
1175                        }
1176                        for(vector<vector<SString> >::iterator iter = yymsp[0].minor.yy78.parameters->begin(); iter != yymsp[0].minor.yy78.parameters->end(); iter++) {
1177                                yygotominor.yy78.parameters->push_back(*iter);
1178                        }
1179                        delete yymsp[0].minor.yy78.vectorActions;
1180                        delete yymsp[0].minor.yy78.parameters;
1181                } else {
1182#if PARSER_DEBUG > 0
1183                        cout << "\tNULL~~~~~~~~~~~~" << endl;
1184#endif
1185                }
1186               
1187                delete yymsp[-1].minor.yy89.actions;
1188                delete yymsp[-1].minor.yy89.parameters;
1189        }
1190}
1191#line 1193 "conv_f8tof1_grammar.c"
1192        break;
1193      case 28: /* real_prod ::= FORLOOP_BEGIN real_prod FORLOOP_END LPAREN single_val RPAREN real_prod */
1194#line 394 "conv_f8tof1_grammar.y"
1195{
1196        if (!syntaxOnly) {
1197                {
1198#if PARSER_DEBUG > 0
1199                        std::cout << "real_prod ::= FORLOOP_BEGIN real_prod FORLOOP_END LPAREN single_val RPAREN." << std::endl;
1200#endif
1201                }
1202                yygotominor.yy78.vectorActions = new vector<Action*>();
1203                yygotominor.yy78.parameters = new vector<vector<SString> >();
1204                int iterations = (int) parseExpression(*(yymsp[-2].minor.yy78.strValue));
1205                for (int i = 0; i < iterations; i++) {
1206                        for (vector<Action*>::iterator iter = yymsp[-5].minor.yy78.vectorActions->begin(); iter != yymsp[-5].minor.yy78.vectorActions->end(); iter++) {
1207                                yygotominor.yy78.vectorActions->push_back(*iter);
1208                        }
1209                        for (vector<vector<SString> >::iterator iter = yymsp[-5].minor.yy78.parameters->begin(); iter != yymsp[-5].minor.yy78.parameters->end(); iter++) {
1210                                yygotominor.yy78.parameters->push_back(*iter);
1211                        }
1212                }
1213                for (vector<Action*>::iterator iter = yymsp[0].minor.yy78.vectorActions->begin(); iter != yymsp[0].minor.yy78.vectorActions->end(); iter++) {
1214                        yygotominor.yy78.vectorActions->push_back(*iter);
1215                }
1216                for (vector<vector<SString> >::iterator iter = yymsp[0].minor.yy78.parameters->begin(); iter != yymsp[0].minor.yy78.parameters->end(); iter++) {
1217                        yygotominor.yy78.parameters->push_back(*iter);
1218                }
1219                delete yymsp[-5].minor.yy78.vectorActions;
1220                delete yymsp[-5].minor.yy78.parameters;
1221                delete yymsp[-2].minor.yy78.strValue;
1222                delete yymsp[0].minor.yy78.vectorActions;
1223                delete yymsp[0].minor.yy78.parameters;
1224        }
1225}
1226#line 1228 "conv_f8tof1_grammar.c"
1227        break;
1228      case 29: /* prod_piece ::= prod_name LPAREN multiple_val RPAREN */
1229#line 426 "conv_f8tof1_grammar.y"
1230{
1231        if (!syntaxOnly) {
1232                {
1233#if PARSER_DEBUG > 0
1234                        std::cout << "prod_piece ::= prod_name LPAREN multiple_val RPAREN." << std::endl;
1235#endif
1236                }
1237                yygotominor.yy89.actions = new vector<Action*>();
1238                yygotominor.yy89.parameters = new vector<vector<SString> >();
1239               
1240                Production *p = lsys->productions.find(sstringToString(*(yymsp[-3].minor.yy78.strValue)))->second;
1241                yygotominor.yy89.actions->push_back(p);
1242                yygotominor.yy89.parameters->push_back(*(yymsp[-1].minor.yy78.vectorStr));
1243                delete yymsp[-3].minor.yy78.strValue;
1244                delete yymsp[-1].minor.yy78.vectorStr;
1245        }
1246}
1247#line 1249 "conv_f8tof1_grammar.c"
1248        break;
1249      case 30: /* prod_piece ::= prod_name LPAREN RPAREN */
1250#line 443 "conv_f8tof1_grammar.y"
1251{
1252        if (!syntaxOnly) {
1253                {
1254#if PARSER_DEBUG > 0
1255                        std::cout << "prod_piece ::= prod_name LPAREN RPAREN." << std::endl;
1256#endif
1257                }
1258                yygotominor.yy89.actions = new vector<Action*>();
1259                yygotominor.yy89.parameters = new vector<vector<SString> >();
1260               
1261                Production *p = lsys->productions.find(sstringToString(*(yymsp[-2].minor.yy78.strValue)))->second;
1262                yygotominor.yy89.actions->push_back(p);
1263                delete yymsp[-2].minor.yy78.strValue;
1264        }
1265}
1266#line 1268 "conv_f8tof1_grammar.c"
1267        break;
1268      case 31: /* prod_piece ::= command */
1269#line 458 "conv_f8tof1_grammar.y"
1270{
1271        if (!syntaxOnly) {
1272                {
1273#if PARSER_DEBUG > 0
1274                        std::cout << "prod_piece ::= command."  << std::endl;
1275#endif
1276                }
1277                yygotominor.yy89.actions = new vector<Action*>();
1278                yygotominor.yy89.parameters = new vector<vector<SString> >();
1279                PrimitiveProduction *pp = lsys->getPrimitiveProduction(*(yymsp[0].minor.yy78.strValue));
1280                yygotominor.yy89.actions->push_back(pp);
1281                vector<SString> param;
1282                yygotominor.yy89.parameters->push_back(param);
1283                delete yymsp[0].minor.yy78.strValue;
1284        }
1285}
1286#line 1288 "conv_f8tof1_grammar.c"
1287        break;
1288      case 32: /* prod_piece ::= param_name */
1289#line 474 "conv_f8tof1_grammar.y"
1290{
1291        if (!syntaxOnly) {
1292                {
1293#if PARSER_DEBUG > 0
1294                        std::cout << "prod_piece ::= paramName." << std::endl;
1295#endif
1296                }
1297                yygotominor.yy89.actions = new vector<Action*>();
1298                yygotominor.yy89.parameters = new vector<vector<SString> >();
1299                ParamProduction *pp = lsys->getParamProduction(*(yymsp[0].minor.yy78.strValue));
1300                yygotominor.yy89.actions->push_back(pp);
1301                vector<SString> param;
1302                param.push_back(*(yymsp[0].minor.yy78.strValue));
1303                yygotominor.yy89.parameters->push_back(param);
1304                delete yymsp[0].minor.yy78.strValue;
1305        }
1306}
1307#line 1309 "conv_f8tof1_grammar.c"
1308        break;
1309      case 33: /* prod_piece ::= neuron */
1310#line 491 "conv_f8tof1_grammar.y"
1311{
1312        if (!syntaxOnly) {
1313                {
1314#if PARSER_DEBUG > 0
1315                        std::cout << "prod_piece ::= neuron." << std::endl;
1316#endif
1317                }
1318                yygotominor.yy89.actions = new vector<Action*>();
1319                yygotominor.yy89.parameters = new vector<vector<SString> >();
1320                NeuronProduction *np = new NeuronProduction(*(yymsp[0].minor.yy78.strValue));
1321                lsys->neuronProductions.push_back(np);
1322                yygotominor.yy89.actions->push_back(np);
1323                vector<SString> param;
1324                yygotominor.yy89.parameters->push_back(param);
1325                delete yymsp[0].minor.yy78.strValue;           
1326        }
1327}
1328#line 1330 "conv_f8tof1_grammar.c"
1329        break;
1330      case 34: /* multiple_val ::= single_val */
1331#line 509 "conv_f8tof1_grammar.y"
1332{
1333        if (!syntaxOnly) {
1334                {
1335#if PARSER_DEBUG > 0
1336                        std::cout << "multiple_val ::= single_val." << std::endl;
1337#endif
1338                }
1339                yygotominor.yy78.vectorStr = new vector<SString>();
1340                yygotominor.yy78.vectorStr->push_back(SString(*(yymsp[0].minor.yy78.strValue)));
1341                delete yymsp[0].minor.yy78.strValue;
1342        }
1343}
1344#line 1346 "conv_f8tof1_grammar.c"
1345        break;
1346      case 35: /* multiple_val ::= multiple_val COMMA multiple_val */
1347#line 521 "conv_f8tof1_grammar.y"
1348{
1349        if (!syntaxOnly) {
1350                {
1351#if PARSER_DEBUG > 0
1352                        std::cout << "multiple_val ::= multiple_val COMMA multiple_val." << std::endl;
1353#endif
1354                }
1355                yygotominor.yy78.vectorStr = new vector<SString>();
1356                for (vector<SString>::iterator iter = yymsp[-2].minor.yy78.vectorStr->begin(); iter != yymsp[-2].minor.yy78.vectorStr->end(); iter++) {
1357                        yygotominor.yy78.vectorStr->push_back(*iter);
1358                }
1359                for (vector<SString>::iterator iter = yymsp[0].minor.yy78.vectorStr->begin(); iter != yymsp[0].minor.yy78.vectorStr->end(); iter++) {
1360                        yygotominor.yy78.vectorStr->push_back(*iter);
1361                }
1362                delete yymsp[-2].minor.yy78.vectorStr;
1363                delete yymsp[0].minor.yy78.vectorStr;
1364        }
1365}
1366#line 1368 "conv_f8tof1_grammar.c"
1367        break;
1368      case 36: /* single_val ::= double_val */
1369#line 540 "conv_f8tof1_grammar.y"
1370{
1371        if (!syntaxOnly) {
1372                {
1373#if PARSER_DEBUG > 0
1374                        std::cout << "single_val ::= double_val." << std::endl;
1375#endif
1376                }
1377                yygotominor.yy78.strValue = new SString(SString::valueOf(yymsp[0].minor.yy78.dblValue) + ";");
1378                delete yymsp[0].minor.yy78.strValue;
1379        }
1380}
1381#line 1383 "conv_f8tof1_grammar.c"
1382        break;
1383      case 37: /* single_val ::= param_name */
1384#line 551 "conv_f8tof1_grammar.y"
1385{
1386        if (!syntaxOnly) {
1387                {
1388#if PARSER_DEBUG > 0
1389                        std::cout << "single_val ::= param_name." << std::endl;
1390#endif
1391                }
1392                yygotominor.yy78.strValue = new SString(*(yymsp[0].minor.yy78.strValue) + ";");
1393                delete yymsp[0].minor.yy78.strValue;
1394        }
1395}
1396#line 1398 "conv_f8tof1_grammar.c"
1397        break;
1398      case 38: /* single_val ::= single_val PLUS single_val */
1399#line 562 "conv_f8tof1_grammar.y"
1400{
1401        if (!syntaxOnly) {
1402                {
1403#if PARSER_DEBUG > 0
1404                        std::cout << "single_val ::= single_val PLUS single_val." << std::endl;
1405#endif
1406                }
1407                yygotominor.yy78.strValue = new SString(*(yymsp[-2].minor.yy78.strValue) + *(yymsp[0].minor.yy78.strValue) + "+;");
1408                delete yymsp[-2].minor.yy78.strValue;
1409                delete yymsp[0].minor.yy78.strValue;
1410        }
1411}
1412#line 1414 "conv_f8tof1_grammar.c"
1413        break;
1414      case 39: /* single_val ::= single_val MINUS single_val */
1415#line 574 "conv_f8tof1_grammar.y"
1416{
1417        if (!syntaxOnly) {
1418                {
1419#if PARSER_DEBUG > 0
1420                        std::cout << "single_val ::= single_val MINUS single_val." << std::endl;
1421#endif
1422                }
1423                yygotominor.yy78.strValue = new SString(*(yymsp[-2].minor.yy78.strValue) + *(yymsp[0].minor.yy78.strValue) + "-;");
1424                delete yymsp[-2].minor.yy78.strValue;
1425                delete yymsp[0].minor.yy78.strValue;
1426        }
1427}
1428#line 1430 "conv_f8tof1_grammar.c"
1429        break;
1430      case 40: /* single_val ::= single_val TIMES single_val */
1431#line 586 "conv_f8tof1_grammar.y"
1432{
1433        if (!syntaxOnly) {
1434                {
1435#if PARSER_DEBUG > 0
1436                        std::cout << "single_val ::= single_val TIMES single_val." << std::endl;
1437#endif
1438                }
1439                yygotominor.yy78.strValue = new SString(*(yymsp[-2].minor.yy78.strValue) + *(yymsp[0].minor.yy78.strValue) + "*;");
1440                delete yymsp[-2].minor.yy78.strValue;
1441                delete yymsp[0].minor.yy78.strValue;
1442        }
1443}
1444#line 1446 "conv_f8tof1_grammar.c"
1445        break;
1446      case 41: /* single_val ::= single_val DIV single_val */
1447#line 598 "conv_f8tof1_grammar.y"
1448{
1449        if (!syntaxOnly) {
1450                {
1451#if PARSER_DEBUG > 0
1452                        std::cout << "single_val ::= single_val DIV single_val." << std::endl;
1453#endif
1454                }
1455                yygotominor.yy78.strValue = new SString(*(yymsp[-2].minor.yy78.strValue) + *(yymsp[0].minor.yy78.strValue) + "/;");
1456                delete yymsp[-2].minor.yy78.strValue;
1457                delete yymsp[0].minor.yy78.strValue;
1458        }
1459}
1460#line 1462 "conv_f8tof1_grammar.c"
1461        break;
1462      case 42: /* double_val ::= DOUBLE_VAL */
1463#line 611 "conv_f8tof1_grammar.y"
1464{
1465        if (!syntaxOnly) {
1466                {
1467#if PARSER_DEBUG > 0
1468                        std::cout << "double_val ::= DOUBLE_VAL. -> " << (string(yymsp[0].minor.yy0.strArrValue)).c_str() << std::endl;
1469#endif
1470                }
1471                yygotominor.yy78.dblValue = atof((string(yymsp[0].minor.yy0.strArrValue)).c_str());
1472        }
1473}
1474#line 1476 "conv_f8tof1_grammar.c"
1475        break;
1476      case 43: /* param_name ::= PARAM_NAME */
1477#line 621 "conv_f8tof1_grammar.y"
1478{
1479        if (!syntaxOnly) {
1480                {
1481#if PARSER_DEBUG > 0
1482                        std::cout << "param_name ::= PARAM_NAME." << std::endl;
1483#endif
1484                }
1485                yygotominor.yy78.strValue = new SString(string(yymsp[0].minor.yy0.strArrValue).c_str());
1486        }
1487}
1488#line 1490 "conv_f8tof1_grammar.c"
1489        break;
1490      case 44: /* prod_name ::= PROD_NAME */
1491#line 631 "conv_f8tof1_grammar.y"
1492{
1493        if (!syntaxOnly) {
1494                {
1495#if PARSER_DEBUG > 0
1496                        std::cout << "prod_name ::= PROD_NAME." << std::endl;
1497#endif
1498                }
1499                yygotominor.yy78.strValue = new SString(string(yymsp[0].minor.yy0.strArrValue).c_str());
1500        }
1501}
1502#line 1504 "conv_f8tof1_grammar.c"
1503        break;
1504      case 45: /* command ::= COMMAND */
1505#line 641 "conv_f8tof1_grammar.y"
1506{
1507        if (!syntaxOnly) {
1508                {
1509#if PARSER_DEBUG > 0
1510                        std::cout << "command ::= COMMAND." << std::endl;
1511#endif
1512                }
1513                yygotominor.yy78.strValue = new SString(string(yymsp[0].minor.yy0.strArrValue).c_str());
1514        }
1515}
1516#line 1518 "conv_f8tof1_grammar.c"
1517        break;
1518      case 46: /* neuron ::= NEURON */
1519#line 651 "conv_f8tof1_grammar.y"
1520{
1521        if (!syntaxOnly) {
1522                {
1523#if PARSER_DEBUG > 0
1524                        std::cout << "neuron ::= NEURON." << std::endl;
1525#endif
1526                }
1527                yygotominor.yy78.strValue = new SString(string(yymsp[0].minor.yy0.strArrValue).c_str());
1528        }
1529}
1530#line 1532 "conv_f8tof1_grammar.c"
1531        break;
1532  };
1533  yygoto = yyRuleInfo[yyruleno].lhs;
1534  yysize = yyRuleInfo[yyruleno].nrhs;
1535  yypParser->yyidx -= yysize;
1536  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,yygoto);
1537  if( yyact < YYNSTATE ){
1538#ifdef NDEBUG
1539    /* If we are not debugging and the reduce action popped at least
1540    ** one element off the stack, then we can push the new element back
1541    ** onto the stack here, and skip the stack overflow test in yy_shift().
1542    ** That gives a significant speed improvement. */
1543    if( yysize ){
1544      yypParser->yyidx++;
1545      yymsp -= yysize-1;
1546      yymsp->stateno = yyact;
1547      yymsp->major = yygoto;
1548      yymsp->minor = yygotominor;
1549    }else
1550#endif
1551    {
1552      yy_shift(yypParser,yyact,yygoto,&yygotominor);
1553    }
1554  }else{
1555    assert( yyact == YYNSTATE + YYNRULE + 1 );
1556    yy_accept(yypParser);
1557  }
1558}
1559
1560/*
1561** The following code executes when the parse fails
1562*/
1563static void yy_parse_failed(
1564  yyParser *yypParser           /* The parser */
1565){
1566  ParseARG_FETCH;
1567#ifndef NDEBUG
1568  if( yyTraceFILE ){
1569    fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
1570  }
1571#endif
1572  while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
1573  /* Here code is inserted which will be executed whenever the
1574  ** parser fails */
1575  ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
1576}
1577
1578/*
1579** The following code executes when a syntax error first occurs.
1580*/
1581static void yy_syntax_error(
1582  yyParser *yypParser,           /* The parser */
1583  int yymajor,                   /* The major type of the error token */
1584  YYMINORTYPE yyminor            /* The minor type of the error token */
1585){
1586  ParseARG_FETCH;
1587#define TOKEN (yyminor.yy0)
1588  ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
1589}
1590
1591/*
1592** The following is executed when the parser accepts
1593*/
1594static void yy_accept(
1595  yyParser *yypParser           /* The parser */
1596){
1597  ParseARG_FETCH;
1598#ifndef NDEBUG
1599  if( yyTraceFILE ){
1600    fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
1601  }
1602#endif
1603  while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
1604  /* Here code is inserted which will be executed whenever the
1605  ** parser accepts */
1606  ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
1607}
1608
1609/* The main parser program.
1610** The first argument is a pointer to a structure obtained from
1611** "ParseAlloc" which describes the current state of the parser.
1612** The second argument is the major token number.  The third is
1613** the minor token.  The fourth optional argument is whatever the
1614** user wants (and specified in the grammar) and is available for
1615** use by the action routines.
1616**
1617** Inputs:
1618** <ul>
1619** <li> A pointer to the parser (an opaque structure.)
1620** <li> The major token number.
1621** <li> The minor token number.
1622** <li> An option argument of a grammar-specified type.
1623** </ul>
1624**
1625** Outputs:
1626** None.
1627*/
1628void Parse(
1629  void *yyp,                   /* The parser */
1630  int yymajor,                 /* The major token code number */
1631  ParseTOKENTYPE yyminor       /* The value for the token */
1632  ParseARG_PDECL               /* Optional %extra_argument parameter */
1633){
1634  YYMINORTYPE yyminorunion;
1635  int yyact;            /* The parser action. */
1636  int yyendofinput;     /* True if we are at the end of input */
1637#ifdef YYERRORSYMBOL
1638  int yyerrorhit = 0;   /* True if yymajor has invoked an error */
1639#endif
1640  yyParser *yypParser;  /* The parser */
1641
1642  /* (re)initialize the parser, if necessary */
1643  yypParser = (yyParser*)yyp;
1644  if( yypParser->yyidx<0 ){
1645#if YYSTACKDEPTH<=0
1646    if( yypParser->yystksz <=0 ){
1647      memset(&yyminorunion, 0, sizeof(yyminorunion));
1648      yyStackOverflow(yypParser, &yyminorunion);
1649      return;
1650    }
1651#endif
1652    yypParser->yyidx = 0;
1653    yypParser->yyerrcnt = -1;
1654    yypParser->yystack[0].stateno = 0;
1655    yypParser->yystack[0].major = 0;
1656  }
1657  yyminorunion.yy0 = yyminor;
1658  yyendofinput = (yymajor==0);
1659  ParseARG_STORE;
1660
1661#ifndef NDEBUG
1662  if( yyTraceFILE ){
1663    fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
1664  }
1665#endif
1666
1667  do{
1668    yyact = yy_find_shift_action(yypParser,yymajor);
1669    if( yyact<YYNSTATE ){
1670      assert( !yyendofinput );  /* Impossible to shift the $ token */
1671      yy_shift(yypParser,yyact,yymajor,&yyminorunion);
1672      yypParser->yyerrcnt--;
1673      yymajor = YYNOCODE;
1674    }else if( yyact < YYNSTATE + YYNRULE ){
1675      yy_reduce(yypParser,yyact-YYNSTATE);
1676    }else{
1677      assert( yyact == YY_ERROR_ACTION );
1678#ifdef YYERRORSYMBOL
1679      int yymx;
1680#endif
1681#ifndef NDEBUG
1682      if( yyTraceFILE ){
1683        fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
1684      }
1685#endif
1686#ifdef YYERRORSYMBOL
1687      /* A syntax error has occurred.
1688      ** The response to an error depends upon whether or not the
1689      ** grammar defines an error token "ERROR". 
1690      **
1691      ** This is what we do if the grammar does define ERROR:
1692      **
1693      **  * Call the %syntax_error function.
1694      **
1695      **  * Begin popping the stack until we enter a state where
1696      **    it is legal to shift the error symbol, then shift
1697      **    the error symbol.
1698      **
1699      **  * Set the error count to three.
1700      **
1701      **  * Begin accepting and shifting new tokens.  No new error
1702      **    processing will occur until three tokens have been
1703      **    shifted successfully.
1704      **
1705      */
1706      if( yypParser->yyerrcnt<0 ){
1707        yy_syntax_error(yypParser,yymajor,yyminorunion);
1708      }
1709      yymx = yypParser->yystack[yypParser->yyidx].major;
1710      if( yymx==YYERRORSYMBOL || yyerrorhit ){
1711#ifndef NDEBUG
1712        if( yyTraceFILE ){
1713          fprintf(yyTraceFILE,"%sDiscard input token %s\n",
1714             yyTracePrompt,yyTokenName[yymajor]);
1715        }
1716#endif
1717        yy_destructor(yymajor,&yyminorunion);
1718        yymajor = YYNOCODE;
1719      }else{
1720         while(
1721          yypParser->yyidx >= 0 &&
1722          yymx != YYERRORSYMBOL &&
1723          (yyact = yy_find_reduce_action(
1724                        yypParser->yystack[yypParser->yyidx].stateno,
1725                        YYERRORSYMBOL)) >= YYNSTATE
1726        ){
1727          yy_pop_parser_stack(yypParser);
1728        }
1729        if( yypParser->yyidx < 0 || yymajor==0 ){
1730          yy_destructor(yymajor,&yyminorunion);
1731          yy_parse_failed(yypParser);
1732          yymajor = YYNOCODE;
1733        }else if( yymx!=YYERRORSYMBOL ){
1734          YYMINORTYPE u2;
1735          u2.YYERRSYMDT = 0;
1736          yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
1737        }
1738      }
1739      yypParser->yyerrcnt = 3;
1740      yyerrorhit = 1;
1741#else  /* YYERRORSYMBOL is not defined */
1742      /* This is what we do if the grammar does not define ERROR:
1743      **
1744      **  * Report an error message, and throw away the input token.
1745      **
1746      **  * If the input token is $, then fail the parse.
1747      **
1748      ** As before, subsequent error messages are suppressed until
1749      ** three input tokens have been successfully shifted.
1750      */
1751      if( yypParser->yyerrcnt<=0 ){
1752        yy_syntax_error(yypParser,yymajor,yyminorunion);
1753      }
1754      yypParser->yyerrcnt = 3;
1755      yy_destructor(yymajor,&yyminorunion);
1756      if( yyendofinput ){
1757        yy_parse_failed(yypParser);
1758      }
1759      yymajor = YYNOCODE;
1760#endif
1761    }
1762  }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
1763  return;
1764}
1765
1766
Note: See TracBrowser for help on using the repository browser.