NCDValueParser_parse.c 36 KB

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