NCDValueParser_parse.c 36 KB

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