parser
SPARQL 1.1 Parser
based on pyparsing
Functions:
-
expandBNodeTriples–expand [ ?p ?o ] syntax for implicit bnodes
-
expandCollection–expand ( 1 2 3 ) notation for collections
-
expandTriples–Expand ; and , syntax for repeat predicates, subjects
-
expandUnicodeEscapes–The syntax of the SPARQL Query Language is expressed over code points in Unicode [UNICODE]. The encoding is always UTF-8 [RFC3629].
-
neg– -
parseQuery– -
parseUpdate– -
setDataType– -
setLanguage–
Attributes:
-
A– -
ANON– -
Add– -
AdditiveExpression– -
Aggregate– -
ArgList– -
AskQuery– -
BLANK_NODE_LABEL– -
BaseDecl– -
Bind– -
BlankNode– -
BlankNodePropertyList– -
BlankNodePropertyListPath– -
BooleanLiteral– -
BrackettedExpression– -
BuiltInCall– -
Clear– -
Collection– -
CollectionPath– -
ConditionalAndExpression– -
ConditionalOrExpression– -
Constraint– -
ConstructQuery– -
ConstructTemplate– -
ConstructTriples– -
Copy– -
Create– -
DEBUG– -
DECIMAL– -
DECIMAL_NEGATIVE– -
DECIMAL_POSITIVE– -
DOUBLE– -
DOUBLE_NEGATIVE– -
DOUBLE_POSITIVE– -
DataBlock– -
DataBlockValue– -
DatasetClause– -
DefaultGraphClause– -
DeleteClause– -
DeleteData– -
DeleteWhere– -
DescribeQuery– -
Drop– -
EXPONENT_re– -
ExistsFunc– -
Expression– -
ExpressionList– -
Filter– -
FunctionCall– -
GraphGraphPattern– -
GraphNode– -
GraphNodePath– -
GraphOrDefault– -
GraphPatternNotTriples– -
GraphRef– -
GraphRefAll– -
GraphTerm– -
GroupClause– -
GroupCondition– -
GroupGraphPattern– -
GroupGraphPatternSub– -
GroupOrUnionGraphPattern– -
HavingClause– -
HavingCondition– -
INTEGER– -
INTEGER_NEGATIVE– -
INTEGER_POSITIVE– -
IRIREF– -
InlineData– -
InlineDataFull– -
InlineDataOneVar– -
InsertClause– -
InsertData– -
Integer– -
LANGTAG– -
LimitClause– -
LimitOffsetClauses– -
Load– -
MinusGraphPattern– -
Modify– -
Move– -
MultiplicativeExpression– -
NIL– -
NamedGraphClause– -
NotExistsFunc– -
NumericExpression– -
NumericLiteral– -
NumericLiteralNegative– -
NumericLiteralPositive– -
NumericLiteralUnsigned– -
Object– -
ObjectList– -
ObjectListPath– -
ObjectPath– -
OffsetClause– -
OptionalGraphPattern– -
OrderClause– -
OrderCondition– -
PERCENT_re– -
PLX_re– -
PNAME_LN– -
PNAME_NS– -
PN_CHARS_BASE_re– -
PN_CHARS_U_re– -
PN_CHARS_re– -
PN_LOCAL– -
PN_LOCAL_ESC_re– -
PN_PREFIX– -
Path– -
PathAlternative– -
PathElt– -
PathEltOrInverse– -
PathMod– -
PathNegatedPropertySet– -
PathOneInPropertySet– -
PathPrimary– -
PathSequence– -
PrefixDecl– -
PrefixedName– -
PrimaryExpression– -
Prologue– -
PropertyList– -
PropertyListNotEmpty– -
PropertyListPath– -
PropertyListPathNotEmpty– -
QuadData– -
QuadPattern– -
Quads– -
QuadsNotTriples– -
Query– -
QueryUnit– -
RDFLiteral– -
RegexExpression– -
RelationalExpression– -
STRING_LITERAL1– -
STRING_LITERAL2– -
STRING_LITERAL_LONG1– -
STRING_LITERAL_LONG2– -
SelectClause– -
SelectQuery– -
ServiceGraphPattern– -
SolutionModifier– -
SourceSelector– -
StrReplaceExpression– -
String– -
SubSelect– -
SubstringExpression– -
TriplesBlock– -
TriplesNode– -
TriplesNodePath– -
TriplesSameSubject– -
TriplesSameSubjectPath– -
TriplesTemplate– -
UnaryExpression– -
Update– -
Update1– -
UpdateUnit– -
UsingClause– -
VAR1– -
VAR2– -
VARNAME– -
ValueLogical– -
ValuesClause– -
Var– -
VarOrIri– -
VarOrTerm– -
Verb– -
VerbPath– -
VerbSimple– -
WhereClause– -
expandUnicodeEscapes_re(Pattern) – -
iri– -
iriOrFunction–
Add
module-attribute
Add = Comp('Add', Keyword('ADD') + _Silent + GraphOrDefault + Keyword('TO') + GraphOrDefault)
AdditiveExpression
module-attribute
AdditiveExpression = Comp('AdditiveExpression', Param('expr', MultiplicativeExpression) + ZeroOrMore(ParamList('op', '+') + ParamList('other', MultiplicativeExpression) | ParamList('op', '-') + ParamList('other', MultiplicativeExpression))).setEvalFn(op.AdditiveExpression)
Aggregate
module-attribute
Aggregate = Comp('Aggregate_Count', Keyword('COUNT') + '(' + Param('distinct', _Distinct) + Param('vars', '*' | Expression) + ')') | Comp('Aggregate_Sum', Keyword('SUM') + _AggregateParams) | Comp('Aggregate_Min', Keyword('MIN') + _AggregateParams) | Comp('Aggregate_Max', Keyword('MAX') + _AggregateParams) | Comp('Aggregate_Avg', Keyword('AVG') + _AggregateParams) | Comp('Aggregate_Sample', Keyword('SAMPLE') + _AggregateParams) | Comp('Aggregate_GroupConcat', Keyword('GROUP_CONCAT') + '(' + Param('distinct', _Distinct) + Param('vars', Expression) + Optional(';' + Keyword('SEPARATOR') + '=' + Param('separator', String)) + ')')
ArgList
module-attribute
ArgList = NIL | '(' + Param('distinct', _Distinct) + DelimitedList(ParamList('expr', Expression)) + ')'
AskQuery
module-attribute
AskQuery = Comp('AskQuery', Keyword('ASK') + ZeroOrMore(ParamList('datasetClause', DatasetClause)) + WhereClause + SolutionModifier + ValuesClause)
BLANK_NODE_LABEL
module-attribute
BLANK_NODE_LABEL = Regex('_:[0-9%s](?:[\\.%s]*[%s])?' % (PN_CHARS_U_re, PN_CHARS_re, PN_CHARS_re), flags=re.U)
Bind
module-attribute
Bind = Comp('Bind', Keyword('BIND') + '(' + Param('expr', Expression) + Keyword('AS') + Param('var', Var) + ')')
BlankNodePropertyList
module-attribute
BlankNodePropertyList = Group(Suppress('[') + PropertyListNotEmpty + Suppress(']'))
BlankNodePropertyListPath
module-attribute
BlankNodePropertyListPath = Group(Suppress('[') + PropertyListPathNotEmpty + Suppress(']'))
BooleanLiteral
module-attribute
BooleanLiteral = Keyword('true').set_parse_action(lambda: rdflib.Literal(True)) | Keyword('false').set_parse_action(lambda: rdflib.Literal(False))
BrackettedExpression
module-attribute
BrackettedExpression = Suppress('(') + Expression + Suppress(')')
BuiltInCall
module-attribute
BuiltInCall = Aggregate | Comp('Builtin_STR', Keyword('STR') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_STR) | Comp('Builtin_LANG', Keyword('LANG') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_LANG) | Comp('Builtin_LANGMATCHES', Keyword('LANGMATCHES') + '(' + Param('arg1', Expression) + ',' + Param('arg2', Expression) + ')').setEvalFn(op.Builtin_LANGMATCHES) | Comp('Builtin_DATATYPE', Keyword('DATATYPE') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_DATATYPE) | Comp('Builtin_BOUND', Keyword('BOUND') + '(' + Param('arg', Var) + ')').setEvalFn(op.Builtin_BOUND) | Comp('Builtin_IRI', Keyword('IRI') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_IRI) | Comp('Builtin_URI', Keyword('URI') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_IRI) | Comp('Builtin_BNODE', Keyword('BNODE') + ('(' + Param('arg', Expression) + ')' | NIL)).setEvalFn(op.Builtin_BNODE) | Comp('Builtin_RAND', Keyword('RAND') + NIL).setEvalFn(op.Builtin_RAND) | Comp('Builtin_ABS', Keyword('ABS') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_ABS) | Comp('Builtin_CEIL', Keyword('CEIL') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_CEIL) | Comp('Builtin_FLOOR', Keyword('FLOOR') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_FLOOR) | Comp('Builtin_ROUND', Keyword('ROUND') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_ROUND) | Comp('Builtin_CONCAT', Keyword('CONCAT') + Param('arg', ExpressionList)).setEvalFn(op.Builtin_CONCAT) | SubstringExpression | Comp('Builtin_STRLEN', Keyword('STRLEN') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_STRLEN) | StrReplaceExpression | Comp('Builtin_UCASE', Keyword('UCASE') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_UCASE) | Comp('Builtin_LCASE', Keyword('LCASE') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_LCASE) | Comp('Builtin_ENCODE_FOR_URI', Keyword('ENCODE_FOR_URI') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_ENCODE_FOR_URI) | Comp('Builtin_CONTAINS', Keyword('CONTAINS') + '(' + Param('arg1', Expression) + ',' + Param('arg2', Expression) + ')').setEvalFn(op.Builtin_CONTAINS) | Comp('Builtin_STRSTARTS', Keyword('STRSTARTS') + '(' + Param('arg1', Expression) + ',' + Param('arg2', Expression) + ')').setEvalFn(op.Builtin_STRSTARTS) | Comp('Builtin_STRENDS', Keyword('STRENDS') + '(' + Param('arg1', Expression) + ',' + Param('arg2', Expression) + ')').setEvalFn(op.Builtin_STRENDS) | Comp('Builtin_STRBEFORE', Keyword('STRBEFORE') + '(' + Param('arg1', Expression) + ',' + Param('arg2', Expression) + ')').setEvalFn(op.Builtin_STRBEFORE) | Comp('Builtin_STRAFTER', Keyword('STRAFTER') + '(' + Param('arg1', Expression) + ',' + Param('arg2', Expression) + ')').setEvalFn(op.Builtin_STRAFTER) | Comp('Builtin_YEAR', Keyword('YEAR') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_YEAR) | Comp('Builtin_MONTH', Keyword('MONTH') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_MONTH) | Comp('Builtin_DAY', Keyword('DAY') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_DAY) | Comp('Builtin_HOURS', Keyword('HOURS') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_HOURS) | Comp('Builtin_MINUTES', Keyword('MINUTES') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_MINUTES) | Comp('Builtin_SECONDS', Keyword('SECONDS') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_SECONDS) | Comp('Builtin_TIMEZONE', Keyword('TIMEZONE') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_TIMEZONE) | Comp('Builtin_TZ', Keyword('TZ') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_TZ) | Comp('Builtin_NOW', Keyword('NOW') + NIL).setEvalFn(op.Builtin_NOW) | Comp('Builtin_UUID', Keyword('UUID') + NIL).setEvalFn(op.Builtin_UUID) | Comp('Builtin_STRUUID', Keyword('STRUUID') + NIL).setEvalFn(op.Builtin_STRUUID) | Comp('Builtin_MD5', Keyword('MD5') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_MD5) | Comp('Builtin_SHA1', Keyword('SHA1') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_SHA1) | Comp('Builtin_SHA256', Keyword('SHA256') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_SHA256) | Comp('Builtin_SHA384', Keyword('SHA384') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_SHA384) | Comp('Builtin_SHA512', Keyword('SHA512') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_SHA512) | Comp('Builtin_COALESCE', Keyword('COALESCE') + Param('arg', ExpressionList)).setEvalFn(op.Builtin_COALESCE) | Comp('Builtin_IF', Keyword('IF') + '(' + Param('arg1', Expression) + ',' + Param('arg2', Expression) + ',' + Param('arg3', Expression) + ')').setEvalFn(op.Builtin_IF) | Comp('Builtin_STRLANG', Keyword('STRLANG') + '(' + Param('arg1', Expression) + ',' + Param('arg2', Expression) + ')').setEvalFn(op.Builtin_STRLANG) | Comp('Builtin_STRDT', Keyword('STRDT') + '(' + Param('arg1', Expression) + ',' + Param('arg2', Expression) + ')').setEvalFn(op.Builtin_STRDT) | Comp('Builtin_sameTerm', Keyword('sameTerm') + '(' + Param('arg1', Expression) + ',' + Param('arg2', Expression) + ')').setEvalFn(op.Builtin_sameTerm) | Comp('Builtin_isIRI', Keyword('isIRI') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_isIRI) | Comp('Builtin_isURI', Keyword('isURI') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_isIRI) | Comp('Builtin_isBLANK', Keyword('isBLANK') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_isBLANK) | Comp('Builtin_isLITERAL', Keyword('isLITERAL') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_isLITERAL) | Comp('Builtin_isNUMERIC', Keyword('isNUMERIC') + '(' + Param('arg', Expression) + ')').setEvalFn(op.Builtin_isNUMERIC) | RegexExpression | ExistsFunc | NotExistsFunc
CollectionPath
module-attribute
CollectionPath = Suppress('(') + OneOrMore(GraphNodePath) + Suppress(')')
ConditionalAndExpression
module-attribute
ConditionalAndExpression = Comp('ConditionalAndExpression', Param('expr', ValueLogical) + ZeroOrMore('&&' + ParamList('other', ValueLogical))).setEvalFn(op.ConditionalAndExpression)
ConditionalOrExpression
module-attribute
ConditionalOrExpression = Comp('ConditionalOrExpression', Param('expr', ConditionalAndExpression) + ZeroOrMore('||' + ParamList('other', ConditionalAndExpression))).setEvalFn(op.ConditionalOrExpression)
ConstructQuery
module-attribute
ConstructQuery = Comp('ConstructQuery', Keyword('CONSTRUCT') + (ConstructTemplate + ZeroOrMore(ParamList('datasetClause', DatasetClause)) + WhereClause + SolutionModifier + ValuesClause | ZeroOrMore(ParamList('datasetClause', DatasetClause)) + Keyword('WHERE') + '{' + Optional(Param('where', Comp('FakeGroupGraphPatten', ParamList('part', Comp('TriplesBlock', TriplesTemplate))))) + '}' + SolutionModifier + ValuesClause))
ConstructTemplate
module-attribute
ConstructTemplate = Suppress('{') + Optional(ConstructTriples) + Suppress('}')
Copy
module-attribute
Copy = Comp('Copy', Keyword('COPY') + _Silent + GraphOrDefault + Keyword('TO') + GraphOrDefault)
DECIMAL_NEGATIVE
module-attribute
DECIMAL_NEGATIVE = Suppress('-') + DECIMAL.copy().leave_whitespace()
DECIMAL_POSITIVE
module-attribute
DECIMAL_POSITIVE = Suppress('+') + DECIMAL.copy().leave_whitespace()
DOUBLE
module-attribute
DOUBLE = Regex('[0-9]+\\.[0-9]*%(e)s|\\.([0-9])+%(e)s|[0-9]+%(e)s' % {'e': EXPONENT_re})
DataBlockValue
module-attribute
DataBlockValue = iri | RDFLiteral | NumericLiteral | BooleanLiteral | Keyword('UNDEF')
DatasetClause
module-attribute
DatasetClause = Comp('DatasetClause', Keyword('FROM') + (Param('default', DefaultGraphClause) | NamedGraphClause))
DeleteData
module-attribute
DeleteWhere
module-attribute
DeleteWhere = Comp('DeleteWhere', Keyword('DELETE') + Keyword('WHERE') + QuadPattern)
DescribeQuery
module-attribute
DescribeQuery = Comp('DescribeQuery', Keyword('DESCRIBE') + (OneOrMore(ParamList('var', VarOrIri)) | '*') + ZeroOrMore(ParamList('datasetClause', DatasetClause)) + Optional(WhereClause) + SolutionModifier + ValuesClause)
ExistsFunc
module-attribute
ExistsFunc = Comp('Builtin_EXISTS', Keyword('EXISTS') + Param('graph', GroupGraphPattern)).setEvalFn(op.Builtin_EXISTS)
ExpressionList
module-attribute
ExpressionList = NIL | Group(Suppress('(') + DelimitedList(Expression) + Suppress(')'))
FunctionCall
module-attribute
GraphGraphPattern
module-attribute
GraphGraphPattern = Comp('GraphGraphPattern', Keyword('GRAPH') + Param('term', VarOrIri) + Param('graph', GroupGraphPattern))
GraphOrDefault
module-attribute
GraphOrDefault = ParamList('graph', Keyword('DEFAULT')) | Optional(Keyword('GRAPH')) + ParamList('graph', iri)
GraphPatternNotTriples
module-attribute
GraphPatternNotTriples = GroupOrUnionGraphPattern | OptionalGraphPattern | MinusGraphPattern | GraphGraphPattern | ServiceGraphPattern | Filter | Bind | InlineData
GraphRefAll
module-attribute
GraphRefAll = GraphRef | Param('graphiri', Keyword('DEFAULT')) | Param('graphiri', Keyword('NAMED')) | Param('graphiri', Keyword('ALL'))
GraphTerm
module-attribute
GraphTerm = iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL
GroupClause
module-attribute
GroupClause = Comp('GroupClause', Keyword('GROUP') + Keyword('BY') + OneOrMore(ParamList('condition', GroupCondition)))
GroupCondition
module-attribute
GroupCondition = BuiltInCall | FunctionCall | Comp('GroupAs', '(' + Param('expr', Expression) + Optional(Keyword('AS') + Param('var', Var)) + ')') | Var
GroupGraphPatternSub
module-attribute
GroupGraphPatternSub = Comp('GroupGraphPatternSub', Optional(ParamList('part', Comp('TriplesBlock', TriplesBlock))) + ZeroOrMore(ParamList('part', GraphPatternNotTriples) + Optional('.') + Optional(ParamList('part', Comp('TriplesBlock', TriplesBlock)))))
GroupOrUnionGraphPattern
module-attribute
GroupOrUnionGraphPattern = Comp('GroupOrUnionGraphPattern', ParamList('graph', GroupGraphPattern) + ZeroOrMore(Keyword('UNION') + ParamList('graph', GroupGraphPattern)))
HavingClause
module-attribute
HavingClause = Comp('HavingClause', Keyword('HAVING') + OneOrMore(ParamList('condition', HavingCondition)))
INTEGER_NEGATIVE
module-attribute
INTEGER_NEGATIVE = Suppress('-') + INTEGER.copy().leave_whitespace()
INTEGER_POSITIVE
module-attribute
INTEGER_POSITIVE = Suppress('+') + INTEGER.copy().leave_whitespace()
IRIREF
module-attribute
IRIREF = Combine(Suppress('<') + Regex('[^<>"{}|^`\\\\%s]*' % ''.join(('\\x%02X' % i) for i in (range(33)))) + Suppress('>'))
InlineDataFull
module-attribute
InlineDataFull = (NIL | '(' + ZeroOrMore(ParamList('var', Var)) + ')') + '{' + ZeroOrMore(ParamList('value', Group(Suppress('(') + ZeroOrMore(DataBlockValue) + Suppress(')') | NIL))) + '}'
InlineDataOneVar
module-attribute
InlineDataOneVar = ParamList('var', Var) + '{' + ZeroOrMore(ParamList('value', DataBlockValue)) + '}'
InsertData
module-attribute
LimitOffsetClauses
module-attribute
LimitOffsetClauses = Comp('LimitOffsetClauses', LimitClause + Optional(OffsetClause) | OffsetClause + Optional(LimitClause))
Load
module-attribute
Load = Comp('Load', Keyword('LOAD') + _Silent + Param('iri', iri) + Optional(Keyword('INTO') + GraphRef))
MinusGraphPattern
module-attribute
MinusGraphPattern = Comp('MinusGraphPattern', Keyword('MINUS') + Param('graph', GroupGraphPattern))
Modify
module-attribute
Modify = Comp('Modify', Optional(Keyword('WITH') + Param('withClause', iri)) + (Param('delete', DeleteClause) + Optional(Param('insert', InsertClause)) | Param('insert', InsertClause)) + ZeroOrMore(ParamList('using', UsingClause)) + Keyword('WHERE') + Param('where', GroupGraphPattern))
Move
module-attribute
Move = Comp('Move', Keyword('MOVE') + _Silent + GraphOrDefault + Keyword('TO') + GraphOrDefault)
MultiplicativeExpression
module-attribute
MultiplicativeExpression = Comp('MultiplicativeExpression', Param('expr', UnaryExpression) + ZeroOrMore(ParamList('op', '*') + ParamList('other', UnaryExpression) | ParamList('op', '/') + ParamList('other', UnaryExpression))).setEvalFn(op.MultiplicativeExpression)
NamedGraphClause
module-attribute
NamedGraphClause = Keyword('NAMED') + Param('named', SourceSelector)
NotExistsFunc
module-attribute
NotExistsFunc = Comp('Builtin_NOTEXISTS', Keyword('NOT') + Keyword('EXISTS') + Param('graph', GroupGraphPattern)).setEvalFn(op.Builtin_EXISTS)
NumericLiteral
module-attribute
NumericLiteral = NumericLiteralUnsigned | NumericLiteralPositive | NumericLiteralNegative
NumericLiteralNegative
module-attribute
NumericLiteralNegative = DOUBLE_NEGATIVE | DECIMAL_NEGATIVE | INTEGER_NEGATIVE
NumericLiteralPositive
module-attribute
NumericLiteralPositive = DOUBLE_POSITIVE | DECIMAL_POSITIVE | INTEGER_POSITIVE
OptionalGraphPattern
module-attribute
OptionalGraphPattern = Comp('OptionalGraphPattern', Keyword('OPTIONAL') + Param('graph', GroupGraphPattern))
OrderClause
module-attribute
OrderClause = Comp('OrderClause', Keyword('ORDER') + Keyword('BY') + OneOrMore(ParamList('condition', OrderCondition)))
OrderCondition
module-attribute
OrderCondition = Comp('OrderCondition', Param('order', Keyword('ASC') | Keyword('DESC')) + Param('expr', BrackettedExpression) | Param('expr', Constraint | Var))
PNAME_NS
module-attribute
PN_CHARS_BASE_re
module-attribute
PN_LOCAL
module-attribute
PN_LOCAL = Regex('([%(PN_CHARS_U)s:0-9]|%(PLX)s)\n (([%(PN_CHARS)s\\.:]|%(PLX)s)*\n ([%(PN_CHARS)s:]|%(PLX)s) )?' % dict(PN_CHARS_U=PN_CHARS_U_re, PN_CHARS=PN_CHARS_re, PLX=PLX_re), flags=re.X | re.UNICODE)
PN_PREFIX
module-attribute
PN_PREFIX = Regex('[%s](?:[%s\\.]*[%s])?' % (PN_CHARS_BASE_re, PN_CHARS_re, PN_CHARS_re), flags=re.U)
PathAlternative
module-attribute
PathAlternative = Comp('PathAlternative', ParamList('part', PathSequence) + ZeroOrMore('|' + ParamList('part', PathSequence)))
PathElt
module-attribute
PathElt = Comp('PathElt', Param('part', PathPrimary) + Optional(Param('mod', PathMod.leave_whitespace())))
PathEltOrInverse
module-attribute
PathNegatedPropertySet
module-attribute
PathNegatedPropertySet = Comp('PathNegatedPropertySet', ParamList('part', PathOneInPropertySet) | '(' + Optional(ParamList('part', PathOneInPropertySet) + ZeroOrMore('|' + ParamList('part', PathOneInPropertySet))) + ')')
PathOneInPropertySet
module-attribute
PathPrimary
module-attribute
PathPrimary = iri | A | Suppress('!') + PathNegatedPropertySet | Suppress('(') + Path + Suppress(')') | Comp('DistinctPath', Keyword('DISTINCT') + '(' + Param('part', Path) + ')')
PathSequence
module-attribute
PathSequence = Comp('PathSequence', ParamList('part', PathEltOrInverse) + ZeroOrMore('/' + ParamList('part', PathEltOrInverse)))
PrefixDecl
module-attribute
PrimaryExpression
module-attribute
PrimaryExpression = BrackettedExpression | BuiltInCall | iriOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | Var
PropertyListNotEmpty
module-attribute
PropertyListNotEmpty = Verb + ObjectList + ZeroOrMore(';' + Optional(Verb + ObjectList))
PropertyListPathNotEmpty
module-attribute
PropertyListPathNotEmpty = (VerbPath | VerbSimple) + ObjectListPath + ZeroOrMore(';' + Optional((VerbPath | VerbSimple) + ObjectListPath))
Quads
module-attribute
Quads = Comp('Quads', Optional(TriplesTemplate) + ZeroOrMore(ParamList('quadsNotTriples', QuadsNotTriples) + Optional(Suppress('.')) + Optional(TriplesTemplate)))
QuadsNotTriples
module-attribute
QuadsNotTriples = Comp('QuadsNotTriples', Keyword('GRAPH') + Param('term', VarOrIri) + '{' + Optional(TriplesTemplate) + '}')
RDFLiteral
module-attribute
RDFLiteral = Comp('literal', Param('string', String) + Optional(Param('lang', LANGTAG.leave_whitespace()) | Literal('^^').leave_whitespace() + Param('datatype', iri).leave_whitespace()))
RegexExpression
module-attribute
RegexExpression = Comp('Builtin_REGEX', Keyword('REGEX') + '(' + Param('text', Expression) + ',' + Param('pattern', Expression) + Optional(',' + Param('flags', Expression)) + ')')
RelationalExpression
module-attribute
RelationalExpression = Comp('RelationalExpression', Param('expr', NumericExpression) + Optional(Param('op', '=') + Param('other', NumericExpression) | Param('op', '!=') + Param('other', NumericExpression) | Param('op', '<') + Param('other', NumericExpression) | Param('op', '>') + Param('other', NumericExpression) | Param('op', '<=') + Param('other', NumericExpression) | Param('op', '>=') + Param('other', NumericExpression) | Param('op', Keyword('IN')) + Param('other', ExpressionList) | Param('op', Combine(Keyword('NOT') + Keyword('IN'), adjacent=False, **(combine_join_kwargs(' ')))) + Param('other', ExpressionList))).setEvalFn(op.RelationalExpression)
STRING_LITERAL1
module-attribute
STRING_LITERAL2
module-attribute
STRING_LITERAL_LONG1
module-attribute
STRING_LITERAL_LONG2
module-attribute
SelectClause
module-attribute
SelectClause = Keyword('SELECT') + Optional(Param('modifier', Keyword('DISTINCT') | Keyword('REDUCED'))) + (OneOrMore(ParamList('projection', Comp('vars', Param('var', Var) | Literal('(') + Param('expr', Expression) + Keyword('AS') + Param('evar', Var) + ')'))) | '*')
SelectQuery
module-attribute
SelectQuery = Comp('SelectQuery', SelectClause + ZeroOrMore(ParamList('datasetClause', DatasetClause)) + WhereClause + SolutionModifier + ValuesClause)
ServiceGraphPattern
module-attribute
ServiceGraphPattern = Comp('ServiceGraphPattern', Keyword('SERVICE') + _Silent + Param('term', VarOrIri) + Param('graph', GroupGraphPattern))
SolutionModifier
module-attribute
SolutionModifier = Optional(Param('groupby', GroupClause)) + Optional(Param('having', HavingClause)) + Optional(Param('orderby', OrderClause)) + Optional(Param('limitoffset', LimitOffsetClauses))
StrReplaceExpression
module-attribute
StrReplaceExpression = Comp('Builtin_REPLACE', Keyword('REPLACE') + '(' + Param('arg', Expression) + ',' + Param('pattern', Expression) + ',' + Param('replacement', Expression) + Optional(',' + Param('flags', Expression)) + ')').setEvalFn(op.Builtin_REPLACE)
String
module-attribute
String = STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2 | STRING_LITERAL1 | STRING_LITERAL2
SubSelect
module-attribute
SubSelect = Comp('SubSelect', SelectClause + WhereClause + SolutionModifier + ValuesClause)
SubstringExpression
module-attribute
SubstringExpression = Comp('Builtin_SUBSTR', Keyword('SUBSTR') + '(' + Param('arg', Expression) + ',' + Param('start', Expression) + Optional(',' + Param('length', Expression)) + ')').setEvalFn(op.Builtin_SUBSTR)
TriplesSameSubject
module-attribute
TriplesSameSubject = VarOrTerm + PropertyListNotEmpty | TriplesNode + PropertyList
TriplesSameSubjectPath
module-attribute
TriplesSameSubjectPath = VarOrTerm + PropertyListPathNotEmpty | TriplesNodePath + PropertyListPath
TriplesTemplate
module-attribute
TriplesTemplate = ParamList('triples', TriplesSameSubject) + ZeroOrMore(Suppress('.') + Optional(ParamList('triples', TriplesSameSubject)))
UnaryExpression
module-attribute
UnaryExpression = Comp('UnaryNot', '!' + Param('expr', PrimaryExpression)).setEvalFn(op.UnaryNot) | Comp('UnaryPlus', '+' + Param('expr', PrimaryExpression)).setEvalFn(op.UnaryPlus) | Comp('UnaryMinus', '-' + Param('expr', PrimaryExpression)).setEvalFn(op.UnaryMinus) | PrimaryExpression
Update1
module-attribute
Update1 = Load | Clear | Drop | Add | Move | Copy | Create | InsertData | DeleteData | DeleteWhere | Modify
UsingClause
module-attribute
UsingClause = Comp('UsingClause', Keyword('USING') + (Param('default', iri) | Keyword('NAMED') + Param('named', iri)))
VARNAME
module-attribute
VARNAME = Regex('[%s0-9][%s0-9·̀-ͯ‿-⁀]*' % (PN_CHARS_U_re, PN_CHARS_U_re), flags=re.U)
ValuesClause
module-attribute
WhereClause
module-attribute
WhereClause = Optional(Keyword('WHERE')) + Param('where', GroupGraphPattern)
expandUnicodeEscapes_re
module-attribute
iriOrFunction
module-attribute
expandBNodeTriples
expand [ ?p ?o ] syntax for implicit bnodes
Source code in rdflib/plugins/sparql/parser.py
expandCollection
expand ( 1 2 3 ) notation for collections
Source code in rdflib/plugins/sparql/parser.py
expandTriples
Expand ; and , syntax for repeat predicates, subjects
Source code in rdflib/plugins/sparql/parser.py
expandUnicodeEscapes
The syntax of the SPARQL Query Language is expressed over code points in Unicode [UNICODE]. The encoding is always UTF-8 [RFC3629]. Unicode code points may also be expressed using an \ uXXXX (U+0 to U+FFFF) or \ UXXXXXXXX syntax (for U+10000 onwards) where X is a hexadecimal digit [0-9A-F]
Source code in rdflib/plugins/sparql/parser.py
neg
parseQuery
Source code in rdflib/plugins/sparql/parser.py
parseUpdate
parseUpdate(q: Union[str, bytes, TextIO, BinaryIO]) -> CompValue
Source code in rdflib/plugins/sparql/parser.py
setDataType
setDataType(terms: tuple[Any, str | None]) -> Literal