-
Notifications
You must be signed in to change notification settings - Fork 1
/
shaclc-grammar.ebnf
113 lines (95 loc) · 5.47 KB
/
shaclc-grammar.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
/* SHACL Compact (SHACLC) https://w3c.github.io/shacl/shacl-compact-syntax/ */
shaclDoc ::= directive* (nodeShape|shapeClass)*
directive ::= baseDecl | importsDecl | prefixDecl
baseDecl ::= KW_BASE IRIREF
importsDecl ::= KW_IMPORTS IRIREF
prefixDecl ::= KW_PREFIX PNAME_NS IRIREF
nodeShape ::= KW_SHAPE iri targetClass? nodeShapeBody
shapeClass ::= KW_SHAPE_CLASS iri nodeShapeBody
nodeShapeBody ::= '{' constraint* '}'
targetClass ::= '->' iri+
constraint ::= ( nodeOr+ | propertyShape ) '.'
nodeOr ::= nodeNot ( '|' nodeNot) *
nodeNot ::= negation? nodeValue
nodeValue ::= nodeParam '=' iriOrLiteralOrArray
propertyShape ::= path ( propertyCount | propertyOr )*
propertyOr ::= propertyNot ( '|' propertyNot) *
propertyNot ::= negation? propertyAtom
propertyAtom ::= propertyType | nodeKind | shapeRef | propertyValue | nodeShapeBody
propertyCount ::= '[' propertyMinCount '..' propertyMaxCount ']'
propertyMinCount ::= INTEGER
propertyMaxCount ::= (INTEGER | '*')
propertyType ::= iri
nodeKind ::= 'BlankNode' | 'IRI' | 'Literal' | 'BlankNodeOrIRI' | 'BlankNodeOrLiteral' | 'IRIOrLiteral'
shapeRef ::= ATPNAME_LN | ATPNAME_NS | '@' IRIREF
propertyValue ::= propertyParam '=' iriOrLiteralOrArray
negation ::= '!'
path ::= pathAlternative
pathAlternative ::= pathSequence ( '|' pathSequence )*
pathSequence ::= pathEltOrInverse ( '/' pathEltOrInverse )*
pathElt ::= pathPrimary pathMod?
pathEltOrInverse ::= pathElt | pathInverse pathElt
pathInverse ::= '^'
pathMod ::= '?' | '*' | '+'
pathPrimary ::= iri | '(' path ')'
iriOrLiteralOrArray::= iriOrLiteral | array
iriOrLiteral ::= iri | literal
iri ::= IRIREF | prefixedName
prefixedName ::= PNAME_LN | PNAME_NS
literal ::= rdfLiteral | numericLiteral | booleanLiteral
booleanLiteral ::= KW_TRUE | KW_FALSE
numericLiteral ::= INTEGER | DECIMAL | DOUBLE
rdfLiteral ::= string (LANGTAG | '^^' datatype)?
datatype ::= iri
string ::= STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2 | STRING_LITERAL1 | STRING_LITERAL2
array ::= '[' iriOrLiteral* ']'
nodeParam ::= 'targetNode' | 'targetObjectsOf' | 'targetSubjectsOf' |
'deactivated' | 'severity' | 'message' |
'class' | 'datatype' | 'nodeKind' |
'minExclusive' | 'minInclusive' | 'maxExclusive' | 'maxInclusive' |
'minLength' | 'maxLength' | 'pattern' | 'flags' | 'languageIn' |
'equals' | 'disjoint' |
'closed' | 'ignoredProperties' | 'hasValue' | 'in'
propertyParam ::= 'deactivated' | 'severity' | 'message' |
'class' | 'datatype' | 'nodeKind' |
'minExclusive' | 'minInclusive' | 'maxExclusive' | 'maxInclusive' |
'minLength' | 'maxLength' | 'pattern' | 'flags' | 'languageIn' | 'uniqueLang' |
'equals' | 'disjoint' | 'lessThan' | 'lessThanOrEquals' |
'qualifiedValueShape' | 'qualifiedMinCount' | 'qualifiedMaxCount' | 'qualifiedValueShapesDisjoint' |
'closed' | 'ignoredProperties' | 'hasValue' | 'in'
// Keywords
KW_BASE ::= 'BASE'
KW_IMPORTS ::= 'IMPORTS'
KW_PREFIX ::= 'PREFIX'
KW_SHAPE_CLASS ::= 'shapeClass'
KW_SHAPE ::= 'shape'
KW_TRUE ::= 'true'
KW_FALSE ::= 'false'
// Terminals
COMMENT ::= '#' [^\r\n]*
IRIREF ::= '<' ([^#x0000-#x0020=<>\"{}|^`\\] | UCHAR)* '>'
PNAME_NS ::= PN_PREFIX? ':'
PNAME_LN ::= PNAME_NS PN_LOCAL
ATPNAME_NS ::= '@' PN_PREFIX? ':'
ATPNAME_LN ::= '@' PNAME_NS PN_LOCAL
LANGTAG ::= '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)*
INTEGER ::= [+-]? [0-9]+
DECIMAL ::= [+-]? [0-9]* '.' [0-9]+
DOUBLE ::= [+-]? ([0-9]+ '.' [0-9]* EXPONENT | '.'? [0-9]+ EXPONENT)
EXPONENT ::= [eE] [+-]? [0-9]+
STRING_LITERAL1 ::= "'" ([^#x0027#x005C#x000A#x000D] | ECHAR | UCHAR)* "'"
STRING_LITERAL2 ::= '"' ([^#x0022#x005C#x000A#x000D] | ECHAR | UCHAR)* '"'
STRING_LITERAL_LONG1 ::= "'''" (("'" | "''")? ([^\'\\] | ECHAR | UCHAR))* "'''"
STRING_LITERAL_LONG2 ::= '"""' (('"' | '""')? ([^\"\\] | ECHAR | UCHAR))* '"""'
UCHAR ::= '\\u' HEX HEX HEX HEX | '\\U' HEX HEX HEX HEX HEX HEX HEX HEX
ECHAR ::= '\\' [tbnrf\\\"\']
WS ::= [#x0020#x0009#x000D#x000A]
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]
PN_CHARS_U ::= PN_CHARS_BASE | '_'
PN_CHARS ::= PN_CHARS_U | '-' | [0-9] | [#x00B7] | [#x0300-#x036F] | [#x203F-#x2040]
PN_PREFIX ::= PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)?
PN_LOCAL ::= (PN_CHARS_U | ':' | [0-9] | PLX) ((PN_CHARS | '.' | ':' | PLX)* (PN_CHARS | ':' | PLX))?
PLX ::= PERCENT | PN_LOCAL_ESC
PERCENT ::= '%' HEX HEX
HEX ::= [0-9] | [A-F] | [a-f]
PN_LOCAL_ESC ::= '\\' ('_' | '~' | '.' | '-' | '!' | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%')