#line 2 "../../templates/CYacc/Langname_Parser.y" /* $Id: Langname_Parser.y,v 1.1 2008/04/06 17:10:48 eric Exp SPARQLParser.yy 19 2007-08-19 20:36:24Z tb $ -*- mode: c++ -*- */ /** \file SPARQLParser.yy Contains the Bison parser source */ /*** yacc/bison Declarations ***/ /* Require bison 2.3 or later */ %require "2.3" /* add debug output code to generated parser. disable this for release * versions. */ %debug /* start symbol is named "start" */ %start Query /* write out a header file containing the token defines */ %defines /* set the parser's class identifier */ %define "parser_class_name" "SPARQLParser" %{ /*** C/C++ Declarations ***/ #include #include #include #include #include "SPARQLEnums.h" #include "SPARQLParser.h" void yyerror(char *m); int SPARQL_lex(void); void SPARQL_error(char *); typedef struct _Buf { char* data; int len; } Buf; Buf* makeBuf0 (); Buf* makeBuf1 (char *str); Buf* makeBuf (int count, ...); void destroyBuf (Buf*); char *str(Buf*); Semval* StupidGlobal; %} %union { Semval* semval; }; /* START TokenBlock */ /* Terminals */ %token IT_BASE %token IT_PREFIX %token IT_SELECT %token IT_DISTINCT %token IT_REDUCED %token GT_TIMES %token IT_CONSTRUCT %token IT_DESCRIBE %token IT_ASK %token IT_FROM %token IT_NAMED %token IT_WHERE %token IT_ORDER %token IT_BY %token IT_ASC %token IT_DESC %token IT_LIMIT %token IT_OFFSET %token GT_LCURLEY %token GT_RCURLEY %token GT_DOT %token IT_OPTIONAL %token IT_GRAPH %token IT_UNION %token IT_FILTER %token GT_COMMA %token GT_LPAREN %token GT_RPAREN %token GT_SEMI %token IT_a %token GT_LBRACKET %token GT_RBRACKET %token GT_OR %token GT_AND %token GT_EQUAL %token GT_NEQUAL %token GT_LT %token GT_GT %token GT_LE %token GT_GE %token GT_PLUS %token GT_MINUS %token GT_DIVIDE %token GT_NOT %token IT_STR %token IT_LANG %token IT_LANGMATCHES %token IT_DATATYPE %token IT_BOUND %token IT_sameTerm %token IT_isIRI %token IT_isURI %token IT_isBLANK %token IT_isLITERAL %token IT_REGEX %token GT_DTYPE %token IT_true %token IT_false %token IRI_REF %token PNAME_NS %token PNAME_LN %token BLANK_NODE_LABEL %token VAR1 %token VAR2 %token LANGTAG %token INTEGER %token DECIMAL %token DOUBLE %token INTEGER_POSITIVE %token DECIMAL_POSITIVE %token DOUBLE_POSITIVE %token INTEGER_NEGATIVE %token DECIMAL_NEGATIVE %token DOUBLE_NEGATIVE %token STRING_LITERAL1 %token STRING_LITERAL2 %token STRING_LITERAL_LONG1 %token STRING_LITERAL_LONG2 %token NIL %token ANON /* Productions */ %type Query %type _O_QSelectQuery_E_Or_QConstructQuery_E_Or_QDescribeQuery_E_Or_QAskQuery_E_C %type Prologue %type _QBaseDecl_E_Opt %type _QPrefixDecl_E_Star %type BaseDecl %type PrefixDecl %type SelectQuery %type _O_QIT_DISTINCT_E_Or_QIT_REDUCED_E_C %type _Q_O_QIT_DISTINCT_E_Or_QIT_REDUCED_E_C_E_Opt %type _QVar_E_Plus %type _O_QVar_E_Plus_Or_QGT_TIMES_E_C %type _QDatasetClause_E_Star %type ConstructQuery %type DescribeQuery %type _QVarOrIRIref_E_Plus %type _O_QVarOrIRIref_E_Plus_Or_QGT_TIMES_E_C %type _QWhereClause_E_Opt %type AskQuery %type DatasetClause %type _O_QDefaultGraphClause_E_Or_QNamedGraphClause_E_C %type DefaultGraphClause %type NamedGraphClause %type SourceSelector %type WhereClause %type _QIT_WHERE_E_Opt %type SolutionModifier %type _QOrderClause_E_Opt %type _QLimitOffsetClauses_E_Opt %type LimitOffsetClauses %type _QOffsetClause_E_Opt %type _QLimitClause_E_Opt %type _O_QLimitClause_E_S_QOffsetClause_E_Opt_Or_QOffsetClause_E_S_QLimitClause_E_Opt_C %type OrderClause %type _QOrderCondition_E_Plus %type OrderCondition %type _O_QIT_ASC_E_Or_QIT_DESC_E_C %type _O_QIT_ASC_E_Or_QIT_DESC_E_S_QBrackettedExpression_E_C %type _O_QConstraint_E_Or_QVar_E_C %type LimitClause %type OffsetClause %type GroupGraphPattern %type _QTriplesBlock_E_Opt %type _O_QGraphPatternNotTriples_E_Or_QFilter_E_C %type _QGT_DOT_E_Opt %type _O_QGraphPatternNotTriples_E_Or_QFilter_E_S_QGT_DOT_E_Opt_S_QTriplesBlock_E_Opt_C %type _Q_O_QGraphPatternNotTriples_E_Or_QFilter_E_S_QGT_DOT_E_Opt_S_QTriplesBlock_E_Opt_C_E_Star %type TriplesBlock %type _O_QGT_DOT_E_S_QTriplesBlock_E_Opt_C %type _Q_O_QGT_DOT_E_S_QTriplesBlock_E_Opt_C_E_Opt %type GraphPatternNotTriples %type OptionalGraphPattern %type GraphGraphPattern %type GroupOrUnionGraphPattern %type _O_QIT_UNION_E_S_QGroupGraphPattern_E_C %type _Q_O_QIT_UNION_E_S_QGroupGraphPattern_E_C_E_Star %type Filter %type Constraint %type FunctionCall %type ArgList %type _O_QGT_COMMA_E_S_QExpression_E_C %type _Q_O_QGT_COMMA_E_S_QExpression_E_C_E_Star %type _O_QNIL_E_Or_QGT_LPAREN_E_S_QExpression_E_S_QGT_COMMA_E_S_QExpression_E_Star_S_QGT_RPAREN_E_C %type ConstructTemplate %type _QConstructTriples_E_Opt %type ConstructTriples %type _O_QGT_DOT_E_S_QConstructTriples_E_Opt_C %type _Q_O_QGT_DOT_E_S_QConstructTriples_E_Opt_C_E_Opt %type TriplesSameSubject %type PropertyListNotEmpty %type _O_QVerb_E_S_QObjectList_E_C %type _Q_O_QVerb_E_S_QObjectList_E_C_E_Opt %type _O_QGT_SEMI_E_S_QVerb_E_S_QObjectList_E_Opt_C %type _Q_O_QGT_SEMI_E_S_QVerb_E_S_QObjectList_E_Opt_C_E_Star %type PropertyList %type _QPropertyListNotEmpty_E_Opt %type ObjectList %type _O_QGT_COMMA_E_S_QObject_E_C %type _Q_O_QGT_COMMA_E_S_QObject_E_C_E_Star %type Object %type Verb %type TriplesNode %type BlankNodePropertyList %type Collection %type _QGraphNode_E_Plus %type GraphNode %type VarOrTerm %type VarOrIRIref %type Var %type GraphTerm %type Expression %type ConditionalOrExpression %type _O_QGT_OR_E_S_QConditionalAndExpression_E_C %type _Q_O_QGT_OR_E_S_QConditionalAndExpression_E_C_E_Star %type ConditionalAndExpression %type _O_QGT_AND_E_S_QValueLogical_E_C %type _Q_O_QGT_AND_E_S_QValueLogical_E_C_E_Star %type ValueLogical %type RelationalExpression %type _O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C %type _Q_O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C_E_Opt %type NumericExpression %type AdditiveExpression %type _O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C %type _Q_O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C_E_Star %type MultiplicativeExpression %type _O_QGT_TIMES_E_S_QUnaryExpression_E_Or_QGT_DIVIDE_E_S_QUnaryExpression_E_C %type _Q_O_QGT_TIMES_E_S_QUnaryExpression_E_Or_QGT_DIVIDE_E_S_QUnaryExpression_E_C_E_Star %type UnaryExpression %type PrimaryExpression %type BrackettedExpression %type BuiltInCall %type RegexExpression %type _Q_O_QGT_COMMA_E_S_QExpression_E_C_E_Opt %type IRIrefOrFunction %type _QArgList_E_Opt %type RDFLiteral %type _O_QGT_DTYPE_E_S_QIRIref_E_C %type _O_QLANGTAG_E_Or_QGT_DTYPE_E_S_QIRIref_E_C %type _Q_O_QLANGTAG_E_Or_QGT_DTYPE_E_S_QIRIref_E_C_E_Opt %type NumericLiteral %type NumericLiteralUnsigned %type NumericLiteralPositive %type NumericLiteralNegative %type BooleanLiteral %type String %type IRIref %type PrefixedName %type BlankNode /* END TokenBlock */ %{ //#include "SPARQLDriver.hh" //#include "SPARQLScanner.hh" //#undef yylex #define yylex SPARQLlex %} %% /*** Grammar Rules ***/ /*** BEGIN SPARQL - Change the grammar rules below ***/ Query: Prologue _O_QSelectQuery_E_Or_QConstructQuery_E_Or_QDescribeQuery_E_Or_QAskQuery_E_C { StupidGlobal = constructProduction(e_Query, 2, $1, $2); } ; _O_QSelectQuery_E_Or_QConstructQuery_E_Or_QDescribeQuery_E_Or_QAskQuery_E_C: SelectQuery { $$ = constructProduction(e__O_QSelectQuery_E_Or_QConstructQuery_E_Or_QDescribeQuery_E_Or_QAskQuery_E_C, 1, $1); } | ConstructQuery { $$ = constructProduction(e__O_QSelectQuery_E_Or_QConstructQuery_E_Or_QDescribeQuery_E_Or_QAskQuery_E_C, 1, $1); } | DescribeQuery { $$ = constructProduction(e__O_QSelectQuery_E_Or_QConstructQuery_E_Or_QDescribeQuery_E_Or_QAskQuery_E_C, 1, $1); } | AskQuery { $$ = constructProduction(e__O_QSelectQuery_E_Or_QConstructQuery_E_Or_QDescribeQuery_E_Or_QAskQuery_E_C, 1, $1); } ; Prologue: _QBaseDecl_E_Opt _QPrefixDecl_E_Star { $$ = constructProduction(e_Prologue, 2, $1, $2); } ; _QBaseDecl_E_Opt: { $$ = constructProduction(e__QBaseDecl_E_Opt, 0); } | BaseDecl { $$ = constructProduction(e__QBaseDecl_E_Opt, 1, $1); } ; _QPrefixDecl_E_Star: { $$ = constructProduction(e__QPrefixDecl_E_Star, 0); } | _QPrefixDecl_E_Star PrefixDecl { $$ = constructProduction(e__QPrefixDecl_E_Star, 2, $1, $2); } ; BaseDecl: IT_BASE IRI_REF { $$ = constructProduction(e_BaseDecl, 2, $1, $2); } ; PrefixDecl: IT_PREFIX PNAME_NS IRI_REF { $$ = constructProduction(e_PrefixDecl, 3, $1, $2, $3); } ; SelectQuery: IT_SELECT _Q_O_QIT_DISTINCT_E_Or_QIT_REDUCED_E_C_E_Opt _O_QVar_E_Plus_Or_QGT_TIMES_E_C _QDatasetClause_E_Star WhereClause SolutionModifier { $$ = constructProduction(e_SelectQuery, 6, $1, $2, $3, $4, $5, $6); } ; _O_QIT_DISTINCT_E_Or_QIT_REDUCED_E_C: IT_DISTINCT { $$ = constructProduction(e__O_QIT_DISTINCT_E_Or_QIT_REDUCED_E_C, 1, $1); } | IT_REDUCED { $$ = constructProduction(e__O_QIT_DISTINCT_E_Or_QIT_REDUCED_E_C, 1, $1); } ; _Q_O_QIT_DISTINCT_E_Or_QIT_REDUCED_E_C_E_Opt: { $$ = constructProduction(e__Q_O_QIT_DISTINCT_E_Or_QIT_REDUCED_E_C_E_Opt, 0); } | _O_QIT_DISTINCT_E_Or_QIT_REDUCED_E_C { $$ = constructProduction(e__Q_O_QIT_DISTINCT_E_Or_QIT_REDUCED_E_C_E_Opt, 1, $1); } ; _QVar_E_Plus: Var { $$ = constructProduction(e__QVar_E_Plus, 1, $1); } | _QVar_E_Plus Var { $$ = constructProduction(e__QVar_E_Plus, 2, $1, $2); } ; _O_QVar_E_Plus_Or_QGT_TIMES_E_C: _QVar_E_Plus { $$ = constructProduction(e__O_QVar_E_Plus_Or_QGT_TIMES_E_C, 1, $1); } | GT_TIMES { $$ = constructProduction(e__O_QVar_E_Plus_Or_QGT_TIMES_E_C, 1, $1); } ; _QDatasetClause_E_Star: { $$ = constructProduction(e__QDatasetClause_E_Star, 0); } | _QDatasetClause_E_Star DatasetClause { $$ = constructProduction(e__QDatasetClause_E_Star, 2, $1, $2); } ; ConstructQuery: IT_CONSTRUCT ConstructTemplate _QDatasetClause_E_Star WhereClause SolutionModifier { $$ = constructProduction(e_ConstructQuery, 5, $1, $2, $3, $4, $5); } ; DescribeQuery: IT_DESCRIBE _O_QVarOrIRIref_E_Plus_Or_QGT_TIMES_E_C _QDatasetClause_E_Star _QWhereClause_E_Opt SolutionModifier { $$ = constructProduction(e_DescribeQuery, 5, $1, $2, $3, $4, $5); } ; _QVarOrIRIref_E_Plus: VarOrIRIref { $$ = constructProduction(e__QVarOrIRIref_E_Plus, 1, $1); } | _QVarOrIRIref_E_Plus VarOrIRIref { $$ = constructProduction(e__QVarOrIRIref_E_Plus, 2, $1, $2); } ; _O_QVarOrIRIref_E_Plus_Or_QGT_TIMES_E_C: _QVarOrIRIref_E_Plus { $$ = constructProduction(e__O_QVarOrIRIref_E_Plus_Or_QGT_TIMES_E_C, 1, $1); } | GT_TIMES { $$ = constructProduction(e__O_QVarOrIRIref_E_Plus_Or_QGT_TIMES_E_C, 1, $1); } ; _QWhereClause_E_Opt: { $$ = constructProduction(e__QWhereClause_E_Opt, 0); } | WhereClause { $$ = constructProduction(e__QWhereClause_E_Opt, 1, $1); } ; AskQuery: IT_ASK _QDatasetClause_E_Star WhereClause { $$ = constructProduction(e_AskQuery, 3, $1, $2, $3); } ; DatasetClause: IT_FROM _O_QDefaultGraphClause_E_Or_QNamedGraphClause_E_C { $$ = constructProduction(e_DatasetClause, 2, $1, $2); } ; _O_QDefaultGraphClause_E_Or_QNamedGraphClause_E_C: DefaultGraphClause { $$ = constructProduction(e__O_QDefaultGraphClause_E_Or_QNamedGraphClause_E_C, 1, $1); } | NamedGraphClause { $$ = constructProduction(e__O_QDefaultGraphClause_E_Or_QNamedGraphClause_E_C, 1, $1); } ; DefaultGraphClause: SourceSelector { $$ = constructProduction(e_DefaultGraphClause, 1, $1); } ; NamedGraphClause: IT_NAMED SourceSelector { $$ = constructProduction(e_NamedGraphClause, 2, $1, $2); } ; SourceSelector: IRIref { $$ = constructProduction(e_SourceSelector, 1, $1); } ; WhereClause: _QIT_WHERE_E_Opt GroupGraphPattern { $$ = constructProduction(e_WhereClause, 2, $1, $2); } ; _QIT_WHERE_E_Opt: { $$ = constructProduction(e__QIT_WHERE_E_Opt, 0); } | IT_WHERE { $$ = constructProduction(e__QIT_WHERE_E_Opt, 1, $1); } ; SolutionModifier: _QOrderClause_E_Opt _QLimitOffsetClauses_E_Opt { $$ = constructProduction(e_SolutionModifier, 2, $1, $2); } ; _QOrderClause_E_Opt: { $$ = constructProduction(e__QOrderClause_E_Opt, 0); } | OrderClause { $$ = constructProduction(e__QOrderClause_E_Opt, 1, $1); } ; _QLimitOffsetClauses_E_Opt: { $$ = constructProduction(e__QLimitOffsetClauses_E_Opt, 0); } | LimitOffsetClauses { $$ = constructProduction(e__QLimitOffsetClauses_E_Opt, 1, $1); } ; LimitOffsetClauses: _O_QLimitClause_E_S_QOffsetClause_E_Opt_Or_QOffsetClause_E_S_QLimitClause_E_Opt_C { $$ = constructProduction(e_LimitOffsetClauses, 1, $1); } ; _QOffsetClause_E_Opt: { $$ = constructProduction(e__QOffsetClause_E_Opt, 0); } | OffsetClause { $$ = constructProduction(e__QOffsetClause_E_Opt, 1, $1); } ; _QLimitClause_E_Opt: { $$ = constructProduction(e__QLimitClause_E_Opt, 0); } | LimitClause { $$ = constructProduction(e__QLimitClause_E_Opt, 1, $1); } ; _O_QLimitClause_E_S_QOffsetClause_E_Opt_Or_QOffsetClause_E_S_QLimitClause_E_Opt_C: LimitClause _QOffsetClause_E_Opt { $$ = constructProduction(e__O_QLimitClause_E_S_QOffsetClause_E_Opt_Or_QOffsetClause_E_S_QLimitClause_E_Opt_C, 2, $1, $2); } | OffsetClause _QLimitClause_E_Opt { $$ = constructProduction(e__O_QLimitClause_E_S_QOffsetClause_E_Opt_Or_QOffsetClause_E_S_QLimitClause_E_Opt_C, 2, $1, $2); } ; OrderClause: IT_ORDER IT_BY _QOrderCondition_E_Plus { $$ = constructProduction(e_OrderClause, 3, $1, $2, $3); } ; _QOrderCondition_E_Plus: OrderCondition { $$ = constructProduction(e__QOrderCondition_E_Plus, 1, $1); } | _QOrderCondition_E_Plus OrderCondition { $$ = constructProduction(e__QOrderCondition_E_Plus, 2, $1, $2); } ; OrderCondition: _O_QIT_ASC_E_Or_QIT_DESC_E_S_QBrackettedExpression_E_C { $$ = constructProduction(e_OrderCondition, 1, $1); } | _O_QConstraint_E_Or_QVar_E_C { $$ = constructProduction(e_OrderCondition, 1, $1); } ; _O_QIT_ASC_E_Or_QIT_DESC_E_C: IT_ASC { $$ = constructProduction(e__O_QIT_ASC_E_Or_QIT_DESC_E_C, 1, $1); } | IT_DESC { $$ = constructProduction(e__O_QIT_ASC_E_Or_QIT_DESC_E_C, 1, $1); } ; _O_QIT_ASC_E_Or_QIT_DESC_E_S_QBrackettedExpression_E_C: _O_QIT_ASC_E_Or_QIT_DESC_E_C BrackettedExpression { $$ = constructProduction(e__O_QIT_ASC_E_Or_QIT_DESC_E_S_QBrackettedExpression_E_C, 2, $1, $2); } ; _O_QConstraint_E_Or_QVar_E_C: Constraint { $$ = constructProduction(e__O_QConstraint_E_Or_QVar_E_C, 1, $1); } | Var { $$ = constructProduction(e__O_QConstraint_E_Or_QVar_E_C, 1, $1); } ; LimitClause: IT_LIMIT INTEGER { $$ = constructProduction(e_LimitClause, 2, $1, $2); } ; OffsetClause: IT_OFFSET INTEGER { $$ = constructProduction(e_OffsetClause, 2, $1, $2); } ; GroupGraphPattern: GT_LCURLEY _QTriplesBlock_E_Opt _Q_O_QGraphPatternNotTriples_E_Or_QFilter_E_S_QGT_DOT_E_Opt_S_QTriplesBlock_E_Opt_C_E_Star GT_RCURLEY { $$ = constructProduction(e_GroupGraphPattern, 4, $1, $2, $3, $4); } ; _QTriplesBlock_E_Opt: { $$ = constructProduction(e__QTriplesBlock_E_Opt, 0); } | TriplesBlock { $$ = constructProduction(e__QTriplesBlock_E_Opt, 1, $1); } ; _O_QGraphPatternNotTriples_E_Or_QFilter_E_C: GraphPatternNotTriples { $$ = constructProduction(e__O_QGraphPatternNotTriples_E_Or_QFilter_E_C, 1, $1); } | Filter { $$ = constructProduction(e__O_QGraphPatternNotTriples_E_Or_QFilter_E_C, 1, $1); } ; _QGT_DOT_E_Opt: { $$ = constructProduction(e__QGT_DOT_E_Opt, 0); } | GT_DOT { $$ = constructProduction(e__QGT_DOT_E_Opt, 1, $1); } ; _O_QGraphPatternNotTriples_E_Or_QFilter_E_S_QGT_DOT_E_Opt_S_QTriplesBlock_E_Opt_C: _O_QGraphPatternNotTriples_E_Or_QFilter_E_C _QGT_DOT_E_Opt _QTriplesBlock_E_Opt { $$ = constructProduction(e__O_QGraphPatternNotTriples_E_Or_QFilter_E_S_QGT_DOT_E_Opt_S_QTriplesBlock_E_Opt_C, 3, $1, $2, $3); } ; _Q_O_QGraphPatternNotTriples_E_Or_QFilter_E_S_QGT_DOT_E_Opt_S_QTriplesBlock_E_Opt_C_E_Star: { $$ = constructProduction(e__Q_O_QGraphPatternNotTriples_E_Or_QFilter_E_S_QGT_DOT_E_Opt_S_QTriplesBlock_E_Opt_C_E_Star, 0); } | _Q_O_QGraphPatternNotTriples_E_Or_QFilter_E_S_QGT_DOT_E_Opt_S_QTriplesBlock_E_Opt_C_E_Star _O_QGraphPatternNotTriples_E_Or_QFilter_E_S_QGT_DOT_E_Opt_S_QTriplesBlock_E_Opt_C { $$ = constructProduction(e__Q_O_QGraphPatternNotTriples_E_Or_QFilter_E_S_QGT_DOT_E_Opt_S_QTriplesBlock_E_Opt_C_E_Star, 2, $1, $2); } ; TriplesBlock: TriplesSameSubject _Q_O_QGT_DOT_E_S_QTriplesBlock_E_Opt_C_E_Opt { $$ = constructProduction(e_TriplesBlock, 2, $1, $2); } ; _O_QGT_DOT_E_S_QTriplesBlock_E_Opt_C: GT_DOT _QTriplesBlock_E_Opt { $$ = constructProduction(e__O_QGT_DOT_E_S_QTriplesBlock_E_Opt_C, 2, $1, $2); } ; _Q_O_QGT_DOT_E_S_QTriplesBlock_E_Opt_C_E_Opt: { $$ = constructProduction(e__Q_O_QGT_DOT_E_S_QTriplesBlock_E_Opt_C_E_Opt, 0); } | _O_QGT_DOT_E_S_QTriplesBlock_E_Opt_C { $$ = constructProduction(e__Q_O_QGT_DOT_E_S_QTriplesBlock_E_Opt_C_E_Opt, 1, $1); } ; GraphPatternNotTriples: OptionalGraphPattern { $$ = constructProduction(e_GraphPatternNotTriples, 1, $1); } | GroupOrUnionGraphPattern { $$ = constructProduction(e_GraphPatternNotTriples, 1, $1); } | GraphGraphPattern { $$ = constructProduction(e_GraphPatternNotTriples, 1, $1); } ; OptionalGraphPattern: IT_OPTIONAL GroupGraphPattern { $$ = constructProduction(e_OptionalGraphPattern, 2, $1, $2); } ; GraphGraphPattern: IT_GRAPH VarOrIRIref GroupGraphPattern { $$ = constructProduction(e_GraphGraphPattern, 3, $1, $2, $3); } ; GroupOrUnionGraphPattern: GroupGraphPattern _Q_O_QIT_UNION_E_S_QGroupGraphPattern_E_C_E_Star { $$ = constructProduction(e_GroupOrUnionGraphPattern, 2, $1, $2); } ; _O_QIT_UNION_E_S_QGroupGraphPattern_E_C: IT_UNION GroupGraphPattern { $$ = constructProduction(e__O_QIT_UNION_E_S_QGroupGraphPattern_E_C, 2, $1, $2); } ; _Q_O_QIT_UNION_E_S_QGroupGraphPattern_E_C_E_Star: { $$ = constructProduction(e__Q_O_QIT_UNION_E_S_QGroupGraphPattern_E_C_E_Star, 0); } | _Q_O_QIT_UNION_E_S_QGroupGraphPattern_E_C_E_Star _O_QIT_UNION_E_S_QGroupGraphPattern_E_C { $$ = constructProduction(e__Q_O_QIT_UNION_E_S_QGroupGraphPattern_E_C_E_Star, 2, $1, $2); } ; Filter: IT_FILTER Constraint { $$ = constructProduction(e_Filter, 2, $1, $2); } ; Constraint: BrackettedExpression { $$ = constructProduction(e_Constraint, 1, $1); } | BuiltInCall { $$ = constructProduction(e_Constraint, 1, $1); } | FunctionCall { $$ = constructProduction(e_Constraint, 1, $1); } ; FunctionCall: IRIref ArgList { $$ = constructProduction(e_FunctionCall, 2, $1, $2); } ; ArgList: _O_QNIL_E_Or_QGT_LPAREN_E_S_QExpression_E_S_QGT_COMMA_E_S_QExpression_E_Star_S_QGT_RPAREN_E_C { $$ = constructProduction(e_ArgList, 1, $1); } ; _O_QGT_COMMA_E_S_QExpression_E_C: GT_COMMA Expression { $$ = constructProduction(e__O_QGT_COMMA_E_S_QExpression_E_C, 2, $1, $2); } ; _Q_O_QGT_COMMA_E_S_QExpression_E_C_E_Star: { $$ = constructProduction(e__Q_O_QGT_COMMA_E_S_QExpression_E_C_E_Star, 0); } | _Q_O_QGT_COMMA_E_S_QExpression_E_C_E_Star _O_QGT_COMMA_E_S_QExpression_E_C { $$ = constructProduction(e__Q_O_QGT_COMMA_E_S_QExpression_E_C_E_Star, 2, $1, $2); } ; _O_QNIL_E_Or_QGT_LPAREN_E_S_QExpression_E_S_QGT_COMMA_E_S_QExpression_E_Star_S_QGT_RPAREN_E_C: NIL { $$ = constructProduction(e__O_QNIL_E_Or_QGT_LPAREN_E_S_QExpression_E_S_QGT_COMMA_E_S_QExpression_E_Star_S_QGT_RPAREN_E_C, 1, $1); } | GT_LPAREN Expression _Q_O_QGT_COMMA_E_S_QExpression_E_C_E_Star GT_RPAREN { $$ = constructProduction(e__O_QNIL_E_Or_QGT_LPAREN_E_S_QExpression_E_S_QGT_COMMA_E_S_QExpression_E_Star_S_QGT_RPAREN_E_C, 4, $1, $2, $3, $4); } ; ConstructTemplate: GT_LCURLEY _QConstructTriples_E_Opt GT_RCURLEY { $$ = constructProduction(e_ConstructTemplate, 3, $1, $2, $3); } ; _QConstructTriples_E_Opt: { $$ = constructProduction(e__QConstructTriples_E_Opt, 0); } | ConstructTriples { $$ = constructProduction(e__QConstructTriples_E_Opt, 1, $1); } ; ConstructTriples: TriplesSameSubject _Q_O_QGT_DOT_E_S_QConstructTriples_E_Opt_C_E_Opt { $$ = constructProduction(e_ConstructTriples, 2, $1, $2); } ; _O_QGT_DOT_E_S_QConstructTriples_E_Opt_C: GT_DOT _QConstructTriples_E_Opt { $$ = constructProduction(e__O_QGT_DOT_E_S_QConstructTriples_E_Opt_C, 2, $1, $2); } ; _Q_O_QGT_DOT_E_S_QConstructTriples_E_Opt_C_E_Opt: { $$ = constructProduction(e__Q_O_QGT_DOT_E_S_QConstructTriples_E_Opt_C_E_Opt, 0); } | _O_QGT_DOT_E_S_QConstructTriples_E_Opt_C { $$ = constructProduction(e__Q_O_QGT_DOT_E_S_QConstructTriples_E_Opt_C_E_Opt, 1, $1); } ; TriplesSameSubject: VarOrTerm PropertyListNotEmpty { $$ = constructProduction(e_TriplesSameSubject, 2, $1, $2); } | TriplesNode PropertyList { $$ = constructProduction(e_TriplesSameSubject, 2, $1, $2); } ; PropertyListNotEmpty: Verb ObjectList _Q_O_QGT_SEMI_E_S_QVerb_E_S_QObjectList_E_Opt_C_E_Star { $$ = constructProduction(e_PropertyListNotEmpty, 3, $1, $2, $3); } ; _O_QVerb_E_S_QObjectList_E_C: Verb ObjectList { $$ = constructProduction(e__O_QVerb_E_S_QObjectList_E_C, 2, $1, $2); } ; _Q_O_QVerb_E_S_QObjectList_E_C_E_Opt: { $$ = constructProduction(e__Q_O_QVerb_E_S_QObjectList_E_C_E_Opt, 0); } | _O_QVerb_E_S_QObjectList_E_C { $$ = constructProduction(e__Q_O_QVerb_E_S_QObjectList_E_C_E_Opt, 1, $1); } ; _O_QGT_SEMI_E_S_QVerb_E_S_QObjectList_E_Opt_C: GT_SEMI _Q_O_QVerb_E_S_QObjectList_E_C_E_Opt { $$ = constructProduction(e__O_QGT_SEMI_E_S_QVerb_E_S_QObjectList_E_Opt_C, 2, $1, $2); } ; _Q_O_QGT_SEMI_E_S_QVerb_E_S_QObjectList_E_Opt_C_E_Star: { $$ = constructProduction(e__Q_O_QGT_SEMI_E_S_QVerb_E_S_QObjectList_E_Opt_C_E_Star, 0); } | _Q_O_QGT_SEMI_E_S_QVerb_E_S_QObjectList_E_Opt_C_E_Star _O_QGT_SEMI_E_S_QVerb_E_S_QObjectList_E_Opt_C { $$ = constructProduction(e__Q_O_QGT_SEMI_E_S_QVerb_E_S_QObjectList_E_Opt_C_E_Star, 2, $1, $2); } ; PropertyList: _QPropertyListNotEmpty_E_Opt { $$ = constructProduction(e_PropertyList, 1, $1); } ; _QPropertyListNotEmpty_E_Opt: { $$ = constructProduction(e__QPropertyListNotEmpty_E_Opt, 0); } | PropertyListNotEmpty { $$ = constructProduction(e__QPropertyListNotEmpty_E_Opt, 1, $1); } ; ObjectList: Object _Q_O_QGT_COMMA_E_S_QObject_E_C_E_Star { $$ = constructProduction(e_ObjectList, 2, $1, $2); } ; _O_QGT_COMMA_E_S_QObject_E_C: GT_COMMA Object { $$ = constructProduction(e__O_QGT_COMMA_E_S_QObject_E_C, 2, $1, $2); } ; _Q_O_QGT_COMMA_E_S_QObject_E_C_E_Star: { $$ = constructProduction(e__Q_O_QGT_COMMA_E_S_QObject_E_C_E_Star, 0); } | _Q_O_QGT_COMMA_E_S_QObject_E_C_E_Star _O_QGT_COMMA_E_S_QObject_E_C { $$ = constructProduction(e__Q_O_QGT_COMMA_E_S_QObject_E_C_E_Star, 2, $1, $2); } ; Object: GraphNode { $$ = constructProduction(e_Object, 1, $1); } ; Verb: VarOrIRIref { $$ = constructProduction(e_Verb, 1, $1); } | IT_a { $$ = constructProduction(e_Verb, 1, $1); } ; TriplesNode: Collection { $$ = constructProduction(e_TriplesNode, 1, $1); } | BlankNodePropertyList { $$ = constructProduction(e_TriplesNode, 1, $1); } ; BlankNodePropertyList: GT_LBRACKET PropertyListNotEmpty GT_RBRACKET { $$ = constructProduction(e_BlankNodePropertyList, 3, $1, $2, $3); } ; Collection: GT_LPAREN _QGraphNode_E_Plus GT_RPAREN { $$ = constructProduction(e_Collection, 3, $1, $2, $3); } ; _QGraphNode_E_Plus: GraphNode { $$ = constructProduction(e__QGraphNode_E_Plus, 1, $1); } | _QGraphNode_E_Plus GraphNode { $$ = constructProduction(e__QGraphNode_E_Plus, 2, $1, $2); } ; GraphNode: VarOrTerm { $$ = constructProduction(e_GraphNode, 1, $1); } | TriplesNode { $$ = constructProduction(e_GraphNode, 1, $1); } ; VarOrTerm: Var { $$ = constructProduction(e_VarOrTerm, 1, $1); } | GraphTerm { $$ = constructProduction(e_VarOrTerm, 1, $1); } ; VarOrIRIref: Var { $$ = constructProduction(e_VarOrIRIref, 1, $1); } | IRIref { $$ = constructProduction(e_VarOrIRIref, 1, $1); } ; Var: VAR1 { $$ = constructProduction(e_Var, 1, $1); } | VAR2 { $$ = constructProduction(e_Var, 1, $1); } ; GraphTerm: IRIref { $$ = constructProduction(e_GraphTerm, 1, $1); } | RDFLiteral { $$ = constructProduction(e_GraphTerm, 1, $1); } | NumericLiteral { $$ = constructProduction(e_GraphTerm, 1, $1); } | BooleanLiteral { $$ = constructProduction(e_GraphTerm, 1, $1); } | BlankNode { $$ = constructProduction(e_GraphTerm, 1, $1); } | NIL { $$ = constructProduction(e_GraphTerm, 1, $1); } ; Expression: ConditionalOrExpression { $$ = constructProduction(e_Expression, 1, $1); } ; ConditionalOrExpression: ConditionalAndExpression _Q_O_QGT_OR_E_S_QConditionalAndExpression_E_C_E_Star { $$ = constructProduction(e_ConditionalOrExpression, 2, $1, $2); } ; _O_QGT_OR_E_S_QConditionalAndExpression_E_C: GT_OR ConditionalAndExpression { $$ = constructProduction(e__O_QGT_OR_E_S_QConditionalAndExpression_E_C, 2, $1, $2); } ; _Q_O_QGT_OR_E_S_QConditionalAndExpression_E_C_E_Star: { $$ = constructProduction(e__Q_O_QGT_OR_E_S_QConditionalAndExpression_E_C_E_Star, 0); } | _Q_O_QGT_OR_E_S_QConditionalAndExpression_E_C_E_Star _O_QGT_OR_E_S_QConditionalAndExpression_E_C { $$ = constructProduction(e__Q_O_QGT_OR_E_S_QConditionalAndExpression_E_C_E_Star, 2, $1, $2); } ; ConditionalAndExpression: ValueLogical _Q_O_QGT_AND_E_S_QValueLogical_E_C_E_Star { $$ = constructProduction(e_ConditionalAndExpression, 2, $1, $2); } ; _O_QGT_AND_E_S_QValueLogical_E_C: GT_AND ValueLogical { $$ = constructProduction(e__O_QGT_AND_E_S_QValueLogical_E_C, 2, $1, $2); } ; _Q_O_QGT_AND_E_S_QValueLogical_E_C_E_Star: { $$ = constructProduction(e__Q_O_QGT_AND_E_S_QValueLogical_E_C_E_Star, 0); } | _Q_O_QGT_AND_E_S_QValueLogical_E_C_E_Star _O_QGT_AND_E_S_QValueLogical_E_C { $$ = constructProduction(e__Q_O_QGT_AND_E_S_QValueLogical_E_C_E_Star, 2, $1, $2); } ; ValueLogical: RelationalExpression { $$ = constructProduction(e_ValueLogical, 1, $1); } ; RelationalExpression: NumericExpression _Q_O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C_E_Opt { $$ = constructProduction(e_RelationalExpression, 2, $1, $2); } ; _O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C: GT_EQUAL NumericExpression { $$ = constructProduction(e__O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C, 2, $1, $2); } | GT_NEQUAL NumericExpression { $$ = constructProduction(e__O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C, 2, $1, $2); } | GT_LT NumericExpression { $$ = constructProduction(e__O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C, 2, $1, $2); } | GT_GT NumericExpression { $$ = constructProduction(e__O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C, 2, $1, $2); } | GT_LE NumericExpression { $$ = constructProduction(e__O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C, 2, $1, $2); } | GT_GE NumericExpression { $$ = constructProduction(e__O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C, 2, $1, $2); } ; _Q_O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C_E_Opt: { $$ = constructProduction(e__Q_O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C_E_Opt, 0); } | _O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C { $$ = constructProduction(e__Q_O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C_E_Opt, 1, $1); } ; NumericExpression: AdditiveExpression { $$ = constructProduction(e_NumericExpression, 1, $1); } ; AdditiveExpression: MultiplicativeExpression _Q_O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C_E_Star { $$ = constructProduction(e_AdditiveExpression, 2, $1, $2); } ; _O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C: GT_PLUS MultiplicativeExpression { $$ = constructProduction(e__O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C, 2, $1, $2); } | GT_MINUS MultiplicativeExpression { $$ = constructProduction(e__O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C, 2, $1, $2); } | NumericLiteralPositive { $$ = constructProduction(e__O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C, 1, $1); } | NumericLiteralNegative { $$ = constructProduction(e__O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C, 1, $1); } ; _Q_O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C_E_Star: { $$ = constructProduction(e__Q_O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C_E_Star, 0); } | _Q_O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C_E_Star _O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C { $$ = constructProduction(e__Q_O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C_E_Star, 2, $1, $2); } ; MultiplicativeExpression: UnaryExpression _Q_O_QGT_TIMES_E_S_QUnaryExpression_E_Or_QGT_DIVIDE_E_S_QUnaryExpression_E_C_E_Star { $$ = constructProduction(e_MultiplicativeExpression, 2, $1, $2); } ; _O_QGT_TIMES_E_S_QUnaryExpression_E_Or_QGT_DIVIDE_E_S_QUnaryExpression_E_C: GT_TIMES UnaryExpression { $$ = constructProduction(e__O_QGT_TIMES_E_S_QUnaryExpression_E_Or_QGT_DIVIDE_E_S_QUnaryExpression_E_C, 2, $1, $2); } | GT_DIVIDE UnaryExpression { $$ = constructProduction(e__O_QGT_TIMES_E_S_QUnaryExpression_E_Or_QGT_DIVIDE_E_S_QUnaryExpression_E_C, 2, $1, $2); } ; _Q_O_QGT_TIMES_E_S_QUnaryExpression_E_Or_QGT_DIVIDE_E_S_QUnaryExpression_E_C_E_Star: { $$ = constructProduction(e__Q_O_QGT_TIMES_E_S_QUnaryExpression_E_Or_QGT_DIVIDE_E_S_QUnaryExpression_E_C_E_Star, 0); } | _Q_O_QGT_TIMES_E_S_QUnaryExpression_E_Or_QGT_DIVIDE_E_S_QUnaryExpression_E_C_E_Star _O_QGT_TIMES_E_S_QUnaryExpression_E_Or_QGT_DIVIDE_E_S_QUnaryExpression_E_C { $$ = constructProduction(e__Q_O_QGT_TIMES_E_S_QUnaryExpression_E_Or_QGT_DIVIDE_E_S_QUnaryExpression_E_C_E_Star, 2, $1, $2); } ; UnaryExpression: GT_NOT PrimaryExpression { $$ = constructProduction(e_UnaryExpression, 2, $1, $2); } | GT_PLUS PrimaryExpression { $$ = constructProduction(e_UnaryExpression, 2, $1, $2); } | GT_MINUS PrimaryExpression { $$ = constructProduction(e_UnaryExpression, 2, $1, $2); } | PrimaryExpression { $$ = constructProduction(e_UnaryExpression, 1, $1); } ; PrimaryExpression: BrackettedExpression { $$ = constructProduction(e_PrimaryExpression, 1, $1); } | BuiltInCall { $$ = constructProduction(e_PrimaryExpression, 1, $1); } | IRIrefOrFunction { $$ = constructProduction(e_PrimaryExpression, 1, $1); } | RDFLiteral { $$ = constructProduction(e_PrimaryExpression, 1, $1); } | NumericLiteral { $$ = constructProduction(e_PrimaryExpression, 1, $1); } | BooleanLiteral { $$ = constructProduction(e_PrimaryExpression, 1, $1); } | Var { $$ = constructProduction(e_PrimaryExpression, 1, $1); } ; BrackettedExpression: GT_LPAREN Expression GT_RPAREN { $$ = constructProduction(e_BrackettedExpression, 3, $1, $2, $3); } ; BuiltInCall: IT_STR GT_LPAREN Expression GT_RPAREN { $$ = constructProduction(e_BuiltInCall, 4, $1, $2, $3, $4); } | IT_LANG GT_LPAREN Expression GT_RPAREN { $$ = constructProduction(e_BuiltInCall, 4, $1, $2, $3, $4); } | IT_LANGMATCHES GT_LPAREN Expression GT_COMMA Expression GT_RPAREN { $$ = constructProduction(e_BuiltInCall, 6, $1, $2, $3, $4, $5, $6); } | IT_DATATYPE GT_LPAREN Expression GT_RPAREN { $$ = constructProduction(e_BuiltInCall, 4, $1, $2, $3, $4); } | IT_BOUND GT_LPAREN Var GT_RPAREN { $$ = constructProduction(e_BuiltInCall, 4, $1, $2, $3, $4); } | IT_sameTerm GT_LPAREN Expression GT_COMMA Expression GT_RPAREN { $$ = constructProduction(e_BuiltInCall, 6, $1, $2, $3, $4, $5, $6); } | IT_isIRI GT_LPAREN Expression GT_RPAREN { $$ = constructProduction(e_BuiltInCall, 4, $1, $2, $3, $4); } | IT_isURI GT_LPAREN Expression GT_RPAREN { $$ = constructProduction(e_BuiltInCall, 4, $1, $2, $3, $4); } | IT_isBLANK GT_LPAREN Expression GT_RPAREN { $$ = constructProduction(e_BuiltInCall, 4, $1, $2, $3, $4); } | IT_isLITERAL GT_LPAREN Expression GT_RPAREN { $$ = constructProduction(e_BuiltInCall, 4, $1, $2, $3, $4); } | RegexExpression { $$ = constructProduction(e_BuiltInCall, 1, $1); } ; RegexExpression: IT_REGEX GT_LPAREN Expression GT_COMMA Expression _Q_O_QGT_COMMA_E_S_QExpression_E_C_E_Opt GT_RPAREN { $$ = constructProduction(e_RegexExpression, 7, $1, $2, $3, $4, $5, $6, $7); } ; _Q_O_QGT_COMMA_E_S_QExpression_E_C_E_Opt: { $$ = constructProduction(e__Q_O_QGT_COMMA_E_S_QExpression_E_C_E_Opt, 0); } | _O_QGT_COMMA_E_S_QExpression_E_C { $$ = constructProduction(e__Q_O_QGT_COMMA_E_S_QExpression_E_C_E_Opt, 1, $1); } ; IRIrefOrFunction: IRIref _QArgList_E_Opt { $$ = constructProduction(e_IRIrefOrFunction, 2, $1, $2); } ; _QArgList_E_Opt: { $$ = constructProduction(e__QArgList_E_Opt, 0); } | ArgList { $$ = constructProduction(e__QArgList_E_Opt, 1, $1); } ; RDFLiteral: String _Q_O_QLANGTAG_E_Or_QGT_DTYPE_E_S_QIRIref_E_C_E_Opt { $$ = constructProduction(e_RDFLiteral, 2, $1, $2); } ; _O_QGT_DTYPE_E_S_QIRIref_E_C: GT_DTYPE IRIref { $$ = constructProduction(e__O_QGT_DTYPE_E_S_QIRIref_E_C, 2, $1, $2); } ; _O_QLANGTAG_E_Or_QGT_DTYPE_E_S_QIRIref_E_C: LANGTAG { $$ = constructProduction(e__O_QLANGTAG_E_Or_QGT_DTYPE_E_S_QIRIref_E_C, 1, $1); } | _O_QGT_DTYPE_E_S_QIRIref_E_C { $$ = constructProduction(e__O_QLANGTAG_E_Or_QGT_DTYPE_E_S_QIRIref_E_C, 1, $1); } ; _Q_O_QLANGTAG_E_Or_QGT_DTYPE_E_S_QIRIref_E_C_E_Opt: { $$ = constructProduction(e__Q_O_QLANGTAG_E_Or_QGT_DTYPE_E_S_QIRIref_E_C_E_Opt, 0); } | _O_QLANGTAG_E_Or_QGT_DTYPE_E_S_QIRIref_E_C { $$ = constructProduction(e__Q_O_QLANGTAG_E_Or_QGT_DTYPE_E_S_QIRIref_E_C_E_Opt, 1, $1); } ; NumericLiteral: NumericLiteralUnsigned { $$ = constructProduction(e_NumericLiteral, 1, $1); } | NumericLiteralPositive { $$ = constructProduction(e_NumericLiteral, 1, $1); } | NumericLiteralNegative { $$ = constructProduction(e_NumericLiteral, 1, $1); } ; NumericLiteralUnsigned: INTEGER { $$ = constructProduction(e_NumericLiteralUnsigned, 1, $1); } | DECIMAL { $$ = constructProduction(e_NumericLiteralUnsigned, 1, $1); } | DOUBLE { $$ = constructProduction(e_NumericLiteralUnsigned, 1, $1); } ; NumericLiteralPositive: INTEGER_POSITIVE { $$ = constructProduction(e_NumericLiteralPositive, 1, $1); } | DECIMAL_POSITIVE { $$ = constructProduction(e_NumericLiteralPositive, 1, $1); } | DOUBLE_POSITIVE { $$ = constructProduction(e_NumericLiteralPositive, 1, $1); } ; NumericLiteralNegative: INTEGER_NEGATIVE { $$ = constructProduction(e_NumericLiteralNegative, 1, $1); } | DECIMAL_NEGATIVE { $$ = constructProduction(e_NumericLiteralNegative, 1, $1); } | DOUBLE_NEGATIVE { $$ = constructProduction(e_NumericLiteralNegative, 1, $1); } ; BooleanLiteral: IT_true { $$ = constructProduction(e_BooleanLiteral, 1, $1); } | IT_false { $$ = constructProduction(e_BooleanLiteral, 1, $1); } ; String: STRING_LITERAL1 { $$ = constructProduction(e_String, 1, $1); } | STRING_LITERAL2 { $$ = constructProduction(e_String, 1, $1); } | STRING_LITERAL_LONG1 { $$ = constructProduction(e_String, 1, $1); } | STRING_LITERAL_LONG2 { $$ = constructProduction(e_String, 1, $1); } ; IRIref: IRI_REF { $$ = constructProduction(e_IRIref, 1, $1); } | PrefixedName { $$ = constructProduction(e_IRIref, 1, $1); } ; PrefixedName: PNAME_LN { $$ = constructProduction(e_PrefixedName, 1, $1); } | PNAME_NS { $$ = constructProduction(e_PrefixedName, 1, $1); } ; BlankNode: BLANK_NODE_LABEL { $$ = constructProduction(e_BlankNode, 1, $1); } | ANON { $$ = constructProduction(e_BlankNode, 1, $1); } ; /*** END SPARQL - Change the grammar rules above ***/ %% /*** Additional Code ***/ Class_t Classes[] = { {"_INVISIBLE_", 0, 0}, {"_TERMINAL_", 0, 0}, /* Productions */ {"Query", 5, _Production}, {"_O_QSelectQuery_E_Or_QConstructQuery_E_Or_QDescribeQuery_E_Or_QAskQuery_E_C", 75, _GenProduction}, {"Prologue", 8, _Production}, {"_QBaseDecl_E_Opt", 16, _GenProduction}, {"_QPrefixDecl_E_Star", 19, _GenProduction}, {"BaseDecl", 8, _Production}, {"PrefixDecl", 10, _Production}, {"SelectQuery", 11, _Production}, {"_O_QIT_DISTINCT_E_Or_QIT_REDUCED_E_C", 36, _GenProduction}, {"_Q_O_QIT_DISTINCT_E_Or_QIT_REDUCED_E_C_E_Opt", 44, _GenProduction}, {"_QVar_E_Plus", 12, _GenProduction}, {"_O_QVar_E_Plus_Or_QGT_TIMES_E_C", 31, _GenProduction}, {"_QDatasetClause_E_Star", 22, _GenProduction}, {"ConstructQuery", 14, _Production}, {"DescribeQuery", 13, _Production}, {"_QVarOrIRIref_E_Plus", 20, _GenProduction}, {"_O_QVarOrIRIref_E_Plus_Or_QGT_TIMES_E_C", 39, _GenProduction}, {"_QWhereClause_E_Opt", 19, _GenProduction}, {"AskQuery", 8, _Production}, {"DatasetClause", 13, _Production}, {"_O_QDefaultGraphClause_E_Or_QNamedGraphClause_E_C", 49, _GenProduction}, {"DefaultGraphClause", 18, _Production}, {"NamedGraphClause", 16, _Production}, {"SourceSelector", 14, _Production}, {"WhereClause", 11, _Production}, {"_QIT_WHERE_E_Opt", 16, _GenProduction}, {"SolutionModifier", 16, _Production}, {"_QOrderClause_E_Opt", 19, _GenProduction}, {"_QLimitOffsetClauses_E_Opt", 26, _GenProduction}, {"LimitOffsetClauses", 18, _Production}, {"_QOffsetClause_E_Opt", 20, _GenProduction}, {"_QLimitClause_E_Opt", 19, _GenProduction}, {"_O_QLimitClause_E_S_QOffsetClause_E_Opt_Or_QOffsetClause_E_S_QLimitClause_E_Opt_C", 81, _GenProduction}, {"OrderClause", 11, _Production}, {"_QOrderCondition_E_Plus", 23, _GenProduction}, {"OrderCondition", 14, _Production}, {"_O_QIT_ASC_E_Or_QIT_DESC_E_C", 28, _GenProduction}, {"_O_QIT_ASC_E_Or_QIT_DESC_E_S_QBrackettedExpression_E_C", 54, _GenProduction}, {"_O_QConstraint_E_Or_QVar_E_C", 28, _GenProduction}, {"LimitClause", 11, _Production}, {"OffsetClause", 12, _Production}, {"GroupGraphPattern", 17, _Production}, {"_QTriplesBlock_E_Opt", 20, _GenProduction}, {"_O_QGraphPatternNotTriples_E_Or_QFilter_E_C", 43, _GenProduction}, {"_QGT_DOT_E_Opt", 14, _GenProduction}, {"_O_QGraphPatternNotTriples_E_Or_QFilter_E_S_QGT_DOT_E_Opt_S_QTriplesBlock_E_Opt_C", 81, _GenProduction}, {"_Q_O_QGraphPatternNotTriples_E_Or_QFilter_E_S_QGT_DOT_E_Opt_S_QTriplesBlock_E_Opt_C_E_Star", 90, _GenProduction}, {"TriplesBlock", 12, _Production}, {"_O_QGT_DOT_E_S_QTriplesBlock_E_Opt_C", 36, _GenProduction}, {"_Q_O_QGT_DOT_E_S_QTriplesBlock_E_Opt_C_E_Opt", 44, _GenProduction}, {"GraphPatternNotTriples", 22, _Production}, {"OptionalGraphPattern", 20, _Production}, {"GraphGraphPattern", 17, _Production}, {"GroupOrUnionGraphPattern", 24, _Production}, {"_O_QIT_UNION_E_S_QGroupGraphPattern_E_C", 39, _GenProduction}, {"_Q_O_QIT_UNION_E_S_QGroupGraphPattern_E_C_E_Star", 48, _GenProduction}, {"Filter", 6, _Production}, {"Constraint", 10, _Production}, {"FunctionCall", 12, _Production}, {"ArgList", 7, _Production}, {"_O_QGT_COMMA_E_S_QExpression_E_C", 32, _GenProduction}, {"_Q_O_QGT_COMMA_E_S_QExpression_E_C_E_Star", 41, _GenProduction}, {"_O_QNIL_E_Or_QGT_LPAREN_E_S_QExpression_E_S_QGT_COMMA_E_S_QExpression_E_Star_S_QGT_RPAREN_E_C", 93, _GenProduction}, {"ConstructTemplate", 17, _Production}, {"_QConstructTriples_E_Opt", 24, _GenProduction}, {"ConstructTriples", 16, _Production}, {"_O_QGT_DOT_E_S_QConstructTriples_E_Opt_C", 40, _GenProduction}, {"_Q_O_QGT_DOT_E_S_QConstructTriples_E_Opt_C_E_Opt", 48, _GenProduction}, {"TriplesSameSubject", 18, _Production}, {"PropertyListNotEmpty", 20, _Production}, {"_O_QVerb_E_S_QObjectList_E_C", 28, _GenProduction}, {"_Q_O_QVerb_E_S_QObjectList_E_C_E_Opt", 36, _GenProduction}, {"_O_QGT_SEMI_E_S_QVerb_E_S_QObjectList_E_Opt_C", 45, _GenProduction}, {"_Q_O_QGT_SEMI_E_S_QVerb_E_S_QObjectList_E_Opt_C_E_Star", 54, _GenProduction}, {"PropertyList", 12, _Production}, {"_QPropertyListNotEmpty_E_Opt", 28, _GenProduction}, {"ObjectList", 10, _Production}, {"_O_QGT_COMMA_E_S_QObject_E_C", 28, _GenProduction}, {"_Q_O_QGT_COMMA_E_S_QObject_E_C_E_Star", 37, _GenProduction}, {"Object", 6, _Production}, {"Verb", 4, _Production}, {"TriplesNode", 11, _Production}, {"BlankNodePropertyList", 21, _Production}, {"Collection", 10, _Production}, {"_QGraphNode_E_Plus", 18, _GenProduction}, {"GraphNode", 9, _Production}, {"VarOrTerm", 9, _Production}, {"VarOrIRIref", 11, _Production}, {"Var", 3, _Production}, {"GraphTerm", 9, _Production}, {"Expression", 10, _Production}, {"ConditionalOrExpression", 23, _Production}, {"_O_QGT_OR_E_S_QConditionalAndExpression_E_C", 43, _GenProduction}, {"_Q_O_QGT_OR_E_S_QConditionalAndExpression_E_C_E_Star", 52, _GenProduction}, {"ConditionalAndExpression", 24, _Production}, {"_O_QGT_AND_E_S_QValueLogical_E_C", 32, _GenProduction}, {"_Q_O_QGT_AND_E_S_QValueLogical_E_C_E_Star", 41, _GenProduction}, {"ValueLogical", 12, _Production}, {"RelationalExpression", 20, _Production}, {"_O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C", 218, _GenProduction}, {"_Q_O_QGT_EQUAL_E_S_QNumericExpression_E_Or_QGT_NEQUAL_E_S_QNumericExpression_E_Or_QGT_LT_E_S_QNumericExpression_E_Or_QGT_GT_E_S_QNumericExpression_E_Or_QGT_LE_E_S_QNumericExpression_E_Or_QGT_GE_E_S_QNumericExpression_E_C_E_Opt", 226, _GenProduction}, {"NumericExpression", 17, _Production}, {"AdditiveExpression", 18, _Production}, {"_O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C", 148, _GenProduction}, {"_Q_O_QGT_PLUS_E_S_QMultiplicativeExpression_E_Or_QGT_MINUS_E_S_QMultiplicativeExpression_E_Or_QNumericLiteralPositive_E_Or_QNumericLiteralNegative_E_C_E_Star", 157, _GenProduction}, {"MultiplicativeExpression", 24, _Production}, {"_O_QGT_TIMES_E_S_QUnaryExpression_E_Or_QGT_DIVIDE_E_S_QUnaryExpression_E_C", 74, _GenProduction}, {"_Q_O_QGT_TIMES_E_S_QUnaryExpression_E_Or_QGT_DIVIDE_E_S_QUnaryExpression_E_C_E_Star", 83, _GenProduction}, {"UnaryExpression", 15, _Production}, {"PrimaryExpression", 17, _Production}, {"BrackettedExpression", 20, _Production}, {"BuiltInCall", 11, _Production}, {"RegexExpression", 15, _Production}, {"_Q_O_QGT_COMMA_E_S_QExpression_E_C_E_Opt", 40, _GenProduction}, {"IRIrefOrFunction", 16, _Production}, {"_QArgList_E_Opt", 15, _GenProduction}, {"RDFLiteral", 10, _Production}, {"_O_QGT_DTYPE_E_S_QIRIref_E_C", 28, _GenProduction}, {"_O_QLANGTAG_E_Or_QGT_DTYPE_E_S_QIRIref_E_C", 42, _GenProduction}, {"_Q_O_QLANGTAG_E_Or_QGT_DTYPE_E_S_QIRIref_E_C_E_Opt", 50, _GenProduction}, {"NumericLiteral", 14, _Production}, {"NumericLiteralUnsigned", 22, _Production}, {"NumericLiteralPositive", 22, _Production}, {"NumericLiteralNegative", 22, _Production}, {"BooleanLiteral", 14, _Production}, {"String", 6, _Production}, {"IRIref", 6, _Production}, {"PrefixedName", 12, _Production}, {"BlankNode", 9, _Production}, /* Terminals */ {"IT_BASE", 7, _Constant}, {"IT_PREFIX", 9, _Constant}, {"IT_SELECT", 9, _Constant}, {"IT_DISTINCT", 11, _Constant}, {"IT_REDUCED", 10, _Constant}, {"GT_TIMES", 8, _Constant}, {"IT_CONSTRUCT", 12, _Constant}, {"IT_DESCRIBE", 11, _Constant}, {"IT_ASK", 6, _Constant}, {"IT_FROM", 7, _Constant}, {"IT_NAMED", 8, _Constant}, {"IT_WHERE", 8, _Constant}, {"IT_ORDER", 8, _Constant}, {"IT_BY", 5, _Constant}, {"IT_ASC", 6, _Constant}, {"IT_DESC", 7, _Constant}, {"IT_LIMIT", 8, _Constant}, {"IT_OFFSET", 9, _Constant}, {"GT_LCURLEY", 10, _Constant}, {"GT_RCURLEY", 10, _Constant}, {"GT_DOT", 6, _Constant}, {"IT_OPTIONAL", 11, _Constant}, {"IT_GRAPH", 8, _Constant}, {"IT_UNION", 8, _Constant}, {"IT_FILTER", 9, _Constant}, {"GT_COMMA", 8, _Constant}, {"GT_LPAREN", 9, _Constant}, {"GT_RPAREN", 9, _Constant}, {"GT_SEMI", 7, _Constant}, {"IT_a", 4, _Constant}, {"GT_LBRACKET", 11, _Constant}, {"GT_RBRACKET", 11, _Constant}, {"GT_OR", 5, _Constant}, {"GT_AND", 6, _Constant}, {"GT_EQUAL", 8, _Constant}, {"GT_NEQUAL", 9, _Constant}, {"GT_LT", 5, _Constant}, {"GT_GT", 5, _Constant}, {"GT_LE", 5, _Constant}, {"GT_GE", 5, _Constant}, {"GT_PLUS", 7, _Constant}, {"GT_MINUS", 8, _Constant}, {"GT_DIVIDE", 9, _Constant}, {"GT_NOT", 6, _Constant}, {"IT_STR", 6, _Constant}, {"IT_LANG", 7, _Constant}, {"IT_LANGMATCHES", 14, _Constant}, {"IT_DATATYPE", 11, _Constant}, {"IT_BOUND", 8, _Constant}, {"IT_sameTerm", 11, _Constant}, {"IT_isIRI", 8, _Constant}, {"IT_isURI", 8, _Constant}, {"IT_isBLANK", 10, _Constant}, {"IT_isLITERAL", 12, _Constant}, {"IT_REGEX", 8, _Constant}, {"GT_DTYPE", 8, _Constant}, {"IT_true", 7, _Constant}, {"IT_false", 8, _Constant}, {"IRI_REF", 7, _Terminal}, {"PNAME_NS", 8, _Terminal}, {"PNAME_LN", 8, _Terminal}, {"BLANK_NODE_LABEL", 16, _Terminal}, {"VAR1", 4, _Terminal}, {"VAR2", 4, _Terminal}, {"LANGTAG", 7, _Terminal}, {"INTEGER", 7, _Terminal}, {"DECIMAL", 7, _Terminal}, {"DOUBLE", 6, _Terminal}, {"INTEGER_POSITIVE", 16, _Terminal}, {"DECIMAL_POSITIVE", 16, _Terminal}, {"DOUBLE_POSITIVE", 15, _Terminal}, {"INTEGER_NEGATIVE", 16, _Terminal}, {"DECIMAL_NEGATIVE", 16, _Terminal}, {"DOUBLE_NEGATIVE", 15, _Terminal}, {"STRING_LITERAL1", 15, _Terminal}, {"STRING_LITERAL2", 15, _Terminal}, {"STRING_LITERAL_LONG1", 20, _Terminal}, {"STRING_LITERAL_LONG2", 20, _Terminal}, {"NIL", 3, _Terminal}, {"ANON", 4, _Terminal}, }; #line 2 "../../CYaccFooterTemplate" // -------------------------------------- START // -------------------------------------- END const char const * toString (Semval* semval) { char* ret; const char const ** rets; size_t size = 0; size_t i; switch (Classes[semval->type].type) { case _GenProduction: case _Production: if (semval->size == 0) size = 0; else rets = malloc(sizeof(const char const *) * semval->size); for (i = 0; i < semval->size; i++) { rets[i] = toString(semval->vals[i]); size += 1+strlen(rets[i]); } ret = malloc(size + 1); ret[0] = 0; for (i = 0; i < semval->size; i++) { strcat(ret, " "); strcat(ret, rets[i]); } if (semval->size != 0) free(rets); return ret; case _Constant: case _Terminal: ret = malloc(sizeof(char*)*semval->size + 1); strncpy(ret, semval->str, semval->size + 1); return ret; default: fprintf(stderr, "how do i toString a %d?\n", semval->type); } } #define tab 2 const char const * yit = "yacker:implicit-terminal"; #define lyit strlen(yit) #define ns "\n xmlns=\"http://www.w3.org/2005/01/yacker/uploads/katherine/\"\n xmlns:yacker=\"http://www.w3.org/2005/01/yacker/\"" #define lns sizeof(ns)-1 /* strlen(ns) */ const char const * toXml (Semval* semval, unsigned depth) { char* ret; const char const ** rets; size_t size = 0; size_t i; unsigned leaderLen = depth*tab; char* leader = malloc(leaderLen+1); for (i = 0; i < leaderLen; i++) leader[i] = ' '; leader[leaderLen] = 0; switch (Classes[semval->type].type) { case _GenProduction: case _Production: /* Calculate size of namespaces and embedded elements. */ if (semval->size == 0) size = 0; else rets = malloc(sizeof(const char const *) * semval->size); for (i = 0; i < semval->size; i++) { rets[i] = toXml(semval->vals[i], Classes[semval->type].type == _Production ? depth+1 : depth); size += strlen(rets[i]); } if (depth == 0) size += lns; ret = malloc(leaderLen*2 + Classes[semval->type].size*2+8 + size); if (Classes[semval->type].type == _Production) sprintf(ret, "%s<%s%s>\n", leader, Classes[semval->type].name, depth == 0 ? ns : ""); else ret[0] = 0; for (i = 0; i < semval->size; i++) strcat(ret, rets[i]); if (semval->size != 0) free(rets); if (Classes[semval->type].type == _Production) sprintf(ret+leaderLen+1+Classes[semval->type].size+2+size, "%s\n", leader, Classes[semval->type].name); break; case _Constant: ret = malloc(leaderLen+lyit*2+6 + semval->size); sprintf(ret, "%s<%s>%s\n", leader, yit, semval->str, yit); break; case _Terminal: ret = malloc(leaderLen+Classes[semval->type].size*2+6 + semval->size); sprintf(ret, "%s<%s>%s\n", leader, Classes[semval->type].name, semval->str, Classes[semval->type].name); break; default: fprintf(stderr, "how do i toXml a %d?\n", semval->type); } return ret; } FILE* _Trace = NULL; Semval* constructProduction (const Classes_e type, size_t argc, ...) { Semval* ret = malloc(sizeof(Semval)); va_list semvals; size_t argNo, valsNo; Semval* semval; const char const * str; ret->type = type; ret->size = argc; /* Appropriate type? */ if (Classes[type].type != _Production && Classes[type].type != _GenProduction) { fprintf(stderr, "constructProduction(%d, %d, ...). Classes[type] (%d) != _Production (%d)", type, argc, Classes[type], _Production); } /* Trace */ if (_Trace) fprintf(_Trace, " %s:", Classes[type].name); va_start(semvals, argc); for (argNo = 0; argNo < argc; argNo++) { semval = va_arg(semvals, Semval*); /* By default, each argument represents a series of parameter. */ int semvalSize = 1; /* Productions created for *, +, ? or ()s are represented * as a series of n parameters. */ if (Classes[semval->type].type == _GenProduction) { semvalSize = semval->size; /* copying elements from an array */ /* Absorb the nested created production when the production * is an expansion for a *, + or ?, e.g. foo_Star: foo_Star foo */ if (semval->type == type) { ret->size -= 1; ret->size += semvalSize; } } if (_Trace) fprintf(_Trace, " %s(%d)", Classes[semval->type].name, semvalSize); } va_end(semvals); if (_Trace) fprintf(_Trace, "\n"); if (argc) { ret->vals = malloc(sizeof(Semval*) * ret->size); va_start(semvals, argc); for (argNo = valsNo = 0; argNo < argc; argNo++) { semval = va_arg(semvals, Semval*); if (Classes[semval->type].type == _GenProduction) { short absorbSemval = semval->type == type; size_t j; for (j = 0; j < semval->size; j++) { Semval* nestedSemval = semval->vals[j]; if (absorbSemval) /* If absorbing the argument, take each of its * constructor args. */ ret->vals[valsNo++] = nestedSemval; if (_Trace && semval->size > 0) { /* Regardless of absorption, display each * generated argument separately. */ str = toString(nestedSemval); fprintf(_Trace, " %s(%d): %s\n", Classes[semval->type].name, j, str); free ((char*)str); } } if (absorbSemval) { /* If we absorbed the nested production, free it. */ if (semval->size) free (semval->vals); free (semval); } else { /* If not absorbing the argument, add it to the * constructor args. */ ret->vals[valsNo++] = semval; } } else { ret->vals[valsNo++] = semval; if (_Trace && semval->size > 0) { str = toString(semval); fprintf(_Trace, " %s(%d): %s\n", Classes[semval->type].name, 0, str); free ((char*)str); } } } va_end(semvals); } free ((char*)toString(ret)); free ((char*)toXml(ret, 0)); return ret; } Semval* constructTerminal (const Classes_e type, const char const * str) { Semval* ret = malloc(sizeof(Semval)); if (_Trace) fprintf(_Trace, "shift (%s, %s)\n", Classes[type].name, str); ret->type = type; ret->size = strlen(str); ret->str = malloc(ret->size+1); strncpy((char*)ret->str, str, ret->size+1); free ((char*)toString(ret)); free ((char*)toXml(ret, 0)); return ret; } void yyerror (char *m) /* SPARQL_ */ { fprintf(stderr,"error %s at \"%s\"\n", m, getContextString(m)); } #include extern FILE *SPARQLin, *SPARQLout; int main(int argc, char* argv[]) { char* tmp; if (tmp = getenv("TRACE_FD")) { int fd; sscanf(tmp, "%d", &fd); if (!(_Trace = fdopen(fd, "a"))) fprintf(stderr, "couldn't open trace fd %d\n", fd); } const char* inputId; if (argc > 1) { inputId = argv[1]; SPARQLin = fopen(argv[1], "r"); } else { inputId = ""; SPARQLin = stdin; } SPARQLset_debug(0); /* prevent lex from printing tokens */ int result = yyparse(); /* @@ SPARQL_ */ if (result) fprintf(stderr, "Error: %s did not contain a valid SPARQL string.\n", inputId); else fprintf(stdout, "%s", toXml(StupidGlobal, 0)); if (_Trace) close(_Trace); return result; }