shex 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -8
- data/VERSION +1 -1
- data/etc/doap.ttl +1 -1
- data/lib/shex.rb +11 -11
- data/lib/shex/algebra.rb +43 -33
- data/lib/shex/algebra/node_constraint.rb +12 -3
- data/lib/shex/algebra/not.rb +1 -1
- data/lib/shex/algebra/operator.rb +20 -13
- data/lib/shex/algebra/schema.rb +106 -33
- data/lib/shex/algebra/shape_expression.rb +1 -1
- data/lib/shex/algebra/stem.rb +46 -2
- data/lib/shex/algebra/stem_range.rb +70 -2
- data/lib/shex/extensions/extension.rb +2 -2
- data/lib/shex/meta.rb +4282 -2334
- data/lib/shex/parser.rb +223 -72
- data/lib/shex/shex_context.rb +67 -68
- data/lib/shex/terminals.rb +36 -21
- metadata +2 -2
data/lib/shex/shex_context.rb
CHANGED
@@ -1,83 +1,82 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
# frozen_string_literal: true
|
3
|
-
# This file generated automatically from
|
3
|
+
# This file generated automatically from http://www.w3.org/ns/shex.jsonld
|
4
4
|
require 'json/ld'
|
5
5
|
class JSON::LD::Context
|
6
|
-
add_preloaded("
|
6
|
+
add_preloaded("http://www.w3.org/ns/shex.jsonld") do
|
7
7
|
new(term_definitions: {
|
8
|
-
"Annotation" => TermDefinition.new("Annotation", id: "http://
|
9
|
-
"EachOf" => TermDefinition.new("EachOf", id: "http://
|
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
|
-
"inverse" => TermDefinition.new("inverse", id: "http://shex.io/ns/shex#inverse", type_mapping: "http://www.w3.org/2001/XMLSchema#boolean"),
|
42
|
-
"iri" => TermDefinition.new("iri", id: "http://shex.io/ns/shex#iri", simple: true),
|
8
|
+
"Annotation" => TermDefinition.new("Annotation", id: "http://www.w3.org/ns/shex#Annotation", simple: true),
|
9
|
+
"EachOf" => TermDefinition.new("EachOf", id: "http://www.w3.org/ns/shex#EachOf", simple: true),
|
10
|
+
"IriStem" => TermDefinition.new("IriStem", id: "http://www.w3.org/ns/shex#IriStem", simple: true),
|
11
|
+
"LanguageStem" => TermDefinition.new("LanguageStem", id: "http://www.w3.org/ns/shex#LanguageStem", simple: true),
|
12
|
+
"LiteralStem" => TermDefinition.new("LiteralStem", id: "http://www.w3.org/ns/shex#LiteralStem", simple: true),
|
13
|
+
"NodeConstraint" => TermDefinition.new("NodeConstraint", id: "http://www.w3.org/ns/shex#NodeConstraint", simple: true),
|
14
|
+
"NodeKind" => TermDefinition.new("NodeKind", id: "http://www.w3.org/ns/shex#NodeKind", simple: true),
|
15
|
+
"OneOf" => TermDefinition.new("OneOf", id: "http://www.w3.org/ns/shex#OneOf", simple: true),
|
16
|
+
"Schema" => TermDefinition.new("Schema", id: "http://www.w3.org/ns/shex#Schema", simple: true),
|
17
|
+
"SemAct" => TermDefinition.new("SemAct", id: "http://www.w3.org/ns/shex#SemAct", simple: true),
|
18
|
+
"Shape" => TermDefinition.new("Shape", id: "http://www.w3.org/ns/shex#Shape", simple: true),
|
19
|
+
"ShapeAnd" => TermDefinition.new("ShapeAnd", id: "http://www.w3.org/ns/shex#ShapeAnd", simple: true),
|
20
|
+
"ShapeExpression" => TermDefinition.new("ShapeExpression", id: "http://www.w3.org/ns/shex#ShapeExpression", simple: true),
|
21
|
+
"ShapeExternal" => TermDefinition.new("ShapeExternal", id: "http://www.w3.org/ns/shex#ShapeExternal", simple: true),
|
22
|
+
"ShapeNot" => TermDefinition.new("ShapeNot", id: "http://www.w3.org/ns/shex#ShapeNot", simple: true),
|
23
|
+
"ShapeOr" => TermDefinition.new("ShapeOr", id: "http://www.w3.org/ns/shex#ShapeOr", simple: true),
|
24
|
+
"Stem" => TermDefinition.new("Stem", id: "http://www.w3.org/ns/shex#Stem", simple: true),
|
25
|
+
"StemRange" => TermDefinition.new("StemRange", id: "http://www.w3.org/ns/shex#StemRange", simple: true),
|
26
|
+
"TripleConstraint" => TermDefinition.new("TripleConstraint", id: "http://www.w3.org/ns/shex#TripleConstraint", simple: true),
|
27
|
+
"TripleExpression" => TermDefinition.new("TripleExpression", id: "http://www.w3.org/ns/shex#TripleExpression", simple: true),
|
28
|
+
"Wildcard" => TermDefinition.new("Wildcard", id: "http://www.w3.org/ns/shex#Wildcard", simple: true),
|
29
|
+
"annotation" => TermDefinition.new("annotation", id: "http://www.w3.org/ns/shex#annotation", type_mapping: "@id"),
|
30
|
+
"annotations" => TermDefinition.new("annotations", id: "http://www.w3.org/ns/shex#annotation", type_mapping: "@id"),
|
31
|
+
"bnode" => TermDefinition.new("bnode", id: "http://www.w3.org/ns/shex#bnode", simple: true),
|
32
|
+
"closed" => TermDefinition.new("closed", id: "http://www.w3.org/ns/shex#closed", type_mapping: "http://www.w3.org/2001/XMLSchema#boolean"),
|
33
|
+
"code" => TermDefinition.new("code", id: "http://www.w3.org/ns/shex#code"),
|
34
|
+
"datatype" => TermDefinition.new("datatype", id: "http://www.w3.org/ns/shex#datatype", type_mapping: "@id"),
|
35
|
+
"exclusion" => TermDefinition.new("exclusion", id: "http://www.w3.org/ns/shex#exclusion", type_mapping: "@id"),
|
36
|
+
"exclusions" => TermDefinition.new("exclusions", id: "http://www.w3.org/ns/shex#exclusion", type_mapping: "@id"),
|
37
|
+
"expression" => TermDefinition.new("expression", id: "http://www.w3.org/ns/shex#expression", type_mapping: "@id"),
|
38
|
+
"expressions" => TermDefinition.new("expressions", id: "http://www.w3.org/ns/shex#expressions", type_mapping: "@id", container_mapping: "@list"),
|
39
|
+
"extra" => TermDefinition.new("extra", id: "http://www.w3.org/ns/shex#extra", type_mapping: "@id"),
|
40
|
+
"fractiondigits" => TermDefinition.new("fractiondigits", id: "http://www.w3.org/ns/shex#fractiondigits", type_mapping: "http://www.w3.org/2001/XMLSchema#integer"),
|
43
41
|
"id" => TermDefinition.new("id", id: "@id", simple: true),
|
42
|
+
"inverse" => TermDefinition.new("inverse", id: "http://www.w3.org/ns/shex#inverse", type_mapping: "http://www.w3.org/2001/XMLSchema#boolean"),
|
43
|
+
"iri" => TermDefinition.new("iri", id: "http://www.w3.org/ns/shex#iri", simple: true),
|
44
44
|
"language" => TermDefinition.new("language", id: "@language", simple: true),
|
45
|
-
"length" => TermDefinition.new("length", id: "http://
|
46
|
-
"literal" => TermDefinition.new("literal", id: "http://
|
47
|
-
"max" => TermDefinition.new("max", id: "http://
|
48
|
-
"maxexclusive" => TermDefinition.new("maxexclusive", id: "http://
|
49
|
-
"maxinclusive" => TermDefinition.new("maxinclusive", id: "http://
|
50
|
-
"maxlength" => TermDefinition.new("maxlength", id: "http://
|
51
|
-
"min" => TermDefinition.new("min", id: "http://
|
52
|
-
"minexclusive" => TermDefinition.new("minexclusive", id: "http://
|
53
|
-
"mininclusive" => TermDefinition.new("mininclusive", id: "http://
|
54
|
-
"minlength" => TermDefinition.new("minlength", id: "http://
|
55
|
-
"name" => TermDefinition.new("name", id: "http://
|
56
|
-
"nodeKind" => TermDefinition.new("nodeKind", id: "http://
|
57
|
-
"nonliteral" => TermDefinition.new("nonliteral", id: "http://
|
58
|
-
"numericFacet" => TermDefinition.new("numericFacet", id: "http://
|
59
|
-
"object" => TermDefinition.new("object", id: "http://
|
60
|
-
"pattern" => TermDefinition.new("pattern", id: "http://
|
61
|
-
"predicate" => TermDefinition.new("predicate", id: "http://
|
45
|
+
"length" => TermDefinition.new("length", id: "http://www.w3.org/ns/shex#length", type_mapping: "http://www.w3.org/2001/XMLSchema#integer"),
|
46
|
+
"literal" => TermDefinition.new("literal", id: "http://www.w3.org/ns/shex#literal", simple: true),
|
47
|
+
"max" => TermDefinition.new("max", id: "http://www.w3.org/ns/shex#max", type_mapping: "http://www.w3.org/2001/XMLSchema#integer"),
|
48
|
+
"maxexclusive" => TermDefinition.new("maxexclusive", id: "http://www.w3.org/ns/shex#maxexclusive", type_mapping: "http://www.w3.org/2001/XMLSchema#integer"),
|
49
|
+
"maxinclusive" => TermDefinition.new("maxinclusive", id: "http://www.w3.org/ns/shex#maxinclusive", type_mapping: "http://www.w3.org/2001/XMLSchema#integer"),
|
50
|
+
"maxlength" => TermDefinition.new("maxlength", id: "http://www.w3.org/ns/shex#maxlength", type_mapping: "http://www.w3.org/2001/XMLSchema#integer"),
|
51
|
+
"min" => TermDefinition.new("min", id: "http://www.w3.org/ns/shex#min", type_mapping: "http://www.w3.org/2001/XMLSchema#integer"),
|
52
|
+
"minexclusive" => TermDefinition.new("minexclusive", id: "http://www.w3.org/ns/shex#minexclusive", type_mapping: "http://www.w3.org/2001/XMLSchema#integer"),
|
53
|
+
"mininclusive" => TermDefinition.new("mininclusive", id: "http://www.w3.org/ns/shex#mininclusive", type_mapping: "http://www.w3.org/2001/XMLSchema#integer"),
|
54
|
+
"minlength" => TermDefinition.new("minlength", id: "http://www.w3.org/ns/shex#minlength", type_mapping: "http://www.w3.org/2001/XMLSchema#integer"),
|
55
|
+
"name" => TermDefinition.new("name", id: "http://www.w3.org/ns/shex#name", type_mapping: "@id"),
|
56
|
+
"nodeKind" => TermDefinition.new("nodeKind", id: "http://www.w3.org/ns/shex#nodeKind", type_mapping: "@vocab"),
|
57
|
+
"nonliteral" => TermDefinition.new("nonliteral", id: "http://www.w3.org/ns/shex#nonliteral", simple: true),
|
58
|
+
"numericFacet" => TermDefinition.new("numericFacet", id: "http://www.w3.org/ns/shex#numericFacet"),
|
59
|
+
"object" => TermDefinition.new("object", id: "http://www.w3.org/ns/shex#object", type_mapping: "@id"),
|
60
|
+
"pattern" => TermDefinition.new("pattern", id: "http://www.w3.org/ns/shex#pattern"),
|
61
|
+
"predicate" => TermDefinition.new("predicate", id: "http://www.w3.org/ns/shex#predicate", type_mapping: "@id"),
|
62
62
|
"rdf" => TermDefinition.new("rdf", id: "http://www.w3.org/1999/02/22-rdf-syntax-ns#", simple: true),
|
63
63
|
"rdfs" => TermDefinition.new("rdfs", id: "http://www.w3.org/2000/01/rdf-schema#", simple: true),
|
64
|
-
"
|
65
|
-
"
|
66
|
-
"
|
67
|
-
"
|
68
|
-
"
|
69
|
-
"
|
70
|
-
"
|
71
|
-
"
|
72
|
-
"
|
73
|
-
"
|
74
|
-
"totaldigits" => TermDefinition.new("totaldigits", id: "http://shex.io/ns/shex#totaldigits", type_mapping: "http://www.w3.org/2001/XMLSchema#integer"),
|
64
|
+
"semActs" => TermDefinition.new("semActs", id: "http://www.w3.org/ns/shex#semActs", type_mapping: "@id", container_mapping: "@list"),
|
65
|
+
"shapeExpr" => TermDefinition.new("shapeExpr", id: "http://www.w3.org/ns/shex#shapeExpr", type_mapping: "@id"),
|
66
|
+
"shapeExprs" => TermDefinition.new("shapeExprs", id: "http://www.w3.org/ns/shex#shapeExprs", type_mapping: "@id", container_mapping: "@list"),
|
67
|
+
"shapes" => TermDefinition.new("shapes", id: "http://www.w3.org/ns/shex#shapes", type_mapping: "@id"),
|
68
|
+
"shex" => TermDefinition.new("shex", id: "http://www.w3.org/ns/shex#", simple: true),
|
69
|
+
"start" => TermDefinition.new("start", id: "http://www.w3.org/ns/shex#start", type_mapping: "@id"),
|
70
|
+
"startActs" => TermDefinition.new("startActs", id: "http://www.w3.org/ns/shex#startActs", type_mapping: "@id", container_mapping: "@list"),
|
71
|
+
"stem" => TermDefinition.new("stem", id: "http://www.w3.org/ns/shex#stem", type_mapping: "http://www.w3.org/2001/XMLSchema#anyUri"),
|
72
|
+
"stringFacet" => TermDefinition.new("stringFacet", id: "http://www.w3.org/ns/shex#stringFacet"),
|
73
|
+
"totaldigits" => TermDefinition.new("totaldigits", id: "http://www.w3.org/ns/shex#totaldigits", type_mapping: "http://www.w3.org/2001/XMLSchema#integer"),
|
75
74
|
"type" => TermDefinition.new("type", id: "@type", simple: true),
|
76
75
|
"uri" => TermDefinition.new("uri", id: "@id", simple: true),
|
77
76
|
"value" => TermDefinition.new("value", id: "@value", simple: true),
|
78
|
-
"valueExpr" => TermDefinition.new("valueExpr", id: "http://
|
79
|
-
"values" => TermDefinition.new("values", id: "http://
|
80
|
-
"xsFacet" => TermDefinition.new("xsFacet", id: "http://
|
77
|
+
"valueExpr" => TermDefinition.new("valueExpr", id: "http://www.w3.org/ns/shex#valueExpr", type_mapping: "@id"),
|
78
|
+
"values" => TermDefinition.new("values", id: "http://www.w3.org/ns/shex#values", type_mapping: "@id", container_mapping: "@list"),
|
79
|
+
"xsFacet" => TermDefinition.new("xsFacet", id: "http://www.w3.org/ns/shex#xsFacet"),
|
81
80
|
"xsd" => TermDefinition.new("xsd", id: "http://www.w3.org/2001/XMLSchema#", simple: true)
|
82
81
|
})
|
83
82
|
end
|
data/lib/shex/terminals.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
1
2
|
require 'ebnf/ll1/lexer'
|
2
3
|
|
3
4
|
module ShEx
|
@@ -15,8 +16,10 @@ module ShEx
|
|
15
16
|
U_CHARS2 = Regexp.compile("\\u00B7|[\\u0300-\\u036F]|[\\u203F-\\u2040]").freeze
|
16
17
|
IRI_RANGE = Regexp.compile("[[^<>\"{}|^`\\\\]&&[^\\x00-\\x20]]").freeze
|
17
18
|
|
18
|
-
#
|
19
|
-
|
19
|
+
# 87
|
20
|
+
UCHAR4 = /\\u([0-9A-Fa-f]{4,4})/.freeze
|
21
|
+
UCHAR8 = /\\U([0-9A-Fa-f]{8,8})/.freeze
|
22
|
+
UCHAR = Regexp.union(UCHAR4, UCHAR8).freeze
|
20
23
|
# 171s
|
21
24
|
PERCENT = /%\h\h/.freeze
|
22
25
|
# 173s
|
@@ -42,49 +45,61 @@ module ShEx
|
|
42
45
|
|
43
46
|
WS = /(?:\s|(?:#[^\n\r]*))+/m.freeze
|
44
47
|
|
45
|
-
#
|
48
|
+
# 69
|
46
49
|
RDF_TYPE = /a/.freeze
|
47
50
|
# 18t
|
48
51
|
IRIREF = /<(?:#{IRI_RANGE}|#{UCHAR})*>/.freeze
|
49
|
-
#
|
52
|
+
# 73
|
50
53
|
PNAME_NS = /#{PN_PREFIX}?:/.freeze
|
51
|
-
#
|
54
|
+
# 74
|
52
55
|
PNAME_LN = /#{PNAME_NS}#{PN_LOCAL}/.freeze
|
53
|
-
#
|
56
|
+
# 75
|
54
57
|
ATPNAME_NS = /@#{WS}*#{PN_PREFIX}?:/m.freeze
|
55
|
-
#
|
58
|
+
# 76
|
56
59
|
ATPNAME_LN = /@#{WS}*#{PNAME_NS}#{PN_LOCAL}/m.freeze
|
57
|
-
#
|
60
|
+
# 77
|
58
61
|
BLANK_NODE_LABEL = /_:(?:\d|#{PN_CHARS_U})(?:(?:#{PN_CHARS}|\.)*#{PN_CHARS})?/.freeze
|
59
|
-
#
|
62
|
+
# 78
|
60
63
|
LANGTAG = /@[a-zA-Z]+(?:-[a-zA-Z0-9]+)*/.freeze
|
61
|
-
#
|
64
|
+
# 79
|
62
65
|
INTEGER = /[+-]?\d+/.freeze
|
63
|
-
#
|
66
|
+
# 80
|
64
67
|
DECIMAL = /[+-]?(?:\d*\.\d+)/.freeze
|
65
|
-
#
|
68
|
+
# 81
|
66
69
|
DOUBLE = /[+-]?(?:\d+\.\d*#{EXPONENT}|\.?\d+#{EXPONENT})/.freeze
|
67
|
-
#
|
70
|
+
# 83
|
68
71
|
STRING_LITERAL1 = /'(?:[^\'\\\n\r]|#{ECHAR}|#{UCHAR})*'/.freeze
|
69
|
-
#
|
72
|
+
# 84
|
70
73
|
STRING_LITERAL2 = /"(?:[^\"\\\n\r]|#{ECHAR}|#{UCHAR})*"/.freeze
|
71
|
-
#
|
74
|
+
# 85
|
72
75
|
STRING_LITERAL_LONG1 = /'''(?:(?:'|'')?(?:[^'\\]|#{ECHAR}|#{UCHAR}))*'''/m.freeze
|
73
|
-
#
|
76
|
+
# 86
|
74
77
|
STRING_LITERAL_LONG2 = /"""(?:(?:"|"")?(?:[^"\\]|#{ECHAR}|#{UCHAR}))*"""/m.freeze
|
75
78
|
|
76
|
-
#
|
79
|
+
# 83l
|
80
|
+
LANG_STRING_LITERAL1 = /'(?:[^\'\\\n\r]|#{ECHAR}|#{UCHAR})*'#{LANGTAG}/.freeze
|
81
|
+
# 84l
|
82
|
+
LANG_STRING_LITERAL2 = /"(?:[^\"\\\n\r]|#{ECHAR}|#{UCHAR})*"#{LANGTAG}/.freeze
|
83
|
+
# 85l
|
84
|
+
LANG_STRING_LITERAL_LONG1 = /'''(?:(?:'|'')?(?:[^'\\]|#{ECHAR}|#{UCHAR}))*'''#{LANGTAG}/m.freeze
|
85
|
+
# 86l
|
86
|
+
LANG_STRING_LITERAL_LONG2 = /"""(?:(?:"|"")?(?:[^"\\]|#{ECHAR}|#{UCHAR}))*"""#{LANGTAG}/m.freeze
|
87
|
+
|
88
|
+
# XX
|
89
|
+
REGEXP = %r(/(?:[^/\\\n\r]|\\[nrt\\|.?*+(){}$-\[\]^/]|#{UCHAR})+/[smix]*).freeze
|
90
|
+
|
91
|
+
# 68
|
77
92
|
CODE = /\{(?:[^%\\]|\\[%\\]|#{UCHAR})*%#{WS}*\}/m.freeze
|
78
|
-
#
|
93
|
+
# 70
|
79
94
|
REPEAT_RANGE = /\{\s*#{INTEGER}(?:,#{WS}*(?:#{INTEGER}|\*)?)?#{WS}*\}/.freeze
|
80
95
|
|
81
96
|
# String terminals, mixed case sensitivity
|
82
97
|
STR_EXPR = %r(true|false
|
83
98
|
|\^\^|\/\/
|
84
|
-
|[\(\)\{\}\[\]
|
99
|
+
|[\(\)\{\}\[\],\.;\=\-\~!\|\&\@\$\?\+\*\%\^a]|
|
85
100
|
(?i:OR|AND|NOT
|
86
101
|
|BASE|PREFIX
|
87
|
-
|IRI|BNODE|NONLITERAL
|
102
|
+
|IRI|BNODE|NONLITERAL
|
88
103
|
|MINLENGTH|MAXLENGTH|LENGTH
|
89
104
|
|MAXINCLUSIVE|MAXEXCLUSIVE
|
90
105
|
|MININCLUSIVE|MINEXCLUSIVE
|
@@ -95,7 +110,7 @@ module ShEx
|
|
95
110
|
)x.freeze
|
96
111
|
|
97
112
|
# Map terminals to canonical form
|
98
|
-
STR_MAP = %w{OR AND NOT BASE PREFIX IRI BNODE NONLITERAL
|
113
|
+
STR_MAP = %w{OR AND NOT BASE PREFIX IRI BNODE NONLITERAL
|
99
114
|
MINLENGTH MAXLENGTH LENGTH MININCLUSIVE MAXINCLUSIVE MINEXCLUSIVE MAXEXCLUSIVE
|
100
115
|
TOTALDIGITS FRACTIONDIGITS START EXTERNAL CLOSED EXTRA LITERAL}.
|
101
116
|
inject({}) do |memo, t|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|