misc/lempar.c
author Ryan C. Gordon <icculus@icculus.org>
Sat, 28 Feb 2009 04:32:56 -0500
changeset 708 d29c193900b0
child 715 817d02ae5c4b
permissions -rw-r--r--
Added lemon and lempar sources to revision control.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
 * My changes over the original lempar.c from SQLite are encased in
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
 *  #if __MOJOSHADER__ blocks.  --ryan.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
 */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
#define __MOJOSHADER__ 1
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
/* Driver template for the LEMON parser generator.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
** The author disclaims copyright to this source code.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
/* First off, code is included that follows the "include" declaration
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
** in the input grammar file. */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
#include <stdio.h>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
/* Next is all token values, in a form suitable for use by makeheaders.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
** This section will be null unless lemon is run with the -m switch.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
/* 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
** These constants (all generated automatically by the parser generator)
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
** specify the various kinds of tokens (terminals) that the parser
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
** understands. 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
** Each symbol here is a terminal symbol in the grammar.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
/* Make sure the INTERFACE macro is defined.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
#ifndef INTERFACE
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
# define INTERFACE 1
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
/* The next thing included is series of defines which control
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
** various aspects of the generated parser.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
**    YYCODETYPE         is the data type used for storing terminal
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
**                       and nonterminal numbers.  "unsigned char" is
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
**                       used if there are fewer than 250 terminals
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
**                       and nonterminals.  "int" is used otherwise.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
**    YYNOCODE           is a number of type YYCODETYPE which corresponds
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
**                       to no legal terminal or nonterminal number.  This
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
**                       number is used to fill in empty slots of the hash 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
**                       table.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
**    YYFALLBACK         If defined, this indicates that one or more tokens
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
**                       have fall-back values which should be used if the
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
**                       original value of the token will not parse.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
**    YYACTIONTYPE       is the data type used for storing terminal
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
**                       and nonterminal numbers.  "unsigned char" is
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
**                       used if there are fewer than 250 rules and
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
**                       states combined.  "int" is used otherwise.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
**    ParseTOKENTYPE     is the data type used for minor tokens given 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
**                       directly to the parser from the tokenizer.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
**    YYMINORTYPE        is the data type used for all minor tokens.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
**                       This is typically a union of many types, one of
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
**                       which is ParseTOKENTYPE.  The entry in the union
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
**                       for base tokens is called "yy0".
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
**    YYSTACKDEPTH       is the maximum depth of the parser's stack.  If
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
**                       zero the stack is dynamically sized using realloc()
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
**    ParseARG_SDECL     A static variable declaration for the %extra_argument
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
**    ParseARG_PDECL     A parameter declaration for the %extra_argument
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
**    ParseARG_STORE     Code to store %extra_argument into yypParser
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
**    ParseARG_FETCH     Code to extract %extra_argument from yypParser
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
**    YYNSTATE           the combined number of states.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
**    YYNRULE            the number of rules in the grammar
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
**    YYERRORSYMBOL      is the code number of the error symbol.  If not
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
**                       defined, then do no error processing.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
#define YY_NO_ACTION      (YYNSTATE+YYNRULE+2)
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
#define YY_ACCEPT_ACTION  (YYNSTATE+YYNRULE+1)
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
#define YY_ERROR_ACTION   (YYNSTATE+YYNRULE)
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
/* The yyzerominor constant is used to initialize instances of
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
** YYMINORTYPE objects to zero. */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
static const YYMINORTYPE yyzerominor = { 0 };
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
/* Next are the tables used to determine what action to take based on the
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
** current state and lookahead token.  These tables are used to implement
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
** functions that take a state number and lookahead value and return an
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
** action integer.  
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
** Suppose the action integer is N.  Then the action is determined as
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
** follows
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
**   0 <= N < YYNSTATE                  Shift N.  That is, push the lookahead
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
**                                      token onto the stack and goto state N.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
**   YYNSTATE <= N < YYNSTATE+YYNRULE   Reduce by rule N-YYNSTATE.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
**   N == YYNSTATE+YYNRULE              A syntax error has occurred.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
**   N == YYNSTATE+YYNRULE+1            The parser accepts its input.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
**   N == YYNSTATE+YYNRULE+2            No such action.  Denotes unused
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
**                                      slots in the yy_action[] table.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
** The action table is constructed as a single large table named yy_action[].
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
** Given state S and lookahead X, the action is computed as
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
**      yy_action[ yy_shift_ofst[S] + X ]
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
** If the index value yy_shift_ofst[S]+X is out of range or if the value
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
** and that yy_default[S] should be used instead.  
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
** The formula above is for computing the action when the lookahead is
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
** a reduce action) then the yy_reduce_ofst[] array is used in place of
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
** YY_SHIFT_USE_DFLT.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
** The following are the tables generated in this section:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   112
**  yy_action[]        A single table containing all actions.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
**  yy_lookahead[]     A table containing the lookahead for each entry in
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
**                     yy_action.  Used to detect hash collisions.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
**  yy_shift_ofst[]    For each state, the offset into yy_action for
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
**                     shifting terminals.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
**  yy_reduce_ofst[]   For each state, the offset into yy_action for
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
**                     shifting non-terminals after a reduce.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
**  yy_default[]       Default action for each state.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
#define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   124
/* The next table maps tokens into fallback tokens.  If a construct
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
** like the following:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   126
** 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
**      %fallback ID X Y Z.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
** appears in the grammar, then ID becomes a fallback token for X, Y,
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
** but it does not parse, the type of the token is changed to ID and
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
** the parse is retried before an error is thrown.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
#ifdef YYFALLBACK
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
static const YYCODETYPE yyFallback[] = {
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   136
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   137
};
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
#endif /* YYFALLBACK */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   139
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   140
/* The following structure represents a single element of the
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   141
** parser's stack.  Information stored includes:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   142
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   143
**   +  The state number for the parser at this level of the stack.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   144
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   145
**   +  The value of the token stored at this level of the stack.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   146
**      (In other words, the "major" token.)
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   147
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   148
**   +  The semantic value stored at this level of the stack.  This is
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   149
**      the information used by the action routines in the grammar.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   150
**      It is sometimes called the "minor" token.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   151
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   152
struct yyStackEntry {
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   153
  YYACTIONTYPE stateno;  /* The state-number */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
  YYCODETYPE major;      /* The major token value.  This is the code
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   155
                         ** number for the token at this stack level */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   156
  YYMINORTYPE minor;     /* The user-supplied minor token value.  This
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   157
                         ** is the value of the token  */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   158
};
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   159
typedef struct yyStackEntry yyStackEntry;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   160
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   161
/* The state of the parser is completely contained in an instance of
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   162
** the following structure */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
struct yyParser {
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   164
  int yyidx;                    /* Index of top element in stack */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
#ifdef YYTRACKMAXSTACKDEPTH
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
  int yyidxMax;                 /* Maximum value of yyidx */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   168
  int yyerrcnt;                 /* Shifts left before out of the error */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   169
  ParseARG_SDECL                /* A place to hold %extra_argument */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   170
#if YYSTACKDEPTH<=0
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   171
  int yystksz;                  /* Current side of the stack */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
  yyStackEntry *yystack;        /* The parser's stack */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
#else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   174
  yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   175
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   176
};
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
typedef struct yyParser yyParser;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   178
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   179
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   180
#include <stdio.h>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   181
static FILE *yyTraceFILE = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   182
static char *yyTracePrompt = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   183
#endif /* NDEBUG */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   184
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   185
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   186
/* 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   187
** Turn parser tracing on by giving a stream to which to write the trace
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   188
** and a prompt to preface each trace message.  Tracing is turned off
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   189
** by making either argument NULL 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   190
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   191
** Inputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   192
** <ul>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   193
** <li> A FILE* to which trace output should be written.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   194
**      If NULL, then tracing is turned off.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   195
** <li> A prefix string written at the beginning of every
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   196
**      line of trace output.  If NULL, then tracing is
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   197
**      turned off.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   198
** </ul>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   199
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   200
** Outputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   201
** None.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   202
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   203
void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   204
  yyTraceFILE = TraceFILE;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   205
  yyTracePrompt = zTracePrompt;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   206
  if( yyTraceFILE==0 ) yyTracePrompt = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   207
  else if( yyTracePrompt==0 ) yyTraceFILE = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   208
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   209
#endif /* NDEBUG */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   210
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   211
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   212
/* For tracing shifts, the names of all terminals and nonterminals
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   213
** are required.  The following table supplies these names */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   214
static const char *const yyTokenName[] = { 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   215
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   216
};
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   217
#endif /* NDEBUG */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   218
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   219
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   220
/* For tracing reduce actions, the names of all rules are required.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   221
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   222
static const char *const yyRuleName[] = {
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   223
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   224
};
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   225
#endif /* NDEBUG */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   226
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   227
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   228
#if YYSTACKDEPTH<=0
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   229
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   230
** Try to increase the size of the parser stack.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   231
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   232
static void yyGrowStack(yyParser *p){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   233
  int newSize;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   234
  yyStackEntry *pNew;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   235
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   236
  newSize = p->yystksz*2 + 100;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   237
  pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   238
  if( pNew ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   239
    p->yystack = pNew;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   240
    p->yystksz = newSize;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   241
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   242
    if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   243
      fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   244
              yyTracePrompt, p->yystksz);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   245
    }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   246
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   247
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   248
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   249
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   250
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   251
/* 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   252
** This function allocates a new parser.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   253
** The only argument is a pointer to a function which works like
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   254
** malloc.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   255
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   256
** Inputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   257
** A pointer to the function used to allocate memory.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   258
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   259
** Outputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   260
** A pointer to a parser.  This pointer is used in subsequent calls
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   261
** to Parse and ParseFree.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   262
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   263
#if __MOJOSHADER__
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   264
void *ParseAlloc(void *(*mallocProc)(size_t,void *), void *malloc_data){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   265
  yyParser *pParser;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   266
  pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser), malloc_data );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   267
#else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   268
void *ParseAlloc(void *(*mallocProc)(size_t)){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   269
  yyParser *pParser;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   270
  pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   271
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   272
  if( pParser ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   273
    pParser->yyidx = -1;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   274
#ifdef YYTRACKMAXSTACKDEPTH
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   275
    pParser->yyidxMax = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   276
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   277
#if YYSTACKDEPTH<=0
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   278
    pParser->yystack = NULL;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   279
    pParser->yystksz = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   280
    yyGrowStack(pParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   281
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   282
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   283
  return pParser;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   284
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   285
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   286
/* The following function deletes the value associated with a
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   287
** symbol.  The symbol can be either a terminal or nonterminal.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   288
** "yymajor" is the symbol code, and "yypminor" is a pointer to
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   289
** the value.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   290
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   291
static void yy_destructor(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   292
  yyParser *yypParser,    /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   293
  YYCODETYPE yymajor,     /* Type code for object to destroy */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   294
  YYMINORTYPE *yypminor   /* The object to be destroyed */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   295
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   296
  ParseARG_FETCH;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   297
  switch( yymajor ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   298
    /* Here is inserted the actions which take place when a
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   299
    ** terminal or non-terminal is destroyed.  This can happen
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   300
    ** when the symbol is popped from the stack during a
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   301
    ** reduce or during error processing or when a parser is 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   302
    ** being destroyed before it is finished parsing.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   303
    **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   304
    ** Note: during a reduce, the only symbols destroyed are those
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   305
    ** which appear on the RHS of the rule, but which are not used
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   306
    ** inside the C code.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   307
    */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   308
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   309
    default:  break;   /* If no destructor action specified: do nothing */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   310
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   311
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   312
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   313
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   314
** Pop the parser's stack once.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   315
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   316
** If there is a destructor routine associated with the token which
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   317
** is popped from the stack, then call it.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   318
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   319
** Return the major token number for the symbol popped.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   320
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   321
static int yy_pop_parser_stack(yyParser *pParser){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   322
  YYCODETYPE yymajor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   323
  yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   324
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   325
  if( pParser->yyidx<0 ) return 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   326
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   327
  if( yyTraceFILE && pParser->yyidx>=0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   328
    fprintf(yyTraceFILE,"%sPopping %s\n",
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   329
      yyTracePrompt,
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   330
      yyTokenName[yytos->major]);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   331
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   332
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   333
  yymajor = yytos->major;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   334
  yy_destructor(pParser, yymajor, &yytos->minor);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   335
  pParser->yyidx--;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   336
  return yymajor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   337
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   338
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   339
/* 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   340
** Deallocate and destroy a parser.  Destructors are all called for
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   341
** all stack elements before shutting the parser down.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   342
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   343
** Inputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   344
** <ul>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   345
** <li>  A pointer to the parser.  This should be a pointer
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   346
**       obtained from ParseAlloc.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   347
** <li>  A pointer to a function used to reclaim memory obtained
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   348
**       from malloc.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   349
** </ul>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   350
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   351
void ParseFree(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   352
  void *p,                    /* The parser to be deleted */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   353
#if __MOJOSHADER__
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   354
  void (*freeProc)(void*,void*),     /* Function used to reclaim memory */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   355
  void *malloc_data
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   356
#else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   357
  void (*freeProc)(void*)     /* Function used to reclaim memory */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   358
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   359
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   360
  yyParser *pParser = (yyParser*)p;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   361
  if( pParser==0 ) return;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   362
  while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   363
#if YYSTACKDEPTH<=0
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   364
  free(pParser->yystack);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   365
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   366
#if __MOJOSHADER__
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   367
  (*freeProc)((void*)pParser, malloc_data);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   368
#else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   369
  (*freeProc)((void*)pParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   370
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   371
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   372
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   373
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   374
** Return the peak depth of the stack for a parser.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   375
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   376
#ifdef YYTRACKMAXSTACKDEPTH
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   377
int ParseStackPeak(void *p){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   378
  yyParser *pParser = (yyParser*)p;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   379
  return pParser->yyidxMax;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   380
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   381
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   382
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   383
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   384
** Find the appropriate action for a parser given the terminal
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   385
** look-ahead token iLookAhead.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   386
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   387
** If the look-ahead token is YYNOCODE, then check to see if the action is
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   388
** independent of the look-ahead.  If it is, return the action, otherwise
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   389
** return YY_NO_ACTION.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   390
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   391
static int yy_find_shift_action(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   392
  yyParser *pParser,        /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   393
  YYCODETYPE iLookAhead     /* The look-ahead token */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   394
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   395
  int i;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   396
  int stateno = pParser->yystack[pParser->yyidx].stateno;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   397
 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   398
  if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   399
    return yy_default[stateno];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   400
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   401
  assert( iLookAhead!=YYNOCODE );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   402
  i += iLookAhead;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   403
  if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   404
    if( iLookAhead>0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   405
#ifdef YYFALLBACK
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   406
      YYCODETYPE iFallback;            /* Fallback token */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   407
      if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   408
             && (iFallback = yyFallback[iLookAhead])!=0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   409
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   410
        if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   411
          fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   412
             yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   413
        }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   414
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   415
        return yy_find_shift_action(pParser, iFallback);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   416
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   417
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   418
#ifdef YYWILDCARD
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   419
      {
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   420
        int j = i - iLookAhead + YYWILDCARD;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   421
        if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   422
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   423
          if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   424
            fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   425
               yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   426
          }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   427
#endif /* NDEBUG */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   428
          return yy_action[j];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   429
        }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   430
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   431
#endif /* YYWILDCARD */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   432
    }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   433
    return yy_default[stateno];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   434
  }else{
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   435
    return yy_action[i];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   436
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   437
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   438
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   439
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   440
** Find the appropriate action for a parser given the non-terminal
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   441
** look-ahead token iLookAhead.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   442
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   443
** If the look-ahead token is YYNOCODE, then check to see if the action is
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   444
** independent of the look-ahead.  If it is, return the action, otherwise
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   445
** return YY_NO_ACTION.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   446
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   447
static int yy_find_reduce_action(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   448
  int stateno,              /* Current state number */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   449
  YYCODETYPE iLookAhead     /* The look-ahead token */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   450
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   451
  int i;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   452
#ifdef YYERRORSYMBOL
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   453
  if( stateno>YY_REDUCE_MAX ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   454
    return yy_default[stateno];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   455
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   456
#else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   457
  assert( stateno<=YY_REDUCE_MAX );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   458
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   459
  i = yy_reduce_ofst[stateno];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   460
  assert( i!=YY_REDUCE_USE_DFLT );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   461
  assert( iLookAhead!=YYNOCODE );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   462
  i += iLookAhead;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   463
#ifdef YYERRORSYMBOL
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   464
  if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   465
    return yy_default[stateno];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   466
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   467
#else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   468
  assert( i>=0 && i<YY_SZ_ACTTAB );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   469
  assert( yy_lookahead[i]==iLookAhead );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   470
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   471
  return yy_action[i];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   472
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   473
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   474
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   475
** The following routine is called if the stack overflows.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   476
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   477
static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   478
   ParseARG_FETCH;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   479
   yypParser->yyidx--;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   480
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   481
   if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   482
     fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   483
   }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   484
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   485
   while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   486
   /* Here code is inserted which will execute if the parser
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   487
   ** stack every overflows */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   488
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   489
   ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   490
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   491
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   492
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   493
** Perform a shift action.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   494
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   495
static void yy_shift(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   496
  yyParser *yypParser,          /* The parser to be shifted */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   497
  int yyNewState,               /* The new state to shift in */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   498
  int yyMajor,                  /* The major token to shift in */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   499
  YYMINORTYPE *yypMinor         /* Pointer to the minor token to shift in */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   500
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   501
  yyStackEntry *yytos;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   502
  yypParser->yyidx++;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   503
#ifdef YYTRACKMAXSTACKDEPTH
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   504
  if( yypParser->yyidx>yypParser->yyidxMax ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   505
    yypParser->yyidxMax = yypParser->yyidx;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   506
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   507
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   508
#if YYSTACKDEPTH>0 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   509
  if( yypParser->yyidx>=YYSTACKDEPTH ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   510
    yyStackOverflow(yypParser, yypMinor);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   511
    return;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   512
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   513
#else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   514
  if( yypParser->yyidx>=yypParser->yystksz ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   515
    yyGrowStack(yypParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   516
    if( yypParser->yyidx>=yypParser->yystksz ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   517
      yyStackOverflow(yypParser, yypMinor);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   518
      return;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   519
    }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   520
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   521
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   522
  yytos = &yypParser->yystack[yypParser->yyidx];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   523
  yytos->stateno = (YYACTIONTYPE)yyNewState;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   524
  yytos->major = (YYCODETYPE)yyMajor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   525
  yytos->minor = *yypMinor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   526
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   527
  if( yyTraceFILE && yypParser->yyidx>0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   528
    int i;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   529
    fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   530
    fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   531
    for(i=1; i<=yypParser->yyidx; i++)
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   532
      fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   533
    fprintf(yyTraceFILE,"\n");
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   534
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   535
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   536
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   537
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   538
/* The following table contains information about every rule that
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   539
** is used during the reduce.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   540
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   541
static const struct {
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   542
  YYCODETYPE lhs;         /* Symbol on the left-hand side of the rule */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   543
  unsigned char nrhs;     /* Number of right-hand side symbols in the rule */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   544
} yyRuleInfo[] = {
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   545
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   546
};
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   547
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   548
static void yy_accept(yyParser*);  /* Forward Declaration */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   549
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   550
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   551
** Perform a reduce action and the shift that must immediately
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   552
** follow the reduce.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   553
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   554
static void yy_reduce(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   555
  yyParser *yypParser,         /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   556
  int yyruleno                 /* Number of the rule by which to reduce */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   557
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   558
  int yygoto;                     /* The next state */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   559
  int yyact;                      /* The next action */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   560
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   561
  yyStackEntry *yymsp;            /* The top of the parser's stack */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   562
  int yysize;                     /* Amount to pop the stack */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   563
  ParseARG_FETCH;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   564
  yymsp = &yypParser->yystack[yypParser->yyidx];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   565
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   566
  if( yyTraceFILE && yyruleno>=0 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   567
        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   568
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   569
      yyRuleName[yyruleno]);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   570
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   571
#endif /* NDEBUG */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   572
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   573
  /* Silence complaints from purify about yygotominor being uninitialized
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   574
  ** in some cases when it is copied into the stack after the following
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   575
  ** switch.  yygotominor is uninitialized when a rule reduces that does
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   576
  ** not set the value of its left-hand side nonterminal.  Leaving the
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   577
  ** value of the nonterminal uninitialized is utterly harmless as long
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   578
  ** as the value is never used.  So really the only thing this code
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   579
  ** accomplishes is to quieten purify.  
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   580
  **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   581
  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   582
  ** without this code, their parser segfaults.  I'm not sure what there
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   583
  ** parser is doing to make this happen.  This is the second bug report
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   584
  ** from wireshark this week.  Clearly they are stressing Lemon in ways
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   585
  ** that it has not been previously stressed...  (SQLite ticket #2172)
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   586
  */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   587
  /*memset(&yygotominor, 0, sizeof(yygotominor));*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   588
  yygotominor = yyzerominor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   589
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   590
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   591
  switch( yyruleno ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   592
  /* Beginning here are the reduction cases.  A typical example
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   593
  ** follows:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   594
  **   case 0:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   595
  **  #line <lineno> <grammarfile>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   596
  **     { ... }           // User supplied code
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   597
  **  #line <lineno> <thisfile>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   598
  **     break;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   599
  */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   600
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   601
  };
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   602
  yygoto = yyRuleInfo[yyruleno].lhs;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   603
  yysize = yyRuleInfo[yyruleno].nrhs;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   604
  yypParser->yyidx -= yysize;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   605
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   606
  if( yyact < YYNSTATE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   607
#ifdef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   608
    /* If we are not debugging and the reduce action popped at least
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   609
    ** one element off the stack, then we can push the new element back
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   610
    ** onto the stack here, and skip the stack overflow test in yy_shift().
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   611
    ** That gives a significant speed improvement. */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   612
    if( yysize ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   613
      yypParser->yyidx++;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   614
      yymsp -= yysize-1;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   615
      yymsp->stateno = (YYACTIONTYPE)yyact;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   616
      yymsp->major = (YYCODETYPE)yygoto;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   617
      yymsp->minor = yygotominor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   618
    }else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   619
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   620
    {
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   621
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   622
    }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   623
  }else{
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   624
    assert( yyact == YYNSTATE + YYNRULE + 1 );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   625
    yy_accept(yypParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   626
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   627
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   628
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   629
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   630
** The following code executes when the parse fails
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   631
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   632
static void yy_parse_failed(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   633
  yyParser *yypParser           /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   634
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   635
  ParseARG_FETCH;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   636
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   637
  if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   638
    fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   639
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   640
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   641
  while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   642
  /* Here code is inserted which will be executed whenever the
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   643
  ** parser fails */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   644
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   645
  ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   646
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   647
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   648
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   649
** The following code executes when a syntax error first occurs.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   650
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   651
static void yy_syntax_error(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   652
  yyParser *yypParser,           /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   653
  int yymajor,                   /* The major type of the error token */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   654
  YYMINORTYPE yyminor            /* The minor type of the error token */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   655
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   656
  ParseARG_FETCH;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   657
#define TOKEN (yyminor.yy0)
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   658
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   659
  ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   660
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   661
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   662
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   663
** The following is executed when the parser accepts
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   664
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   665
static void yy_accept(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   666
  yyParser *yypParser           /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   667
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   668
  ParseARG_FETCH;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   669
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   670
  if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   671
    fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   672
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   673
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   674
  while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   675
  /* Here code is inserted which will be executed whenever the
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   676
  ** parser accepts */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   677
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   678
  ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   679
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   680
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   681
/* The main parser program.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   682
** The first argument is a pointer to a structure obtained from
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   683
** "ParseAlloc" which describes the current state of the parser.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   684
** The second argument is the major token number.  The third is
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   685
** the minor token.  The fourth optional argument is whatever the
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   686
** user wants (and specified in the grammar) and is available for
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   687
** use by the action routines.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   688
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   689
** Inputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   690
** <ul>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   691
** <li> A pointer to the parser (an opaque structure.)
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   692
** <li> The major token number.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   693
** <li> The minor token number.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   694
** <li> An option argument of a grammar-specified type.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   695
** </ul>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   696
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   697
** Outputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   698
** None.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   699
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   700
void Parse(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   701
  void *yyp,                   /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   702
  int yymajor,                 /* The major token code number */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   703
  ParseTOKENTYPE yyminor       /* The value for the token */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   704
  ParseARG_PDECL               /* Optional %extra_argument parameter */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   705
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   706
  YYMINORTYPE yyminorunion;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   707
  int yyact;            /* The parser action. */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   708
  int yyendofinput;     /* True if we are at the end of input */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   709
#ifdef YYERRORSYMBOL
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   710
  int yyerrorhit = 0;   /* True if yymajor has invoked an error */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   711
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   712
  yyParser *yypParser;  /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   713
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   714
  /* (re)initialize the parser, if necessary */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   715
  yypParser = (yyParser*)yyp;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   716
  if( yypParser->yyidx<0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   717
#if YYSTACKDEPTH<=0
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   718
    if( yypParser->yystksz <=0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   719
      /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   720
      yyminorunion = yyzerominor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   721
      yyStackOverflow(yypParser, &yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   722
      return;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   723
    }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   724
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   725
    yypParser->yyidx = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   726
    yypParser->yyerrcnt = -1;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   727
    yypParser->yystack[0].stateno = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   728
    yypParser->yystack[0].major = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   729
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   730
  yyminorunion.yy0 = yyminor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   731
  yyendofinput = (yymajor==0);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   732
  ParseARG_STORE;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   733
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   734
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   735
  if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   736
    fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   737
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   738
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   739
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   740
  do{
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   741
    yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   742
    if( yyact<YYNSTATE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   743
      assert( !yyendofinput );  /* Impossible to shift the $ token */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   744
      yy_shift(yypParser,yyact,yymajor,&yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   745
      yypParser->yyerrcnt--;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   746
      yymajor = YYNOCODE;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   747
    }else if( yyact < YYNSTATE + YYNRULE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   748
      yy_reduce(yypParser,yyact-YYNSTATE);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   749
    }else{
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   750
      assert( yyact == YY_ERROR_ACTION );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   751
#ifdef YYERRORSYMBOL
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   752
      int yymx;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   753
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   754
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   755
      if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   756
        fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   757
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   758
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   759
#ifdef YYERRORSYMBOL
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   760
      /* A syntax error has occurred.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   761
      ** The response to an error depends upon whether or not the
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   762
      ** grammar defines an error token "ERROR".  
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   763
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   764
      ** This is what we do if the grammar does define ERROR:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   765
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   766
      **  * Call the %syntax_error function.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   767
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   768
      **  * Begin popping the stack until we enter a state where
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   769
      **    it is legal to shift the error symbol, then shift
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   770
      **    the error symbol.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   771
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   772
      **  * Set the error count to three.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   773
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   774
      **  * Begin accepting and shifting new tokens.  No new error
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   775
      **    processing will occur until three tokens have been
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   776
      **    shifted successfully.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   777
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   778
      */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   779
      if( yypParser->yyerrcnt<0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   780
        yy_syntax_error(yypParser,yymajor,yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   781
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   782
      yymx = yypParser->yystack[yypParser->yyidx].major;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   783
      if( yymx==YYERRORSYMBOL || yyerrorhit ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   784
#ifndef NDEBUG
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   785
        if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   786
          fprintf(yyTraceFILE,"%sDiscard input token %s\n",
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   787
             yyTracePrompt,yyTokenName[yymajor]);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   788
        }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   789
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   790
        yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   791
        yymajor = YYNOCODE;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   792
      }else{
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   793
         while(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   794
          yypParser->yyidx >= 0 &&
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   795
          yymx != YYERRORSYMBOL &&
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   796
          (yyact = yy_find_reduce_action(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   797
                        yypParser->yystack[yypParser->yyidx].stateno,
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   798
                        YYERRORSYMBOL)) >= YYNSTATE
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   799
        ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   800
          yy_pop_parser_stack(yypParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   801
        }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   802
        if( yypParser->yyidx < 0 || yymajor==0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   803
          yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   804
          yy_parse_failed(yypParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   805
          yymajor = YYNOCODE;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   806
        }else if( yymx!=YYERRORSYMBOL ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   807
          YYMINORTYPE u2;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   808
          u2.YYERRSYMDT = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   809
          yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   810
        }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   811
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   812
      yypParser->yyerrcnt = 3;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   813
      yyerrorhit = 1;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   814
#else  /* YYERRORSYMBOL is not defined */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   815
      /* This is what we do if the grammar does not define ERROR:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   816
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   817
      **  * Report an error message, and throw away the input token.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   818
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   819
      **  * If the input token is $, then fail the parse.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   820
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   821
      ** As before, subsequent error messages are suppressed until
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   822
      ** three input tokens have been successfully shifted.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   823
      */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   824
      if( yypParser->yyerrcnt<=0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   825
        yy_syntax_error(yypParser,yymajor,yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   826
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   827
      yypParser->yyerrcnt = 3;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   828
      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   829
      if( yyendofinput ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   830
        yy_parse_failed(yypParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   831
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   832
      yymajor = YYNOCODE;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   833
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   834
    }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   835
  }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   836
  return;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   837
}