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