NCDValueParser_parse.c 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146
  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. {
  365. #line 43 "NCDValueParser_parse.y"
  366. (void)parser_out; free_value((yypminor->yy1));
  367. #line 384 "NCDValueParser_parse.c"
  368. }
  369. break;
  370. case 10: /* list */
  371. case 11: /* map_contents */
  372. case 12: /* map */
  373. case 13: /* value */
  374. {
  375. #line 44 "NCDValueParser_parse.y"
  376. free_value((yypminor->yy1));
  377. #line 394 "NCDValueParser_parse.c"
  378. }
  379. break;
  380. default: break; /* If no destructor action specified: do nothing */
  381. }
  382. }
  383. /*
  384. ** Pop the parser's stack once.
  385. **
  386. ** If there is a destructor routine associated with the token which
  387. ** is popped from the stack, then call it.
  388. **
  389. ** Return the major token number for the symbol popped.
  390. */
  391. static int yy_pop_parser_stack(yyParser *pParser){
  392. YYCODETYPE yymajor;
  393. yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
  394. if( pParser->yyidx<0 ) return 0;
  395. #ifndef NDEBUG
  396. if( yyTraceFILE && pParser->yyidx>=0 ){
  397. fprintf(yyTraceFILE,"%sPopping %s\n",
  398. yyTracePrompt,
  399. yyTokenName[yytos->major]);
  400. }
  401. #endif
  402. yymajor = yytos->major;
  403. yy_destructor(pParser, yymajor, &yytos->minor);
  404. pParser->yyidx--;
  405. return yymajor;
  406. }
  407. /*
  408. ** Deallocate and destroy a parser. Destructors are all called for
  409. ** all stack elements before shutting the parser down.
  410. **
  411. ** Inputs:
  412. ** <ul>
  413. ** <li> A pointer to the parser. This should be a pointer
  414. ** obtained from ParseAlloc.
  415. ** <li> A pointer to a function used to reclaim memory obtained
  416. ** from malloc.
  417. ** </ul>
  418. */
  419. void ParseFree(
  420. void *p, /* The parser to be deleted */
  421. void (*freeProc)(void*) /* Function used to reclaim memory */
  422. ){
  423. yyParser *pParser = (yyParser*)p;
  424. if( pParser==0 ) return;
  425. while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
  426. #if YYSTACKDEPTH<=0
  427. free(pParser->yystack);
  428. #endif
  429. (*freeProc)((void*)pParser);
  430. }
  431. /*
  432. ** Return the peak depth of the stack for a parser.
  433. */
  434. #ifdef YYTRACKMAXSTACKDEPTH
  435. int ParseStackPeak(void *p){
  436. yyParser *pParser = (yyParser*)p;
  437. return pParser->yyidxMax;
  438. }
  439. #endif
  440. /*
  441. ** Find the appropriate action for a parser given the terminal
  442. ** look-ahead token iLookAhead.
  443. **
  444. ** If the look-ahead token is YYNOCODE, then check to see if the action is
  445. ** independent of the look-ahead. If it is, return the action, otherwise
  446. ** return YY_NO_ACTION.
  447. */
  448. static int yy_find_shift_action(
  449. yyParser *pParser, /* The parser */
  450. YYCODETYPE iLookAhead /* The look-ahead token */
  451. ){
  452. int i;
  453. int stateno = pParser->yystack[pParser->yyidx].stateno;
  454. if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
  455. return yy_default[stateno];
  456. }
  457. assert( iLookAhead!=YYNOCODE );
  458. i += iLookAhead;
  459. if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
  460. if( iLookAhead>0 ){
  461. #ifdef YYFALLBACK
  462. YYCODETYPE iFallback; /* Fallback token */
  463. if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
  464. && (iFallback = yyFallback[iLookAhead])!=0 ){
  465. #ifndef NDEBUG
  466. if( yyTraceFILE ){
  467. fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
  468. yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
  469. }
  470. #endif
  471. return yy_find_shift_action(pParser, iFallback);
  472. }
  473. #endif
  474. #ifdef YYWILDCARD
  475. {
  476. int j = i - iLookAhead + YYWILDCARD;
  477. if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){
  478. #ifndef NDEBUG
  479. if( yyTraceFILE ){
  480. fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
  481. yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
  482. }
  483. #endif /* NDEBUG */
  484. return yy_action[j];
  485. }
  486. }
  487. #endif /* YYWILDCARD */
  488. }
  489. return yy_default[stateno];
  490. }else{
  491. return yy_action[i];
  492. }
  493. }
  494. /*
  495. ** Find the appropriate action for a parser given the non-terminal
  496. ** look-ahead token iLookAhead.
  497. **
  498. ** If the look-ahead token is YYNOCODE, then check to see if the action is
  499. ** independent of the look-ahead. If it is, return the action, otherwise
  500. ** return YY_NO_ACTION.
  501. */
  502. static int yy_find_reduce_action(
  503. int stateno, /* Current state number */
  504. YYCODETYPE iLookAhead /* The look-ahead token */
  505. ){
  506. int i;
  507. #ifdef YYERRORSYMBOL
  508. if( stateno>YY_REDUCE_MAX ){
  509. return yy_default[stateno];
  510. }
  511. #else
  512. assert( stateno<=YY_REDUCE_MAX );
  513. #endif
  514. i = yy_reduce_ofst[stateno];
  515. assert( i!=YY_REDUCE_USE_DFLT );
  516. assert( iLookAhead!=YYNOCODE );
  517. i += iLookAhead;
  518. #ifdef YYERRORSYMBOL
  519. if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
  520. return yy_default[stateno];
  521. }
  522. #else
  523. assert( i>=0 && i<YY_SZ_ACTTAB );
  524. assert( yy_lookahead[i]==iLookAhead );
  525. #endif
  526. return yy_action[i];
  527. }
  528. /*
  529. ** The following routine is called if the stack overflows.
  530. */
  531. static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
  532. ParseARG_FETCH;
  533. yypParser->yyidx--;
  534. #ifndef NDEBUG
  535. if( yyTraceFILE ){
  536. fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
  537. }
  538. #endif
  539. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  540. /* Here code is inserted which will execute if the parser
  541. ** stack every overflows */
  542. #line 56 "NCDValueParser_parse.y"
  543. if (yypMinor) {
  544. free_token(yypMinor->yy0);
  545. }
  546. #line 572 "NCDValueParser_parse.c"
  547. ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
  548. }
  549. /*
  550. ** Perform a shift action.
  551. */
  552. static void yy_shift(
  553. yyParser *yypParser, /* The parser to be shifted */
  554. int yyNewState, /* The new state to shift in */
  555. int yyMajor, /* The major token to shift in */
  556. YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */
  557. ){
  558. yyStackEntry *yytos;
  559. yypParser->yyidx++;
  560. #ifdef YYTRACKMAXSTACKDEPTH
  561. if( yypParser->yyidx>yypParser->yyidxMax ){
  562. yypParser->yyidxMax = yypParser->yyidx;
  563. }
  564. #endif
  565. #if YYSTACKDEPTH>0
  566. if( yypParser->yyidx>=YYSTACKDEPTH ){
  567. yyStackOverflow(yypParser, yypMinor);
  568. return;
  569. }
  570. #else
  571. if( yypParser->yyidx>=yypParser->yystksz ){
  572. yyGrowStack(yypParser);
  573. if( yypParser->yyidx>=yypParser->yystksz ){
  574. yyStackOverflow(yypParser, yypMinor);
  575. return;
  576. }
  577. }
  578. #endif
  579. yytos = &yypParser->yystack[yypParser->yyidx];
  580. yytos->stateno = (YYACTIONTYPE)yyNewState;
  581. yytos->major = (YYCODETYPE)yyMajor;
  582. yytos->minor = *yypMinor;
  583. #ifndef NDEBUG
  584. if( yyTraceFILE && yypParser->yyidx>0 ){
  585. int i;
  586. fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState);
  587. fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
  588. for(i=1; i<=yypParser->yyidx; i++)
  589. fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]);
  590. fprintf(yyTraceFILE,"\n");
  591. }
  592. #endif
  593. }
  594. /* The following table contains information about every rule that
  595. ** is used during the reduce.
  596. */
  597. static const struct {
  598. YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
  599. unsigned char nrhs; /* Number of right-hand side symbols in the rule */
  600. } yyRuleInfo[] = {
  601. { 14, 1 },
  602. { 9, 1 },
  603. { 9, 3 },
  604. { 10, 2 },
  605. { 10, 3 },
  606. { 11, 3 },
  607. { 11, 5 },
  608. { 12, 2 },
  609. { 12, 3 },
  610. { 13, 1 },
  611. { 13, 1 },
  612. { 13, 1 },
  613. };
  614. static void yy_accept(yyParser*); /* Forward Declaration */
  615. /*
  616. ** Perform a reduce action and the shift that must immediately
  617. ** follow the reduce.
  618. */
  619. static void yy_reduce(
  620. yyParser *yypParser, /* The parser */
  621. int yyruleno /* Number of the rule by which to reduce */
  622. ){
  623. int yygoto; /* The next state */
  624. int yyact; /* The next action */
  625. YYMINORTYPE yygotominor; /* The LHS of the rule reduced */
  626. yyStackEntry *yymsp; /* The top of the parser's stack */
  627. int yysize; /* Amount to pop the stack */
  628. ParseARG_FETCH;
  629. yymsp = &yypParser->yystack[yypParser->yyidx];
  630. #ifndef NDEBUG
  631. if( yyTraceFILE && yyruleno>=0
  632. && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
  633. fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
  634. yyRuleName[yyruleno]);
  635. }
  636. #endif /* NDEBUG */
  637. /* Silence complaints from purify about yygotominor being uninitialized
  638. ** in some cases when it is copied into the stack after the following
  639. ** switch. yygotominor is uninitialized when a rule reduces that does
  640. ** not set the value of its left-hand side nonterminal. Leaving the
  641. ** value of the nonterminal uninitialized is utterly harmless as long
  642. ** as the value is never used. So really the only thing this code
  643. ** accomplishes is to quieten purify.
  644. **
  645. ** 2007-01-16: The wireshark project (www.wireshark.org) reports that
  646. ** without this code, their parser segfaults. I'm not sure what there
  647. ** parser is doing to make this happen. This is the second bug report
  648. ** from wireshark this week. Clearly they are stressing Lemon in ways
  649. ** that it has not been previously stressed... (SQLite ticket #2172)
  650. */
  651. /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  652. yygotominor = yyzerominor;
  653. switch( yyruleno ){
  654. /* Beginning here are the reduction cases. A typical example
  655. ** follows:
  656. ** case 0:
  657. ** #line <lineno> <grammarfile>
  658. ** { ... } // User supplied code
  659. ** #line <lineno> <thisfile>
  660. ** break;
  661. */
  662. case 0: /* input ::= value */
  663. #line 62 "NCDValueParser_parse.y"
  664. {
  665. if (!yymsp[0].minor.yy1.have || parser_out->have_value) {
  666. free_value(yymsp[0].minor.yy1);
  667. } else {
  668. parser_out->have_value = 1;
  669. parser_out->value = yymsp[0].minor.yy1.v;
  670. }
  671. }
  672. #line 705 "NCDValueParser_parse.c"
  673. break;
  674. case 1: /* list_contents ::= value */
  675. #line 71 "NCDValueParser_parse.y"
  676. {
  677. if (!yymsp[0].minor.yy1.have) {
  678. goto failL0;
  679. }
  680. NCDValue_InitList(&yygotominor.yy1.v);
  681. if (!NCDValue_ListPrepend(&yygotominor.yy1.v, yymsp[0].minor.yy1.v)) {
  682. goto failL1;
  683. }
  684. yymsp[0].minor.yy1.have = 0;
  685. yygotominor.yy1.have = 1;
  686. goto doneL;
  687. failL1:
  688. NCDValue_Free(&yygotominor.yy1.v);
  689. failL0:
  690. yygotominor.yy1.have = 0;
  691. parser_out->out_of_memory = 1;
  692. doneL:
  693. free_value(yymsp[0].minor.yy1);
  694. }
  695. #line 732 "NCDValueParser_parse.c"
  696. break;
  697. case 2: /* list_contents ::= value COMMA list_contents */
  698. #line 95 "NCDValueParser_parse.y"
  699. {
  700. if (!yymsp[-2].minor.yy1.have || !yymsp[0].minor.yy1.have) {
  701. goto failM0;
  702. }
  703. if (!NCDValue_ListPrepend(&yymsp[0].minor.yy1.v, yymsp[-2].minor.yy1.v)) {
  704. goto failM0;
  705. }
  706. yymsp[-2].minor.yy1.have = 0;
  707. yygotominor.yy1.have = 1;
  708. yygotominor.yy1.v = yymsp[0].minor.yy1.v;
  709. yymsp[0].minor.yy1.have = 0;
  710. goto doneM;
  711. failM0:
  712. yygotominor.yy1.have = 0;
  713. parser_out->out_of_memory = 1;
  714. doneM:
  715. free_value(yymsp[-2].minor.yy1);
  716. free_value(yymsp[0].minor.yy1);
  717. yy_destructor(yypParser,1,&yymsp[-1].minor);
  718. }
  719. #line 759 "NCDValueParser_parse.c"
  720. break;
  721. case 3: /* list ::= CURLY_OPEN CURLY_CLOSE */
  722. #line 118 "NCDValueParser_parse.y"
  723. {
  724. yygotominor.yy1.have = 1;
  725. NCDValue_InitList(&yygotominor.yy1.v);
  726. yy_destructor(yypParser,2,&yymsp[-1].minor);
  727. yy_destructor(yypParser,3,&yymsp[0].minor);
  728. }
  729. #line 769 "NCDValueParser_parse.c"
  730. break;
  731. case 4: /* list ::= CURLY_OPEN list_contents CURLY_CLOSE */
  732. #line 123 "NCDValueParser_parse.y"
  733. {
  734. yygotominor.yy1 = yymsp[-1].minor.yy1;
  735. yy_destructor(yypParser,2,&yymsp[-2].minor);
  736. yy_destructor(yypParser,3,&yymsp[0].minor);
  737. }
  738. #line 778 "NCDValueParser_parse.c"
  739. break;
  740. case 5: /* map_contents ::= value COLON value */
  741. #line 127 "NCDValueParser_parse.y"
  742. {
  743. if (!yymsp[-2].minor.yy1.have || !yymsp[0].minor.yy1.have) {
  744. goto failS0;
  745. }
  746. NCDValue_InitMap(&yygotominor.yy1.v);
  747. if (!NCDValue_MapInsert(&yygotominor.yy1.v, yymsp[-2].minor.yy1.v, yymsp[0].minor.yy1.v)) {
  748. goto failS1;
  749. }
  750. yymsp[-2].minor.yy1.have = 0;
  751. yymsp[0].minor.yy1.have = 0;
  752. yygotominor.yy1.have = 1;
  753. goto doneS;
  754. failS1:
  755. NCDValue_Free(&yygotominor.yy1.v);
  756. failS0:
  757. yygotominor.yy1.have = 0;
  758. parser_out->out_of_memory = 1;
  759. doneS:
  760. free_value(yymsp[-2].minor.yy1);
  761. free_value(yymsp[0].minor.yy1);
  762. yy_destructor(yypParser,4,&yymsp[-1].minor);
  763. }
  764. #line 808 "NCDValueParser_parse.c"
  765. break;
  766. case 6: /* map_contents ::= value COLON value COMMA map_contents */
  767. #line 153 "NCDValueParser_parse.y"
  768. {
  769. if (!yymsp[-4].minor.yy1.have || !yymsp[-2].minor.yy1.have || !yymsp[0].minor.yy1.have) {
  770. goto failT0;
  771. }
  772. if (NCDValue_MapFindKey(&yymsp[0].minor.yy1.v, &yymsp[-4].minor.yy1.v)) {
  773. BLog(BLOG_ERROR, "duplicate key in map");
  774. yygotominor.yy1.have = 0;
  775. parser_out->syntax_error = 1;
  776. goto doneT;
  777. }
  778. if (!NCDValue_MapInsert(&yymsp[0].minor.yy1.v, yymsp[-4].minor.yy1.v, yymsp[-2].minor.yy1.v)) {
  779. goto failT0;
  780. }
  781. yymsp[-4].minor.yy1.have = 0;
  782. yymsp[-2].minor.yy1.have = 0;
  783. yygotominor.yy1.have = 1;
  784. yygotominor.yy1.v = yymsp[0].minor.yy1.v;
  785. yymsp[0].minor.yy1.have = 0;
  786. goto doneT;
  787. failT0:
  788. yygotominor.yy1.have = 0;
  789. parser_out->out_of_memory = 1;
  790. doneT:
  791. free_value(yymsp[-4].minor.yy1);
  792. free_value(yymsp[-2].minor.yy1);
  793. free_value(yymsp[0].minor.yy1);
  794. yy_destructor(yypParser,4,&yymsp[-3].minor);
  795. yy_destructor(yypParser,1,&yymsp[-1].minor);
  796. }
  797. #line 845 "NCDValueParser_parse.c"
  798. break;
  799. case 7: /* map ::= BRACKET_OPEN BRACKET_CLOSE */
  800. #line 185 "NCDValueParser_parse.y"
  801. {
  802. yygotominor.yy1.have = 1;
  803. NCDValue_InitMap(&yygotominor.yy1.v);
  804. yy_destructor(yypParser,5,&yymsp[-1].minor);
  805. yy_destructor(yypParser,6,&yymsp[0].minor);
  806. }
  807. #line 855 "NCDValueParser_parse.c"
  808. break;
  809. case 8: /* map ::= BRACKET_OPEN map_contents BRACKET_CLOSE */
  810. #line 190 "NCDValueParser_parse.y"
  811. {
  812. yygotominor.yy1 = yymsp[-1].minor.yy1;
  813. yy_destructor(yypParser,5,&yymsp[-2].minor);
  814. yy_destructor(yypParser,6,&yymsp[0].minor);
  815. }
  816. #line 864 "NCDValueParser_parse.c"
  817. break;
  818. case 9: /* value ::= STRING */
  819. #line 194 "NCDValueParser_parse.y"
  820. {
  821. ASSERT(yymsp[0].minor.yy0.str)
  822. if (!NCDValue_InitStringBin(&yygotominor.yy1.v, (uint8_t *)yymsp[0].minor.yy0.str, yymsp[0].minor.yy0.len)) {
  823. goto failU0;
  824. }
  825. yygotominor.yy1.have = 1;
  826. goto doneU;
  827. failU0:
  828. yygotominor.yy1.have = 0;
  829. parser_out->out_of_memory = 1;
  830. doneU:
  831. free_token(yymsp[0].minor.yy0);
  832. }
  833. #line 884 "NCDValueParser_parse.c"
  834. break;
  835. case 10: /* value ::= list */
  836. case 11: /* value ::= map */ yytestcase(yyruleno==11);
  837. #line 211 "NCDValueParser_parse.y"
  838. {
  839. yygotominor.yy1 = yymsp[0].minor.yy1;
  840. }
  841. #line 892 "NCDValueParser_parse.c"
  842. break;
  843. default:
  844. break;
  845. };
  846. yygoto = yyRuleInfo[yyruleno].lhs;
  847. yysize = yyRuleInfo[yyruleno].nrhs;
  848. yypParser->yyidx -= yysize;
  849. yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  850. if( yyact < YYNSTATE ){
  851. #ifdef NDEBUG
  852. /* If we are not debugging and the reduce action popped at least
  853. ** one element off the stack, then we can push the new element back
  854. ** onto the stack here, and skip the stack overflow test in yy_shift().
  855. ** That gives a significant speed improvement. */
  856. if( yysize ){
  857. yypParser->yyidx++;
  858. yymsp -= yysize-1;
  859. yymsp->stateno = (YYACTIONTYPE)yyact;
  860. yymsp->major = (YYCODETYPE)yygoto;
  861. yymsp->minor = yygotominor;
  862. }else
  863. #endif
  864. {
  865. yy_shift(yypParser,yyact,yygoto,&yygotominor);
  866. }
  867. }else{
  868. assert( yyact == YYNSTATE + YYNRULE + 1 );
  869. yy_accept(yypParser);
  870. }
  871. }
  872. /*
  873. ** The following code executes when the parse fails
  874. */
  875. #ifndef YYNOERRORRECOVERY
  876. static void yy_parse_failed(
  877. yyParser *yypParser /* The parser */
  878. ){
  879. ParseARG_FETCH;
  880. #ifndef NDEBUG
  881. if( yyTraceFILE ){
  882. fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
  883. }
  884. #endif
  885. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  886. /* Here code is inserted which will be executed whenever the
  887. ** parser fails */
  888. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  889. }
  890. #endif /* YYNOERRORRECOVERY */
  891. /*
  892. ** The following code executes when a syntax error first occurs.
  893. */
  894. static void yy_syntax_error(
  895. yyParser *yypParser, /* The parser */
  896. int yymajor, /* The major type of the error token */
  897. YYMINORTYPE yyminor /* The minor type of the error token */
  898. ){
  899. ParseARG_FETCH;
  900. #define TOKEN (yyminor.yy0)
  901. #line 51 "NCDValueParser_parse.y"
  902. parser_out->syntax_error = 1;
  903. #line 957 "NCDValueParser_parse.c"
  904. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  905. }
  906. /*
  907. ** The following is executed when the parser accepts
  908. */
  909. static void yy_accept(
  910. yyParser *yypParser /* The parser */
  911. ){
  912. ParseARG_FETCH;
  913. #ifndef NDEBUG
  914. if( yyTraceFILE ){
  915. fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
  916. }
  917. #endif
  918. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  919. /* Here code is inserted which will be executed whenever the
  920. ** parser accepts */
  921. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  922. }
  923. /* The main parser program.
  924. ** The first argument is a pointer to a structure obtained from
  925. ** "ParseAlloc" which describes the current state of the parser.
  926. ** The second argument is the major token number. The third is
  927. ** the minor token. The fourth optional argument is whatever the
  928. ** user wants (and specified in the grammar) and is available for
  929. ** use by the action routines.
  930. **
  931. ** Inputs:
  932. ** <ul>
  933. ** <li> A pointer to the parser (an opaque structure.)
  934. ** <li> The major token number.
  935. ** <li> The minor token number.
  936. ** <li> An option argument of a grammar-specified type.
  937. ** </ul>
  938. **
  939. ** Outputs:
  940. ** None.
  941. */
  942. void Parse(
  943. void *yyp, /* The parser */
  944. int yymajor, /* The major token code number */
  945. ParseTOKENTYPE yyminor /* The value for the token */
  946. ParseARG_PDECL /* Optional %extra_argument parameter */
  947. ){
  948. YYMINORTYPE yyminorunion;
  949. int yyact; /* The parser action. */
  950. int yyendofinput; /* True if we are at the end of input */
  951. #ifdef YYERRORSYMBOL
  952. int yyerrorhit = 0; /* True if yymajor has invoked an error */
  953. #endif
  954. yyParser *yypParser; /* The parser */
  955. /* (re)initialize the parser, if necessary */
  956. yypParser = (yyParser*)yyp;
  957. if( yypParser->yyidx<0 ){
  958. #if YYSTACKDEPTH<=0
  959. if( yypParser->yystksz <=0 ){
  960. /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
  961. yyminorunion = yyzerominor;
  962. yyStackOverflow(yypParser, &yyminorunion);
  963. return;
  964. }
  965. #endif
  966. yypParser->yyidx = 0;
  967. yypParser->yyerrcnt = -1;
  968. yypParser->yystack[0].stateno = 0;
  969. yypParser->yystack[0].major = 0;
  970. }
  971. yyminorunion.yy0 = yyminor;
  972. yyendofinput = (yymajor==0);
  973. ParseARG_STORE;
  974. #ifndef NDEBUG
  975. if( yyTraceFILE ){
  976. fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
  977. }
  978. #endif
  979. do{
  980. yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
  981. if( yyact<YYNSTATE ){
  982. assert( !yyendofinput ); /* Impossible to shift the $ token */
  983. yy_shift(yypParser,yyact,yymajor,&yyminorunion);
  984. yypParser->yyerrcnt--;
  985. yymajor = YYNOCODE;
  986. }else if( yyact < YYNSTATE + YYNRULE ){
  987. yy_reduce(yypParser,yyact-YYNSTATE);
  988. }else{
  989. assert( yyact == YY_ERROR_ACTION );
  990. #ifdef YYERRORSYMBOL
  991. int yymx;
  992. #endif
  993. #ifndef NDEBUG
  994. if( yyTraceFILE ){
  995. fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
  996. }
  997. #endif
  998. #ifdef YYERRORSYMBOL
  999. /* A syntax error has occurred.
  1000. ** The response to an error depends upon whether or not the
  1001. ** grammar defines an error token "ERROR".
  1002. **
  1003. ** This is what we do if the grammar does define ERROR:
  1004. **
  1005. ** * Call the %syntax_error function.
  1006. **
  1007. ** * Begin popping the stack until we enter a state where
  1008. ** it is legal to shift the error symbol, then shift
  1009. ** the error symbol.
  1010. **
  1011. ** * Set the error count to three.
  1012. **
  1013. ** * Begin accepting and shifting new tokens. No new error
  1014. ** processing will occur until three tokens have been
  1015. ** shifted successfully.
  1016. **
  1017. */
  1018. if( yypParser->yyerrcnt<0 ){
  1019. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1020. }
  1021. yymx = yypParser->yystack[yypParser->yyidx].major;
  1022. if( yymx==YYERRORSYMBOL || yyerrorhit ){
  1023. #ifndef NDEBUG
  1024. if( yyTraceFILE ){
  1025. fprintf(yyTraceFILE,"%sDiscard input token %s\n",
  1026. yyTracePrompt,yyTokenName[yymajor]);
  1027. }
  1028. #endif
  1029. yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
  1030. yymajor = YYNOCODE;
  1031. }else{
  1032. while(
  1033. yypParser->yyidx >= 0 &&
  1034. yymx != YYERRORSYMBOL &&
  1035. (yyact = yy_find_reduce_action(
  1036. yypParser->yystack[yypParser->yyidx].stateno,
  1037. YYERRORSYMBOL)) >= YYNSTATE
  1038. ){
  1039. yy_pop_parser_stack(yypParser);
  1040. }
  1041. if( yypParser->yyidx < 0 || yymajor==0 ){
  1042. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1043. yy_parse_failed(yypParser);
  1044. yymajor = YYNOCODE;
  1045. }else if( yymx!=YYERRORSYMBOL ){
  1046. YYMINORTYPE u2;
  1047. u2.YYERRSYMDT = 0;
  1048. yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
  1049. }
  1050. }
  1051. yypParser->yyerrcnt = 3;
  1052. yyerrorhit = 1;
  1053. #elif defined(YYNOERRORRECOVERY)
  1054. /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
  1055. ** do any kind of error recovery. Instead, simply invoke the syntax
  1056. ** error routine and continue going as if nothing had happened.
  1057. **
  1058. ** Applications can set this macro (for example inside %include) if
  1059. ** they intend to abandon the parse upon the first syntax error seen.
  1060. */
  1061. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1062. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1063. yymajor = YYNOCODE;
  1064. #else /* YYERRORSYMBOL is not defined */
  1065. /* This is what we do if the grammar does not define ERROR:
  1066. **
  1067. ** * Report an error message, and throw away the input token.
  1068. **
  1069. ** * If the input token is $, then fail the parse.
  1070. **
  1071. ** As before, subsequent error messages are suppressed until
  1072. ** three input tokens have been successfully shifted.
  1073. */
  1074. if( yypParser->yyerrcnt<=0 ){
  1075. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1076. }
  1077. yypParser->yyerrcnt = 3;
  1078. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1079. if( yyendofinput ){
  1080. yy_parse_failed(yypParser);
  1081. }
  1082. yymajor = YYNOCODE;
  1083. #endif
  1084. }
  1085. }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
  1086. return;
  1087. }