Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grammar railroad diagram #90

Open
mingodad opened this issue Jul 19, 2021 · 0 comments
Open

Grammar railroad diagram #90

mingodad opened this issue Jul 19, 2021 · 0 comments

Comments

@mingodad
Copy link

Using this tool https://www.bottlecaps.de/convert/ we can see a railroad diagram for the grammar in sparqlify-core/src/main/javacc/SparqlifyConfig.jj copy and paste the EBNF shown bellow on https://www.bottlecaps.de/rr/ui in the tab Edit Grammar then switching to the tab View Diagram.

/*
From https://raw.githubusercontent.com/SmartDataAnalytics/Sparqlify/master/sparqlify-core/src/main/javacc/SparqlifyConfig.jj
*/

/* converted on Mon Jul 19, 2021, 10:57 (UTC+02) by javacc-to-w3c v0.53 which is Copyright (c) 2011-2021 by Gunther Rademacher <grd@gmx.net> */

SparqlifyConfig
         ::= Stmt+
Stmt     ::= PrefixStmt
           | MacroStmt
           | ViewDefStmt
ViewDefStmt
         ::= 'create' 'view' NAME 'as' 'construct' ConstructTemplate VarBindingPart? 'from' RelationRef ';'?
VarBindingPart
         ::= 'with' VarBinding+
VarBinding
         ::= Var '=' Expression
RelationRef
         ::= NAME
           | SQL_STATEMENT
PrefixStmt
         ::= PrefixDecl
           | BaseDecl
MacroStmt
         ::= 'define' Expression
QueryUnit
         ::= Query EOF
Query    ::= Prologue ( SelectQuery | ConstructQuery | DescribeQuery | AskQuery ) BindingsClause
UpdateUnit
         ::= Prologue ( Update1 ';' Prologue )* Update1? EOF
Prologue ::= ( BaseDecl | PrefixDecl )*
BaseDecl ::= 'base' IRI_REF
PrefixDecl
         ::= 'prefix' PNAME_NS IRI_REF
SelectQuery
         ::= SelectClause DatasetClause* WhereClause SolutionModifier
SubSelect
         ::= SelectClause WhereClause SolutionModifier
SelectClause
         ::= 'select' ( 'distinct' | 'reduced' )? ( ( Var | '(' Expression 'as' Var ')' )+ | '*' )
ConstructQuery
         ::= 'construct' ( ConstructTemplate DatasetClause* WhereClause | DatasetClause* 'where' '{' TriplesTemplate? '}' ) 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
         ::= GroupClause? HavingClause? OrderClause? LimitOffsetClauses?
GroupClause
         ::= 'group' 'by' GroupCondition+
GroupCondition
         ::= BuiltInCall
           | FunctionCall
           | '(' Expression ( 'as' Var )? ')'
           | Var
HavingClause
         ::= 'having' HavingCondition+
HavingCondition
         ::= Constraint
OrderClause
         ::= 'order' 'by' OrderCondition+
OrderCondition
         ::= ( 'asc' | 'desc' ) BrackettedExpression
           | Constraint
           | Var
LimitOffsetClauses
         ::= LimitClause OffsetClause?
           | OffsetClause LimitClause?
LimitClause
         ::= 'limit' INTEGER
OffsetClause
         ::= 'offset' INTEGER
BindingsClause
         ::= ( 'bindings' Var* '{' ( '(' BindingValue* ')' | NIL )* '}' )?
BindingValue
         ::= IRIref
           | RDFLiteral
           | NumericLiteral
           | BooleanLiteral
           | 'undef'
Update1  ::= Load
           | Clear
           | Drop
           | Add
           | Move
           | Copy
           | Create
           | InsertData
           | DeleteData
           | DeleteWhere
           | Modify
