lac : bd24ab5aaf0a01f3020c34f9d0cfc113a918b5d8

     1: /*
     2: ** 2000-05-29
     3: **
     4: ** The author disclaims copyright to this source code.  In place of
     5: ** a legal notice, here is a blessing:
     6: **
     7: **    May you do good and not evil.
     8: **    May you find forgiveness for yourself and forgive others.
     9: **    May you share freely, never taking more than you give.
    10: **
    11: *************************************************************************
    12: ** Driver template for the LEMON parser generator.
    13: **
    14: ** The "lemon" program processes an LALR(1) input grammar file, then uses
    15: ** this template to construct a parser.  The "lemon" program inserts text
    16: ** at each "%%" line.  Also, any "P-a-r-s-e" identifer prefix (without the
    17: ** interstitial "-" characters) contained in this template is changed into
    18: ** the value of the %name directive from the grammar.  Otherwise, the content
    19: ** of this template is copied straight through into the generate parser
    20: ** source file.
    21: **
    22: ** The following is the concatenation of all %include directives from the
    23: ** input grammar file:
    24: */
    25: #include <stdio.h>
    26: /************ Begin %include sections from the grammar ************************/
    27: #line 1 "sexpr.lmn"
    28:  #include <lac.h> 
    29: #line 2 "sexpr.lmn"
    30:  #include <assert.h> 
    31: #line 3 "sexpr.lmn"
    32:  #include "private.h" 
    33: #line 34 "sexpr.c"
    34: /**************** End of %include directives **********************************/
    35: /* These constants specify the various numeric values for terminal symbols
    36: ** in a format understandable to "makeheaders".  This section is blank unless
    37: ** "lemon" is run with the "-m" command-line option.
    38: ***************** Begin makeheaders token definitions *************************/
    39: /**************** End makeheaders token definitions ***************************/
    40: 
    41: /* The next sections is a series of control #defines.
    42: ** various aspects of the generated parser.
    43: **    YYCODETYPE         is the data type used to store the integer codes
    44: **                       that represent terminal and non-terminal symbols.
    45: **                       "unsigned char" is used if there are fewer than
    46: **                       256 symbols.  Larger types otherwise.
    47: **    YYNOCODE           is a number of type YYCODETYPE that is not used for
    48: **                       any terminal or nonterminal symbol.
    49: **    YYFALLBACK         If defined, this indicates that one or more tokens
    50: **                       (also known as: "terminal symbols") have fall-back
    51: **                       values which should be used if the original symbol
    52: **                       would not parse.  This permits keywords to sometimes
    53: **                       be used as identifiers, for example.
    54: **    YYACTIONTYPE       is the data type used for "action codes" - numbers
    55: **                       that indicate what to do in response to the next
    56: **                       token.
    57: **    ParseTOKENTYPE     is the data type used for minor type for terminal
    58: **                       symbols.  Background: A "minor type" is a semantic
    59: **                       value associated with a terminal or non-terminal
    60: **                       symbols.  For example, for an "ID" terminal symbol,
    61: **                       the minor type might be the name of the identifier.
    62: **                       Each non-terminal can have a different minor type.
    63: **                       Terminal symbols all have the same minor type, though.
    64: **                       This macros defines the minor type for terminal 
    65: **                       symbols.
    66: **    YYMINORTYPE        is the data type used for all minor types.
    67: **                       This is typically a union of many types, one of
    68: **                       which is ParseTOKENTYPE.  The entry in the union
    69: **                       for terminal symbols is called "yy0".
    70: **    YYSTACKDEPTH       is the maximum depth of the parser's stack.  If
    71: **                       zero the stack is dynamically sized using realloc()
    72: **    ParseARG_SDECL     A static variable declaration for the %extra_argument
    73: **    ParseARG_PDECL     A parameter declaration for the %extra_argument
    74: **    ParseARG_STORE     Code to store %extra_argument into yypParser
    75: **    ParseARG_FETCH     Code to extract %extra_argument from yypParser
    76: **    YYERRORSYMBOL      is the code number of the error symbol.  If not
    77: **                       defined, then do no error processing.
    78: **    YYNSTATE           the combined number of states.
    79: **    YYNRULE            the number of rules in the grammar
    80: **    YY_MAX_SHIFT       Maximum value for shift actions
    81: **    YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
    82: **    YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
    83: **    YY_MIN_REDUCE      Maximum value for reduce actions
    84: **    YY_ERROR_ACTION    The yy_action[] code for syntax error
    85: **    YY_ACCEPT_ACTION   The yy_action[] code for accept
    86: **    YY_NO_ACTION       The yy_action[] code for no-op
    87: */
    88: #ifndef INTERFACE
    89: # define INTERFACE 1
    90: #endif
    91: /************* Begin control #defines *****************************************/
    92: #define YYCODETYPE unsigned char
    93: #define YYNOCODE 21
    94: #define YYACTIONTYPE unsigned char
    95: #define ParseTOKENTYPE  lreg_t 
    96: typedef union {
    97:   int yyinit;
    98:   ParseTOKENTYPE yy0;
    99:   lreg_t yy6;
   100:   int yy41;
   101: } YYMINORTYPE;
   102: #ifndef YYSTACKDEPTH
   103: #define YYSTACKDEPTH 100
   104: #endif
   105: #define ParseARG_SDECL  struct parse_cb *cb ;
   106: #define ParseARG_PDECL , struct parse_cb *cb 
   107: #define ParseARG_FETCH  struct parse_cb *cb  = yypParser->cb 
   108: #define ParseARG_STORE yypParser->cb  = cb 
   109: #define YYERRORSYMBOL 13
   110: #define YYERRSYMDT yy41
   111: #define YYNSTATE             14
   112: #define YYNRULE              19
   113: #define YY_MAX_SHIFT         13
   114: #define YY_MIN_SHIFTREDUCE   29
   115: #define YY_MAX_SHIFTREDUCE   47
   116: #define YY_MIN_REDUCE        48
   117: #define YY_MAX_REDUCE        66
   118: #define YY_ERROR_ACTION      67
   119: #define YY_ACCEPT_ACTION     68
   120: #define YY_NO_ACTION         69
   121: /************* End control #defines *******************************************/
   122: 
   123: /* Define the yytestcase() macro to be a no-op if is not already defined
   124: ** otherwise.
   125: **
   126: ** Applications can choose to define yytestcase() in the %include section
   127: ** to a macro that can assist in verifying code coverage.  For production
   128: ** code the yytestcase() macro should be turned off.  But it is useful
   129: ** for testing.
   130: */
   131: #ifndef yytestcase
   132: # define yytestcase(X)
   133: #endif
   134: 
   135: 
   136: /* Next are the tables used to determine what action to take based on the
   137: ** current state and lookahead token.  These tables are used to implement
   138: ** functions that take a state number and lookahead value and return an
   139: ** action integer.  
   140: **
   141: ** Suppose the action integer is N.  Then the action is determined as
   142: ** follows
   143: **
   144: **   0 <= N <= YY_MAX_SHIFT             Shift N.  That is, push the lookahead
   145: **                                      token onto the stack and goto state N.
   146: **
   147: **   N between YY_MIN_SHIFTREDUCE       Shift to an arbitrary state then
   148: **     and YY_MAX_SHIFTREDUCE           reduce by rule N-YY_MIN_SHIFTREDUCE.
   149: **
   150: **   N between YY_MIN_REDUCE            Reduce by rule N-YY_MIN_REDUCE
   151: **     and YY_MAX_REDUCE
   152: **
   153: **   N == YY_ERROR_ACTION               A syntax error has occurred.
   154: **
   155: **   N == YY_ACCEPT_ACTION              The parser accepts its input.
   156: **
   157: **   N == YY_NO_ACTION                  No such action.  Denotes unused
   158: **                                      slots in the yy_action[] table.
   159: **
   160: ** The action table is constructed as a single large table named yy_action[].
   161: ** Given state S and lookahead X, the action is computed as either:
   162: **
   163: **    (A)   N = yy_action[ yy_shift_ofst[S] + X ]
   164: **    (B)   N = yy_default[S]
   165: **
   166: ** The (A) formula is preferred.  The B formula is used instead if:
   167: **    (1)  The yy_shift_ofst[S]+X value is out of range, or
   168: **    (2)  yy_lookahead[yy_shift_ofst[S]+X] is not equal to X, or
   169: **    (3)  yy_shift_ofst[S] equal YY_SHIFT_USE_DFLT.
   170: ** (Implementation note: YY_SHIFT_USE_DFLT is chosen so that
   171: ** YY_SHIFT_USE_DFLT+X will be out of range for all possible lookaheads X.
   172: ** Hence only tests (1) and (2) need to be evaluated.)
   173: **
   174: ** The formulas above are for computing the action when the lookahead is
   175: ** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
   176: ** a reduce action) then the yy_reduce_ofst[] array is used in place of
   177: ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
   178: ** YY_SHIFT_USE_DFLT.
   179: **
   180: ** The following are the tables generated in this section:
   181: **
   182: **  yy_action[]        A single table containing all actions.
   183: **  yy_lookahead[]     A table containing the lookahead for each entry in
   184: **                     yy_action.  Used to detect hash collisions.
   185: **  yy_shift_ofst[]    For each state, the offset into yy_action for
   186: **                     shifting terminals.
   187: **  yy_reduce_ofst[]   For each state, the offset into yy_action for
   188: **                     shifting non-terminals after a reduce.
   189: **  yy_default[]       Default action for each state.
   190: **
   191: *********** Begin parsing tables **********************************************/
   192: #define YY_ACTTAB_COUNT (90)
   193: static const YYACTIONTYPE yy_action[] = {
   194:  /*     0 */     9,    8,    7,    6,    3,    5,   66,   42,   43,   44,
   195:  /*    10 */    45,    9,    8,    7,    6,    3,   39,   37,   42,   43,
   196:  /*    20 */    44,   45,   13,    9,    8,    7,    6,    3,   36,   65,
   197:  /*    30 */    42,   43,   44,   45,    9,    8,    7,    6,    3,   50,
   198:  /*    40 */    50,   42,   43,   44,   45,    2,   50,   50,   31,   38,
   199:  /*    50 */    11,    2,   50,   50,   31,   38,   40,   10,   50,   68,
   200:  /*    60 */     4,   50,   50,    1,   50,   29,   31,   38,   31,   38,
   201:  /*    70 */    12,   50,   35,   31,   38,   31,   38,   50,   34,   50,
   202:  /*    80 */    33,   31,   38,   31,   38,   32,   50,   50,   31,   38,
   203: };
   204: static const YYCODETYPE yy_lookahead[] = {
   205:  /*     0 */     2,    3,    4,    5,    6,    7,    0,    9,   10,   11,
   206:  /*    10 */    12,    2,    3,    4,    5,    6,    8,    8,    9,   10,
   207:  /*    20 */    11,   12,    1,    2,    3,    4,    5,    6,    8,    0,
   208:  /*    30 */     9,   10,   11,   12,    2,    3,    4,    5,    6,   20,
   209:  /*    40 */    20,    9,   10,   11,   12,   14,   20,   20,   17,   18,
   210:  /*    50 */    19,   14,   20,   20,   17,   18,   19,   13,   20,   15,
   211:  /*    60 */    16,   20,   20,   14,   20,   14,   17,   18,   17,   18,
   212:  /*    70 */    14,   20,   14,   17,   18,   17,   18,   20,   14,   20,
   213:  /*    80 */    14,   17,   18,   17,   18,   14,   20,   20,   17,   18,
   214: };
   215: #define YY_SHIFT_USE_DFLT (90)
   216: #define YY_SHIFT_COUNT    (13)
   217: #define YY_SHIFT_MIN      (-2)
   218: #define YY_SHIFT_MAX      (32)
   219: static const signed char yy_shift_ofst[] = {
   220:  /*     0 */    90,   -2,   32,    9,   21,   32,   32,   32,   32,   32,
   221:  /*    10 */     6,    8,   20,   29,
   222: };
   223: #define YY_REDUCE_USE_DFLT (-1)
   224: #define YY_REDUCE_COUNT (9)
   225: #define YY_REDUCE_MIN   (0)
   226: #define YY_REDUCE_MAX   (71)
   227: static const signed char yy_reduce_ofst[] = {
   228:  /*     0 */    44,   31,   37,   49,   51,   56,   58,   64,   66,   71,
   229: };
   230: static const YYACTIONTYPE yy_default[] = {
   231:  /*     0 */    49,   60,   60,   67,   67,   67,   67,   67,   67,   67,
   232:  /*    10 */    67,   67,   67,   67,
   233: };
   234: /********** End of lemon-generated parsing tables *****************************/
   235: 
   236: /* The next table maps tokens (terminal symbols) into fallback tokens.  
   237: ** If a construct like the following:
   238: ** 
   239: **      %fallback ID X Y Z.
   240: **
   241: ** appears in the grammar, then ID becomes a fallback token for X, Y,
   242: ** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser
   243: ** but it does not parse, the type of the token is changed to ID and
   244: ** the parse is retried before an error is thrown.
   245: **
   246: ** This feature can be used, for example, to cause some keywords in a language
   247: ** to revert to identifiers if they keyword does not apply in the context where
   248: ** it appears.
   249: */
   250: #ifdef YYFALLBACK
   251: static const YYCODETYPE yyFallback[] = {
   252: };
   253: #endif /* YYFALLBACK */
   254: 
   255: /* The following structure represents a single element of the
   256: ** parser's stack.  Information stored includes:
   257: **
   258: **   +  The state number for the parser at this level of the stack.
   259: **
   260: **   +  The value of the token stored at this level of the stack.
   261: **      (In other words, the "major" token.)
   262: **
   263: **   +  The semantic value stored at this level of the stack.  This is
   264: **      the information used by the action routines in the grammar.
   265: **      It is sometimes called the "minor" token.
   266: **
   267: ** After the "shift" half of a SHIFTREDUCE action, the stateno field
   268: ** actually contains the reduce action for the second half of the
   269: ** SHIFTREDUCE.
   270: */
   271: struct yyStackEntry {
   272:   YYACTIONTYPE stateno;  /* The state-number, or reduce action in SHIFTREDUCE */
   273:   YYCODETYPE major;      /* The major token value.  This is the code
   274:                          ** number for the token at this stack level */
   275:   YYMINORTYPE minor;     /* The user-supplied minor token value.  This
   276:                          ** is the value of the token  */
   277: };
   278: typedef struct yyStackEntry yyStackEntry;
   279: 
   280: /* The state of the parser is completely contained in an instance of
   281: ** the following structure */
   282: struct yyParser {
   283:   yyStackEntry *yytos;          /* Pointer to top element of the stack */
   284: #ifdef YYTRACKMAXSTACKDEPTH
   285:   int yyhwm;                    /* High-water mark of the stack */
   286: #endif
   287: #ifndef YYNOERRORRECOVERY
   288:   int yyerrcnt;                 /* Shifts left before out of the error */
   289: #endif
   290:   ParseARG_SDECL                /* A place to hold %extra_argument */
   291: #if YYSTACKDEPTH<=0
   292:   int yystksz;                  /* Current side of the stack */
   293:   yyStackEntry *yystack;        /* The parser's stack */
   294:   yyStackEntry yystk0;          /* First stack entry */
   295: #else
   296:   yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
   297: #endif
   298: };
   299: typedef struct yyParser yyParser;
   300: 
   301: #ifndef NDEBUG
   302: #include <stdio.h>
   303: static FILE *yyTraceFILE = 0;
   304: static char *yyTracePrompt = 0;
   305: #endif /* NDEBUG */
   306: 
   307: #ifndef NDEBUG
   308: /* 
   309: ** Turn parser tracing on by giving a stream to which to write the trace
   310: ** and a prompt to preface each trace message.  Tracing is turned off
   311: ** by making either argument NULL 
   312: **
   313: ** Inputs:
   314: ** <ul>
   315: ** <li> A FILE* to which trace output should be written.
   316: **      If NULL, then tracing is turned off.
   317: ** <li> A prefix string written at the beginning of every
   318: **      line of trace output.  If NULL, then tracing is
   319: **      turned off.
   320: ** </ul>
   321: **
   322: ** Outputs:
   323: ** None.
   324: */
   325: void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
   326:   yyTraceFILE = TraceFILE;
   327:   yyTracePrompt = zTracePrompt;
   328:   if( yyTraceFILE==0 ) yyTracePrompt = 0;
   329:   else if( yyTracePrompt==0 ) yyTraceFILE = 0;
   330: }
   331: #endif /* NDEBUG */
   332: 
   333: #ifndef NDEBUG
   334: /* For tracing shifts, the names of all terminals and nonterminals
   335: ** are required.  The following table supplies these names */
   336: static const char *const yyTokenName[] = { 
   337:   "$",             "ENDPARSE",      "QUOTE",         "QUASI",       
   338:   "COMMA_AT",      "COMMA",         "OPAREN",        "DOT",         
   339:   "CPAREN",        "SYMBOL",        "STRING",        "INTEGER",     
   340:   "NIHIL",         "error",         "sexpr",         "input",       
   341:   "sexprlist",     "atom",          "list",          "listelem",    
   342: };
   343: #endif /* NDEBUG */
   344: 
   345: #ifndef NDEBUG
   346: /* For tracing reduce actions, the names of all rules are required.
   347: */
   348: static const char *const yyRuleName[] = {
   349:  /*   0 */ "sexprlist ::= sexprlist sexpr",
   350:  /*   1 */ "sexprlist ::=",
   351:  /*   2 */ "sexpr ::= atom",
   352:  /*   3 */ "sexpr ::= QUOTE sexpr",
   353:  /*   4 */ "sexpr ::= QUASI sexpr",
   354:  /*   5 */ "sexpr ::= COMMA_AT sexpr",
   355:  /*   6 */ "sexpr ::= COMMA sexpr",
   356:  /*   7 */ "sexpr ::= OPAREN sexpr DOT sexpr CPAREN",
   357:  /*   8 */ "sexpr ::= OPAREN CPAREN",
   358:  /*   9 */ "sexpr ::= list",
   359:  /*  10 */ "list ::= OPAREN sexpr listelem CPAREN",
   360:  /*  11 */ "listelem ::= sexpr listelem",
   361:  /*  12 */ "listelem ::=",
   362:  /*  13 */ "atom ::= SYMBOL",
   363:  /*  14 */ "atom ::= STRING",
   364:  /*  15 */ "atom ::= INTEGER",
   365:  /*  16 */ "atom ::= NIHIL",
   366:  /*  17 */ "input ::= sexprlist ENDPARSE",
   367:  /*  18 */ "input ::= error",
   368: };
   369: #endif /* NDEBUG */
   370: 
   371: 
   372: #if YYSTACKDEPTH<=0
   373: /*
   374: ** Try to increase the size of the parser stack.  Return the number
   375: ** of errors.  Return 0 on success.
   376: */
   377: static int yyGrowStack(yyParser *p){
   378:   int newSize;
   379:   int idx;
   380:   yyStackEntry *pNew;
   381: 
   382:   newSize = p->yystksz*2 + 100;
   383:   idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
   384:   if( p->yystack==&p->yystk0 ){
   385:     pNew = malloc(newSize*sizeof(pNew[0]));
   386:     if( pNew ) pNew[0] = p->yystk0;
   387:   }else{
   388:     pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
   389:   }
   390:   if( pNew ){
   391:     p->yystack = pNew;
   392:     p->yytos = &p->yystack[idx];
   393: #ifndef NDEBUG
   394:     if( yyTraceFILE ){
   395:       fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
   396:               yyTracePrompt, p->yystksz, newSize);
   397:     }
   398: #endif
   399:     p->yystksz = newSize;
   400:   }
   401:   return pNew==0; 
   402: }
   403: #endif
   404: 
   405: /* Datatype of the argument to the memory allocated passed as the
   406: ** second argument to ParseAlloc() below.  This can be changed by
   407: ** putting an appropriate #define in the %include section of the input
   408: ** grammar.
   409: */
   410: #ifndef YYMALLOCARGTYPE
   411: # define YYMALLOCARGTYPE size_t
   412: #endif
   413: 
   414: /* Initialize a new parser that has already been allocated.
   415: */
   416: void ParseInit(void *yypParser){
   417:   yyParser *pParser = (yyParser*)yypParser;
   418: #ifdef YYTRACKMAXSTACKDEPTH
   419:   pParser->yyhwm = 0;
   420: #endif
   421: #if YYSTACKDEPTH<=0
   422:   pParser->yytos = NULL;
   423:   pParser->yystack = NULL;
   424:   pParser->yystksz = 0;
   425:   if( yyGrowStack(pParser) ){
   426:     pParser->yystack = &pParser->yystk0;
   427:     pParser->yystksz = 1;
   428:   }
   429: #endif
   430: #ifndef YYNOERRORRECOVERY
   431:   pParser->yyerrcnt = -1;
   432: #endif
   433:   pParser->yytos = pParser->yystack;
   434:   pParser->yystack[0].stateno = 0;
   435:   pParser->yystack[0].major = 0;
   436: }
   437: 
   438: #ifndef Parse_ENGINEALWAYSONSTACK
   439: /* 
   440: ** This function allocates a new parser.
   441: ** The only argument is a pointer to a function which works like
   442: ** malloc.
   443: **
   444: ** Inputs:
   445: ** A pointer to the function used to allocate memory.
   446: **
   447: ** Outputs:
   448: ** A pointer to a parser.  This pointer is used in subsequent calls
   449: ** to Parse and ParseFree.
   450: */
   451: void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
   452:   yyParser *pParser;
   453:   pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
   454:   if( pParser ) ParseInit(pParser);
   455:   return pParser;
   456: }
   457: #endif /* Parse_ENGINEALWAYSONSTACK */
   458: 
   459: 
   460: /* The following function deletes the "minor type" or semantic value
   461: ** associated with a symbol.  The symbol can be either a terminal
   462: ** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
   463: ** a pointer to the value to be deleted.  The code used to do the 
   464: ** deletions is derived from the %destructor and/or %token_destructor
   465: ** directives of the input grammar.
   466: */
   467: static void yy_destructor(
   468:   yyParser *yypParser,    /* The parser */
   469:   YYCODETYPE yymajor,     /* Type code for object to destroy */
   470:   YYMINORTYPE *yypminor   /* The object to be destroyed */
   471: ){
   472:   ParseARG_FETCH;
   473:   switch( yymajor ){
   474:     /* Here is inserted the actions which take place when a
   475:     ** terminal or non-terminal is destroyed.  This can happen
   476:     ** when the symbol is popped from the stack during a
   477:     ** reduce or during error processing or when a parser is 
   478:     ** being destroyed before it is finished parsing.
   479:     **
   480:     ** Note: during a reduce, the only symbols destroyed are those
   481:     ** which appear on the RHS of the rule, but which are *not* used
   482:     ** inside the C code.
   483:     */
   484: /********* Begin destructor definitions ***************************************/
   485: /********* End destructor definitions *****************************************/
   486:     default:  break;   /* If no destructor action specified: do nothing */
   487:   }
   488: }
   489: 
   490: /*
   491: ** Pop the parser's stack once.
   492: **
   493: ** If there is a destructor routine associated with the token which
   494: ** is popped from the stack, then call it.
   495: */
   496: static void yy_pop_parser_stack(yyParser *pParser){
   497:   yyStackEntry *yytos;
   498:   assert( pParser->yytos!=0 );
   499:   assert( pParser->yytos > pParser->yystack );
   500:   yytos = pParser->yytos--;
   501: #ifndef NDEBUG
   502:   if( yyTraceFILE ){
   503:     fprintf(yyTraceFILE,"%sPopping %s\n",
   504:       yyTracePrompt,
   505:       yyTokenName[yytos->major]);
   506:   }
   507: #endif
   508:   yy_destructor(pParser, yytos->major, &yytos->minor);
   509: }
   510: 
   511: /*
   512: ** Clear all secondary memory allocations from the parser
   513: */
   514: void ParseFinalize(void *p){
   515:   yyParser *pParser = (yyParser*)p;
   516:   while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
   517: #if YYSTACKDEPTH<=0
   518:   if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
   519: #endif
   520: }
   521: 
   522: #ifndef Parse_ENGINEALWAYSONSTACK
   523: /* 
   524: ** Deallocate and destroy a parser.  Destructors are called for
   525: ** all stack elements before shutting the parser down.
   526: **
   527: ** If the YYPARSEFREENEVERNULL macro exists (for example because it
   528: ** is defined in a %include section of the input grammar) then it is
   529: ** assumed that the input pointer is never NULL.
   530: */
   531: void ParseFree(
   532:   void *p,                    /* The parser to be deleted */
   533:   void (*freeProc)(void*)     /* Function used to reclaim memory */
   534: ){
   535: #ifndef YYPARSEFREENEVERNULL
   536:   if( p==0 ) return;
   537: #endif
   538:   ParseFinalize(p);
   539:   (*freeProc)(p);
   540: }
   541: #endif /* Parse_ENGINEALWAYSONSTACK */
   542: 
   543: /*
   544: ** Return the peak depth of the stack for a parser.
   545: */
   546: #ifdef YYTRACKMAXSTACKDEPTH
   547: int ParseStackPeak(void *p){
   548:   yyParser *pParser = (yyParser*)p;
   549:   return pParser->yyhwm;
   550: }
   551: #endif
   552: 
   553: /*
   554: ** Find the appropriate action for a parser given the terminal
   555: ** look-ahead token iLookAhead.
   556: */
   557: static unsigned int yy_find_shift_action(
   558:   yyParser *pParser,        /* The parser */
   559:   YYCODETYPE iLookAhead     /* The look-ahead token */
   560: ){
   561:   int i;
   562:   int stateno = pParser->yytos->stateno;
   563:  
   564:   if( stateno>=YY_MIN_REDUCE ) return stateno;
   565:   assert( stateno <= YY_SHIFT_COUNT );
   566:   do{
   567:     i = yy_shift_ofst[stateno];
   568:     assert( iLookAhead!=YYNOCODE );
   569:     i += iLookAhead;
   570:     if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
   571: #ifdef YYFALLBACK
   572:       YYCODETYPE iFallback;            /* Fallback token */
   573:       if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
   574:              && (iFallback = yyFallback[iLookAhead])!=0 ){
   575: #ifndef NDEBUG
   576:         if( yyTraceFILE ){
   577:           fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
   578:              yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
   579:         }
   580: #endif
   581:         assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
   582:         iLookAhead = iFallback;
   583:         continue;
   584:       }
   585: #endif
   586: #ifdef YYWILDCARD
   587:       {
   588:         int j = i - iLookAhead + YYWILDCARD;
   589:         if( 
   590: #if YY_SHIFT_MIN+YYWILDCARD<0
   591:           j>=0 &&
   592: #endif
   593: #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
   594:           j<YY_ACTTAB_COUNT &&
   595: #endif
   596:           yy_lookahead[j]==YYWILDCARD && iLookAhead>0
   597:         ){
   598: #ifndef NDEBUG
   599:           if( yyTraceFILE ){
   600:             fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
   601:                yyTracePrompt, yyTokenName[iLookAhead],
   602:                yyTokenName[YYWILDCARD]);
   603:           }
   604: #endif /* NDEBUG */
   605:           return yy_action[j];
   606:         }
   607:       }
   608: #endif /* YYWILDCARD */
   609:       return yy_default[stateno];
   610:     }else{
   611:       return yy_action[i];
   612:     }
   613:   }while(1);
   614: }
   615: 
   616: /*
   617: ** Find the appropriate action for a parser given the non-terminal
   618: ** look-ahead token iLookAhead.
   619: */
   620: static int yy_find_reduce_action(
   621:   int stateno,              /* Current state number */
   622:   YYCODETYPE iLookAhead     /* The look-ahead token */
   623: ){
   624:   int i;
   625: #ifdef YYERRORSYMBOL
   626:   if( stateno>YY_REDUCE_COUNT ){
   627:     return yy_default[stateno];
   628:   }
   629: #else
   630:   assert( stateno<=YY_REDUCE_COUNT );
   631: #endif
   632:   i = yy_reduce_ofst[stateno];
   633:   assert( i!=YY_REDUCE_USE_DFLT );
   634:   assert( iLookAhead!=YYNOCODE );
   635:   i += iLookAhead;
   636: #ifdef YYERRORSYMBOL
   637:   if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
   638:     return yy_default[stateno];
   639:   }
   640: #else
   641:   assert( i>=0 && i<YY_ACTTAB_COUNT );
   642:   assert( yy_lookahead[i]==iLookAhead );
   643: #endif
   644:   return yy_action[i];
   645: }
   646: 
   647: /*
   648: ** The following routine is called if the stack overflows.
   649: */
   650: static void yyStackOverflow(yyParser *yypParser){
   651:    ParseARG_FETCH;
   652: #ifndef NDEBUG
   653:    if( yyTraceFILE ){
   654:      fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
   655:    }
   656: #endif
   657:    while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
   658:    /* Here code is inserted which will execute if the parser
   659:    ** stack every overflows */
   660: /******** Begin %stack_overflow code ******************************************/
   661: /******** End %stack_overflow code ********************************************/
   662:    ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
   663: }
   664: 
   665: /*
   666: ** Print tracing information for a SHIFT action
   667: */
   668: #ifndef NDEBUG
   669: static void yyTraceShift(yyParser *yypParser, int yyNewState){
   670:   if( yyTraceFILE ){
   671:     if( yyNewState<YYNSTATE ){
   672:       fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
   673:          yyTracePrompt,yyTokenName[yypParser->yytos->major],
   674:          yyNewState);
   675:     }else{
   676:       fprintf(yyTraceFILE,"%sShift '%s'\n",
   677:          yyTracePrompt,yyTokenName[yypParser->yytos->major]);
   678:     }
   679:   }
   680: }
   681: #else
   682: # define yyTraceShift(X,Y)
   683: #endif
   684: 
   685: /*
   686: ** Perform a shift action.
   687: */
   688: static void yy_shift(
   689:   yyParser *yypParser,          /* The parser to be shifted */
   690:   int yyNewState,               /* The new state to shift in */
   691:   int yyMajor,                  /* The major token to shift in */
   692:   ParseTOKENTYPE yyMinor        /* The minor token to shift in */
   693: ){
   694:   yyStackEntry *yytos;
   695:   yypParser->yytos++;
   696: #ifdef YYTRACKMAXSTACKDEPTH
   697:   if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
   698:     yypParser->yyhwm++;
   699:     assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
   700:   }
   701: #endif
   702: #if YYSTACKDEPTH>0 
   703:   if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){
   704:     yypParser->yytos--;
   705:     yyStackOverflow(yypParser);
   706:     return;
   707:   }
   708: #else
   709:   if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
   710:     if( yyGrowStack(yypParser) ){
   711:       yypParser->yytos--;
   712:       yyStackOverflow(yypParser);
   713:       return;
   714:     }
   715:   }
   716: #endif
   717:   if( yyNewState > YY_MAX_SHIFT ){
   718:     yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
   719:   }
   720:   yytos = yypParser->yytos;
   721:   yytos->stateno = (YYACTIONTYPE)yyNewState;
   722:   yytos->major = (YYCODETYPE)yyMajor;
   723:   yytos->minor.yy0 = yyMinor;
   724:   yyTraceShift(yypParser, yyNewState);
   725: }
   726: 
   727: /* The following table contains information about every rule that
   728: ** is used during the reduce.
   729: */
   730: static const struct {
   731:   YYCODETYPE lhs;         /* Symbol on the left-hand side of the rule */
   732:   unsigned char nrhs;     /* Number of right-hand side symbols in the rule */
   733: } yyRuleInfo[] = {
   734:   { 16, 2 },
   735:   { 16, 0 },
   736:   { 14, 1 },
   737:   { 14, 2 },
   738:   { 14, 2 },
   739:   { 14, 2 },
   740:   { 14, 2 },
   741:   { 14, 5 },
   742:   { 14, 2 },
   743:   { 14, 1 },
   744:   { 18, 4 },
   745:   { 19, 2 },
   746:   { 19, 0 },
   747:   { 17, 1 },
   748:   { 17, 1 },
   749:   { 17, 1 },
   750:   { 17, 1 },
   751:   { 15, 2 },
   752:   { 15, 1 },
   753: };
   754: 
   755: static void yy_accept(yyParser*);  /* Forward Declaration */
   756: 
   757: /*
   758: ** Perform a reduce action and the shift that must immediately
   759: ** follow the reduce.
   760: */
   761: static void yy_reduce(
   762:   yyParser *yypParser,         /* The parser */
   763:   unsigned int yyruleno        /* Number of the rule by which to reduce */
   764: ){
   765:   int yygoto;                     /* The next state */
   766:   int yyact;                      /* The next action */
   767:   yyStackEntry *yymsp;            /* The top of the parser's stack */
   768:   int yysize;                     /* Amount to pop the stack */
   769:   ParseARG_FETCH;
   770:   yymsp = yypParser->yytos;
   771: #ifndef NDEBUG
   772:   if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
   773:     yysize = yyRuleInfo[yyruleno].nrhs;
   774:     fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
   775:       yyRuleName[yyruleno], yymsp[-yysize].stateno);
   776:   }
   777: #endif /* NDEBUG */
   778: 
   779:   /* Check that the stack is large enough to grow by a single entry
   780:   ** if the RHS of the rule is empty.  This ensures that there is room
   781:   ** enough on the stack to push the LHS value */
   782:   if( yyRuleInfo[yyruleno].nrhs==0 ){
   783: #ifdef YYTRACKMAXSTACKDEPTH
   784:     if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
   785:       yypParser->yyhwm++;
   786:       assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
   787:     }
   788: #endif
   789: #if YYSTACKDEPTH>0 
   790:     if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){
   791:       yyStackOverflow(yypParser);
   792:       return;
   793:     }
   794: #else
   795:     if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
   796:       if( yyGrowStack(yypParser) ){
   797:         yyStackOverflow(yypParser);
   798:         return;
   799:       }
   800:       yymsp = yypParser->yytos;
   801:     }
   802: #endif
   803:   }
   804: 
   805:   switch( yyruleno ){
   806:   /* Beginning here are the reduction cases.  A typical example
   807:   ** follows:
   808:   **   case 0:
   809:   **  #line <lineno> <grammarfile>
   810:   **     { ... }           // User supplied code
   811:   **  #line <lineno> <thisfile>
   812:   **     break;
   813:   */
   814: /********** Begin reduce actions **********************************************/
   815:         YYMINORTYPE yylhsminor;
   816:       case 0: /* sexprlist ::= sexprlist sexpr */
   817: #line 15 "sexpr.lmn"
   818: { if (cb != NULL) { cb->res = cb->fn(yymsp[0].minor.yy6, cb->opq); } }
   819: #line 820 "sexpr.c"
   820:         break;
   821:       case 1: /* sexprlist ::= */
   822: #line 16 "sexpr.lmn"
   823: { /* */ }
   824: #line 825 "sexpr.c"
   825:         break;
   826:       case 2: /* sexpr ::= atom */
   827:       case 9: /* sexpr ::= list */ yytestcase(yyruleno==9);
   828: #line 18 "sexpr.lmn"
   829: { yylhsminor.yy6 = yymsp[0].minor.yy0; }
   830: #line 831 "sexpr.c"
   831:   yymsp[0].minor.yy6 = yylhsminor.yy6;
   832:         break;
   833:       case 3: /* sexpr ::= QUOTE sexpr */
   834: #line 19 "sexpr.lmn"
   835: { yymsp[-1].minor.yy6 = cons(sym_quote, cons(yymsp[0].minor.yy6, NIL)); }
   836: #line 837 "sexpr.c"
   837:         break;
   838:       case 4: /* sexpr ::= QUASI sexpr */
   839: #line 20 "sexpr.lmn"
   840: { yymsp[-1].minor.yy6 = cons(sym_quasiquote, cons(yymsp[0].minor.yy6, NIL)); }
   841: #line 842 "sexpr.c"
   842:         break;
   843:       case 5: /* sexpr ::= COMMA_AT sexpr */
   844: #line 21 "sexpr.lmn"
   845: { yymsp[-1].minor.yy6 = cons(sym_splice, cons(yymsp[0].minor.yy6, NIL)); }
   846: #line 847 "sexpr.c"
   847:         break;
   848:       case 6: /* sexpr ::= COMMA sexpr */
   849: #line 22 "sexpr.lmn"
   850: { yymsp[-1].minor.yy6 = cons(sym_unquote, cons(yymsp[0].minor.yy6, NIL)); }
   851: #line 852 "sexpr.c"
   852:         break;
   853:       case 7: /* sexpr ::= OPAREN sexpr DOT sexpr CPAREN */
   854: #line 23 "sexpr.lmn"
   855: { yymsp[-4].minor.yy6 = cons(yymsp[-3].minor.yy6,yymsp[-1].minor.yy6); }
   856: #line 857 "sexpr.c"
   857:         break;
   858:       case 8: /* sexpr ::= OPAREN CPAREN */
   859: #line 24 "sexpr.lmn"
   860: { yymsp[-1].minor.yy6 = NIL; }
   861: #line 862 "sexpr.c"
   862:         break;
   863:       case 10: /* list ::= OPAREN sexpr listelem CPAREN */
   864: #line 27 "sexpr.lmn"
   865: { yymsp[-3].minor.yy0 = cons(yymsp[-2].minor.yy6,yymsp[-1].minor.yy0); }
   866: #line 867 "sexpr.c"
   867:         break;
   868:       case 11: /* listelem ::= sexpr listelem */
   869: #line 29 "sexpr.lmn"
   870: { yylhsminor.yy0 = cons(yymsp[-1].minor.yy6, yymsp[0].minor.yy0); }
   871: #line 872 "sexpr.c"
   872:   yymsp[-1].minor.yy0 = yylhsminor.yy0;
   873:         break;
   874:       case 12: /* listelem ::= */
   875: #line 30 "sexpr.lmn"
   876: { yymsp[1].minor.yy0 = NIL; }
   877: #line 878 "sexpr.c"
   878:         break;
   879:       case 13: /* atom ::= SYMBOL */
   880:       case 14: /* atom ::= STRING */ yytestcase(yyruleno==14);
   881:       case 15: /* atom ::= INTEGER */ yytestcase(yyruleno==15);
   882:       case 16: /* atom ::= NIHIL */ yytestcase(yyruleno==16);
   883: #line 32 "sexpr.lmn"
   884: { yylhsminor.yy0 = yymsp[0].minor.yy0; }
   885: #line 886 "sexpr.c"
   886:   yymsp[0].minor.yy0 = yylhsminor.yy0;
   887:         break;
   888:       default:
   889:       /* (17) input ::= sexprlist ENDPARSE */ yytestcase(yyruleno==17);
   890:       /* (18) input ::= error */ yytestcase(yyruleno==18);
   891:         break;
   892: /********** End reduce actions ************************************************/
   893:   };
   894:   assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
   895:   yygoto = yyRuleInfo[yyruleno].lhs;
   896:   yysize = yyRuleInfo[yyruleno].nrhs;
   897:   yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
   898:   if( yyact <= YY_MAX_SHIFTREDUCE ){
   899:     if( yyact>YY_MAX_SHIFT ){
   900:       yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
   901:     }
   902:     yymsp -= yysize-1;
   903:     yypParser->yytos = yymsp;
   904:     yymsp->stateno = (YYACTIONTYPE)yyact;
   905:     yymsp->major = (YYCODETYPE)yygoto;
   906:     yyTraceShift(yypParser, yyact);
   907:   }else{
   908:     assert( yyact == YY_ACCEPT_ACTION );
   909:     yypParser->yytos -= yysize;
   910:     yy_accept(yypParser);
   911:   }
   912: }
   913: 
   914: /*
   915: ** The following code executes when the parse fails
   916: */
   917: #ifndef YYNOERRORRECOVERY
   918: static void yy_parse_failed(
   919:   yyParser *yypParser           /* The parser */
   920: ){
   921:   ParseARG_FETCH;
   922: #ifndef NDEBUG
   923:   if( yyTraceFILE ){
   924:     fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
   925:   }
   926: #endif
   927:   while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
   928:   /* Here code is inserted which will be executed whenever the
   929:   ** parser fails */
   930: /************ Begin %parse_failure code ***************************************/
   931: /************ End %parse_failure code *****************************************/
   932:   ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
   933: }
   934: #endif /* YYNOERRORRECOVERY */
   935: 
   936: /*
   937: ** The following code executes when a syntax error first occurs.
   938: */
   939: static void yy_syntax_error(
   940:   yyParser *yypParser,           /* The parser */
   941:   int yymajor,                   /* The major type of the error token */
   942:   ParseTOKENTYPE yyminor         /* The minor type of the error token */
   943: ){
   944:   ParseARG_FETCH;
   945: #define TOKEN yyminor
   946: /************ Begin %syntax_error code ****************************************/
   947: #line 8 "sexpr.lmn"
   948: 
   949: 	      printf("SYNTAX ERROR!\n");
   950: #line 951 "sexpr.c"
   951: /************ End %syntax_error code ******************************************/
   952:   ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
   953: }
   954: 
   955: /*
   956: ** The following is executed when the parser accepts
   957: */
   958: static void yy_accept(
   959:   yyParser *yypParser           /* The parser */
   960: ){
   961:   ParseARG_FETCH;
   962: #ifndef NDEBUG
   963:   if( yyTraceFILE ){
   964:     fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
   965:   }
   966: #endif
   967: #ifndef YYNOERRORRECOVERY
   968:   yypParser->yyerrcnt = -1;
   969: #endif
   970:   assert( yypParser->yytos==yypParser->yystack );
   971:   /* Here code is inserted which will be executed whenever the
   972:   ** parser accepts */
   973: /*********** Begin %parse_accept code *****************************************/
   974: /*********** End %parse_accept code *******************************************/
   975:   ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
   976: }
   977: 
   978: /* The main parser program.
   979: ** The first argument is a pointer to a structure obtained from
   980: ** "ParseAlloc" which describes the current state of the parser.
   981: ** The second argument is the major token number.  The third is
   982: ** the minor token.  The fourth optional argument is whatever the
   983: ** user wants (and specified in the grammar) and is available for
   984: ** use by the action routines.
   985: **
   986: ** Inputs:
   987: ** <ul>
   988: ** <li> A pointer to the parser (an opaque structure.)
   989: ** <li> The major token number.
   990: ** <li> The minor token number.
   991: ** <li> An option argument of a grammar-specified type.
   992: ** </ul>
   993: **
   994: ** Outputs:
   995: ** None.
   996: */
   997: void Parse(
   998:   void *yyp,                   /* The parser */
   999:   int yymajor,                 /* The major token code number */
  1000:   ParseTOKENTYPE yyminor       /* The value for the token */
  1001:   ParseARG_PDECL               /* Optional %extra_argument parameter */
  1002: ){
  1003:   YYMINORTYPE yyminorunion;
  1004:   unsigned int yyact;   /* The parser action. */
  1005: #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
  1006:   int yyendofinput;     /* True if we are at the end of input */
  1007: #endif
  1008: #ifdef YYERRORSYMBOL
  1009:   int yyerrorhit = 0;   /* True if yymajor has invoked an error */
  1010: #endif
  1011:   yyParser *yypParser;  /* The parser */
  1012: 
  1013:   yypParser = (yyParser*)yyp;
  1014:   assert( yypParser->yytos!=0 );
  1015: #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
  1016:   yyendofinput = (yymajor==0);
  1017: #endif
  1018:   ParseARG_STORE;
  1019: 
  1020: #ifndef NDEBUG
  1021:   if( yyTraceFILE ){
  1022:     fprintf(yyTraceFILE,"%sInput '%s'\n",yyTracePrompt,yyTokenName[yymajor]);
  1023:   }
  1024: #endif
  1025: 
  1026:   do{
  1027:     yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
  1028:     if( yyact <= YY_MAX_SHIFTREDUCE ){
  1029:       yy_shift(yypParser,yyact,yymajor,yyminor);
  1030: #ifndef YYNOERRORRECOVERY
  1031:       yypParser->yyerrcnt--;
  1032: #endif
  1033:       yymajor = YYNOCODE;
  1034:     }else if( yyact <= YY_MAX_REDUCE ){
  1035:       yy_reduce(yypParser,yyact-YY_MIN_REDUCE);
  1036:     }else{
  1037:       assert( yyact == YY_ERROR_ACTION );
  1038:       yyminorunion.yy0 = yyminor;
  1039: #ifdef YYERRORSYMBOL
  1040:       int yymx;
  1041: #endif
  1042: #ifndef NDEBUG
  1043:       if( yyTraceFILE ){
  1044:         fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
  1045:       }
  1046: #endif
  1047: #ifdef YYERRORSYMBOL
  1048:       /* A syntax error has occurred.
  1049:       ** The response to an error depends upon whether or not the
  1050:       ** grammar defines an error token "ERROR".  
  1051:       **
  1052:       ** This is what we do if the grammar does define ERROR:
  1053:       **
  1054:       **  * Call the %syntax_error function.
  1055:       **
  1056:       **  * Begin popping the stack until we enter a state where
  1057:       **    it is legal to shift the error symbol, then shift
  1058:       **    the error symbol.
  1059:       **
  1060:       **  * Set the error count to three.
  1061:       **
  1062:       **  * Begin accepting and shifting new tokens.  No new error
  1063:       **    processing will occur until three tokens have been
  1064:       **    shifted successfully.
  1065:       **
  1066:       */
  1067:       if( yypParser->yyerrcnt<0 ){
  1068:         yy_syntax_error(yypParser,yymajor,yyminor);
  1069:       }
  1070:       yymx = yypParser->yytos->major;
  1071:       if( yymx==YYERRORSYMBOL || yyerrorhit ){
  1072: #ifndef NDEBUG
  1073:         if( yyTraceFILE ){
  1074:           fprintf(yyTraceFILE,"%sDiscard input token %s\n",
  1075:              yyTracePrompt,yyTokenName[yymajor]);
  1076:         }
  1077: #endif
  1078:         yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
  1079:         yymajor = YYNOCODE;
  1080:       }else{
  1081:         while( yypParser->yytos >= yypParser->yystack
  1082:             && yymx != YYERRORSYMBOL
  1083:             && (yyact = yy_find_reduce_action(
  1084:                         yypParser->yytos->stateno,
  1085:                         YYERRORSYMBOL)) >= YY_MIN_REDUCE
  1086:         ){
  1087:           yy_pop_parser_stack(yypParser);
  1088:         }
  1089:         if( yypParser->yytos < yypParser->yystack || yymajor==0 ){
  1090:           yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1091:           yy_parse_failed(yypParser);
  1092: #ifndef YYNOERRORRECOVERY
  1093:           yypParser->yyerrcnt = -1;
  1094: #endif
  1095:           yymajor = YYNOCODE;
  1096:         }else if( yymx!=YYERRORSYMBOL ){
  1097:           yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
  1098:         }
  1099:       }
  1100:       yypParser->yyerrcnt = 3;
  1101:       yyerrorhit = 1;
  1102: #elif defined(YYNOERRORRECOVERY)
  1103:       /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
  1104:       ** do any kind of error recovery.  Instead, simply invoke the syntax
  1105:       ** error routine and continue going as if nothing had happened.
  1106:       **
  1107:       ** Applications can set this macro (for example inside %include) if
  1108:       ** they intend to abandon the parse upon the first syntax error seen.
  1109:       */
  1110:       yy_syntax_error(yypParser,yymajor, yyminor);
  1111:       yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1112:       yymajor = YYNOCODE;
  1113:       
  1114: #else  /* YYERRORSYMBOL is not defined */
  1115:       /* This is what we do if the grammar does not define ERROR:
  1116:       **
  1117:       **  * Report an error message, and throw away the input token.
  1118:       **
  1119:       **  * If the input token is $, then fail the parse.
  1120:       **
  1121:       ** As before, subsequent error messages are suppressed until
  1122:       ** three input tokens have been successfully shifted.
  1123:       */
  1124:       if( yypParser->yyerrcnt<=0 ){
  1125:         yy_syntax_error(yypParser,yymajor, yyminor);
  1126:       }
  1127:       yypParser->yyerrcnt = 3;
  1128:       yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1129:       if( yyendofinput ){
  1130:         yy_parse_failed(yypParser);
  1131: #ifndef YYNOERRORRECOVERY
  1132:         yypParser->yyerrcnt = -1;
  1133: #endif
  1134:       }
  1135:       yymajor = YYNOCODE;
  1136: #endif
  1137:     }
  1138:   }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack );
  1139: #ifndef NDEBUG
  1140:   if( yyTraceFILE ){
  1141:     yyStackEntry *i;
  1142:     char cDiv = '[';
  1143:     fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
  1144:     for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
  1145:       fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
  1146:       cDiv = ' ';
  1147:     }
  1148:     fprintf(yyTraceFILE,"]\n");
  1149:   }
  1150: #endif
  1151:   return;
  1152: }

Generated by git2html.