PageRenderTime 60ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/tools/m2sh/src/parser.c

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