2001-02-01 20:21:25 +00:00
|
|
|
/* Driver template for the LEMON parser generator.
|
2008-07-29 12:40:03 +00:00
|
|
|
* $Id$
|
|
|
|
*
|
2001-02-01 20:21:25 +00:00
|
|
|
** Copyright 1991-1995 by D. Richard Hipp.
|
|
|
|
**
|
|
|
|
** This library is free software; you can redistribute it and/or
|
|
|
|
** modify it under the terms of the GNU Library General Public
|
|
|
|
** License as published by the Free Software Foundation; either
|
|
|
|
** version 2 of the License, or (at your option) any later version.
|
2002-08-28 21:04:11 +00:00
|
|
|
**
|
2001-02-01 20:21:25 +00:00
|
|
|
** This library is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
** Library General Public License for more details.
|
2002-08-28 21:04:11 +00:00
|
|
|
**
|
2001-02-01 20:21:25 +00:00
|
|
|
** You should have received a copy of the GNU Library General Public
|
|
|
|
** License along with this library; if not, write to the
|
|
|
|
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
** Boston, MA 02111-1307, USA.
|
|
|
|
**
|
|
|
|
** Modified 1997 to make it suitable for use with makeheaders.
|
2008-07-29 12:40:03 +00:00
|
|
|
* Updated to sqlite lemon version 1.36
|
2001-02-01 20:21:25 +00:00
|
|
|
*/
|
2008-07-29 12:40:03 +00:00
|
|
|
/* First off, code is included that follows the "include" declaration
|
|
|
|
** in the input grammar file. */
|
2005-08-04 20:41:52 +00:00
|
|
|
#include <stdio.h>
|
2013-03-04 22:04:58 +00:00
|
|
|
%%
|
2001-02-01 20:21:25 +00:00
|
|
|
/* Next is all token values, in a form suitable for use by makeheaders.
|
|
|
|
** This section will be null unless lemon is run with the -m switch.
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
/*
|
2001-02-01 20:21:25 +00:00
|
|
|
** These constants (all generated automatically by the parser generator)
|
|
|
|
** specify the various kinds of tokens (terminals) that the parser
|
2002-08-28 21:04:11 +00:00
|
|
|
** understands.
|
2001-02-01 20:21:25 +00:00
|
|
|
**
|
|
|
|
** Each symbol here is a terminal symbol in the grammar.
|
|
|
|
*/
|
|
|
|
%%
|
|
|
|
/* Make sure the INTERFACE macro is defined.
|
|
|
|
*/
|
|
|
|
#ifndef INTERFACE
|
|
|
|
# define INTERFACE 1
|
|
|
|
#endif
|
|
|
|
/* The next thing included is series of defines which control
|
|
|
|
** various aspects of the generated parser.
|
|
|
|
** YYCODETYPE is the data type used for storing terminal
|
|
|
|
** and nonterminal numbers. "unsigned char" is
|
|
|
|
** used if there are fewer than 250 terminals
|
|
|
|
** and nonterminals. "int" is used otherwise.
|
|
|
|
** YYNOCODE is a number of type YYCODETYPE which corresponds
|
|
|
|
** to no legal terminal or nonterminal number. This
|
2002-08-28 21:04:11 +00:00
|
|
|
** number is used to fill in empty slots of the hash
|
2001-02-01 20:21:25 +00:00
|
|
|
** table.
|
2006-03-21 18:56:34 +00:00
|
|
|
** YYFALLBACK If defined, this indicates that one or more tokens
|
|
|
|
** have fall-back values which should be used if the
|
|
|
|
** original value of the token will not parse.
|
2001-02-01 20:21:25 +00:00
|
|
|
** YYACTIONTYPE is the data type used for storing terminal
|
|
|
|
** and nonterminal numbers. "unsigned char" is
|
|
|
|
** used if there are fewer than 250 rules and
|
|
|
|
** states combined. "int" is used otherwise.
|
2002-08-28 21:04:11 +00:00
|
|
|
** ParseTOKENTYPE is the data type used for minor tokens given
|
2001-02-01 20:21:25 +00:00
|
|
|
** directly to the parser from the tokenizer.
|
|
|
|
** YYMINORTYPE is the data type used for all minor tokens.
|
|
|
|
** This is typically a union of many types, one of
|
|
|
|
** which is ParseTOKENTYPE. The entry in the union
|
|
|
|
** for base tokens is called "yy0".
|
2008-04-08 09:54:19 +00:00
|
|
|
** YYSTACKDEPTH is the maximum depth of the parser's stack. If
|
|
|
|
** zero the stack is dynamically sized using realloc()
|
2006-03-21 18:56:34 +00:00
|
|
|
** ParseARG_SDECL A static variable declaration for the %extra_argument
|
|
|
|
** ParseARG_PDECL A parameter declaration for the %extra_argument
|
|
|
|
** ParseARG_STORE Code to store %extra_argument into yypParser
|
|
|
|
** ParseARG_FETCH Code to extract %extra_argument from yypParser
|
2001-02-01 20:21:25 +00:00
|
|
|
** YYNSTATE the combined number of states.
|
|
|
|
** YYNRULE the number of rules in the grammar
|
|
|
|
** YYERRORSYMBOL is the code number of the error symbol. If not
|
|
|
|
** defined, then do no error processing.
|
|
|
|
*/
|
|
|
|
%%
|
|
|
|
#define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
|
|
|
|
#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
|
|
|
|
#define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
|
2006-03-21 18:56:34 +00:00
|
|
|
|
2008-07-29 12:40:03 +00:00
|
|
|
/* The yyzerominor constant is used to initialize instances of
|
|
|
|
** YYMINORTYPE objects to zero. */
|
2013-03-04 22:04:58 +00:00
|
|
|
static const YYMINORTYPE yyzerominor = { 0 };
|
|
|
|
|
|
|
|
/* Define the yytestcase() macro to be a no-op if is not already defined
|
|
|
|
** otherwise.
|
|
|
|
**
|
|
|
|
** Applications can choose to define yytestcase() in the %include section
|
|
|
|
** to a macro that can assist in verifying code coverage. For production
|
|
|
|
** code the yytestcase() macro should be turned off. But it is useful
|
|
|
|
** for testing.
|
|
|
|
*/
|
|
|
|
#ifndef yytestcase
|
|
|
|
# define yytestcase(X)
|
|
|
|
#endif
|
2008-07-29 12:40:03 +00:00
|
|
|
|
|
|
|
/* Next are the tables used to determine what action to take based on the
|
2006-03-21 18:56:34 +00:00
|
|
|
** current state and lookahead token. These tables are used to implement
|
|
|
|
** functions that take a state number and lookahead value and return an
|
|
|
|
** action integer.
|
2001-02-01 20:21:25 +00:00
|
|
|
**
|
2006-08-01 21:29:05 +00:00
|
|
|
** Suppose the action integer is N. Then the action is determined as
|
|
|
|
** follows
|
2001-02-01 20:21:25 +00:00
|
|
|
**
|
2006-08-01 21:29:05 +00:00
|
|
|
** 0 <= N < YYNSTATE Shift N. That is, push the lookahead
|
|
|
|
** token onto the stack and goto state N.
|
|
|
|
**
|
|
|
|
** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE.
|
|
|
|
**
|
|
|
|
** N == YYNSTATE+YYNRULE A syntax error has occurred.
|
|
|
|
**
|
|
|
|
** N == YYNSTATE+YYNRULE+1 The parser accepts its input.
|
|
|
|
**
|
|
|
|
** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused
|
|
|
|
** slots in the yy_action[] table.
|
|
|
|
**
|
|
|
|
** The action table is constructed as a single large table named yy_action[].
|
|
|
|
** Given state S and lookahead X, the action is computed as
|
2001-02-01 20:21:25 +00:00
|
|
|
**
|
2006-03-21 18:56:34 +00:00
|
|
|
** yy_action[ yy_shift_ofst[S] + X ]
|
2001-02-01 20:21:25 +00:00
|
|
|
**
|
2006-08-01 21:29:05 +00:00
|
|
|
** If the index value yy_shift_ofst[S]+X is out of range or if the value
|
2006-03-21 18:56:34 +00:00
|
|
|
** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
|
|
|
|
** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
|
|
|
|
** and that yy_default[S] should be used instead.
|
|
|
|
**
|
|
|
|
** The formula above is for computing the action when the lookahead is
|
|
|
|
** a terminal symbol. If the lookahead is a non-terminal (as occurs after
|
|
|
|
** a reduce action) then the yy_reduce_ofst[] array is used in place of
|
|
|
|
** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
|
|
|
|
** YY_SHIFT_USE_DFLT.
|
2001-02-01 20:21:25 +00:00
|
|
|
**
|
2006-03-21 18:56:34 +00:00
|
|
|
** The following are the tables generated in this section:
|
2001-02-01 20:21:25 +00:00
|
|
|
**
|
2006-03-21 18:56:34 +00:00
|
|
|
** yy_action[] A single table containing all actions.
|
|
|
|
** yy_lookahead[] A table containing the lookahead for each entry in
|
|
|
|
** yy_action. Used to detect hash collisions.
|
|
|
|
** yy_shift_ofst[] For each state, the offset into yy_action for
|
|
|
|
** shifting terminals.
|
|
|
|
** yy_reduce_ofst[] For each state, the offset into yy_action for
|
|
|
|
** shifting non-terminals after a reduce.
|
|
|
|
** yy_default[] Default action for each state.
|
2006-08-01 21:29:05 +00:00
|
|
|
*/
|
2006-03-21 18:56:34 +00:00
|
|
|
%%
|
2006-11-19 16:24:18 +00:00
|
|
|
#define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
|
|
|
|
|
2006-03-21 18:56:34 +00:00
|
|
|
/* The next table maps tokens into fallback tokens. If a construct
|
|
|
|
** like the following:
|
|
|
|
**
|
|
|
|
** %fallback ID X Y Z.
|
2001-02-01 20:21:25 +00:00
|
|
|
**
|
2008-07-29 12:40:03 +00:00
|
|
|
** appears in the grammar, then ID becomes a fallback token for X, Y,
|
2006-03-21 18:56:34 +00:00
|
|
|
** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
|
|
|
|
** but it does not parse, the type of the token is changed to ID and
|
|
|
|
** the parse is retried before an error is thrown.
|
2001-02-01 20:21:25 +00:00
|
|
|
*/
|
2006-03-21 18:56:34 +00:00
|
|
|
#ifdef YYFALLBACK
|
|
|
|
static const YYCODETYPE yyFallback[] = {
|
2001-02-01 20:21:25 +00:00
|
|
|
%%
|
|
|
|
};
|
2006-03-21 18:56:34 +00:00
|
|
|
#endif /* YYFALLBACK */
|
2001-02-01 20:21:25 +00:00
|
|
|
|
|
|
|
/* The following structure represents a single element of the
|
|
|
|
** parser's stack. Information stored includes:
|
|
|
|
**
|
|
|
|
** + The state number for the parser at this level of the stack.
|
|
|
|
**
|
|
|
|
** + The value of the token stored at this level of the stack.
|
|
|
|
** (In other words, the "major" token.)
|
|
|
|
**
|
|
|
|
** + The semantic value stored at this level of the stack. This is
|
|
|
|
** the information used by the action routines in the grammar.
|
|
|
|
** It is sometimes called the "minor" token.
|
|
|
|
*/
|
|
|
|
struct yyStackEntry {
|
2008-07-29 12:40:03 +00:00
|
|
|
YYACTIONTYPE stateno; /* The state-number */
|
|
|
|
YYCODETYPE major; /* The major token value. This is the code
|
|
|
|
** number for the token at this stack level */
|
|
|
|
YYMINORTYPE minor; /* The user-supplied minor token value. This
|
|
|
|
** is the value of the token */
|
2001-02-01 20:21:25 +00:00
|
|
|
};
|
2006-03-21 18:56:34 +00:00
|
|
|
typedef struct yyStackEntry yyStackEntry;
|
2001-02-01 20:21:25 +00:00
|
|
|
|
|
|
|
/* The state of the parser is completely contained in an instance of
|
|
|
|
** the following structure */
|
|
|
|
struct yyParser {
|
2006-03-21 18:56:34 +00:00
|
|
|
int yyidx; /* Index of top element in stack */
|
2008-07-29 12:40:03 +00:00
|
|
|
#ifdef YYTRACKMAXSTACKDEPTH
|
|
|
|
int yyidxMax; /* Maximum value of yyidx */
|
|
|
|
#endif
|
2006-03-21 18:56:34 +00:00
|
|
|
int yyerrcnt; /* Shifts left before out of the error */
|
|
|
|
ParseARG_SDECL /* A place to hold %extra_argument */
|
2008-04-08 09:54:19 +00:00
|
|
|
#if YYSTACKDEPTH<=0
|
|
|
|
int yystksz; /* Current side of the stack */
|
|
|
|
yyStackEntry *yystack; /* The parser's stack */
|
|
|
|
#else
|
2006-03-21 18:56:34 +00:00
|
|
|
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
|
2008-04-08 09:54:19 +00:00
|
|
|
#endif
|
2001-02-01 20:21:25 +00:00
|
|
|
};
|
|
|
|
typedef struct yyParser yyParser;
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
#include <stdio.h>
|
|
|
|
static FILE *yyTraceFILE = 0;
|
|
|
|
static char *yyTracePrompt = 0;
|
2006-03-21 18:56:34 +00:00
|
|
|
#endif /* NDEBUG */
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
2002-08-28 21:04:11 +00:00
|
|
|
/*
|
2001-02-01 20:21:25 +00:00
|
|
|
** Turn parser tracing on by giving a stream to which to write the trace
|
|
|
|
** and a prompt to preface each trace message. Tracing is turned off
|
2002-08-28 21:04:11 +00:00
|
|
|
** by making either argument NULL
|
2001-02-01 20:21:25 +00:00
|
|
|
**
|
|
|
|
** Inputs:
|
|
|
|
** <ul>
|
|
|
|
** <li> A FILE* to which trace output should be written.
|
|
|
|
** If NULL, then tracing is turned off.
|
|
|
|
** <li> A prefix string written at the beginning of every
|
|
|
|
** line of trace output. If NULL, then tracing is
|
|
|
|
** turned off.
|
|
|
|
** </ul>
|
|
|
|
**
|
|
|
|
** Outputs:
|
|
|
|
** None.
|
|
|
|
*/
|
|
|
|
void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
|
|
|
|
yyTraceFILE = TraceFILE;
|
|
|
|
yyTracePrompt = zTracePrompt;
|
|
|
|
if( yyTraceFILE==0 ) yyTracePrompt = 0;
|
|
|
|
else if( yyTracePrompt==0 ) yyTraceFILE = 0;
|
|
|
|
}
|
2006-03-21 18:56:34 +00:00
|
|
|
#endif /* NDEBUG */
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
2001-02-01 20:21:25 +00:00
|
|
|
/* For tracing shifts, the names of all terminals and nonterminals
|
|
|
|
** are required. The following table supplies these names */
|
2006-08-01 21:29:05 +00:00
|
|
|
static const char *const yyTokenName[] = {
|
2001-02-01 20:21:25 +00:00
|
|
|
%%
|
|
|
|
};
|
2006-03-21 18:56:34 +00:00
|
|
|
#endif /* NDEBUG */
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
/* For tracing reduce actions, the names of all rules are required.
|
|
|
|
*/
|
2006-08-01 21:29:05 +00:00
|
|
|
static const char *const yyRuleName[] = {
|
2006-03-21 18:56:34 +00:00
|
|
|
%%
|
|
|
|
};
|
|
|
|
#endif /* NDEBUG */
|
|
|
|
|
2008-04-08 09:54:19 +00:00
|
|
|
|
|
|
|
#if YYSTACKDEPTH<=0
|
2006-03-21 18:56:34 +00:00
|
|
|
/*
|
2008-04-08 09:54:19 +00:00
|
|
|
** Try to increase the size of the parser stack.
|
2006-03-21 18:56:34 +00:00
|
|
|
*/
|
2008-04-08 09:54:19 +00:00
|
|
|
static void yyGrowStack(yyParser *p){
|
|
|
|
int newSize;
|
|
|
|
yyStackEntry *pNew;
|
|
|
|
|
|
|
|
newSize = p->yystksz*2 + 100;
|
|
|
|
pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
|
|
|
|
if( pNew ){
|
|
|
|
p->yystack = pNew;
|
|
|
|
p->yystksz = newSize;
|
2006-03-21 18:56:34 +00:00
|
|
|
#ifndef NDEBUG
|
2008-04-08 09:54:19 +00:00
|
|
|
if( yyTraceFILE ){
|
|
|
|
fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
|
|
|
|
yyTracePrompt, p->yystksz);
|
|
|
|
}
|
2001-02-01 20:21:25 +00:00
|
|
|
#endif
|
2008-04-08 09:54:19 +00:00
|
|
|
}
|
2006-03-21 18:56:34 +00:00
|
|
|
}
|
2008-04-08 09:54:19 +00:00
|
|
|
#endif
|
2006-03-21 18:56:34 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/*
|
2001-02-01 20:21:25 +00:00
|
|
|
** This function allocates a new parser.
|
|
|
|
** The only argument is a pointer to a function which works like
|
|
|
|
** malloc.
|
|
|
|
**
|
|
|
|
** Inputs:
|
|
|
|
** A pointer to the function used to allocate memory.
|
|
|
|
**
|
|
|
|
** Outputs:
|
|
|
|
** A pointer to a parser. This pointer is used in subsequent calls
|
|
|
|
** to Parse and ParseFree.
|
|
|
|
*/
|
2008-03-23 08:58:52 +00:00
|
|
|
void *ParseAlloc(void *(*mallocProc)(gsize)){
|
|
|
|
yyParser *pParser;
|
|
|
|
pParser = (yyParser*)(*mallocProc)( (gsize)sizeof(yyParser) );
|
2001-02-01 20:21:25 +00:00
|
|
|
if( pParser ){
|
2006-03-21 18:56:34 +00:00
|
|
|
pParser->yyidx = -1;
|
2008-07-29 12:40:03 +00:00
|
|
|
#ifdef YYTRACKMAXSTACKDEPTH
|
|
|
|
pParser->yyidxMax = 0;
|
|
|
|
#endif
|
2008-04-08 09:54:19 +00:00
|
|
|
#if YYSTACKDEPTH<=0
|
2013-03-26 05:36:27 +00:00
|
|
|
pParser->yystack = NULL;
|
|
|
|
pParser->yystksz = 0;
|
2008-04-08 09:54:19 +00:00
|
|
|
yyGrowStack(pParser);
|
|
|
|
#endif
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
|
|
|
return pParser;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The following function deletes the value associated with a
|
|
|
|
** symbol. The symbol can be either a terminal or nonterminal.
|
|
|
|
** "yymajor" is the symbol code, and "yypminor" is a pointer to
|
|
|
|
** the value.
|
|
|
|
*/
|
2013-03-26 05:36:27 +00:00
|
|
|
static void yy_destructor(yyParser *yypParser, YYCODETYPE yymajor, YYMINORTYPE *yypminor){
|
|
|
|
ParseARG_FETCH;
|
2001-02-01 20:21:25 +00:00
|
|
|
switch( yymajor ){
|
|
|
|
/* Here is inserted the actions which take place when a
|
|
|
|
** terminal or non-terminal is destroyed. This can happen
|
|
|
|
** when the symbol is popped from the stack during a
|
2002-08-28 21:04:11 +00:00
|
|
|
** reduce or during error processing or when a parser is
|
2001-02-01 20:21:25 +00:00
|
|
|
** being destroyed before it is finished parsing.
|
|
|
|
**
|
|
|
|
** Note: during a reduce, the only symbols destroyed are those
|
|
|
|
** which appear on the RHS of the rule, but which are not used
|
|
|
|
** inside the C code.
|
|
|
|
*/
|
|
|
|
%%
|
|
|
|
default: break; /* If no destructor action specified: do nothing */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Pop the parser's stack once.
|
|
|
|
**
|
|
|
|
** If there is a destructor routine associated with the token which
|
|
|
|
** is popped from the stack, then call it.
|
|
|
|
**
|
|
|
|
** Return the major token number for the symbol popped.
|
|
|
|
*/
|
|
|
|
static int yy_pop_parser_stack(yyParser *pParser){
|
|
|
|
YYCODETYPE yymajor;
|
2013-03-26 05:36:27 +00:00
|
|
|
yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
|
2001-02-01 20:21:25 +00:00
|
|
|
|
2006-03-21 18:56:34 +00:00
|
|
|
if( pParser->yyidx<0 ) return 0;
|
2001-02-01 20:21:25 +00:00
|
|
|
#ifndef NDEBUG
|
2013-03-26 05:36:27 +00:00
|
|
|
if( yyTraceFILE && pParser->yyidx>=0 ){
|
2001-02-01 20:21:25 +00:00
|
|
|
fprintf(yyTraceFILE,"%sPopping %s\n",
|
|
|
|
yyTracePrompt,
|
2013-03-04 22:04:58 +00:00
|
|
|
yyTokenName[yytos->major]);
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
|
|
|
#endif
|
2006-08-01 21:29:05 +00:00
|
|
|
yymajor = yytos->major;
|
2013-03-26 05:36:27 +00:00
|
|
|
yy_destructor(pParser, yymajor, &yytos->minor);
|
2006-03-21 18:56:34 +00:00
|
|
|
pParser->yyidx--;
|
2001-02-01 20:21:25 +00:00
|
|
|
return yymajor;
|
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/*
|
2001-02-01 20:21:25 +00:00
|
|
|
** Deallocate and destroy a parser. Destructors are all called for
|
|
|
|
** all stack elements before shutting the parser down.
|
|
|
|
**
|
|
|
|
** Inputs:
|
|
|
|
** <ul>
|
|
|
|
** <li> A pointer to the parser. This should be a pointer
|
|
|
|
** obtained from ParseAlloc.
|
|
|
|
** <li> A pointer to a function used to reclaim memory obtained
|
|
|
|
** from malloc.
|
|
|
|
** </ul>
|
|
|
|
*/
|
|
|
|
void ParseFree(
|
2013-03-04 22:04:58 +00:00
|
|
|
void *p, /* The parser to be deleted */
|
|
|
|
void (*freeProc)(void*) /* Function used to reclaim memory */
|
2001-02-01 20:21:25 +00:00
|
|
|
){
|
|
|
|
yyParser *pParser = (yyParser*)p;
|
|
|
|
if( pParser==0 ) return;
|
2006-03-21 18:56:34 +00:00
|
|
|
while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
|
2008-04-08 09:54:19 +00:00
|
|
|
#if YYSTACKDEPTH<=0
|
|
|
|
free(pParser->yystack);
|
|
|
|
#endif
|
2013-03-04 22:04:58 +00:00
|
|
|
(*freeProc)((void*)pParser);
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
|
|
|
|
2008-07-29 12:40:03 +00:00
|
|
|
/*
|
|
|
|
** Return the peak depth of the stack for a parser.
|
|
|
|
*/
|
|
|
|
#ifdef YYTRACKMAXSTACKDEPTH
|
|
|
|
int ParseStackPeak(void *p){
|
|
|
|
yyParser *pParser = (yyParser*)p;
|
|
|
|
return pParser->yyidxMax;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
/*
|
2006-03-21 18:56:34 +00:00
|
|
|
** Find the appropriate action for a parser given the terminal
|
|
|
|
** look-ahead token iLookAhead.
|
2001-02-01 20:21:25 +00:00
|
|
|
**
|
|
|
|
** If the look-ahead token is YYNOCODE, then check to see if the action is
|
|
|
|
** independent of the look-ahead. If it is, return the action, otherwise
|
|
|
|
** return YY_NO_ACTION.
|
|
|
|
*/
|
2006-03-21 18:56:34 +00:00
|
|
|
static int yy_find_shift_action(
|
2001-02-01 20:21:25 +00:00
|
|
|
yyParser *pParser, /* The parser */
|
2006-11-19 16:24:18 +00:00
|
|
|
YYCODETYPE iLookAhead /* The look-ahead token */
|
2001-02-01 20:21:25 +00:00
|
|
|
){
|
2006-03-21 18:56:34 +00:00
|
|
|
int i;
|
|
|
|
int stateno = pParser->yystack[pParser->yyidx].stateno;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2013-03-26 05:36:27 +00:00
|
|
|
if( stateno>YY_SHIFT_MAX
|
|
|
|
|| (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
|
2006-08-01 21:29:05 +00:00
|
|
|
return yy_default[stateno];
|
2006-03-21 18:56:34 +00:00
|
|
|
}
|
2008-04-08 09:54:19 +00:00
|
|
|
assert( iLookAhead!=YYNOCODE );
|
2006-03-21 18:56:34 +00:00
|
|
|
i += iLookAhead;
|
|
|
|
if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
|
2006-11-19 16:24:18 +00:00
|
|
|
if( iLookAhead>0 ){
|
2006-03-21 18:56:34 +00:00
|
|
|
#ifdef YYFALLBACK
|
2013-03-04 22:04:58 +00:00
|
|
|
YYCODETYPE iFallback; /* Fallback token */
|
2006-11-19 16:24:18 +00:00
|
|
|
if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
|
|
|
|
&& (iFallback = yyFallback[iLookAhead])!=0 ){
|
2006-03-21 18:56:34 +00:00
|
|
|
#ifndef NDEBUG
|
2006-11-19 16:24:18 +00:00
|
|
|
if( yyTraceFILE ){
|
|
|
|
fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
|
|
|
|
yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return yy_find_shift_action(pParser, iFallback);
|
2006-03-21 18:56:34 +00:00
|
|
|
}
|
|
|
|
#endif
|
2006-11-19 16:24:18 +00:00
|
|
|
#ifdef YYWILDCARD
|
2013-03-04 22:04:58 +00:00
|
|
|
{
|
|
|
|
int j = i - iLookAhead + YYWILDCARD;
|
|
|
|
if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){
|
2006-11-19 16:24:18 +00:00
|
|
|
#ifndef NDEBUG
|
2013-03-04 22:04:58 +00:00
|
|
|
if( yyTraceFILE ){
|
|
|
|
fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
|
|
|
|
yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
|
|
|
|
}
|
2006-11-19 16:24:18 +00:00
|
|
|
#endif /* NDEBUG */
|
2013-03-04 22:04:58 +00:00
|
|
|
return yy_action[j];
|
|
|
|
}
|
2006-11-19 16:24:18 +00:00
|
|
|
}
|
|
|
|
#endif /* YYWILDCARD */
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
2006-08-01 21:29:05 +00:00
|
|
|
return yy_default[stateno];
|
2006-03-21 18:56:34 +00:00
|
|
|
}else{
|
|
|
|
return yy_action[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Find the appropriate action for a parser given the non-terminal
|
|
|
|
** look-ahead token iLookAhead.
|
|
|
|
**
|
|
|
|
** If the look-ahead token is YYNOCODE, then check to see if the action is
|
|
|
|
** independent of the look-ahead. If it is, return the action, otherwise
|
|
|
|
** return YY_NO_ACTION.
|
|
|
|
*/
|
|
|
|
static int yy_find_reduce_action(
|
|
|
|
int stateno, /* Current state number */
|
2006-11-19 16:24:18 +00:00
|
|
|
YYCODETYPE iLookAhead /* The look-ahead token */
|
2006-03-21 18:56:34 +00:00
|
|
|
){
|
|
|
|
int i;
|
2008-07-29 12:40:03 +00:00
|
|
|
#ifdef YYERRORSYMBOL
|
|
|
|
if( stateno>YY_REDUCE_MAX ){
|
|
|
|
return yy_default[stateno];
|
|
|
|
}
|
|
|
|
#else
|
2008-04-08 09:54:19 +00:00
|
|
|
assert( stateno<=YY_REDUCE_MAX );
|
2008-07-29 12:40:03 +00:00
|
|
|
#endif
|
2008-04-08 09:54:19 +00:00
|
|
|
i = yy_reduce_ofst[stateno];
|
|
|
|
assert( i!=YY_REDUCE_USE_DFLT );
|
|
|
|
assert( iLookAhead!=YYNOCODE );
|
2006-03-21 18:56:34 +00:00
|
|
|
i += iLookAhead;
|
2008-07-29 12:40:03 +00:00
|
|
|
#ifdef YYERRORSYMBOL
|
|
|
|
if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
|
|
|
|
return yy_default[stateno];
|
|
|
|
}
|
|
|
|
#else
|
2008-04-08 09:54:19 +00:00
|
|
|
assert( i>=0 && i<YY_SZ_ACTTAB );
|
|
|
|
assert( yy_lookahead[i]==iLookAhead );
|
2008-07-29 12:40:03 +00:00
|
|
|
#endif
|
2008-04-08 09:54:19 +00:00
|
|
|
return yy_action[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** The following routine is called if the stack overflows.
|
|
|
|
*/
|
2008-06-04 00:35:30 +00:00
|
|
|
static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor _U_){
|
2008-04-08 09:54:19 +00:00
|
|
|
ParseARG_FETCH;
|
|
|
|
yypParser->yyidx--;
|
|
|
|
#ifndef NDEBUG
|
|
|
|
if( yyTraceFILE ){
|
|
|
|
fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
|
|
|
|
/* Here code is inserted which will execute if the parser
|
|
|
|
** stack every overflows */
|
|
|
|
%%
|
|
|
|
ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform a shift action.
|
|
|
|
*/
|
|
|
|
static void yy_shift(
|
|
|
|
yyParser *yypParser, /* The parser to be shifted */
|
|
|
|
int yyNewState, /* The new state to shift in */
|
|
|
|
int yyMajor, /* The major token to shift in */
|
2008-07-29 12:40:03 +00:00
|
|
|
YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */
|
2001-02-01 20:21:25 +00:00
|
|
|
){
|
2006-08-01 21:29:05 +00:00
|
|
|
yyStackEntry *yytos;
|
2006-03-21 18:56:34 +00:00
|
|
|
yypParser->yyidx++;
|
2008-07-29 12:40:03 +00:00
|
|
|
#ifdef YYTRACKMAXSTACKDEPTH
|
|
|
|
if( yypParser->yyidx>yypParser->yyidxMax ){
|
|
|
|
yypParser->yyidxMax = yypParser->yyidx;
|
|
|
|
}
|
|
|
|
#endif
|
2008-04-08 09:54:19 +00:00
|
|
|
#if YYSTACKDEPTH>0
|
2006-03-21 18:56:34 +00:00
|
|
|
if( yypParser->yyidx>=YYSTACKDEPTH ){
|
2008-04-08 09:54:19 +00:00
|
|
|
yyStackOverflow(yypParser, yypMinor);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if( yypParser->yyidx>=yypParser->yystksz ){
|
|
|
|
yyGrowStack(yypParser);
|
|
|
|
if( yypParser->yyidx>=yypParser->yystksz ){
|
|
|
|
yyStackOverflow(yypParser, yypMinor);
|
|
|
|
return;
|
|
|
|
}
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
2008-04-08 09:54:19 +00:00
|
|
|
#endif
|
2006-08-01 21:29:05 +00:00
|
|
|
yytos = &yypParser->yystack[yypParser->yyidx];
|
2013-03-26 05:36:27 +00:00
|
|
|
yytos->stateno = (YYACTIONTYPE)yyNewState;
|
|
|
|
yytos->major = (YYCODETYPE)yyMajor;
|
2006-08-01 21:29:05 +00:00
|
|
|
yytos->minor = *yypMinor;
|
2001-02-01 20:21:25 +00:00
|
|
|
#ifndef NDEBUG
|
2006-03-21 18:56:34 +00:00
|
|
|
if( yyTraceFILE && yypParser->yyidx>0 ){
|
2001-02-01 20:21:25 +00:00
|
|
|
int i;
|
|
|
|
fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState);
|
|
|
|
fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
|
2006-03-21 18:56:34 +00:00
|
|
|
for(i=1; i<=yypParser->yyidx; i++)
|
|
|
|
fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]);
|
2001-02-01 20:21:25 +00:00
|
|
|
fprintf(yyTraceFILE,"\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The following table contains information about every rule that
|
|
|
|
** is used during the reduce.
|
|
|
|
*/
|
2006-03-21 18:56:34 +00:00
|
|
|
static const struct {
|
2001-02-01 20:21:25 +00:00
|
|
|
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
|
|
|
|
unsigned char nrhs; /* Number of right-hand side symbols in the rule */
|
|
|
|
} yyRuleInfo[] = {
|
|
|
|
%%
|
|
|
|
};
|
|
|
|
|
2008-04-08 09:54:19 +00:00
|
|
|
static void yy_accept(yyParser *yypParser); /* Forward declaration */
|
2001-02-01 20:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform a reduce action and the shift that must immediately
|
|
|
|
** follow the reduce.
|
|
|
|
*/
|
|
|
|
static void yy_reduce(
|
|
|
|
yyParser *yypParser, /* The parser */
|
|
|
|
int yyruleno /* Number of the rule by which to reduce */
|
|
|
|
){
|
|
|
|
int yygoto; /* The next state */
|
|
|
|
int yyact; /* The next action */
|
|
|
|
YYMINORTYPE yygotominor; /* The LHS of the rule reduced */
|
2006-03-21 18:56:34 +00:00
|
|
|
yyStackEntry *yymsp; /* The top of the parser's stack */
|
2001-02-01 20:21:25 +00:00
|
|
|
int yysize; /* Amount to pop the stack */
|
2006-03-21 18:56:34 +00:00
|
|
|
ParseARG_FETCH;
|
2006-08-01 21:29:05 +00:00
|
|
|
yymsp = &yypParser->yystack[yypParser->yyidx];
|
2006-03-21 18:56:34 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
if( yyTraceFILE && yyruleno>=0
|
2006-11-19 16:24:18 +00:00
|
|
|
&& yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
|
2006-03-21 18:56:34 +00:00
|
|
|
fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
|
|
|
|
yyRuleName[yyruleno]);
|
|
|
|
}
|
|
|
|
#endif /* NDEBUG */
|
|
|
|
|
|
|
|
/* Silence complaints from purify about yygotominor being uninitialized
|
|
|
|
** in some cases when it is copied into the stack after the following
|
|
|
|
** switch. yygotominor is uninitialized when a rule reduces that does
|
|
|
|
** not set the value of its left-hand side nonterminal. Leaving the
|
|
|
|
** value of the nonterminal uninitialized is utterly harmless as long
|
|
|
|
** as the value is never used. So really the only thing this code
|
|
|
|
** accomplishes is to quieten purify.
|
2008-04-08 09:54:19 +00:00
|
|
|
**
|
|
|
|
** 2007-01-16: The wireshark project (www.wireshark.org) reports that
|
|
|
|
** without this code, their parser segfaults. I'm not sure what there
|
|
|
|
** parser is doing to make this happen. This is the second bug report
|
|
|
|
** from wireshark this week. Clearly they are stressing Lemon in ways
|
|
|
|
** that it has not been previously stressed... (SQLite ticket #2172)
|
2006-03-21 18:56:34 +00:00
|
|
|
*/
|
2008-07-29 12:40:03 +00:00
|
|
|
/*memset(&yygotominor, 0, sizeof(yygotominor));*/
|
|
|
|
yygotominor = yyzerominor;
|
2001-02-01 20:21:25 +00:00
|
|
|
switch( yyruleno ){
|
|
|
|
/* Beginning here are the reduction cases. A typical example
|
|
|
|
** follows:
|
|
|
|
** case 0:
|
|
|
|
** #line <lineno> <grammarfile>
|
|
|
|
** { ... } // User supplied code
|
|
|
|
** #line <lineno> <thisfile>
|
|
|
|
** break;
|
|
|
|
*/
|
|
|
|
%%
|
|
|
|
};
|
|
|
|
yygoto = yyRuleInfo[yyruleno].lhs;
|
|
|
|
yysize = yyRuleInfo[yyruleno].nrhs;
|
2006-03-21 18:56:34 +00:00
|
|
|
yypParser->yyidx -= yysize;
|
2007-03-23 03:45:18 +00:00
|
|
|
yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
|
2001-02-01 20:21:25 +00:00
|
|
|
if( yyact < YYNSTATE ){
|
2006-03-21 18:56:34 +00:00
|
|
|
#ifdef NDEBUG
|
|
|
|
/* If we are not debugging and the reduce action popped at least
|
|
|
|
** one element off the stack, then we can push the new element back
|
|
|
|
** onto the stack here, and skip the stack overflow test in yy_shift().
|
|
|
|
** That gives a significant speed improvement. */
|
|
|
|
if( yysize ){
|
|
|
|
yypParser->yyidx++;
|
|
|
|
yymsp -= yysize-1;
|
2013-03-26 05:36:27 +00:00
|
|
|
yymsp->stateno = (YYACTIONTYPE)yyact;
|
|
|
|
yymsp->major = (YYCODETYPE)yygoto;
|
2006-03-21 18:56:34 +00:00
|
|
|
yymsp->minor = yygotominor;
|
|
|
|
}else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
yy_shift(yypParser,yyact,yygoto,&yygotominor);
|
|
|
|
}
|
2008-04-08 09:54:19 +00:00
|
|
|
}else{
|
|
|
|
assert( yyact == YYNSTATE + YYNRULE + 1 );
|
2006-03-21 18:56:34 +00:00
|
|
|
yy_accept(yypParser);
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** The following code executes when the parse fails
|
|
|
|
*/
|
|
|
|
static void yy_parse_failed(
|
|
|
|
yyParser *yypParser /* The parser */
|
|
|
|
){
|
2006-03-21 18:56:34 +00:00
|
|
|
ParseARG_FETCH;
|
2001-02-01 20:21:25 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
if( yyTraceFILE ){
|
|
|
|
fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
|
|
|
|
}
|
|
|
|
#endif
|
2006-03-21 18:56:34 +00:00
|
|
|
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
|
2001-02-01 20:21:25 +00:00
|
|
|
/* Here code is inserted which will be executed whenever the
|
|
|
|
** parser fails */
|
|
|
|
%%
|
2006-03-21 18:56:34 +00:00
|
|
|
ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** The following code executes when a syntax error first occurs.
|
|
|
|
*/
|
|
|
|
static void yy_syntax_error(
|
2002-05-04 10:19:20 +00:00
|
|
|
yyParser *yypParser _U_, /* The parser */
|
|
|
|
int yymajor _U_, /* The major type of the error token */
|
2001-02-01 20:21:25 +00:00
|
|
|
YYMINORTYPE yyminor /* The minor type of the error token */
|
|
|
|
){
|
2006-03-21 18:56:34 +00:00
|
|
|
ParseARG_FETCH;
|
2001-02-01 20:21:25 +00:00
|
|
|
#define TOKEN (yyminor.yy0)
|
|
|
|
%%
|
2006-03-21 18:56:34 +00:00
|
|
|
ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** The following is executed when the parser accepts
|
|
|
|
*/
|
|
|
|
static void yy_accept(
|
|
|
|
yyParser *yypParser /* The parser */
|
|
|
|
){
|
2006-03-21 18:56:34 +00:00
|
|
|
ParseARG_FETCH;
|
2001-02-01 20:21:25 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
if( yyTraceFILE ){
|
|
|
|
fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
|
|
|
|
}
|
|
|
|
#endif
|
2006-03-21 18:56:34 +00:00
|
|
|
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
|
2001-02-01 20:21:25 +00:00
|
|
|
/* Here code is inserted which will be executed whenever the
|
|
|
|
** parser accepts */
|
|
|
|
%%
|
2006-03-21 18:56:34 +00:00
|
|
|
ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The main parser program.
|
|
|
|
** The first argument is a pointer to a structure obtained from
|
|
|
|
** "ParseAlloc" which describes the current state of the parser.
|
|
|
|
** The second argument is the major token number. The third is
|
|
|
|
** the minor token. The fourth optional argument is whatever the
|
|
|
|
** user wants (and specified in the grammar) and is available for
|
|
|
|
** use by the action routines.
|
|
|
|
**
|
|
|
|
** Inputs:
|
|
|
|
** <ul>
|
|
|
|
** <li> A pointer to the parser (an opaque structure.)
|
|
|
|
** <li> The major token number.
|
|
|
|
** <li> The minor token number.
|
|
|
|
** <li> An option argument of a grammar-specified type.
|
|
|
|
** </ul>
|
|
|
|
**
|
|
|
|
** Outputs:
|
|
|
|
** None.
|
|
|
|
*/
|
|
|
|
void Parse(
|
|
|
|
void *yyp, /* The parser */
|
|
|
|
int yymajor, /* The major token code number */
|
|
|
|
ParseTOKENTYPE yyminor /* The value for the token */
|
2006-03-21 18:56:34 +00:00
|
|
|
ParseARG_PDECL /* Optional %extra_argument parameter */
|
2001-02-01 20:21:25 +00:00
|
|
|
){
|
|
|
|
YYMINORTYPE yyminorunion;
|
|
|
|
int yyact; /* The parser action. */
|
|
|
|
int yyendofinput; /* True if we are at the end of input */
|
2008-04-08 09:54:19 +00:00
|
|
|
#ifdef YYERRORSYMBOL
|
2013-03-04 22:04:58 +00:00
|
|
|
int yyerrorhit = 0; /* True if yymajor has invoked an error */
|
2008-04-08 09:54:19 +00:00
|
|
|
#endif
|
2001-02-01 20:21:25 +00:00
|
|
|
yyParser *yypParser; /* The parser */
|
|
|
|
|
|
|
|
/* (re)initialize the parser, if necessary */
|
|
|
|
yypParser = (yyParser*)yyp;
|
2006-03-21 18:56:34 +00:00
|
|
|
if( yypParser->yyidx<0 ){
|
2008-04-08 09:54:19 +00:00
|
|
|
#if YYSTACKDEPTH<=0
|
|
|
|
if( yypParser->yystksz <=0 ){
|
2008-07-29 12:40:03 +00:00
|
|
|
/*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
|
|
|
|
yyminorunion = yyzerominor;
|
2013-03-04 22:04:58 +00:00
|
|
|
yyStackOverflow(yypParser, &yyminorunion);
|
2008-04-08 09:54:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2006-03-21 18:56:34 +00:00
|
|
|
yypParser->yyidx = 0;
|
|
|
|
yypParser->yyerrcnt = -1;
|
2006-08-01 21:29:05 +00:00
|
|
|
yypParser->yystack[0].stateno = 0;
|
|
|
|
yypParser->yystack[0].major = 0;
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
|
|
|
yyminorunion.yy0 = yyminor;
|
|
|
|
yyendofinput = (yymajor==0);
|
2006-03-21 18:56:34 +00:00
|
|
|
ParseARG_STORE;
|
2001-02-01 20:21:25 +00:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
if( yyTraceFILE ){
|
|
|
|
fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
do{
|
2007-03-23 03:45:18 +00:00
|
|
|
yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
|
2001-02-01 20:21:25 +00:00
|
|
|
if( yyact<YYNSTATE ){
|
2013-03-04 22:04:58 +00:00
|
|
|
assert( !yyendofinput ); /* Impossible to shift the $ token */
|
2001-02-01 20:21:25 +00:00
|
|
|
yy_shift(yypParser,yyact,yymajor,&yyminorunion);
|
2006-03-21 18:56:34 +00:00
|
|
|
yypParser->yyerrcnt--;
|
2013-03-04 22:04:58 +00:00
|
|
|
yymajor = YYNOCODE;
|
2001-02-01 20:21:25 +00:00
|
|
|
}else if( yyact < YYNSTATE + YYNRULE ){
|
2006-03-21 18:56:34 +00:00
|
|
|
yy_reduce(yypParser,yyact-YYNSTATE);
|
2008-04-08 09:54:19 +00:00
|
|
|
}else{
|
|
|
|
#ifdef YYERRORSYMBOL
|
2006-08-01 21:29:05 +00:00
|
|
|
int yymx;
|
2008-04-08 09:54:19 +00:00
|
|
|
#endif
|
2009-06-08 11:54:38 +00:00
|
|
|
assert( yyact == YY_ERROR_ACTION );
|
2001-02-01 20:21:25 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
if( yyTraceFILE ){
|
|
|
|
fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef YYERRORSYMBOL
|
|
|
|
/* A syntax error has occurred.
|
|
|
|
** The response to an error depends upon whether or not the
|
2002-08-28 21:04:11 +00:00
|
|
|
** grammar defines an error token "ERROR".
|
2001-02-01 20:21:25 +00:00
|
|
|
**
|
|
|
|
** This is what we do if the grammar does define ERROR:
|
|
|
|
**
|
|
|
|
** * Call the %syntax_error function.
|
|
|
|
**
|
|
|
|
** * Begin popping the stack until we enter a state where
|
|
|
|
** it is legal to shift the error symbol, then shift
|
|
|
|
** the error symbol.
|
|
|
|
**
|
|
|
|
** * Set the error count to three.
|
|
|
|
**
|
|
|
|
** * Begin accepting and shifting new tokens. No new error
|
|
|
|
** processing will occur until three tokens have been
|
|
|
|
** shifted successfully.
|
|
|
|
**
|
|
|
|
*/
|
2006-03-21 18:56:34 +00:00
|
|
|
if( yypParser->yyerrcnt<0 ){
|
|
|
|
yy_syntax_error(yypParser,yymajor,yyminorunion);
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
2006-08-01 21:29:05 +00:00
|
|
|
yymx = yypParser->yystack[yypParser->yyidx].major;
|
|
|
|
if( yymx==YYERRORSYMBOL || yyerrorhit ){
|
2001-02-01 20:21:25 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
if( yyTraceFILE ){
|
|
|
|
fprintf(yyTraceFILE,"%sDiscard input token %s\n",
|
|
|
|
yyTracePrompt,yyTokenName[yymajor]);
|
|
|
|
}
|
|
|
|
#endif
|
2013-03-26 05:36:27 +00:00
|
|
|
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
|
2001-02-01 20:21:25 +00:00
|
|
|
yymajor = YYNOCODE;
|
|
|
|
}else{
|
|
|
|
while(
|
2006-03-21 18:56:34 +00:00
|
|
|
yypParser->yyidx >= 0 &&
|
2006-08-01 21:29:05 +00:00
|
|
|
yymx != YYERRORSYMBOL &&
|
2008-04-08 09:54:19 +00:00
|
|
|
(yyact = yy_find_reduce_action(
|
|
|
|
yypParser->yystack[yypParser->yyidx].stateno,
|
|
|
|
YYERRORSYMBOL)) >= YYNSTATE
|
2013-03-04 22:04:58 +00:00
|
|
|
){
|
2001-02-01 20:21:25 +00:00
|
|
|
yy_pop_parser_stack(yypParser);
|
|
|
|
}
|
2006-03-21 18:56:34 +00:00
|
|
|
if( yypParser->yyidx < 0 || yymajor==0 ){
|
2013-03-26 05:36:27 +00:00
|
|
|
yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
|
2006-03-21 18:56:34 +00:00
|
|
|
yy_parse_failed(yypParser);
|
2001-02-01 20:21:25 +00:00
|
|
|
yymajor = YYNOCODE;
|
2006-08-01 21:29:05 +00:00
|
|
|
}else if( yymx!=YYERRORSYMBOL ){
|
2001-02-01 20:21:25 +00:00
|
|
|
YYMINORTYPE u2;
|
|
|
|
u2.YYERRSYMDT = 0;
|
|
|
|
yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
|
|
|
|
}
|
|
|
|
}
|
2006-03-21 18:56:34 +00:00
|
|
|
yypParser->yyerrcnt = 3;
|
2001-02-01 20:21:25 +00:00
|
|
|
yyerrorhit = 1;
|
|
|
|
#else /* YYERRORSYMBOL is not defined */
|
|
|
|
/* This is what we do if the grammar does not define ERROR:
|
|
|
|
**
|
|
|
|
** * Report an error message, and throw away the input token.
|
|
|
|
**
|
|
|
|
** * If the input token is $, then fail the parse.
|
|
|
|
**
|
|
|
|
** As before, subsequent error messages are suppressed until
|
|
|
|
** three input tokens have been successfully shifted.
|
|
|
|
*/
|
2006-03-21 18:56:34 +00:00
|
|
|
if( yypParser->yyerrcnt<=0 ){
|
|
|
|
yy_syntax_error(yypParser,yymajor,yyminorunion);
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
2006-03-21 18:56:34 +00:00
|
|
|
yypParser->yyerrcnt = 3;
|
2013-03-26 05:36:27 +00:00
|
|
|
yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
|
2001-02-01 20:21:25 +00:00
|
|
|
if( yyendofinput ){
|
2006-03-21 18:56:34 +00:00
|
|
|
yy_parse_failed(yypParser);
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
|
|
|
yymajor = YYNOCODE;
|
|
|
|
#endif
|
|
|
|
}
|
2006-03-21 18:56:34 +00:00
|
|
|
}while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
|
2001-02-01 20:21:25 +00:00
|
|
|
return;
|
|
|
|
}
|