io.konig.formula.formula-grammar.txt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of konig-core Show documentation
Show all versions of konig-core Show documentation
A library for core classes (Graph, Vertex, Edge, etc.)
Formula ::= Prologue Expression
Prologue ::= ( PrefixDecl | TermDecl )*
PrefixDecl ::= '@prefix' PNAME_NS ':' IRIREF '.'
TermDecl ::= '@term' TermKey IRI
Term ::= JsonString ':' TermValue
JsonString ::= '"' JsonChar* '"'
JsonChar ::= UnescapedJsonChar | EscapedJsonChar
UnescapedJsonChar ::= [#x20-#x21] | [#x23-#x5b] | [#x5D=#x10FFF]
EscapedJsonChar ::= '\' ( ["\\bfnrt] | 'u' HEX HEX HEX HEX )
TermValue ::= JsonString | ExpandedTerm
ExpandedTerm ::= '{' (JsonldKeyword ':' JsonString)* '}'
JsonldKeyword ::= '@id' | '@type' | '@language'
Expression ::= ConditionalOrExpression
QuantifiedExpression ::= Expression WhereClause?
WhereClause := 'WHERE' (Triple)+
Triple ::= Path IRI PathTerm '.'
ConditionalOrExpression ::= ConditionalAndExpression ( OrOperator ConditionalAndExpression )*
OrOperator ::= '||' | 'OR'
ConditionalAndExpression ::= ValueLogical ( AndOperator ValueLogical )*
AndOperator ::= '&&' | 'AND'
ValueLogical ::= RelationalExpression
RelationalExpression ::=
NumericExpression (
'=' NumericExpression
| '!=' NumericExpression
| '<' NumericExpression
| '>' NumericExpression
| '<=' NumericExpression
| '>=' NumericExpression
| 'IN' ExpressionList
| 'NOT' 'IN' ExpressionList
)?
ExpressionList ::= '(' Expression ( ',' Expression )* ')'
NumericExpression ::= AdditiveExpression
AdditiveExpression ::=
MultiplicativeExpression (
'+' MultiplicativeExpression
| '-' MultiplicativeExpression
)*
MultiplicativeExpression ::= UnaryExpression ( '*' UnaryExpression | '/' UnaryExpression )*
UnaryExpression ::=
'!' PrimaryExpression
| '+' PrimaryExpression
| '-' PrimaryExpression
| PrimaryExpression
PrimaryExpression ::= BrackettedExpression | BuiltInCall | Path | Literal | IRI | CURIE
BrackettedExpression ::= '(' Expression ')'
Path ::= '$'? (InStep | PathTerm) ( OutStep | InStep | HasStep)*
PathTerm ::= IRI | CURIE | LocalName | Variable
HasStep ::= '[' PredicateObjectList ']'
PredicateObjectList ::= Verb ObjectList ( ';' (Verb ObjectList)?)*
Verb ::= IRI | CURIE | LocalName
ObjectList ::= Object (',' Object)*
Object ::= Expression
Variable ::= '?' [a-zA-Z][a-zA-Z0-9]*
OutStep ::= '.' PathTerm
InStep ::= '^' PathTerm
DISTINCT ::= 'DISTINCT'
BuiltInCall ::=
'IF' '(' Expression ',' Expression ',' Expression ')'
| 'COUNT' '(' DISTINCT? Expression ')'
| 'SUM' '(' DISTINCT? Expression ')'
| 'AVG' '(' DISTINCT? Expression ')'
| 'DAY' '(' Expression ')'
| 'MONTH' '(' Expression ')'
| 'YEAR' '(' Expression ')'
| 'CONCAT' '(' Expression (',' Expression)* ')'
| 'STRPOS' '(' Expression ',' Expression ')'
| 'SUBSTR' '(' Expression ',' Expression ',' Expression ')'
| 'BOUND' '(' Variable | Path ')'
| 'UNIX_TIME' '(' Expression ')'
| 'CASE' ('WHEN' Expression 'THEN' Expression)+ ('ELSE' Expression) 'END'
Keyword ::=
'IF'
| 'COUNT'
| 'SUM'
| 'AVG'
| 'DAY'
| 'MONTH'
| 'YEAR'
| 'CONCAT'
| 'STRPOS'
| 'SUBSTR'
| 'BOUND'
| 'UNIX_TIME'
| 'CASE'
| 'WHEN'
| 'THEN'
| 'ELSE'
| 'END'
| 'DISTINCT'
| 'IN'
| 'NOT'
| 'AND'
| 'OR'
| 'WHERE'
| '@prefix'
| '@term'