[1] shexDoc ::= directive* ( ( notStartAction | startActions) statement* ) ?
[2] directive ::= baseDecl | prefixDecl | importDecl
[3] baseDecl ::= "BASE" IRIREF
[4] prefixDecl ::= "PREFIX" PNAME_NS IRIREF
[4.5] importDecl ::= "IMPORT" IRIREF
[5] notStartAction ::= start | shapeExprDecl
[6] start ::= "START" "=" inlineShapeExpression
[7] startActions ::= codeDecl+
[8] statement ::= directive | notStartAction
[9] shapeExprDecl ::= shapeExprLabel ( shapeExpression | "EXTERNAL")
[10] shapeExpression ::= shapeOr
[11] inlineShapeExpression ::= inlineShapeOr
[12] shapeOr ::= shapeAnd ( "OR" shapeAnd) *
[13] inlineShapeOr ::= inlineShapeAnd ( "OR" inlineShapeAnd) *
[14] shapeAnd ::= shapeNot ( "AND" shapeNot) *
[15] inlineShapeAnd ::= inlineShapeNot ( "AND" inlineShapeNot) *
[16] shapeNot ::= "NOT"? shapeAtom
[17] inlineShapeNot ::= "NOT"? inlineShapeAtom
[18] shapeAtom ::= ( nonLitNodeConstraint shapeOrRef? ) | litNodeConstraint | ( shapeOrRef nonLitNodeConstraint? ) | ( "(" shapeExpression ")") | "."
[19] shapeAtomNoRef ::= ( nonLitNodeConstraint shapeOrRef? ) | litNodeConstraint | ( shapeDefinition nonLitNodeConstraint? ) | ( "(" shapeExpression ")") | "."
[20] inlineShapeAtom ::= ( nonLitNodeConstraint inlineShapeOrRef? ) | litNodeConstraint | ( inlineShapeOrRef nonLitNodeConstraint? ) | ( "(" shapeExpression ")") | "."
[21] shapeOrRef ::= shapeDefinition | shapeRef
[22] inlineShapeOrRef ::= inlineShapeDefinition | shapeRef
[23] shapeRef ::= ATPNAME_LN | ATPNAME_NS | ( "@" shapeExprLabel)
[24] litNodeConstraint ::= ( "LITERAL" xsFacet* ) | ( datatype xsFacet* ) | ( valueSet xsFacet* ) | numericFacet+
[25] nonLitNodeConstraint ::= ( nonLiteralKind stringFacet* ) | stringFacet+
[26] nonLiteralKind ::= "IRI" | "BNODE" | "NONLITERAL"
[27] xsFacet ::= stringFacet | numericFacet
[28] stringFacet ::= ( stringLength INTEGER) | REGEXP
[29] stringLength ::= "LENGTH" | "MINLENGTH" | "MAXLENGTH"
[30] numericFacet ::= ( numericRange numericLiteral) | ( numericLength INTEGER)
[31] numericRange ::= "MININCLUSIVE" | "MINEXCLUSIVE" | "MAXINCLUSIVE" | "MAXEXCLUSIVE"
[32] numericLength ::= "TOTALDIGITS" | "FRACTIONDIGITS"
[33] shapeDefinition ::= ( extraPropertySet | "CLOSED") * "{" tripleExpression? "}" annotation* semanticActions
[34] inlineShapeDefinition ::= ( extraPropertySet | "CLOSED") * "{" tripleExpression? "}"
[35] extraPropertySet ::= "EXTRA" predicate+
[36] tripleExpression ::= oneOfTripleExpr
[37] oneOfTripleExpr ::= groupTripleExpr ( "|" groupTripleExpr) *
[40] groupTripleExpr ::= unaryTripleExpr ( ";" unaryTripleExpr? ) *
[43] unaryTripleExpr ::= ( ( "$" tripleExprLabel) ? ( tripleConstraint | bracketedTripleExpr) ) | include
[44] bracketedTripleExpr ::= "(" tripleExpression ")" cardinality? annotation* semanticActions
[45] tripleConstraint ::= senseFlags? predicate inlineShapeExpression cardinality? annotation* semanticActions
[46] cardinality ::= "*" | "+" | "?" | REPEAT_RANGE
[47] senseFlags ::= "^"
[48] valueSet ::= "[" valueSetValue* "]"
[49] valueSetValue ::= iriRange | literalRange | languageRange | ( "." exclusion+ )
[50] exclusion ::= "-" ( iri | literal | LANGTAG) "~"?
[51] iriRange ::= iri ( "~" iriExclusion* ) ?
[52] iriExclusion ::= "-" iri "~"?
[53] literalRange ::= literal ( "~" literalExclusion* ) ?
[54] literalExclusion ::= "-" literal "~"?
[55] languageRange ::= ( LANGTAG ( "~" languageExclusion* ) ? ) | ( "@" "~" languageExclusion* )
[56] languageExclusion ::= "-" LANGTAG "~"?
[57] include ::= "&" tripleExprLabel
[58] annotation ::= "//" predicate ( iri | literal)
[59] semanticActions ::= codeDecl*
[60] codeDecl ::= "%" iri ( CODE | "%")
[13t] literal ::= rdfLiteral | numericLiteral | booleanLiteral
[61] predicate ::= iri | RDF_TYPE
[62] datatype ::= iri
[63] shapeExprLabel ::= iri | blankNode
[64] tripleExprLabel ::= iri | blankNode
[16t] numericLiteral ::= DOUBLE | DECIMAL | INTEGER
[65] rdfLiteral ::= langString | ( string ( "^^" datatype) ? )
[134s] booleanLiteral ::= "true" | "false"
[135s] string ::= STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2 | STRING_LITERAL1 | STRING_LITERAL2
[66] langString ::= LANG_STRING_LITERAL1 | LANG_STRING_LITERAL_LONG1 | LANG_STRING_LITERAL2 | LANG_STRING_LITERAL_LONG2
[136s] iri ::= IRIREF | prefixedName
[137s] prefixedName ::= PNAME_LN | PNAME_NS
[138s] blankNode ::= BLANK_NODE_LABEL
@terminals # Productions for terminals
[67] CODE ::= "{" [ ^%\]#x20|#x20'\'[%\]#x20|#x20UCHAR)*#x20'%''}']
[68] REPEAT_RANGE ::= "{" INTEGER ( "," ( INTEGER | "*") ? ) ? "}"
[69] RDF_TYPE ::= "a"
[18t] IRIREF ::= "<" [ ^#x00-#x20<>"{}|^`\]#x20|#x20UCHAR)*#x20'>'#x20/*#x20#x00=NULL#x20#x2301-#x1F=control#x20codes#x20#x20=space#x20*/]
[140s] PNAME_NS ::= PN_PREFIX? ":"
[141s] PNAME_LN ::= PNAME_NS PN_LOCAL
[70] ATPNAME_NS ::= "@" PN_PREFIX? ":"
[71] ATPNAME_LN ::= "@" PNAME_NS PN_LOCAL
[72] REGEXP ::= "/" ( [ ^/\#x0A#x0D] | ( "\" [ nrt\|.?*+(){}$-[]^/] ) | UCHAR) + "/" [ smix] *
[142s] BLANK_NODE_LABEL ::= "_:" ( PN_CHARS_U | [ 0-9] ) ( ( PN_CHARS | ".") * PN_CHARS) ?
[145s] LANGTAG ::= "@" [ a-zA-Z] + ( "-" [ a-zA-Z0-9] + ) *
[19t] INTEGER ::= [ +-] ? [ 0-9] +
[20t] DECIMAL ::= [ +-] ? [ 0-9] * "." [ 0-9] +
[21t] DOUBLE ::= [ +-] ? ( ( [ 0-9] + "." [ 0-9] * EXPONENT) | ( "."? [ 0-9] + EXPONENT) )
[155s] EXPONENT ::= [ eE] [ +-] ? [ 0-9] +
[156s] STRING_LITERAL1 ::= "'" ( [ ^#x27#x5C#x0A#x0D] | ECHAR | UCHAR) * "'"
[157s] STRING_LITERAL2 ::= '"' ( [ ^>"#x5C#x0A#x0D] | ECHAR | UCHAR) * '"'
[158s] STRING_LITERAL_LONG1 ::= "'''" ( ( "'" | "''") ? [ ^'\]#x20|#x20ECHAR#x20|#x20UCHAR))*#x20"'''"] )
[159s] STRING_LITERAL_LONG2 ::= '"""' ( ( '"' | '""') ? [ ^"\]#x20|#x20ECHAR#x20|#x20UCHAR))*#x20'"""'] )
[73] LANG_STRING_LITERAL1 ::= "'" ( [ ^#x27#x5C#x0A#x0D] | ECHAR | UCHAR) * "'" LANGTAG
[74] LANG_STRING_LITERAL2 ::= '"' ( [ ^>"#x5C#x0A#x0D] | ECHAR | UCHAR) * '"' LANGTAG
[75] LANG_STRING_LITERAL_LONG1 ::= "'''" ( ( "'" | "''") ? [ ^'\]#x20|#x20ECHAR#x20|#x20UCHAR))*#x20"'''"#x20LANGTAG] )
[76] LANG_STRING_LITERAL_LONG2 ::= '"""' ( ( '"' | '""') ? [ ^"\]#x20|#x20ECHAR#x20|#x20UCHAR))*#x20'"""'#x20LANGTAG] )
[26t] UCHAR ::= ( "\u" HEX HEX HEX HEX) | ( "\U" HEX HEX HEX HEX HEX HEX HEX HEX)
[160s] ECHAR ::= "\" [ tbnrf\"']
[164s] PN_CHARS_BASE ::= [ A-Z]
| [ a-z]
| [ #xC0-#xD6]
| [ #xD8-#xF6]
| [ #xF8-#x02FF]
| [ #x0370-#x037D]
| [ #x037F-#x1FFF]
| [ #x200C-#x200D]
| [ #x2070-#x218F]
| [ #x2C00-#x2FEF]
| [ #x3001-#xD7FF]
| [ #xF900-#xFDCF]
| [ #xFDF0-#xFFFD]
| [ #x00010000-#x000EFFFF]
[165s] PN_CHARS_U ::= PN_CHARS_BASE | "_"
[167s] PN_CHARS ::= PN_CHARS_U | "-" | [ 0-9] | [ #xB7] | [ #x0300-#x036F] | [ #x203F-#x2040]
[168s] PN_PREFIX ::= PN_CHARS_BASE ( ( PN_CHARS | ".") * PN_CHARS) ?
[169s] PN_LOCAL ::= ( PN_CHARS_U | ":" | [ 0-9] | PLX) ( ( PN_CHARS | "." | ":" | PLX) * ( PN_CHARS | ":" | PLX) ) ?
[170s] PLX ::= PERCENT | PN_LOCAL_ESC
[171s] PERCENT ::= "%" HEX HEX
[172s] HEX ::= [ 0-9] | [ A-F] | [ a-f]
[173s] PN_LOCAL_ESC ::= "\" ( "_" | "~" | "." | "-" | "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "=" | "/" | "?" | "#" | "@" | "%")
@pass [ #x20#x09#x0D#x0A] + | ( "#" [ ^#x0D#x0A] * ) | ( "/*" ( [ ^*] | ( "*" ( [ ^/] | "\/") ) ) * "*/")