|
1 | | -# Yacker grammer for (Sh)ape (Ex)pressions (C)ompact language |
2 | | -# |
3 | | -# Copyright 2015, Eric Prud'hommeax, Harold Solbrig, Iovka Boneva, Jose Labra Gayo |
4 | | -# All rights reserved; please contact copyright holders for any use outside of the ShEx semantics. |
5 | | -# http://www.w3.org/2005/01/yacker/uploads/ShEx2/bnf |
6 | | -# |
7 | | -# yacker: https://www.w3.org/2005/01/yacker/uploads/ShEx3?lang=perl |
8 | | -# repo: https://github.com/shexSpec/shexTest/ |
9 | | -# branch: TEisSE |
10 | | -# TODO: |
11 | | -# annotations on shapes |
12 | | -# look hard at EXTERNAL valueClassDefinitions |
13 | | -# |
14 | | -# Changes from yacker ShEx2: |
15 | | -# |
16 | | -# + '*' in 2nd pos of REPEAT_RANGE so e.g. {2,*} === {2,} |
17 | | -# ~ code names are iris. this changes existing semantic actions as follows: |
18 | | -# <S> { :p1 . %GenX{ blah blah blah %} } |
19 | | -# PREFIX GenX: <http://...GenX> <S> { :p1 . %GenX:{ blah blah blah %} } |
20 | | -# empty code names %{ ... %} are parsed as empty relative URLs: %<>{ ... %} |
21 | | -# + ATPNAME_NS, ATPNAME_LN terminals to parse e.g. @ex:foo which looks like a LANGTAG |
22 | | -# ~ a is an iri (not just for predicates) enabling e.g. <reif> { rdf:predicate (a) } |
23 | | -# ~ groupShapeConstr can only have ORs (no ANDs) so no <S1> { :p1 @<S2> AND @<S3> } |
24 | | -# + includeSet parallels inclPropertySet (&<A><B><C>) e.g. <S3> &<S1> <S2> { ... } |
25 | | -# + factored out (labeled) productions for startActions and semanticActions |
26 | | -# ~ BNodes can have stringFacets |
27 | | -# - ANON terminal (not referenced) |
28 | | -# ~ tripleConstraint: swapped position of annotations and cardinality (EGP 20150727) |
29 | | -# + valueClass: add xsFacet* to datatype (EGP 20150727) |
30 | | -# + escapes (\\, \uxxxx, \Uxxxxxxxx) in CODE (EGP 20150730) |
31 | | -# ~ moved | RDF_TYPE from iri: to predicate: (disables e.g. %a{ ... %}) (EGP 20150807) |
32 | | -# + tried to intercept non-terminated STRING_LITERAL_LONG{1,2} (EGP 20150807) |
33 | | -# - unaryShape: id (EGP 20150818) |
34 | | -# + unaryShape: annotation* (EGP 20150818) |
35 | | -# + valueClassLabel, valueClassDefinition, valueClassExpr, valueClassOrRef (EGP 20150818) |
36 | | -# + factored out notStartAction (EGP 20150818) |
37 | | -# - oneOf (EGP 20150820) |
38 | | -# ~ split out encapsulatedShape (EGP 20150831) |
39 | | -# - numericRange takes a numericLiteral, was INTEGER (EGP 20150917) |
40 | | -# + innerShape ::= multiElementGroup | multiElementSomeOf (EGP 20151022) |
41 | | -# ~ annotation ::= ';' predicate (iri | literal) -- was iri (EGP 20151022) |
42 | | -# + generalized AND/OR expressions on valueClasses (EGP 20151031) |
43 | | -# - groupShapeConstr (shapeOrRef (OR shapeOrRef)*) (EGP 20151031) |
44 | | -# + stringFacet* on negatableValueClass ::= shapeOrRef (EGP 20151101) |
45 | | -# ~ vcand and vcor are mutually exclusive (i.e. not recursive) (EGP 20151111) |
46 | | -# ~ s/valueClassDefinition/valueExprDefinition/ (EGP 20151120) |
47 | | -# ~ s/valueClassLabel/valueExprLabel/ (EGP 20151120) |
48 | | -# ~ change valueSet delimiters from ()s to []s (EGP 20160104) |
49 | | -# ~ codeDecls can have no code (implies code ref) (EGP 20160128) |
50 | | -# + ()s around valueExprs (EGP 20160520) |
51 | | -# + shapeDefinition += nonLiteralKind? stringFacet* (EGP 20160520) |
52 | | -# - shape == "VIRTUAL"? (EGP 20160520) |
53 | | -# + ';' separator for groups (EGP 20160524) |
54 | | -# ~ s{;}{//} for annotations (EGP 20160524) |
55 | | -# + ("AND" shapeDefinition)* (EGP 20160524) |
56 | | -# + ("OR" shapeDefinition)* (EGP 20160615) |
57 | | -# ~ generalized shapeExpression to include valueExprDefinition (EGP 20160708) |
58 | | -# ~ reordered (EGP 20160913) |
59 | | -# ~ s/ShapeDisjunction/shapeOr/ (EGP 20160913) |
60 | | -# ~ s/shapeConjunction/shapeAnd/ (EGP 20160913) |
61 | | -# ~ s/negShapeAtom/shapeNot/ (EGP 20160913) |
62 | | -# ~ s/inclPropertySet/extraPropertySet/ (EGP 20160913) |
63 | | -# ~ s/value/valueSetValue/ (EGP 20160913) |
64 | | -# ~ updated production labels (EGP 20160913) |
65 | | -# ~ reorder to align with spec (EGP 20160930) |
66 | | -# ~ s/someOfShape/someOfTripleExpr/ (EGP 20160930) |
67 | | -# ~ s/innerShape/innerTripleExpr/ (EGP 20160930) |
68 | | -# ~ s/groupShape/groupTripleExpr/ (EGP 20160930) |
69 | | -# ~ s/unaryShape/unaryTripleExpr/ (EGP 20160930) |
70 | | -# ~ s/encapsulatedShape/bracketedTripleExpr/ (EGP 20160930) |
71 | | -# ~ s/SomeOf/OneOf/g (EGP 20161201) |
72 | | -
|
73 | 1 | # Notation: |
74 | 2 | # in-line terminals in ""s are case-insensitive |
75 | 3 | # production numbers ending in t or s are from Turtle or SPARQL. |
|
87 | 15 |
|
88 | 16 | [8] statement ::= directive | notStartAction |
89 | 17 |
|
90 | | -[9] shapeExprDecl ::= shapeLabel (shapeExpression|"EXTERNAL") |
91 | | -[10] shapeExpression ::= shapeAtomNoRef shapeOr? |
92 | | - | "NOT" (shapeAtomNoRef | shapeRef) shapeOr? |
| 18 | +[9] shapeExprDecl ::= shapeExprLabel (shapeExpression | "EXTERNAL") |
| 19 | +[10] shapeExpression ::= "NOT"? shapeAtomNoRef shapeOr? |
| 20 | + | "NOT" shapeRef shapeOr? |
93 | 21 | | shapeRef shapeOr |
94 | 22 | [11] inlineShapeExpression ::= inlineShapeOr |
95 | | -# [12] shapeOr ::= shapeAnd ("OR" shapeAnd)* |
96 | | -[12] shapeOr ::= shapeOrA | shapeOrB shapeOrA? |
97 | | -[12a] shapeOrA ::= ("OR" shapeAnd)+ |
98 | | -[12b] shapeOrB ::= ("AND" shapeNot)+ |
| 23 | +[12] shapeOr ::= ("OR" shapeAnd)+ |
| 24 | + | ("AND" shapeNot)+ ("OR" shapeAnd)* |
99 | 25 | [13] inlineShapeOr ::= inlineShapeAnd ("OR" inlineShapeAnd)* |
100 | 26 | [14] shapeAnd ::= shapeNot ("AND" shapeNot)* |
101 | 27 | [15] inlineShapeAnd ::= inlineShapeNot ("AND" inlineShapeNot)* |
|
119 | 45 |
|
120 | 46 | [21] shapeOrRef ::= shapeDefinition | shapeRef |
121 | 47 | [22] inlineShapeOrRef ::= inlineShapeDefinition | shapeRef |
122 | | -[23] shapeRef ::= ATPNAME_LN | ATPNAME_NS | '@' shapeLabel |
| 48 | +[23] shapeRef ::= ATPNAME_LN | ATPNAME_NS | '@' shapeExprLabel |
123 | 49 |
|
124 | 50 | [24] litNodeConstraint ::= "LITERAL" xsFacet* |
| 51 | + | nonLiteralKind stringFacet* |
125 | 52 | | datatype xsFacet* |
126 | 53 | | valueSet xsFacet* |
127 | 54 | | numericFacet+ |
|
137 | 64 | [31] numericRange ::= "MININCLUSIVE" | "MINEXCLUSIVE" | "MAXINCLUSIVE" | "MAXEXCLUSIVE" |
138 | 65 | [32] numericLength ::= "TOTALDIGITS" | "FRACTIONDIGITS" |
139 | 66 |
|
140 | | -[33] shapeDefinition ::= (includeSet | extraPropertySet | "CLOSED")* '{' tripleExpression? '}' annotation* semanticActions |
141 | | -[34] inlineShapeDefinition ::= (includeSet | extraPropertySet | "CLOSED")* '{' tripleExpression? '}' |
| 67 | +[33] shapeDefinition ::= (extraPropertySet | "CLOSED")* '{' tripleExpression? '}' annotation* semanticActions |
| 68 | +[34] inlineShapeDefinition ::= (extraPropertySet | "CLOSED")* '{' tripleExpression? '}' |
142 | 69 | [35] extraPropertySet ::= "EXTRA" predicate+ |
143 | 70 |
|
144 | 71 | [36] tripleExpression ::= oneOfTripleExpr |
145 | 72 |
|
146 | | -# First/First Conflicts on "&", "$", "(", "^", :RDF_TYPE , :IRIREF, :PNAME_LN and :PNAME_NS |
| 73 | +# oneOfTripleExpr and multiElementOneOf both start with groupTripleExpr |
147 | 74 | #[37] oneOfTripleExpr ::= groupTripleExpr | multiElementOneOf |
148 | 75 | #[38] multiElementOneOf ::= groupTripleExpr ('|' groupTripleExpr)+ |
149 | 76 | #[39] innerTripleExpr ::= multiElementGroup | multiElementOneOf |
150 | 77 | [37] oneOfTripleExpr ::= groupTripleExpr ('|' groupTripleExpr)* |
151 | 78 |
|
152 | | -# First/First Conflicts on "&", "$", "(", "^", :RDF_TYPE , :IRIREF, :PNAME_LN and :PNAME_NS |
153 | | -# First/Follow Conflict on ";" |
| 79 | +# singleElementGroup and multiElementGroup both start with unaryTripleExpr |
154 | 80 | #[40] groupTripleExpr ::= singleElementGroup | multiElementGroup |
155 | 81 | #[41] singleElementGroup ::= unaryTripleExpr ';'? |
156 | 82 | #[42] multiElementGroup ::= unaryTripleExpr (';' unaryTripleExpr)+ ';'? |
|
179 | 105 | [55] languageRange ::= LANGTAG ('~' languageExclusion*)? |
180 | 106 | [56] languageExclusion ::= '-' LANGTAG '~'? |
181 | 107 |
|
182 | | -[57] include ::= '&' shapeLabel |
| 108 | +[57] include ::= '&' tripleExprLabel |
183 | 109 |
|
184 | 110 | [58] annotation ::= '//' predicate (iri | literal) |
185 | 111 | [59] semanticActions ::= codeDecl* |
|
188 | 114 | [13t] literal ::= rdfLiteral | numericLiteral | booleanLiteral |
189 | 115 | [61] predicate ::= iri | RDF_TYPE |
190 | 116 | [62] datatype ::= iri |
191 | | -[63] shapeLabel ::= iri | blankNode |
192 | | -[16t] numericLiteral ::= INTEGER | DECIMAL | DOUBLE |
193 | | -[129s] rdfLiteral ::= langString | string ('^^' datatype)? |
| 117 | +[63] shapeExprLabel ::= iri | blankNode |
| 118 | +[64] tripleExprLabel ::= iri | blankNode |
| 119 | + |
| 120 | +[16t] numericLiteral ::= DOUBLE | DECIMAL | INTEGER |
| 121 | +[65] rdfLiteral ::= langString | string ('^^' datatype)? |
194 | 122 | [134s] booleanLiteral ::= 'true' | 'false' |
195 | | -[135s] string ::= STRING_LITERAL1 | STRING_LITERAL_LONG1 |
196 | | - | STRING_LITERAL2 | STRING_LITERAL_LONG2 |
197 | | -[66] langString ::= LANG_STRING_LITERAL1 | LANG_STRING_LITERAL_LONG1 |
| 123 | +[135s] string ::= STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2 |
| 124 | + | STRING_LITERAL1 | STRING_LITERAL2 |
| 125 | +[66] langString ::= LANG_STRING_LITERAL1 | LANG_STRING_LITERAL_LONG1 |
198 | 126 | | LANG_STRING_LITERAL2 | LANG_STRING_LITERAL_LONG2 |
199 | 127 | [136s] iri ::= IRIREF | prefixedName |
200 | 128 | [137s] prefixedName ::= PNAME_LN | PNAME_NS |
201 | 129 | [138s] blankNode ::= BLANK_NODE_LABEL |
202 | 130 |
|
203 | | -# Reserved for future use |
204 | | -#[65] includeSet ::= "&" (shapeLabel)+ |
205 | 131 | @terminals |
206 | 132 |
|
207 | 133 | [67] CODE ::= '{' ([^%\\] | '\\' [%\\] | UCHAR)* '%' '}' |
|
0 commit comments