{-# LANGUAGE OverloadedStrings #-}

module Hydra.Impl.Haskell.Sources.Ext.Shex.Syntax where

import Hydra.Core
import Hydra.Compute
import Hydra.Module
import Hydra.Grammar
import Hydra.Impl.Haskell.Dsl.Grammars
import Hydra.Util.GrammarToModule
import qualified Hydra.Impl.Haskell.Dsl.Standard as Standard


base_ :: Pattern
base_ = [Char] -> Pattern
terminal [Char]
"BASE"
prefix_ :: Pattern
prefix_ = [Char] -> Pattern
terminal [Char]
"PREFIX"
start_ :: Pattern
start_ = [Char] -> Pattern
terminal [Char]
"start"
equal_ :: Pattern
equal_ = [Char] -> Pattern
terminal [Char]
"="
or_ :: Pattern
or_ = [Char] -> Pattern
terminal [Char]
"OR"
and_ :: Pattern
and_ = [Char] -> Pattern
terminal [Char]
"AND"
not_ :: Pattern
not_ = [Char] -> Pattern
terminal [Char]
"NOT"
true_ :: Pattern
true_ = [Char] -> Pattern
terminal [Char]
"true"
false_ :: Pattern
false_ = [Char] -> Pattern
terminal [Char]
"false"
iri_ :: Pattern
iri_ = [Char] -> Pattern
terminal [Char]
"IRI"
bnode_ :: Pattern
bnode_ = [Char] -> Pattern
terminal [Char]
"BNODE"
literal_ :: Pattern
literal_ = [Char] -> Pattern
terminal [Char]
"LITERAL"
nonLiteral_ :: Pattern
nonLiteral_ = [Char] -> Pattern
terminal [Char]
"NONLITERAL"
length_ :: Pattern
length_ = [Char] -> Pattern
terminal [Char]
"LENGTH"
minLength_ :: Pattern
minLength_ = [Char] -> Pattern
terminal [Char]
"MINLENGTH"
maxLength_ :: Pattern
maxLength_ = [Char] -> Pattern
terminal [Char]
"MAXLENGTH"
external_ :: Pattern
external_ = [Char] -> Pattern
terminal [Char]
"EXTERNAL"
percent_ :: Pattern
percent_ = [Char] -> Pattern
terminal [Char]
"%"
at_ :: Pattern
at_ = [Char] -> Pattern
terminal [Char]
"@"
dollar_ :: Pattern
dollar_ = [Char] -> Pattern
terminal [Char]
"$"
ampersand_ :: Pattern
ampersand_ = [Char] -> Pattern
terminal [Char]
"&"
colon_ :: Pattern
colon_ = [Char] -> Pattern
terminal [Char]
":"
period_ :: Pattern
period_ = [Char] -> Pattern
terminal [Char]
"."
coma_ :: Pattern
coma_ = [Char] -> Pattern
terminal [Char]
","
semicolon_ :: Pattern
semicolon_ = [Char] -> Pattern
terminal [Char]
";"
underscore_ :: Pattern
underscore_ = [Char] -> Pattern
terminal [Char]
"_"
dash_ :: Pattern
dash_ = [Char] -> Pattern
terminal [Char]
"-"
parenOpen_ :: Pattern
parenOpen_ = [Char] -> Pattern
terminal [Char]
"("
parenClose_ :: Pattern
parenClose_ = [Char] -> Pattern
terminal [Char]
")"
braceOpen_ :: Pattern
braceOpen_ = [Char] -> Pattern
terminal [Char]
"{"
braceClose_ :: Pattern
braceClose_ = [Char] -> Pattern
terminal [Char]
"}"
pipe_ :: Pattern
pipe_ = [Char] -> Pattern
terminal [Char]
"|"
star_ :: Pattern
star_ = [Char] -> Pattern
terminal [Char]
"*"
plus_ :: Pattern
plus_ = [Char] -> Pattern
terminal [Char]
"+"
question_ :: Pattern
question_ = [Char] -> Pattern
terminal [Char]
"?"
tilde_ :: Pattern
tilde_ = [Char] -> Pattern
terminal [Char]
"~"
doubleFrwSlash_ :: Pattern
doubleFrwSlash_ = [Char] -> Pattern
terminal [Char]
"\\"
singleQuote_ :: Pattern
singleQuote_ = [Char] -> Pattern
terminal [Char]
"'"
doubleQuote_ :: Pattern
doubleQuote_ = [Char] -> Pattern
terminal [Char]
"\""

minInclusive_ :: Pattern
minInclusive_ = [Char] -> Pattern
terminal [Char]
"MININCLUSIVE"
minExclusive_ :: Pattern
minExclusive_ = [Char] -> Pattern
terminal [Char]
"MINEXCLUSIVE"
maxInclusive_ :: Pattern
maxInclusive_ = [Char] -> Pattern
terminal [Char]
"MAXINCLUSIVE"
maxExclusive_ :: Pattern
maxExclusive_ = [Char] -> Pattern
terminal [Char]
"MAXEXCLUSIVE"
totalDigits_ :: Pattern
totalDigits_ = [Char] -> Pattern
terminal [Char]
"TOTALDIGITS"
fractionDigits_ :: Pattern
fractionDigits_ = [Char] -> Pattern
terminal [Char]
"FRACTIONDIGITS"
extra_ :: Pattern
extra_ = [Char] -> Pattern
terminal [Char]
"EXTRA"
closed_ :: Pattern
closed_ = [Char] -> Pattern
terminal [Char]
"CLOSED"


shexSyntaxModule :: Module Meta
shexSyntaxModule :: Module Meta
shexSyntaxModule = Namespace -> Grammar -> Maybe [Char] -> Module Meta
grammarToModule Namespace
ns Grammar
shexGrammar forall a b. (a -> b) -> a -> b
$
    forall a. a -> Maybe a
Just ([Char]
"A Shex model. Based on the BNF at:\n" forall a. [a] -> [a] -> [a]
++
        [Char]
"  https://github.com/shexSpec/grammar/blob/master/bnf")
    where
        ns :: Namespace
ns = [Char] -> Namespace
Namespace [Char]
"hydra/ext/shex/syntax"

shexGrammar :: Grammar
shexGrammar :: Grammar
shexGrammar = [Production] -> Grammar
Grammar [

-- [1] ShexDoc ::= Directive* ((NotStartAction | StartActions) Statement*)?
  [Char] -> [Pattern] -> Production
define [Char]
"ShexDoc" [
    [Pattern] -> Pattern
list[Pattern -> Pattern
starPattern
"Directive", Pattern -> Pattern
opt([Pattern] -> Pattern
list[ [Pattern] -> Pattern
alts[Pattern
"NotStartAction", Pattern
"StartActions"], Pattern -> Pattern
star Pattern
"Statement" ]), Pattern
"PrefixDecl"]],

-- [2] Directive ::= BaseDecl | PrefixDecl
  [Char] -> [Pattern] -> Production
define [Char]
"Directive" [
     Pattern
"BaseDecl", Pattern
"PrefixDecl"],

-- [3] BaseDecl ::= "BASE" IriRef
 [Char] -> [Pattern] -> Production
define [Char]
"BaseDecl" [
     [Pattern] -> Pattern
list[Pattern
base_, Pattern
"IriRef"]],

-- [4] PrefixDecl ::= "PREFIX" PnameNs IriRef
 [Char] -> [Pattern] -> Production
define [Char]
"PrefixDecl" [
     [Pattern] -> Pattern
list[Pattern
prefix_, Pattern
"PnameNs", Pattern
"IriRef"]],

-- [5] NotStartAction ::= start | shapeExprDecl
-- [6] start ::= "start" '=' ShapeExpression
-- [9] shapeExprDecl ::= ShapeExprLabel (ShapeExpression|"EXTERNAL")
  [Char] -> [Pattern] -> Production
define [Char]
"NotStartAction" [
    [Char]
"start"[Char] -> Pattern -> Pattern
>: [Pattern] -> Pattern
list[Pattern
start_, Pattern
equal_, Pattern
"ShapeExpression"],
    [Char]
"shapeExprDecl"[Char] -> Pattern -> Pattern
>: [Pattern] -> Pattern
list[Pattern
"ShapeExprLabel", [Pattern] -> Pattern
alts[Pattern
"ShapeExpression", Pattern
external_]]],

-- [7] StartActions ::= CodeDecl+
  [Char] -> [Pattern] -> Production
define [Char]
"StartActions" [
    Pattern -> Pattern
plus(Pattern
"CodeDecl")],

-- [8] Statement ::= Directive | NotStartAction
  [Char] -> [Pattern] -> Production
define [Char]
"Statement" [
    [Pattern] -> Pattern
alts[ Pattern
"Directive", Pattern
"NotStartAction"]],

-- [10] ShapeExpression ::= ShapeOr
  [Char] -> [Pattern] -> Production
define [Char]
"ShapeExpression" [
    Pattern
"ShapeOr"],

-- [11] InlineShapeExpression ::= InlineShapeOr
  [Char] -> [Pattern] -> Production
define [Char]
"InlineShapeExpression" [
    Pattern
"InlineShapeOr"],

-- [12] ShapeOr ::= ShapeAnd ("OR" ShapeAnd)*
  [Char] -> [Pattern] -> Production
define [Char]
"ShapeOr" [
    [Pattern] -> Pattern
list[Pattern
"ShapeAnd", Pattern -> Pattern
star([Pattern] -> Pattern
list[Pattern
or_, Pattern
"ShapeAnd"])]],

-- [13] InlineShapeOr ::= InlineShapeAnd ("OR" InlineShapeAnd)*
  [Char] -> [Pattern] -> Production
define [Char]
"InlineShapeOr" [
    [Pattern] -> Pattern
list[Pattern
"ShapeAnd", Pattern -> Pattern
star([Pattern] -> Pattern
list[Pattern
or_, Pattern
"InlineShapeAnd"])]],

-- [14] ShapeAnd ::= ShapeNot ("AND" ShapeNot)*
  [Char] -> [Pattern] -> Production
define [Char]
"ShapeAnd" [
    [Pattern] -> Pattern
list[Pattern
"ShapeNot", Pattern -> Pattern
star([Pattern] -> Pattern
list[Pattern
and_, Pattern
"ShapeNot"])]],

-- [15] InlineShapeAnd ::= InlineShapeNot ("AND" InlineShapeNot)*
  [Char] -> [Pattern] -> Production
define [Char]
"InlineShapeAnd" [
    [Pattern] -> Pattern
list[Pattern
"InlineShapeNot", Pattern -> Pattern
star([Pattern] -> Pattern
list[Pattern
and_, Pattern
"InlineShapeNot"])]],

-- [16] ShapeNot ::= "NOT"? ShapeAtom
  [Char] -> [Pattern] -> Production
define [Char]
"ShapeNot" [
    [Pattern] -> Pattern
list[Pattern -> Pattern
opt (Pattern
not_), Pattern
"ShapeAtom"]],

-- [17] InlineShapeNot ::= "NOT"? InlineShapeAtom
  [Char] -> [Pattern] -> Production
define [Char]
"InlineShapeNot" [
    [Pattern] -> Pattern
list[Pattern -> Pattern
opt(Pattern
not_), Pattern
"InlineShapeAtom"]],

-- [18] ShapeAtom ::= NodeConstraint ShapeOrRef?
--                                   | ShapeOrRef
--                                   | "(" ShapeExpression ")"
--                                   | '.'  # no constraint
  [Char] -> [Pattern] -> Production
define [Char]
"ShapeAtom" [
    [Pattern] -> Pattern
list[Pattern
"NodeConstraint", Pattern -> Pattern
opt(Pattern
"ShapeOrRef")],
    Pattern
"ShapeOrRef",
    [Pattern] -> Pattern
list[Pattern
parenOpen_, Pattern
"ShapeExpression", Pattern
parenClose_],
    Pattern
period_],

-- [19] InlineShapeAtom ::= NodeConstraint InlineShapeOrRef?
--                                   | InlineShapeOrRef NodeConstraint?
--                                   | "(" ShapeExpression ")"
--                                   | '.'  # no constraint
  [Char] -> [Pattern] -> Production
define [Char]
"InlineShapeAtom" [
    [Pattern] -> Pattern
list[Pattern
"NodeConstraint", Pattern -> Pattern
opt(Pattern
"InlineShapeOrRef")],
    [Pattern] -> Pattern
list[Pattern
"InlineShapeOrRef", Pattern -> Pattern
opt(Pattern
"NodeConstraint")],
    [Pattern] -> Pattern
list[Pattern
parenOpen_, Pattern
"ShapeExpression", Pattern
parenClose_],
    Pattern
period_],

-- [20] ShapeOrRef ::= ShapeDefinition
--                                   | AtpNameLn | AtpNameNs | '@' ShapeExprLabel
  [Char] -> [Pattern] -> Production
define [Char]
"ShapeOrRef" [
    Pattern
"ShapeDefinition",
    Pattern
"AtpNameLn",
    Pattern
"AtpNameNs",
    [Pattern] -> Pattern
list[Pattern
at_,Pattern
"ShapeExprLabel"]],

-- [21] InlineShapeOrRef ::= InlineShapeDefinition
--                                   | AtpNameLn | AtpNameNs | '@' ShapeExprLabel
  [Char] -> [Pattern] -> Production
define [Char]
"InlineShapeOrRef" [
    Pattern
"InlineShapeDefinition",
    Pattern
"AtpNameLn",
    Pattern
"AtpNameNs",
    [Pattern] -> Pattern
list[Pattern
at_,Pattern
"ShapeExprLabel"]],

-- [22] NodeConstraint ::= "LITERAL" XsFacet*
--                                   | NonLiteralKind StringFacet*
--                                   | Datatype XsFacet*
--                                   | ValueSet XsFacet*
--                                   | XsFacet+
  [Char] -> [Pattern] -> Production
define [Char]
"NodeConstraint" [
    [Pattern] -> Pattern
list[Pattern
literal_, Pattern -> Pattern
star(Pattern
"XsFacet")],
    [Pattern] -> Pattern
list[Pattern
"NonLiteralKind", Pattern -> Pattern
star(Pattern
"StringFacet")],
    [Pattern] -> Pattern
list[Pattern
"Datatype", Pattern -> Pattern
star(Pattern
"XsFacet")],
    [Pattern] -> Pattern
list[Pattern
"ValueSet", Pattern -> Pattern
star(Pattern
"XsFacet")],
    [Pattern] -> Pattern
list[Pattern
"ValueSet", Pattern -> Pattern
star(Pattern
"XsFacet")],
    Pattern -> Pattern
plus(Pattern
"XsFacet")],

-- [23] NonLiteralKind ::= "IRI" | "BNODE" | "NONLITERAL"
  [Char] -> [Pattern] -> Production
define [Char]
"NonLiteralKind" [Pattern
iri_, Pattern
bnode_, Pattern
nonLiteral_],

-- [24] XsFacet ::= StringFacet | NumericFacet
  [Char] -> [Pattern] -> Production
define [Char]
"XsFacet" [Pattern
"StringFacet", Pattern
"NumericFacet"],

-- [25] StringFacet ::= StringLength Integer | Regexp
  [Char] -> [Pattern] -> Production
define [Char]
"StringFacet" [
    [Pattern] -> Pattern
list [Pattern
"StringLength", Pattern
"Integer"],
    Pattern
"Regexp" ],

-- [26] StringLength ::= "LENGTH" | "MINLENGTH" | "MAXLENGTH"
  [Char] -> [Pattern] -> Production
define [Char]
"StringLength" [
    Pattern
length_, Pattern
minLength_, Pattern
maxLength_],

-- [27] NumericFacet ::= NumericRange NumericLiteral
--                                   | NumericLength Integer
  [Char] -> [Pattern] -> Production
define [Char]
"NumericFacet" [
    [Pattern] -> Pattern
list [Pattern
"NumericRange", Pattern
"NumericLiteral"],
    [Pattern] -> Pattern
list [Pattern
"NumericLength", Pattern
"Integer"]],

-- [28] NumericRange ::= "MININCLUSIVE" | "MINEXCLUSIVE" | "MAXINCLUSIVE" | "MAXEXCLUSIVE"
  [Char] -> [Pattern] -> Production
define [Char]
"NumericRange" [
    Pattern
minInclusive_, Pattern
minExclusive_, Pattern
maxInclusive_, Pattern
maxExclusive_],

-- [29] NumericLength ::= "TOTALDIGITS" | "FRACTIONDIGITS"
  [Char] -> [Pattern] -> Production
define [Char]
"NumericLength" [
    Pattern
totalDigits_, Pattern
fractionDigits_],

-- [30] ShapeDefinition ::= (IncludeSet | ExtraPropertySet | "CLOSED")* '{' TripleExpression? '}' Annotation* SemanticActions
  [Char] -> [Pattern] -> Production
define [Char]
"ShapeDefinition" [
    [Pattern] -> Pattern
list[Pattern -> Pattern
star([Pattern] -> Pattern
alts[Pattern
"IncludeSet", Pattern
"ExtraPropertySet", Pattern
closed_]),
        Pattern
braceOpen_, Pattern -> Pattern
opt(Pattern
"TripleExpression"), Pattern
braceClose_,
        Pattern -> Pattern
star(Pattern
"Annotation"), Pattern
"SemanticActions"]],

-- [31] InlineShapeDefinition ::= (IncludeSet | ExtraPropertySet | "CLOSED")* '{' TripleExpression? '}'
  [Char] -> [Pattern] -> Production
define [Char]
"InlineShapeDefinition" [
    [Pattern] -> Pattern
list[Pattern -> Pattern
star([Pattern] -> Pattern
alts[Pattern
"IncludeSet", Pattern
"ExtraPropertySet", Pattern
closed_]), Pattern
braceOpen_, Pattern -> Pattern
opt(Pattern
"TripleExpression"), Pattern
braceClose_]],

-- [32] ExtraPropertySet ::= "EXTRA" Predicate+
  [Char] -> [Pattern] -> Production
define [Char]
"ExtraPropertySet" [
    [Pattern] -> Pattern
list[Pattern
extra_, Pattern -> Pattern
plusPattern
"Predicate"]],

-- [33] TripleExpression ::= OneOfTripleExpr
  [Char] -> [Pattern] -> Production
define [Char]
"TripleExpression" [
    Pattern
"OneOfTripleExpr"],

-- [34] OneOfTripleExpr ::= GroupTripleExpr | MultiElementOneOf
  [Char] -> [Pattern] -> Production
define [Char]
"OneOfTripleExpr" [
    Pattern
"GroupTripleExpr",
    Pattern
"MultiElementOneOf"],

-- [35] MultiElementOneOf ::= GroupTripleExpr ('|' GroupTripleExpr)+
  [Char] -> [Pattern] -> Production
define [Char]
"MultiElementOneOf" [
    [Pattern] -> Pattern
list[Pattern
"GroupTripleExpr", Pattern -> Pattern
plus([Pattern] -> Pattern
list[Pattern
pipe_, Pattern
"GroupTripleExpr"])]],

-- [36] InnerTripleExpr ::= MultiElementGroup | MultiElementOneOf
  [Char] -> [Pattern] -> Production
define [Char]
"InnerTripleExpr" [
    Pattern
"MultiElementGroup",
    Pattern
"MultiElementOneOf"],

-- [37] GroupTripleExpr ::= SingleElementGroup | MultiElementGroup
  [Char] -> [Pattern] -> Production
define [Char]
"GroupTripleExpr" [
    Pattern
"SingleElementGroup",
    Pattern
"MultiElementGroup"],

-- [38] SingleElementGroup ::= UnaryTripleExpr ';'?
  [Char] -> [Pattern] -> Production
define [Char]
"SingleElementGroup" [
    [Pattern] -> Pattern
list[Pattern
"UnaryTripleExpr", Pattern -> Pattern
opt(Pattern
semicolon_)]],

-- [39] MultiElementGroup ::= UnaryTripleExpr (';' UnaryTripleExpr)+ ';'?
  [Char] -> [Pattern] -> Production
define [Char]
"MultiElementGroup" [
    [Pattern] -> Pattern
list[Pattern
"UnaryTripleExpr", Pattern -> Pattern
plus([Pattern] -> Pattern
list[Pattern
semicolon_, Pattern
"UnaryTripleExpr"]), Pattern -> Pattern
opt(Pattern
semicolon_)]],

-- [40] UnaryTripleExpr ::= ('$' TripleExprLabel)? (TripleConstraint | BracketedTripleExpr) | Include
  [Char] -> [Pattern] -> Production
define [Char]
"UnaryTripleExpr" [
    [Pattern] -> Pattern
list[Pattern -> Pattern
opt([Pattern] -> Pattern
list[Pattern
dollar_, Pattern
"TripleExprLabel"]), [Pattern] -> Pattern
alts[Pattern
"TripleConstraint", Pattern
"BracketedTripleExpr"]],
    Pattern
"Include"],

-- [41] BracketedTripleExpr ::= '(' InnerTripleExpr ')' Cardinality? Annotation* SemanticActions
  [Char] -> [Pattern] -> Production
define [Char]
"BracketedTripleExpr" [
    [Pattern] -> Pattern
list[Pattern
parenOpen_, Pattern
"InnerTripleExpr", Pattern
parenClose_, Pattern -> Pattern
optPattern
"Cardinality", Pattern -> Pattern
starPattern
"Annotation", Pattern
"SemanticActions"]],

-- [43] TripleConstraint ::= SenseFlags? Predicate InlineShapeExpression Cardinality? Annotation* SemanticActions
  [Char] -> [Pattern] -> Production
define [Char]
"TripleConstraint" [
    [Pattern] -> Pattern
list[Pattern -> Pattern
optPattern
"SenseFlags", Pattern
"Predicate", Pattern
"InlineShapeExpression", Pattern -> Pattern
optPattern
"Cardinality", Pattern -> Pattern
starPattern
"Annotation", Pattern
"SemanticActions"]],

-- [44] Cardinality ::= '*' | '+' | '?' | RepeatRange
  [Char] -> [Pattern] -> Production
define [Char]
"Cardinality" [
    Pattern
star_, Pattern
plus_, Pattern
question_, Pattern
"RepeatRange"],


-- [45] SenseFlags ::= '^'
  [Char] -> [Pattern] -> Production
define [Char]
"SenseFlags" [
    [Char] -> Pattern
terminal [Char]
"^"],

-- [46] ValueSet ::= '[' ValueSetValue* ']'
  [Char] -> [Pattern] -> Production
define [Char]
"ValueSet" [
    [Pattern] -> Pattern
list[[Char] -> Pattern
terminal [Char]
"[", Pattern -> Pattern
starPattern
"ValueSetValue", [Char] -> Pattern
terminal [Char]
"]"]],

-- [47] ValueSetValue ::= IriRange | Literal
  [Char] -> [Pattern] -> Production
define [Char]
"ValueSetValue" [
    Pattern
"IriRange",
    Pattern
"Literal"],

-- [48] IriRange ::= Iri ('~' Exclusion*)? | '.' Exclusion+
  [Char] -> [Pattern] -> Production
define [Char]
"IriRange" [
    [Pattern] -> Pattern
list[Pattern
"Iri", Pattern -> Pattern
opt([Pattern] -> Pattern
list[Pattern
tilde_, Pattern -> Pattern
starPattern
"Exclusion"])],
    [Pattern] -> Pattern
list[Pattern
period_, Pattern -> Pattern
plusPattern
"Exclusion"]],

-- [49] Exclusion ::= '-' Iri '~'?
  [Char] -> [Pattern] -> Production
define [Char]
"Exclusion" [
    [Pattern] -> Pattern
list[Pattern
dash_, Pattern
"Iri", Pattern
tilde_]],

-- [50] Include ::= '&' TripleExprLabel
  [Char] -> [Pattern] -> Production
define [Char]
"Include" [
    [Pattern] -> Pattern
list[Pattern
ampersand_, Pattern
"TripleExprLabel"]],

-- [51] Annotation ::= '//' Predicate (Iri | Literal)
  [Char] -> [Pattern] -> Production
define [Char]
"Annotation" [
    [Pattern] -> Pattern
list[[Char] -> Pattern
terminal [Char]
"//", Pattern
"Predicate", [Pattern] -> Pattern
alts[Pattern
"Iri", Pattern
"Literal"]]],

-- [52] SemanticActions ::= CodeDecl*
  [Char] -> [Pattern] -> Production
define [Char]
"SemanticActions" [
    Pattern -> Pattern
starPattern
"CodeDecl"],

-- [53] CodeDecl ::= '%' Iri (Code | "%")
  [Char] -> [Pattern] -> Production
define [Char]
"CodeDecl" [
    [Pattern] -> Pattern
list[Pattern
percent_, Pattern
"Iri", [Pattern] -> Pattern
alts[Pattern
"Code", Pattern
percent_]]],

-- [13t] Literal ::= RdfLiteral | NumericLiteral | BooleanLiteral
  [Char] -> [Pattern] -> Production
define [Char]
"Literal" [
    Pattern
"RdfLiteral",
    Pattern
"NumericLiteral",
    Pattern
"BooleanLiteral"],

-- [54] Predicate ::= Iri | RdfType
  [Char] -> [Pattern] -> Production
define [Char]
"Predicate" [
    Pattern
"Iri",
    Pattern
"RdfType"],

-- [55] Datatype ::= Iri
  [Char] -> [Pattern] -> Production
define [Char]
"Datatype" [
    Pattern
"Iri"],

-- [56] ShapeExprLabel ::= Iri | BlankNode
  [Char] -> [Pattern] -> Production
define [Char]
"ShapeExprLabel" [
    Pattern
"Iri",
    Pattern
"BlankNode"],

-- [42] TripleExprLabel ::= '$' (Iri | BlankNode)
  [Char] -> [Pattern] -> Production
define [Char]
"TripleExprLabel" [
    [Pattern] -> Pattern
list[Pattern
dollar_, [Pattern] -> Pattern
alts[Pattern
"Iri", Pattern
"BlankNode"]]],

-- [16t] NumericLiteral ::= Integer | Decimal | Double
  [Char] -> [Pattern] -> Production
define [Char]
"NumericLiteral" [
    Pattern
"Integer", Pattern
"Decimal", Pattern
"Double"],

-- [129s] RdfLiteral ::= String (LangTag | '^^' Datatype)?
  [Char] -> [Pattern] -> Production
define [Char]
"RdfLiteral" [
    [Pattern] -> Pattern
list[Pattern
"String", Pattern -> Pattern
opt([Pattern] -> Pattern
alts[Pattern
"LangTag", [Pattern] -> Pattern
list[[Char] -> Pattern
terminal [Char]
"^^", Pattern
"Datatype"]])]],

-- [134s] BooleanLiteral ::= 'true' | 'false'
  [Char] -> [Pattern] -> Production
define [Char]
"BooleanLiteral" [
    Pattern
true_, Pattern
false_],

-- [135s] String ::= StringLiteral1 | StringLiteralLong1
--                 | StringLiteral2 | StringLiteralLong2
  [Char] -> [Pattern] -> Production
define [Char]
"String" [
    Pattern
"StringLiteral1",
    Pattern
"StringLiteralLong1",
    Pattern
"StringLiteral2",
    Pattern
"StringLiteralLong2"],

-- [136s] Iri ::= IriRef | PrefixedName
  [Char] -> [Pattern] -> Production
define [Char]
"Iri" [
    Pattern
"IriRef",
    Pattern
"PrefixedName"],

-- [137s] PrefixedName ::= PnameLn | PnameNs
  [Char] -> [Pattern] -> Production
define [Char]
"PrefixedName" [
    Pattern
"PnameLn",
    Pattern
"PnameNs"],

-- [138s] BlankNode ::= BlankNodeLabel
  [Char] -> [Pattern] -> Production
define [Char]
"BlankNode" [
    Pattern
"BlankNodeLabel"],

--   # Reserved for future use
-- [57] IncludeSet ::= '&' ShapeExprLabel+
  [Char] -> [Pattern] -> Production
define [Char]
"IncludeSet" [
    [Pattern] -> Pattern
list[Pattern
ampersand_, Pattern -> Pattern
plusPattern
"ShapeExprLabel"]],

-- [58] Code ::= '{' ([^%\\] | '\\' [%\\] | Uchar)* '%' '}'
  [Char] -> [Pattern] -> Production
define [Char]
"Code" [
    [Pattern] -> Pattern
list[Pattern
braceOpen_, Pattern -> Pattern
star([Pattern] -> Pattern
alts[ [Char] -> Pattern
regex [Char]
"[^%\\]", [Pattern] -> Pattern
list[Pattern
doubleFrwSlash_, [Char] -> Pattern
regex [Char]
"[%\\]"], Pattern
"Uchar" ]), Pattern
percent_, Pattern
braceClose_]],

-- [59] RepeatRange ::= '{' Integer (',' (Integer | '*')?)? '}'
  [Char] -> [Pattern] -> Production
define [Char]
"RepeatRange" [
    [Pattern] -> Pattern
list[Pattern
braceOpen_, Pattern
"Integer", Pattern -> Pattern
opt([Pattern] -> Pattern
list[Pattern
coma_, Pattern -> Pattern
opt(Pattern -> Pattern
opt([Pattern] -> Pattern
alts[Pattern
"Integer", Pattern
star_]))]), Pattern
braceClose_]],

-- [60] RdfType ::= 'a'
  [Char] -> [Pattern] -> Production
define [Char]
"RdfType" [
    [Char] -> Pattern
terminal [Char]
"a"],

-- [18t] IriRef ::= '<' ([^#x00-#x20<>\"{}|^`\\] | Uchar)* '>' /* #x00=NULL #01-#x1F=control codes #x20=space */
  [Char] -> [Pattern] -> Production
define [Char]
"IriRef" [
    [Pattern] -> Pattern
list[[Char] -> Pattern
terminal [Char]
"<", Pattern -> Pattern
star([Pattern] -> Pattern
alts[ [Char] -> Pattern
regex [Char]
"[^#x00-#x20<>\"{}|^`\\]", Pattern
"Uchar"]), [Char] -> Pattern
terminal [Char]
">"]],

-- [140s] PnameNs ::= PnPrefix? ':'
  [Char] -> [Pattern] -> Production
define [Char]
"PnameNs" [
    [Pattern] -> Pattern
list[Pattern -> Pattern
optPattern
"PnPrefix", Pattern
semicolon_]],

-- [141s] PnameLn ::= PnameNs PnLocal
  [Char] -> [Pattern] -> Production
define [Char]
"PnameLn" [
    [Pattern] -> Pattern
list[Pattern
"PnameNs", Pattern
"PnLocal"]],

-- [61] AtpNameNs ::= '@' PnPrefix? ':'
  [Char] -> [Pattern] -> Production
define [Char]
"AtpNameNs" [
    [Pattern] -> Pattern
list[Pattern
at_, Pattern -> Pattern
optPattern
"PnPrefix", Pattern
colon_]],

-- [62] AtpNameLn ::= '@' PnameNs PnLocal
  [Char] -> [Pattern] -> Production
define [Char]
"AtpNameLn" [
    [Pattern] -> Pattern
list[Pattern
at_, Pattern
"PnameNs", Pattern
"PnLocal"]],

-- [63] Regexp ::= '~/' ([^#x2f#x5C#xA#xD] | '\\' [tbnrf\\/] | Uchar)* '/' [smix]*
  [Char] -> [Pattern] -> Production
define [Char]
"Regexp" [
    [Pattern] -> Pattern
list[[Char] -> Pattern
terminal [Char]
"~/", Pattern -> Pattern
star([Pattern] -> Pattern
alts[
        [Char] -> Pattern
regex [Char]
"[^#x2f#x5C#xA#xD]",
        [Pattern] -> Pattern
list[[Char] -> Pattern
terminal [Char]
"\\", [Char] -> Pattern
regex [Char]
"[tbnrf\\/]"], Pattern
"Uchar"]),
        [Char] -> Pattern
terminal [Char]
"/", Pattern -> Pattern
star( [Char] -> Pattern
regex [Char]
"[smix]")
    ]],

-- [142s] BlankNodeLabel ::= '_:' (PnCharsU | [0-9]) ((PnChars | '.')* PnChars)?
  [Char] -> [Pattern] -> Production
define [Char]
"BlankNodeLabel" [
    [Pattern] -> Pattern
list[[Char] -> Pattern
terminal [Char]
"_:", [Pattern] -> Pattern
alts[Pattern
"PnCharsU", [Char] -> Pattern
regex [Char]
"[0-9]"], Pattern -> Pattern
opt(Pattern -> Pattern
star([Pattern] -> Pattern
alts[Pattern
"PnChars", Pattern
period_])),Pattern
"PnChars"]],

-- [145s] LangTag ::= '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)*
  [Char] -> [Pattern] -> Production
define [Char]
"LangTag" [
    [Char] -> Pattern
regex [Char]
"@[a-zA-Z]+('-'[a-zA-Z0-9]+)*"],

-- [19t] Integer ::= [+-]? [0-9]+
  [Char] -> [Pattern] -> Production
define [Char]
"Integer" [
    [Char] -> Pattern
regex [Char]
"[+-]? [0-9]+"],

-- [20t] Decimal ::= [+-]? [0-9]* '.' [0-9]+
  [Char] -> [Pattern] -> Production
define [Char]
"Decimal" [
    [Char] -> Pattern
regex [Char]
"[+-]? [0-9]*\\.[0-9]+"],

-- [21t] Double ::= [+-]? ([0-9]+ '.' [0-9]* EXPONENT | '.'? [0-9]+ EXPONENT)
-- [155s] EXPONENT ::= [eE] [+-]? [0-9]+
  [Char] -> [Pattern] -> Production
define [Char]
"Double" [
    [Char] -> Pattern
regex [Char]
"([+-]?([0-9]+)?\\.[0-9]*[eE][+-]?[0-9]+"],

-- [156s] StringLiteral1 ::= "'" ([^#x27#x5C#xA#xD] | Echar | Uchar)* "'" /* #x27=' #x5C=\ #xA=new line #xD=carriage return */
  [Char] -> [Pattern] -> Production
define [Char]
"StringLiteral1" [
    [Pattern] -> Pattern
list[Pattern
singleQuote_, Pattern -> Pattern
star([Pattern] -> Pattern
alts[[Char] -> Pattern
regex [Char]
"[^#x27#x5C#xA#xD]", Pattern
"Echar", Pattern
"Uchar"]), Pattern
singleQuote_]],

-- [157s] StringLiteral2 ::= '"' ([^#x22#x5C#xA#xD] | Echar | Uchar)* '"' /* #x22=" #x5C=\ #xA=new line #xD=carriage return */
  [Char] -> [Pattern] -> Production
define [Char]
"StringLiteral2" [
    [Pattern] -> Pattern
list[Pattern
doubleQuote_, Pattern -> Pattern
star([Pattern] -> Pattern
alts[[Char] -> Pattern
regex [Char]
"[^#x22#x5C#xA#xD]", Pattern
"Echar", Pattern
"Uchar"]), Pattern
doubleQuote_]],

-- [158s] StringLiteralLong1 ::= "'''" (("'" | "''")? ([^\'\\] | Echar | Uchar))* "'''"
  [Char] -> [Pattern] -> Production
define [Char]
"StringLiteralLong1" [
    [Pattern] -> Pattern
list[Pattern
singleQuote_, Pattern
singleQuote_, Pattern
singleQuote_,
        Pattern -> Pattern
star([Pattern] -> Pattern
alts[[Pattern] -> Pattern
list[ Pattern -> Pattern
opt([Pattern] -> Pattern
alts[Pattern
singleQuote_, [Pattern] -> Pattern
list[Pattern
singleQuote_,Pattern
singleQuote_]]), [Char] -> Pattern
regex [Char]
"[^\'\\]"], Pattern
"Echar", Pattern
"Uchar"]),
        Pattern
singleQuote_, Pattern
singleQuote_, Pattern
singleQuote_]],

-- [159s] StringLiteralLong2 ::= '"""' (('"' | '""')? ([^\"\\] | Echar | Uchar))* '"""'
  [Char] -> [Pattern] -> Production
define [Char]
"StringLiteralLong2" [
    [Pattern] -> Pattern
list[Pattern
doubleQuote_, Pattern
doubleQuote_, Pattern
doubleQuote_,
        Pattern -> Pattern
star([Pattern] -> Pattern
alts[[Pattern] -> Pattern
list[ Pattern -> Pattern
opt([Pattern] -> Pattern
alts[Pattern
doubleQuote_, [Pattern] -> Pattern
list[Pattern
doubleQuote_,Pattern
doubleQuote_]]), [Char] -> Pattern
regex [Char]
"[^\"\\]"], Pattern
"Echar", Pattern
"Uchar"]),
        Pattern
doubleQuote_, Pattern
doubleQuote_, Pattern
doubleQuote_]],

-- [26t] Uchar ::= '\\u' Hex Hex Hex Hex
--                                   | '\\U' Hex Hex Hex Hex Hex Hex Hex Hex
  [Char] -> [Pattern] -> Production
define [Char]
"Uchar" [
    [Pattern] -> Pattern
list[[Char] -> Pattern
terminal [Char]
"\\u", Pattern
"Hex", Pattern
"Hex", Pattern
"Hex", Pattern
"Hex"],
    [Pattern] -> Pattern
list[[Char] -> Pattern
terminal [Char]
"\\U", Pattern
"Hex", Pattern
"Hex", Pattern
"Hex", Pattern
"Hex", Pattern
"Hex", Pattern
"Hex", Pattern
"Hex", Pattern
"Hex"]],

-- [160s] Echar ::= '\\' [tbnrf\\\"\']
  [Char] -> [Pattern] -> Production
define [Char]
"Echar" [
    [Pattern] -> Pattern
list[Pattern
doubleFrwSlash_, [Char] -> Pattern
regex [Char]
"[tbnrf\\\"\']"]],

-- [164s] PnCharsBase ::= [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]
  [Char] -> [Pattern] -> Production
define [Char]
"PnCharsBase" [
    [Char] -> Pattern
regex [Char]
"[A-Z]",
    [Char] -> Pattern
regex [Char]
"[a-z]"], -- TODO other chars


-- [165s] PnCharsU ::= PnCharsBase | '_'
  [Char] -> [Pattern] -> Production
define [Char]
"PnCharsU" [
    Pattern
"PnCharsBase",
    Pattern
underscore_],

-- [167s] PnChars ::= PnCharsU | '-' | [0-9]
--                                   | [#x00B7] | [#x0300-#x036F] | [#x203F-#x2040]
  [Char] -> [Pattern] -> Production
define [Char]
"PnChars" [
    Pattern
"PnCharsU",
    Pattern
dash_,
    [Char] -> Pattern
regex [Char]
"0-9"], -- TODO other chars

-- [168s] PnPrefix ::= PnCharsBase ((PnChars | '.')* PnChars)?
  [Char] -> [Pattern] -> Production
define [Char]
"PnPrefix" [
    [Pattern] -> Pattern
list[Pattern
"PnCharsBase",
    Pattern -> Pattern
opt([Pattern] -> Pattern
list[[Pattern] -> Pattern
alts[Pattern
"PnChars", Pattern
period_],Pattern
"PnChars"])]],

-- [169s] PnLocal ::= (PnCharsU | ':' | [0-9] | Plx) ((PnChars | '.' | ':' | Plx)* (PnChars | ':' | Plx))?
  [Char] -> [Pattern] -> Production
define [Char]
"PnLocal" [
    [Pattern] -> Pattern
list[
      [Pattern] -> Pattern
alts[Pattern
"PnCharsU", Pattern
colon_, [Char] -> Pattern
regex [Char]
"0-9", Pattern
"Plx"],
      Pattern -> Pattern
opt([Pattern] -> Pattern
list[
        Pattern -> Pattern
star([Pattern] -> Pattern
alts[Pattern
"PnChars", Pattern
period_, Pattern
colon_, Pattern
"Plx"]),
        [Pattern] -> Pattern
alts[Pattern
"PnChars", Pattern
colon_, Pattern
"Plx"]]
      )]],

-- [170s] Plx ::= Percent | PnLocalEsc
  [Char] -> [Pattern] -> Production
define [Char]
"Plx" [
    Pattern
"Percent",
    Pattern
"PnLocalEsc"],

-- [171s] Percent ::= '%' Hex Hex
  [Char] -> [Pattern] -> Production
define [Char]
"Percent" [
    [Pattern] -> Pattern
list[Pattern
percent_, Pattern
"Hex", Pattern
"Hex"]],

-- [172s] Hex ::= [0-9] | [A-F] | [a-f]
  [Char] -> [Pattern] -> Production
define [Char]
"Hex" [[Char] -> Pattern
regex [Char]
"[0-9][A-F][a-f]"],


-- [173s] PnLocalEsc ::= '\\' ('_' | '~' | '.' | '-' | '!' | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%')
  [Char] -> [Pattern] -> Production
define [Char]
"PnLocalEsc" [
    [Pattern] -> Pattern
list[Pattern
doubleFrwSlash_, [Char] -> Pattern
regex [Char]
"[_~\\.-!$&'\\(\\)\\*+,;=/\\?#@%]"]]]

--   @pass ::= [ \t\r\n]+ -- TODO
--           | "#" [^\r\n]*