Skip to content

Commit bc4d9bf

Browse files
committed
create shacl12-compact-syntax
1 parent bf3e332 commit bc4d9bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1010
-0
lines changed

shacl12-compact-syntax/SHACLC.g4

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
grammar SHACLC;
2+
3+
shaclDoc : directive* (nodeShape|shapeClass)* EOF;
4+
5+
directive : baseDecl | importsDecl | prefixDecl ;
6+
baseDecl : KW_BASE IRIREF ;
7+
importsDecl : KW_IMPORTS IRIREF ;
8+
prefixDecl : KW_PREFIX PNAME_NS IRIREF ;
9+
10+
shapeClass : KW_SHAPE_CLASS iri nodeShapeBody ;
11+
nodeShape : KW_SHAPE iri targetClass? nodeShapeBody ;
12+
nodeShapeBody : '{' constraint* '}';
13+
targetClass : '->' iri+ ;
14+
15+
constraint : ( nodeOr+ | propertyShape ) '.' ;
16+
nodeOr : nodeNot ( '|' nodeNot) * ;
17+
nodeNot : negation? nodeValue ;
18+
nodeValue : nodeParam '=' iriOrLiteralOrArray ;
19+
20+
propertyShape : path ( propertyCount | propertyOr )* ;
21+
propertyOr : propertyNot ( '|' propertyNot) * ;
22+
propertyNot : negation? propertyAtom ;
23+
propertyAtom : propertyType | nodeKind | shapeRef | propertyValue | nodeShapeBody ;
24+
propertyCount : '[' propertyMinCount '..' propertyMaxCount ']' ;
25+
propertyMinCount : INTEGER ;
26+
propertyMaxCount : (INTEGER | '*') ;
27+
propertyType : iri ;
28+
nodeKind : 'BlankNode' | 'IRI' | 'Literal' | 'BlankNodeOrIRI' | 'BlankNodeOrLiteral' | 'IRIOrLiteral' ;
29+
shapeRef : ATPNAME_LN | ATPNAME_NS | '@' IRIREF ;
30+
propertyValue : propertyParam '=' iriOrLiteralOrArray ;
31+
negation : '!' ;
32+
33+
path : pathAlternative ;
34+
pathAlternative : pathSequence ( '|' pathSequence )* ;
35+
pathSequence : pathEltOrInverse ( '/' pathEltOrInverse )* ;
36+
pathElt : pathPrimary pathMod? ;
37+
pathEltOrInverse : pathElt | pathInverse pathElt ;
38+
pathInverse : '^' ;
39+
pathMod : '?' | '*' | '+' ;
40+
pathPrimary : iri | '(' path ')' ;
41+
42+
iriOrLiteralOrArray : iriOrLiteral | array ;
43+
iriOrLiteral : iri | literal ;
44+
45+
iri : IRIREF | prefixedName ;
46+
prefixedName : PNAME_LN | PNAME_NS ;
47+
48+
literal : rdfLiteral | numericLiteral | booleanLiteral ;
49+
booleanLiteral : KW_TRUE | KW_FALSE ;
50+
numericLiteral : INTEGER | DECIMAL | DOUBLE ;
51+
rdfLiteral : string (LANGTAG | '^^' datatype)? ;
52+
datatype : iri ;
53+
string : STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2 | STRING_LITERAL1 | STRING_LITERAL2 ;
54+
55+
array : '[' iriOrLiteral* ']' ;
56+
57+
nodeParam : 'targetNode' | 'targetObjectsOf' | 'targetSubjectsOf' |
58+
'deactivated' | 'severity' | 'message' |
59+
'class' | 'datatype' | 'nodeKind' |
60+
'minExclusive' | 'minInclusive' | 'maxExclusive' | 'maxInclusive' |
61+
'minLength' | 'maxLength' | 'pattern' | 'flags' | 'languageIn' |
62+
'equals' | 'disjoint' |
63+
'closed' | 'ignoredProperties' | 'hasValue' | 'in' ;
64+
65+
propertyParam : 'deactivated' | 'severity' | 'message' |
66+
'class' | 'datatype' | 'nodeKind' |
67+
'minExclusive' | 'minInclusive' | 'maxExclusive' | 'maxInclusive' |
68+
'minLength' | 'maxLength' | 'pattern' | 'flags' | 'languageIn' | 'uniqueLang' |
69+
'equals' | 'disjoint' | 'lessThan' | 'lessThanOrEquals' |
70+
'qualifiedValueShape' | 'qualifiedMinCount' | 'qualifiedMaxCount' | 'qualifiedValueShapesDisjoint' |
71+
'closed' | 'ignoredProperties' | 'hasValue' | 'in' ;
72+
73+
// Keywords
74+
KW_BASE : 'BASE' ;
75+
KW_IMPORTS : 'IMPORTS' ;
76+
KW_PREFIX : 'PREFIX' ;
77+
78+
KW_SHAPE_CLASS : 'shapeClass' ;
79+
KW_SHAPE : 'shape' ;
80+
81+
KW_TRUE : 'true' ;
82+
KW_FALSE : 'false' ;
83+
84+
// Terminals
85+
PASS : [ \t\r\n]+ -> skip;
86+
COMMENT : '#' ~[\r\n]* -> skip;
87+
88+
IRIREF : '<' (~[\u0000-\u0020=<>\"{}|^`\\] | UCHAR)* '>' ;
89+
PNAME_NS : PN_PREFIX? ':' ;
90+
PNAME_LN : PNAME_NS PN_LOCAL ;
91+
ATPNAME_NS : '@' PN_PREFIX? ':' ;
92+
ATPNAME_LN : '@' PNAME_NS PN_LOCAL ;
93+
LANGTAG : '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)* ;
94+
INTEGER : [+-]? [0-9]+ ;
95+
DECIMAL : [+-]? [0-9]* '.' [0-9]+ ;
96+
DOUBLE : [+-]? ([0-9]+ '.' [0-9]* EXPONENT | '.'? [0-9]+ EXPONENT) ;
97+
fragment EXPONENT : [eE] [+-]? [0-9]+ ;
98+
STRING_LITERAL1 : '\'' (~[\u0027\u005C\u000A\u000D] | ECHAR | UCHAR)* '\'' ;
99+
STRING_LITERAL2 : '"' (~[\u0022\u005C\u000A\u000D] | ECHAR | UCHAR)* '"' ;
100+
STRING_LITERAL_LONG1: '\'\'\'' (('\'' | '\'\'')? (~[\'\\] | ECHAR | UCHAR))* '\'\'\'' ;
101+
STRING_LITERAL_LONG2: '"""' (('"' | '""')? (~[\"\\] | ECHAR | UCHAR))* '"""' ;
102+
fragment UCHAR : '\\u' HEX HEX HEX HEX | '\\U' HEX HEX HEX HEX HEX HEX HEX HEX ;
103+
fragment ECHAR : '\\' [tbnrf\\\"\'] ;
104+
fragment WS : [\u0020\u0009\u000D\u000A] ;
105+
fragment PN_CHARS_BASE: [A-Z] | [a-z] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u02FF] | [\u0370-\u037D]
106+
| [\u037F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF]
107+
| [\uF900-\uFDCF] | [\uFDF0-\uFFFD]
108+
;
109+
fragment PN_CHARS_U : PN_CHARS_BASE | '_' ;
110+
fragment PN_CHARS : PN_CHARS_U | '-' | [0-9] | [\u00B7] | [\u0300-\u036F] | [\u203F-\u2040] ;
111+
fragment PN_PREFIX : PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)? ;
112+
fragment PN_LOCAL : (PN_CHARS_U | ':' | [0-9] | PLX) ((PN_CHARS | '.' | ':' | PLX)* (PN_CHARS | ':' | PLX))? ;
113+
fragment PLX : PERCENT | PN_LOCAL_ESC ;
114+
fragment PERCENT : '%' HEX HEX ;
115+
fragment HEX : [0-9] | [A-F] | [a-f] ;
116+
fragment PN_LOCAL_ESC: '\\' ('_' | '~' | '.' | '-' | '!' | '$' | '&' | '\'' | '(' | ')' | '*' | '+' | ','
117+
| ';' | '=' | '/' | '?' | '#' | '@' | '%') ;

shacl12-compact-syntax/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>SHACL Compact Syntax</title>
5+
<meta charset="utf-8">
6+
</head>
7+
<body>
8+
<p>
9+
This Editors Draft is intentionally left blank.
10+
It is intended to overwrite the earlier editor's draft which documented a proposed design.
11+
That proposal did not reach consensus within the Working Group and should not be used.
12+
</p>
13+
<p>
14+
The definition of a SHACL Compact Syntax is being continued by the
15+
<a href="https://w3c.github.io/shacl/shacl-compact-syntax/">SHACL Community Group</a>.
16+
</p>
17+
</body>
18+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
BASE <http://example.org/array-in>
2+
3+
PREFIX ex: <http://example.org/test#>
4+
5+
shape ex:TestShape {
6+
ex:property in=[ex:Instance1 true "string" 42] .
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@base <http://example.org/array-in> .
2+
@prefix ex: <http://example.org/test#> .
3+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
4+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
5+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
6+
@prefix sh: <http://www.w3.org/ns/shacl#> .
7+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
8+
9+
<>
10+
a owl:Ontology ;
11+
.
12+
13+
ex:TestShape
14+
a sh:NodeShape ;
15+
sh:property [
16+
sh:path ex:property ;
17+
sh:in ( ex:Instance1 true "string" 42 ) ;
18+
] ;
19+
.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
BASE <http://example.org/basic-shape-iri>
2+
3+
shape <http://example.org/test#TestShape> {
4+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@base <http://example.org/basic-shape-iri> .
2+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
3+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
4+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
5+
@prefix sh: <http://www.w3.org/ns/shacl#> .
6+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
7+
8+
<http://example.org/basic-shape-iri>
9+
a owl:Ontology ;
10+
.
11+
12+
<http://example.org/test#TestShape>
13+
a sh:NodeShape ;
14+
.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
BASE <http://example.org/basic-shape-with-target>
2+
3+
PREFIX ex: <http://example.org/test#>
4+
5+
shape ex:TestShape -> ex:TestClass {
6+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@base <http://example.org/basic-shape-with-target> .
2+
@prefix ex: <http://example.org/test#> .
3+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
4+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
5+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
6+
@prefix sh: <http://www.w3.org/ns/shacl#> .
7+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
8+
9+
<http://example.org/basic-shape-with-target>
10+
a owl:Ontology ;
11+
.
12+
13+
ex:TestShape
14+
a sh:NodeShape ;
15+
sh:targetClass ex:TestClass ;
16+
.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
BASE <http://example.org/basic-shape-with-targets>
2+
3+
PREFIX ex: <http://example.org/test#>
4+
5+
shape ex:TestShape -> ex:TestClass1 ex:TestClass2 {
6+
targetNode=ex:TestNode targetSubjectsOf=ex:subjectProperty targetObjectsOf=ex:objectProperty .
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@base <http://example.org/basic-shape-with-targets> .
2+
@prefix ex: <http://example.org/test#> .
3+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
4+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
5+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
6+
@prefix sh: <http://www.w3.org/ns/shacl#> .
7+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
8+
9+
<http://example.org/basic-shape-with-targets>
10+
a owl:Ontology ;
11+
.
12+
13+
ex:TestShape
14+
a sh:NodeShape ;
15+
sh:targetClass ex:TestClass1, ex:TestClass2 ;
16+
sh:targetNode ex:TestNode ;
17+
sh:targetObjectsOf ex:objectProperty ;
18+
sh:targetSubjectsOf ex:subjectProperty ;
19+
.

0 commit comments

Comments
 (0)