grammar_nt.c 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235
  1. /* This file is automatically generated by Lemon from input grammar
  2. ** source file "grammar_nt.y". */
  3. /** @brief Lemon parser grammar for N-Triples.
  4. *
  5. * The `lemon' parser generator executable must be in your PATH:
  6. * https://sqlite.org/src/doc/trunk/doc/lemon.html
  7. *
  8. * To generate the parser, run: `lemon ${FILE}'
  9. */
  10. #include "volksdata/codec.h"
  11. #line 38 "../../build/grammar_nt.c"
  12. /**************** End of %include directives **********************************/
  13. /* These constants specify the various numeric values for terminal symbols.
  14. ***************** Begin token definitions *************************************/
  15. #ifndef T_EOF
  16. #define T_EOF 1
  17. #define T_DOT 2
  18. #define T_IRIREF 3
  19. #define T_BNODE 4
  20. #define T_LITERAL 5
  21. #define T_EOL 6
  22. #define T_WS 7
  23. #endif
  24. /**************** End token definitions ***************************************/
  25. /* The next sections is a series of control #defines.
  26. ** various aspects of the generated parser.
  27. ** YYCODETYPE is the data type used to store the integer codes
  28. ** that represent terminal and non-terminal symbols.
  29. ** "unsigned char" is used if there are fewer than
  30. ** 256 symbols. Larger types otherwise.
  31. ** YYNOCODE is a number of type YYCODETYPE that is not used for
  32. ** any terminal or nonterminal symbol.
  33. ** YYFALLBACK If defined, this indicates that one or more tokens
  34. ** (also known as: "terminal symbols") have fall-back
  35. ** values which should be used if the original symbol
  36. ** would not parse. This permits keywords to sometimes
  37. ** be used as identifiers, for example.
  38. ** YYACTIONTYPE is the data type used for "action codes" - numbers
  39. ** that indicate what to do in response to the next
  40. ** token.
  41. ** NTParseTOKENTYPE is the data type used for minor type for terminal
  42. ** symbols. Background: A "minor type" is a semantic
  43. ** value associated with a terminal or non-terminal
  44. ** symbols. For example, for an "ID" terminal symbol,
  45. ** the minor type might be the name of the identifier.
  46. ** Each non-terminal can have a different minor type.
  47. ** Terminal symbols all have the same minor type, though.
  48. ** This macros defines the minor type for terminal
  49. ** symbols.
  50. ** YYMINORTYPE is the data type used for all minor types.
  51. ** This is typically a union of many types, one of
  52. ** which is NTParseTOKENTYPE. The entry in the union
  53. ** for terminal symbols is called "yy0".
  54. ** YYSTACKDEPTH is the maximum depth of the parser's stack. If
  55. ** zero the stack is dynamically sized using realloc()
  56. ** NTParseARG_SDECL A static variable declaration for the %extra_argument
  57. ** NTParseARG_PDECL A parameter declaration for the %extra_argument
  58. ** NTParseARG_PARAM Code to pass %extra_argument as a subroutine parameter
  59. ** NTParseARG_STORE Code to store %extra_argument into yypParser
  60. ** NTParseARG_FETCH Code to extract %extra_argument from yypParser
  61. ** NTParseCTX_* As NTParseARG_ except for %extra_context
  62. ** YYERRORSYMBOL is the code number of the error symbol. If not
  63. ** defined, then do no error processing.
  64. ** YYNSTATE the combined number of states.
  65. ** YYNRULE the number of rules in the grammar
  66. ** YYNTOKEN Number of terminal symbols
  67. ** YY_MAX_SHIFT Maximum value for shift actions
  68. ** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
  69. ** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
  70. ** YY_ERROR_ACTION The yy_action[] code for syntax error
  71. ** YY_ACCEPT_ACTION The yy_action[] code for accept
  72. ** YY_NO_ACTION The yy_action[] code for no-op
  73. ** YY_MIN_REDUCE Minimum value for reduce actions
  74. ** YY_MAX_REDUCE Maximum value for reduce actions
  75. */
  76. #ifndef INTERFACE
  77. # define INTERFACE 1
  78. #endif
  79. /************* Begin control #defines *****************************************/
  80. #define YYCODETYPE unsigned char
  81. #define YYNOCODE 16
  82. #define YYACTIONTYPE unsigned char
  83. #define NTParseTOKENTYPE VOLK_Term *
  84. typedef union {
  85. int yyinit;
  86. NTParseTOKENTYPE yy0;
  87. void * yy17;
  88. VOLK_Triple * yy18;
  89. VOLK_Term * yy22;
  90. } YYMINORTYPE;
  91. #ifndef YYSTACKDEPTH
  92. #define YYSTACKDEPTH 100
  93. #endif
  94. #define NTParseARG_SDECL VOLK_GraphIterator *it ;
  95. #define NTParseARG_PDECL , VOLK_GraphIterator *it
  96. #define NTParseARG_PARAM ,it
  97. #define NTParseARG_FETCH VOLK_GraphIterator *it =yypParser->it ;
  98. #define NTParseARG_STORE yypParser->it =it ;
  99. #define NTParseCTX_SDECL
  100. #define NTParseCTX_PDECL
  101. #define NTParseCTX_PARAM
  102. #define NTParseCTX_FETCH
  103. #define NTParseCTX_STORE
  104. #define YYNSTATE 15
  105. #define YYNRULE 15
  106. #define YYNRULE_WITH_ACTION 1
  107. #define YYNTOKEN 8
  108. #define YY_MAX_SHIFT 14
  109. #define YY_MIN_SHIFTREDUCE 25
  110. #define YY_MAX_SHIFTREDUCE 39
  111. #define YY_ERROR_ACTION 40
  112. #define YY_ACCEPT_ACTION 41
  113. #define YY_NO_ACTION 42
  114. #define YY_MIN_REDUCE 43
  115. #define YY_MAX_REDUCE 57
  116. /************* End control #defines *******************************************/
  117. #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
  118. /* Define the yytestcase() macro to be a no-op if is not already defined
  119. ** otherwise.
  120. **
  121. ** Applications can choose to define yytestcase() in the %include section
  122. ** to a macro that can assist in verifying code coverage. For production
  123. ** code the yytestcase() macro should be turned off. But it is useful
  124. ** for testing.
  125. */
  126. #ifndef yytestcase
  127. # define yytestcase(X)
  128. #endif
  129. /* Next are the tables used to determine what action to take based on the
  130. ** current state and lookahead token. These tables are used to implement
  131. ** functions that take a state number and lookahead value and return an
  132. ** action integer.
  133. **
  134. ** Suppose the action integer is N. Then the action is determined as
  135. ** follows
  136. **
  137. ** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead
  138. ** token onto the stack and goto state N.
  139. **
  140. ** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then
  141. ** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE.
  142. **
  143. ** N == YY_ERROR_ACTION A syntax error has occurred.
  144. **
  145. ** N == YY_ACCEPT_ACTION The parser accepts its input.
  146. **
  147. ** N == YY_NO_ACTION No such action. Denotes unused
  148. ** slots in the yy_action[] table.
  149. **
  150. ** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
  151. ** and YY_MAX_REDUCE
  152. **
  153. ** The action table is constructed as a single large table named yy_action[].
  154. ** Given state S and lookahead X, the action is computed as either:
  155. **
  156. ** (A) N = yy_action[ yy_shift_ofst[S] + X ]
  157. ** (B) N = yy_default[S]
  158. **
  159. ** The (A) formula is preferred. The B formula is used instead if
  160. ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X.
  161. **
  162. ** The formulas above are for computing the action when the lookahead is
  163. ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
  164. ** a reduce action) then the yy_reduce_ofst[] array is used in place of
  165. ** the yy_shift_ofst[] array.
  166. **
  167. ** The following are the tables generated in this section:
  168. **
  169. ** yy_action[] A single table containing all actions.
  170. ** yy_lookahead[] A table containing the lookahead for each entry in
  171. ** yy_action. Used to detect hash collisions.
  172. ** yy_shift_ofst[] For each state, the offset into yy_action for
  173. ** shifting terminals.
  174. ** yy_reduce_ofst[] For each state, the offset into yy_action for
  175. ** shifting non-terminals after a reduce.
  176. ** yy_default[] Default action for each state.
  177. **
  178. *********** Begin parsing tables **********************************************/
  179. #define YY_ACTTAB_COUNT (31)
  180. static const YYACTIONTYPE yy_action[] = {
  181. /* 0 */ 41, 1, 11, 4, 3, 33, 34, 35, 14, 36,
  182. /* 10 */ 39, 9, 3, 5, 39, 30, 31, 8, 10, 36,
  183. /* 20 */ 32, 39, 12, 2, 37, 25, 44, 42, 7, 6,
  184. /* 30 */ 13,
  185. };
  186. static const YYCODETYPE yy_lookahead[] = {
  187. /* 0 */ 8, 9, 10, 11, 12, 3, 4, 5, 1, 6,
  188. /* 10 */ 7, 11, 12, 15, 7, 3, 4, 13, 10, 6,
  189. /* 20 */ 3, 7, 12, 12, 6, 2, 0, 16, 12, 14,
  190. /* 30 */ 10, 16, 16, 16, 16, 8, 8, 8, 8,
  191. };
  192. #define YY_SHIFT_COUNT (14)
  193. #define YY_SHIFT_MIN (0)
  194. #define YY_SHIFT_MAX (26)
  195. static const unsigned char yy_shift_ofst[] = {
  196. /* 0 */ 3, 7, 2, 12, 13, 14, 14, 17, 14, 13,
  197. /* 10 */ 18, 18, 23, 18, 26,
  198. };
  199. #define YY_REDUCE_COUNT (9)
  200. #define YY_REDUCE_MIN (-8)
  201. #define YY_REDUCE_MAX (20)
  202. static const signed char yy_reduce_ofst[] = {
  203. /* 0 */ -8, 0, -2, 4, 8, 10, 11, 15, 16, 20,
  204. };
  205. static const YYACTIONTYPE yy_default[] = {
  206. /* 0 */ 56, 56, 40, 40, 40, 56, 56, 40, 56, 40,
  207. /* 10 */ 46, 45, 40, 47, 40,
  208. };
  209. /********** End of lemon-generated parsing tables *****************************/
  210. /* The next table maps tokens (terminal symbols) into fallback tokens.
  211. ** If a construct like the following:
  212. **
  213. ** %fallback ID X Y Z.
  214. **
  215. ** appears in the grammar, then ID becomes a fallback token for X, Y,
  216. ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
  217. ** but it does not parse, the type of the token is changed to ID and
  218. ** the parse is retried before an error is thrown.
  219. **
  220. ** This feature can be used, for example, to cause some keywords in a language
  221. ** to revert to identifiers if they keyword does not apply in the context where
  222. ** it appears.
  223. */
  224. #ifdef YYFALLBACK
  225. static const YYCODETYPE yyFallback[] = {
  226. };
  227. #endif /* YYFALLBACK */
  228. /* The following structure represents a single element of the
  229. ** parser's stack. Information stored includes:
  230. **
  231. ** + The state number for the parser at this level of the stack.
  232. **
  233. ** + The value of the token stored at this level of the stack.
  234. ** (In other words, the "major" token.)
  235. **
  236. ** + The semantic value stored at this level of the stack. This is
  237. ** the information used by the action routines in the grammar.
  238. ** It is sometimes called the "minor" token.
  239. **
  240. ** After the "shift" half of a SHIFTREDUCE action, the stateno field
  241. ** actually contains the reduce action for the second half of the
  242. ** SHIFTREDUCE.
  243. */
  244. struct yyStackEntry {
  245. YYACTIONTYPE stateno; /* The state-number, or reduce action in SHIFTREDUCE */
  246. YYCODETYPE major; /* The major token value. This is the code
  247. ** number for the token at this stack level */
  248. YYMINORTYPE minor; /* The user-supplied minor token value. This
  249. ** is the value of the token */
  250. };
  251. typedef struct yyStackEntry yyStackEntry;
  252. /* The state of the parser is completely contained in an instance of
  253. ** the following structure */
  254. struct yyParser {
  255. yyStackEntry *yytos; /* Pointer to top element of the stack */
  256. #ifdef YYTRACKMAXSTACKDEPTH
  257. int yyhwm; /* High-water mark of the stack */
  258. #endif
  259. #ifndef YYNOERRORRECOVERY
  260. int yyerrcnt; /* Shifts left before out of the error */
  261. #endif
  262. NTParseARG_SDECL /* A place to hold %extra_argument */
  263. NTParseCTX_SDECL /* A place to hold %extra_context */
  264. #if YYSTACKDEPTH<=0
  265. int yystksz; /* Current side of the stack */
  266. yyStackEntry *yystack; /* The parser's stack */
  267. yyStackEntry yystk0; /* First stack entry */
  268. #else
  269. yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
  270. yyStackEntry *yystackEnd; /* Last entry in the stack */
  271. #endif
  272. };
  273. typedef struct yyParser yyParser;
  274. #include <assert.h>
  275. #ifndef NDEBUG
  276. #include <stdio.h>
  277. static FILE *yyTraceFILE = 0;
  278. static char *yyTracePrompt = 0;
  279. #endif /* NDEBUG */
  280. #ifndef NDEBUG
  281. /*
  282. ** Turn parser tracing on by giving a stream to which to write the trace
  283. ** and a prompt to preface each trace message. Tracing is turned off
  284. ** by making either argument NULL
  285. **
  286. ** Inputs:
  287. ** <ul>
  288. ** <li> A FILE* to which trace output should be written.
  289. ** If NULL, then tracing is turned off.
  290. ** <li> A prefix string written at the beginning of every
  291. ** line of trace output. If NULL, then tracing is
  292. ** turned off.
  293. ** </ul>
  294. **
  295. ** Outputs:
  296. ** None.
  297. */
  298. void NTParseTrace(FILE *TraceFILE, char *zTracePrompt){
  299. yyTraceFILE = TraceFILE;
  300. yyTracePrompt = zTracePrompt;
  301. if( yyTraceFILE==0 ) yyTracePrompt = 0;
  302. else if( yyTracePrompt==0 ) yyTraceFILE = 0;
  303. }
  304. #endif /* NDEBUG */
  305. #if defined(YYCOVERAGE) || !defined(NDEBUG)
  306. /* For tracing shifts, the names of all terminals and nonterminals
  307. ** are required. The following table supplies these names */
  308. static const char *const yyTokenName[] = {
  309. /* 0 */ "$",
  310. /* 1 */ "EOF",
  311. /* 2 */ "DOT",
  312. /* 3 */ "IRIREF",
  313. /* 4 */ "BNODE",
  314. /* 5 */ "LITERAL",
  315. /* 6 */ "EOL",
  316. /* 7 */ "WS",
  317. /* 8 */ "ntriplesDoc",
  318. /* 9 */ "triples",
  319. /* 10 */ "eol",
  320. /* 11 */ "triple",
  321. /* 12 */ "ws",
  322. /* 13 */ "subject",
  323. /* 14 */ "predicate",
  324. /* 15 */ "object",
  325. };
  326. #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
  327. #ifndef NDEBUG
  328. /* For tracing reduce actions, the names of all rules are required.
  329. */
  330. static const char *const yyRuleName[] = {
  331. /* 0 */ "triple ::= ws subject ws predicate ws object ws DOT",
  332. /* 1 */ "ntriplesDoc ::= triples EOF",
  333. /* 2 */ "triples ::= eol",
  334. /* 3 */ "triples ::= triple eol",
  335. /* 4 */ "triples ::= triples triple eol",
  336. /* 5 */ "subject ::= IRIREF",
  337. /* 6 */ "subject ::= BNODE",
  338. /* 7 */ "predicate ::= IRIREF",
  339. /* 8 */ "object ::= IRIREF",
  340. /* 9 */ "object ::= BNODE",
  341. /* 10 */ "object ::= LITERAL",
  342. /* 11 */ "eol ::= EOL",
  343. /* 12 */ "eol ::= eol EOL",
  344. /* 13 */ "ws ::=",
  345. /* 14 */ "ws ::= WS",
  346. };
  347. #endif /* NDEBUG */
  348. #if YYSTACKDEPTH<=0
  349. /*
  350. ** Try to increase the size of the parser stack. Return the number
  351. ** of errors. Return 0 on success.
  352. */
  353. static int yyGrowStack(yyParser *p){
  354. int newSize;
  355. int idx;
  356. yyStackEntry *pNew;
  357. newSize = p->yystksz*2 + 100;
  358. idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
  359. if( p->yystack==&p->yystk0 ){
  360. pNew = malloc(newSize*sizeof(pNew[0]));
  361. if( pNew ) pNew[0] = p->yystk0;
  362. }else{
  363. pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
  364. }
  365. if( pNew ){
  366. p->yystack = pNew;
  367. p->yytos = &p->yystack[idx];
  368. #ifndef NDEBUG
  369. if( yyTraceFILE ){
  370. fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
  371. yyTracePrompt, p->yystksz, newSize);
  372. }
  373. #endif
  374. p->yystksz = newSize;
  375. }
  376. return pNew==0;
  377. }
  378. #endif
  379. /* Datatype of the argument to the memory allocated passed as the
  380. ** second argument to NTParseAlloc() below. This can be changed by
  381. ** putting an appropriate #define in the %include section of the input
  382. ** grammar.
  383. */
  384. #ifndef YYMALLOCARGTYPE
  385. # define YYMALLOCARGTYPE size_t
  386. #endif
  387. /* Initialize a new parser that has already been allocated.
  388. */
  389. void NTParseInit(void *yypRawParser NTParseCTX_PDECL){
  390. yyParser *yypParser = (yyParser*)yypRawParser;
  391. NTParseCTX_STORE
  392. #ifdef YYTRACKMAXSTACKDEPTH
  393. yypParser->yyhwm = 0;
  394. #endif
  395. #if YYSTACKDEPTH<=0
  396. yypParser->yytos = NULL;
  397. yypParser->yystack = NULL;
  398. yypParser->yystksz = 0;
  399. if( yyGrowStack(yypParser) ){
  400. yypParser->yystack = &yypParser->yystk0;
  401. yypParser->yystksz = 1;
  402. }
  403. #endif
  404. #ifndef YYNOERRORRECOVERY
  405. yypParser->yyerrcnt = -1;
  406. #endif
  407. yypParser->yytos = yypParser->yystack;
  408. yypParser->yystack[0].stateno = 0;
  409. yypParser->yystack[0].major = 0;
  410. #if YYSTACKDEPTH>0
  411. yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1];
  412. #endif
  413. }
  414. #ifndef NTParse_ENGINEALWAYSONSTACK
  415. /*
  416. ** This function allocates a new parser.
  417. ** The only argument is a pointer to a function which works like
  418. ** malloc.
  419. **
  420. ** Inputs:
  421. ** A pointer to the function used to allocate memory.
  422. **
  423. ** Outputs:
  424. ** A pointer to a parser. This pointer is used in subsequent calls
  425. ** to NTParse and NTParseFree.
  426. */
  427. void *NTParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) NTParseCTX_PDECL){
  428. yyParser *yypParser;
  429. yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
  430. if( yypParser ){
  431. NTParseCTX_STORE
  432. NTParseInit(yypParser NTParseCTX_PARAM);
  433. }
  434. return (void*)yypParser;
  435. }
  436. #endif /* NTParse_ENGINEALWAYSONSTACK */
  437. /* The following function deletes the "minor type" or semantic value
  438. ** associated with a symbol. The symbol can be either a terminal
  439. ** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
  440. ** a pointer to the value to be deleted. The code used to do the
  441. ** deletions is derived from the %destructor and/or %token_destructor
  442. ** directives of the input grammar.
  443. */
  444. static void yy_destructor(
  445. yyParser *yypParser, /* The parser */
  446. YYCODETYPE yymajor, /* Type code for object to destroy */
  447. YYMINORTYPE *yypminor /* The object to be destroyed */
  448. ){
  449. NTParseARG_FETCH
  450. NTParseCTX_FETCH
  451. switch( yymajor ){
  452. /* Here is inserted the actions which take place when a
  453. ** terminal or non-terminal is destroyed. This can happen
  454. ** when the symbol is popped from the stack during a
  455. ** reduce or during error processing or when a parser is
  456. ** being destroyed before it is finished parsing.
  457. **
  458. ** Note: during a reduce, the only symbols destroyed are those
  459. ** which appear on the RHS of the rule, but which are *not* used
  460. ** inside the C code.
  461. */
  462. /********* Begin destructor definitions ***************************************/
  463. case 11: /* triple */
  464. {
  465. #line 32 "grammar_nt.y"
  466. VOLK_triple_free ((yypminor->yy18));
  467. #line 512 "../../build/grammar_nt.c"
  468. }
  469. break;
  470. case 13: /* subject */
  471. {
  472. #line 39 "grammar_nt.y"
  473. (void)(it); VOLK_term_free ((yypminor->yy22));
  474. #line 519 "../../build/grammar_nt.c"
  475. }
  476. break;
  477. case 14: /* predicate */
  478. case 15: /* object */
  479. {
  480. #line 44 "grammar_nt.y"
  481. VOLK_term_free ((yypminor->yy22));
  482. #line 527 "../../build/grammar_nt.c"
  483. }
  484. break;
  485. /********* End destructor definitions *****************************************/
  486. default: break; /* If no destructor action specified: do nothing */
  487. }
  488. }
  489. /*
  490. ** Pop the parser's stack once.
  491. **
  492. ** If there is a destructor routine associated with the token which
  493. ** is popped from the stack, then call it.
  494. */
  495. static void yy_pop_parser_stack(yyParser *pParser){
  496. yyStackEntry *yytos;
  497. assert( pParser->yytos!=0 );
  498. assert( pParser->yytos > pParser->yystack );
  499. yytos = pParser->yytos--;
  500. #ifndef NDEBUG
  501. if( yyTraceFILE ){
  502. fprintf(yyTraceFILE,"%sPopping %s\n",
  503. yyTracePrompt,
  504. yyTokenName[yytos->major]);
  505. }
  506. #endif
  507. yy_destructor(pParser, yytos->major, &yytos->minor);
  508. }
  509. /*
  510. ** Clear all secondary memory allocations from the parser
  511. */
  512. void NTParseFinalize(void *p){
  513. yyParser *pParser = (yyParser*)p;
  514. while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
  515. #if YYSTACKDEPTH<=0
  516. if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
  517. #endif
  518. }
  519. #ifndef NTParse_ENGINEALWAYSONSTACK
  520. /*
  521. ** Deallocate and destroy a parser. Destructors are called for
  522. ** all stack elements before shutting the parser down.
  523. **
  524. ** If the YYPARSEFREENEVERNULL macro exists (for example because it
  525. ** is defined in a %include section of the input grammar) then it is
  526. ** assumed that the input pointer is never NULL.
  527. */
  528. void NTParseFree(
  529. void *p, /* The parser to be deleted */
  530. void (*freeProc)(void*) /* Function used to reclaim memory */
  531. ){
  532. #ifndef YYPARSEFREENEVERNULL
  533. if( p==0 ) return;
  534. #endif
  535. NTParseFinalize(p);
  536. (*freeProc)(p);
  537. }
  538. #endif /* NTParse_ENGINEALWAYSONSTACK */
  539. /*
  540. ** Return the peak depth of the stack for a parser.
  541. */
  542. #ifdef YYTRACKMAXSTACKDEPTH
  543. int NTParseStackPeak(void *p){
  544. yyParser *pParser = (yyParser*)p;
  545. return pParser->yyhwm;
  546. }
  547. #endif
  548. /* This array of booleans keeps track of the parser statement
  549. ** coverage. The element yycoverage[X][Y] is set when the parser
  550. ** is in state X and has a lookahead token Y. In a well-tested
  551. ** systems, every element of this matrix should end up being set.
  552. */
  553. #if defined(YYCOVERAGE)
  554. static unsigned char yycoverage[YYNSTATE][YYNTOKEN];
  555. #endif
  556. /*
  557. ** Write into out a description of every state/lookahead combination that
  558. **
  559. ** (1) has not been used by the parser, and
  560. ** (2) is not a syntax error.
  561. **
  562. ** Return the number of missed state/lookahead combinations.
  563. */
  564. #if defined(YYCOVERAGE)
  565. int NTParseCoverage(FILE *out){
  566. int stateno, iLookAhead, i;
  567. int nMissed = 0;
  568. for(stateno=0; stateno<YYNSTATE; stateno++){
  569. i = yy_shift_ofst[stateno];
  570. for(iLookAhead=0; iLookAhead<YYNTOKEN; iLookAhead++){
  571. if( yy_lookahead[i+iLookAhead]!=iLookAhead ) continue;
  572. if( yycoverage[stateno][iLookAhead]==0 ) nMissed++;
  573. if( out ){
  574. fprintf(out,"State %d lookahead %s %s\n", stateno,
  575. yyTokenName[iLookAhead],
  576. yycoverage[stateno][iLookAhead] ? "ok" : "missed");
  577. }
  578. }
  579. }
  580. return nMissed;
  581. }
  582. #endif
  583. /*
  584. ** Find the appropriate action for a parser given the terminal
  585. ** look-ahead token iLookAhead.
  586. */
  587. static YYACTIONTYPE yy_find_shift_action(
  588. YYCODETYPE iLookAhead, /* The look-ahead token */
  589. YYACTIONTYPE stateno /* Current state number */
  590. ){
  591. int i;
  592. if( stateno>YY_MAX_SHIFT ) return stateno;
  593. assert( stateno <= YY_SHIFT_COUNT );
  594. #if defined(YYCOVERAGE)
  595. yycoverage[stateno][iLookAhead] = 1;
  596. #endif
  597. do{
  598. i = yy_shift_ofst[stateno];
  599. assert( i>=0 );
  600. assert( i<=YY_ACTTAB_COUNT );
  601. assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD );
  602. assert( iLookAhead!=YYNOCODE );
  603. assert( iLookAhead < YYNTOKEN );
  604. i += iLookAhead;
  605. assert( i<(int)YY_NLOOKAHEAD );
  606. if( yy_lookahead[i]!=iLookAhead ){
  607. #ifdef YYFALLBACK
  608. YYCODETYPE iFallback; /* Fallback token */
  609. assert( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) );
  610. iFallback = yyFallback[iLookAhead];
  611. if( iFallback!=0 ){
  612. #ifndef NDEBUG
  613. if( yyTraceFILE ){
  614. fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
  615. yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
  616. }
  617. #endif
  618. assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
  619. iLookAhead = iFallback;
  620. continue;
  621. }
  622. #endif
  623. #ifdef YYWILDCARD
  624. {
  625. int j = i - iLookAhead + YYWILDCARD;
  626. assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) );
  627. if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){
  628. #ifndef NDEBUG
  629. if( yyTraceFILE ){
  630. fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
  631. yyTracePrompt, yyTokenName[iLookAhead],
  632. yyTokenName[YYWILDCARD]);
  633. }
  634. #endif /* NDEBUG */
  635. return yy_action[j];
  636. }
  637. }
  638. #endif /* YYWILDCARD */
  639. return yy_default[stateno];
  640. }else{
  641. assert( i>=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) );
  642. return yy_action[i];
  643. }
  644. }while(1);
  645. }
  646. /*
  647. ** Find the appropriate action for a parser given the non-terminal
  648. ** look-ahead token iLookAhead.
  649. */
  650. static YYACTIONTYPE yy_find_reduce_action(
  651. YYACTIONTYPE stateno, /* Current state number */
  652. YYCODETYPE iLookAhead /* The look-ahead token */
  653. ){
  654. int i;
  655. #ifdef YYERRORSYMBOL
  656. if( stateno>YY_REDUCE_COUNT ){
  657. return yy_default[stateno];
  658. }
  659. #else
  660. assert( stateno<=YY_REDUCE_COUNT );
  661. #endif
  662. i = yy_reduce_ofst[stateno];
  663. assert( iLookAhead!=YYNOCODE );
  664. i += iLookAhead;
  665. #ifdef YYERRORSYMBOL
  666. if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
  667. return yy_default[stateno];
  668. }
  669. #else
  670. assert( i>=0 && i<YY_ACTTAB_COUNT );
  671. assert( yy_lookahead[i]==iLookAhead );
  672. #endif
  673. return yy_action[i];
  674. }
  675. /*
  676. ** The following routine is called if the stack overflows.
  677. */
  678. static void yyStackOverflow(yyParser *yypParser){
  679. NTParseARG_FETCH
  680. NTParseCTX_FETCH
  681. #ifndef NDEBUG
  682. if( yyTraceFILE ){
  683. fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
  684. }
  685. #endif
  686. while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
  687. /* Here code is inserted which will execute if the parser
  688. ** stack every overflows */
  689. /******** Begin %stack_overflow code ******************************************/
  690. /******** End %stack_overflow code ********************************************/
  691. NTParseARG_STORE /* Suppress warning about unused %extra_argument var */
  692. NTParseCTX_STORE
  693. }
  694. /*
  695. ** Print tracing information for a SHIFT action
  696. */
  697. #ifndef NDEBUG
  698. static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){
  699. if( yyTraceFILE ){
  700. if( yyNewState<YYNSTATE ){
  701. fprintf(yyTraceFILE,"%s%s '%s', go to state %d\n",
  702. yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
  703. yyNewState);
  704. }else{
  705. fprintf(yyTraceFILE,"%s%s '%s', pending reduce %d\n",
  706. yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
  707. yyNewState - YY_MIN_REDUCE);
  708. }
  709. }
  710. }
  711. #else
  712. # define yyTraceShift(X,Y,Z)
  713. #endif
  714. /*
  715. ** Perform a shift action.
  716. */
  717. static void yy_shift(
  718. yyParser *yypParser, /* The parser to be shifted */
  719. YYACTIONTYPE yyNewState, /* The new state to shift in */
  720. YYCODETYPE yyMajor, /* The major token to shift in */
  721. NTParseTOKENTYPE yyMinor /* The minor token to shift in */
  722. ){
  723. yyStackEntry *yytos;
  724. yypParser->yytos++;
  725. #ifdef YYTRACKMAXSTACKDEPTH
  726. if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
  727. yypParser->yyhwm++;
  728. assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
  729. }
  730. #endif
  731. #if YYSTACKDEPTH>0
  732. if( yypParser->yytos>yypParser->yystackEnd ){
  733. yypParser->yytos--;
  734. yyStackOverflow(yypParser);
  735. return;
  736. }
  737. #else
  738. if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
  739. if( yyGrowStack(yypParser) ){
  740. yypParser->yytos--;
  741. yyStackOverflow(yypParser);
  742. return;
  743. }
  744. }
  745. #endif
  746. if( yyNewState > YY_MAX_SHIFT ){
  747. yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
  748. }
  749. yytos = yypParser->yytos;
  750. yytos->stateno = yyNewState;
  751. yytos->major = yyMajor;
  752. yytos->minor.yy0 = yyMinor;
  753. yyTraceShift(yypParser, yyNewState, "Shift");
  754. }
  755. /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
  756. ** of that rule */
  757. static const YYCODETYPE yyRuleInfoLhs[] = {
  758. 11, /* (0) triple ::= ws subject ws predicate ws object ws DOT */
  759. 8, /* (1) ntriplesDoc ::= triples EOF */
  760. 9, /* (2) triples ::= eol */
  761. 9, /* (3) triples ::= triple eol */
  762. 9, /* (4) triples ::= triples triple eol */
  763. 13, /* (5) subject ::= IRIREF */
  764. 13, /* (6) subject ::= BNODE */
  765. 14, /* (7) predicate ::= IRIREF */
  766. 15, /* (8) object ::= IRIREF */
  767. 15, /* (9) object ::= BNODE */
  768. 15, /* (10) object ::= LITERAL */
  769. 10, /* (11) eol ::= EOL */
  770. 10, /* (12) eol ::= eol EOL */
  771. 12, /* (13) ws ::= */
  772. 12, /* (14) ws ::= WS */
  773. };
  774. /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
  775. ** of symbols on the right-hand side of that rule. */
  776. static const signed char yyRuleInfoNRhs[] = {
  777. -8, /* (0) triple ::= ws subject ws predicate ws object ws DOT */
  778. -2, /* (1) ntriplesDoc ::= triples EOF */
  779. -1, /* (2) triples ::= eol */
  780. -2, /* (3) triples ::= triple eol */
  781. -3, /* (4) triples ::= triples triple eol */
  782. -1, /* (5) subject ::= IRIREF */
  783. -1, /* (6) subject ::= BNODE */
  784. -1, /* (7) predicate ::= IRIREF */
  785. -1, /* (8) object ::= IRIREF */
  786. -1, /* (9) object ::= BNODE */
  787. -1, /* (10) object ::= LITERAL */
  788. -1, /* (11) eol ::= EOL */
  789. -2, /* (12) eol ::= eol EOL */
  790. 0, /* (13) ws ::= */
  791. -1, /* (14) ws ::= WS */
  792. };
  793. static void yy_accept(yyParser*); /* Forward Declaration */
  794. /*
  795. ** Perform a reduce action and the shift that must immediately
  796. ** follow the reduce.
  797. **
  798. ** The yyLookahead and yyLookaheadToken parameters provide reduce actions
  799. ** access to the lookahead token (if any). The yyLookahead will be YYNOCODE
  800. ** if the lookahead token has already been consumed. As this procedure is
  801. ** only called from one place, optimizing compilers will in-line it, which
  802. ** means that the extra parameters have no performance impact.
  803. */
  804. static YYACTIONTYPE yy_reduce(
  805. yyParser *yypParser, /* The parser */
  806. unsigned int yyruleno, /* Number of the rule by which to reduce */
  807. int yyLookahead, /* Lookahead token, or YYNOCODE if none */
  808. NTParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */
  809. NTParseCTX_PDECL /* %extra_context */
  810. ){
  811. int yygoto; /* The next state */
  812. YYACTIONTYPE yyact; /* The next action */
  813. yyStackEntry *yymsp; /* The top of the parser's stack */
  814. int yysize; /* Amount to pop the stack */
  815. NTParseARG_FETCH
  816. (void)yyLookahead;
  817. (void)yyLookaheadToken;
  818. yymsp = yypParser->yytos;
  819. switch( yyruleno ){
  820. /* Beginning here are the reduction cases. A typical example
  821. ** follows:
  822. ** case 0:
  823. ** #line <lineno> <grammarfile>
  824. ** { ... } // User supplied code
  825. ** #line <lineno> <thisfile>
  826. ** break;
  827. */
  828. /********** Begin reduce actions **********************************************/
  829. case 0: /* triple ::= ws subject ws predicate ws object ws DOT */
  830. #line 33 "grammar_nt.y"
  831. {
  832. yymsp[-7].minor.yy18 = VOLK_triple_new (yymsp[-6].minor.yy22, yymsp[-4].minor.yy22, yymsp[-2].minor.yy22);
  833. VOLK_graph_add_iter (it, yymsp[-7].minor.yy18);
  834. }
  835. #line 897 "../../build/grammar_nt.c"
  836. break;
  837. case 3: /* triples ::= triple eol */
  838. { yy_destructor(yypParser,11,&yymsp[-1].minor);
  839. #line 28 "grammar_nt.y"
  840. {
  841. }
  842. #line 904 "../../build/grammar_nt.c"
  843. }
  844. break;
  845. case 4: /* triples ::= triples triple eol */
  846. #line 29 "grammar_nt.y"
  847. {
  848. }
  849. #line 911 "../../build/grammar_nt.c"
  850. yy_destructor(yypParser,11,&yymsp[-1].minor);
  851. break;
  852. default:
  853. /* (1) ntriplesDoc ::= triples EOF */ yytestcase(yyruleno==1);
  854. /* (2) triples ::= eol */ yytestcase(yyruleno==2);
  855. /* (5) subject ::= IRIREF */ yytestcase(yyruleno==5);
  856. /* (6) subject ::= BNODE */ yytestcase(yyruleno==6);
  857. /* (7) predicate ::= IRIREF */ yytestcase(yyruleno==7);
  858. /* (8) object ::= IRIREF */ yytestcase(yyruleno==8);
  859. /* (9) object ::= BNODE */ yytestcase(yyruleno==9);
  860. /* (10) object ::= LITERAL */ yytestcase(yyruleno==10);
  861. /* (11) eol ::= EOL */ yytestcase(yyruleno==11);
  862. /* (12) eol ::= eol EOL */ yytestcase(yyruleno==12);
  863. /* (13) ws ::= */ yytestcase(yyruleno==13);
  864. /* (14) ws ::= WS */ yytestcase(yyruleno==14);
  865. break;
  866. /********** End reduce actions ************************************************/
  867. };
  868. assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
  869. yygoto = yyRuleInfoLhs[yyruleno];
  870. yysize = yyRuleInfoNRhs[yyruleno];
  871. yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
  872. /* There are no SHIFTREDUCE actions on nonterminals because the table
  873. ** generator has simplified them to pure REDUCE actions. */
  874. assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );
  875. /* It is not possible for a REDUCE to be followed by an error */
  876. assert( yyact!=YY_ERROR_ACTION );
  877. yymsp += yysize+1;
  878. yypParser->yytos = yymsp;
  879. yymsp->stateno = (YYACTIONTYPE)yyact;
  880. yymsp->major = (YYCODETYPE)yygoto;
  881. yyTraceShift(yypParser, yyact, "... then shift");
  882. return yyact;
  883. }
  884. /*
  885. ** The following code executes when the parse fails
  886. */
  887. #ifndef YYNOERRORRECOVERY
  888. static void yy_parse_failed(
  889. yyParser *yypParser /* The parser */
  890. ){
  891. NTParseARG_FETCH
  892. NTParseCTX_FETCH
  893. #ifndef NDEBUG
  894. if( yyTraceFILE ){
  895. fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
  896. }
  897. #endif
  898. while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
  899. /* Here code is inserted which will be executed whenever the
  900. ** parser fails */
  901. /************ Begin %parse_failure code ***************************************/
  902. /************ End %parse_failure code *****************************************/
  903. NTParseARG_STORE /* Suppress warning about unused %extra_argument variable */
  904. NTParseCTX_STORE
  905. }
  906. #endif /* YYNOERRORRECOVERY */
  907. /*
  908. ** The following code executes when a syntax error first occurs.
  909. */
  910. static void yy_syntax_error(
  911. yyParser *yypParser, /* The parser */
  912. int yymajor, /* The major type of the error token */
  913. NTParseTOKENTYPE yyminor /* The minor type of the error token */
  914. ){
  915. NTParseARG_FETCH
  916. NTParseCTX_FETCH
  917. #define TOKEN yyminor
  918. /************ Begin %syntax_error code ****************************************/
  919. /************ End %syntax_error code ******************************************/
  920. NTParseARG_STORE /* Suppress warning about unused %extra_argument variable */
  921. NTParseCTX_STORE
  922. }
  923. /*
  924. ** The following is executed when the parser accepts
  925. */
  926. static void yy_accept(
  927. yyParser *yypParser /* The parser */
  928. ){
  929. NTParseARG_FETCH
  930. NTParseCTX_FETCH
  931. #ifndef NDEBUG
  932. if( yyTraceFILE ){
  933. fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
  934. }
  935. #endif
  936. #ifndef YYNOERRORRECOVERY
  937. yypParser->yyerrcnt = -1;
  938. #endif
  939. assert( yypParser->yytos==yypParser->yystack );
  940. /* Here code is inserted which will be executed whenever the
  941. ** parser accepts */
  942. /*********** Begin %parse_accept code *****************************************/
  943. /*********** End %parse_accept code *******************************************/
  944. NTParseARG_STORE /* Suppress warning about unused %extra_argument variable */
  945. NTParseCTX_STORE
  946. }
  947. /* The main parser program.
  948. ** The first argument is a pointer to a structure obtained from
  949. ** "NTParseAlloc" which describes the current state of the parser.
  950. ** The second argument is the major token number. The third is
  951. ** the minor token. The fourth optional argument is whatever the
  952. ** user wants (and specified in the grammar) and is available for
  953. ** use by the action routines.
  954. **
  955. ** Inputs:
  956. ** <ul>
  957. ** <li> A pointer to the parser (an opaque structure.)
  958. ** <li> The major token number.
  959. ** <li> The minor token number.
  960. ** <li> An option argument of a grammar-specified type.
  961. ** </ul>
  962. **
  963. ** Outputs:
  964. ** None.
  965. */
  966. void NTParse(
  967. void *yyp, /* The parser */
  968. int yymajor, /* The major token code number */
  969. NTParseTOKENTYPE yyminor /* The value for the token */
  970. NTParseARG_PDECL /* Optional %extra_argument parameter */
  971. ){
  972. YYMINORTYPE yyminorunion;
  973. YYACTIONTYPE yyact; /* The parser action. */
  974. #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
  975. int yyendofinput; /* True if we are at the end of input */
  976. #endif
  977. #ifdef YYERRORSYMBOL
  978. int yyerrorhit = 0; /* True if yymajor has invoked an error */
  979. #endif
  980. yyParser *yypParser = (yyParser*)yyp; /* The parser */
  981. NTParseCTX_FETCH
  982. NTParseARG_STORE
  983. assert( yypParser->yytos!=0 );
  984. #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
  985. yyendofinput = (yymajor==0);
  986. #endif
  987. yyact = yypParser->yytos->stateno;
  988. #ifndef NDEBUG
  989. if( yyTraceFILE ){
  990. if( yyact < YY_MIN_REDUCE ){
  991. fprintf(yyTraceFILE,"%sInput '%s' in state %d\n",
  992. yyTracePrompt,yyTokenName[yymajor],yyact);
  993. }else{
  994. fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
  995. yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE);
  996. }
  997. }
  998. #endif
  999. while(1){ /* Exit by "break" */
  1000. assert( yypParser->yytos>=yypParser->yystack );
  1001. assert( yyact==yypParser->yytos->stateno );
  1002. yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);
  1003. if( yyact >= YY_MIN_REDUCE ){
  1004. unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */
  1005. #ifndef NDEBUG
  1006. assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
  1007. if( yyTraceFILE ){
  1008. int yysize = yyRuleInfoNRhs[yyruleno];
  1009. if( yysize ){
  1010. fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
  1011. yyTracePrompt,
  1012. yyruleno, yyRuleName[yyruleno],
  1013. yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action",
  1014. yypParser->yytos[yysize].stateno);
  1015. }else{
  1016. fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n",
  1017. yyTracePrompt, yyruleno, yyRuleName[yyruleno],
  1018. yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action");
  1019. }
  1020. }
  1021. #endif /* NDEBUG */
  1022. /* Check that the stack is large enough to grow by a single entry
  1023. ** if the RHS of the rule is empty. This ensures that there is room
  1024. ** enough on the stack to push the LHS value */
  1025. if( yyRuleInfoNRhs[yyruleno]==0 ){
  1026. #ifdef YYTRACKMAXSTACKDEPTH
  1027. if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
  1028. yypParser->yyhwm++;
  1029. assert( yypParser->yyhwm ==
  1030. (int)(yypParser->yytos - yypParser->yystack));
  1031. }
  1032. #endif
  1033. #if YYSTACKDEPTH>0
  1034. if( yypParser->yytos>=yypParser->yystackEnd ){
  1035. yyStackOverflow(yypParser);
  1036. break;
  1037. }
  1038. #else
  1039. if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
  1040. if( yyGrowStack(yypParser) ){
  1041. yyStackOverflow(yypParser);
  1042. break;
  1043. }
  1044. }
  1045. #endif
  1046. }
  1047. yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor NTParseCTX_PARAM);
  1048. }else if( yyact <= YY_MAX_SHIFTREDUCE ){
  1049. yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor);
  1050. #ifndef YYNOERRORRECOVERY
  1051. yypParser->yyerrcnt--;
  1052. #endif
  1053. break;
  1054. }else if( yyact==YY_ACCEPT_ACTION ){
  1055. yypParser->yytos--;
  1056. yy_accept(yypParser);
  1057. return;
  1058. }else{
  1059. assert( yyact == YY_ERROR_ACTION );
  1060. yyminorunion.yy0 = yyminor;
  1061. #ifdef YYERRORSYMBOL
  1062. int yymx;
  1063. #endif
  1064. #ifndef NDEBUG
  1065. if( yyTraceFILE ){
  1066. fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
  1067. }
  1068. #endif
  1069. #ifdef YYERRORSYMBOL
  1070. /* A syntax error has occurred.
  1071. ** The response to an error depends upon whether or not the
  1072. ** grammar defines an error token "ERROR".
  1073. **
  1074. ** This is what we do if the grammar does define ERROR:
  1075. **
  1076. ** * Call the %syntax_error function.
  1077. **
  1078. ** * Begin popping the stack until we enter a state where
  1079. ** it is legal to shift the error symbol, then shift
  1080. ** the error symbol.
  1081. **
  1082. ** * Set the error count to three.
  1083. **
  1084. ** * Begin accepting and shifting new tokens. No new error
  1085. ** processing will occur until three tokens have been
  1086. ** shifted successfully.
  1087. **
  1088. */
  1089. if( yypParser->yyerrcnt<0 ){
  1090. yy_syntax_error(yypParser,yymajor,yyminor);
  1091. }
  1092. yymx = yypParser->yytos->major;
  1093. if( yymx==YYERRORSYMBOL || yyerrorhit ){
  1094. #ifndef NDEBUG
  1095. if( yyTraceFILE ){
  1096. fprintf(yyTraceFILE,"%sDiscard input token %s\n",
  1097. yyTracePrompt,yyTokenName[yymajor]);
  1098. }
  1099. #endif
  1100. yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
  1101. yymajor = YYNOCODE;
  1102. }else{
  1103. while( yypParser->yytos > yypParser->yystack ){
  1104. yyact = yy_find_reduce_action(yypParser->yytos->stateno,
  1105. YYERRORSYMBOL);
  1106. if( yyact<=YY_MAX_SHIFTREDUCE ) break;
  1107. yy_pop_parser_stack(yypParser);
  1108. }
  1109. if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){
  1110. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1111. yy_parse_failed(yypParser);
  1112. #ifndef YYNOERRORRECOVERY
  1113. yypParser->yyerrcnt = -1;
  1114. #endif
  1115. yymajor = YYNOCODE;
  1116. }else if( yymx!=YYERRORSYMBOL ){
  1117. yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
  1118. }
  1119. }
  1120. yypParser->yyerrcnt = 3;
  1121. yyerrorhit = 1;
  1122. if( yymajor==YYNOCODE ) break;
  1123. yyact = yypParser->yytos->stateno;
  1124. #elif defined(YYNOERRORRECOVERY)
  1125. /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
  1126. ** do any kind of error recovery. Instead, simply invoke the syntax
  1127. ** error routine and continue going as if nothing had happened.
  1128. **
  1129. ** Applications can set this macro (for example inside %include) if
  1130. ** they intend to abandon the parse upon the first syntax error seen.
  1131. */
  1132. yy_syntax_error(yypParser,yymajor, yyminor);
  1133. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1134. break;
  1135. #else /* YYERRORSYMBOL is not defined */
  1136. /* This is what we do if the grammar does not define ERROR:
  1137. **
  1138. ** * Report an error message, and throw away the input token.
  1139. **
  1140. ** * If the input token is $, then fail the parse.
  1141. **
  1142. ** As before, subsequent error messages are suppressed until
  1143. ** three input tokens have been successfully shifted.
  1144. */
  1145. if( yypParser->yyerrcnt<=0 ){
  1146. yy_syntax_error(yypParser,yymajor, yyminor);
  1147. }
  1148. yypParser->yyerrcnt = 3;
  1149. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1150. if( yyendofinput ){
  1151. yy_parse_failed(yypParser);
  1152. #ifndef YYNOERRORRECOVERY
  1153. yypParser->yyerrcnt = -1;
  1154. #endif
  1155. }
  1156. break;
  1157. #endif
  1158. }
  1159. }
  1160. #ifndef NDEBUG
  1161. if( yyTraceFILE ){
  1162. yyStackEntry *i;
  1163. char cDiv = '[';
  1164. fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
  1165. for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
  1166. fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
  1167. cDiv = ' ';
  1168. }
  1169. fprintf(yyTraceFILE,"]\n");
  1170. }
  1171. #endif
  1172. return;
  1173. }
  1174. /*
  1175. ** Return the fallback token corresponding to canonical token iToken, or
  1176. ** 0 if iToken has no fallback.
  1177. */
  1178. int NTParseFallback(int iToken){
  1179. #ifdef YYFALLBACK
  1180. assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) );
  1181. return yyFallback[iToken];
  1182. #else
  1183. (void)iToken;
  1184. return 0;
  1185. #endif
  1186. }