/* This file is automatically generated by Lemon from input grammar ** source file "grammar_ttl.y". */ /** @brief Lemon parser grammar for Turtle. * * The `lemon' parser generator executable must be in your PATH: * https://sqlite.org/src/doc/trunk/doc/lemon.html * * TTL EBNF: https://www.w3.org/TeamSubmission/turtle/#sec-grammar-grammar */ #include "volksdata/codec.h" #line 39 "../../build/grammar_ttl.c" /**************** End of %include directives **********************************/ /* These constants specify the various numeric values for terminal symbols. ***************** Begin token definitions *************************************/ #ifndef T_PERIOD #define T_PERIOD 1 #define T_SEMICOLON 2 #define T_COMMA 3 #define T_STRING 4 #define T_INTEGER 5 #define T_DOUBLE 6 #define T_DECIMAL 7 #define T_BOOLEAN 8 #define T_BNODE_ID 9 #define T_QNAME 10 #define T_IRIREF 11 #define T_LANGTAG 12 #define T_PREFIX 13 #define T_COLON 14 #define T_EOF 15 #define T_WS 16 #define T_BASE 17 #define T_RDF_TYPE 18 #define T_DTYPE_MARKER 19 #define T_ANON 20 #define T_LBRACKET 21 #define T_RBRACKET 22 #define T_LPAREN 23 #define T_RPAREN 24 #endif /**************** End token definitions ***************************************/ /* The next sections is a series of control #defines. ** various aspects of the generated parser. ** YYCODETYPE is the data type used to store the integer codes ** that represent terminal and non-terminal symbols. ** "unsigned char" is used if there are fewer than ** 256 symbols. Larger types otherwise. ** YYNOCODE is a number of type YYCODETYPE that is not used for ** any terminal or nonterminal symbol. ** YYFALLBACK If defined, this indicates that one or more tokens ** (also known as: "terminal symbols") have fall-back ** values which should be used if the original symbol ** would not parse. This permits keywords to sometimes ** be used as identifiers, for example. ** YYACTIONTYPE is the data type used for "action codes" - numbers ** that indicate what to do in response to the next ** token. ** TTLParseTOKENTYPE is the data type used for minor type for terminal ** symbols. Background: A "minor type" is a semantic ** value associated with a terminal or non-terminal ** symbols. For example, for an "ID" terminal symbol, ** the minor type might be the name of the identifier. ** Each non-terminal can have a different minor type. ** Terminal symbols all have the same minor type, though. ** This macros defines the minor type for terminal ** symbols. ** YYMINORTYPE is the data type used for all minor types. ** This is typically a union of many types, one of ** which is TTLParseTOKENTYPE. The entry in the union ** for terminal symbols is called "yy0". ** YYSTACKDEPTH is the maximum depth of the parser's stack. If ** zero the stack is dynamically sized using realloc() ** TTLParseARG_SDECL A static variable declaration for the %extra_argument ** TTLParseARG_PDECL A parameter declaration for the %extra_argument ** TTLParseARG_PARAM Code to pass %extra_argument as a subroutine parameter ** TTLParseARG_STORE Code to store %extra_argument into yypParser ** TTLParseARG_FETCH Code to extract %extra_argument from yypParser ** TTLParseCTX_* As TTLParseARG_ except for %extra_context ** YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. ** YYNSTATE the combined number of states. ** YYNRULE the number of rules in the grammar ** YYNTOKEN Number of terminal symbols ** YY_MAX_SHIFT Maximum value for shift actions ** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions ** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions ** YY_ERROR_ACTION The yy_action[] code for syntax error ** YY_ACCEPT_ACTION The yy_action[] code for accept ** YY_NO_ACTION The yy_action[] code for no-op ** YY_MIN_REDUCE Minimum value for reduce actions ** YY_MAX_REDUCE Maximum value for reduce actions */ #ifndef INTERFACE # define INTERFACE 1 #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char #define YYNOCODE 42 #define YYACTIONTYPE unsigned char #define TTLParseTOKENTYPE char * typedef union { int yyinit; TTLParseTOKENTYPE yy0; char * yy1; VOLK_TermSet * yy22; VOLK_LinkMap * yy34; VOLK_Term * yy50; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define TTLParseARG_SDECL VOLK_TTLParserState *state ; #define TTLParseARG_PDECL , VOLK_TTLParserState *state #define TTLParseARG_PARAM ,state #define TTLParseARG_FETCH VOLK_TTLParserState *state =yypParser->state ; #define TTLParseARG_STORE yypParser->state =state ; #define TTLParseCTX_SDECL #define TTLParseCTX_PDECL #define TTLParseCTX_PARAM #define TTLParseCTX_FETCH #define TTLParseCTX_STORE #define YYNSTATE 28 #define YYNRULE 41 #define YYNRULE_WITH_ACTION 27 #define YYNTOKEN 25 #define YY_MAX_SHIFT 27 #define YY_MIN_SHIFTREDUCE 63 #define YY_MAX_SHIFTREDUCE 103 #define YY_ERROR_ACTION 104 #define YY_ACCEPT_ACTION 105 #define YY_NO_ACTION 106 #define YY_MIN_REDUCE 107 #define YY_MAX_REDUCE 147 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) /* Define the yytestcase() macro to be a no-op if is not already defined ** otherwise. ** ** Applications can choose to define yytestcase() in the %include section ** to a macro that can assist in verifying code coverage. For production ** code the yytestcase() macro should be turned off. But it is useful ** for testing. */ #ifndef yytestcase # define yytestcase(X) #endif /* Next are the tables used to determine what action to take based on the ** current state and lookahead token. These tables are used to implement ** functions that take a state number and lookahead value and return an ** action integer. ** ** Suppose the action integer is N. Then the action is determined as ** follows ** ** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead ** token onto the stack and goto state N. ** ** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then ** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE. ** ** N == YY_ERROR_ACTION A syntax error has occurred. ** ** N == YY_ACCEPT_ACTION The parser accepts its input. ** ** N == YY_NO_ACTION No such action. Denotes unused ** slots in the yy_action[] table. ** ** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE ** and YY_MAX_REDUCE ** ** The action table is constructed as a single large table named yy_action[]. ** Given state S and lookahead X, the action is computed as either: ** ** (A) N = yy_action[ yy_shift_ofst[S] + X ] ** (B) N = yy_default[S] ** ** The (A) formula is preferred. The B formula is used instead if ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X. ** ** The formulas above are for computing the action when the lookahead is ** a terminal symbol. If the lookahead is a non-terminal (as occurs after ** a reduce action) then the yy_reduce_ofst[] array is used in place of ** the yy_shift_ofst[] array. ** ** The following are the tables generated in this section: ** ** yy_action[] A single table containing all actions. ** yy_lookahead[] A table containing the lookahead for each entry in ** yy_action. Used to detect hash collisions. ** yy_shift_ofst[] For each state, the offset into yy_action for ** shifting terminals. ** yy_reduce_ofst[] For each state, the offset into yy_action for ** shifting non-terminals after a reduce. ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ #define YY_ACTTAB_COUNT (115) static const YYACTIONTYPE yy_action[] = { /* 0 */ 105, 1, 65, 9, 17, 77, 78, 79, 80, 81, /* 10 */ 89, 88, 17, 77, 78, 79, 80, 81, 89, 88, /* 20 */ 82, 7, 14, 2, 84, 14, 16, 13, 82, 7, /* 30 */ 13, 2, 120, 81, 89, 88, 5, 26, 102, 27, /* 40 */ 96, 23, 18, 13, 82, 7, 13, 2, 135, 135, /* 50 */ 135, 135, 15, 130, 130, 130, 130, 130, 115, 116, /* 60 */ 3, 116, 89, 88, 4, 131, 131, 131, 131, 131, /* 70 */ 11, 19, 114, 114, 114, 114, 114, 20, 114, 114, /* 80 */ 114, 114, 114, 66, 113, 113, 113, 113, 113, 89, /* 90 */ 88, 102, 89, 88, 10, 75, 8, 73, 6, 85, /* 100 */ 73, 64, 12, 22, 21, 63, 25, 24, 134, 106, /* 110 */ 106, 106, 106, 106, 83, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 25, 26, 1, 2, 4, 5, 6, 7, 8, 9, /* 10 */ 10, 11, 4, 5, 6, 7, 8, 9, 10, 11, /* 20 */ 20, 21, 34, 23, 24, 37, 33, 34, 20, 21, /* 30 */ 37, 23, 37, 9, 10, 11, 32, 13, 16, 15, /* 40 */ 16, 17, 33, 34, 20, 21, 37, 23, 27, 28, /* 50 */ 29, 30, 31, 36, 37, 38, 39, 40, 37, 38, /* 60 */ 32, 40, 10, 11, 32, 36, 37, 38, 39, 40, /* 70 */ 41, 35, 36, 37, 38, 39, 40, 35, 36, 37, /* 80 */ 38, 39, 40, 1, 36, 37, 38, 39, 40, 10, /* 90 */ 11, 16, 10, 11, 2, 12, 32, 18, 3, 24, /* 100 */ 18, 1, 19, 16, 11, 1, 16, 11, 0, 42, /* 110 */ 42, 42, 42, 42, 22, 42, 42, 42, 42, 42, /* 120 */ 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, /* 130 */ 42, 42, 42, 42, 25, 25, 25, 25, 25, 25, }; #define YY_SHIFT_COUNT (27) #define YY_SHIFT_MIN (0) #define YY_SHIFT_MAX (108) static const unsigned char yy_shift_ofst[] = { /* 0 */ 115, 24, 0, 8, 8, 8, 8, 79, 79, 82, /* 10 */ 79, 75, 52, 22, 22, 22, 92, 83, 1, 95, /* 20 */ 95, 100, 93, 87, 104, 96, 90, 108, }; #define YY_REDUCE_COUNT (15) #define YY_REDUCE_MIN (-25) #define YY_REDUCE_MAX (64) static const signed char yy_reduce_ofst[] = { /* 0 */ -25, 21, 29, 36, 42, 17, 48, -7, 9, -12, /* 10 */ -12, 4, -5, 28, 32, 64, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 136, 104, 104, 104, 104, 104, 104, 104, 104, 104, /* 10 */ 104, 147, 104, 147, 147, 147, 104, 118, 104, 111, /* 20 */ 112, 104, 104, 104, 104, 104, 104, 104, }; /********** End of lemon-generated parsing tables *****************************/ /* The next table maps tokens (terminal symbols) into fallback tokens. ** If a construct like the following: ** ** %fallback ID X Y Z. ** ** appears in the grammar, then ID becomes a fallback token for X, Y, ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser ** but it does not parse, the type of the token is changed to ID and ** the parse is retried before an error is thrown. ** ** This feature can be used, for example, to cause some keywords in a language ** to revert to identifiers if they keyword does not apply in the context where ** it appears. */ #ifdef YYFALLBACK static const YYCODETYPE yyFallback[] = { }; #endif /* YYFALLBACK */ /* The following structure represents a single element of the ** parser's stack. Information stored includes: ** ** + The state number for the parser at this level of the stack. ** ** + The value of the token stored at this level of the stack. ** (In other words, the "major" token.) ** ** + The semantic value stored at this level of the stack. This is ** the information used by the action routines in the grammar. ** It is sometimes called the "minor" token. ** ** After the "shift" half of a SHIFTREDUCE action, the stateno field ** actually contains the reduce action for the second half of the ** SHIFTREDUCE. */ struct yyStackEntry { YYACTIONTYPE stateno; /* The state-number, or reduce action in SHIFTREDUCE */ YYCODETYPE major; /* The major token value. This is the code ** number for the token at this stack level */ YYMINORTYPE minor; /* The user-supplied minor token value. This ** is the value of the token */ }; typedef struct yyStackEntry yyStackEntry; /* The state of the parser is completely contained in an instance of ** the following structure */ struct yyParser { yyStackEntry *yytos; /* Pointer to top element of the stack */ #ifdef YYTRACKMAXSTACKDEPTH int yyhwm; /* High-water mark of the stack */ #endif #ifndef YYNOERRORRECOVERY int yyerrcnt; /* Shifts left before out of the error */ #endif TTLParseARG_SDECL /* A place to hold %extra_argument */ TTLParseCTX_SDECL /* A place to hold %extra_context */ #if YYSTACKDEPTH<=0 int yystksz; /* Current side of the stack */ yyStackEntry *yystack; /* The parser's stack */ yyStackEntry yystk0; /* First stack entry */ #else yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ yyStackEntry *yystackEnd; /* Last entry in the stack */ #endif }; typedef struct yyParser yyParser; #include #ifndef NDEBUG #include static FILE *yyTraceFILE = 0; static char *yyTracePrompt = 0; #endif /* NDEBUG */ #ifndef NDEBUG /* ** Turn parser tracing on by giving a stream to which to write the trace ** and a prompt to preface each trace message. Tracing is turned off ** by making either argument NULL ** ** Inputs: ** ** ** Outputs: ** None. */ void TTLParseTrace(FILE *TraceFILE, char *zTracePrompt){ yyTraceFILE = TraceFILE; yyTracePrompt = zTracePrompt; if( yyTraceFILE==0 ) yyTracePrompt = 0; else if( yyTracePrompt==0 ) yyTraceFILE = 0; } #endif /* NDEBUG */ #if defined(YYCOVERAGE) || !defined(NDEBUG) /* For tracing shifts, the names of all terminals and nonterminals ** are required. The following table supplies these names */ static const char *const yyTokenName[] = { /* 0 */ "$", /* 1 */ "PERIOD", /* 2 */ "SEMICOLON", /* 3 */ "COMMA", /* 4 */ "STRING", /* 5 */ "INTEGER", /* 6 */ "DOUBLE", /* 7 */ "DECIMAL", /* 8 */ "BOOLEAN", /* 9 */ "BNODE_ID", /* 10 */ "QNAME", /* 11 */ "IRIREF", /* 12 */ "LANGTAG", /* 13 */ "PREFIX", /* 14 */ "COLON", /* 15 */ "EOF", /* 16 */ "WS", /* 17 */ "BASE", /* 18 */ "RDF_TYPE", /* 19 */ "DTYPE_MARKER", /* 20 */ "ANON", /* 21 */ "LBRACKET", /* 22 */ "RBRACKET", /* 23 */ "LPAREN", /* 24 */ "RPAREN", /* 25 */ "turtleDoc", /* 26 */ "statements", /* 27 */ "statement", /* 28 */ "prefixID", /* 29 */ "base", /* 30 */ "triples", /* 31 */ "subject", /* 32 */ "ows", /* 33 */ "predObjList", /* 34 */ "predicate", /* 35 */ "objectList", /* 36 */ "object", /* 37 */ "resource", /* 38 */ "blank", /* 39 */ "literal", /* 40 */ "collection", /* 41 */ "itemList", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ #ifndef NDEBUG /* For tracing reduce actions, the names of all rules are required. */ static const char *const yyRuleName[] = { /* 0 */ "prefixID ::= PREFIX WS IRIREF PERIOD", /* 1 */ "base ::= BASE WS IRIREF PERIOD", /* 2 */ "triples ::= subject ows predObjList PERIOD", /* 3 */ "triples ::= subject ows predObjList SEMICOLON PERIOD", /* 4 */ "predObjList ::= predicate ows objectList", /* 5 */ "predObjList ::= predObjList SEMICOLON predicate ows objectList", /* 6 */ "objectList ::= objectList COMMA object", /* 7 */ "objectList ::= object", /* 8 */ "subject ::= resource", /* 9 */ "subject ::= blank", /* 10 */ "predicate ::= RDF_TYPE", /* 11 */ "literal ::= STRING", /* 12 */ "literal ::= STRING LANGTAG", /* 13 */ "literal ::= STRING DTYPE_MARKER resource", /* 14 */ "literal ::= INTEGER", /* 15 */ "literal ::= DOUBLE", /* 16 */ "literal ::= DECIMAL", /* 17 */ "literal ::= BOOLEAN", /* 18 */ "blank ::= BNODE_ID", /* 19 */ "blank ::= ANON", /* 20 */ "blank ::= LBRACKET predObjList RBRACKET", /* 21 */ "blank ::= LPAREN RPAREN", /* 22 */ "collection ::= LPAREN itemList RPAREN", /* 23 */ "itemList ::= itemList ows object", /* 24 */ "itemList ::= object", /* 25 */ "resource ::= IRIREF", /* 26 */ "resource ::= QNAME", /* 27 */ "turtleDoc ::= statements EOF", /* 28 */ "statements ::= statements statement", /* 29 */ "statements ::=", /* 30 */ "statement ::= prefixID", /* 31 */ "statement ::= base", /* 32 */ "statement ::= triples", /* 33 */ "statement ::= WS", /* 34 */ "predicate ::= resource", /* 35 */ "object ::= resource", /* 36 */ "object ::= blank", /* 37 */ "object ::= literal", /* 38 */ "blank ::= collection", /* 39 */ "ows ::= WS", /* 40 */ "ows ::=", }; #endif /* NDEBUG */ #if YYSTACKDEPTH<=0 /* ** Try to increase the size of the parser stack. Return the number ** of errors. Return 0 on success. */ static int yyGrowStack(yyParser *p){ int newSize; int idx; yyStackEntry *pNew; newSize = p->yystksz*2 + 100; idx = p->yytos ? (int)(p->yytos - p->yystack) : 0; if( p->yystack==&p->yystk0 ){ pNew = malloc(newSize*sizeof(pNew[0])); if( pNew ) pNew[0] = p->yystk0; }else{ pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); } if( pNew ){ p->yystack = pNew; p->yytos = &p->yystack[idx]; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n", yyTracePrompt, p->yystksz, newSize); } #endif p->yystksz = newSize; } return pNew==0; } #endif /* Datatype of the argument to the memory allocated passed as the ** second argument to TTLParseAlloc() below. This can be changed by ** putting an appropriate #define in the %include section of the input ** grammar. */ #ifndef YYMALLOCARGTYPE # define YYMALLOCARGTYPE size_t #endif /* Initialize a new parser that has already been allocated. */ void TTLParseInit(void *yypRawParser TTLParseCTX_PDECL){ yyParser *yypParser = (yyParser*)yypRawParser; TTLParseCTX_STORE #ifdef YYTRACKMAXSTACKDEPTH yypParser->yyhwm = 0; #endif #if YYSTACKDEPTH<=0 yypParser->yytos = NULL; yypParser->yystack = NULL; yypParser->yystksz = 0; if( yyGrowStack(yypParser) ){ yypParser->yystack = &yypParser->yystk0; yypParser->yystksz = 1; } #endif #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif yypParser->yytos = yypParser->yystack; yypParser->yystack[0].stateno = 0; yypParser->yystack[0].major = 0; #if YYSTACKDEPTH>0 yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1]; #endif } #ifndef TTLParse_ENGINEALWAYSONSTACK /* ** This function allocates a new parser. ** The only argument is a pointer to a function which works like ** malloc. ** ** Inputs: ** A pointer to the function used to allocate memory. ** ** Outputs: ** A pointer to a parser. This pointer is used in subsequent calls ** to TTLParse and TTLParseFree. */ void *TTLParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) TTLParseCTX_PDECL){ yyParser *yypParser; yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); if( yypParser ){ TTLParseCTX_STORE TTLParseInit(yypParser TTLParseCTX_PARAM); } return (void*)yypParser; } #endif /* TTLParse_ENGINEALWAYSONSTACK */ /* The following function deletes the "minor type" or semantic value ** associated with a symbol. The symbol can be either a terminal ** or nonterminal. "yymajor" is the symbol code, and "yypminor" is ** a pointer to the value to be deleted. The code used to do the ** deletions is derived from the %destructor and/or %token_destructor ** directives of the input grammar. */ static void yy_destructor( yyParser *yypParser, /* The parser */ YYCODETYPE yymajor, /* Type code for object to destroy */ YYMINORTYPE *yypminor /* The object to be destroyed */ ){ TTLParseARG_FETCH TTLParseCTX_FETCH switch( yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen ** when the symbol is popped from the stack during a ** reduce or during error processing or when a parser is ** being destroyed before it is finished parsing. ** ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are *not* used ** inside the C code. */ /********* Begin destructor definitions ***************************************/ /* TERMINAL Destructor */ case 1: /* PERIOD */ case 2: /* SEMICOLON */ case 3: /* COMMA */ case 4: /* STRING */ case 5: /* INTEGER */ case 6: /* DOUBLE */ case 7: /* DECIMAL */ case 8: /* BOOLEAN */ case 9: /* BNODE_ID */ case 10: /* QNAME */ case 11: /* IRIREF */ case 12: /* LANGTAG */ case 13: /* PREFIX */ case 14: /* COLON */ case 15: /* EOF */ case 16: /* WS */ case 17: /* BASE */ case 18: /* RDF_TYPE */ case 19: /* DTYPE_MARKER */ case 20: /* ANON */ case 21: /* LBRACKET */ case 22: /* RBRACKET */ case 23: /* LPAREN */ case 24: /* RPAREN */ { #line 36 "grammar_ttl.y" (void) state; free ((yypminor->yy0)); #line 628 "../../build/grammar_ttl.c" } break; case 31: /* subject */ case 34: /* predicate */ case 36: /* object */ case 37: /* resource */ case 38: /* blank */ case 39: /* literal */ case 40: /* collection */ { #line 129 "grammar_ttl.y" VOLK_term_free ((yypminor->yy50)); #line 641 "../../build/grammar_ttl.c" } break; case 33: /* predObjList */ { #line 97 "grammar_ttl.y" VOLK_link_map_free ((yypminor->yy34)); #line 648 "../../build/grammar_ttl.c" } break; case 35: /* objectList */ case 41: /* itemList */ { #line 117 "grammar_ttl.y" VOLK_term_set_free ((yypminor->yy22)); #line 656 "../../build/grammar_ttl.c" } break; /********* End destructor definitions *****************************************/ default: break; /* If no destructor action specified: do nothing */ } } /* ** Pop the parser's stack once. ** ** If there is a destructor routine associated with the token which ** is popped from the stack, then call it. */ static void yy_pop_parser_stack(yyParser *pParser){ yyStackEntry *yytos; assert( pParser->yytos!=0 ); assert( pParser->yytos > pParser->yystack ); yytos = pParser->yytos--; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sPopping %s\n", yyTracePrompt, yyTokenName[yytos->major]); } #endif yy_destructor(pParser, yytos->major, &yytos->minor); } /* ** Clear all secondary memory allocations from the parser */ void TTLParseFinalize(void *p){ yyParser *pParser = (yyParser*)p; while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser); #if YYSTACKDEPTH<=0 if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack); #endif } #ifndef TTLParse_ENGINEALWAYSONSTACK /* ** Deallocate and destroy a parser. Destructors are called for ** all stack elements before shutting the parser down. ** ** If the YYPARSEFREENEVERNULL macro exists (for example because it ** is defined in a %include section of the input grammar) then it is ** assumed that the input pointer is never NULL. */ void TTLParseFree( void *p, /* The parser to be deleted */ void (*freeProc)(void*) /* Function used to reclaim memory */ ){ #ifndef YYPARSEFREENEVERNULL if( p==0 ) return; #endif TTLParseFinalize(p); (*freeProc)(p); } #endif /* TTLParse_ENGINEALWAYSONSTACK */ /* ** Return the peak depth of the stack for a parser. */ #ifdef YYTRACKMAXSTACKDEPTH int TTLParseStackPeak(void *p){ yyParser *pParser = (yyParser*)p; return pParser->yyhwm; } #endif /* This array of booleans keeps track of the parser statement ** coverage. The element yycoverage[X][Y] is set when the parser ** is in state X and has a lookahead token Y. In a well-tested ** systems, every element of this matrix should end up being set. */ #if defined(YYCOVERAGE) static unsigned char yycoverage[YYNSTATE][YYNTOKEN]; #endif /* ** Write into out a description of every state/lookahead combination that ** ** (1) has not been used by the parser, and ** (2) is not a syntax error. ** ** Return the number of missed state/lookahead combinations. */ #if defined(YYCOVERAGE) int TTLParseCoverage(FILE *out){ int stateno, iLookAhead, i; int nMissed = 0; for(stateno=0; statenoYY_MAX_SHIFT ) return stateno; assert( stateno <= YY_SHIFT_COUNT ); #if defined(YYCOVERAGE) yycoverage[stateno][iLookAhead] = 1; #endif do{ i = yy_shift_ofst[stateno]; assert( i>=0 ); assert( i<=YY_ACTTAB_COUNT ); assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); assert( iLookAhead!=YYNOCODE ); assert( iLookAhead < YYNTOKEN ); i += iLookAhead; assert( i<(int)YY_NLOOKAHEAD ); if( yy_lookahead[i]!=iLookAhead ){ #ifdef YYFALLBACK YYCODETYPE iFallback; /* Fallback token */ assert( iLookAhead %s\n", yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); } #endif assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */ iLookAhead = iFallback; continue; } #endif #ifdef YYWILDCARD { int j = i - iLookAhead + YYWILDCARD; assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); } #endif /* NDEBUG */ return yy_action[j]; } } #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ assert( i>=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) ); return yy_action[i]; } }while(1); } /* ** Find the appropriate action for a parser given the non-terminal ** look-ahead token iLookAhead. */ static YYACTIONTYPE yy_find_reduce_action( YYACTIONTYPE stateno, /* Current state number */ YYCODETYPE iLookAhead /* The look-ahead token */ ){ int i; #ifdef YYERRORSYMBOL if( stateno>YY_REDUCE_COUNT ){ return yy_default[stateno]; } #else assert( stateno<=YY_REDUCE_COUNT ); #endif i = yy_reduce_ofst[stateno]; assert( iLookAhead!=YYNOCODE ); i += iLookAhead; #ifdef YYERRORSYMBOL if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ return yy_default[stateno]; } #else assert( i>=0 && iyytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ /******** Begin %stack_overflow code ******************************************/ #line 17 "grammar_ttl.y" log_error ("Stack oveflow in TTL parsing."); state->rc = VOLK_MEM_ERR; #line 878 "../../build/grammar_ttl.c" /******** End %stack_overflow code ********************************************/ TTLParseARG_STORE /* Suppress warning about unused %extra_argument var */ TTLParseCTX_STORE } /* ** Print tracing information for a SHIFT action */ #ifndef NDEBUG static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){ if( yyTraceFILE ){ if( yyNewStateyytos->major], yyNewState); }else{ fprintf(yyTraceFILE,"%s%s '%s', pending reduce %d\n", yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major], yyNewState - YY_MIN_REDUCE); } } } #else # define yyTraceShift(X,Y,Z) #endif /* ** Perform a shift action. */ static void yy_shift( yyParser *yypParser, /* The parser to be shifted */ YYACTIONTYPE yyNewState, /* The new state to shift in */ YYCODETYPE yyMajor, /* The major token to shift in */ TTLParseTOKENTYPE yyMinor /* The minor token to shift in */ ){ yyStackEntry *yytos; yypParser->yytos++; #ifdef YYTRACKMAXSTACKDEPTH if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) ); } #endif #if YYSTACKDEPTH>0 if( yypParser->yytos>yypParser->yystackEnd ){ yypParser->yytos--; yyStackOverflow(yypParser); return; } #else if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){ if( yyGrowStack(yypParser) ){ yypParser->yytos--; yyStackOverflow(yypParser); return; } } #endif if( yyNewState > YY_MAX_SHIFT ){ yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; } yytos = yypParser->yytos; yytos->stateno = yyNewState; yytos->major = yyMajor; yytos->minor.yy0 = yyMinor; yyTraceShift(yypParser, yyNewState, "Shift"); } /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { 28, /* (0) prefixID ::= PREFIX WS IRIREF PERIOD */ 29, /* (1) base ::= BASE WS IRIREF PERIOD */ 30, /* (2) triples ::= subject ows predObjList PERIOD */ 30, /* (3) triples ::= subject ows predObjList SEMICOLON PERIOD */ 33, /* (4) predObjList ::= predicate ows objectList */ 33, /* (5) predObjList ::= predObjList SEMICOLON predicate ows objectList */ 35, /* (6) objectList ::= objectList COMMA object */ 35, /* (7) objectList ::= object */ 31, /* (8) subject ::= resource */ 31, /* (9) subject ::= blank */ 34, /* (10) predicate ::= RDF_TYPE */ 39, /* (11) literal ::= STRING */ 39, /* (12) literal ::= STRING LANGTAG */ 39, /* (13) literal ::= STRING DTYPE_MARKER resource */ 39, /* (14) literal ::= INTEGER */ 39, /* (15) literal ::= DOUBLE */ 39, /* (16) literal ::= DECIMAL */ 39, /* (17) literal ::= BOOLEAN */ 38, /* (18) blank ::= BNODE_ID */ 38, /* (19) blank ::= ANON */ 38, /* (20) blank ::= LBRACKET predObjList RBRACKET */ 38, /* (21) blank ::= LPAREN RPAREN */ 40, /* (22) collection ::= LPAREN itemList RPAREN */ 41, /* (23) itemList ::= itemList ows object */ 41, /* (24) itemList ::= object */ 37, /* (25) resource ::= IRIREF */ 37, /* (26) resource ::= QNAME */ 25, /* (27) turtleDoc ::= statements EOF */ 26, /* (28) statements ::= statements statement */ 26, /* (29) statements ::= */ 27, /* (30) statement ::= prefixID */ 27, /* (31) statement ::= base */ 27, /* (32) statement ::= triples */ 27, /* (33) statement ::= WS */ 34, /* (34) predicate ::= resource */ 36, /* (35) object ::= resource */ 36, /* (36) object ::= blank */ 36, /* (37) object ::= literal */ 38, /* (38) blank ::= collection */ 32, /* (39) ows ::= WS */ 32, /* (40) ows ::= */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number ** of symbols on the right-hand side of that rule. */ static const signed char yyRuleInfoNRhs[] = { -4, /* (0) prefixID ::= PREFIX WS IRIREF PERIOD */ -4, /* (1) base ::= BASE WS IRIREF PERIOD */ -4, /* (2) triples ::= subject ows predObjList PERIOD */ -5, /* (3) triples ::= subject ows predObjList SEMICOLON PERIOD */ -3, /* (4) predObjList ::= predicate ows objectList */ -5, /* (5) predObjList ::= predObjList SEMICOLON predicate ows objectList */ -3, /* (6) objectList ::= objectList COMMA object */ -1, /* (7) objectList ::= object */ -1, /* (8) subject ::= resource */ -1, /* (9) subject ::= blank */ -1, /* (10) predicate ::= RDF_TYPE */ -1, /* (11) literal ::= STRING */ -2, /* (12) literal ::= STRING LANGTAG */ -3, /* (13) literal ::= STRING DTYPE_MARKER resource */ -1, /* (14) literal ::= INTEGER */ -1, /* (15) literal ::= DOUBLE */ -1, /* (16) literal ::= DECIMAL */ -1, /* (17) literal ::= BOOLEAN */ -1, /* (18) blank ::= BNODE_ID */ -1, /* (19) blank ::= ANON */ -3, /* (20) blank ::= LBRACKET predObjList RBRACKET */ -2, /* (21) blank ::= LPAREN RPAREN */ -3, /* (22) collection ::= LPAREN itemList RPAREN */ -3, /* (23) itemList ::= itemList ows object */ -1, /* (24) itemList ::= object */ -1, /* (25) resource ::= IRIREF */ -1, /* (26) resource ::= QNAME */ -2, /* (27) turtleDoc ::= statements EOF */ -2, /* (28) statements ::= statements statement */ 0, /* (29) statements ::= */ -1, /* (30) statement ::= prefixID */ -1, /* (31) statement ::= base */ -1, /* (32) statement ::= triples */ -1, /* (33) statement ::= WS */ -1, /* (34) predicate ::= resource */ -1, /* (35) object ::= resource */ -1, /* (36) object ::= blank */ -1, /* (37) object ::= literal */ -1, /* (38) blank ::= collection */ -1, /* (39) ows ::= WS */ 0, /* (40) ows ::= */ }; static void yy_accept(yyParser*); /* Forward Declaration */ /* ** Perform a reduce action and the shift that must immediately ** follow the reduce. ** ** The yyLookahead and yyLookaheadToken parameters provide reduce actions ** access to the lookahead token (if any). The yyLookahead will be YYNOCODE ** if the lookahead token has already been consumed. As this procedure is ** only called from one place, optimizing compilers will in-line it, which ** means that the extra parameters have no performance impact. */ static YYACTIONTYPE yy_reduce( yyParser *yypParser, /* The parser */ unsigned int yyruleno, /* Number of the rule by which to reduce */ int yyLookahead, /* Lookahead token, or YYNOCODE if none */ TTLParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ TTLParseCTX_PDECL /* %extra_context */ ){ int yygoto; /* The next state */ YYACTIONTYPE yyact; /* The next action */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ TTLParseARG_FETCH (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** #line ** { ... } // User supplied code ** #line ** break; */ /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* prefixID ::= PREFIX WS IRIREF PERIOD */ #line 63 "grammar_ttl.y" { VOLK_nsmap_add (yymsp[-3].minor.yy0, yymsp[-1].minor.yy0); free (yymsp[-3].minor.yy0); free (yymsp[-1].minor.yy0); } #line 1086 "../../build/grammar_ttl.c" yy_destructor(yypParser,16,&yymsp[-2].minor); yy_destructor(yypParser,1,&yymsp[0].minor); break; case 1: /* base ::= BASE WS IRIREF PERIOD */ { yy_destructor(yypParser,17,&yymsp[-3].minor); #line 70 "grammar_ttl.y" { VOLK_term_free (state->base); state->base = VOLK_iriref_new (yymsp[-1].minor.yy0); free (yymsp[-1].minor.yy0); } #line 1099 "../../build/grammar_ttl.c" yy_destructor(yypParser,16,&yymsp[-2].minor); yy_destructor(yypParser,1,&yymsp[0].minor); } break; case 2: /* triples ::= subject ows predObjList PERIOD */ #line 77 "grammar_ttl.y" { size_t ct = VOLK_graph_add_link_map (state->it, yymsp[-1].minor.yy34); state->ct += ct; state->rc = VOLK_OK; LOG_TRACE("Added %lu triples.", ct); VOLK_term_free (yymsp[-3].minor.yy50); VOLK_link_map_free (yymsp[-1].minor.yy34); } #line 1115 "../../build/grammar_ttl.c" yy_destructor(yypParser,1,&yymsp[0].minor); break; case 3: /* triples ::= subject ows predObjList SEMICOLON PERIOD */ #line 86 "grammar_ttl.y" { size_t ct = VOLK_graph_add_link_map (state->it, yymsp[-2].minor.yy34); state->ct += ct; state->rc = VOLK_OK; LOG_TRACE("Added %lu triples.", ct); VOLK_term_free (yymsp[-4].minor.yy50); VOLK_link_map_free (yymsp[-2].minor.yy34); } #line 1129 "../../build/grammar_ttl.c" yy_destructor(yypParser,2,&yymsp[-1].minor); yy_destructor(yypParser,1,&yymsp[0].minor); break; case 4: /* predObjList ::= predicate ows objectList */ #line 98 "grammar_ttl.y" { VOLK_Term *s; if (state->lms) s = state->lms; else { // TODO This may be brittle. It is not verifying the // full BNode syntax. log_info ("Link map subject not present. Assuming BNode."); s = VOLK_bnode_new (NULL); } yylhsminor.yy34 = VOLK_link_map_new (s, VOLK_LINK_OUTBOUND); VOLK_link_map_add (yylhsminor.yy34, yymsp[-2].minor.yy50, yymsp[0].minor.yy22); if (s != state->lms) VOLK_term_free (s); } #line 1148 "../../build/grammar_ttl.c" yymsp[-2].minor.yy34 = yylhsminor.yy34; break; case 5: /* predObjList ::= predObjList SEMICOLON predicate ows objectList */ #line 111 "grammar_ttl.y" { VOLK_link_map_add (yymsp[-4].minor.yy34, yymsp[-2].minor.yy50, yymsp[0].minor.yy22); yylhsminor.yy34 = yymsp[-4].minor.yy34; } #line 1157 "../../build/grammar_ttl.c" yy_destructor(yypParser,2,&yymsp[-3].minor); yymsp[-4].minor.yy34 = yylhsminor.yy34; break; case 6: /* objectList ::= objectList COMMA object */ #line 118 "grammar_ttl.y" { if (VOLK_term_set_add (yymsp[-2].minor.yy22, yymsp[0].minor.yy50, NULL) == VOLK_NOACTION) VOLK_term_free (yymsp[0].minor.yy50); yylhsminor.yy22 = yymsp[-2].minor.yy22; } #line 1168 "../../build/grammar_ttl.c" yy_destructor(yypParser,3,&yymsp[-1].minor); yymsp[-2].minor.yy22 = yylhsminor.yy22; break; case 7: /* objectList ::= object */ #line 123 "grammar_ttl.y" { yylhsminor.yy22 = VOLK_term_set_new(); VOLK_term_set_add (yylhsminor.yy22, yymsp[0].minor.yy50, NULL); } #line 1178 "../../build/grammar_ttl.c" yymsp[0].minor.yy22 = yylhsminor.yy22; break; case 8: /* subject ::= resource */ case 9: /* subject ::= blank */ yytestcase(yyruleno==9); #line 130 "grammar_ttl.y" { state->lms = yymsp[0].minor.yy50; } #line 1185 "../../build/grammar_ttl.c" break; case 10: /* predicate ::= RDF_TYPE */ { yy_destructor(yypParser,18,&yymsp[0].minor); #line 136 "grammar_ttl.y" { yymsp[0].minor.yy50 = VOLK_iriref_new_ns ("rdf:type"); } #line 1191 "../../build/grammar_ttl.c" } break; case 11: /* literal ::= STRING */ #line 146 "grammar_ttl.y" { yylhsminor.yy50 = VOLK_literal_new (yymsp[0].minor.yy0, NULL); LOG_TRACE("Created plain literal: \"%s\"", yylhsminor.yy50->data); free (yymsp[0].minor.yy0); } #line 1201 "../../build/grammar_ttl.c" yymsp[0].minor.yy50 = yylhsminor.yy50; break; case 12: /* literal ::= STRING LANGTAG */ #line 151 "grammar_ttl.y" { yylhsminor.yy50 = VOLK_lt_literal_new (yymsp[-1].minor.yy0, yymsp[0].minor.yy0); LOG_TRACE("Created LT-literal: \"%s\"@%s", yylhsminor.yy50->data, yylhsminor.yy50->lang); free (yymsp[-1].minor.yy0); free (yymsp[0].minor.yy0); } #line 1212 "../../build/grammar_ttl.c" yymsp[-1].minor.yy50 = yylhsminor.yy50; break; case 13: /* literal ::= STRING DTYPE_MARKER resource */ #line 157 "grammar_ttl.y" { yylhsminor.yy50 = VOLK_literal_new (yymsp[-2].minor.yy0, yymsp[0].minor.yy50); LOG_TRACE( "Created DT-literal: \"%s\"^^%s", yylhsminor.yy50->data, yylhsminor.yy50->datatype); free (yymsp[-2].minor.yy0); } #line 1224 "../../build/grammar_ttl.c" yy_destructor(yypParser,19,&yymsp[-1].minor); yymsp[-2].minor.yy50 = yylhsminor.yy50; break; case 14: /* literal ::= INTEGER */ #line 164 "grammar_ttl.y" { yylhsminor.yy50 = VOLK_literal_new (yymsp[0].minor.yy0, VOLK_iriref_new_ns ("xsd:integer")); free (yymsp[0].minor.yy0); } #line 1234 "../../build/grammar_ttl.c" yymsp[0].minor.yy50 = yylhsminor.yy50; break; case 15: /* literal ::= DOUBLE */ #line 168 "grammar_ttl.y" { yylhsminor.yy50 = VOLK_literal_new (yymsp[0].minor.yy0, VOLK_iriref_new_ns ("xsd:double")); free (yymsp[0].minor.yy0); } #line 1243 "../../build/grammar_ttl.c" yymsp[0].minor.yy50 = yylhsminor.yy50; break; case 16: /* literal ::= DECIMAL */ #line 172 "grammar_ttl.y" { yylhsminor.yy50 = VOLK_literal_new (yymsp[0].minor.yy0, VOLK_iriref_new_ns ("xsd:decimal")); free (yymsp[0].minor.yy0); } #line 1252 "../../build/grammar_ttl.c" yymsp[0].minor.yy50 = yylhsminor.yy50; break; case 17: /* literal ::= BOOLEAN */ #line 176 "grammar_ttl.y" { yylhsminor.yy50 = VOLK_literal_new (yymsp[0].minor.yy0, VOLK_iriref_new_ns ("xsd:boolean")); free (yymsp[0].minor.yy0); } #line 1261 "../../build/grammar_ttl.c" yymsp[0].minor.yy50 = yylhsminor.yy50; break; case 18: /* blank ::= BNODE_ID */ #line 183 "grammar_ttl.y" { yylhsminor.yy50 = VOLK_bnode_new (yymsp[0].minor.yy0); LOG_TRACE("Created blank node: _:%s", yylhsminor.yy50->data); free (yymsp[0].minor.yy0); } #line 1271 "../../build/grammar_ttl.c" yymsp[0].minor.yy50 = yylhsminor.yy50; break; case 19: /* blank ::= ANON */ { yy_destructor(yypParser,20,&yymsp[0].minor); #line 188 "grammar_ttl.y" { LOG_TRACE ("Found empty BNode."); yymsp[0].minor.yy50 = VOLK_bnode_new (NULL); LOG_TRACE("Created empty list BN: _:%s", yymsp[0].minor.yy50->data); } #line 1282 "../../build/grammar_ttl.c" } break; case 20: /* blank ::= LBRACKET predObjList RBRACKET */ { yy_destructor(yypParser,21,&yymsp[-2].minor); #line 193 "grammar_ttl.y" { LOG_TRACE ("Found BNode with data."); yymsp[-2].minor.yy50 = VOLK_bnode_new (NULL); state->lms = yymsp[-2].minor.yy50; state->ct += VOLK_graph_add_link_map (state->it, yymsp[-1].minor.yy34); LOG_TRACE("Created list BN: _:%s", yymsp[-2].minor.yy50->data); VOLK_link_map_free (yymsp[-1].minor.yy34); } #line 1297 "../../build/grammar_ttl.c" yy_destructor(yypParser,22,&yymsp[0].minor); } break; case 21: /* blank ::= LPAREN RPAREN */ { yy_destructor(yypParser,23,&yymsp[-1].minor); #line 203 "grammar_ttl.y" { yymsp[-1].minor.yy50 = VOLK_iriref_new_ns ("rdf:nil"); LOG_TRACE("Created list terminator: %s", yymsp[-1].minor.yy50->data); } #line 1308 "../../build/grammar_ttl.c" yy_destructor(yypParser,24,&yymsp[0].minor); } break; case 22: /* collection ::= LPAREN itemList RPAREN */ { yy_destructor(yypParser,23,&yymsp[-2].minor); #line 212 "grammar_ttl.y" { yymsp[-2].minor.yy50 = VOLK_bnode_add_collection (state->it, yymsp[-1].minor.yy22); VOLK_term_set_free (yymsp[-1].minor.yy22); } #line 1319 "../../build/grammar_ttl.c" yy_destructor(yypParser,24,&yymsp[0].minor); } break; case 23: /* itemList ::= itemList ows object */ #line 219 "grammar_ttl.y" { if (VOLK_term_set_add (yymsp[-2].minor.yy22, yymsp[0].minor.yy50, NULL) == VOLK_NOACTION) VOLK_term_free (yymsp[0].minor.yy50); yylhsminor.yy22 = yymsp[-2].minor.yy22; } #line 1330 "../../build/grammar_ttl.c" yymsp[-2].minor.yy22 = yylhsminor.yy22; break; case 24: /* itemList ::= object */ #line 224 "grammar_ttl.y" { yylhsminor.yy22 = VOLK_term_set_new (); VOLK_term_set_add (yylhsminor.yy22, yymsp[0].minor.yy50, NULL); } #line 1339 "../../build/grammar_ttl.c" yymsp[0].minor.yy22 = yylhsminor.yy22; break; case 25: /* resource ::= IRIREF */ #line 231 "grammar_ttl.y" { VOLK_Term *rel_iri = VOLK_iriref_new (yymsp[0].minor.yy0); free (yymsp[0].minor.yy0); if (state->base) { yylhsminor.yy50 = VOLK_iriref_new_abs (rel_iri, state->base); VOLK_term_free (rel_iri); } else { yylhsminor.yy50 = rel_iri; } LOG_TRACE("Created IRI: <%s>", yylhsminor.yy50->data); } #line 1355 "../../build/grammar_ttl.c" yymsp[0].minor.yy50 = yylhsminor.yy50; break; case 26: /* resource ::= QNAME */ #line 242 "grammar_ttl.y" { yylhsminor.yy50 = VOLK_iriref_new_ns (yymsp[0].minor.yy0); LOG_TRACE("Created IRI: %s", yylhsminor.yy50->data); free (yymsp[0].minor.yy0); } #line 1365 "../../build/grammar_ttl.c" yymsp[0].minor.yy50 = yylhsminor.yy50; break; case 27: /* turtleDoc ::= statements EOF */ #line 54 "grammar_ttl.y" { } #line 1372 "../../build/grammar_ttl.c" yy_destructor(yypParser,15,&yymsp[0].minor); break; case 33: /* statement ::= WS */ case 39: /* ows ::= WS */ yytestcase(yyruleno==39); { yy_destructor(yypParser,16,&yymsp[0].minor); #line 61 "grammar_ttl.y" { } #line 1381 "../../build/grammar_ttl.c" } break; case 34: /* predicate ::= resource */ case 35: /* object ::= resource */ yytestcase(yyruleno==35); { yy_destructor(yypParser,37,&yymsp[0].minor); #line 135 "grammar_ttl.y" { } #line 1390 "../../build/grammar_ttl.c" } break; case 36: /* object ::= blank */ { yy_destructor(yypParser,38,&yymsp[0].minor); #line 141 "grammar_ttl.y" { } #line 1398 "../../build/grammar_ttl.c" } break; case 37: /* object ::= literal */ { yy_destructor(yypParser,39,&yymsp[0].minor); #line 142 "grammar_ttl.y" { } #line 1406 "../../build/grammar_ttl.c" } break; case 38: /* blank ::= collection */ { yy_destructor(yypParser,40,&yymsp[0].minor); #line 202 "grammar_ttl.y" { } #line 1414 "../../build/grammar_ttl.c" } break; default: /* (28) statements ::= statements statement */ yytestcase(yyruleno==28); /* (29) statements ::= */ yytestcase(yyruleno==29); /* (30) statement ::= prefixID (OPTIMIZED OUT) */ assert(yyruleno!=30); /* (31) statement ::= base (OPTIMIZED OUT) */ assert(yyruleno!=31); /* (32) statement ::= triples (OPTIMIZED OUT) */ assert(yyruleno!=32); /* (40) ows ::= */ yytestcase(yyruleno==40); break; /********** End reduce actions ************************************************/ }; assert( yyrulenoYY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) ); /* It is not possible for a REDUCE to be followed by an error */ assert( yyact!=YY_ERROR_ACTION ); yymsp += yysize+1; yypParser->yytos = yymsp; yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact, "... then shift"); return yyact; } /* ** The following code executes when the parse fails */ #ifndef YYNOERRORRECOVERY static void yy_parse_failed( yyParser *yypParser /* The parser */ ){ TTLParseARG_FETCH TTLParseCTX_FETCH #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); } #endif while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will be executed whenever the ** parser fails */ /************ Begin %parse_failure code ***************************************/ #line 22 "grammar_ttl.y" log_error ("TTL parse error. Cannot continue."); state->rc = VOLK_PARSE_ERR; #line 1469 "../../build/grammar_ttl.c" /************ End %parse_failure code *****************************************/ TTLParseARG_STORE /* Suppress warning about unused %extra_argument variable */ TTLParseCTX_STORE } #endif /* YYNOERRORRECOVERY */ /* ** The following code executes when a syntax error first occurs. */ static void yy_syntax_error( yyParser *yypParser, /* The parser */ int yymajor, /* The major type of the error token */ TTLParseTOKENTYPE yyminor /* The minor type of the error token */ ){ TTLParseARG_FETCH TTLParseCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ #line 27 "grammar_ttl.y" // Fail immediately on first error. yy_parse_failed (yypParser); #line 1492 "../../build/grammar_ttl.c" /************ End %syntax_error code ******************************************/ TTLParseARG_STORE /* Suppress warning about unused %extra_argument variable */ TTLParseCTX_STORE } /* ** The following is executed when the parser accepts */ static void yy_accept( yyParser *yypParser /* The parser */ ){ TTLParseARG_FETCH TTLParseCTX_FETCH #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); } #endif #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif assert( yypParser->yytos==yypParser->yystack ); /* Here code is inserted which will be executed whenever the ** parser accepts */ /*********** Begin %parse_accept code *****************************************/ /*********** End %parse_accept code *******************************************/ TTLParseARG_STORE /* Suppress warning about unused %extra_argument variable */ TTLParseCTX_STORE } /* The main parser program. ** The first argument is a pointer to a structure obtained from ** "TTLParseAlloc" which describes the current state of the parser. ** The second argument is the major token number. The third is ** the minor token. The fourth optional argument is whatever the ** user wants (and specified in the grammar) and is available for ** use by the action routines. ** ** Inputs: **
    **
  • A pointer to the parser (an opaque structure.) **
  • The major token number. **
  • The minor token number. **
  • An option argument of a grammar-specified type. **
