-
Notifications
You must be signed in to change notification settings - Fork 2
/
shex.ebnf
172 lines (148 loc) · 9.64 KB
/
shex.ebnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Notation:
# in-line terminals in ""s are case-insensitive
# production numbers ending in t or s are from Turtle or SPARQL.
# leading CODE is captured in startActions
[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
# "START" easier for parser than "start"
[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 ")"
| '.' # no constraint
[19] shapeAtomNoRef ::= nonLitNodeConstraint shapeOrRef?
| litNodeConstraint
| shapeDefinition nonLitNodeConstraint?
| "(" shapeExpression ")"
| '.' # no constraint
[20] inlineShapeAtom ::= nonLitNodeConstraint inlineShapeOrRef?
| litNodeConstraint
| inlineShapeOrRef nonLitNodeConstraint?
| "(" shapeExpression ")"
| '.' # no constraint
[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
# oneOfTripleExpr and multiElementOneOf both start with groupTripleExpr
#[37] oneOfTripleExpr ::= groupTripleExpr | multiElementOneOf
#[38] multiElementOneOf ::= groupTripleExpr ('|' groupTripleExpr)+
#[39] innerTripleExpr ::= multiElementGroup | multiElementOneOf
[37] oneOfTripleExpr ::= groupTripleExpr ('|' groupTripleExpr)*
# singleElementGroup and multiElementGroup both start with unaryTripleExpr
#[40] groupTripleExpr ::= singleElementGroup | multiElementGroup
#[41] singleElementGroup ::= unaryTripleExpr ';'?
#[42] multiElementGroup ::= unaryTripleExpr (';' unaryTripleExpr)+ ';'?
[40] groupTripleExpr ::= unaryTripleExpr (';' unaryTripleExpr?)*
[43] unaryTripleExpr ::= ('$' tripleExprLabel)? (tripleConstraint | bracketedTripleExpr) | include
# Use oneOfTripleExpr instead of innerTripleExpr
[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
[67] CODE ::= '{' ([^%\\] | '\\' [%\\] | UCHAR)* '%' '}'
[68] REPEAT_RANGE ::= '{' INTEGER (',' (INTEGER | '*')?)? '}'
[69] RDF_TYPE ::= 'a'
[18t] IRIREF ::= '<' ([^#x00-#x20<>\"{}|^`\\] | UCHAR)* '>' /* #x00=NULL #01-#x1F=control codes #x20=space */
[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 ::= '/' ([^/\\\n\r] | '\\' [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#xA#xD] | ECHAR | UCHAR)* "'" /* #x27=' #x5C=\ #xA=new line #xD=carriage return */
[157s] STRING_LITERAL2 ::= '"' ([^#x22#x5C#xA#xD] | ECHAR | UCHAR)* '"' /* #x22=" #x5C=\ #xA=new line #xD=carriage return */
[158s] STRING_LITERAL_LONG1 ::= "'''" (("'" | "''")? ([^\'\\] | ECHAR | UCHAR))* "'''"
[159s] STRING_LITERAL_LONG2 ::= '"""' (('"' | '""')? ([^\"\\] | ECHAR | UCHAR))* '"""'
[73] LANG_STRING_LITERAL1 ::= "'" ([^#x27#x5C#xA#xD] | ECHAR | UCHAR)* "'" LANGTAG
[74] LANG_STRING_LITERAL2 ::= '"' ([^#x22#x5C#xA#xD] | ECHAR | UCHAR)* '"' LANGTAG
[75] LANG_STRING_LITERAL_LONG1 ::= "'''" (("'" | "''")? ([^\'\\] | ECHAR | UCHAR))* "'''" LANGTAG
[76] LANG_STRING_LITERAL_LONG2 ::= '"""' (('"' | '""')? ([^\"\\] | ECHAR | UCHAR))* '"""' LANGTAG
[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]
| [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x02FF]
| [#x0370-#x037D] | [#x037F-#x1FFF]
| [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF]
| [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD]
| [#x10000-#xEFFFF]
[165s] PN_CHARS_U ::= PN_CHARS_BASE | '_'
[167s] PN_CHARS ::= PN_CHARS_U | '-' | [0-9]
| [#x00B7] | [#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 [ \t\r\n]+ | "#" [^\r\n]* | "/*" ([^*] | '*' ([^/] | '\\/'))* "*/"