PSPARQL Grammar

The grammar of PSPARQL, which is an extension to SPARQL grammar, is given in EBNF specification in the following table.

[1]   Query   ::=   Prolog
( SelectQuery | ConstructQuery | DescribeQuery | AskQuery )
[2]   Prolog   ::=   BaseDecl? PrefixDecl*
[3]   BaseDecl   ::=   'BASE' Q_IRI_REF
[4]   PrefixDecl   ::=   'PREFIX' QNAME_NS Q_IRI_REF
[5]   SelectQuery   ::=   'SELECT' 'DISTINCT'? ( Var+ | '*' ) DatasetClause* WhereClause SolutionModifier
[6]   ConstructQuery   ::=   'CONSTRUCT' ConstructTemplate DatasetClause* WhereClause SolutionModifier
[7]   DescribeQuery   ::=   'DESCRIBE' ( VarOrIRIref+ | '*' ) DatasetClause* WhereClause? SolutionModifier
[8]   AskQuery   ::=   'ASK' DatasetClause* WhereClause
[9]   DatasetClause   ::=   'FROM' ( DefaultGraphClause | NamedGraphClause )
[10]   DefaultGraphClause   ::=   SourceSelector
[11]   NamedGraphClause   ::=   'NAMED' SourceSelector
[12]   SourceSelector   ::=   IRIref
[13]   WhereClause   ::=   'WHERE'? GroupGraphPattern
[14]   SolutionModifier   ::=   OrderClause? LimitClause? OffsetClause?
[15]   OrderClause   ::=   'ORDER' 'BY' OrderCondition+
[16]   OrderCondition   ::=   ( ( 'ASC' | 'DESC' ) BrackettedExpression )
| ( FunctionCall | Var | BrackettedExpression )
[17]   LimitClause   ::=   'LIMIT' INTEGER
[18]   OffsetClause   ::=   'OFFSET' INTEGER
[19]   GroupGraphPattern   ::=   '{' GraphPattern '}'
[20]   GraphPattern   ::=   FilteredBasicGraphPattern ( GraphPatternNotTriples '.'? GraphPattern )?
[21]   FilteredBasicGraphPattern   ::=   BlockOfTriples? ( Constraint '.'? FilteredBasicGraphPattern )?
[22]   BlockOfTriples   ::=   PathTriplesSameSubject ( '.' PathTriplesSameSubject? )*
[23]   GraphPatternNotTriples   ::=   OptionalGraphPattern | GroupOrUnionGraphPattern | GraphGraphPattern
[24]   OptionalGraphPattern   ::=   'OPTIONAL' GroupGraphPattern
[25]   GraphGraphPattern   ::=   'GRAPH' VarOrBlankNodeOrIRIref GroupGraphPattern
[26]   GroupOrUnionGraphPattern   ::=   GroupGraphPattern ( 'UNION' GroupGraphPattern )*
[27]   Constraint   ::=   'FILTER' ( BrackettedExpression | BuiltInCall | FunctionCall )
[28]   FunctionCall   ::=   IRIref ArgList
[29]   ArgList   ::=   ( NIL | '(' Expression ( ',' Expression )* ')' )
[30]   ConstructTemplate   ::=   '{' ConstructTriples '}'
[31]   ConstructTriples   ::=   ( TriplesSameSubject ( '.' ConstructTriples )? )?
[32]   TriplesSameSubject   ::=   VarOrTerm PropertyListNotEmpty | TriplesNode PropertyList
[32.1]   PathTriplesSameSubject   ::=   VarOrTerm PathPropertyListNotEmpty | PathTriplesNode PathPropertyList
[33]   PropertyList   ::=   PropertyListNotEmpty?
[33.1]   PathPropertyList   ::=   PathPropertyListNotEmpty?
[34]   PropertyListNotEmpty   ::=   Verb ObjectList ( ';' PropertyList )?
[34.1]   PathPropertyListNotEmpty   ::=   PathVerb PathObjectList ( ';' PathPropertyList )?
[35]   ObjectList   ::=   GraphNode ( ',' ObjectList )?
[35.1]   PathObjectList   ::=   PathGraphNode ( ',' PathObjectList )?
[36]   Verb   ::=   VarOrIRIref | 'a'
[36.1]   PathVerb   ::=   RegularExpression
[37]   TriplesNode   ::=   Collection | BlankNodePropertyList
[37.1]   PathTriplesNode   ::=   PathCollection | PathBlankNodePropertyList
[38]   BlankNodePropertyList   ::=   '[' PropertyListNotEmpty ']'
[38.1]   PathBlankNodePropertyList   ::=   '[' PathPropertyListNotEmpty ']'
[39]   Collection   ::=   '(' GraphNode+ ')'
[39.1]   PathCollection   ::=   '(' PathGraphNode+ ')'
[40]   GraphNode   ::=   VarOrTerm | TriplesNode
[40.1]   PathGraphNode   ::=   VarOrTerm | PathTriplesNode
[41]   VarOrTerm   ::=   Var | GraphTerm
[42]   VarOrIRIref   ::=   Var | IRIref
[41.1]   RegularExpression   ::=   Rexp (( '|' | '.' ) Rexp )*
[41.2]   Rexp   ::=   ( '+' | '*' )? Atom
[41.3]   Atom   ::=   '!'IRIref | '#' | VarOrIRIref | 'a' | '(' RegularExpression ')'
[43]   VarOrBlankNodeOrIRIref   ::=   Var | BlankNode | IRIref
[44]   Var   ::=   VAR1 | VAR2
[45]   GraphTerm   ::=   IRIref | RDFLiteral | ( '-' | '+' )? NumericLiteral | BooleanLiteral | BlankNode | NIL
[46]   Expression   ::=   ConditionalOrExpression
[47]   ConditionalOrExpression   ::=   ConditionalAndExpression ( '||' ConditionalAndExpression )*
[48]   ConditionalAndExpression   ::=   ValueLogical ( '&&' ValueLogical )*
[49]   ValueLogical   ::=   RelationalExpression
[50]   RelationalExpression   ::=   NumericExpression ( '=' NumericExpression | '!=' NumericExpression | '<' NumericExpression | '>' NumericExpression | '<=' NumericExpression | '>=' NumericExpression )?
[51]   NumericExpression   ::=   AdditiveExpression
[52]   AdditiveExpression   ::=   MultiplicativeExpression ( '+' MultiplicativeExpression | '-' MultiplicativeExpression )*
[53]   MultiplicativeExpression   ::=   UnaryExpression ( '*' UnaryExpression | '/' UnaryExpression )*
[54]   UnaryExpression   ::=     '!' PrimaryExpression
| '+' PrimaryExpression
| '-' PrimaryExpression
| PrimaryExpression
[55]   PrimaryExpression   ::=   BrackettedExpression | BuiltInCall | IRIrefOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | Var
[56]   BrackettedExpression   ::=   '(' Expression ')'
[57]   BuiltInCall   ::=     'STR' '(' Expression ')'
| 'LANG' '(' Expression ')'
| 'LANGMATCHES' '(' Expression ',' Expression ')'
| 'DATATYPE' '(' Expression ')'
| 'BOUND' '(' Var ')'
| 'isIRI' '(' Expression ')'
| 'isURI' '(' Expression ')'
| 'isBLANK' '(' Expression ')'
| 'isLITERAL' '(' Expression ')'
| RegexExpression
[58]   RegexExpression   ::=   'REGEX' '(' Expression ',' Expression ( ',' Expression )? ')'
[59]   IRIrefOrFunction   ::=   IRIref ArgList?
[60]   RDFLiteral   ::=   String ( LANGTAG | ( '^^' IRIref ) )?
[61]   NumericLiteral   ::=   INTEGER | DECIMAL | DOUBLE
[62]   BooleanLiteral   ::=   'true' | 'false'
[63]   String   ::=   STRING_LITERAL1 | STRING_LITERAL2 | STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2
[64]   IRIref   ::=   Q_IRI_REF | QName
[65]   QName   ::=   QNAME | QNAME_NS
[66]   BlankNode   ::=   BLANK_NODE_LABEL | ANON
[67]   Q_IRI_REF   ::=   '<' ([^<>'{}|^`]-[#x00-#x20])* '>'
[68]   QNAME_NS   ::=   NCNAME_PREFIX? ':'
[69]   QNAME   ::=   NCNAME_PREFIX? ':' NCNAME?
[70]   BLANK_NODE_LABEL   ::=   '_:' NCNAME
[71]   VAR1   ::=   '?' VARNAME
[72]   VAR2   ::=   '$' VARNAME
[73]   LANGTAG   ::=   '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)*
[74]   INTEGER   ::=   [0-9]+
[75]   DECIMAL   ::=   [0-9]+ '.' [0-9]* | '.' [0-9]+
[76]   DOUBLE   ::=   [0-9]+ '.' [0-9]* EXPONENT | '.' ([0-9])+ EXPONENT | ([0-9])+ EXPONENT
[77]   EXPONENT   ::=   [eE] [+-]? [0-9]+
[78]   STRING_LITERAL1   ::=   "'" ( ([^#x27#x5C#xA#xD]) | ECHAR | UCHAR )* "'"
[79]   STRING_LITERAL2   ::=   '"' ( ([^#x22#x5C#xA#xD]) | ECHAR | UCHAR )* '"'
[80]   STRING_LITERAL_LONG1   ::=   "'''" ( ( "'" | "''" )? ( [^'\] | ECHAR | UCHAR ) )* "'''"
[81]   STRING_LITERAL_LONG2   ::=   '"""' ( ( '"' | '""' )? ( [^"\] | ECHAR | UCHAR ) )* '"""'
[82]   ECHAR   ::=   '\' [tbnrf\"']
[83]   UCHAR   ::=   '\' ( 'u' HEX HEX HEX HEX | 'U' HEX HEX HEX HEX HEX HEX HEX HEX )
[84]   HEX   ::=   [0-9] | [A-F] | [a-f]
[85]   NIL   ::=   '(' WS* ')'
[86]   WS   ::=   #x20 | #x9 | #xD | #xA
[87]   ANON   ::=   '[' WS* ']'
[88]   NCCHAR1p   ::=     [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]
| UCHAR
[89]   NCCHAR1   ::=   NCCHAR1p | '_'
[90]   VARNAME   ::=   ( NCCHAR1 | [0-9] ) ( NCCHAR1 | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] )*
[91]   NCCHAR   ::=   NCCHAR1 | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
[92]   NCNAME_PREFIX   ::=   NCCHAR1p ((NCCHAR|'.')* NCCHAR)?
[93]   NCNAME   ::=   NCCHAR1 ((NCCHAR|'.')* NCCHAR)?

EXMO : research | people | papers | teaching | training | cooperation | software | applications | transfer | © | ? | *

http://exmo.inrialpes.fr/software/psparql/psparqlgrammar.html © INRIA, 2006, 2008

Feel free to comment to Faisal Alkhateeb $Id: psparqlgrammar.html,v 1.2 2008/12/10 20:43:26 euzenat Exp $