** ** Outputs: ** None. */ void TTLParse( void *yyp, /* The parser */ int yymajor, /* The major token code number */ TTLParseTOKENTYPE yyminor /* The value for the token */ TTLParseARG_PDECL /* Optional %extra_argument parameter */ ){ YYMINORTYPE yyminorunion; YYACTIONTYPE yyact; /* The parser action. */ #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) int yyendofinput; /* True if we are at the end of input */ #endif #ifdef YYERRORSYMBOL int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif yyParser *yypParser = (yyParser*)yyp; /* The parser */ TTLParseCTX_FETCH TTLParseARG_STORE assert( yypParser->yytos!=0 ); #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) yyendofinput = (yymajor==0); #endif yyact = yypParser->yytos->stateno; #ifndef NDEBUG if( yyTraceFILE ){ if( yyact < YY_MIN_REDUCE ){ fprintf(yyTraceFILE,"%sInput '%s' in state %d\n", yyTracePrompt,yyTokenName[yymajor],yyact); }else{ fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n", yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE); } } #endif while(1){ /* Exit by "break" */ assert( yypParser->yytos>=yypParser->yystack ); assert( yyact==yypParser->yytos->stateno ); yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); if( yyact >= YY_MIN_REDUCE ){ unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ #ifndef NDEBUG assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); if( yyTraceFILE ){ int yysize = yyRuleInfoNRhs[yyruleno]; if( yysize ){ fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", yyTracePrompt, yyruleno, yyRuleName[yyruleno], yyrulenoyytos[yysize].stateno); }else{ fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n", yyTracePrompt, yyruleno, yyRuleName[yyruleno], yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); } #endif #if YYSTACKDEPTH>0 if( yypParser->yytos>=yypParser->yystackEnd ){ yyStackOverflow(yypParser); break; } #else if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ if( yyGrowStack(yypParser) ){ yyStackOverflow(yypParser); break; } } #endif } yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor TTLParseCTX_PARAM); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt--; #endif break; }else if( yyact==YY_ACCEPT_ACTION ){ yypParser->yytos--; yy_accept(yypParser); return; }else{ assert( yyact == YY_ERROR_ACTION ); yyminorunion.yy0 = yyminor; #ifdef YYERRORSYMBOL int yymx; #endif #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); } #endif #ifdef YYERRORSYMBOL /* A syntax error has occurred. ** The response to an error depends upon whether or not the ** grammar defines an error token "ERROR". ** ** This is what we do if the grammar does define ERROR: ** ** * Call the %syntax_error function. ** ** * Begin popping the stack until we enter a state where ** it is legal to shift the error symbol, then shift ** the error symbol. ** ** * Set the error count to three. ** ** * Begin accepting and shifting new tokens. No new error ** processing will occur until three tokens have been ** shifted successfully. ** */ if( yypParser->yyerrcnt<0 ){ yy_syntax_error(yypParser,yymajor,yyminor); } yymx = yypParser->yytos->major; if( yymx==YYERRORSYMBOL || yyerrorhit ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sDiscard input token %s\n", yyTracePrompt,yyTokenName[yymajor]); } #endif yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); yymajor = YYNOCODE; }else{ while( yypParser->yytos > yypParser->yystack ){ yyact = yy_find_reduce_action(yypParser->yytos->stateno, YYERRORSYMBOL); if( yyact<=YY_MAX_SHIFTREDUCE ) break; yy_pop_parser_stack(yypParser); } if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){ yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_parse_failed(yypParser); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif yymajor = YYNOCODE; }else if( yymx!=YYERRORSYMBOL ){ yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor); } } yypParser->yyerrcnt = 3; yyerrorhit = 1; if( yymajor==YYNOCODE ) break; yyact = yypParser->yytos->stateno; #elif defined(YYNOERRORRECOVERY) /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to ** do any kind of error recovery. Instead, simply invoke the syntax ** error routine and continue going as if nothing had happened. ** ** Applications can set this macro (for example inside %include) if ** they intend to abandon the parse upon the first syntax error seen. */ yy_syntax_error(yypParser,yymajor, yyminor); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); break; #else /* YYERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** ** * Report an error message, and throw away the input token. ** ** * If the input token is $, then fail the parse. ** ** As before, subsequent error messages are suppressed until ** three input tokens have been successfully shifted. */ if( yypParser->yyerrcnt<=0 ){ yy_syntax_error(yypParser,yymajor, yyminor); } yypParser->yyerrcnt = 3; yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); if( yyendofinput ){ yy_parse_failed(yypParser); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif } break; #endif } } #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; char cDiv = '['; fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt); for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){ fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]); cDiv = ' '; } fprintf(yyTraceFILE,"]\n"); } #endif return; } /* ** Return the fallback token corresponding to canonical token iToken, or ** 0 if iToken has no fallback. */ int TTLParseFallback(int iToken){ #ifdef YYFALLBACK assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); return yyFallback[iToken]; #else (void)iToken; return 0; #endif }