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