NCDConfigParser_parse.c 37 KB

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