Load     ::= 'load' 'silent'? IRIref ( 'into' GraphRef )?
Clear    ::= 'clear' 'silent'? GraphRefAll
Drop     ::= 'drop' 'silent'? GraphRefAll
Create   ::= 'create' 'silent'? GraphRef
Add      ::= 'add' 'silent'? GraphOrDefault 'to' GraphOrDefault
Move     ::= 'move' 'silent'? GraphOrDefault 'to' GraphOrDefault
Copy     ::= 'copy' 'silent'? GraphOrDefault 'to' GraphOrDefault
InsertData
         ::= INSERT_DATA QuadData
DeleteData
         ::= DELETE_DATA QuadData
DeleteWhere
         ::= DELETE_WHERE QuadPattern
Modify   ::= ( 'with' IRIref )? ( DeleteClause InsertClause? | InsertClause ) UsingClause* 'where' GroupGraphPattern
DeleteClause
         ::= 'delete' QuadPattern
InsertClause
         ::= 'insert' QuadPattern
UsingClause
         ::= 'using' 'named'? IRIref
GraphOrDefault
         ::= 'default'
           | 'graph'? IRIref
GraphRef ::= 'graph' IRIref
GraphRefAll
         ::= GraphRef
           | 'default'
           | 'named'
           | 'all'
QuadPattern
         ::= '{' Quads '}'
QuadData ::= '{' Quads '}'
Quads    ::= TriplesTemplate? ( QuadsNotTriples '.'? TriplesTemplate? )*
QuadsNotTriples
         ::= 'graph' VarOrIRIref '{' TriplesTemplate? '}'
TriplesTemplate
         ::= TriplesSameSubject ( '.' TriplesSameSubject )* '.'?
GroupGraphPattern
         ::= '{' ( SubSelect | GroupGraphPatternSub ) '}'
GroupGraphPatternSub
         ::= TriplesBlock? ( GraphPatternNotTriples '.'? TriplesBlock? )*
TriplesBlock
         ::= TriplesSameSubjectPath ( '.' TriplesSameSubjectPath )* '.'?
GraphPatternNotTriples
         ::= GroupOrUnionGraphPattern
           | OptionalGraphPattern
           | MinusGraphPattern
           | GraphGraphPattern
           | ServiceGraphPattern
           | Filter
           | Bind
OptionalGraphPattern
         ::= 'optional' GroupGraphPattern
GraphGraphPattern
         ::= 'graph' VarOrIRIref GroupGraphPattern
ServiceGraphPattern
         ::= 'service' 'silent'? VarOrIRIref GroupGraphPattern
Bind     ::= 'bind' '(' Expression 'as' Var ')'
MinusGraphPattern
         ::= 'minus' GroupGraphPattern
GroupOrUnionGraphPattern
         ::= GroupGraphPattern ( 'union' GroupGraphPattern )*
Filter   ::= 'filter' Constraint
Constraint
         ::= BrackettedExpression
           | BuiltInCall
           | FunctionCall
FunctionCall
         ::= IRIref ArgList
ArgList  ::= NIL
           | '(' 'distinct'? Expression ( ',' Expression )* ')'
ExpressionList
         ::= NIL
           | '(' Expression ( ',' Expression )* ')'
ConstructTemplate
         ::= '{' ( TriplesSameSubject ( '.' TriplesSameSubject )* '.'? )? '}'
TriplesSameSubject
         ::= VarOrTerm PropertyListNotEmpty
           | TriplesNode PropertyList
PropertyListNotEmpty
         ::= Verb ObjectList ( ';' ( Verb ObjectList )? )*
PropertyList
         ::= PropertyListNotEmpty?
ObjectList
         ::= Object ( ',' Object )*
Object   ::= GraphNode
Verb     ::= VarOrIRIref
           | 'a'
TriplesSameSubjectPath
         ::= VarOrTerm PropertyListNotEmptyPath
           | TriplesNode PropertyListPath
PropertyListNotEmptyPath
         ::= ( VerbPath | VerbSimple ) ObjectList ( ';' ( ( VerbPath | VerbSimple ) ObjectList )? )*
