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