grammar_ttl.c 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742
  1. /* This file is automatically generated by Lemon from input grammar
  2. ** source file "grammar_ttl.y". */
  3. /** @brief Lemon parser grammar for Turtle.
  4. *
  5. * The `lemon' parser generator executable must be in your PATH:
  6. * https://sqlite.org/src/doc/trunk/doc/lemon.html
  7. *
  8. * TTL EBNF: https://www.w3.org/TeamSubmission/turtle/#sec-grammar-grammar
  9. */
  10. #include "volksdata/codec.h"
  11. #line 39 "../../build/grammar_ttl.c"
  12. /**************** End of %include directives **********************************/
  13. /* These constants specify the various numeric values for terminal symbols.
  14. ***************** Begin token definitions *************************************/
  15. #ifndef T_PERIOD
  16. #define T_PERIOD 1
  17. #define T_SEMICOLON 2
  18. #define T_COMMA 3
  19. #define T_STRING 4
  20. #define T_INTEGER 5
  21. #define T_DOUBLE 6
  22. #define T_DECIMAL 7
  23. #define T_BOOLEAN 8
  24. #define T_BNODE_ID 9
  25. #define T_QNAME 10
  26. #define T_IRIREF 11
  27. #define T_LANGTAG 12
  28. #define T_PREFIX 13
  29. #define T_COLON 14
  30. #define T_EOF 15
  31. #define T_WS 16
  32. #define T_BASE 17
  33. #define T_RDF_TYPE 18
  34. #define T_DTYPE_MARKER 19
  35. #define T_ANON 20
  36. #define T_LBRACKET 21
  37. #define T_RBRACKET 22
  38. #define T_LPAREN 23
  39. #define T_RPAREN 24
  40. #endif
  41. /**************** End token definitions ***************************************/
  42. /* The next sections is a series of control #defines.
  43. ** various aspects of the generated parser.
  44. ** YYCODETYPE is the data type used to store the integer codes
  45. ** that represent terminal and non-terminal symbols.
  46. ** "unsigned char" is used if there are fewer than
  47. ** 256 symbols. Larger types otherwise.
  48. ** YYNOCODE is a number of type YYCODETYPE that is not used for
  49. ** any terminal or nonterminal symbol.
  50. ** YYFALLBACK If defined, this indicates that one or more tokens
  51. ** (also known as: "terminal symbols") have fall-back
  52. ** values which should be used if the original symbol
  53. ** would not parse. This permits keywords to sometimes
  54. ** be used as identifiers, for example.
  55. ** YYACTIONTYPE is the data type used for "action codes" - numbers
  56. ** that indicate what to do in response to the next
  57. ** token.
  58. ** TTLParseTOKENTYPE is the data type used for minor type for terminal
  59. ** symbols. Background: A "minor type" is a semantic
  60. ** value associated with a terminal or non-terminal
  61. ** symbols. For example, for an "ID" terminal symbol,
  62. ** the minor type might be the name of the identifier.
  63. ** Each non-terminal can have a different minor type.
  64. ** Terminal symbols all have the same minor type, though.
  65. ** This macros defines the minor type for terminal
  66. ** symbols.
  67. ** YYMINORTYPE is the data type used for all minor types.
  68. ** This is typically a union of many types, one of
  69. ** which is TTLParseTOKENTYPE. The entry in the union
  70. ** for terminal symbols is called "yy0".
  71. ** YYSTACKDEPTH is the maximum depth of the parser's stack. If
  72. ** zero the stack is dynamically sized using realloc()
  73. ** TTLParseARG_SDECL A static variable declaration for the %extra_argument
  74. ** TTLParseARG_PDECL A parameter declaration for the %extra_argument
  75. ** TTLParseARG_PARAM Code to pass %extra_argument as a subroutine parameter
  76. ** TTLParseARG_STORE Code to store %extra_argument into yypParser
  77. ** TTLParseARG_FETCH Code to extract %extra_argument from yypParser
  78. ** TTLParseCTX_* As TTLParseARG_ except for %extra_context
  79. ** YYERRORSYMBOL is the code number of the error symbol. If not
  80. ** defined, then do no error processing.
  81. ** YYNSTATE the combined number of states.
  82. ** YYNRULE the number of rules in the grammar
  83. ** YYNTOKEN Number of terminal symbols
  84. ** YY_MAX_SHIFT Maximum value for shift actions
  85. ** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
  86. ** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
  87. ** YY_ERROR_ACTION The yy_action[] code for syntax error
  88. ** YY_ACCEPT_ACTION The yy_action[] code for accept
  89. ** YY_NO_ACTION The yy_action[] code for no-op
  90. ** YY_MIN_REDUCE Minimum value for reduce actions
  91. ** YY_MAX_REDUCE Maximum value for reduce actions
  92. */
  93. #ifndef INTERFACE
  94. # define INTERFACE 1
  95. #endif
  96. /************* Begin control #defines *****************************************/
  97. #define YYCODETYPE unsigned char
  98. #define YYNOCODE 42
  99. #define YYACTIONTYPE unsigned char
  100. #define TTLParseTOKENTYPE char *
  101. typedef union {
  102. int yyinit;
  103. TTLParseTOKENTYPE yy0;
  104. char * yy1;
  105. VOLK_TermSet * yy22;
  106. VOLK_LinkMap * yy34;
  107. VOLK_Term * yy50;
  108. } YYMINORTYPE;
  109. #ifndef YYSTACKDEPTH
  110. #define YYSTACKDEPTH 100
  111. #endif
  112. #define TTLParseARG_SDECL VOLK_TTLParserState *state ;
  113. #define TTLParseARG_PDECL , VOLK_TTLParserState *state
  114. #define TTLParseARG_PARAM ,state
  115. #define TTLParseARG_FETCH VOLK_TTLParserState *state =yypParser->state ;
  116. #define TTLParseARG_STORE yypParser->state =state ;
  117. #define TTLParseCTX_SDECL
  118. #define TTLParseCTX_PDECL
  119. #define TTLParseCTX_PARAM
  120. #define TTLParseCTX_FETCH
  121. #define TTLParseCTX_STORE
  122. #define YYNSTATE 28
  123. #define YYNRULE 41
  124. #define YYNRULE_WITH_ACTION 27
  125. #define YYNTOKEN 25
  126. #define YY_MAX_SHIFT 27
  127. #define YY_MIN_SHIFTREDUCE 63
  128. #define YY_MAX_SHIFTREDUCE 103
  129. #define YY_ERROR_ACTION 104
  130. #define YY_ACCEPT_ACTION 105
  131. #define YY_NO_ACTION 106
  132. #define YY_MIN_REDUCE 107
  133. #define YY_MAX_REDUCE 147
  134. /************* End control #defines *******************************************/
  135. #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
  136. /* Define the yytestcase() macro to be a no-op if is not already defined
  137. ** otherwise.
  138. **
  139. ** Applications can choose to define yytestcase() in the %include section
  140. ** to a macro that can assist in verifying code coverage. For production
  141. ** code the yytestcase() macro should be turned off. But it is useful
  142. ** for testing.
  143. */
  144. #ifndef yytestcase
  145. # define yytestcase(X)
  146. #endif
  147. /* Next are the tables used to determine what action to take based on the
  148. ** current state and lookahead token. These tables are used to implement
  149. ** functions that take a state number and lookahead value and return an
  150. ** action integer.
  151. **
  152. ** Suppose the action integer is N. Then the action is determined as
  153. ** follows
  154. **
  155. ** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead
  156. ** token onto the stack and goto state N.
  157. **
  158. ** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then
  159. ** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE.
  160. **
  161. ** N == YY_ERROR_ACTION A syntax error has occurred.
  162. **
  163. ** N == YY_ACCEPT_ACTION The parser accepts its input.
  164. **
  165. ** N == YY_NO_ACTION No such action. Denotes unused
  166. ** slots in the yy_action[] table.
  167. **
  168. ** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
  169. ** and YY_MAX_REDUCE
  170. **
  171. ** The action table is constructed as a single large table named yy_action[].
  172. ** Given state S and lookahead X, the action is computed as either:
  173. **
  174. ** (A) N = yy_action[ yy_shift_ofst[S] + X ]
  175. ** (B) N = yy_default[S]
  176. **
  177. ** The (A) formula is preferred. The B formula is used instead if
  178. ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X.
  179. **
  180. ** The formulas above are for computing the action when the lookahead is
  181. ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
  182. ** a reduce action) then the yy_reduce_ofst[] array is used in place of
  183. ** the yy_shift_ofst[] array.
  184. **
  185. ** The following are the tables generated in this section:
  186. **
  187. ** yy_action[] A single table containing all actions.
  188. ** yy_lookahead[] A table containing the lookahead for each entry in
  189. ** yy_action. Used to detect hash collisions.
  190. ** yy_shift_ofst[] For each state, the offset into yy_action for
  191. ** shifting terminals.
  192. ** yy_reduce_ofst[] For each state, the offset into yy_action for
  193. ** shifting non-terminals after a reduce.
  194. ** yy_default[] Default action for each state.
  195. **
  196. *********** Begin parsing tables **********************************************/
  197. #define YY_ACTTAB_COUNT (115)
  198. static const YYACTIONTYPE yy_action[] = {
  199. /* 0 */ 105, 1, 65, 9, 17, 77, 78, 79, 80, 81,
  200. /* 10 */ 89, 88, 17, 77, 78, 79, 80, 81, 89, 88,
  201. /* 20 */ 82, 7, 14, 2, 84, 14, 16, 13, 82, 7,
  202. /* 30 */ 13, 2, 120, 81, 89, 88, 5, 26, 102, 27,
  203. /* 40 */ 96, 23, 18, 13, 82, 7, 13, 2, 135, 135,
  204. /* 50 */ 135, 135, 15, 130, 130, 130, 130, 130, 115, 116,
  205. /* 60 */ 3, 116, 89, 88, 4, 131, 131, 131, 131, 131,
  206. /* 70 */ 11, 19, 114, 114, 114, 114, 114, 20, 114, 114,
  207. /* 80 */ 114, 114, 114, 66, 113, 113, 113, 113, 113, 89,
  208. /* 90 */ 88, 102, 89, 88, 10, 75, 8, 73, 6, 85,
  209. /* 100 */ 73, 64, 12, 22, 21, 63, 25, 24, 134, 106,
  210. /* 110 */ 106, 106, 106, 106, 83,
  211. };
  212. static const YYCODETYPE yy_lookahead[] = {
  213. /* 0 */ 25, 26, 1, 2, 4, 5, 6, 7, 8, 9,
  214. /* 10 */ 10, 11, 4, 5, 6, 7, 8, 9, 10, 11,
  215. /* 20 */ 20, 21, 34, 23, 24, 37, 33, 34, 20, 21,
  216. /* 30 */ 37, 23, 37, 9, 10, 11, 32, 13, 16, 15,
  217. /* 40 */ 16, 17, 33, 34, 20, 21, 37, 23, 27, 28,
  218. /* 50 */ 29, 30, 31, 36, 37, 38, 39, 40, 37, 38,
  219. /* 60 */ 32, 40, 10, 11, 32, 36, 37, 38, 39, 40,
  220. /* 70 */ 41, 35, 36, 37, 38, 39, 40, 35, 36, 37,
  221. /* 80 */ 38, 39, 40, 1, 36, 37, 38, 39, 40, 10,
  222. /* 90 */ 11, 16, 10, 11, 2, 12, 32, 18, 3, 24,
  223. /* 100 */ 18, 1, 19, 16, 11, 1, 16, 11, 0, 42,
  224. /* 110 */ 42, 42, 42, 42, 22, 42, 42, 42, 42, 42,
  225. /* 120 */ 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
  226. /* 130 */ 42, 42, 42, 42, 25, 25, 25, 25, 25, 25,
  227. };
  228. #define YY_SHIFT_COUNT (27)
  229. #define YY_SHIFT_MIN (0)
  230. #define YY_SHIFT_MAX (108)
  231. static const unsigned char yy_shift_ofst[] = {
  232. /* 0 */ 115, 24, 0, 8, 8, 8, 8, 79, 79, 82,
  233. /* 10 */ 79, 75, 52, 22, 22, 22, 92, 83, 1, 95,
  234. /* 20 */ 95, 100, 93, 87, 104, 96, 90, 108,
  235. };
  236. #define YY_REDUCE_COUNT (15)
  237. #define YY_REDUCE_MIN (-25)
  238. #define YY_REDUCE_MAX (64)
  239. static const signed char yy_reduce_ofst[] = {
  240. /* 0 */ -25, 21, 29, 36, 42, 17, 48, -7, 9, -12,
  241. /* 10 */ -12, 4, -5, 28, 32, 64,
  242. };
  243. static const YYACTIONTYPE yy_default[] = {
  244. /* 0 */ 136, 104, 104, 104, 104, 104, 104, 104, 104, 104,
  245. /* 10 */ 104, 147, 104, 147, 147, 147, 104, 118, 104, 111,
  246. /* 20 */ 112, 104, 104, 104, 104, 104, 104, 104,
  247. };
  248. /********** End of lemon-generated parsing tables *****************************/
  249. /* The next table maps tokens (terminal symbols) into fallback tokens.
  250. ** If a construct like the following:
  251. **
  252. ** %fallback ID X Y Z.
  253. **
  254. ** appears in the grammar, then ID becomes a fallback token for X, Y,
  255. ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
  256. ** but it does not parse, the type of the token is changed to ID and
  257. ** the parse is retried before an error is thrown.
  258. **
  259. ** This feature can be used, for example, to cause some keywords in a language
  260. ** to revert to identifiers if they keyword does not apply in the context where
  261. ** it appears.
  262. */
  263. #ifdef YYFALLBACK
  264. static const YYCODETYPE yyFallback[] = {
  265. };
  266. #endif /* YYFALLBACK */
  267. /* The following structure represents a single element of the
  268. ** parser's stack. Information stored includes:
  269. **
  270. ** + The state number for the parser at this level of the stack.
  271. **
  272. ** + The value of the token stored at this level of the stack.
  273. ** (In other words, the "major" token.)
  274. **
  275. ** + The semantic value stored at this level of the stack. This is
  276. ** the information used by the action routines in the grammar.
  277. ** It is sometimes called the "minor" token.
  278. **
  279. ** After the "shift" half of a SHIFTREDUCE action, the stateno field
  280. ** actually contains the reduce action for the second half of the
  281. ** SHIFTREDUCE.
  282. */
  283. struct yyStackEntry {
  284. YYACTIONTYPE stateno; /* The state-number, or reduce action in SHIFTREDUCE */
  285. YYCODETYPE major; /* The major token value. This is the code
  286. ** number for the token at this stack level */
  287. YYMINORTYPE minor; /* The user-supplied minor token value. This
  288. ** is the value of the token */
  289. };
  290. typedef struct yyStackEntry yyStackEntry;
  291. /* The state of the parser is completely contained in an instance of
  292. ** the following structure */
  293. struct yyParser {
  294. yyStackEntry *yytos; /* Pointer to top element of the stack */
  295. #ifdef YYTRACKMAXSTACKDEPTH
  296. int yyhwm; /* High-water mark of the stack */
  297. #endif
  298. #ifndef YYNOERRORRECOVERY
  299. int yyerrcnt; /* Shifts left before out of the error */
  300. #endif
  301. TTLParseARG_SDECL /* A place to hold %extra_argument */
  302. TTLParseCTX_SDECL /* A place to hold %extra_context */
  303. #if YYSTACKDEPTH<=0
  304. int yystksz; /* Current side of the stack */
  305. yyStackEntry *yystack; /* The parser's stack */
  306. yyStackEntry yystk0; /* First stack entry */
  307. #else
  308. yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
  309. yyStackEntry *yystackEnd; /* Last entry in the stack */
  310. #endif
  311. };
  312. typedef struct yyParser yyParser;
  313. #include <assert.h>
  314. #ifndef NDEBUG
  315. #include <stdio.h>
  316. static FILE *yyTraceFILE = 0;
  317. static char *yyTracePrompt = 0;
  318. #endif /* NDEBUG */
  319. #ifndef NDEBUG
  320. /*
  321. ** Turn parser tracing on by giving a stream to which to write the trace
  322. ** and a prompt to preface each trace message. Tracing is turned off
  323. ** by making either argument NULL
  324. **
  325. ** Inputs:
  326. ** <ul>
  327. ** <li> A FILE* to which trace output should be written.
  328. ** If NULL, then tracing is turned off.
  329. ** <li> A prefix string written at the beginning of every
  330. ** line of trace output. If NULL, then tracing is
  331. ** turned off.
  332. ** </ul>
  333. **
  334. ** Outputs:
  335. ** None.
  336. */
  337. void TTLParseTrace(FILE *TraceFILE, char *zTracePrompt){
  338. yyTraceFILE = TraceFILE;
  339. yyTracePrompt = zTracePrompt;
  340. if( yyTraceFILE==0 ) yyTracePrompt = 0;
  341. else if( yyTracePrompt==0 ) yyTraceFILE = 0;
  342. }
  343. #endif /* NDEBUG */
  344. #if defined(YYCOVERAGE) || !defined(NDEBUG)
  345. /* For tracing shifts, the names of all terminals and nonterminals
  346. ** are required. The following table supplies these names */
  347. static const char *const yyTokenName[] = {
  348. /* 0 */ "$",
  349. /* 1 */ "PERIOD",
  350. /* 2 */ "SEMICOLON",
  351. /* 3 */ "COMMA",
  352. /* 4 */ "STRING",
  353. /* 5 */ "INTEGER",
  354. /* 6 */ "DOUBLE",
  355. /* 7 */ "DECIMAL",
  356. /* 8 */ "BOOLEAN",
  357. /* 9 */ "BNODE_ID",
  358. /* 10 */ "QNAME",
  359. /* 11 */ "IRIREF",
  360. /* 12 */ "LANGTAG",
  361. /* 13 */ "PREFIX",
  362. /* 14 */ "COLON",
  363. /* 15 */ "EOF",
  364. /* 16 */ "WS",
  365. /* 17 */ "BASE",
  366. /* 18 */ "RDF_TYPE",
  367. /* 19 */ "DTYPE_MARKER",
  368. /* 20 */ "ANON",
  369. /* 21 */ "LBRACKET",
  370. /* 22 */ "RBRACKET",
  371. /* 23 */ "LPAREN",
  372. /* 24 */ "RPAREN",
  373. /* 25 */ "turtleDoc",
  374. /* 26 */ "statements",
  375. /* 27 */ "statement",
  376. /* 28 */ "prefixID",
  377. /* 29 */ "base",
  378. /* 30 */ "triples",
  379. /* 31 */ "subject",
  380. /* 32 */ "ows",
  381. /* 33 */ "predObjList",
  382. /* 34 */ "predicate",
  383. /* 35 */ "objectList",
  384. /* 36 */ "object",
  385. /* 37 */ "resource",
  386. /* 38 */ "blank",
  387. /* 39 */ "literal",
  388. /* 40 */ "collection",
  389. /* 41 */ "itemList",
  390. };
  391. #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
  392. #ifndef NDEBUG
  393. /* For tracing reduce actions, the names of all rules are required.
  394. */
  395. static const char *const yyRuleName[] = {
  396. /* 0 */ "prefixID ::= PREFIX WS IRIREF PERIOD",
  397. /* 1 */ "base ::= BASE WS IRIREF PERIOD",
  398. /* 2 */ "triples ::= subject ows predObjList PERIOD",
  399. /* 3 */ "triples ::= subject ows predObjList SEMICOLON PERIOD",
  400. /* 4 */ "predObjList ::= predicate ows objectList",
  401. /* 5 */ "predObjList ::= predObjList SEMICOLON predicate ows objectList",
  402. /* 6 */ "objectList ::= objectList COMMA object",
  403. /* 7 */ "objectList ::= object",
  404. /* 8 */ "subject ::= resource",
  405. /* 9 */ "subject ::= blank",
  406. /* 10 */ "predicate ::= RDF_TYPE",
  407. /* 11 */ "literal ::= STRING",
  408. /* 12 */ "literal ::= STRING LANGTAG",
  409. /* 13 */ "literal ::= STRING DTYPE_MARKER resource",
  410. /* 14 */ "literal ::= INTEGER",
  411. /* 15 */ "literal ::= DOUBLE",
  412. /* 16 */ "literal ::= DECIMAL",
  413. /* 17 */ "literal ::= BOOLEAN",
  414. /* 18 */ "blank ::= BNODE_ID",
  415. /* 19 */ "blank ::= ANON",
  416. /* 20 */ "blank ::= LBRACKET predObjList RBRACKET",
  417. /* 21 */ "blank ::= LPAREN RPAREN",
  418. /* 22 */ "collection ::= LPAREN itemList RPAREN",
  419. /* 23 */ "itemList ::= itemList ows object",
  420. /* 24 */ "itemList ::= object",
  421. /* 25 */ "resource ::= IRIREF",
  422. /* 26 */ "resource ::= QNAME",
  423. /* 27 */ "turtleDoc ::= statements EOF",
  424. /* 28 */ "statements ::= statements statement",
  425. /* 29 */ "statements ::=",
  426. /* 30 */ "statement ::= prefixID",
  427. /* 31 */ "statement ::= base",
  428. /* 32 */ "statement ::= triples",
  429. /* 33 */ "statement ::= WS",
  430. /* 34 */ "predicate ::= resource",
  431. /* 35 */ "object ::= resource",
  432. /* 36 */ "object ::= blank",
  433. /* 37 */ "object ::= literal",
  434. /* 38 */ "blank ::= collection",
  435. /* 39 */ "ows ::= WS",
  436. /* 40 */ "ows ::=",
  437. };
  438. #endif /* NDEBUG */
  439. #if YYSTACKDEPTH<=0
  440. /*
  441. ** Try to increase the size of the parser stack. Return the number
  442. ** of errors. Return 0 on success.
  443. */
  444. static int yyGrowStack(yyParser *p){
  445. int newSize;
  446. int idx;
  447. yyStackEntry *pNew;
  448. newSize = p->yystksz*2 + 100;
  449. idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
  450. if( p->yystack==&p->yystk0 ){
  451. pNew = malloc(newSize*sizeof(pNew[0]));
  452. if( pNew ) pNew[0] = p->yystk0;
  453. }else{
  454. pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
  455. }
  456. if( pNew ){
  457. p->yystack = pNew;
  458. p->yytos = &p->yystack[idx];
  459. #ifndef NDEBUG
  460. if( yyTraceFILE ){
  461. fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
  462. yyTracePrompt, p->yystksz, newSize);
  463. }
  464. #endif
  465. p->yystksz = newSize;
  466. }
  467. return pNew==0;
  468. }
  469. #endif
  470. /* Datatype of the argument to the memory allocated passed as the
  471. ** second argument to TTLParseAlloc() below. This can be changed by
  472. ** putting an appropriate #define in the %include section of the input
  473. ** grammar.
  474. */
  475. #ifndef YYMALLOCARGTYPE
  476. # define YYMALLOCARGTYPE size_t
  477. #endif
  478. /* Initialize a new parser that has already been allocated.
  479. */
  480. void TTLParseInit(void *yypRawParser TTLParseCTX_PDECL){
  481. yyParser *yypParser = (yyParser*)yypRawParser;
  482. TTLParseCTX_STORE
  483. #ifdef YYTRACKMAXSTACKDEPTH
  484. yypParser->yyhwm = 0;
  485. #endif
  486. #if YYSTACKDEPTH<=0
  487. yypParser->yytos = NULL;
  488. yypParser->yystack = NULL;
  489. yypParser->yystksz = 0;
  490. if( yyGrowStack(yypParser) ){
  491. yypParser->yystack = &yypParser->yystk0;
  492. yypParser->yystksz = 1;
  493. }
  494. #endif
  495. #ifndef YYNOERRORRECOVERY
  496. yypParser->yyerrcnt = -1;
  497. #endif
  498. yypParser->yytos = yypParser->yystack;
  499. yypParser->yystack[0].stateno = 0;
  500. yypParser->yystack[0].major = 0;
  501. #if YYSTACKDEPTH>0
  502. yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1];
  503. #endif
  504. }
  505. #ifndef TTLParse_ENGINEALWAYSONSTACK
  506. /*
  507. ** This function allocates a new parser.
  508. ** The only argument is a pointer to a function which works like
  509. ** malloc.
  510. **
  511. ** Inputs:
  512. ** A pointer to the function used to allocate memory.
  513. **
  514. ** Outputs:
  515. ** A pointer to a parser. This pointer is used in subsequent calls
  516. ** to TTLParse and TTLParseFree.
  517. */
  518. void *TTLParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) TTLParseCTX_PDECL){
  519. yyParser *yypParser;
  520. yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
  521. if( yypParser ){
  522. TTLParseCTX_STORE
  523. TTLParseInit(yypParser TTLParseCTX_PARAM);
  524. }
  525. return (void*)yypParser;
  526. }
  527. #endif /* TTLParse_ENGINEALWAYSONSTACK */
  528. /* The following function deletes the "minor type" or semantic value
  529. ** associated with a symbol. The symbol can be either a terminal
  530. ** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
  531. ** a pointer to the value to be deleted. The code used to do the
  532. ** deletions is derived from the %destructor and/or %token_destructor
  533. ** directives of the input grammar.
  534. */
  535. static void yy_destructor(
  536. yyParser *yypParser, /* The parser */
  537. YYCODETYPE yymajor, /* Type code for object to destroy */
  538. YYMINORTYPE *yypminor /* The object to be destroyed */
  539. ){
  540. TTLParseARG_FETCH
  541. TTLParseCTX_FETCH
  542. switch( yymajor ){
  543. /* Here is inserted the actions which take place when a
  544. ** terminal or non-terminal is destroyed. This can happen
  545. ** when the symbol is popped from the stack during a
  546. ** reduce or during error processing or when a parser is
  547. ** being destroyed before it is finished parsing.
  548. **
  549. ** Note: during a reduce, the only symbols destroyed are those
  550. ** which appear on the RHS of the rule, but which are *not* used
  551. ** inside the C code.
  552. */
  553. /********* Begin destructor definitions ***************************************/
  554. /* TERMINAL Destructor */
  555. case 1: /* PERIOD */
  556. case 2: /* SEMICOLON */
  557. case 3: /* COMMA */
  558. case 4: /* STRING */
  559. case 5: /* INTEGER */
  560. case 6: /* DOUBLE */
  561. case 7: /* DECIMAL */
  562. case 8: /* BOOLEAN */
  563. case 9: /* BNODE_ID */
  564. case 10: /* QNAME */
  565. case 11: /* IRIREF */
  566. case 12: /* LANGTAG */
  567. case 13: /* PREFIX */
  568. case 14: /* COLON */
  569. case 15: /* EOF */
  570. case 16: /* WS */
  571. case 17: /* BASE */
  572. case 18: /* RDF_TYPE */
  573. case 19: /* DTYPE_MARKER */
  574. case 20: /* ANON */
  575. case 21: /* LBRACKET */
  576. case 22: /* RBRACKET */
  577. case 23: /* LPAREN */
  578. case 24: /* RPAREN */
  579. {
  580. #line 36 "grammar_ttl.y"
  581. (void) state; free ((yypminor->yy0));
  582. #line 628 "../../build/grammar_ttl.c"
  583. }
  584. break;
  585. case 31: /* subject */
  586. case 34: /* predicate */
  587. case 36: /* object */
  588. case 37: /* resource */
  589. case 38: /* blank */
  590. case 39: /* literal */
  591. case 40: /* collection */
  592. {
  593. #line 129 "grammar_ttl.y"
  594. VOLK_term_free ((yypminor->yy50));
  595. #line 641 "../../build/grammar_ttl.c"
  596. }
  597. break;
  598. case 33: /* predObjList */
  599. {
  600. #line 97 "grammar_ttl.y"
  601. VOLK_link_map_free ((yypminor->yy34));
  602. #line 648 "../../build/grammar_ttl.c"
  603. }
  604. break;
  605. case 35: /* objectList */
  606. case 41: /* itemList */
  607. {
  608. #line 117 "grammar_ttl.y"
  609. VOLK_term_set_free ((yypminor->yy22));
  610. #line 656 "../../build/grammar_ttl.c"
  611. }
  612. break;
  613. /********* End destructor definitions *****************************************/
  614. default: break; /* If no destructor action specified: do nothing */
  615. }
  616. }
  617. /*
  618. ** Pop the parser's stack once.
  619. **
  620. ** If there is a destructor routine associated with the token which
  621. ** is popped from the stack, then call it.
  622. */
  623. static void yy_pop_parser_stack(yyParser *pParser){
  624. yyStackEntry *yytos;
  625. assert( pParser->yytos!=0 );
  626. assert( pParser->yytos > pParser->yystack );
  627. yytos = pParser->yytos--;
  628. #ifndef NDEBUG
  629. if( yyTraceFILE ){
  630. fprintf(yyTraceFILE,"%sPopping %s\n",
  631. yyTracePrompt,
  632. yyTokenName[yytos->major]);
  633. }
  634. #endif
  635. yy_destructor(pParser, yytos->major, &yytos->minor);
  636. }
  637. /*
  638. ** Clear all secondary memory allocations from the parser
  639. */
  640. void TTLParseFinalize(void *p){
  641. yyParser *pParser = (yyParser*)p;
  642. while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
  643. #if YYSTACKDEPTH<=0
  644. if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
  645. #endif
  646. }
  647. #ifndef TTLParse_ENGINEALWAYSONSTACK
  648. /*
  649. ** Deallocate and destroy a parser. Destructors are called for
  650. ** all stack elements before shutting the parser down.
  651. **
  652. ** If the YYPARSEFREENEVERNULL macro exists (for example because it
  653. ** is defined in a %include section of the input grammar) then it is
  654. ** assumed that the input pointer is never NULL.
  655. */
  656. void TTLParseFree(
  657. void *p, /* The parser to be deleted */
  658. void (*freeProc)(void*) /* Function used to reclaim memory */
  659. ){
  660. #ifndef YYPARSEFREENEVERNULL
  661. if( p==0 ) return;
  662. #endif
  663. TTLParseFinalize(p);
  664. (*freeProc)(p);
  665. }
  666. #endif /* TTLParse_ENGINEALWAYSONSTACK */
  667. /*
  668. ** Return the peak depth of the stack for a parser.
  669. */
  670. #ifdef YYTRACKMAXSTACKDEPTH
  671. int TTLParseStackPeak(void *p){
  672. yyParser *pParser = (yyParser*)p;
  673. return pParser->yyhwm;
  674. }
  675. #endif
  676. /* This array of booleans keeps track of the parser statement
  677. ** coverage. The element yycoverage[X][Y] is set when the parser
  678. ** is in state X and has a lookahead token Y. In a well-tested
  679. ** systems, every element of this matrix should end up being set.
  680. */
  681. #if defined(YYCOVERAGE)
  682. static unsigned char yycoverage[YYNSTATE][YYNTOKEN];
  683. #endif
  684. /*
  685. ** Write into out a description of every state/lookahead combination that
  686. **
  687. ** (1) has not been used by the parser, and
  688. ** (2) is not a syntax error.
  689. **
  690. ** Return the number of missed state/lookahead combinations.
  691. */
  692. #if defined(YYCOVERAGE)
  693. int TTLParseCoverage(FILE *out){
  694. int stateno, iLookAhead, i;
  695. int nMissed = 0;
  696. for(stateno=0; stateno<YYNSTATE; stateno++){
  697. i = yy_shift_ofst[stateno];
  698. for(iLookAhead=0; iLookAhead<YYNTOKEN; iLookAhead++){
  699. if( yy_lookahead[i+iLookAhead]!=iLookAhead ) continue;
  700. if( yycoverage[stateno][iLookAhead]==0 ) nMissed++;
  701. if( out ){
  702. fprintf(out,"State %d lookahead %s %s\n", stateno,
  703. yyTokenName[iLookAhead],
  704. yycoverage[stateno][iLookAhead] ? "ok" : "missed");
  705. }
  706. }
  707. }
  708. return nMissed;
  709. }
  710. #endif
  711. /*
  712. ** Find the appropriate action for a parser given the terminal
  713. ** look-ahead token iLookAhead.
  714. */
  715. static YYACTIONTYPE yy_find_shift_action(
  716. YYCODETYPE iLookAhead, /* The look-ahead token */
  717. YYACTIONTYPE stateno /* Current state number */
  718. ){
  719. int i;
  720. if( stateno>YY_MAX_SHIFT ) return stateno;
  721. assert( stateno <= YY_SHIFT_COUNT );
  722. #if defined(YYCOVERAGE)
  723. yycoverage[stateno][iLookAhead] = 1;
  724. #endif
  725. do{
  726. i = yy_shift_ofst[stateno];
  727. assert( i>=0 );
  728. assert( i<=YY_ACTTAB_COUNT );
  729. assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD );
  730. assert( iLookAhead!=YYNOCODE );
  731. assert( iLookAhead < YYNTOKEN );
  732. i += iLookAhead;
  733. assert( i<(int)YY_NLOOKAHEAD );
  734. if( yy_lookahead[i]!=iLookAhead ){
  735. #ifdef YYFALLBACK
  736. YYCODETYPE iFallback; /* Fallback token */
  737. assert( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) );
  738. iFallback = yyFallback[iLookAhead];
  739. if( iFallback!=0 ){
  740. #ifndef NDEBUG
  741. if( yyTraceFILE ){
  742. fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
  743. yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
  744. }
  745. #endif
  746. assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
  747. iLookAhead = iFallback;
  748. continue;
  749. }
  750. #endif
  751. #ifdef YYWILDCARD
  752. {
  753. int j = i - iLookAhead + YYWILDCARD;
  754. assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) );
  755. if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){
  756. #ifndef NDEBUG
  757. if( yyTraceFILE ){
  758. fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
  759. yyTracePrompt, yyTokenName[iLookAhead],
  760. yyTokenName[YYWILDCARD]);
  761. }
  762. #endif /* NDEBUG */
  763. return yy_action[j];
  764. }
  765. }
  766. #endif /* YYWILDCARD */
  767. return yy_default[stateno];
  768. }else{
  769. assert( i>=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) );
  770. return yy_action[i];
  771. }
  772. }while(1);
  773. }
  774. /*
  775. ** Find the appropriate action for a parser given the non-terminal
  776. ** look-ahead token iLookAhead.
  777. */
  778. static YYACTIONTYPE yy_find_reduce_action(
  779. YYACTIONTYPE stateno, /* Current state number */
  780. YYCODETYPE iLookAhead /* The look-ahead token */
  781. ){
  782. int i;
  783. #ifdef YYERRORSYMBOL
  784. if( stateno>YY_REDUCE_COUNT ){
  785. return yy_default[stateno];
  786. }
  787. #else
  788. assert( stateno<=YY_REDUCE_COUNT );
  789. #endif
  790. i = yy_reduce_ofst[stateno];
  791. assert( iLookAhead!=YYNOCODE );
  792. i += iLookAhead;
  793. #ifdef YYERRORSYMBOL
  794. if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
  795. return yy_default[stateno];
  796. }
  797. #else
  798. assert( i>=0 && i<YY_ACTTAB_COUNT );
  799. assert( yy_lookahead[i]==iLookAhead );
  800. #endif
  801. return yy_action[i];
  802. }
  803. /*
  804. ** The following routine is called if the stack overflows.
  805. */
  806. static void yyStackOverflow(yyParser *yypParser){
  807. TTLParseARG_FETCH
  808. TTLParseCTX_FETCH
  809. #ifndef NDEBUG
  810. if( yyTraceFILE ){
  811. fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
  812. }
  813. #endif
  814. while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
  815. /* Here code is inserted which will execute if the parser
  816. ** stack every overflows */
  817. /******** Begin %stack_overflow code ******************************************/
  818. #line 17 "grammar_ttl.y"
  819. log_error ("Stack oveflow in TTL parsing.");
  820. state->rc = VOLK_MEM_ERR;
  821. #line 878 "../../build/grammar_ttl.c"
  822. /******** End %stack_overflow code ********************************************/
  823. TTLParseARG_STORE /* Suppress warning about unused %extra_argument var */
  824. TTLParseCTX_STORE
  825. }
  826. /*
  827. ** Print tracing information for a SHIFT action
  828. */
  829. #ifndef NDEBUG
  830. static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){
  831. if( yyTraceFILE ){
  832. if( yyNewState<YYNSTATE ){
  833. fprintf(yyTraceFILE,"%s%s '%s', go to state %d\n",
  834. yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
  835. yyNewState);
  836. }else{
  837. fprintf(yyTraceFILE,"%s%s '%s', pending reduce %d\n",
  838. yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
  839. yyNewState - YY_MIN_REDUCE);
  840. }
  841. }
  842. }
  843. #else
  844. # define yyTraceShift(X,Y,Z)
  845. #endif
  846. /*
  847. ** Perform a shift action.
  848. */
  849. static void yy_shift(
  850. yyParser *yypParser, /* The parser to be shifted */
  851. YYACTIONTYPE yyNewState, /* The new state to shift in */
  852. YYCODETYPE yyMajor, /* The major token to shift in */
  853. TTLParseTOKENTYPE yyMinor /* The minor token to shift in */
  854. ){
  855. yyStackEntry *yytos;
  856. yypParser->yytos++;
  857. #ifdef YYTRACKMAXSTACKDEPTH
  858. if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
  859. yypParser->yyhwm++;
  860. assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
  861. }
  862. #endif
  863. #if YYSTACKDEPTH>0
  864. if( yypParser->yytos>yypParser->yystackEnd ){
  865. yypParser->yytos--;
  866. yyStackOverflow(yypParser);
  867. return;
  868. }
  869. #else
  870. if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
  871. if( yyGrowStack(yypParser) ){
  872. yypParser->yytos--;
  873. yyStackOverflow(yypParser);
  874. return;
  875. }
  876. }
  877. #endif
  878. if( yyNewState > YY_MAX_SHIFT ){
  879. yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
  880. }
  881. yytos = yypParser->yytos;
  882. yytos->stateno = yyNewState;
  883. yytos->major = yyMajor;
  884. yytos->minor.yy0 = yyMinor;
  885. yyTraceShift(yypParser, yyNewState, "Shift");
  886. }
  887. /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
  888. ** of that rule */
  889. static const YYCODETYPE yyRuleInfoLhs[] = {
  890. 28, /* (0) prefixID ::= PREFIX WS IRIREF PERIOD */
  891. 29, /* (1) base ::= BASE WS IRIREF PERIOD */
  892. 30, /* (2) triples ::= subject ows predObjList PERIOD */
  893. 30, /* (3) triples ::= subject ows predObjList SEMICOLON PERIOD */
  894. 33, /* (4) predObjList ::= predicate ows objectList */
  895. 33, /* (5) predObjList ::= predObjList SEMICOLON predicate ows objectList */
  896. 35, /* (6) objectList ::= objectList COMMA object */
  897. 35, /* (7) objectList ::= object */
  898. 31, /* (8) subject ::= resource */
  899. 31, /* (9) subject ::= blank */
  900. 34, /* (10) predicate ::= RDF_TYPE */
  901. 39, /* (11) literal ::= STRING */
  902. 39, /* (12) literal ::= STRING LANGTAG */
  903. 39, /* (13) literal ::= STRING DTYPE_MARKER resource */
  904. 39, /* (14) literal ::= INTEGER */
  905. 39, /* (15) literal ::= DOUBLE */
  906. 39, /* (16) literal ::= DECIMAL */
  907. 39, /* (17) literal ::= BOOLEAN */
  908. 38, /* (18) blank ::= BNODE_ID */
  909. 38, /* (19) blank ::= ANON */
  910. 38, /* (20) blank ::= LBRACKET predObjList RBRACKET */
  911. 38, /* (21) blank ::= LPAREN RPAREN */
  912. 40, /* (22) collection ::= LPAREN itemList RPAREN */
  913. 41, /* (23) itemList ::= itemList ows object */
  914. 41, /* (24) itemList ::= object */
  915. 37, /* (25) resource ::= IRIREF */
  916. 37, /* (26) resource ::= QNAME */
  917. 25, /* (27) turtleDoc ::= statements EOF */
  918. 26, /* (28) statements ::= statements statement */
  919. 26, /* (29) statements ::= */
  920. 27, /* (30) statement ::= prefixID */
  921. 27, /* (31) statement ::= base */
  922. 27, /* (32) statement ::= triples */
  923. 27, /* (33) statement ::= WS */
  924. 34, /* (34) predicate ::= resource */
  925. 36, /* (35) object ::= resource */
  926. 36, /* (36) object ::= blank */
  927. 36, /* (37) object ::= literal */
  928. 38, /* (38) blank ::= collection */
  929. 32, /* (39) ows ::= WS */
  930. 32, /* (40) ows ::= */
  931. };
  932. /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
  933. ** of symbols on the right-hand side of that rule. */
  934. static const signed char yyRuleInfoNRhs[] = {
  935. -4, /* (0) prefixID ::= PREFIX WS IRIREF PERIOD */
  936. -4, /* (1) base ::= BASE WS IRIREF PERIOD */
  937. -4, /* (2) triples ::= subject ows predObjList PERIOD */
  938. -5, /* (3) triples ::= subject ows predObjList SEMICOLON PERIOD */
  939. -3, /* (4) predObjList ::= predicate ows objectList */
  940. -5, /* (5) predObjList ::= predObjList SEMICOLON predicate ows objectList */
  941. -3, /* (6) objectList ::= objectList COMMA object */
  942. -1, /* (7) objectList ::= object */
  943. -1, /* (8) subject ::= resource */
  944. -1, /* (9) subject ::= blank */
  945. -1, /* (10) predicate ::= RDF_TYPE */
  946. -1, /* (11) literal ::= STRING */
  947. -2, /* (12) literal ::= STRING LANGTAG */
  948. -3, /* (13) literal ::= STRING DTYPE_MARKER resource */
  949. -1, /* (14) literal ::= INTEGER */
  950. -1, /* (15) literal ::= DOUBLE */
  951. -1, /* (16) literal ::= DECIMAL */
  952. -1, /* (17) literal ::= BOOLEAN */
  953. -1, /* (18) blank ::= BNODE_ID */
  954. -1, /* (19) blank ::= ANON */
  955. -3, /* (20) blank ::= LBRACKET predObjList RBRACKET */
  956. -2, /* (21) blank ::= LPAREN RPAREN */
  957. -3, /* (22) collection ::= LPAREN itemList RPAREN */
  958. -3, /* (23) itemList ::= itemList ows object */
  959. -1, /* (24) itemList ::= object */
  960. -1, /* (25) resource ::= IRIREF */
  961. -1, /* (26) resource ::= QNAME */
  962. -2, /* (27) turtleDoc ::= statements EOF */
  963. -2, /* (28) statements ::= statements statement */
  964. 0, /* (29) statements ::= */
  965. -1, /* (30) statement ::= prefixID */
  966. -1, /* (31) statement ::= base */
  967. -1, /* (32) statement ::= triples */
  968. -1, /* (33) statement ::= WS */
  969. -1, /* (34) predicate ::= resource */
  970. -1, /* (35) object ::= resource */
  971. -1, /* (36) object ::= blank */
  972. -1, /* (37) object ::= literal */
  973. -1, /* (38) blank ::= collection */
  974. -1, /* (39) ows ::= WS */
  975. 0, /* (40) ows ::= */
  976. };
  977. static void yy_accept(yyParser*); /* Forward Declaration */
  978. /*
  979. ** Perform a reduce action and the shift that must immediately
  980. ** follow the reduce.
  981. **
  982. ** The yyLookahead and yyLookaheadToken parameters provide reduce actions
  983. ** access to the lookahead token (if any). The yyLookahead will be YYNOCODE
  984. ** if the lookahead token has already been consumed. As this procedure is
  985. ** only called from one place, optimizing compilers will in-line it, which
  986. ** means that the extra parameters have no performance impact.
  987. */
  988. static YYACTIONTYPE yy_reduce(
  989. yyParser *yypParser, /* The parser */
  990. unsigned int yyruleno, /* Number of the rule by which to reduce */
  991. int yyLookahead, /* Lookahead token, or YYNOCODE if none */
  992. TTLParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */
  993. TTLParseCTX_PDECL /* %extra_context */
  994. ){
  995. int yygoto; /* The next state */
  996. YYACTIONTYPE yyact; /* The next action */
  997. yyStackEntry *yymsp; /* The top of the parser's stack */
  998. int yysize; /* Amount to pop the stack */
  999. TTLParseARG_FETCH
  1000. (void)yyLookahead;
  1001. (void)yyLookaheadToken;
  1002. yymsp = yypParser->yytos;
  1003. switch( yyruleno ){
  1004. /* Beginning here are the reduction cases. A typical example
  1005. ** follows:
  1006. ** case 0:
  1007. ** #line <lineno> <grammarfile>
  1008. ** { ... } // User supplied code
  1009. ** #line <lineno> <thisfile>
  1010. ** break;
  1011. */
  1012. /********** Begin reduce actions **********************************************/
  1013. YYMINORTYPE yylhsminor;
  1014. case 0: /* prefixID ::= PREFIX WS IRIREF PERIOD */
  1015. #line 63 "grammar_ttl.y"
  1016. {
  1017. VOLK_nsmap_add (yymsp[-3].minor.yy0, yymsp[-1].minor.yy0);
  1018. free (yymsp[-3].minor.yy0);
  1019. free (yymsp[-1].minor.yy0);
  1020. }
  1021. #line 1086 "../../build/grammar_ttl.c"
  1022. yy_destructor(yypParser,16,&yymsp[-2].minor);
  1023. yy_destructor(yypParser,1,&yymsp[0].minor);
  1024. break;
  1025. case 1: /* base ::= BASE WS IRIREF PERIOD */
  1026. { yy_destructor(yypParser,17,&yymsp[-3].minor);
  1027. #line 70 "grammar_ttl.y"
  1028. {
  1029. VOLK_term_free (state->base);
  1030. state->base = VOLK_iriref_new (yymsp[-1].minor.yy0);
  1031. free (yymsp[-1].minor.yy0);
  1032. }
  1033. #line 1099 "../../build/grammar_ttl.c"
  1034. yy_destructor(yypParser,16,&yymsp[-2].minor);
  1035. yy_destructor(yypParser,1,&yymsp[0].minor);
  1036. }
  1037. break;
  1038. case 2: /* triples ::= subject ows predObjList PERIOD */
  1039. #line 77 "grammar_ttl.y"
  1040. {
  1041. size_t ct = VOLK_graph_add_link_map (state->it, yymsp[-1].minor.yy34);
  1042. state->ct += ct;
  1043. state->rc = VOLK_OK;
  1044. LOG_TRACE("Added %lu triples.", ct);
  1045. VOLK_term_free (yymsp[-3].minor.yy50);
  1046. VOLK_link_map_free (yymsp[-1].minor.yy34);
  1047. }
  1048. #line 1115 "../../build/grammar_ttl.c"
  1049. yy_destructor(yypParser,1,&yymsp[0].minor);
  1050. break;
  1051. case 3: /* triples ::= subject ows predObjList SEMICOLON PERIOD */
  1052. #line 86 "grammar_ttl.y"
  1053. {
  1054. size_t ct = VOLK_graph_add_link_map (state->it, yymsp[-2].minor.yy34);
  1055. state->ct += ct;
  1056. state->rc = VOLK_OK;
  1057. LOG_TRACE("Added %lu triples.", ct);
  1058. VOLK_term_free (yymsp[-4].minor.yy50);
  1059. VOLK_link_map_free (yymsp[-2].minor.yy34);
  1060. }
  1061. #line 1129 "../../build/grammar_ttl.c"
  1062. yy_destructor(yypParser,2,&yymsp[-1].minor);
  1063. yy_destructor(yypParser,1,&yymsp[0].minor);
  1064. break;
  1065. case 4: /* predObjList ::= predicate ows objectList */
  1066. #line 98 "grammar_ttl.y"
  1067. {
  1068. VOLK_Term *s;
  1069. if (state->lms) s = state->lms;
  1070. else {
  1071. // TODO This may be brittle. It is not verifying the
  1072. // full BNode syntax.
  1073. log_info ("Link map subject not present. Assuming BNode.");
  1074. s = VOLK_bnode_new (NULL);
  1075. }
  1076. yylhsminor.yy34 = VOLK_link_map_new (s, VOLK_LINK_OUTBOUND);
  1077. VOLK_link_map_add (yylhsminor.yy34, yymsp[-2].minor.yy50, yymsp[0].minor.yy22);
  1078. if (s != state->lms) VOLK_term_free (s);
  1079. }
  1080. #line 1148 "../../build/grammar_ttl.c"
  1081. yymsp[-2].minor.yy34 = yylhsminor.yy34;
  1082. break;
  1083. case 5: /* predObjList ::= predObjList SEMICOLON predicate ows objectList */
  1084. #line 111 "grammar_ttl.y"
  1085. {
  1086. VOLK_link_map_add (yymsp[-4].minor.yy34, yymsp[-2].minor.yy50, yymsp[0].minor.yy22);
  1087. yylhsminor.yy34 = yymsp[-4].minor.yy34;
  1088. }
  1089. #line 1157 "../../build/grammar_ttl.c"
  1090. yy_destructor(yypParser,2,&yymsp[-3].minor);
  1091. yymsp[-4].minor.yy34 = yylhsminor.yy34;
  1092. break;
  1093. case 6: /* objectList ::= objectList COMMA object */
  1094. #line 118 "grammar_ttl.y"
  1095. {
  1096. if (VOLK_term_set_add (yymsp[-2].minor.yy22, yymsp[0].minor.yy50, NULL) == VOLK_NOACTION)
  1097. VOLK_term_free (yymsp[0].minor.yy50);
  1098. yylhsminor.yy22 = yymsp[-2].minor.yy22;
  1099. }
  1100. #line 1168 "../../build/grammar_ttl.c"
  1101. yy_destructor(yypParser,3,&yymsp[-1].minor);
  1102. yymsp[-2].minor.yy22 = yylhsminor.yy22;
  1103. break;
  1104. case 7: /* objectList ::= object */
  1105. #line 123 "grammar_ttl.y"
  1106. {
  1107. yylhsminor.yy22 = VOLK_term_set_new();
  1108. VOLK_term_set_add (yylhsminor.yy22, yymsp[0].minor.yy50, NULL);
  1109. }
  1110. #line 1178 "../../build/grammar_ttl.c"
  1111. yymsp[0].minor.yy22 = yylhsminor.yy22;
  1112. break;
  1113. case 8: /* subject ::= resource */
  1114. case 9: /* subject ::= blank */ yytestcase(yyruleno==9);
  1115. #line 130 "grammar_ttl.y"
  1116. { state->lms = yymsp[0].minor.yy50; }
  1117. #line 1185 "../../build/grammar_ttl.c"
  1118. break;
  1119. case 10: /* predicate ::= RDF_TYPE */
  1120. { yy_destructor(yypParser,18,&yymsp[0].minor);
  1121. #line 136 "grammar_ttl.y"
  1122. { yymsp[0].minor.yy50 = VOLK_iriref_new_ns ("rdf:type"); }
  1123. #line 1191 "../../build/grammar_ttl.c"
  1124. }
  1125. break;
  1126. case 11: /* literal ::= STRING */
  1127. #line 146 "grammar_ttl.y"
  1128. {
  1129. yylhsminor.yy50 = VOLK_literal_new (yymsp[0].minor.yy0, NULL);
  1130. LOG_TRACE("Created plain literal: \"%s\"", yylhsminor.yy50->data);
  1131. free (yymsp[0].minor.yy0);
  1132. }
  1133. #line 1201 "../../build/grammar_ttl.c"
  1134. yymsp[0].minor.yy50 = yylhsminor.yy50;
  1135. break;
  1136. case 12: /* literal ::= STRING LANGTAG */
  1137. #line 151 "grammar_ttl.y"
  1138. {
  1139. yylhsminor.yy50 = VOLK_lt_literal_new (yymsp[-1].minor.yy0, yymsp[0].minor.yy0);
  1140. LOG_TRACE("Created LT-literal: \"%s\"@%s", yylhsminor.yy50->data, yylhsminor.yy50->lang);
  1141. free (yymsp[-1].minor.yy0);
  1142. free (yymsp[0].minor.yy0);
  1143. }
  1144. #line 1212 "../../build/grammar_ttl.c"
  1145. yymsp[-1].minor.yy50 = yylhsminor.yy50;
  1146. break;
  1147. case 13: /* literal ::= STRING DTYPE_MARKER resource */
  1148. #line 157 "grammar_ttl.y"
  1149. {
  1150. yylhsminor.yy50 = VOLK_literal_new (yymsp[-2].minor.yy0, yymsp[0].minor.yy50);
  1151. LOG_TRACE(
  1152. "Created DT-literal: \"%s\"^^%s",
  1153. yylhsminor.yy50->data, yylhsminor.yy50->datatype);
  1154. free (yymsp[-2].minor.yy0);
  1155. }
  1156. #line 1224 "../../build/grammar_ttl.c"
  1157. yy_destructor(yypParser,19,&yymsp[-1].minor);
  1158. yymsp[-2].minor.yy50 = yylhsminor.yy50;
  1159. break;
  1160. case 14: /* literal ::= INTEGER */
  1161. #line 164 "grammar_ttl.y"
  1162. {
  1163. yylhsminor.yy50 = VOLK_literal_new (yymsp[0].minor.yy0, VOLK_iriref_new_ns ("xsd:integer"));
  1164. free (yymsp[0].minor.yy0);
  1165. }
  1166. #line 1234 "../../build/grammar_ttl.c"
  1167. yymsp[0].minor.yy50 = yylhsminor.yy50;
  1168. break;
  1169. case 15: /* literal ::= DOUBLE */
  1170. #line 168 "grammar_ttl.y"
  1171. {
  1172. yylhsminor.yy50 = VOLK_literal_new (yymsp[0].minor.yy0, VOLK_iriref_new_ns ("xsd:double"));
  1173. free (yymsp[0].minor.yy0);
  1174. }
  1175. #line 1243 "../../build/grammar_ttl.c"
  1176. yymsp[0].minor.yy50 = yylhsminor.yy50;
  1177. break;
  1178. case 16: /* literal ::= DECIMAL */
  1179. #line 172 "grammar_ttl.y"
  1180. {
  1181. yylhsminor.yy50 = VOLK_literal_new (yymsp[0].minor.yy0, VOLK_iriref_new_ns ("xsd:decimal"));
  1182. free (yymsp[0].minor.yy0);
  1183. }
  1184. #line 1252 "../../build/grammar_ttl.c"
  1185. yymsp[0].minor.yy50 = yylhsminor.yy50;
  1186. break;
  1187. case 17: /* literal ::= BOOLEAN */
  1188. #line 176 "grammar_ttl.y"
  1189. {
  1190. yylhsminor.yy50 = VOLK_literal_new (yymsp[0].minor.yy0, VOLK_iriref_new_ns ("xsd:boolean"));
  1191. free (yymsp[0].minor.yy0);
  1192. }
  1193. #line 1261 "../../build/grammar_ttl.c"
  1194. yymsp[0].minor.yy50 = yylhsminor.yy50;
  1195. break;
  1196. case 18: /* blank ::= BNODE_ID */
  1197. #line 183 "grammar_ttl.y"
  1198. {
  1199. yylhsminor.yy50 = VOLK_bnode_new (yymsp[0].minor.yy0);
  1200. LOG_TRACE("Created blank node: _:%s", yylhsminor.yy50->data);
  1201. free (yymsp[0].minor.yy0);
  1202. }
  1203. #line 1271 "../../build/grammar_ttl.c"
  1204. yymsp[0].minor.yy50 = yylhsminor.yy50;
  1205. break;
  1206. case 19: /* blank ::= ANON */
  1207. { yy_destructor(yypParser,20,&yymsp[0].minor);
  1208. #line 188 "grammar_ttl.y"
  1209. {
  1210. LOG_TRACE ("Found empty BNode.");
  1211. yymsp[0].minor.yy50 = VOLK_bnode_new (NULL);
  1212. LOG_TRACE("Created empty list BN: _:%s", yymsp[0].minor.yy50->data);
  1213. }
  1214. #line 1282 "../../build/grammar_ttl.c"
  1215. }
  1216. break;
  1217. case 20: /* blank ::= LBRACKET predObjList RBRACKET */
  1218. { yy_destructor(yypParser,21,&yymsp[-2].minor);
  1219. #line 193 "grammar_ttl.y"
  1220. {
  1221. LOG_TRACE ("Found BNode with data.");
  1222. yymsp[-2].minor.yy50 = VOLK_bnode_new (NULL);
  1223. state->lms = yymsp[-2].minor.yy50;
  1224. state->ct += VOLK_graph_add_link_map (state->it, yymsp[-1].minor.yy34);
  1225. LOG_TRACE("Created list BN: _:%s", yymsp[-2].minor.yy50->data);
  1226. VOLK_link_map_free (yymsp[-1].minor.yy34);
  1227. }
  1228. #line 1297 "../../build/grammar_ttl.c"
  1229. yy_destructor(yypParser,22,&yymsp[0].minor);
  1230. }
  1231. break;
  1232. case 21: /* blank ::= LPAREN RPAREN */
  1233. { yy_destructor(yypParser,23,&yymsp[-1].minor);
  1234. #line 203 "grammar_ttl.y"
  1235. {
  1236. yymsp[-1].minor.yy50 = VOLK_iriref_new_ns ("rdf:nil");
  1237. LOG_TRACE("Created list terminator: %s", yymsp[-1].minor.yy50->data);
  1238. }
  1239. #line 1308 "../../build/grammar_ttl.c"
  1240. yy_destructor(yypParser,24,&yymsp[0].minor);
  1241. }
  1242. break;
  1243. case 22: /* collection ::= LPAREN itemList RPAREN */
  1244. { yy_destructor(yypParser,23,&yymsp[-2].minor);
  1245. #line 212 "grammar_ttl.y"
  1246. {
  1247. yymsp[-2].minor.yy50 = VOLK_bnode_add_collection (state->it, yymsp[-1].minor.yy22);
  1248. VOLK_term_set_free (yymsp[-1].minor.yy22);
  1249. }
  1250. #line 1319 "../../build/grammar_ttl.c"
  1251. yy_destructor(yypParser,24,&yymsp[0].minor);
  1252. }
  1253. break;
  1254. case 23: /* itemList ::= itemList ows object */
  1255. #line 219 "grammar_ttl.y"
  1256. {
  1257. if (VOLK_term_set_add (yymsp[-2].minor.yy22, yymsp[0].minor.yy50, NULL) == VOLK_NOACTION)
  1258. VOLK_term_free (yymsp[0].minor.yy50);
  1259. yylhsminor.yy22 = yymsp[-2].minor.yy22;
  1260. }
  1261. #line 1330 "../../build/grammar_ttl.c"
  1262. yymsp[-2].minor.yy22 = yylhsminor.yy22;
  1263. break;
  1264. case 24: /* itemList ::= object */
  1265. #line 224 "grammar_ttl.y"
  1266. {
  1267. yylhsminor.yy22 = VOLK_term_set_new ();
  1268. VOLK_term_set_add (yylhsminor.yy22, yymsp[0].minor.yy50, NULL);
  1269. }
  1270. #line 1339 "../../build/grammar_ttl.c"
  1271. yymsp[0].minor.yy22 = yylhsminor.yy22;
  1272. break;
  1273. case 25: /* resource ::= IRIREF */
  1274. #line 231 "grammar_ttl.y"
  1275. {
  1276. VOLK_Term *rel_iri = VOLK_iriref_new (yymsp[0].minor.yy0);
  1277. free (yymsp[0].minor.yy0);
  1278. if (state->base) {
  1279. yylhsminor.yy50 = VOLK_iriref_new_abs (rel_iri, state->base);
  1280. VOLK_term_free (rel_iri);
  1281. } else {
  1282. yylhsminor.yy50 = rel_iri;
  1283. }
  1284. LOG_TRACE("Created IRI: <%s>", yylhsminor.yy50->data);
  1285. }
  1286. #line 1355 "../../build/grammar_ttl.c"
  1287. yymsp[0].minor.yy50 = yylhsminor.yy50;
  1288. break;
  1289. case 26: /* resource ::= QNAME */
  1290. #line 242 "grammar_ttl.y"
  1291. {
  1292. yylhsminor.yy50 = VOLK_iriref_new_ns (yymsp[0].minor.yy0);
  1293. LOG_TRACE("Created IRI: %s", yylhsminor.yy50->data);
  1294. free (yymsp[0].minor.yy0);
  1295. }
  1296. #line 1365 "../../build/grammar_ttl.c"
  1297. yymsp[0].minor.yy50 = yylhsminor.yy50;
  1298. break;
  1299. case 27: /* turtleDoc ::= statements EOF */
  1300. #line 54 "grammar_ttl.y"
  1301. {
  1302. }
  1303. #line 1372 "../../build/grammar_ttl.c"
  1304. yy_destructor(yypParser,15,&yymsp[0].minor);
  1305. break;
  1306. case 33: /* statement ::= WS */
  1307. case 39: /* ows ::= WS */ yytestcase(yyruleno==39);
  1308. { yy_destructor(yypParser,16,&yymsp[0].minor);
  1309. #line 61 "grammar_ttl.y"
  1310. {
  1311. }
  1312. #line 1381 "../../build/grammar_ttl.c"
  1313. }
  1314. break;
  1315. case 34: /* predicate ::= resource */
  1316. case 35: /* object ::= resource */ yytestcase(yyruleno==35);
  1317. { yy_destructor(yypParser,37,&yymsp[0].minor);
  1318. #line 135 "grammar_ttl.y"
  1319. {
  1320. }
  1321. #line 1390 "../../build/grammar_ttl.c"
  1322. }
  1323. break;
  1324. case 36: /* object ::= blank */
  1325. { yy_destructor(yypParser,38,&yymsp[0].minor);
  1326. #line 141 "grammar_ttl.y"
  1327. {
  1328. }
  1329. #line 1398 "../../build/grammar_ttl.c"
  1330. }
  1331. break;
  1332. case 37: /* object ::= literal */
  1333. { yy_destructor(yypParser,39,&yymsp[0].minor);
  1334. #line 142 "grammar_ttl.y"
  1335. {
  1336. }
  1337. #line 1406 "../../build/grammar_ttl.c"
  1338. }
  1339. break;
  1340. case 38: /* blank ::= collection */
  1341. { yy_destructor(yypParser,40,&yymsp[0].minor);
  1342. #line 202 "grammar_ttl.y"
  1343. {
  1344. }
  1345. #line 1414 "../../build/grammar_ttl.c"
  1346. }
  1347. break;
  1348. default:
  1349. /* (28) statements ::= statements statement */ yytestcase(yyruleno==28);
  1350. /* (29) statements ::= */ yytestcase(yyruleno==29);
  1351. /* (30) statement ::= prefixID (OPTIMIZED OUT) */ assert(yyruleno!=30);
  1352. /* (31) statement ::= base (OPTIMIZED OUT) */ assert(yyruleno!=31);
  1353. /* (32) statement ::= triples (OPTIMIZED OUT) */ assert(yyruleno!=32);
  1354. /* (40) ows ::= */ yytestcase(yyruleno==40);
  1355. break;
  1356. /********** End reduce actions ************************************************/
  1357. };
  1358. assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
  1359. yygoto = yyRuleInfoLhs[yyruleno];
  1360. yysize = yyRuleInfoNRhs[yyruleno];
  1361. yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
  1362. /* There are no SHIFTREDUCE actions on nonterminals because the table
  1363. ** generator has simplified them to pure REDUCE actions. */
  1364. assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );
  1365. /* It is not possible for a REDUCE to be followed by an error */
  1366. assert( yyact!=YY_ERROR_ACTION );
  1367. yymsp += yysize+1;
  1368. yypParser->yytos = yymsp;
  1369. yymsp->stateno = (YYACTIONTYPE)yyact;
  1370. yymsp->major = (YYCODETYPE)yygoto;
  1371. yyTraceShift(yypParser, yyact, "... then shift");
  1372. return yyact;
  1373. }
  1374. /*
  1375. ** The following code executes when the parse fails
  1376. */
  1377. #ifndef YYNOERRORRECOVERY
  1378. static void yy_parse_failed(
  1379. yyParser *yypParser /* The parser */
  1380. ){
  1381. TTLParseARG_FETCH
  1382. TTLParseCTX_FETCH
  1383. #ifndef NDEBUG
  1384. if( yyTraceFILE ){
  1385. fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
  1386. }
  1387. #endif
  1388. while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
  1389. /* Here code is inserted which will be executed whenever the
  1390. ** parser fails */
  1391. /************ Begin %parse_failure code ***************************************/
  1392. #line 22 "grammar_ttl.y"
  1393. log_error ("TTL parse error. Cannot continue.");
  1394. state->rc = VOLK_PARSE_ERR;
  1395. #line 1469 "../../build/grammar_ttl.c"
  1396. /************ End %parse_failure code *****************************************/
  1397. TTLParseARG_STORE /* Suppress warning about unused %extra_argument variable */
  1398. TTLParseCTX_STORE
  1399. }
  1400. #endif /* YYNOERRORRECOVERY */
  1401. /*
  1402. ** The following code executes when a syntax error first occurs.
  1403. */
  1404. static void yy_syntax_error(
  1405. yyParser *yypParser, /* The parser */
  1406. int yymajor, /* The major type of the error token */
  1407. TTLParseTOKENTYPE yyminor /* The minor type of the error token */
  1408. ){
  1409. TTLParseARG_FETCH
  1410. TTLParseCTX_FETCH
  1411. #define TOKEN yyminor
  1412. /************ Begin %syntax_error code ****************************************/
  1413. #line 27 "grammar_ttl.y"
  1414. // Fail immediately on first error.
  1415. yy_parse_failed (yypParser);
  1416. #line 1492 "../../build/grammar_ttl.c"
  1417. /************ End %syntax_error code ******************************************/
  1418. TTLParseARG_STORE /* Suppress warning about unused %extra_argument variable */
  1419. TTLParseCTX_STORE
  1420. }
  1421. /*
  1422. ** The following is executed when the parser accepts
  1423. */
  1424. static void yy_accept(
  1425. yyParser *yypParser /* The parser */
  1426. ){
  1427. TTLParseARG_FETCH
  1428. TTLParseCTX_FETCH
  1429. #ifndef NDEBUG
  1430. if( yyTraceFILE ){
  1431. fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
  1432. }
  1433. #endif
  1434. #ifndef YYNOERRORRECOVERY
  1435. yypParser->yyerrcnt = -1;
  1436. #endif
  1437. assert( yypParser->yytos==yypParser->yystack );
  1438. /* Here code is inserted which will be executed whenever the
  1439. ** parser accepts */
  1440. /*********** Begin %parse_accept code *****************************************/
  1441. /*********** End %parse_accept code *******************************************/
  1442. TTLParseARG_STORE /* Suppress warning about unused %extra_argument variable */
  1443. TTLParseCTX_STORE
  1444. }
  1445. /* The main parser program.
  1446. ** The first argument is a pointer to a structure obtained from
  1447. ** "TTLParseAlloc" which describes the current state of the parser.
  1448. ** The second argument is the major token number. The third is
  1449. ** the minor token. The fourth optional argument is whatever the
  1450. ** user wants (and specified in the grammar) and is available for
  1451. ** use by the action routines.
  1452. **
  1453. ** Inputs:
  1454. ** <ul>
  1455. ** <li> A pointer to the parser (an opaque structure.)
  1456. ** <li> The major token number.
  1457. ** <li> The minor token number.
  1458. ** <li> An option argument of a grammar-specified type.
  1459. ** </ul>
  1460. **
  1461. ** Outputs:
  1462. ** None.
  1463. */
  1464. void TTLParse(
  1465. void *yyp, /* The parser */
  1466. int yymajor, /* The major token code number */
  1467. TTLParseTOKENTYPE yyminor /* The value for the token */
  1468. TTLParseARG_PDECL /* Optional %extra_argument parameter */
  1469. ){
  1470. YYMINORTYPE yyminorunion;
  1471. YYACTIONTYPE yyact; /* The parser action. */
  1472. #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
  1473. int yyendofinput; /* True if we are at the end of input */
  1474. #endif
  1475. #ifdef YYERRORSYMBOL
  1476. int yyerrorhit = 0; /* True if yymajor has invoked an error */
  1477. #endif
  1478. yyParser *yypParser = (yyParser*)yyp; /* The parser */
  1479. TTLParseCTX_FETCH
  1480. TTLParseARG_STORE
  1481. assert( yypParser->yytos!=0 );
  1482. #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
  1483. yyendofinput = (yymajor==0);
  1484. #endif
  1485. yyact = yypParser->yytos->stateno;
  1486. #ifndef NDEBUG
  1487. if( yyTraceFILE ){
  1488. if( yyact < YY_MIN_REDUCE ){
  1489. fprintf(yyTraceFILE,"%sInput '%s' in state %d\n",
  1490. yyTracePrompt,yyTokenName[yymajor],yyact);
  1491. }else{
  1492. fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
  1493. yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE);
  1494. }
  1495. }
  1496. #endif
  1497. while(1){ /* Exit by "break" */
  1498. assert( yypParser->yytos>=yypParser->yystack );
  1499. assert( yyact==yypParser->yytos->stateno );
  1500. yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);
  1501. if( yyact >= YY_MIN_REDUCE ){
  1502. unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */
  1503. #ifndef NDEBUG
  1504. assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
  1505. if( yyTraceFILE ){
  1506. int yysize = yyRuleInfoNRhs[yyruleno];
  1507. if( yysize ){
  1508. fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
  1509. yyTracePrompt,
  1510. yyruleno, yyRuleName[yyruleno],
  1511. yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action",
  1512. yypParser->yytos[yysize].stateno);
  1513. }else{
  1514. fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n",
  1515. yyTracePrompt, yyruleno, yyRuleName[yyruleno],
  1516. yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action");
  1517. }
  1518. }
  1519. #endif /* NDEBUG */
  1520. /* Check that the stack is large enough to grow by a single entry
  1521. ** if the RHS of the rule is empty. This ensures that there is room
  1522. ** enough on the stack to push the LHS value */
  1523. if( yyRuleInfoNRhs[yyruleno]==0 ){
  1524. #ifdef YYTRACKMAXSTACKDEPTH
  1525. if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
  1526. yypParser->yyhwm++;
  1527. assert( yypParser->yyhwm ==
  1528. (int)(yypParser->yytos - yypParser->yystack));
  1529. }
  1530. #endif
  1531. #if YYSTACKDEPTH>0
  1532. if( yypParser->yytos>=yypParser->yystackEnd ){
  1533. yyStackOverflow(yypParser);
  1534. break;
  1535. }
  1536. #else
  1537. if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
  1538. if( yyGrowStack(yypParser) ){
  1539. yyStackOverflow(yypParser);
  1540. break;
  1541. }
  1542. }
  1543. #endif
  1544. }
  1545. yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor TTLParseCTX_PARAM);
  1546. }else if( yyact <= YY_MAX_SHIFTREDUCE ){
  1547. yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor);
  1548. #ifndef YYNOERRORRECOVERY
  1549. yypParser->yyerrcnt--;
  1550. #endif
  1551. break;
  1552. }else if( yyact==YY_ACCEPT_ACTION ){
  1553. yypParser->yytos--;
  1554. yy_accept(yypParser);
  1555. return;
  1556. }else{
  1557. assert( yyact == YY_ERROR_ACTION );
  1558. yyminorunion.yy0 = yyminor;
  1559. #ifdef YYERRORSYMBOL
  1560. int yymx;
  1561. #endif
  1562. #ifndef NDEBUG
  1563. if( yyTraceFILE ){
  1564. fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
  1565. }
  1566. #endif
  1567. #ifdef YYERRORSYMBOL
  1568. /* A syntax error has occurred.
  1569. ** The response to an error depends upon whether or not the
  1570. ** grammar defines an error token "ERROR".
  1571. **
  1572. ** This is what we do if the grammar does define ERROR:
  1573. **
  1574. ** * Call the %syntax_error function.
  1575. **
  1576. ** * Begin popping the stack until we enter a state where
  1577. ** it is legal to shift the error symbol, then shift
  1578. ** the error symbol.
  1579. **
  1580. ** * Set the error count to three.
  1581. **
  1582. ** * Begin accepting and shifting new tokens. No new error
  1583. ** processing will occur until three tokens have been
  1584. ** shifted successfully.
  1585. **
  1586. */
  1587. if( yypParser->yyerrcnt<0 ){
  1588. yy_syntax_error(yypParser,yymajor,yyminor);
  1589. }
  1590. yymx = yypParser->yytos->major;
  1591. if( yymx==YYERRORSYMBOL || yyerrorhit ){
  1592. #ifndef NDEBUG
  1593. if( yyTraceFILE ){
  1594. fprintf(yyTraceFILE,"%sDiscard input token %s\n",
  1595. yyTracePrompt,yyTokenName[yymajor]);
  1596. }
  1597. #endif
  1598. yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
  1599. yymajor = YYNOCODE;
  1600. }else{
  1601. while( yypParser->yytos > yypParser->yystack ){
  1602. yyact = yy_find_reduce_action(yypParser->yytos->stateno,
  1603. YYERRORSYMBOL);
  1604. if( yyact<=YY_MAX_SHIFTREDUCE ) break;
  1605. yy_pop_parser_stack(yypParser);
  1606. }
  1607. if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){
  1608. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1609. yy_parse_failed(yypParser);
  1610. #ifndef YYNOERRORRECOVERY
  1611. yypParser->yyerrcnt = -1;
  1612. #endif
  1613. yymajor = YYNOCODE;
  1614. }else if( yymx!=YYERRORSYMBOL ){
  1615. yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
  1616. }
  1617. }
  1618. yypParser->yyerrcnt = 3;
  1619. yyerrorhit = 1;
  1620. if( yymajor==YYNOCODE ) break;
  1621. yyact = yypParser->yytos->stateno;
  1622. #elif defined(YYNOERRORRECOVERY)
  1623. /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
  1624. ** do any kind of error recovery. Instead, simply invoke the syntax
  1625. ** error routine and continue going as if nothing had happened.
  1626. **
  1627. ** Applications can set this macro (for example inside %include) if
  1628. ** they intend to abandon the parse upon the first syntax error seen.
  1629. */
  1630. yy_syntax_error(yypParser,yymajor, yyminor);
  1631. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1632. break;
  1633. #else /* YYERRORSYMBOL is not defined */
  1634. /* This is what we do if the grammar does not define ERROR:
  1635. **
  1636. ** * Report an error message, and throw away the input token.
  1637. **
  1638. ** * If the input token is $, then fail the parse.
  1639. **
  1640. ** As before, subsequent error messages are suppressed until
  1641. ** three input tokens have been successfully shifted.
  1642. */
  1643. if( yypParser->yyerrcnt<=0 ){
  1644. yy_syntax_error(yypParser,yymajor, yyminor);
  1645. }
  1646. yypParser->yyerrcnt = 3;
  1647. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1648. if( yyendofinput ){
  1649. yy_parse_failed(yypParser);
  1650. #ifndef YYNOERRORRECOVERY
  1651. yypParser->yyerrcnt = -1;
  1652. #endif
  1653. }
  1654. break;
  1655. #endif
  1656. }
  1657. }
  1658. #ifndef NDEBUG
  1659. if( yyTraceFILE ){
  1660. yyStackEntry *i;
  1661. char cDiv = '[';
  1662. fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
  1663. for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
  1664. fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
  1665. cDiv = ' ';
  1666. }
  1667. fprintf(yyTraceFILE,"]\n");
  1668. }
  1669. #endif
  1670. return;
  1671. }
  1672. /*
  1673. ** Return the fallback token corresponding to canonical token iToken, or
  1674. ** 0 if iToken has no fallback.
  1675. */
  1676. int TTLParseFallback(int iToken){
  1677. #ifdef YYFALLBACK
  1678. assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) );
  1679. return yyFallback[iToken];
  1680. #else
  1681. (void)iToken;
  1682. return 0;
  1683. #endif
  1684. }