PropertyListPath
         ::= PropertyListNotEmpty?
VerbPath ::= Path
VerbSimple
         ::= Var
Path     ::= PathAlternative
PathAlternative
         ::= PathSequence ( '|' PathSequence )*
PathSequence
         ::= PathEltOrInverse ( '/' PathEltOrInverse )*
PathElt  ::= PathPrimary PathMod?
PathEltOrInverse
         ::= '^'? PathElt
PathMod  ::= '*'
           | '?'
           | '+'
           | '{' ( Integer ( ',' Integer? )? | ',' Integer ) '}'
PathPrimary
         ::= IRIref
           | 'a'
           | '!' PathNegatedPropertySet
           | '(' Path ')'
PathNegatedPropertySet
         ::= PathOneInPropertySet
           | '(' ( PathOneInPropertySet ( '|' PathOneInPropertySet )* )? ')'
PathOneInPropertySet
         ::= '^'? ( IRIref | 'a' )
Integer  ::= INTEGER
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 | 'not'? 'in' ExpressionList )?
NumericExpression
         ::= AdditiveExpression
AdditiveExpression
         ::= MultiplicativeExpression ( ( '+' | '-' ) MultiplicativeExpression | ( NumericLiteralPositive | NumericLiteralNegative ) ( ( '*' | '/' ) UnaryExpression )? )*
MultiplicativeExpression
         ::= UnaryExpression ( ( '*' | '/' ) UnaryExpression )*
UnaryExpression
         ::= ( '!' | '+' | '-' )? PrimaryExpression
PrimaryExpression
         ::= BrackettedExpression
           | BuiltInCall
           | IRIrefOrFunction
           | RDFLiteral
           | NumericLiteral
           | BooleanLiteral
           | Var
           | Aggregate
BrackettedExpression
         ::= '(' Expression ')'
BuiltInCall
         ::= ( ( ( 'str' | 'lang' | 'datatype' | 'iri' | 'uri' | 'ABS' | 'CEIL' | 'FLOOR' | 'ROUND' | 'STRLEN' | 'UCASE' | 'LCASE' | 'ENCODE_FOR_URI' | 'YEAR' | 'MONTH' | 'DAY' | 'HOURS' | 'MINUTES' | 'SECONDS' | 'TIMEZONE' | 'TZ' | 'MD5' | 'SHA1' | 'SHA224' | 'SHA256' | 'SHA384' | 'SHA512' | 'isIRI' | 'isURI' | 'isBlank' | 'isLiteral' | 'isNumeric' ) '(' | ( ( 'langmatches' | 'CONTAINS' | 'strSTARTS' | 'strENDS' | 'strlang' | 'strdt' | 'sameTerm' ) '(' | 'if' '(' Expression ',' ) Expression ',' ) Expression | 'bound' '(' Var ) ')'
           | 'bnode' ( '(' Expression ')' | NIL )
           | ( 'RAND' | 'NOW' ) NIL
           | ( 'CONCAT' | 'coalesce' ) ExpressionList
           | SubstringExpression
           | RegexExpression
           | ExistsFunc
           | NotExistsFunc
RegexExpression
         ::= 'regex' '(' Expression ',' Expression ( ',' Expression )? ')'
SubstringExpression
         ::= 'SUBSTR' '(' Expression ',' Expression ( ',' Expression )? ')'
ExistsFunc
         ::= 'exists' GroupGraphPattern
NotExistsFunc
         ::= 'not' 'exists' GroupGraphPattern
Aggregate
         ::= ( 'count' '(' 'distinct'? ( '*' | Expression ) | ( 'sum' | 'min' | 'max' | 'avg' | 'sample' ) '(' 'distinct'? Expression | 'group_concat' '(' 'distinct'? Expression ( ';' 'separator' '=' String )? ) ')'
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  ::= IRIref

