-
Notifications
You must be signed in to change notification settings - Fork 1
/
bnf
219 lines (200 loc) · 11.8 KB
/
bnf
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# Yacker grammer for (Sh)ape (Ex)pressions (C)ompact language
#
# Copyright 2015, Eric Prud'hommeax, Harold Solbrig, Iovka Boneva, Jose Labra Gayo
# All rights reserved; please contact copyright holders for any use outside of the ShEx semantics.
# http://www.w3.org/2005/01/yacker/uploads/ShEx2/bnf
#
# yacker: https://www.w3.org/2005/01/yacker/uploads/ShEx3?lang=perl
# repo: https://github.com/shexSpec/shexTest/
# branch: TEisSE
# TODO:
# annotations on shapes
# look hard at EXTERNAL valueClassDefinitions
#
# Changes from yacker ShEx2:
#
# + '*' in 2nd pos of REPEAT_RANGE so e.g. {2,*} === {2,}
# ~ code names are iris. this changes existing semantic actions as follows:
# <S> { :p1 . %GenX{ blah blah blah %} }
# PREFIX GenX: <http://...GenX> <S> { :p1 . %GenX:{ blah blah blah %} }
# empty code names %{ ... %} are parsed as empty relative URLs: %<>{ ... %}
# + ATPNAME_NS, ATPNAME_LN terminals to parse e.g. @ex:foo which looks like a LANGTAG
# ~ a is an iri (not just for predicates) enabling e.g. <reif> { rdf:predicate (a) }
# ~ groupShapeConstr can only have ORs (no ANDs) so no <S1> { :p1 @<S2> AND @<S3> }
# + includeSet parallels inclPropertySet (&<A><B><C>) e.g. <S3> &<S1> <S2> { ... }
# + factored out (labeled) productions for startActions and semanticActions
# ~ BNodes can have stringFacets
# - ANON terminal (not referenced)
# ~ tripleConstraint: swapped position of annotations and cardinality (EGP 20150727)
# + valueClass: add xsFacet* to datatype (EGP 20150727)
# + escapes (\\, \uxxxx, \Uxxxxxxxx) in CODE (EGP 20150730)
# ~ moved | RDF_TYPE from iri: to predicate: (disables e.g. %a{ ... %}) (EGP 20150807)
# + tried to intercept non-terminated STRING_LITERAL_LONG{1,2} (EGP 20150807)
# - unaryShape: id (EGP 20150818)
# + unaryShape: annotation* (EGP 20150818)
# + valueClassLabel, valueClassDefinition, valueClassExpr, valueClassOrRef (EGP 20150818)
# + factored out notStartAction (EGP 20150818)
# - oneOf (EGP 20150820)
# ~ split out encapsulatedShape (EGP 20150831)
# - numericRange takes a numericLiteral, was INTEGER (EGP 20150917)
# + innerShape ::= multiElementGroup | multiElementSomeOf (EGP 20151022)
# ~ annotation ::= ';' predicate (iri | literal) -- was iri (EGP 20151022)
# + generalized AND/OR expressions on valueClasses (EGP 20151031)
# - groupShapeConstr (shapeOrRef (OR shapeOrRef)*) (EGP 20151031)
# + stringFacet* on negatableValueClass ::= shapeOrRef (EGP 20151101)
# ~ vcand and vcor are mutually exclusive (i.e. not recursive) (EGP 20151111)
# ~ s/valueClassDefinition/valueExprDefinition/ (EGP 20151120)
# ~ s/valueClassLabel/valueExprLabel/ (EGP 20151120)
# ~ change valueSet delimiters from ()s to []s (EGP 20160104)
# ~ codeDecls can have no code (implies code ref) (EGP 20160128)
# + ()s around valueExprs (EGP 20160520)
# + shapeDefinition += nonLiteralKind? stringFacet* (EGP 20160520)
# - shape == "VIRTUAL"? (EGP 20160520)
# + ';' separator for groups (EGP 20160524)
# ~ s{;}{//} for annotations (EGP 20160524)
# + ("AND" shapeDefinition)* (EGP 20160524)
# + ("OR" shapeDefinition)* (EGP 20160615)
# ~ generalized shapeExpression to include valueExprDefinition (EGP 20160708)
# ~ reordered (EGP 20160913)
# ~ s/ShapeDisjunction/shapeOr/ (EGP 20160913)
# ~ s/shapeConjunction/shapeAnd/ (EGP 20160913)
# ~ s/negShapeAtom/shapeNot/ (EGP 20160913)
# ~ s/inclPropertySet/extraPropertySet/ (EGP 20160913)
# ~ s/value/valueSetValue/ (EGP 20160913)
# ~ updated production labels (EGP 20160913)
# ~ reorder to align with spec (EGP 20160930)
# ~ s/someOfShape/someOfTripleExpr/ (EGP 20160930)
# ~ s/innerShape/innerTripleExpr/ (EGP 20160930)
# ~ s/groupShape/groupTripleExpr/ (EGP 20160930)
# ~ s/unaryShape/unaryTripleExpr/ (EGP 20160930)
# ~ s/encapsulatedShape/bracketedTripleExpr/ (EGP 20160930)
# ~ s/SomeOf/OneOf/g (EGP 20161201)
# ~ s/shapeLabel/shapeExprLabel/? (EGP 20170228)
# + tripleExprLabel (EGP 20170228)
# - ^^-style facet arguments per shex#41 (EGP 20170303)
# ~ switch to ~/regexp/ (EGP 20170303)
# 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
[3] baseDecl ::= "BASE" IRIREF
[4] prefixDecl ::= "PREFIX" PNAME_NS IRIREF
[5] notStartAction ::= start | shapeExprDecl
[6] start ::= "start" '=' shapeExpression
[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 ::= nodeConstraint shapeOrRef?
| shapeOrRef
| "(" shapeExpression ")"
| '.' # no constraint
[19] inlineShapeAtom ::= nodeConstraint inlineShapeOrRef?
| inlineShapeOrRef nodeConstraint?
| "(" shapeExpression ")"
| '.' # no constraint
[20] shapeOrRef ::= shapeDefinition
| ATPNAME_LN | ATPNAME_NS | '@' shapeExprLabel
[21] inlineShapeOrRef ::= inlineShapeDefinition
| ATPNAME_LN | ATPNAME_NS | '@' shapeExprLabel
[22] nodeConstraint ::= "LITERAL" xsFacet*
| nonLiteralKind stringFacet*
| datatype xsFacet*
| valueSet xsFacet*
| xsFacet+
[23] nonLiteralKind ::= "IRI" | "BNODE" | "NONLITERAL"
[24] xsFacet ::= stringFacet | numericFacet
[25] stringFacet ::= stringLength INTEGER
| REGEXP
[26] stringLength ::= "LENGTH" | "MINLENGTH" | "MAXLENGTH"
[27] numericFacet ::= numericRange numericLiteral
| numericLength INTEGER
[28] numericRange ::= "MININCLUSIVE" | "MINEXCLUSIVE" | "MAXINCLUSIVE" | "MAXEXCLUSIVE"
[29] numericLength ::= "TOTALDIGITS" | "FRACTIONDIGITS"
[30] shapeDefinition ::= (includeSet | extraPropertySet | "CLOSED")* '{' tripleExpression? '}' annotation* semanticActions
[31] inlineShapeDefinition ::= (includeSet | extraPropertySet | "CLOSED")* '{' tripleExpression? '}'
[32] extraPropertySet ::= "EXTRA" predicate+
[33] tripleExpression ::= oneOfTripleExpr
[34] oneOfTripleExpr ::= groupTripleExpr | multiElementOneOf
[35] multiElementOneOf ::= groupTripleExpr ('|' groupTripleExpr)+
[36] innerTripleExpr ::= multiElementGroup | multiElementOneOf
[37] groupTripleExpr ::= singleElementGroup | multiElementGroup
[38] singleElementGroup ::= unaryTripleExpr ';'?
[39] multiElementGroup ::= unaryTripleExpr (';' unaryTripleExpr)+ ';'?
[40] unaryTripleExpr ::= ('$' tripleExprLabel)? (tripleConstraint | bracketedTripleExpr) | include
[41] bracketedTripleExpr ::= '(' innerTripleExpr ')' cardinality? annotation* semanticActions
[43] tripleConstraint ::= senseFlags? predicate inlineShapeExpression cardinality? annotation* semanticActions
[44] cardinality ::= '*' | '+' | '?' | REPEAT_RANGE
[45] senseFlags ::= '^'
[46] valueSet ::= '[' valueSetValue* ']'
[47] valueSetValue ::= iriRange | literal
[48] iriRange ::= iri ('~' exclusion*)? | '.' exclusion+
[49] exclusion ::= '-' iri '~'?
[50] include ::= '&' tripleExprLabel
[51] annotation ::= '//' predicate (iri | literal)
[52] semanticActions ::= codeDecl*
[53] codeDecl ::= '%' iri (CODE | "%")
[13t] literal ::= rdfLiteral | numericLiteral | booleanLiteral
[54] predicate ::= iri | RDF_TYPE
[55] datatype ::= iri
[56] shapeExprLabel ::= iri | blankNode
[42] tripleExprLabel ::= '$' (iri | blankNode)
[16t] numericLiteral ::= INTEGER | DECIMAL | DOUBLE
[129s] rdfLiteral ::= string (LANGTAG | '^^' datatype)?
[134s] booleanLiteral ::= 'true' | 'false'
[135s] string ::= STRING_LITERAL1 | STRING_LITERAL_LONG1
| STRING_LITERAL2 | STRING_LITERAL_LONG2
[136s] iri ::= IRIREF | prefixedName
[137s] prefixedName ::= PNAME_LN | PNAME_NS
[138s] blankNode ::= BLANK_NODE_LABEL
# Reserved for future use
[57] includeSet ::= '&' shapeExprLabel+
@terminals
[58] CODE ::= '{' ([^%\\] | '\\' [%\\] | UCHAR)* '%' '}'
[59] REPEAT_RANGE ::= '{' INTEGER (',' (INTEGER | '*')?)? '}'
[60] 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
[61] ATPNAME_NS ::= '@' PN_PREFIX? ':'
[62] ATPNAME_LN ::= '@' PNAME_NS PN_LOCAL
[63] REGEXP ::= '~/' ([^#x2f#x5C#xA#xD] | '\\' [tbnrf\\/] | 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))* '"""'
[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]*