misc/lempar.c
author Ethan Lee <flibitijibibo@flibitijibibo.com>
Tue, 25 Aug 2020 22:41:43 -0400
changeset 1300 f1cdc5187d53
parent 834 f651801bfbbd
permissions -rw-r--r--
Handle MOJOSHADER_USAGE_UNKNOWN in SPIR-V linker
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
 */
715
817d02ae5c4b Make all the lempar.c functions static (we #include it from a .c file...)
Ryan C. Gordon <icculus@icculus.org>
parents: 708
diff changeset
     5
#ifndef __MOJOSHADER__
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
#define __MOJOSHADER__ 1
715
817d02ae5c4b Make all the lempar.c functions static (we #include it from a .c file...)
Ryan C. Gordon <icculus@icculus.org>
parents: 708
diff changeset
     7
#endif
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
     9
#if !__MOJOSHADER__
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
    10
#define LEMON_SUPPORT_TRACING (!defined(NDEBUG))
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
    11
#endif
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
    12
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
/* Driver template for the LEMON parser generator.
717
4465cffe0a9f ...just to be clear about that. :)
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
    14
** The original author(s) of lempar.c disclaim copyright to this source code.
4465cffe0a9f ...just to be clear about that. :)
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
    15
** However, changes made for MojoShader fall under the same license as the
4465cffe0a9f ...just to be clear about that. :)
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
    16
** rest of MojoShader. Please see the file LICENSE.txt in the source's root
4465cffe0a9f ...just to be clear about that. :)
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
    17
** directory.
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
/* 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
    20
** in the input grammar file. */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
#include <stdio.h>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
/* 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
    24
** 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
    25
*/
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
** 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
    28
** 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
    29
** understands. 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
** 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
    32
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
/* 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
    35
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
#ifndef INTERFACE
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
# define INTERFACE 1
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
/* 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
    40
** various aspects of the generated parser.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
**    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
    42
**                       and nonterminal numbers.  "unsigned char" is
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
**                       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
    44
**                       and nonterminals.  "int" is used otherwise.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
**    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
    46
**                       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
    47
**                       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
    48
**                       table.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
**    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
    50
**                       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
    51
**                       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
    52
**    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
    53
**                       and nonterminal numbers.  "unsigned char" is
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
**                       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
    55
**                       states combined.  "int" is used otherwise.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
**    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
    57
**                       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
    58
**    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
    59
**                       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
    60
**                       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
    61
**                       for base tokens is called "yy0".
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
**    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
    63
**                       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
    64
**    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
    65
**    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
    66
**    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
    67
**    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
    68
**    YYNSTATE           the combined number of states.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
**    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
    70
**    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
    71
**                       defined, then do no error processing.
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
#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
    75
#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
    76
#define YY_ERROR_ACTION   (YYNSTATE+YYNRULE)
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
/* 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
    79
** YYMINORTYPE objects to zero. */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
static const YYMINORTYPE yyzerominor = { 0 };
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
834
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
    82
/* Define the yytestcase() macro to be a no-op if is not already defined
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
    83
** otherwise.
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
    84
**
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
    85
** Applications can choose to define yytestcase() in the %include section
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
    86
** to a macro that can assist in verifying code coverage.  For production
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
    87
** code the yytestcase() macro should be turned off.  But it is useful
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
    88
** for testing.
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
    89
*/
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
    90
#ifndef yytestcase
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
    91
# define yytestcase(X)
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
    92
#endif
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
    93
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
/* 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
    96
** 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
    97
** 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
    98
** action integer.  
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
** 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
   101
** follows
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
**   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
   104
**                                      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
   105
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
**   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
   107
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
**   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
   109
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
**   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
   111
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   112
**   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
   113
**                                      slots in the yy_action[] table.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
** 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
   116
** 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
   117
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
**      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
   119
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
** 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
   121
** 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
   122
** 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
   123
** 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
   124
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
** 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
   126
** 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
   127
** 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
   128
** 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
   129
** YY_SHIFT_USE_DFLT.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
** 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
   132
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
**  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
   134
**  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
   135
**                     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
   136
**  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
   137
**                     shifting terminals.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
**  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
   139
**                     shifting non-terminals after a reduce.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   140
**  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
   141
*/
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
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   144
/* 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
   145
** like the following:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   146
** 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   147
**      %fallback ID X Y Z.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   148
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   149
** 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
   150
** 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
   151
** 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
   152
** 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
   153
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
#ifdef YYFALLBACK
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   155
static const YYCODETYPE yyFallback[] = {
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   156
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   157
};
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   158
#endif /* YYFALLBACK */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   159
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   160
/* 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
   161
** parser's stack.  Information stored includes:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   162
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
**   +  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
   164
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
**   +  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
   166
**      (In other words, the "major" token.)
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   168
**   +  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
   169
**      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
   170
**      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
   171
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
struct yyStackEntry {
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
  YYACTIONTYPE stateno;  /* The state-number */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   174
  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
   175
                         ** 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
   176
  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
   177
                         ** is the value of the token  */
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
typedef struct yyStackEntry yyStackEntry;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   180
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   181
/* 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
   182
** the following structure */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   183
struct yyParser {
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   184
  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
   185
#ifdef YYTRACKMAXSTACKDEPTH
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   186
  int yyidxMax;                 /* Maximum value of yyidx */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   187
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   188
  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
   189
  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
   190
#if YYSTACKDEPTH<=0
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   191
  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
   192
  yyStackEntry *yystack;        /* The parser's stack */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   193
#else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   194
  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
   195
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   196
};
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   197
typedef struct yyParser yyParser;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   198
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   199
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   200
#include <stdio.h>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   201
static FILE *yyTraceFILE = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   202
static char *yyTracePrompt = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   203
#endif /* NDEBUG */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   204
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   205
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   206
/*
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   207
** 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
   208
** 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
   209
** by making either argument NULL 
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
** Inputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   212
** <ul>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   213
** <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
   214
**      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
   215
** <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
   216
**      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
   217
**      turned off.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   218
** </ul>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   219
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   220
** Outputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   221
** None.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   222
*/
715
817d02ae5c4b Make all the lempar.c functions static (we #include it from a .c file...)
Ryan C. Gordon <icculus@icculus.org>
parents: 708
diff changeset
   223
#if __MOJOSHADER__
817d02ae5c4b Make all the lempar.c functions static (we #include it from a .c file...)
Ryan C. Gordon <icculus@icculus.org>
parents: 708
diff changeset
   224
static
817d02ae5c4b Make all the lempar.c functions static (we #include it from a .c file...)
Ryan C. Gordon <icculus@icculus.org>
parents: 708
diff changeset
   225
#endif
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   226
void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   227
  yyTraceFILE = TraceFILE;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   228
  yyTracePrompt = zTracePrompt;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   229
  if( yyTraceFILE==0 ) yyTracePrompt = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   230
  else if( yyTracePrompt==0 ) yyTraceFILE = 0;
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
#endif /* NDEBUG */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   233
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   234
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   235
/* 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
   236
** 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
   237
static const char *const yyTokenName[] = { 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   238
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   239
};
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   240
#endif /* NDEBUG */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   241
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   242
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   243
/* 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
   244
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   245
static const char *const yyRuleName[] = {
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   246
%%
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
#endif /* NDEBUG */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   249
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
#if YYSTACKDEPTH<=0
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   252
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   253
** 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
   254
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   255
static void yyGrowStack(yyParser *p){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   256
  int newSize;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   257
  yyStackEntry *pNew;
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
  newSize = p->yystksz*2 + 100;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   260
  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
   261
  if( pNew ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   262
    p->yystack = pNew;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   263
    p->yystksz = newSize;
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   264
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   265
    if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   266
      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
   267
              yyTracePrompt, p->yystksz);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   268
    }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   269
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   270
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   271
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   272
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   273
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   274
/* 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   275
** This function allocates a new parser.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   276
** 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
   277
** malloc.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   278
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   279
** Inputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   280
** 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
   281
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   282
** Outputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   283
** 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
   284
** to Parse and ParseFree.
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
#if __MOJOSHADER__
794
55bd6ae8be53 Fixed compiler warning about Lemon allocator function signature.
Ryan C. Gordon <icculus@icculus.org>
parents: 717
diff changeset
   287
static void *ParseAlloc(void *(*mallocProc)(int,void *), void *malloc_data){
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   288
  yyParser *pParser;
794
55bd6ae8be53 Fixed compiler warning about Lemon allocator function signature.
Ryan C. Gordon <icculus@icculus.org>
parents: 717
diff changeset
   289
  pParser = (yyParser*)(*mallocProc)( (int)sizeof(yyParser), malloc_data );
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   290
#else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   291
void *ParseAlloc(void *(*mallocProc)(size_t)){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   292
  yyParser *pParser;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   293
  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
   294
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   295
  if( pParser ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   296
    pParser->yyidx = -1;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   297
#ifdef YYTRACKMAXSTACKDEPTH
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   298
    pParser->yyidxMax = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   299
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   300
#if YYSTACKDEPTH<=0
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   301
    pParser->yystack = NULL;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   302
    pParser->yystksz = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   303
    yyGrowStack(pParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   304
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   305
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   306
  return pParser;
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
/* 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
   310
** 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
   311
** "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
   312
** the value.
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
static void yy_destructor(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   315
  yyParser *yypParser,    /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   316
  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
   317
  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
   318
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   319
  ParseARG_FETCH;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   320
  switch( yymajor ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   321
    /* 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
   322
    ** 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
   323
    ** 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
   324
    ** 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
   325
    ** 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
   326
    **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   327
    ** 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
   328
    ** 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
   329
    ** inside the C code.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   330
    */
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
    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
   333
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   334
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   335
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   336
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   337
** Pop the parser's stack once.
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
** 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
   340
** 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
   341
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   342
** 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
   343
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   344
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
   345
  YYCODETYPE yymajor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   346
  yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   347
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   348
  if( pParser->yyidx<0 ) return 0;
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   349
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   350
  if( yyTraceFILE && pParser->yyidx>=0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   351
    fprintf(yyTraceFILE,"%sPopping %s\n",
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   352
      yyTracePrompt,
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   353
      yyTokenName[yytos->major]);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   354
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   355
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   356
  yymajor = yytos->major;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   357
  yy_destructor(pParser, yymajor, &yytos->minor);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   358
  pParser->yyidx--;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   359
  return yymajor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   360
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   361
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   362
/* 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   363
** 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
   364
** 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
   365
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   366
** Inputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   367
** <ul>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   368
** <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
   369
**       obtained from ParseAlloc.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   370
** <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
   371
**       from malloc.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   372
** </ul>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   373
*/
715
817d02ae5c4b Make all the lempar.c functions static (we #include it from a .c file...)
Ryan C. Gordon <icculus@icculus.org>
parents: 708
diff changeset
   374
#if __MOJOSHADER__
817d02ae5c4b Make all the lempar.c functions static (we #include it from a .c file...)
Ryan C. Gordon <icculus@icculus.org>
parents: 708
diff changeset
   375
static
817d02ae5c4b Make all the lempar.c functions static (we #include it from a .c file...)
Ryan C. Gordon <icculus@icculus.org>
parents: 708
diff changeset
   376
#endif
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   377
void ParseFree(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   378
  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
   379
#if __MOJOSHADER__
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   380
  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
   381
  void *malloc_data
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   382
#else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   383
  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
   384
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   385
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   386
  yyParser *pParser = (yyParser*)p;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   387
  if( pParser==0 ) return;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   388
  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
   389
#if YYSTACKDEPTH<=0
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   390
  free(pParser->yystack);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   391
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   392
#if __MOJOSHADER__
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   393
  (*freeProc)((void*)pParser, malloc_data);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   394
#else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   395
  (*freeProc)((void*)pParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   396
#endif
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
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   399
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   400
** 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
   401
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   402
#ifdef YYTRACKMAXSTACKDEPTH
715
817d02ae5c4b Make all the lempar.c functions static (we #include it from a .c file...)
Ryan C. Gordon <icculus@icculus.org>
parents: 708
diff changeset
   403
static int ParseStackPeak(void *p){
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   404
  yyParser *pParser = (yyParser*)p;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   405
  return pParser->yyidxMax;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   406
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   407
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   408
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   409
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   410
** 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
   411
** look-ahead token iLookAhead.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   412
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   413
** 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
   414
** 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
   415
** return YY_NO_ACTION.
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
static int yy_find_shift_action(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   418
  yyParser *pParser,        /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   419
  YYCODETYPE iLookAhead     /* The look-ahead token */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   420
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   421
  int i;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   422
  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
   423
 
834
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   424
  if( stateno>YY_SHIFT_COUNT
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   425
   || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   426
    return yy_default[stateno];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   427
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   428
  assert( iLookAhead!=YYNOCODE );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   429
  i += iLookAhead;
834
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   430
  if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   431
    if( iLookAhead>0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   432
#ifdef YYFALLBACK
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   433
      YYCODETYPE iFallback;            /* Fallback token */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   434
      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
   435
             && (iFallback = yyFallback[iLookAhead])!=0 ){
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   436
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   437
        if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   438
          fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   439
             yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   440
        }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   441
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   442
        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
   443
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   444
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   445
#ifdef YYWILDCARD
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
        int j = i - iLookAhead + YYWILDCARD;
834
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   448
        if( 
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   449
#if YY_SHIFT_MIN+YYWILDCARD<0
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   450
          j>=0 &&
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   451
#endif
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   452
#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   453
          j<YY_ACTTAB_COUNT &&
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   454
#endif
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   455
          yy_lookahead[j]==YYWILDCARD
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   456
        ){
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   457
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   458
          if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   459
            fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   460
               yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   461
          }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   462
#endif /* NDEBUG */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   463
          return yy_action[j];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   464
        }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   465
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   466
#endif /* YYWILDCARD */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   467
    }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   468
    return yy_default[stateno];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   469
  }else{
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   470
    return yy_action[i];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   471
  }
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
** 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
   476
** look-ahead token iLookAhead.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   477
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   478
** 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
   479
** 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
   480
** return YY_NO_ACTION.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   481
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   482
static int yy_find_reduce_action(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   483
  int stateno,              /* Current state number */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   484
  YYCODETYPE iLookAhead     /* The look-ahead token */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   485
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   486
  int i;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   487
#ifdef YYERRORSYMBOL
834
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   488
  if( stateno>YY_REDUCE_COUNT ){
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   489
    return yy_default[stateno];
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
#else
834
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   492
  assert( stateno<=YY_REDUCE_COUNT );
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   493
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   494
  i = yy_reduce_ofst[stateno];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   495
  assert( i!=YY_REDUCE_USE_DFLT );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   496
  assert( iLookAhead!=YYNOCODE );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   497
  i += iLookAhead;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   498
#ifdef YYERRORSYMBOL
834
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   499
  if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   500
    return yy_default[stateno];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   501
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   502
#else
834
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   503
  assert( i>=0 && i<YY_ACTTAB_COUNT );
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   504
  assert( yy_lookahead[i]==iLookAhead );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   505
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   506
  return yy_action[i];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   507
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   508
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   509
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   510
** 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
   511
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   512
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
   513
   ParseARG_FETCH;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   514
   yypParser->yyidx--;
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   515
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   516
   if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   517
     fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   518
   }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   519
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   520
   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
   521
   /* 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
   522
   ** stack every overflows */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   523
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   524
   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
   525
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   526
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   527
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   528
** Perform a shift action.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   529
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   530
static void yy_shift(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   531
  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
   532
  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
   533
  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
   534
  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
   535
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   536
  yyStackEntry *yytos;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   537
  yypParser->yyidx++;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   538
#ifdef YYTRACKMAXSTACKDEPTH
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   539
  if( yypParser->yyidx>yypParser->yyidxMax ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   540
    yypParser->yyidxMax = yypParser->yyidx;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   541
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   542
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   543
#if YYSTACKDEPTH>0 
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   544
  if( yypParser->yyidx>=YYSTACKDEPTH ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   545
    yyStackOverflow(yypParser, yypMinor);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   546
    return;
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
#else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   549
  if( yypParser->yyidx>=yypParser->yystksz ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   550
    yyGrowStack(yypParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   551
    if( yypParser->yyidx>=yypParser->yystksz ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   552
      yyStackOverflow(yypParser, yypMinor);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   553
      return;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   554
    }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   555
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   556
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   557
  yytos = &yypParser->yystack[yypParser->yyidx];
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   558
  yytos->stateno = (YYACTIONTYPE)yyNewState;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   559
  yytos->major = (YYCODETYPE)yyMajor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   560
  yytos->minor = *yypMinor;
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   561
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   562
  if( yyTraceFILE && yypParser->yyidx>0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   563
    int i;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   564
    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
   565
    fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   566
    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
   567
      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
   568
    fprintf(yyTraceFILE,"\n");
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   569
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   570
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   571
}
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
/* 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
   574
** is used during the reduce.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   575
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   576
static const struct {
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   577
  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
   578
  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
   579
} yyRuleInfo[] = {
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
};
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   582
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   583
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
   584
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   585
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   586
** 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
   587
** follow the reduce.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   588
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   589
static void yy_reduce(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   590
  yyParser *yypParser,         /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   591
  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
   592
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   593
  int yygoto;                     /* The next state */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   594
  int yyact;                      /* The next action */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   595
  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
   596
  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
   597
  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
   598
  ParseARG_FETCH;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   599
  yymsp = &yypParser->yystack[yypParser->yyidx];
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   600
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   601
  if( yyTraceFILE && yyruleno>=0
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   602
        && 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
   603
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   604
      yyRuleName[yyruleno]);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   605
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   606
#endif /* NDEBUG */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   607
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   608
  /* 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
   609
  ** 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
   610
  ** 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
   611
  ** 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
   612
  ** 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
   613
  ** 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
   614
  ** accomplishes is to quieten purify.  
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   615
  **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   616
  ** 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
   617
  ** 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
   618
  ** 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
   619
  ** 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
   620
  ** 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
   621
  */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   622
  /*memset(&yygotominor, 0, sizeof(yygotominor));*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   623
  yygotominor = yyzerominor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   624
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   625
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   626
  switch( yyruleno ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   627
  /* 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
   628
  ** follows:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   629
  **   case 0:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   630
  **  #line <lineno> <grammarfile>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   631
  **     { ... }           // User supplied code
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   632
  **  #line <lineno> <thisfile>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   633
  **     break;
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
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   636
  };
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   637
  yygoto = yyRuleInfo[yyruleno].lhs;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   638
  yysize = yyRuleInfo[yyruleno].nrhs;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   639
  yypParser->yyidx -= yysize;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   640
  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
   641
  if( yyact < YYNSTATE ){
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   642
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   643
    /* 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
   644
    ** 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
   645
    ** 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
   646
    ** That gives a significant speed improvement. */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   647
    if( yysize ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   648
      yypParser->yyidx++;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   649
      yymsp -= yysize-1;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   650
      yymsp->stateno = (YYACTIONTYPE)yyact;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   651
      yymsp->major = (YYCODETYPE)yygoto;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   652
      yymsp->minor = yygotominor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   653
    }else
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   654
#endif
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
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   657
    }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   658
  }else{
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   659
    assert( yyact == YYNSTATE + YYNRULE + 1 );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   660
    yy_accept(yypParser);
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
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
** 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
   666
*/
834
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   667
#ifndef YYNOERRORRECOVERY
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   668
static void yy_parse_failed(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   669
  yyParser *yypParser           /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   670
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   671
  ParseARG_FETCH;
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   672
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   673
  if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   674
    fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   675
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   676
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   677
  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
   678
  /* 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
   679
  ** parser fails */
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
  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
   682
}
834
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   683
#endif /* YYNOERRORRECOVERY */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   684
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   685
/*
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   686
** 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
   687
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   688
static void yy_syntax_error(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   689
  yyParser *yypParser,           /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   690
  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
   691
  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
   692
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   693
  ParseARG_FETCH;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   694
#define TOKEN (yyminor.yy0)
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   695
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   696
  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
   697
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   698
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
** 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
   701
*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   702
static void yy_accept(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   703
  yyParser *yypParser           /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   704
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   705
  ParseARG_FETCH;
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   706
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   707
  if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   708
    fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   709
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   710
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   711
  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
   712
  /* 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
   713
  ** parser accepts */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   714
%%
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   715
  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
   716
}
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   717
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   718
/* The main parser program.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   719
** 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
   720
** "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
   721
** 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
   722
** 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
   723
** 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
   724
** use by the action routines.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   725
**
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   726
** Inputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   727
** <ul>
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   728
** <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
   729
** <li> The major token number.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   730
** <li> The minor token number.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   731
** <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
   732
** </ul>
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
** Outputs:
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   735
** None.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   736
*/
715
817d02ae5c4b Make all the lempar.c functions static (we #include it from a .c file...)
Ryan C. Gordon <icculus@icculus.org>
parents: 708
diff changeset
   737
#if __MOJOSHADER__
817d02ae5c4b Make all the lempar.c functions static (we #include it from a .c file...)
Ryan C. Gordon <icculus@icculus.org>
parents: 708
diff changeset
   738
static
817d02ae5c4b Make all the lempar.c functions static (we #include it from a .c file...)
Ryan C. Gordon <icculus@icculus.org>
parents: 708
diff changeset
   739
#endif
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   740
void Parse(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   741
  void *yyp,                   /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   742
  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
   743
  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
   744
  ParseARG_PDECL               /* Optional %extra_argument parameter */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   745
){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   746
  YYMINORTYPE yyminorunion;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   747
  int yyact;            /* The parser action. */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   748
  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
   749
#ifdef YYERRORSYMBOL
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   750
  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
   751
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   752
  yyParser *yypParser;  /* The parser */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   753
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   754
  /* (re)initialize the parser, if necessary */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   755
  yypParser = (yyParser*)yyp;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   756
  if( yypParser->yyidx<0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   757
#if YYSTACKDEPTH<=0
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   758
    if( yypParser->yystksz <=0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   759
      /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   760
      yyminorunion = yyzerominor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   761
      yyStackOverflow(yypParser, &yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   762
      return;
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
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   765
    yypParser->yyidx = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   766
    yypParser->yyerrcnt = -1;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   767
    yypParser->yystack[0].stateno = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   768
    yypParser->yystack[0].major = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   769
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   770
  yyminorunion.yy0 = yyminor;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   771
  yyendofinput = (yymajor==0);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   772
  ParseARG_STORE;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   773
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   774
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   775
  if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   776
    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
   777
  }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   778
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   779
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   780
  do{
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   781
    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
   782
    if( yyact<YYNSTATE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   783
      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
   784
      yy_shift(yypParser,yyact,yymajor,&yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   785
      yypParser->yyerrcnt--;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   786
      yymajor = YYNOCODE;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   787
    }else if( yyact < YYNSTATE + YYNRULE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   788
      yy_reduce(yypParser,yyact-YYNSTATE);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   789
    }else{
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   790
      assert( yyact == YY_ERROR_ACTION );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   791
#ifdef YYERRORSYMBOL
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   792
      int yymx;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   793
#endif
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   794
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   795
      if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   796
        fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   797
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   798
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   799
#ifdef YYERRORSYMBOL
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   800
      /* A syntax error has occurred.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   801
      ** 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
   802
      ** grammar defines an error token "ERROR".  
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   803
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   804
      ** 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
   805
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   806
      **  * Call the %syntax_error function.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   807
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   808
      **  * 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
   809
      **    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
   810
      **    the error symbol.
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
      **  * Set the error count to three.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   813
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   814
      **  * 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
   815
      **    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
   816
      **    shifted successfully.
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   817
      **
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( yypParser->yyerrcnt<0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   820
        yy_syntax_error(yypParser,yymajor,yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   821
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   822
      yymx = yypParser->yystack[yypParser->yyidx].major;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   823
      if( yymx==YYERRORSYMBOL || yyerrorhit ){
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 715
diff changeset
   824
#if LEMON_SUPPORT_TRACING   /* __MOJOSHADER__ */
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   825
        if( yyTraceFILE ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   826
          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
   827
             yyTracePrompt,yyTokenName[yymajor]);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   828
        }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   829
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   830
        yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   831
        yymajor = YYNOCODE;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   832
      }else{
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   833
         while(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   834
          yypParser->yyidx >= 0 &&
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   835
          yymx != YYERRORSYMBOL &&
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   836
          (yyact = yy_find_reduce_action(
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   837
                        yypParser->yystack[yypParser->yyidx].stateno,
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   838
                        YYERRORSYMBOL)) >= YYNSTATE
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   839
        ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   840
          yy_pop_parser_stack(yypParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   841
        }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   842
        if( yypParser->yyidx < 0 || yymajor==0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   843
          yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   844
          yy_parse_failed(yypParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   845
          yymajor = YYNOCODE;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   846
        }else if( yymx!=YYERRORSYMBOL ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   847
          YYMINORTYPE u2;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   848
          u2.YYERRSYMDT = 0;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   849
          yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   850
        }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   851
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   852
      yypParser->yyerrcnt = 3;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   853
      yyerrorhit = 1;
834
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   854
#elif defined(YYNOERRORRECOVERY)
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   855
      /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   856
      ** do any kind of error recovery.  Instead, simply invoke the syntax
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   857
      ** error routine and continue going as if nothing had happened.
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   858
      **
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   859
      ** Applications can set this macro (for example inside %include) if
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   860
      ** they intend to abandon the parse upon the first syntax error seen.
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   861
      */
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   862
      yy_syntax_error(yypParser,yymajor,yyminorunion);
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   863
      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   864
      yymajor = YYNOCODE;
f651801bfbbd Updated lempar.c to match updated lemon.c
Ryan C. Gordon <icculus@icculus.org>
parents: 794
diff changeset
   865
      
708
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   866
#else  /* YYERRORSYMBOL is not defined */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   867
      /* 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
   868
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   869
      **  * 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
   870
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   871
      **  * 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
   872
      **
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   873
      ** 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
   874
      ** 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
   875
      */
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   876
      if( yypParser->yyerrcnt<=0 ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   877
        yy_syntax_error(yypParser,yymajor,yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   878
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   879
      yypParser->yyerrcnt = 3;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   880
      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   881
      if( yyendofinput ){
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   882
        yy_parse_failed(yypParser);
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   883
      }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   884
      yymajor = YYNOCODE;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   885
#endif
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   886
    }
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   887
  }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   888
  return;
d29c193900b0 Added lemon and lempar sources to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   889
}