<?TOKENS?>

SINGLE_LINE_COMMENT
         ::= '#' [^#xA#xD]* #xD? #xA?
SINGLE_LINE_COMMENT_SLASH
         ::= '//' [^#xA#xD]* #xD? #xA?
WS       ::= [ #x9#xA#xD#xC]
WSC      ::= WS
           | SINGLE_LINE_COMMENT
IRIref   ::= '<' [^><"{}^\|`#x0-#x20]* '>'
PNAME_NS ::= PN_PREFIX? ':'
PNAME_LN ::= PNAME_NS PN_LOCAL
BLANK_NODE_LABEL
         ::= '_:' PN_LOCAL
VAR1     ::= '?' VARNAME
VAR2     ::= '$' VARNAME
LANGTAG  ::= '@' A2Z+ ( '-' A2ZN+ )*
A2Z      ::= [a-zA-Z]
A2ZN     ::= [a-zA-Z0-9]
SQL_STATEMENT
         ::= '[' '[' .* ']' ']'
INSERT_DATA
         ::= 'insert' WSC* 'data'
DELETE_DATA
         ::= 'delete' WSC* 'data'
DELETE_WHERE
         ::= 'delete' WSC* 'where'
NAME     ::= PN_CHARS_U NAMESUFFIX
DIGITS   ::= [0-9]+
INTEGER  ::= DIGITS
DECIMAL  ::= DIGITS? '.' DIGITS
DOUBLE   ::= ( [0-9]+ ( '.' [0-9]* )? | '.' [0-9]+ ) EXPONENT
INTEGER_POSITIVE
         ::= '+' INTEGER
DECIMAL_POSITIVE
         ::= '+' DECIMAL
DOUBLE_POSITIVE
         ::= '+' DOUBLE
INTEGER_NEGATIVE
         ::= '-' INTEGER
DECIMAL_NEGATIVE
         ::= '-' DECIMAL
DOUBLE_NEGATIVE
         ::= '-' DOUBLE
EXPONENT ::= [eE] [+#x2D]? [0-9]+
ECHAR    ::= '\' ( 't' | 'b' | 'n' | 'r' | 'f' | '\' | '"' | "'" )
STRING_LITERAL1
         ::= "'" ( [^'\#xA#xD] | ECHAR )* "'"
STRING_LITERAL2
         ::= '"' ( [^"\#xA#xD] | ECHAR )* '"'
STRING_LITERAL_LONG1
         ::= "'''" ( ( "'" | "''" )? ( [^'\] | ECHAR ) )* "'''"
STRING_LITERAL_LONG2
         ::= '"""' ( ( '"' | '""' )? ( [^"\] | ECHAR ) )* '"""'
NIL      ::= '(' WSC* ')'
ANON     ::= '[' WSC* ']'
PN_CHARS_BASE
         ::= [A-Za-z#xC0-#xD6#xD8-#xF6#xF8-#x2FF#x370-#x37D#x37F-#x1FFF#x200C-#x200D#x2070-#x218F#x2C00-#x2FEF#x3001-#xD7FF#xF900-#xFFFD]
PN_CHARS_U
         ::= PN_CHARS_BASE
           | '_'
PN_CHARS ::= PN_CHARS_U
           | [-0-9#xB7#x300-#x36F#x203F-#x2040]
PN_PREFIX
         ::= PN_CHARS_BASE ( ( PN_CHARS | '.' )* PN_CHARS )?
PN_LOCAL ::= ( PN_CHARS_U | [0-9] ) ( ( PN_CHARS | '.' )* PN_CHARS )?
VARNAME  ::= ( PN_CHARS_U | [0-9] ) NAMESUFFIX
NAMESUFFIX
         ::= ( PN_CHARS_U | [0-9#xB7#x300-#x36F#x203F-#x2040] )*
UNKNOWN  ::= [^ #x9#xA#xD#xC]+
EOF      ::= $

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant