Created
January 4, 2015 15:36
-
-
Save kinow/becda136c7ff829ae64a to your computer and use it in GitHub Desktop.
SPARQL W3C Grammar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Query ::= Prologue | |
( SelectQuery | ConstructQuery | DescribeQuery | AskQuery ) | |
Prologue ::= BaseDecl? PrefixDecl* | |
BaseDecl ::= 'BASE' IRI_REF | |
PrefixDecl ::= 'PREFIX' PNAME_NS IRI_REF | |
SelectQuery ::= 'SELECT' ( 'DISTINCT' | 'REDUCED' )? ( Var+ | '*' ) DatasetClause* WhereClause SolutionModifier | |
ConstructQuery ::= 'CONSTRUCT' ConstructTemplate DatasetClause* WhereClause SolutionModifier | |
DescribeQuery ::= 'DESCRIBE' ( VarOrIRIref+ | '*' ) DatasetClause* WhereClause? SolutionModifier | |
AskQuery ::= 'ASK' DatasetClause* WhereClause | |
DatasetClause ::= 'FROM' ( DefaultGraphClause | NamedGraphClause ) | |
DefaultGraphClause ::= SourceSelector | |
NamedGraphClause ::= 'NAMED' SourceSelector | |
SourceSelector ::= IRIref | |
WhereClause ::= 'WHERE'? GroupGraphPattern | |
SolutionModifier ::= OrderClause? LimitOffsetClauses? | |
LimitOffsetClauses ::= ( LimitClause OffsetClause? | OffsetClause LimitClause? ) | |
OrderClause ::= 'ORDER' 'BY' OrderCondition+ | |
OrderCondition ::= ( ( 'ASC' | 'DESC' ) BrackettedExpression ) | |
| ( Constraint | Var ) | |
LimitClause ::= 'LIMIT' INTEGER | |
OffsetClause ::= 'OFFSET' INTEGER | |
GroupGraphPattern ::= '{' TriplesBlock? ( ( GraphPatternNotTriples | Filter ) '.'? TriplesBlock? )* '}' | |
TriplesBlock ::= TriplesSameSubject ( '.' TriplesBlock? )? | |
GraphPatternNotTriples ::= OptionalGraphPattern | GroupOrUnionGraphPattern | GraphGraphPattern | |
OptionalGraphPattern ::= 'OPTIONAL' GroupGraphPattern | |
GraphGraphPattern ::= 'GRAPH' VarOrIRIref GroupGraphPattern | |
GroupOrUnionGraphPattern ::= GroupGraphPattern ( 'UNION' GroupGraphPattern )* | |
Filter ::= 'FILTER' Constraint | |
Constraint ::= BrackettedExpression | BuiltInCall | FunctionCall | |
FunctionCall ::= IRIref ArgList | |
ArgList ::= ( NIL | '(' Expression ( ',' Expression )* ')' ) | |
ConstructTemplate ::= '{' ConstructTriples? '}' | |
ConstructTriples ::= TriplesSameSubject ( '.' ConstructTriples? )? | |
TriplesSameSubject ::= VarOrTerm PropertyListNotEmpty | TriplesNode PropertyList | |
PropertyListNotEmpty ::= Verb ObjectList ( ';' ( Verb ObjectList )? )* | |
PropertyList ::= PropertyListNotEmpty? | |
ObjectList ::= Object ( ',' Object )* | |
Object ::= GraphNode | |
Verb ::= VarOrIRIref | 'a' | |
TriplesNode ::= Collection | BlankNodePropertyList | |
BlankNodePropertyList ::= '[' PropertyListNotEmpty ']' | |
Collection ::= '(' GraphNode+ ')' | |
GraphNode ::= VarOrTerm | TriplesNode | |
VarOrTerm ::= Var | GraphTerm | |
VarOrIRIref ::= Var | IRIref | |
Var ::= VAR1 | VAR2 | |
GraphTerm ::= IRIref | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL | |
Expression ::= ConditionalOrExpression | |
ConditionalOrExpression ::= ConditionalAndExpression ( '||' ConditionalAndExpression )* | |
ConditionalAndExpression ::= ValueLogical ( '&&' ValueLogical )* | |
ValueLogical ::= RelationalExpression | |
RelationalExpression ::= NumericExpression ( '=' NumericExpression | '!=' NumericExpression | '<' NumericExpression | '>' NumericExpression | '<=' NumericExpression | '>=' NumericExpression )? | |
NumericExpression ::= AdditiveExpression | |
AdditiveExpression ::= MultiplicativeExpression ( '+' MultiplicativeExpression | '-' MultiplicativeExpression | NumericLiteralPositive | NumericLiteralNegative )* | |
MultiplicativeExpression ::= UnaryExpression ( '*' UnaryExpression | '/' UnaryExpression )* | |
UnaryExpression ::= '!' PrimaryExpression | |
| '+' PrimaryExpression | |
| '-' PrimaryExpression | |
| PrimaryExpression | |
PrimaryExpression ::= BrackettedExpression | BuiltInCall | IRIrefOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | Var | |
BrackettedExpression ::= '(' Expression ')' | |
BuiltInCall ::= 'STR' '(' Expression ')' | |
| 'LANG' '(' Expression ')' | |
| 'LANGMATCHES' '(' Expression ',' Expression ')' | |
| 'DATATYPE' '(' Expression ')' | |
| 'BOUND' '(' Var ')' | |
| 'sameTerm' '(' Expression ',' Expression ')' | |
| 'isIRI' '(' Expression ')' | |
| 'isURI' '(' Expression ')' | |
| 'isBLANK' '(' Expression ')' | |
| 'isLITERAL' '(' Expression ')' | |
| RegexExpression | |
RegexExpression ::= 'REGEX' '(' Expression ',' Expression ( ',' Expression )? ')' | |
IRIrefOrFunction ::= IRIref ArgList? | |
RDFLiteral ::= String ( LANGTAG | ( '^^' IRIref ) )? | |
NumericLiteral ::= NumericLiteralUnsigned | NumericLiteralPositive | NumericLiteralNegative | |
NumericLiteralUnsigned ::= INTEGER | DECIMAL | DOUBLE | |
NumericLiteralPositive ::= INTEGER_POSITIVE | DECIMAL_POSITIVE | DOUBLE_POSITIVE | |
NumericLiteralNegative ::= INTEGER_NEGATIVE | DECIMAL_NEGATIVE | DOUBLE_NEGATIVE | |
BooleanLiteral ::= 'true' | 'false' | |
String ::= STRING_LITERAL1 | STRING_LITERAL2 | STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2 | |
IRIref ::= IRI_REF | PrefixedName | |
PrefixedName ::= PNAME_LN | PNAME_NS | |
BlankNode ::= BLANK_NODE_LABEL | ANON | |
IRI_REF ::= '<' ([^<>"{}|^`\]-[#x00-#x20])* '>' | |
PNAME_NS ::= PN_PREFIX? ':' | |
PNAME_LN ::= PNAME_NS PN_LOCAL | |
BLANK_NODE_LABEL ::= '_:' PN_LOCAL | |
VAR1 ::= '?' VARNAME | |
VAR2 ::= '$' VARNAME | |
LANGTAG ::= '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)* | |
INTEGER ::= [0-9]+ | |
DECIMAL ::= [0-9]+ '.' [0-9]* | '.' [0-9]+ | |
DOUBLE ::= [0-9]+ '.' [0-9]* EXPONENT | '.' ([0-9])+ EXPONENT | ([0-9])+ EXPONENT | |
INTEGER_POSITIVE ::= '+' INTEGER | |
DECIMAL_POSITIVE ::= '+' DECIMAL | |
DOUBLE_POSITIVE ::= '+' DOUBLE | |
INTEGER_NEGATIVE ::= '-' INTEGER | |
DECIMAL_NEGATIVE ::= '-' DECIMAL | |
DOUBLE_NEGATIVE ::= '-' DOUBLE | |
EXPONENT ::= [eE] [+-]? [0-9]+ | |
STRING_LITERAL1 ::= "'" ( ([^#x27#x5C#xA#xD]) | ECHAR )* "'" | |
STRING_LITERAL2 ::= '"' ( ([^#x22#x5C#xA#xD]) | ECHAR )* '"' | |
STRING_LITERAL_LONG1 ::= "'''" ( ( "'" | "''" )? ( [^'\] | ECHAR ) )* "'''" | |
STRING_LITERAL_LONG2 ::= '"""' ( ( '"' | '""' )? ( [^"\] | ECHAR ) )* '"""' | |
ECHAR ::= '\' [tbnrf\"'] | |
NIL ::= '(' WS* ')' | |
WS ::= #x20 | #x9 | #xD | #xA | |
ANON ::= '[' WS* ']' | |
PN_CHARS_BASE ::= [A-Z] | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] | |
PN_CHARS_U ::= PN_CHARS_BASE | '_' | |
VARNAME ::= ( PN_CHARS_U | [0-9] ) ( PN_CHARS_U | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] )* | |
PN_CHARS ::= PN_CHARS_U | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] | |
PN_PREFIX ::= PN_CHARS_BASE ((PN_CHARS|'.')* PN_CHARS)? | |
PN_LOCAL ::= ( PN_CHARS_U | [0-9] ) ((PN_CHARS|'.')* PN_CHARS)? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment