NCDConfigParser_parse.c 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167
  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 "NCDConfigParser_parse.y"
  8. #include <string.h>
  9. #include <stddef.h>
  10. #include <misc/debug.h>
  11. #include <misc/concat_strings.h>
  12. #include <ncd/NCDAst.h>
  13. struct parser_out {
  14. int out_of_memory;
  15. int syntax_error;
  16. int have_ast;
  17. NCDProgram ast;
  18. };
  19. struct token {
  20. char *str;
  21. size_t len;
  22. };
  23. struct program {
  24. int have;
  25. NCDProgram v;
  26. };
  27. struct block {
  28. int have;
  29. NCDBlock v;
  30. };
  31. struct statement {
  32. int have;
  33. NCDStatement v;
  34. };
  35. struct ifblock {
  36. int have;
  37. NCDIfBlock v;
  38. };
  39. struct value {
  40. int have;
  41. NCDValue v;
  42. };
  43. static void free_token (struct token o) { free(o.str); }
  44. static void free_program (struct program o) { if (o.have) NCDProgram_Free(&o.v); }
  45. static void free_block (struct block o) { if (o.have) NCDBlock_Free(&o.v); }
  46. static void free_statement (struct statement o) { if (o.have) NCDStatement_Free(&o.v); }
  47. static void free_ifblock (struct ifblock o) { if (o.have) NCDIfBlock_Free(&o.v); }
  48. static void free_value (struct value o) { if (o.have) NCDValue_Free(&o.v); }
  49. #line 62 "NCDConfigParser_parse.c"
  50. /* Next is all token values, in a form suitable for use by makeheaders.
  51. ** This section will be null unless lemon is run with the -m switch.
  52. */
  53. /*
  54. ** These constants (all generated automatically by the parser generator)
  55. ** specify the various kinds of tokens (terminals) that the parser
  56. ** understands.
  57. **
  58. ** Each symbol here is a terminal symbol in the grammar.
  59. */
  60. /* Make sure the INTERFACE macro is defined.
  61. */
  62. #ifndef INTERFACE
  63. # define INTERFACE 1
  64. #endif
  65. /* The next thing included is series of defines which control
  66. ** various aspects of the generated parser.
  67. ** YYCODETYPE is the data type used for storing terminal
  68. ** and nonterminal numbers. "unsigned char" is
  69. ** used if there are fewer than 250 terminals
  70. ** and nonterminals. "int" is used otherwise.
  71. ** YYNOCODE is a number of type YYCODETYPE which corresponds
  72. ** to no legal terminal or nonterminal number. This
  73. ** number is used to fill in empty slots of the hash
  74. ** table.
  75. ** YYFALLBACK If defined, this indicates that one or more tokens
  76. ** have fall-back values which should be used if the
  77. ** original value of the token will not parse.
  78. ** YYACTIONTYPE is the data type used for storing terminal
  79. ** and nonterminal numbers. "unsigned char" is
  80. ** used if there are fewer than 250 rules and
  81. ** states combined. "int" is used otherwise.
  82. ** ParseTOKENTYPE is the data type used for minor tokens given
  83. ** directly to the parser from the tokenizer.
  84. ** YYMINORTYPE is the data type used for all minor tokens.
  85. ** This is typically a union of many types, one of
  86. ** which is ParseTOKENTYPE. The entry in the union
  87. ** for base tokens is called "yy0".
  88. ** YYSTACKDEPTH is the maximum depth of the parser's stack. If
  89. ** zero the stack is dynamically sized using realloc()
  90. ** ParseARG_SDECL A static variable declaration for the %extra_argument
  91. ** ParseARG_PDECL A parameter declaration for the %extra_argument
  92. ** ParseARG_STORE Code to store %extra_argument into yypParser
  93. ** ParseARG_FETCH Code to extract %extra_argument from yypParser
  94. ** YYNSTATE the combined number of states.
  95. ** YYNRULE the number of rules in the grammar
  96. ** YYERRORSYMBOL is the code number of the error symbol. If not
  97. ** defined, then do no error processing.
  98. */
  99. #define YYCODETYPE unsigned char
  100. #define YYNOCODE 49
  101. #define YYACTIONTYPE unsigned char
  102. #define ParseTOKENTYPE struct token
  103. typedef union {
  104. int yyinit;
  105. ParseTOKENTYPE yy0;
  106. struct program yy6;
  107. struct value yy19;
  108. int yy28;
  109. struct ifblock yy44;
  110. struct statement yy47;
  111. char * yy49;
  112. struct block yy69;
  113. } YYMINORTYPE;
  114. #ifndef YYSTACKDEPTH
  115. #define YYSTACKDEPTH 0
  116. #endif
  117. #define ParseARG_SDECL struct parser_out *parser_out ;
  118. #define ParseARG_PDECL , struct parser_out *parser_out
  119. #define ParseARG_FETCH struct parser_out *parser_out = yypParser->parser_out
  120. #define ParseARG_STORE yypParser->parser_out = parser_out
  121. #define YYNSTATE 130
  122. #define YYNRULE 49
  123. #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
  124. #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
  125. #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
  126. /* The yyzerominor constant is used to initialize instances of
  127. ** YYMINORTYPE objects to zero. */
  128. static const YYMINORTYPE yyzerominor = { 0 };
  129. /* Define the yytestcase() macro to be a no-op if is not already defined
  130. ** otherwise.
  131. **
  132. ** Applications can choose to define yytestcase() in the %include section
  133. ** to a macro that can assist in verifying code coverage. For production
  134. ** code the yytestcase() macro should be turned off. But it is useful
  135. ** for testing.
  136. */
  137. #ifndef yytestcase
  138. # define yytestcase(X)
  139. #endif
  140. /* Next are the tables used to determine what action to take based on the
  141. ** current state and lookahead token. These tables are used to implement
  142. ** functions that take a state number and lookahead value and return an
  143. ** action integer.
  144. **
  145. ** Suppose the action integer is N. Then the action is determined as
  146. ** follows
  147. **
  148. ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead
  149. ** token onto the stack and goto state N.
  150. **
  151. ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE.
  152. **
  153. ** N == YYNSTATE+YYNRULE A syntax error has occurred.
  154. **
  155. ** N == YYNSTATE+YYNRULE+1 The parser accepts its input.
  156. **
  157. ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused
  158. ** slots in the yy_action[] table.
  159. **
  160. ** The action table is constructed as a single large table named yy_action[].
  161. ** Given state S and lookahead X, the action is computed as
  162. **
  163. ** yy_action[ yy_shift_ofst[S] + X ]
  164. **
  165. ** If the index value yy_shift_ofst[S]+X is out of range or if the value
  166. ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
  167. ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
  168. ** and that yy_default[S] should be used instead.
  169. **
  170. ** The formula above is for computing the action when the lookahead is
  171. ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
  172. ** a reduce action) then the yy_reduce_ofst[] array is used in place of
  173. ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
  174. ** YY_SHIFT_USE_DFLT.
  175. **
  176. ** The following are the tables generated in this section:
  177. **
  178. ** yy_action[] A single table containing all actions.
  179. ** yy_lookahead[] A table containing the lookahead for each entry in
  180. ** yy_action. Used to detect hash collisions.
  181. ** yy_shift_ofst[] For each state, the offset into yy_action for
  182. ** shifting terminals.
  183. ** yy_reduce_ofst[] For each state, the offset into yy_action for
  184. ** shifting non-terminals after a reduce.
  185. ** yy_default[] Default action for each state.
  186. */
  187. static const YYACTIONTYPE yy_action[] = {
  188. /* 0 */ 107, 51, 59, 4, 104, 9, 107, 2, 59, 4,
  189. /* 10 */ 94, 9, 107, 58, 59, 4, 54, 9, 95, 180,
  190. /* 20 */ 5, 6, 29, 30, 100, 54, 5, 117, 29, 30,
  191. /* 30 */ 34, 128, 5, 54, 29, 30, 111, 57, 102, 112,
  192. /* 40 */ 59, 113, 115, 43, 111, 62, 102, 112, 96, 113,
  193. /* 50 */ 115, 43, 2, 111, 65, 102, 112, 91, 113, 115,
  194. /* 60 */ 43, 101, 111, 54, 60, 112, 7, 113, 115, 43,
  195. /* 70 */ 111, 61, 2, 112, 63, 113, 115, 44, 111, 8,
  196. /* 80 */ 103, 112, 108, 113, 115, 43, 111, 2, 116, 112,
  197. /* 90 */ 106, 113, 115, 44, 111, 2, 68, 112, 2, 113,
  198. /* 100 */ 115, 45, 1, 111, 73, 32, 112, 110, 113, 115,
  199. /* 110 */ 46, 111, 64, 52, 112, 53, 113, 115, 47, 111,
  200. /* 120 */ 109, 66, 112, 71, 113, 115, 48, 111, 70, 59,
  201. /* 130 */ 112, 35, 113, 115, 50, 39, 67, 72, 97, 98,
  202. /* 140 */ 76, 20, 77, 79, 80, 56, 42, 20, 82, 20,
  203. /* 150 */ 129, 69, 42, 90, 42, 130, 20, 84, 20, 89,
  204. /* 160 */ 75, 42, 78, 42, 20, 23, 24, 20, 81, 42,
  205. /* 170 */ 20, 83, 42, 20, 124, 42, 20, 88, 42, 74,
  206. /* 180 */ 93, 42, 2, 92, 55, 85, 13, 27, 25, 28,
  207. /* 190 */ 105, 118, 99, 31, 114, 3, 119, 33, 10, 14,
  208. /* 200 */ 49, 26, 120, 15, 11, 16, 86, 36, 121, 17,
  209. /* 210 */ 181, 37, 122, 18, 87, 38, 123, 19, 181, 21,
  210. /* 220 */ 181, 40, 125, 127, 41, 126, 181, 12, 22,
  211. };
  212. static const YYCODETYPE yy_lookahead[] = {
  213. /* 0 */ 2, 29, 4, 5, 6, 7, 2, 7, 4, 5,
  214. /* 10 */ 29, 7, 2, 43, 4, 5, 44, 7, 29, 47,
  215. /* 20 */ 22, 21, 24, 25, 4, 44, 22, 23, 24, 25,
  216. /* 30 */ 31, 32, 22, 44, 24, 25, 35, 36, 37, 38,
  217. /* 40 */ 4, 40, 41, 42, 35, 36, 37, 38, 29, 40,
  218. /* 50 */ 41, 42, 7, 35, 36, 37, 38, 15, 40, 41,
  219. /* 60 */ 42, 35, 35, 44, 37, 38, 21, 40, 41, 42,
  220. /* 70 */ 35, 4, 7, 38, 39, 40, 41, 42, 35, 14,
  221. /* 80 */ 37, 38, 35, 40, 41, 42, 35, 7, 8, 38,
  222. /* 90 */ 39, 40, 41, 42, 35, 7, 8, 38, 7, 40,
  223. /* 100 */ 41, 42, 7, 35, 13, 10, 38, 45, 40, 41,
  224. /* 110 */ 42, 35, 35, 1, 38, 3, 40, 41, 42, 35,
  225. /* 120 */ 45, 43, 38, 16, 40, 41, 42, 35, 43, 4,
  226. /* 130 */ 38, 33, 40, 41, 42, 46, 11, 12, 26, 27,
  227. /* 140 */ 43, 30, 17, 43, 19, 34, 35, 30, 18, 30,
  228. /* 150 */ 32, 34, 35, 34, 35, 0, 30, 43, 30, 43,
  229. /* 160 */ 34, 35, 34, 35, 30, 2, 2, 30, 34, 35,
  230. /* 170 */ 30, 34, 35, 30, 34, 35, 30, 34, 35, 8,
  231. /* 180 */ 34, 35, 7, 8, 4, 14, 5, 8, 6, 20,
  232. /* 190 */ 6, 23, 9, 20, 8, 7, 9, 8, 7, 5,
  233. /* 200 */ 4, 6, 9, 5, 7, 5, 4, 6, 9, 5,
  234. /* 210 */ 48, 6, 9, 5, 8, 6, 6, 5, 48, 5,
  235. /* 220 */ 48, 6, 9, 6, 6, 9, 48, 7, 5,
  236. };
  237. #define YY_SHIFT_USE_DFLT (-3)
  238. #define YY_SHIFT_MAX 93
  239. static const short yy_shift_ofst[] = {
  240. /* 0 */ 112, 10, 10, 10, -2, 4, 10, 10, 10, 10,
  241. /* 10 */ 10, 10, 10, 125, 125, 125, 125, 125, 125, 125,
  242. /* 20 */ 125, 125, 125, 112, 112, 112, 42, 20, 36, 36,
  243. /* 30 */ 67, 67, 36, 20, 107, 20, 20, 20, 130, 20,
  244. /* 40 */ 20, 42, 95, 0, 65, 45, 80, 88, 91, 171,
  245. /* 50 */ 175, 155, 163, 164, 180, 181, 182, 179, 183, 169,
  246. /* 60 */ 184, 173, 186, 168, 188, 189, 187, 191, 194, 195,
  247. /* 70 */ 193, 198, 197, 196, 200, 201, 199, 204, 205, 203,
  248. /* 80 */ 208, 209, 212, 210, 213, 202, 206, 214, 215, 216,
  249. /* 90 */ 217, 220, 223, 218,
  250. };
  251. #define YY_REDUCE_USE_DFLT (-31)
  252. #define YY_REDUCE_MAX 41
  253. static const short yy_reduce_ofst[] = {
  254. /* 0 */ -28, 1, 9, 18, 27, 35, 43, 51, 59, 68,
  255. /* 10 */ 76, 84, 92, 111, 117, 119, 126, 128, 134, 137,
  256. /* 20 */ 140, 143, 146, -19, -11, 19, -1, -30, 26, 47,
  257. /* 30 */ 62, 75, 77, 78, 98, 85, 97, 100, 89, 114,
  258. /* 40 */ 116, 118,
  259. };
  260. static const YYACTIONTYPE yy_default[] = {
  261. /* 0 */ 131, 156, 156, 156, 179, 179, 179, 179, 179, 179,
  262. /* 10 */ 179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
  263. /* 20 */ 150, 179, 179, 131, 131, 131, 140, 175, 179, 179,
  264. /* 30 */ 179, 179, 179, 175, 144, 175, 175, 175, 147, 175,
  265. /* 40 */ 175, 142, 179, 158, 179, 162, 179, 179, 179, 179,
  266. /* 50 */ 179, 179, 179, 179, 179, 179, 179, 179, 179, 152,
  267. /* 60 */ 179, 154, 179, 179, 179, 179, 179, 179, 179, 179,
  268. /* 70 */ 179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
  269. /* 80 */ 179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
  270. /* 90 */ 179, 179, 179, 179, 132, 133, 134, 177, 178, 135,
  271. /* 100 */ 176, 153, 157, 159, 160, 161, 163, 167, 168, 155,
  272. /* 110 */ 169, 170, 171, 172, 166, 174, 173, 164, 165, 136,
  273. /* 120 */ 137, 138, 146, 148, 151, 149, 139, 145, 141, 143,
  274. };
  275. #define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
  276. /* The next table maps tokens into fallback tokens. If a construct
  277. ** like the following:
  278. **
  279. ** %fallback ID X Y Z.
  280. **
  281. ** appears in the grammar, then ID becomes a fallback token for X, Y,
  282. ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
  283. ** but it does not parse, the type of the token is changed to ID and
  284. ** the parse is retried before an error is thrown.
  285. */
  286. #ifdef YYFALLBACK
  287. static const YYCODETYPE yyFallback[] = {
  288. };
  289. #endif /* YYFALLBACK */
  290. /* The following structure represents a single element of the
  291. ** parser's stack. Information stored includes:
  292. **
  293. ** + The state number for the parser at this level of the stack.
  294. **
  295. ** + The value of the token stored at this level of the stack.
  296. ** (In other words, the "major" token.)
  297. **
  298. ** + The semantic value stored at this level of the stack. This is
  299. ** the information used by the action routines in the grammar.
  300. ** It is sometimes called the "minor" token.
  301. */
  302. struct yyStackEntry {
  303. YYACTIONTYPE stateno; /* The state-number */
  304. YYCODETYPE major; /* The major token value. This is the code
  305. ** number for the token at this stack level */
  306. YYMINORTYPE minor; /* The user-supplied minor token value. This
  307. ** is the value of the token */
  308. };
  309. typedef struct yyStackEntry yyStackEntry;
  310. /* The state of the parser is completely contained in an instance of
  311. ** the following structure */
  312. struct yyParser {
  313. int yyidx; /* Index of top element in stack */
  314. #ifdef YYTRACKMAXSTACKDEPTH
  315. int yyidxMax; /* Maximum value of yyidx */
  316. #endif
  317. int yyerrcnt; /* Shifts left before out of the error */
  318. ParseARG_SDECL /* A place to hold %extra_argument */
  319. #if YYSTACKDEPTH<=0
  320. int yystksz; /* Current side of the stack */
  321. yyStackEntry *yystack; /* The parser's stack */
  322. #else
  323. yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
  324. #endif
  325. };
  326. typedef struct yyParser yyParser;
  327. #ifndef NDEBUG
  328. #include <stdio.h>
  329. static FILE *yyTraceFILE = 0;
  330. static char *yyTracePrompt = 0;
  331. #endif /* NDEBUG */
  332. #ifndef NDEBUG
  333. /*
  334. ** Turn parser tracing on by giving a stream to which to write the trace
  335. ** and a prompt to preface each trace message. Tracing is turned off
  336. ** by making either argument NULL
  337. **
  338. ** Inputs:
  339. ** <ul>
  340. ** <li> A FILE* to which trace output should be written.
  341. ** If NULL, then tracing is turned off.
  342. ** <li> A prefix string written at the beginning of every
  343. ** line of trace output. If NULL, then tracing is
  344. ** turned off.
  345. ** </ul>
  346. **
  347. ** Outputs:
  348. ** None.
  349. */
  350. void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
  351. yyTraceFILE = TraceFILE;
  352. yyTracePrompt = zTracePrompt;
  353. if( yyTraceFILE==0 ) yyTracePrompt = 0;
  354. else if( yyTracePrompt==0 ) yyTraceFILE = 0;
  355. }
  356. #endif /* NDEBUG */
  357. #ifndef NDEBUG
  358. /* For tracing shifts, the names of all terminals and nonterminals
  359. ** are required. The following table supplies these names */
  360. static const char *const yyTokenName[] = {
  361. "$", "INCLUDE", "STRING", "INCLUDE_GUARD",
  362. "NAME", "CURLY_OPEN", "CURLY_CLOSE", "ROUND_OPEN",
  363. "ROUND_CLOSE", "SEMICOLON", "ARROW", "IF",
  364. "FOREACH", "AS", "COLON", "ELIF",
  365. "ELSE", "BLOCK", "TOKEN_INTERRUPT", "TOKEN_DO",
  366. "DOT", "COMMA", "BRACKET_OPEN", "BRACKET_CLOSE",
  367. "AT_SIGN", "CARET", "PROCESS", "TEMPLATE",
  368. "error", "processes", "statement", "elif_maybe",
  369. "elif", "else_maybe", "statements", "dotted_name",
  370. "list_contents_maybe", "list_contents", "list", "map_contents",
  371. "map", "invoc", "value", "name_maybe",
  372. "process_or_template", "name_list", "interrupt_maybe", "input",
  373. };
  374. #endif /* NDEBUG */
  375. #ifndef NDEBUG
  376. /* For tracing reduce actions, the names of all rules are required.
  377. */
  378. static const char *const yyRuleName[] = {
  379. /* 0 */ "input ::= processes",
  380. /* 1 */ "processes ::=",
  381. /* 2 */ "processes ::= INCLUDE STRING processes",
  382. /* 3 */ "processes ::= INCLUDE_GUARD STRING processes",
  383. /* 4 */ "processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes",
  384. /* 5 */ "statement ::= dotted_name ROUND_OPEN list_contents_maybe ROUND_CLOSE name_maybe SEMICOLON",
  385. /* 6 */ "statement ::= dotted_name ARROW dotted_name ROUND_OPEN list_contents_maybe ROUND_CLOSE name_maybe SEMICOLON",
  386. /* 7 */ "statement ::= IF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif_maybe else_maybe name_maybe SEMICOLON",
  387. /* 8 */ "statement ::= FOREACH ROUND_OPEN value AS NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON",
  388. /* 9 */ "statement ::= FOREACH ROUND_OPEN value AS NAME COLON NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON",
  389. /* 10 */ "elif_maybe ::=",
  390. /* 11 */ "elif_maybe ::= elif",
  391. /* 12 */ "elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE",
  392. /* 13 */ "elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif",
  393. /* 14 */ "else_maybe ::=",
  394. /* 15 */ "else_maybe ::= ELSE CURLY_OPEN statements CURLY_CLOSE",
  395. /* 16 */ "statement ::= BLOCK CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON",
  396. /* 17 */ "interrupt_maybe ::=",
  397. /* 18 */ "interrupt_maybe ::= TOKEN_INTERRUPT CURLY_OPEN statements CURLY_CLOSE",
  398. /* 19 */ "statement ::= TOKEN_DO CURLY_OPEN statements CURLY_CLOSE interrupt_maybe name_maybe SEMICOLON",
  399. /* 20 */ "statements ::= statement",
  400. /* 21 */ "statements ::= statement statements",
  401. /* 22 */ "dotted_name ::= NAME",
  402. /* 23 */ "dotted_name ::= NAME DOT dotted_name",
  403. /* 24 */ "name_list ::= NAME",
  404. /* 25 */ "name_list ::= NAME DOT name_list",
  405. /* 26 */ "list_contents_maybe ::=",
  406. /* 27 */ "list_contents_maybe ::= list_contents",
  407. /* 28 */ "list_contents ::= value",
  408. /* 29 */ "list_contents ::= value COMMA list_contents",
  409. /* 30 */ "list ::= CURLY_OPEN CURLY_CLOSE",
  410. /* 31 */ "list ::= CURLY_OPEN list_contents CURLY_CLOSE",
  411. /* 32 */ "map_contents ::= value COLON value",
  412. /* 33 */ "map_contents ::= value COLON value COMMA map_contents",
  413. /* 34 */ "map ::= BRACKET_OPEN BRACKET_CLOSE",
  414. /* 35 */ "map ::= BRACKET_OPEN map_contents BRACKET_CLOSE",
  415. /* 36 */ "invoc ::= value ROUND_OPEN list_contents_maybe ROUND_CLOSE",
  416. /* 37 */ "value ::= STRING",
  417. /* 38 */ "value ::= AT_SIGN dotted_name",
  418. /* 39 */ "value ::= CARET name_list",
  419. /* 40 */ "value ::= dotted_name",
  420. /* 41 */ "value ::= list",
  421. /* 42 */ "value ::= map",
  422. /* 43 */ "value ::= ROUND_OPEN value ROUND_CLOSE",
  423. /* 44 */ "value ::= invoc",
  424. /* 45 */ "name_maybe ::=",
  425. /* 46 */ "name_maybe ::= NAME",
  426. /* 47 */ "process_or_template ::= PROCESS",
  427. /* 48 */ "process_or_template ::= TEMPLATE",
  428. };
  429. #endif /* NDEBUG */
  430. #if YYSTACKDEPTH<=0
  431. /*
  432. ** Try to increase the size of the parser stack.
  433. */
  434. static void yyGrowStack(yyParser *p){
  435. int newSize;
  436. yyStackEntry *pNew;
  437. newSize = p->yystksz*2 + 100;
  438. pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
  439. if( pNew ){
  440. p->yystack = pNew;
  441. p->yystksz = newSize;
  442. #ifndef NDEBUG
  443. if( yyTraceFILE ){
  444. fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
  445. yyTracePrompt, p->yystksz);
  446. }
  447. #endif
  448. }
  449. }
  450. #endif
  451. /*
  452. ** This function allocates a new parser.
  453. ** The only argument is a pointer to a function which works like
  454. ** malloc.
  455. **
  456. ** Inputs:
  457. ** A pointer to the function used to allocate memory.
  458. **
  459. ** Outputs:
  460. ** A pointer to a parser. This pointer is used in subsequent calls
  461. ** to Parse and ParseFree.
  462. */
  463. void *ParseAlloc(void *(*mallocProc)(size_t)){
  464. yyParser *pParser;
  465. pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );
  466. if( pParser ){
  467. pParser->yyidx = -1;
  468. #ifdef YYTRACKMAXSTACKDEPTH
  469. pParser->yyidxMax = 0;
  470. #endif
  471. #if YYSTACKDEPTH<=0
  472. pParser->yystack = NULL;
  473. pParser->yystksz = 0;
  474. yyGrowStack(pParser);
  475. #endif
  476. }
  477. return pParser;
  478. }
  479. /* The following function deletes the value associated with a
  480. ** symbol. The symbol can be either a terminal or nonterminal.
  481. ** "yymajor" is the symbol code, and "yypminor" is a pointer to
  482. ** the value.
  483. */
  484. static void yy_destructor(
  485. yyParser *yypParser, /* The parser */
  486. YYCODETYPE yymajor, /* Type code for object to destroy */
  487. YYMINORTYPE *yypminor /* The object to be destroyed */
  488. ){
  489. ParseARG_FETCH;
  490. switch( yymajor ){
  491. /* Here is inserted the actions which take place when a
  492. ** terminal or non-terminal is destroyed. This can happen
  493. ** when the symbol is popped from the stack during a
  494. ** reduce or during error processing or when a parser is
  495. ** being destroyed before it is finished parsing.
  496. **
  497. ** Note: during a reduce, the only symbols destroyed are those
  498. ** which appear on the RHS of the rule, but which are not used
  499. ** inside the C code.
  500. */
  501. /* TERMINAL Destructor */
  502. case 1: /* INCLUDE */
  503. case 2: /* STRING */
  504. case 3: /* INCLUDE_GUARD */
  505. case 4: /* NAME */
  506. case 5: /* CURLY_OPEN */
  507. case 6: /* CURLY_CLOSE */
  508. case 7: /* ROUND_OPEN */
  509. case 8: /* ROUND_CLOSE */
  510. case 9: /* SEMICOLON */
  511. case 10: /* ARROW */
  512. case 11: /* IF */
  513. case 12: /* FOREACH */
  514. case 13: /* AS */
  515. case 14: /* COLON */
  516. case 15: /* ELIF */
  517. case 16: /* ELSE */
  518. case 17: /* BLOCK */
  519. case 18: /* TOKEN_INTERRUPT */
  520. case 19: /* TOKEN_DO */
  521. case 20: /* DOT */
  522. case 21: /* COMMA */
  523. case 22: /* BRACKET_OPEN */
  524. case 23: /* BRACKET_CLOSE */
  525. case 24: /* AT_SIGN */
  526. case 25: /* CARET */
  527. case 26: /* PROCESS */
  528. case 27: /* TEMPLATE */
  529. {
  530. #line 89 "NCDConfigParser_parse.y"
  531. free_token((yypminor->yy0));
  532. #line 561 "NCDConfigParser_parse.c"
  533. }
  534. break;
  535. case 29: /* processes */
  536. {
  537. #line 111 "NCDConfigParser_parse.y"
  538. (void)parser_out; free_program((yypminor->yy6));
  539. #line 568 "NCDConfigParser_parse.c"
  540. }
  541. break;
  542. case 30: /* statement */
  543. {
  544. #line 112 "NCDConfigParser_parse.y"
  545. free_statement((yypminor->yy47));
  546. #line 575 "NCDConfigParser_parse.c"
  547. }
  548. break;
  549. case 31: /* elif_maybe */
  550. case 32: /* elif */
  551. {
  552. #line 113 "NCDConfigParser_parse.y"
  553. free_ifblock((yypminor->yy44));
  554. #line 583 "NCDConfigParser_parse.c"
  555. }
  556. break;
  557. case 33: /* else_maybe */
  558. case 34: /* statements */
  559. case 46: /* interrupt_maybe */
  560. {
  561. #line 115 "NCDConfigParser_parse.y"
  562. free_block((yypminor->yy69));
  563. #line 592 "NCDConfigParser_parse.c"
  564. }
  565. break;
  566. case 35: /* dotted_name */
  567. case 43: /* name_maybe */
  568. {
  569. #line 117 "NCDConfigParser_parse.y"
  570. free((yypminor->yy49));
  571. #line 600 "NCDConfigParser_parse.c"
  572. }
  573. break;
  574. case 36: /* list_contents_maybe */
  575. case 37: /* list_contents */
  576. case 38: /* list */
  577. case 39: /* map_contents */
  578. case 40: /* map */
  579. case 41: /* invoc */
  580. case 42: /* value */
  581. case 45: /* name_list */
  582. {
  583. #line 118 "NCDConfigParser_parse.y"
  584. free_value((yypminor->yy19));
  585. #line 614 "NCDConfigParser_parse.c"
  586. }
  587. break;
  588. default: break; /* If no destructor action specified: do nothing */
  589. }
  590. }
  591. /*
  592. ** Pop the parser's stack once.
  593. **
  594. ** If there is a destructor routine associated with the token which
  595. ** is popped from the stack, then call it.
  596. **
  597. ** Return the major token number for the symbol popped.
  598. */
  599. static int yy_pop_parser_stack(yyParser *pParser){
  600. YYCODETYPE yymajor;
  601. yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
  602. if( pParser->yyidx<0 ) return 0;
  603. #ifndef NDEBUG
  604. if( yyTraceFILE && pParser->yyidx>=0 ){
  605. fprintf(yyTraceFILE,"%sPopping %s\n",
  606. yyTracePrompt,
  607. yyTokenName[yytos->major]);
  608. }
  609. #endif
  610. yymajor = yytos->major;
  611. yy_destructor(pParser, yymajor, &yytos->minor);
  612. pParser->yyidx--;
  613. return yymajor;
  614. }
  615. /*
  616. ** Deallocate and destroy a parser. Destructors are all called for
  617. ** all stack elements before shutting the parser down.
  618. **
  619. ** Inputs:
  620. ** <ul>
  621. ** <li> A pointer to the parser. This should be a pointer
  622. ** obtained from ParseAlloc.
  623. ** <li> A pointer to a function used to reclaim memory obtained
  624. ** from malloc.
  625. ** </ul>
  626. */
  627. void ParseFree(
  628. void *p, /* The parser to be deleted */
  629. void (*freeProc)(void*) /* Function used to reclaim memory */
  630. ){
  631. yyParser *pParser = (yyParser*)p;
  632. if( pParser==0 ) return;
  633. while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
  634. #if YYSTACKDEPTH<=0
  635. free(pParser->yystack);
  636. #endif
  637. (*freeProc)((void*)pParser);
  638. }
  639. /*
  640. ** Return the peak depth of the stack for a parser.
  641. */
  642. #ifdef YYTRACKMAXSTACKDEPTH
  643. int ParseStackPeak(void *p){
  644. yyParser *pParser = (yyParser*)p;
  645. return pParser->yyidxMax;
  646. }
  647. #endif
  648. /*
  649. ** Find the appropriate action for a parser given the terminal
  650. ** look-ahead token iLookAhead.
  651. **
  652. ** If the look-ahead token is YYNOCODE, then check to see if the action is
  653. ** independent of the look-ahead. If it is, return the action, otherwise
  654. ** return YY_NO_ACTION.
  655. */
  656. static int yy_find_shift_action(
  657. yyParser *pParser, /* The parser */
  658. YYCODETYPE iLookAhead /* The look-ahead token */
  659. ){
  660. int i;
  661. int stateno = pParser->yystack[pParser->yyidx].stateno;
  662. if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
  663. return yy_default[stateno];
  664. }
  665. assert( iLookAhead!=YYNOCODE );
  666. i += iLookAhead;
  667. if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
  668. if( iLookAhead>0 ){
  669. #ifdef YYFALLBACK
  670. YYCODETYPE iFallback; /* Fallback token */
  671. if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
  672. && (iFallback = yyFallback[iLookAhead])!=0 ){
  673. #ifndef NDEBUG
  674. if( yyTraceFILE ){
  675. fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
  676. yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
  677. }
  678. #endif
  679. return yy_find_shift_action(pParser, iFallback);
  680. }
  681. #endif
  682. #ifdef YYWILDCARD
  683. {
  684. int j = i - iLookAhead + YYWILDCARD;
  685. if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){
  686. #ifndef NDEBUG
  687. if( yyTraceFILE ){
  688. fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
  689. yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
  690. }
  691. #endif /* NDEBUG */
  692. return yy_action[j];
  693. }
  694. }
  695. #endif /* YYWILDCARD */
  696. }
  697. return yy_default[stateno];
  698. }else{
  699. return yy_action[i];
  700. }
  701. }
  702. /*
  703. ** Find the appropriate action for a parser given the non-terminal
  704. ** look-ahead token iLookAhead.
  705. **
  706. ** If the look-ahead token is YYNOCODE, then check to see if the action is
  707. ** independent of the look-ahead. If it is, return the action, otherwise
  708. ** return YY_NO_ACTION.
  709. */
  710. static int yy_find_reduce_action(
  711. int stateno, /* Current state number */
  712. YYCODETYPE iLookAhead /* The look-ahead token */
  713. ){
  714. int i;
  715. #ifdef YYERRORSYMBOL
  716. if( stateno>YY_REDUCE_MAX ){
  717. return yy_default[stateno];
  718. }
  719. #else
  720. assert( stateno<=YY_REDUCE_MAX );
  721. #endif
  722. i = yy_reduce_ofst[stateno];
  723. assert( i!=YY_REDUCE_USE_DFLT );
  724. assert( iLookAhead!=YYNOCODE );
  725. i += iLookAhead;
  726. #ifdef YYERRORSYMBOL
  727. if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
  728. return yy_default[stateno];
  729. }
  730. #else
  731. assert( i>=0 && i<YY_SZ_ACTTAB );
  732. assert( yy_lookahead[i]==iLookAhead );
  733. #endif
  734. return yy_action[i];
  735. }
  736. /*
  737. ** The following routine is called if the stack overflows.
  738. */
  739. static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
  740. ParseARG_FETCH;
  741. yypParser->yyidx--;
  742. #ifndef NDEBUG
  743. if( yyTraceFILE ){
  744. fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
  745. }
  746. #endif
  747. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  748. /* Here code is inserted which will execute if the parser
  749. ** stack every overflows */
  750. #line 136 "NCDConfigParser_parse.y"
  751. if (yypMinor) {
  752. free_token(yypMinor->yy0);
  753. }
  754. #line 792 "NCDConfigParser_parse.c"
  755. ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
  756. }
  757. /*
  758. ** Perform a shift action.
  759. */
  760. static void yy_shift(
  761. yyParser *yypParser, /* The parser to be shifted */
  762. int yyNewState, /* The new state to shift in */
  763. int yyMajor, /* The major token to shift in */
  764. YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */
  765. ){
  766. yyStackEntry *yytos;
  767. yypParser->yyidx++;
  768. #ifdef YYTRACKMAXSTACKDEPTH
  769. if( yypParser->yyidx>yypParser->yyidxMax ){
  770. yypParser->yyidxMax = yypParser->yyidx;
  771. }
  772. #endif
  773. #if YYSTACKDEPTH>0
  774. if( yypParser->yyidx>=YYSTACKDEPTH ){
  775. yyStackOverflow(yypParser, yypMinor);
  776. return;
  777. }
  778. #else
  779. if( yypParser->yyidx>=yypParser->yystksz ){
  780. yyGrowStack(yypParser);
  781. if( yypParser->yyidx>=yypParser->yystksz ){
  782. yyStackOverflow(yypParser, yypMinor);
  783. return;
  784. }
  785. }
  786. #endif
  787. yytos = &yypParser->yystack[yypParser->yyidx];
  788. yytos->stateno = (YYACTIONTYPE)yyNewState;
  789. yytos->major = (YYCODETYPE)yyMajor;
  790. yytos->minor = *yypMinor;
  791. #ifndef NDEBUG
  792. if( yyTraceFILE && yypParser->yyidx>0 ){
  793. int i;
  794. fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState);
  795. fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
  796. for(i=1; i<=yypParser->yyidx; i++)
  797. fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]);
  798. fprintf(yyTraceFILE,"\n");
  799. }
  800. #endif
  801. }
  802. /* The following table contains information about every rule that
  803. ** is used during the reduce.
  804. */
  805. static const struct {
  806. YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
  807. unsigned char nrhs; /* Number of right-hand side symbols in the rule */
  808. } yyRuleInfo[] = {
  809. { 47, 1 },
  810. { 29, 0 },
  811. { 29, 3 },
  812. { 29, 3 },
  813. { 29, 6 },
  814. { 30, 6 },
  815. { 30, 8 },
  816. { 30, 11 },
  817. { 30, 11 },
  818. { 30, 13 },
  819. { 31, 0 },
  820. { 31, 1 },
  821. { 32, 7 },
  822. { 32, 8 },
  823. { 33, 0 },
  824. { 33, 4 },
  825. { 30, 6 },
  826. { 46, 0 },
  827. { 46, 4 },
  828. { 30, 7 },
  829. { 34, 1 },
  830. { 34, 2 },
  831. { 35, 1 },
  832. { 35, 3 },
  833. { 45, 1 },
  834. { 45, 3 },
  835. { 36, 0 },
  836. { 36, 1 },
  837. { 37, 1 },
  838. { 37, 3 },
  839. { 38, 2 },
  840. { 38, 3 },
  841. { 39, 3 },
  842. { 39, 5 },
  843. { 40, 2 },
  844. { 40, 3 },
  845. { 41, 4 },
  846. { 42, 1 },
  847. { 42, 2 },
  848. { 42, 2 },
  849. { 42, 1 },
  850. { 42, 1 },
  851. { 42, 1 },
  852. { 42, 3 },
  853. { 42, 1 },
  854. { 43, 0 },
  855. { 43, 1 },
  856. { 44, 1 },
  857. { 44, 1 },
  858. };
  859. static void yy_accept(yyParser*); /* Forward Declaration */
  860. /*
  861. ** Perform a reduce action and the shift that must immediately
  862. ** follow the reduce.
  863. */
  864. static void yy_reduce(
  865. yyParser *yypParser, /* The parser */
  866. int yyruleno /* Number of the rule by which to reduce */
  867. ){
  868. int yygoto; /* The next state */
  869. int yyact; /* The next action */
  870. YYMINORTYPE yygotominor; /* The LHS of the rule reduced */
  871. yyStackEntry *yymsp; /* The top of the parser's stack */
  872. int yysize; /* Amount to pop the stack */
  873. ParseARG_FETCH;
  874. yymsp = &yypParser->yystack[yypParser->yyidx];
  875. #ifndef NDEBUG
  876. if( yyTraceFILE && yyruleno>=0
  877. && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
  878. fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
  879. yyRuleName[yyruleno]);
  880. }
  881. #endif /* NDEBUG */
  882. /* Silence complaints from purify about yygotominor being uninitialized
  883. ** in some cases when it is copied into the stack after the following
  884. ** switch. yygotominor is uninitialized when a rule reduces that does
  885. ** not set the value of its left-hand side nonterminal. Leaving the
  886. ** value of the nonterminal uninitialized is utterly harmless as long
  887. ** as the value is never used. So really the only thing this code
  888. ** accomplishes is to quieten purify.
  889. **
  890. ** 2007-01-16: The wireshark project (www.wireshark.org) reports that
  891. ** without this code, their parser segfaults. I'm not sure what there
  892. ** parser is doing to make this happen. This is the second bug report
  893. ** from wireshark this week. Clearly they are stressing Lemon in ways
  894. ** that it has not been previously stressed... (SQLite ticket #2172)
  895. */
  896. /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  897. yygotominor = yyzerominor;
  898. switch( yyruleno ){
  899. /* Beginning here are the reduction cases. A typical example
  900. ** follows:
  901. ** case 0:
  902. ** #line <lineno> <grammarfile>
  903. ** { ... } // User supplied code
  904. ** #line <lineno> <thisfile>
  905. ** break;
  906. */
  907. case 0: /* input ::= processes */
  908. #line 142 "NCDConfigParser_parse.y"
  909. {
  910. ASSERT(!parser_out->have_ast)
  911. if (yymsp[0].minor.yy6.have) {
  912. parser_out->have_ast = 1;
  913. parser_out->ast = yymsp[0].minor.yy6.v;
  914. }
  915. }
  916. #line 962 "NCDConfigParser_parse.c"
  917. break;
  918. case 1: /* processes ::= */
  919. #line 151 "NCDConfigParser_parse.y"
  920. {
  921. NCDProgram prog;
  922. NCDProgram_Init(&prog);
  923. yygotominor.yy6.have = 1;
  924. yygotominor.yy6.v = prog;
  925. }
  926. #line 973 "NCDConfigParser_parse.c"
  927. break;
  928. case 2: /* processes ::= INCLUDE STRING processes */
  929. #line 159 "NCDConfigParser_parse.y"
  930. {
  931. ASSERT(yymsp[-1].minor.yy0.str)
  932. if (!yymsp[0].minor.yy6.have) {
  933. goto failA0;
  934. }
  935. NCDProgramElem elem;
  936. if (!NCDProgramElem_InitInclude(&elem, yymsp[-1].minor.yy0.str, yymsp[-1].minor.yy0.len)) {
  937. goto failA0;
  938. }
  939. if (!NCDProgram_PrependElem(&yymsp[0].minor.yy6.v, elem)) {
  940. goto failA1;
  941. }
  942. yygotominor.yy6.have = 1;
  943. yygotominor.yy6.v = yymsp[0].minor.yy6.v;
  944. yymsp[0].minor.yy6.have = 0;
  945. goto doneA;
  946. failA1:
  947. NCDProgramElem_Free(&elem);
  948. failA0:
  949. yygotominor.yy6.have = 0;
  950. parser_out->out_of_memory = 1;
  951. doneA:
  952. free_token(yymsp[-1].minor.yy0);
  953. free_program(yymsp[0].minor.yy6);
  954. yy_destructor(yypParser,1,&yymsp[-2].minor);
  955. }
  956. #line 1007 "NCDConfigParser_parse.c"
  957. break;
  958. case 3: /* processes ::= INCLUDE_GUARD STRING processes */
  959. #line 189 "NCDConfigParser_parse.y"
  960. {
  961. ASSERT(yymsp[-1].minor.yy0.str)
  962. if (!yymsp[0].minor.yy6.have) {
  963. goto failZ0;
  964. }
  965. NCDProgramElem elem;
  966. if (!NCDProgramElem_InitIncludeGuard(&elem, yymsp[-1].minor.yy0.str, yymsp[-1].minor.yy0.len)) {
  967. goto failZ0;
  968. }
  969. if (!NCDProgram_PrependElem(&yymsp[0].minor.yy6.v, elem)) {
  970. goto failZ1;
  971. }
  972. yygotominor.yy6.have = 1;
  973. yygotominor.yy6.v = yymsp[0].minor.yy6.v;
  974. yymsp[0].minor.yy6.have = 0;
  975. goto doneZ;
  976. failZ1:
  977. NCDProgramElem_Free(&elem);
  978. failZ0:
  979. yygotominor.yy6.have = 0;
  980. parser_out->out_of_memory = 1;
  981. doneZ:
  982. free_token(yymsp[-1].minor.yy0);
  983. free_program(yymsp[0].minor.yy6);
  984. yy_destructor(yypParser,3,&yymsp[-2].minor);
  985. }
  986. #line 1041 "NCDConfigParser_parse.c"
  987. break;
  988. case 4: /* processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes */
  989. #line 219 "NCDConfigParser_parse.y"
  990. {
  991. ASSERT(yymsp[-4].minor.yy0.str)
  992. if (!yymsp[-2].minor.yy69.have || !yymsp[0].minor.yy6.have) {
  993. goto failB0;
  994. }
  995. NCDProcess proc;
  996. if (!NCDProcess_Init(&proc, yymsp[-5].minor.yy28, yymsp[-4].minor.yy0.str, yymsp[-2].minor.yy69.v)) {
  997. goto failB0;
  998. }
  999. yymsp[-2].minor.yy69.have = 0;
  1000. NCDProgramElem elem;
  1001. NCDProgramElem_InitProcess(&elem, proc);
  1002. if (!NCDProgram_PrependElem(&yymsp[0].minor.yy6.v, elem)) {
  1003. goto failB1;
  1004. }
  1005. yygotominor.yy6.have = 1;
  1006. yygotominor.yy6.v = yymsp[0].minor.yy6.v;
  1007. yymsp[0].minor.yy6.have = 0;
  1008. goto doneB;
  1009. failB1:
  1010. NCDProgramElem_Free(&elem);
  1011. failB0:
  1012. yygotominor.yy6.have = 0;
  1013. parser_out->out_of_memory = 1;
  1014. doneB:
  1015. free_token(yymsp[-4].minor.yy0);
  1016. free_block(yymsp[-2].minor.yy69);
  1017. free_program(yymsp[0].minor.yy6);
  1018. yy_destructor(yypParser,5,&yymsp[-3].minor);
  1019. yy_destructor(yypParser,6,&yymsp[-1].minor);
  1020. }
  1021. #line 1081 "NCDConfigParser_parse.c"
  1022. break;
  1023. case 5: /* statement ::= dotted_name ROUND_OPEN list_contents_maybe ROUND_CLOSE name_maybe SEMICOLON */
  1024. #line 254 "NCDConfigParser_parse.y"
  1025. {
  1026. if (!yymsp[-5].minor.yy49 || !yymsp[-3].minor.yy19.have) {
  1027. goto failC0;
  1028. }
  1029. if (!NCDStatement_InitReg(&yygotominor.yy47.v, yymsp[-1].minor.yy49, NULL, yymsp[-5].minor.yy49, yymsp[-3].minor.yy19.v)) {
  1030. goto failC0;
  1031. }
  1032. yymsp[-3].minor.yy19.have = 0;
  1033. yygotominor.yy47.have = 1;
  1034. goto doneC;
  1035. failC0:
  1036. yygotominor.yy47.have = 0;
  1037. parser_out->out_of_memory = 1;
  1038. doneC:
  1039. free(yymsp[-5].minor.yy49);
  1040. free_value(yymsp[-3].minor.yy19);
  1041. free(yymsp[-1].minor.yy49);
  1042. yy_destructor(yypParser,7,&yymsp[-4].minor);
  1043. yy_destructor(yypParser,8,&yymsp[-2].minor);
  1044. yy_destructor(yypParser,9,&yymsp[0].minor);
  1045. }
  1046. #line 1109 "NCDConfigParser_parse.c"
  1047. break;
  1048. case 6: /* statement ::= dotted_name ARROW dotted_name ROUND_OPEN list_contents_maybe ROUND_CLOSE name_maybe SEMICOLON */
  1049. #line 276 "NCDConfigParser_parse.y"
  1050. {
  1051. if (!yymsp[-7].minor.yy49 || !yymsp[-5].minor.yy49 || !yymsp[-3].minor.yy19.have) {
  1052. goto failD0;
  1053. }
  1054. if (!NCDStatement_InitReg(&yygotominor.yy47.v, yymsp[-1].minor.yy49, yymsp[-7].minor.yy49, yymsp[-5].minor.yy49, yymsp[-3].minor.yy19.v)) {
  1055. goto failD0;
  1056. }
  1057. yymsp[-3].minor.yy19.have = 0;
  1058. yygotominor.yy47.have = 1;
  1059. goto doneD;
  1060. failD0:
  1061. yygotominor.yy47.have = 0;
  1062. parser_out->out_of_memory = 1;
  1063. doneD:
  1064. free(yymsp[-7].minor.yy49);
  1065. free(yymsp[-5].minor.yy49);
  1066. free_value(yymsp[-3].minor.yy19);
  1067. free(yymsp[-1].minor.yy49);
  1068. yy_destructor(yypParser,10,&yymsp[-6].minor);
  1069. yy_destructor(yypParser,7,&yymsp[-4].minor);
  1070. yy_destructor(yypParser,8,&yymsp[-2].minor);
  1071. yy_destructor(yypParser,9,&yymsp[0].minor);
  1072. }
  1073. #line 1139 "NCDConfigParser_parse.c"
  1074. break;
  1075. case 7: /* statement ::= IF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif_maybe else_maybe name_maybe SEMICOLON */
  1076. #line 299 "NCDConfigParser_parse.y"
  1077. {
  1078. if (!yymsp[-8].minor.yy19.have || !yymsp[-5].minor.yy69.have || !yymsp[-3].minor.yy44.have) {
  1079. goto failE0;
  1080. }
  1081. NCDIf ifc;
  1082. NCDIf_Init(&ifc, yymsp[-8].minor.yy19.v, yymsp[-5].minor.yy69.v);
  1083. yymsp[-8].minor.yy19.have = 0;
  1084. yymsp[-5].minor.yy69.have = 0;
  1085. if (!NCDIfBlock_PrependIf(&yymsp[-3].minor.yy44.v, ifc)) {
  1086. NCDIf_Free(&ifc);
  1087. goto failE0;
  1088. }
  1089. if (!NCDStatement_InitIf(&yygotominor.yy47.v, yymsp[-1].minor.yy49, yymsp[-3].minor.yy44.v, NCDIFTYPE_IF)) {
  1090. goto failE0;
  1091. }
  1092. yymsp[-3].minor.yy44.have = 0;
  1093. if (yymsp[-2].minor.yy69.have) {
  1094. NCDStatement_IfAddElse(&yygotominor.yy47.v, yymsp[-2].minor.yy69.v);
  1095. yymsp[-2].minor.yy69.have = 0;
  1096. }
  1097. yygotominor.yy47.have = 1;
  1098. goto doneE;
  1099. failE0:
  1100. yygotominor.yy47.have = 0;
  1101. parser_out->out_of_memory = 1;
  1102. doneE:
  1103. free_value(yymsp[-8].minor.yy19);
  1104. free_block(yymsp[-5].minor.yy69);
  1105. free_ifblock(yymsp[-3].minor.yy44);
  1106. free_block(yymsp[-2].minor.yy69);
  1107. free(yymsp[-1].minor.yy49);
  1108. yy_destructor(yypParser,11,&yymsp[-10].minor);
  1109. yy_destructor(yypParser,7,&yymsp[-9].minor);
  1110. yy_destructor(yypParser,8,&yymsp[-7].minor);
  1111. yy_destructor(yypParser,5,&yymsp[-6].minor);
  1112. yy_destructor(yypParser,6,&yymsp[-4].minor);
  1113. yy_destructor(yypParser,9,&yymsp[0].minor);
  1114. }
  1115. #line 1187 "NCDConfigParser_parse.c"
  1116. break;
  1117. case 8: /* statement ::= FOREACH ROUND_OPEN value AS NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON */
  1118. #line 338 "NCDConfigParser_parse.y"
  1119. {
  1120. if (!yymsp[-8].minor.yy19.have || !yymsp[-6].minor.yy0.str || !yymsp[-3].minor.yy69.have) {
  1121. goto failEA0;
  1122. }
  1123. if (!NCDStatement_InitForeach(&yygotominor.yy47.v, yymsp[-1].minor.yy49, yymsp[-8].minor.yy19.v, yymsp[-6].minor.yy0.str, NULL, yymsp[-3].minor.yy69.v)) {
  1124. goto failEA0;
  1125. }
  1126. yymsp[-8].minor.yy19.have = 0;
  1127. yymsp[-3].minor.yy69.have = 0;
  1128. yygotominor.yy47.have = 1;
  1129. goto doneEA0;
  1130. failEA0:
  1131. yygotominor.yy47.have = 0;
  1132. parser_out->out_of_memory = 1;
  1133. doneEA0:
  1134. free_value(yymsp[-8].minor.yy19);
  1135. free_token(yymsp[-6].minor.yy0);
  1136. free_block(yymsp[-3].minor.yy69);
  1137. free(yymsp[-1].minor.yy49);
  1138. yy_destructor(yypParser,12,&yymsp[-10].minor);
  1139. yy_destructor(yypParser,7,&yymsp[-9].minor);
  1140. yy_destructor(yypParser,13,&yymsp[-7].minor);
  1141. yy_destructor(yypParser,8,&yymsp[-5].minor);
  1142. yy_destructor(yypParser,5,&yymsp[-4].minor);
  1143. yy_destructor(yypParser,6,&yymsp[-2].minor);
  1144. yy_destructor(yypParser,9,&yymsp[0].minor);
  1145. }
  1146. #line 1221 "NCDConfigParser_parse.c"
  1147. break;
  1148. case 9: /* statement ::= FOREACH ROUND_OPEN value AS NAME COLON NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON */
  1149. #line 362 "NCDConfigParser_parse.y"
  1150. {
  1151. if (!yymsp[-10].minor.yy19.have || !yymsp[-8].minor.yy0.str || !yymsp[-6].minor.yy0.str || !yymsp[-3].minor.yy69.have) {
  1152. goto failEB0;
  1153. }
  1154. if (!NCDStatement_InitForeach(&yygotominor.yy47.v, yymsp[-1].minor.yy49, yymsp[-10].minor.yy19.v, yymsp[-8].minor.yy0.str, yymsp[-6].minor.yy0.str, yymsp[-3].minor.yy69.v)) {
  1155. goto failEB0;
  1156. }
  1157. yymsp[-10].minor.yy19.have = 0;
  1158. yymsp[-3].minor.yy69.have = 0;
  1159. yygotominor.yy47.have = 1;
  1160. goto doneEB0;
  1161. failEB0:
  1162. yygotominor.yy47.have = 0;
  1163. parser_out->out_of_memory = 1;
  1164. doneEB0:
  1165. free_value(yymsp[-10].minor.yy19);
  1166. free_token(yymsp[-8].minor.yy0);
  1167. free_token(yymsp[-6].minor.yy0);
  1168. free_block(yymsp[-3].minor.yy69);
  1169. free(yymsp[-1].minor.yy49);
  1170. yy_destructor(yypParser,12,&yymsp[-12].minor);
  1171. yy_destructor(yypParser,7,&yymsp[-11].minor);
  1172. yy_destructor(yypParser,13,&yymsp[-9].minor);
  1173. yy_destructor(yypParser,14,&yymsp[-7].minor);
  1174. yy_destructor(yypParser,8,&yymsp[-5].minor);
  1175. yy_destructor(yypParser,5,&yymsp[-4].minor);
  1176. yy_destructor(yypParser,6,&yymsp[-2].minor);
  1177. yy_destructor(yypParser,9,&yymsp[0].minor);
  1178. }
  1179. #line 1257 "NCDConfigParser_parse.c"
  1180. break;
  1181. case 10: /* elif_maybe ::= */
  1182. #line 387 "NCDConfigParser_parse.y"
  1183. {
  1184. NCDIfBlock_Init(&yygotominor.yy44.v);
  1185. yygotominor.yy44.have = 1;
  1186. }
  1187. #line 1265 "NCDConfigParser_parse.c"
  1188. break;
  1189. case 11: /* elif_maybe ::= elif */
  1190. #line 392 "NCDConfigParser_parse.y"
  1191. {
  1192. yygotominor.yy44 = yymsp[0].minor.yy44;
  1193. }
  1194. #line 1272 "NCDConfigParser_parse.c"
  1195. break;
  1196. case 12: /* elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE */
  1197. #line 396 "NCDConfigParser_parse.y"
  1198. {
  1199. if (!yymsp[-4].minor.yy19.have || !yymsp[-1].minor.yy69.have) {
  1200. goto failF0;
  1201. }
  1202. NCDIfBlock_Init(&yygotominor.yy44.v);
  1203. NCDIf ifc;
  1204. NCDIf_Init(&ifc, yymsp[-4].minor.yy19.v, yymsp[-1].minor.yy69.v);
  1205. yymsp[-4].minor.yy19.have = 0;
  1206. yymsp[-1].minor.yy69.have = 0;
  1207. if (!NCDIfBlock_PrependIf(&yygotominor.yy44.v, ifc)) {
  1208. goto failF1;
  1209. }
  1210. yygotominor.yy44.have = 1;
  1211. goto doneF0;
  1212. failF1:
  1213. NCDIf_Free(&ifc);
  1214. NCDIfBlock_Free(&yygotominor.yy44.v);
  1215. failF0:
  1216. yygotominor.yy44.have = 0;
  1217. parser_out->out_of_memory = 1;
  1218. doneF0:
  1219. free_value(yymsp[-4].minor.yy19);
  1220. free_block(yymsp[-1].minor.yy69);
  1221. yy_destructor(yypParser,15,&yymsp[-6].minor);
  1222. yy_destructor(yypParser,7,&yymsp[-5].minor);
  1223. yy_destructor(yypParser,8,&yymsp[-3].minor);
  1224. yy_destructor(yypParser,5,&yymsp[-2].minor);
  1225. yy_destructor(yypParser,6,&yymsp[0].minor);
  1226. }
  1227. #line 1310 "NCDConfigParser_parse.c"
  1228. break;
  1229. case 13: /* elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif */
  1230. #line 426 "NCDConfigParser_parse.y"
  1231. {
  1232. if (!yymsp[-5].minor.yy19.have || !yymsp[-2].minor.yy69.have || !yymsp[0].minor.yy44.have) {
  1233. goto failG0;
  1234. }
  1235. NCDIf ifc;
  1236. NCDIf_Init(&ifc, yymsp[-5].minor.yy19.v, yymsp[-2].minor.yy69.v);
  1237. yymsp[-5].minor.yy19.have = 0;
  1238. yymsp[-2].minor.yy69.have = 0;
  1239. if (!NCDIfBlock_PrependIf(&yymsp[0].minor.yy44.v, ifc)) {
  1240. goto failG1;
  1241. }
  1242. yygotominor.yy44.have = 1;
  1243. yygotominor.yy44.v = yymsp[0].minor.yy44.v;
  1244. yymsp[0].minor.yy44.have = 0;
  1245. goto doneG0;
  1246. failG1:
  1247. NCDIf_Free(&ifc);
  1248. failG0:
  1249. yygotominor.yy44.have = 0;
  1250. parser_out->out_of_memory = 1;
  1251. doneG0:
  1252. free_value(yymsp[-5].minor.yy19);
  1253. free_block(yymsp[-2].minor.yy69);
  1254. free_ifblock(yymsp[0].minor.yy44);
  1255. yy_destructor(yypParser,15,&yymsp[-7].minor);
  1256. yy_destructor(yypParser,7,&yymsp[-6].minor);
  1257. yy_destructor(yypParser,8,&yymsp[-4].minor);
  1258. yy_destructor(yypParser,5,&yymsp[-3].minor);
  1259. yy_destructor(yypParser,6,&yymsp[-1].minor);
  1260. }
  1261. #line 1348 "NCDConfigParser_parse.c"
  1262. break;
  1263. case 14: /* else_maybe ::= */
  1264. case 17: /* interrupt_maybe ::= */ yytestcase(yyruleno==17);
  1265. #line 456 "NCDConfigParser_parse.y"
  1266. {
  1267. yygotominor.yy69.have = 0;
  1268. }
  1269. #line 1356 "NCDConfigParser_parse.c"
  1270. break;
  1271. case 15: /* else_maybe ::= ELSE CURLY_OPEN statements CURLY_CLOSE */
  1272. #line 460 "NCDConfigParser_parse.y"
  1273. {
  1274. yygotominor.yy69 = yymsp[-1].minor.yy69;
  1275. yy_destructor(yypParser,16,&yymsp[-3].minor);
  1276. yy_destructor(yypParser,5,&yymsp[-2].minor);
  1277. yy_destructor(yypParser,6,&yymsp[0].minor);
  1278. }
  1279. #line 1366 "NCDConfigParser_parse.c"
  1280. break;
  1281. case 16: /* statement ::= BLOCK CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON */
  1282. #line 464 "NCDConfigParser_parse.y"
  1283. {
  1284. if (!yymsp[-3].minor.yy69.have) {
  1285. goto failGA0;
  1286. }
  1287. if (!NCDStatement_InitBlock(&yygotominor.yy47.v, yymsp[-1].minor.yy49, yymsp[-3].minor.yy69.v)) {
  1288. goto failGA0;
  1289. }
  1290. yymsp[-3].minor.yy69.have = 0;
  1291. yygotominor.yy47.have = 1;
  1292. goto doneGA0;
  1293. failGA0:
  1294. yygotominor.yy47.have = 0;
  1295. parser_out->out_of_memory = 1;
  1296. doneGA0:
  1297. free_block(yymsp[-3].minor.yy69);
  1298. free(yymsp[-1].minor.yy49);
  1299. yy_destructor(yypParser,17,&yymsp[-5].minor);
  1300. yy_destructor(yypParser,5,&yymsp[-4].minor);
  1301. yy_destructor(yypParser,6,&yymsp[-2].minor);
  1302. yy_destructor(yypParser,9,&yymsp[0].minor);
  1303. }
  1304. #line 1394 "NCDConfigParser_parse.c"
  1305. break;
  1306. case 18: /* interrupt_maybe ::= TOKEN_INTERRUPT CURLY_OPEN statements CURLY_CLOSE */
  1307. #line 489 "NCDConfigParser_parse.y"
  1308. {
  1309. yygotominor.yy69 = yymsp[-1].minor.yy69;
  1310. yy_destructor(yypParser,18,&yymsp[-3].minor);
  1311. yy_destructor(yypParser,5,&yymsp[-2].minor);
  1312. yy_destructor(yypParser,6,&yymsp[0].minor);
  1313. }
  1314. #line 1404 "NCDConfigParser_parse.c"
  1315. break;
  1316. case 19: /* statement ::= TOKEN_DO CURLY_OPEN statements CURLY_CLOSE interrupt_maybe name_maybe SEMICOLON */
  1317. #line 493 "NCDConfigParser_parse.y"
  1318. {
  1319. if (!yymsp[-4].minor.yy69.have) {
  1320. goto failGB0;
  1321. }
  1322. NCDIfBlock if_block;
  1323. NCDIfBlock_Init(&if_block);
  1324. if (yymsp[-2].minor.yy69.have) {
  1325. NCDIf int_if;
  1326. NCDIf_InitBlock(&int_if, yymsp[-2].minor.yy69.v);
  1327. yymsp[-2].minor.yy69.have = 0;
  1328. if (!NCDIfBlock_PrependIf(&if_block, int_if)) {
  1329. NCDIf_Free(&int_if);
  1330. goto failGB1;
  1331. }
  1332. }
  1333. NCDIf the_if;
  1334. NCDIf_InitBlock(&the_if, yymsp[-4].minor.yy69.v);
  1335. yymsp[-4].minor.yy69.have = 0;
  1336. if (!NCDIfBlock_PrependIf(&if_block, the_if)) {
  1337. NCDIf_Free(&the_if);
  1338. goto failGB1;
  1339. }
  1340. if (!NCDStatement_InitIf(&yygotominor.yy47.v, yymsp[-1].minor.yy49, if_block, NCDIFTYPE_DO)) {
  1341. goto failGB1;
  1342. }
  1343. yygotominor.yy47.have = 1;
  1344. goto doneGB0;
  1345. failGB1:
  1346. NCDIfBlock_Free(&if_block);
  1347. failGB0:
  1348. yygotominor.yy47.have = 0;
  1349. parser_out->out_of_memory = 1;
  1350. doneGB0:
  1351. free_block(yymsp[-4].minor.yy69);
  1352. free_block(yymsp[-2].minor.yy69);
  1353. free(yymsp[-1].minor.yy49);
  1354. yy_destructor(yypParser,19,&yymsp[-6].minor);
  1355. yy_destructor(yypParser,5,&yymsp[-5].minor);
  1356. yy_destructor(yypParser,6,&yymsp[-3].minor);
  1357. yy_destructor(yypParser,9,&yymsp[0].minor);
  1358. }
  1359. #line 1457 "NCDConfigParser_parse.c"
  1360. break;
  1361. case 20: /* statements ::= statement */
  1362. #line 539 "NCDConfigParser_parse.y"
  1363. {
  1364. if (!yymsp[0].minor.yy47.have) {
  1365. goto failH0;
  1366. }
  1367. NCDBlock_Init(&yygotominor.yy69.v);
  1368. if (!NCDBlock_PrependStatement(&yygotominor.yy69.v, yymsp[0].minor.yy47.v)) {
  1369. goto failH1;
  1370. }
  1371. yymsp[0].minor.yy47.have = 0;
  1372. yygotominor.yy69.have = 1;
  1373. goto doneH;
  1374. failH1:
  1375. NCDBlock_Free(&yygotominor.yy69.v);
  1376. failH0:
  1377. yygotominor.yy69.have = 0;
  1378. parser_out->out_of_memory = 1;
  1379. doneH:
  1380. free_statement(yymsp[0].minor.yy47);
  1381. }
  1382. #line 1484 "NCDConfigParser_parse.c"
  1383. break;
  1384. case 21: /* statements ::= statement statements */
  1385. #line 563 "NCDConfigParser_parse.y"
  1386. {
  1387. if (!yymsp[-1].minor.yy47.have || !yymsp[0].minor.yy69.have) {
  1388. goto failI0;
  1389. }
  1390. if (!NCDBlock_PrependStatement(&yymsp[0].minor.yy69.v, yymsp[-1].minor.yy47.v)) {
  1391. goto failI1;
  1392. }
  1393. yymsp[-1].minor.yy47.have = 0;
  1394. yygotominor.yy69.have = 1;
  1395. yygotominor.yy69.v = yymsp[0].minor.yy69.v;
  1396. yymsp[0].minor.yy69.have = 0;
  1397. goto doneI;
  1398. failI1:
  1399. NCDBlock_Free(&yygotominor.yy69.v);
  1400. failI0:
  1401. yygotominor.yy69.have = 0;
  1402. parser_out->out_of_memory = 1;
  1403. doneI:
  1404. free_statement(yymsp[-1].minor.yy47);
  1405. free_block(yymsp[0].minor.yy69);
  1406. }
  1407. #line 1512 "NCDConfigParser_parse.c"
  1408. break;
  1409. case 22: /* dotted_name ::= NAME */
  1410. case 46: /* name_maybe ::= NAME */ yytestcase(yyruleno==46);
  1411. #line 588 "NCDConfigParser_parse.y"
  1412. {
  1413. ASSERT(yymsp[0].minor.yy0.str)
  1414. yygotominor.yy49 = yymsp[0].minor.yy0.str;
  1415. }
  1416. #line 1522 "NCDConfigParser_parse.c"
  1417. break;
  1418. case 23: /* dotted_name ::= NAME DOT dotted_name */
  1419. #line 594 "NCDConfigParser_parse.y"
  1420. {
  1421. ASSERT(yymsp[-2].minor.yy0.str)
  1422. if (!yymsp[0].minor.yy49) {
  1423. goto failJ0;
  1424. }
  1425. if (!(yygotominor.yy49 = concat_strings(3, yymsp[-2].minor.yy0.str, ".", yymsp[0].minor.yy49))) {
  1426. goto failJ0;
  1427. }
  1428. goto doneJ;
  1429. failJ0:
  1430. yygotominor.yy49 = NULL;
  1431. parser_out->out_of_memory = 1;
  1432. doneJ:
  1433. free_token(yymsp[-2].minor.yy0);
  1434. free(yymsp[0].minor.yy49);
  1435. yy_destructor(yypParser,20,&yymsp[-1].minor);
  1436. }
  1437. #line 1546 "NCDConfigParser_parse.c"
  1438. break;
  1439. case 24: /* name_list ::= NAME */
  1440. #line 614 "NCDConfigParser_parse.y"
  1441. {
  1442. if (!yymsp[0].minor.yy0.str) {
  1443. goto failK0;
  1444. }
  1445. NCDValue_InitList(&yygotominor.yy19.v);
  1446. NCDValue this_string;
  1447. if (!NCDValue_InitString(&this_string, yymsp[0].minor.yy0.str)) {
  1448. goto failK1;
  1449. }
  1450. if (!NCDValue_ListPrepend(&yygotominor.yy19.v, this_string)) {
  1451. goto failK2;
  1452. }
  1453. yygotominor.yy19.have = 1;
  1454. goto doneK;
  1455. failK2:
  1456. NCDValue_Free(&this_string);
  1457. failK1:
  1458. NCDValue_Free(&yygotominor.yy19.v);
  1459. failK0:
  1460. yygotominor.yy19.have = 0;
  1461. parser_out->out_of_memory = 1;
  1462. doneK:
  1463. free_token(yymsp[0].minor.yy0);
  1464. }
  1465. #line 1579 "NCDConfigParser_parse.c"
  1466. break;
  1467. case 25: /* name_list ::= NAME DOT name_list */
  1468. #line 644 "NCDConfigParser_parse.y"
  1469. {
  1470. if (!yymsp[-2].minor.yy0.str || !yymsp[0].minor.yy19.have) {
  1471. goto failKA0;
  1472. }
  1473. NCDValue this_string;
  1474. if (!NCDValue_InitString(&this_string, yymsp[-2].minor.yy0.str)) {
  1475. goto failKA0;
  1476. }
  1477. if (!NCDValue_ListPrepend(&yymsp[0].minor.yy19.v, this_string)) {
  1478. goto failKA1;
  1479. }
  1480. yygotominor.yy19.have = 1;
  1481. yygotominor.yy19.v = yymsp[0].minor.yy19.v;
  1482. yymsp[0].minor.yy19.have = 0;
  1483. goto doneKA;
  1484. failKA1:
  1485. NCDValue_Free(&this_string);
  1486. failKA0:
  1487. yygotominor.yy19.have = 0;
  1488. parser_out->out_of_memory = 1;
  1489. doneKA:
  1490. free_token(yymsp[-2].minor.yy0);
  1491. free_value(yymsp[0].minor.yy19);
  1492. yy_destructor(yypParser,20,&yymsp[-1].minor);
  1493. }
  1494. #line 1612 "NCDConfigParser_parse.c"
  1495. break;
  1496. case 26: /* list_contents_maybe ::= */
  1497. #line 673 "NCDConfigParser_parse.y"
  1498. {
  1499. yygotominor.yy19.have = 1;
  1500. NCDValue_InitList(&yygotominor.yy19.v);
  1501. }
  1502. #line 1620 "NCDConfigParser_parse.c"
  1503. break;
  1504. case 27: /* list_contents_maybe ::= list_contents */
  1505. case 41: /* value ::= list */ yytestcase(yyruleno==41);
  1506. case 42: /* value ::= map */ yytestcase(yyruleno==42);
  1507. case 44: /* value ::= invoc */ yytestcase(yyruleno==44);
  1508. #line 678 "NCDConfigParser_parse.y"
  1509. {
  1510. yygotominor.yy19 = yymsp[0].minor.yy19;
  1511. }
  1512. #line 1630 "NCDConfigParser_parse.c"
  1513. break;
  1514. case 28: /* list_contents ::= value */
  1515. #line 682 "NCDConfigParser_parse.y"
  1516. {
  1517. if (!yymsp[0].minor.yy19.have) {
  1518. goto failL0;
  1519. }
  1520. NCDValue_InitList(&yygotominor.yy19.v);
  1521. if (!NCDValue_ListPrepend(&yygotominor.yy19.v, yymsp[0].minor.yy19.v)) {
  1522. goto failL1;
  1523. }
  1524. yymsp[0].minor.yy19.have = 0;
  1525. yygotominor.yy19.have = 1;
  1526. goto doneL;
  1527. failL1:
  1528. NCDValue_Free(&yygotominor.yy19.v);
  1529. failL0:
  1530. yygotominor.yy19.have = 0;
  1531. parser_out->out_of_memory = 1;
  1532. doneL:
  1533. free_value(yymsp[0].minor.yy19);
  1534. }
  1535. #line 1657 "NCDConfigParser_parse.c"
  1536. break;
  1537. case 29: /* list_contents ::= value COMMA list_contents */
  1538. #line 706 "NCDConfigParser_parse.y"
  1539. {
  1540. if (!yymsp[-2].minor.yy19.have || !yymsp[0].minor.yy19.have) {
  1541. goto failM0;
  1542. }
  1543. if (!NCDValue_ListPrepend(&yymsp[0].minor.yy19.v, yymsp[-2].minor.yy19.v)) {
  1544. goto failM0;
  1545. }
  1546. yymsp[-2].minor.yy19.have = 0;
  1547. yygotominor.yy19.have = 1;
  1548. yygotominor.yy19.v = yymsp[0].minor.yy19.v;
  1549. yymsp[0].minor.yy19.have = 0;
  1550. goto doneM;
  1551. failM0:
  1552. yygotominor.yy19.have = 0;
  1553. parser_out->out_of_memory = 1;
  1554. doneM:
  1555. free_value(yymsp[-2].minor.yy19);
  1556. free_value(yymsp[0].minor.yy19);
  1557. yy_destructor(yypParser,21,&yymsp[-1].minor);
  1558. }
  1559. #line 1684 "NCDConfigParser_parse.c"
  1560. break;
  1561. case 30: /* list ::= CURLY_OPEN CURLY_CLOSE */
  1562. #line 729 "NCDConfigParser_parse.y"
  1563. {
  1564. yygotominor.yy19.have = 1;
  1565. NCDValue_InitList(&yygotominor.yy19.v);
  1566. yy_destructor(yypParser,5,&yymsp[-1].minor);
  1567. yy_destructor(yypParser,6,&yymsp[0].minor);
  1568. }
  1569. #line 1694 "NCDConfigParser_parse.c"
  1570. break;
  1571. case 31: /* list ::= CURLY_OPEN list_contents CURLY_CLOSE */
  1572. #line 734 "NCDConfigParser_parse.y"
  1573. {
  1574. yygotominor.yy19 = yymsp[-1].minor.yy19;
  1575. yy_destructor(yypParser,5,&yymsp[-2].minor);
  1576. yy_destructor(yypParser,6,&yymsp[0].minor);
  1577. }
  1578. #line 1703 "NCDConfigParser_parse.c"
  1579. break;
  1580. case 32: /* map_contents ::= value COLON value */
  1581. #line 738 "NCDConfigParser_parse.y"
  1582. {
  1583. if (!yymsp[-2].minor.yy19.have || !yymsp[0].minor.yy19.have) {
  1584. goto failS0;
  1585. }
  1586. NCDValue_InitMap(&yygotominor.yy19.v);
  1587. if (!NCDValue_MapPrepend(&yygotominor.yy19.v, yymsp[-2].minor.yy19.v, yymsp[0].minor.yy19.v)) {
  1588. goto failS1;
  1589. }
  1590. yymsp[-2].minor.yy19.have = 0;
  1591. yymsp[0].minor.yy19.have = 0;
  1592. yygotominor.yy19.have = 1;
  1593. goto doneS;
  1594. failS1:
  1595. NCDValue_Free(&yygotominor.yy19.v);
  1596. failS0:
  1597. yygotominor.yy19.have = 0;
  1598. parser_out->out_of_memory = 1;
  1599. doneS:
  1600. free_value(yymsp[-2].minor.yy19);
  1601. free_value(yymsp[0].minor.yy19);
  1602. yy_destructor(yypParser,14,&yymsp[-1].minor);
  1603. }
  1604. #line 1733 "NCDConfigParser_parse.c"
  1605. break;
  1606. case 33: /* map_contents ::= value COLON value COMMA map_contents */
  1607. #line 764 "NCDConfigParser_parse.y"
  1608. {
  1609. if (!yymsp[-4].minor.yy19.have || !yymsp[-2].minor.yy19.have || !yymsp[0].minor.yy19.have) {
  1610. goto failT0;
  1611. }
  1612. if (!NCDValue_MapPrepend(&yymsp[0].minor.yy19.v, yymsp[-4].minor.yy19.v, yymsp[-2].minor.yy19.v)) {
  1613. goto failT0;
  1614. }
  1615. yymsp[-4].minor.yy19.have = 0;
  1616. yymsp[-2].minor.yy19.have = 0;
  1617. yygotominor.yy19.have = 1;
  1618. yygotominor.yy19.v = yymsp[0].minor.yy19.v;
  1619. yymsp[0].minor.yy19.have = 0;
  1620. goto doneT;
  1621. failT0:
  1622. yygotominor.yy19.have = 0;
  1623. parser_out->out_of_memory = 1;
  1624. doneT:
  1625. free_value(yymsp[-4].minor.yy19);
  1626. free_value(yymsp[-2].minor.yy19);
  1627. free_value(yymsp[0].minor.yy19);
  1628. yy_destructor(yypParser,14,&yymsp[-3].minor);
  1629. yy_destructor(yypParser,21,&yymsp[-1].minor);
  1630. }
  1631. #line 1763 "NCDConfigParser_parse.c"
  1632. break;
  1633. case 34: /* map ::= BRACKET_OPEN BRACKET_CLOSE */
  1634. #line 789 "NCDConfigParser_parse.y"
  1635. {
  1636. yygotominor.yy19.have = 1;
  1637. NCDValue_InitMap(&yygotominor.yy19.v);
  1638. yy_destructor(yypParser,22,&yymsp[-1].minor);
  1639. yy_destructor(yypParser,23,&yymsp[0].minor);
  1640. }
  1641. #line 1773 "NCDConfigParser_parse.c"
  1642. break;
  1643. case 35: /* map ::= BRACKET_OPEN map_contents BRACKET_CLOSE */
  1644. #line 794 "NCDConfigParser_parse.y"
  1645. {
  1646. yygotominor.yy19 = yymsp[-1].minor.yy19;
  1647. yy_destructor(yypParser,22,&yymsp[-2].minor);
  1648. yy_destructor(yypParser,23,&yymsp[0].minor);
  1649. }
  1650. #line 1782 "NCDConfigParser_parse.c"
  1651. break;
  1652. case 36: /* invoc ::= value ROUND_OPEN list_contents_maybe ROUND_CLOSE */
  1653. #line 798 "NCDConfigParser_parse.y"
  1654. {
  1655. if (!yymsp[-3].minor.yy19.have || !yymsp[-1].minor.yy19.have) {
  1656. goto failQ0;
  1657. }
  1658. if (!NCDValue_InitInvoc(&yygotominor.yy19.v, yymsp[-3].minor.yy19.v, yymsp[-1].minor.yy19.v)) {
  1659. goto failQ0;
  1660. }
  1661. yymsp[-3].minor.yy19.have = 0;
  1662. yymsp[-1].minor.yy19.have = 0;
  1663. yygotominor.yy19.have = 1;
  1664. goto doneQ;
  1665. failQ0:
  1666. yygotominor.yy19.have = 0;
  1667. parser_out->out_of_memory = 1;
  1668. doneQ:
  1669. free_value(yymsp[-3].minor.yy19);
  1670. free_value(yymsp[-1].minor.yy19);
  1671. yy_destructor(yypParser,7,&yymsp[-2].minor);
  1672. yy_destructor(yypParser,8,&yymsp[0].minor);
  1673. }
  1674. #line 1808 "NCDConfigParser_parse.c"
  1675. break;
  1676. case 37: /* value ::= STRING */
  1677. #line 819 "NCDConfigParser_parse.y"
  1678. {
  1679. ASSERT(yymsp[0].minor.yy0.str)
  1680. if (!NCDValue_InitStringBin(&yygotominor.yy19.v, (uint8_t *)yymsp[0].minor.yy0.str, yymsp[0].minor.yy0.len)) {
  1681. goto failU0;
  1682. }
  1683. yygotominor.yy19.have = 1;
  1684. goto doneU;
  1685. failU0:
  1686. yygotominor.yy19.have = 0;
  1687. parser_out->out_of_memory = 1;
  1688. doneU:
  1689. free_token(yymsp[0].minor.yy0);
  1690. }
  1691. #line 1828 "NCDConfigParser_parse.c"
  1692. break;
  1693. case 38: /* value ::= AT_SIGN dotted_name */
  1694. #line 836 "NCDConfigParser_parse.y"
  1695. {
  1696. if (!yymsp[0].minor.yy49) {
  1697. goto failUA0;
  1698. }
  1699. if (!NCDValue_InitString(&yygotominor.yy19.v, yymsp[0].minor.yy49)) {
  1700. goto failUA0;
  1701. }
  1702. yygotominor.yy19.have = 1;
  1703. goto doneUA0;
  1704. failUA0:
  1705. yygotominor.yy19.have = 0;
  1706. parser_out->out_of_memory = 1;
  1707. doneUA0:
  1708. free(yymsp[0].minor.yy49);
  1709. yy_destructor(yypParser,24,&yymsp[-1].minor);
  1710. }
  1711. #line 1851 "NCDConfigParser_parse.c"
  1712. break;
  1713. case 39: /* value ::= CARET name_list */
  1714. #line 855 "NCDConfigParser_parse.y"
  1715. {
  1716. yygotominor.yy19 = yymsp[0].minor.yy19;
  1717. yy_destructor(yypParser,25,&yymsp[-1].minor);
  1718. }
  1719. #line 1859 "NCDConfigParser_parse.c"
  1720. break;
  1721. case 40: /* value ::= dotted_name */
  1722. #line 859 "NCDConfigParser_parse.y"
  1723. {
  1724. if (!yymsp[0].minor.yy49) {
  1725. goto failV0;
  1726. }
  1727. if (!NCDValue_InitVar(&yygotominor.yy19.v, yymsp[0].minor.yy49)) {
  1728. goto failV0;
  1729. }
  1730. yygotominor.yy19.have = 1;
  1731. goto doneV;
  1732. failV0:
  1733. yygotominor.yy19.have = 0;
  1734. parser_out->out_of_memory = 1;
  1735. doneV:
  1736. free(yymsp[0].minor.yy49);
  1737. }
  1738. #line 1881 "NCDConfigParser_parse.c"
  1739. break;
  1740. case 43: /* value ::= ROUND_OPEN value ROUND_CLOSE */
  1741. #line 886 "NCDConfigParser_parse.y"
  1742. {
  1743. yygotominor.yy19 = yymsp[-1].minor.yy19;
  1744. yy_destructor(yypParser,7,&yymsp[-2].minor);
  1745. yy_destructor(yypParser,8,&yymsp[0].minor);
  1746. }
  1747. #line 1890 "NCDConfigParser_parse.c"
  1748. break;
  1749. case 45: /* name_maybe ::= */
  1750. #line 894 "NCDConfigParser_parse.y"
  1751. {
  1752. yygotominor.yy49 = NULL;
  1753. }
  1754. #line 1897 "NCDConfigParser_parse.c"
  1755. break;
  1756. case 47: /* process_or_template ::= PROCESS */
  1757. #line 904 "NCDConfigParser_parse.y"
  1758. {
  1759. yygotominor.yy28 = 0;
  1760. yy_destructor(yypParser,26,&yymsp[0].minor);
  1761. }
  1762. #line 1905 "NCDConfigParser_parse.c"
  1763. break;
  1764. case 48: /* process_or_template ::= TEMPLATE */
  1765. #line 908 "NCDConfigParser_parse.y"
  1766. {
  1767. yygotominor.yy28 = 1;
  1768. yy_destructor(yypParser,27,&yymsp[0].minor);
  1769. }
  1770. #line 1913 "NCDConfigParser_parse.c"
  1771. break;
  1772. default:
  1773. break;
  1774. };
  1775. yygoto = yyRuleInfo[yyruleno].lhs;
  1776. yysize = yyRuleInfo[yyruleno].nrhs;
  1777. yypParser->yyidx -= yysize;
  1778. yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  1779. if( yyact < YYNSTATE ){
  1780. #ifdef NDEBUG
  1781. /* If we are not debugging and the reduce action popped at least
  1782. ** one element off the stack, then we can push the new element back
  1783. ** onto the stack here, and skip the stack overflow test in yy_shift().
  1784. ** That gives a significant speed improvement. */
  1785. if( yysize ){
  1786. yypParser->yyidx++;
  1787. yymsp -= yysize-1;
  1788. yymsp->stateno = (YYACTIONTYPE)yyact;
  1789. yymsp->major = (YYCODETYPE)yygoto;
  1790. yymsp->minor = yygotominor;
  1791. }else
  1792. #endif
  1793. {
  1794. yy_shift(yypParser,yyact,yygoto,&yygotominor);
  1795. }
  1796. }else{
  1797. assert( yyact == YYNSTATE + YYNRULE + 1 );
  1798. yy_accept(yypParser);
  1799. }
  1800. }
  1801. /*
  1802. ** The following code executes when the parse fails
  1803. */
  1804. #ifndef YYNOERRORRECOVERY
  1805. static void yy_parse_failed(
  1806. yyParser *yypParser /* The parser */
  1807. ){
  1808. ParseARG_FETCH;
  1809. #ifndef NDEBUG
  1810. if( yyTraceFILE ){
  1811. fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
  1812. }
  1813. #endif
  1814. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  1815. /* Here code is inserted which will be executed whenever the
  1816. ** parser fails */
  1817. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  1818. }
  1819. #endif /* YYNOERRORRECOVERY */
  1820. /*
  1821. ** The following code executes when a syntax error first occurs.
  1822. */
  1823. static void yy_syntax_error(
  1824. yyParser *yypParser, /* The parser */
  1825. int yymajor, /* The major type of the error token */
  1826. YYMINORTYPE yyminor /* The minor type of the error token */
  1827. ){
  1828. ParseARG_FETCH;
  1829. #define TOKEN (yyminor.yy0)
  1830. #line 131 "NCDConfigParser_parse.y"
  1831. parser_out->syntax_error = 1;
  1832. #line 1978 "NCDConfigParser_parse.c"
  1833. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  1834. }
  1835. /*
  1836. ** The following is executed when the parser accepts
  1837. */
  1838. static void yy_accept(
  1839. yyParser *yypParser /* The parser */
  1840. ){
  1841. ParseARG_FETCH;
  1842. #ifndef NDEBUG
  1843. if( yyTraceFILE ){
  1844. fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
  1845. }
  1846. #endif
  1847. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  1848. /* Here code is inserted which will be executed whenever the
  1849. ** parser accepts */
  1850. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  1851. }
  1852. /* The main parser program.
  1853. ** The first argument is a pointer to a structure obtained from
  1854. ** "ParseAlloc" which describes the current state of the parser.
  1855. ** The second argument is the major token number. The third is
  1856. ** the minor token. The fourth optional argument is whatever the
  1857. ** user wants (and specified in the grammar) and is available for
  1858. ** use by the action routines.
  1859. **
  1860. ** Inputs:
  1861. ** <ul>
  1862. ** <li> A pointer to the parser (an opaque structure.)
  1863. ** <li> The major token number.
  1864. ** <li> The minor token number.
  1865. ** <li> An option argument of a grammar-specified type.
  1866. ** </ul>
  1867. **
  1868. ** Outputs:
  1869. ** None.
  1870. */
  1871. void Parse(
  1872. void *yyp, /* The parser */
  1873. int yymajor, /* The major token code number */
  1874. ParseTOKENTYPE yyminor /* The value for the token */
  1875. ParseARG_PDECL /* Optional %extra_argument parameter */
  1876. ){
  1877. YYMINORTYPE yyminorunion;
  1878. int yyact; /* The parser action. */
  1879. int yyendofinput; /* True if we are at the end of input */
  1880. #ifdef YYERRORSYMBOL
  1881. int yyerrorhit = 0; /* True if yymajor has invoked an error */
  1882. #endif
  1883. yyParser *yypParser; /* The parser */
  1884. /* (re)initialize the parser, if necessary */
  1885. yypParser = (yyParser*)yyp;
  1886. if( yypParser->yyidx<0 ){
  1887. #if YYSTACKDEPTH<=0
  1888. if( yypParser->yystksz <=0 ){
  1889. /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
  1890. yyminorunion = yyzerominor;
  1891. yyStackOverflow(yypParser, &yyminorunion);
  1892. return;
  1893. }
  1894. #endif
  1895. yypParser->yyidx = 0;
  1896. yypParser->yyerrcnt = -1;
  1897. yypParser->yystack[0].stateno = 0;
  1898. yypParser->yystack[0].major = 0;
  1899. }
  1900. yyminorunion.yy0 = yyminor;
  1901. yyendofinput = (yymajor==0);
  1902. ParseARG_STORE;
  1903. #ifndef NDEBUG
  1904. if( yyTraceFILE ){
  1905. fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
  1906. }
  1907. #endif
  1908. do{
  1909. yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
  1910. if( yyact<YYNSTATE ){
  1911. assert( !yyendofinput ); /* Impossible to shift the $ token */
  1912. yy_shift(yypParser,yyact,yymajor,&yyminorunion);
  1913. yypParser->yyerrcnt--;
  1914. yymajor = YYNOCODE;
  1915. }else if( yyact < YYNSTATE + YYNRULE ){
  1916. yy_reduce(yypParser,yyact-YYNSTATE);
  1917. }else{
  1918. assert( yyact == YY_ERROR_ACTION );
  1919. #ifdef YYERRORSYMBOL
  1920. int yymx;
  1921. #endif
  1922. #ifndef NDEBUG
  1923. if( yyTraceFILE ){
  1924. fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
  1925. }
  1926. #endif
  1927. #ifdef YYERRORSYMBOL
  1928. /* A syntax error has occurred.
  1929. ** The response to an error depends upon whether or not the
  1930. ** grammar defines an error token "ERROR".
  1931. **
  1932. ** This is what we do if the grammar does define ERROR:
  1933. **
  1934. ** * Call the %syntax_error function.
  1935. **
  1936. ** * Begin popping the stack until we enter a state where
  1937. ** it is legal to shift the error symbol, then shift
  1938. ** the error symbol.
  1939. **
  1940. ** * Set the error count to three.
  1941. **
  1942. ** * Begin accepting and shifting new tokens. No new error
  1943. ** processing will occur until three tokens have been
  1944. ** shifted successfully.
  1945. **
  1946. */
  1947. if( yypParser->yyerrcnt<0 ){
  1948. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1949. }
  1950. yymx = yypParser->yystack[yypParser->yyidx].major;
  1951. if( yymx==YYERRORSYMBOL || yyerrorhit ){
  1952. #ifndef NDEBUG
  1953. if( yyTraceFILE ){
  1954. fprintf(yyTraceFILE,"%sDiscard input token %s\n",
  1955. yyTracePrompt,yyTokenName[yymajor]);
  1956. }
  1957. #endif
  1958. yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
  1959. yymajor = YYNOCODE;
  1960. }else{
  1961. while(
  1962. yypParser->yyidx >= 0 &&
  1963. yymx != YYERRORSYMBOL &&
  1964. (yyact = yy_find_reduce_action(
  1965. yypParser->yystack[yypParser->yyidx].stateno,
  1966. YYERRORSYMBOL)) >= YYNSTATE
  1967. ){
  1968. yy_pop_parser_stack(yypParser);
  1969. }
  1970. if( yypParser->yyidx < 0 || yymajor==0 ){
  1971. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1972. yy_parse_failed(yypParser);
  1973. yymajor = YYNOCODE;
  1974. }else if( yymx!=YYERRORSYMBOL ){
  1975. YYMINORTYPE u2;
  1976. u2.YYERRSYMDT = 0;
  1977. yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
  1978. }
  1979. }
  1980. yypParser->yyerrcnt = 3;
  1981. yyerrorhit = 1;
  1982. #elif defined(YYNOERRORRECOVERY)
  1983. /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
  1984. ** do any kind of error recovery. Instead, simply invoke the syntax
  1985. ** error routine and continue going as if nothing had happened.
  1986. **
  1987. ** Applications can set this macro (for example inside %include) if
  1988. ** they intend to abandon the parse upon the first syntax error seen.
  1989. */
  1990. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1991. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1992. yymajor = YYNOCODE;
  1993. #else /* YYERRORSYMBOL is not defined */
  1994. /* This is what we do if the grammar does not define ERROR:
  1995. **
  1996. ** * Report an error message, and throw away the input token.
  1997. **
  1998. ** * If the input token is $, then fail the parse.
  1999. **
  2000. ** As before, subsequent error messages are suppressed until
  2001. ** three input tokens have been successfully shifted.
  2002. */
  2003. if( yypParser->yyerrcnt<=0 ){
  2004. yy_syntax_error(yypParser,yymajor,yyminorunion);
  2005. }
  2006. yypParser->yyerrcnt = 3;
  2007. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  2008. if( yyendofinput ){
  2009. yy_parse_failed(yypParser);
  2010. }
  2011. yymajor = YYNOCODE;
  2012. #endif
  2013. }
  2014. }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
  2015. return;
  2016. }