Skip to content

Commit

Permalink
~ update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Prud'hommeaux committed Sep 11, 2016
1 parent a20e3f8 commit 9e4f633
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 197 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Grammar-based description and validation of JSON structures.",
"main": "index.js",
"scripts": {
"test": "testsCommand"
"test": "mocha"
},
"repository": {
"type": "git",
Expand Down
58 changes: 32 additions & 26 deletions test/ShExJ.jsg
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
schema { prefixes:{PREFIX->IRI}? valueExprDefns:{IRI->valueExprDefn}? startActs:[semAct]? start:shapeLabel? shapes:{shapeLabel->shape}? }
shape { virtual:BOOL? closed:BOOL? extra:[IRI]? expression:expr? inherit:[shapeLabel]? semActs:[semAct]? }
semAct { name:IRI code:STRING }
expr = eachOf | someOf | tripleConstraint | inclusion ;
eachOf { expressions:[expr] min:INTEGER? max:(INTEGER|"*")? semActs:[semAct]? annotations:[annotation]? }
someOf { expressions:[expr] min:INTEGER? max:(INTEGER|"*")? semActs:[semAct]? annotations:[annotation]? }
inclusion { include:shapeLabel }
# tripleConstraint { inverse:BOOL? negated:BOOL? predicate:IRI (valueExpr:valueClass|valueClassRef:valueClassLabel) min:INTEGER? max:(INTEGER|"*")? semActs:[semAct]? annotations:[annotation]? }
tripleConstraint { inverse:BOOL? negated:BOOL? predicate:IRI valueExpr:valueExpr min:INTEGER? max:(INTEGER|"*")? semActs:[semAct]? annotations:[annotation]? }
valueExprDefn { valueExpr:valueExpr semActs:[semAct]? annotations:[annotation]? }
valueClassOrRef = valueClass | vcref ;
valueExpr = valueClassOrRef | vcor | vcand ;
valueClass { nodeKind:"literal" xsFacet*
| nodeKind:("iri"|"bnode"|"nonliteral") reference:shapeLabel? stringFacet*
| datatype:IRI xsFacet*
| reference:shapeLabel stringFacet*
| values:[valueSetValue]
| } # empty
vcref { valueExprRef:shapeLabel }
vcor { valueExprs:[valueClassOrRef] }
vcand { valueExprs:[valueClassOrRef] }
# and { disjuncts:[expr] }
annotation { predicate:IRI object:IRI }
# This is a JSON Grammar (JSG) file for the ShEx JSON format.
# The form "OBJNAME { property:PROPTYPE ... }" matches an object of type OBJTYPE
# The form "RULENAME = NAME1 | NAME2 ..." matches any of NAMEn.
# the form "TERMNAME : "RegExp" matches any literal matching RegExp
# A PROPETYPE can be:
# TERMINAL - a terminal, all caps in this example.
# [PROPTYPE] - an array of PROPTYPE.
# {TERMINAL->PROPTYPE} - a map from TERMINAL to PROPTYPE.
# (PROPTYPE1|PROPTYPE2...) - any of PROPTYPEn.

.TYPE type; # All objects have a type property corresponding to the production name, e.g. "Schema"

Schema { prefixes:{PREFIX->IRI}? base:IRI? startActs:[SemAct]? start:shapeExpr? shapes:{shapeLabel->shapeExpr}? }
shapeExpr = ShapeOr | ShapeAnd | ShapeNot | NodeConstraint | Shape | ShapeRef | ShapeExternal;
ShapeAnd { shapeExprs:[shapeExpr] }
ShapeOr { shapeExprs:[shapeExpr] }
ShapeNot { shapeExpr:shapeExpr }
Shape { virtual:BOOL? closed:BOOL? extra:[IRI]? expression:tripleExpr? inherit:[shapeLabel]? semActs:[SemAct]? }
ShapeExternal { }
ShapeRef { reference:IRI } # should be a TERM or some such
SemAct { name:IRI code:STRING? }
tripleExpr = EachOf | SomeOf | TripleConstraint | Inclusion ;
EachOf { expressions:[tripleExpr] min:INTEGER? max:(INTEGER|"*")? semActs:[SemAct]? annotations:[Annotation]? }
SomeOf { expressions:[tripleExpr] min:INTEGER? max:(INTEGER|"*")? semActs:[SemAct]? annotations:[Annotation]? }
Inclusion { include:shapeLabel }
TripleConstraint { inverse:BOOL? negated:BOOL? predicate:IRI valueExpr:shapeExpr? min:INTEGER? max:(INTEGER|"*")? semActs:[SemAct]? annotations:[Annotation]? }
NodeConstraint { nodeKind:("iri"|"bnode"|"nonliteral"|"literal")? datatype:IRI? xsFacet* values:[valueSetValue]? }
Annotation { predicate:IRI object:IRI }

xsFacet = stringFacet | numericFacet ;
stringFacet = (length|minlength|maxlength):INTEGER | pattern:STRING ;
numericFacet = (mininclusive|minexclusive|maxinclusive|maxexclusive):numericLiteral
| (totaldigits|fractiondigits):INTEGER ;
valueClassLabel = IRI|BNODE ;
shapeLabel = IRI|BNODE ;
numericLiteral = INTEGER|DECIMAL|DOUBLE ;
valueSetValue = IRI|STRING|DATATYPE_STRING|LANG_STRING|stemRange ;
stemRange { stem:IRI exclusions:[stemRange] }
valueSetValue = IRI|STRING|DATATYPE_STRING|LANG_STRING|Stem|StemRange ;
Stem { stem:IRI } # !! obselete -- use StemRange
StemRange { stem:(IRI|Wildcard) exclusions:[valueSetValue]? }
Wildcard { }

PREFIX : "^.*$" # <http://www.w3.org/TR/turtle/#grammar-production-PNAME_NS>
IRI : "^.*$" # <http://www.w3.org/TR/turtle/#grammar-production-IRIREF>
Expand Down
Loading

0 comments on commit 9e4f633

Please sign in to comment.