sparql 3.1.5 → 3.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/VERSION +1 -1
- data/lib/sparql/algebra/expression.rb +4 -1
- data/lib/sparql/algebra/extensions.rb +8 -1
- data/lib/sparql/algebra/operator.rb +12 -0
- data/lib/sparql/algebra/operator/compare.rb +7 -0
- data/lib/sparql/algebra/operator/construct.rb +2 -1
- data/lib/sparql/algebra/operator/extend.rb +2 -12
- data/lib/sparql/algebra/operator/is_triple.rb +30 -0
- data/lib/sparql/algebra/operator/object.rb +27 -0
- data/lib/sparql/algebra/operator/predicate.rb +27 -0
- data/lib/sparql/algebra/operator/subject.rb +29 -0
- data/lib/sparql/algebra/operator/triple.rb +27 -0
- data/lib/sparql/grammar.rb +0 -25
- data/lib/sparql/grammar/meta.rb +3899 -1115
- data/lib/sparql/grammar/parser11.rb +90 -31
- data/lib/sparql/grammar/terminals11.rb +2 -0
- metadata +10 -5
@@ -23,6 +23,7 @@ module SPARQL::Grammar
|
|
23
23
|
STRAFTER STRBEFORE STRDT STRENDS STRLANG STRLEN STRSTARTS STRUUID STR
|
24
24
|
TIMEZONE TZ UCASE URI UUID YEAR
|
25
25
|
isBLANK isIRI isURI isLITERAL isNUMERIC sameTerm
|
26
|
+
isTRIPLE TRIPLE SUBJECT PREDICATE OBJECT
|
26
27
|
}.map {|s| s.downcase.to_sym}.freeze
|
27
28
|
|
28
29
|
BUILTIN_RULES = [:aggregate, :regex, :substr, :replace, :exists, :notexists].freeze
|
@@ -184,6 +185,7 @@ module SPARQL::Grammar
|
|
184
185
|
|STRAFTER|STRBEFORE|STRDT|STRENDS|STRLANG|STRLEN|STRSTARTS|STRUUID|SUBSTR|STR|SUM
|
185
186
|
|TIMEZONE|TZ|UCASE|UNDEF|URI|UUID|YEAR
|
186
187
|
|isBLANK|isIRI|isURI|isLITERAL|isNUMERIC|sameTerm
|
188
|
+
|isTRIPLE|TRIPLE|SUBJECT|PREDICATE|OBJECT
|
187
189
|
}x
|
188
190
|
add_prod_datum(token.value.downcase.to_sym, token.value.downcase.to_sym)
|
189
191
|
else
|
@@ -647,7 +649,7 @@ module SPARQL::Grammar
|
|
647
649
|
data[:input_query] = input.delete(:query) || [SPARQL::Algebra::Operator::BGP.new]
|
648
650
|
end
|
649
651
|
production(:GraphPatternNotTriples) do |input, data, callback|
|
650
|
-
lhs = data[:input_query].first
|
652
|
+
lhs = Array(data[:input_query]).first
|
651
653
|
|
652
654
|
# Filter trickls up to GroupGraphPatternSub
|
653
655
|
add_prod_datum(:filter, data[:filter])
|
@@ -701,9 +703,9 @@ module SPARQL::Grammar
|
|
701
703
|
end
|
702
704
|
end
|
703
705
|
|
704
|
-
# [60] Bind ::= 'BIND' '('
|
706
|
+
# [60] Bind ::= 'BIND' '(' Expression 'AS' Var ')'
|
705
707
|
production(:Bind) do |input, data, callback|
|
706
|
-
add_prod_datum :extend, [
|
708
|
+
add_prod_datum :extend, [data[:Expression].unshift(data[:Var].first)]
|
707
709
|
end
|
708
710
|
|
709
711
|
# [61] InlineData ::= 'VALUES' DataBlock
|
@@ -752,7 +754,7 @@ module SPARQL::Grammar
|
|
752
754
|
end
|
753
755
|
end
|
754
756
|
|
755
|
-
# [65] DataBlockValue ::= iri | RDFLiteral | NumericLiteral | BooleanLiteral | 'UNDEF'
|
757
|
+
# [65] DataBlockValue ::= EmbTD | iri | RDFLiteral | NumericLiteral | BooleanLiteral | 'UNDEF'
|
756
758
|
production(:DataBlockValue) do |input, data, callback|
|
757
759
|
add_prod_datum :DataBlockValue, data.values.first
|
758
760
|
end
|
@@ -831,7 +833,7 @@ module SPARQL::Grammar
|
|
831
833
|
add_prod_datum(:ConstructTemplate, data[:ConstructTemplate])
|
832
834
|
end
|
833
835
|
|
834
|
-
# [75] TriplesSameSubject ::=
|
836
|
+
# [75] TriplesSameSubject ::= VarOrTermOrEmbTP PropertyListNotEmpty
|
835
837
|
# | TriplesNode PropertyList
|
836
838
|
production(:TriplesSameSubject) do |input, data, callback|
|
837
839
|
add_prod_datum(:pattern, data[:pattern])
|
@@ -840,8 +842,8 @@ module SPARQL::Grammar
|
|
840
842
|
# [77] PropertyListNotEmpty ::= Verb ObjectList
|
841
843
|
# ( ';' ( Verb ObjectList )? )*
|
842
844
|
start_production(:PropertyListNotEmpty) do |input, data, callback|
|
843
|
-
subject = input[:
|
844
|
-
error(nil, "Expected
|
845
|
+
subject = input[:VarOrTermOrEmbTP] || input[:TriplesNode] || input[:GraphNode]
|
846
|
+
error(nil, "Expected VarOrTermOrEmbTP or TriplesNode or GraphNode", production: :PropertyListNotEmpty) if validate? && !subject
|
845
847
|
data[:Subject] = subject
|
846
848
|
end
|
847
849
|
production(:PropertyListNotEmpty) do |input, data, callback|
|
@@ -867,17 +869,13 @@ module SPARQL::Grammar
|
|
867
869
|
add_prod_datum(:path, data[:path])
|
868
870
|
end
|
869
871
|
|
870
|
-
# [
|
871
|
-
start_production(:
|
872
|
-
data[:
|
873
|
-
|
874
|
-
production(:AnnotationPattern) do |input, data, callback|
|
875
|
-
add_prod_datum(:pattern, data[:pattern])
|
872
|
+
# [80] Object ::= GraphNode AnnotationPattern?
|
873
|
+
start_production(:Object) do |input, data, callback|
|
874
|
+
data[:Subject] = Array(input[:Subject]).first
|
875
|
+
data[:Verb] = Array(input[:Verb]).first
|
876
876
|
end
|
877
|
-
|
878
|
-
# [80] Object ::= GraphNode | EmbTP
|
879
877
|
production(:Object) do |input, data, callback|
|
880
|
-
object = data[:GraphNode]
|
878
|
+
object = data[:GraphNode]
|
881
879
|
add_prod_datum(:pattern, data[:pattern])
|
882
880
|
if object
|
883
881
|
if prod_data[:Verb]
|
@@ -891,8 +889,17 @@ module SPARQL::Grammar
|
|
891
889
|
end
|
892
890
|
end
|
893
891
|
end
|
892
|
+
start_production(:_Object_1) do |input, data, callback|
|
893
|
+
pattern = RDF::Query::Pattern.new(input[:Subject], input[:Verb], input[:GraphNode].first)
|
894
|
+
error("ObjectPath", "Expected Verb",
|
895
|
+
production: :_Object_1) unless input[:Verb]
|
896
|
+
data[:TriplesNode] = [pattern]
|
897
|
+
end
|
898
|
+
production(:_Object_1) do |input, data, callback|
|
899
|
+
add_prod_datum(:pattern, data[:pattern])
|
900
|
+
end
|
894
901
|
|
895
|
-
# [81] TriplesSameSubjectPath ::=
|
902
|
+
# [81] TriplesSameSubjectPath ::= VarOrTermOrEmbTP PropertyListPathNotEmpty | TriplesNode PropertyListPath
|
896
903
|
production(:TriplesSameSubjectPath) do |input, data, callback|
|
897
904
|
add_prod_datum(:pattern, data[:pattern])
|
898
905
|
add_prod_datum(:path, data[:path])
|
@@ -900,8 +907,8 @@ module SPARQL::Grammar
|
|
900
907
|
|
901
908
|
# [83] PropertyListPathNotEmpty ::= ( VerbPath | VerbSimple ) ObjectList ( ';' ( ( VerbPath | VerbSimple ) ObjectList )? )*
|
902
909
|
start_production(:PropertyListPathNotEmpty) do |input, data, callback|
|
903
|
-
subject = input[:
|
904
|
-
error(nil, "Expected
|
910
|
+
subject = input[:VarOrTermOrEmbTP] || input[:TriplesNode] || input[:GraphNode]
|
911
|
+
error(nil, "Expected VarOrTermOrEmbTP, got nothing", production: :PropertyListPathNotEmpty) if validate? && !subject
|
905
912
|
data[:Subject] = subject
|
906
913
|
end
|
907
914
|
production(:PropertyListPathNotEmpty) do |input, data, callback|
|
@@ -941,9 +948,13 @@ module SPARQL::Grammar
|
|
941
948
|
add_prod_datum(:path, data[:path])
|
942
949
|
end
|
943
950
|
|
944
|
-
# [87] ObjectPath ::= GraphNodePath
|
951
|
+
# [87] ObjectPath ::= GraphNodePath AnnotationPatternPath?
|
952
|
+
start_production(:ObjectPath) do |input, data, callback|
|
953
|
+
data[:Subject] = Array(input[:Subject]).first
|
954
|
+
data[:Verb] = Array(input[:Verb]).first
|
955
|
+
end
|
945
956
|
production(:ObjectPath) do |input, data, callback|
|
946
|
-
object = data[:
|
957
|
+
object = data[:VarOrTermOrEmbTP] || data[:TriplesNode] || data[:GraphNode]
|
947
958
|
if object
|
948
959
|
if prod_data[:Verb]
|
949
960
|
if data[:pattern] && data[:path]
|
@@ -951,6 +962,9 @@ module SPARQL::Grammar
|
|
951
962
|
data[:pattern].unshift(RDF::Query::Pattern.new(prod_data[:Subject].first, prod_data[:Verb], object.first))
|
952
963
|
bgp = SPARQL::Algebra::Expression[:bgp, data[:pattern]]
|
953
964
|
add_prod_datum(:path, SPARQL::Algebra::Expression[:sequence, bgp, *data[:path]])
|
965
|
+
elsif data[:path]
|
966
|
+
# AnnotationPatternPath case
|
967
|
+
add_prod_datum(:path, data[:path])
|
954
968
|
else
|
955
969
|
add_pattern(:Object, subject: prod_data[:Subject], predicate: prod_data[:Verb], object: object)
|
956
970
|
add_prod_datum(:pattern, data[:pattern])
|
@@ -964,6 +978,16 @@ module SPARQL::Grammar
|
|
964
978
|
end
|
965
979
|
end
|
966
980
|
end
|
981
|
+
start_production(:_ObjectPath_1) do |input, data, callback|
|
982
|
+
pattern = RDF::Query::Pattern.new(input[:Subject], input[:Verb], input[:GraphNode].first)
|
983
|
+
error("ObjectPath", "Expected Verb",
|
984
|
+
production: :_ObjectPath_1) unless input[:Verb]
|
985
|
+
data[:TriplesNode] = [pattern]
|
986
|
+
end
|
987
|
+
production(:_ObjectPath_1) do |input, data, callback|
|
988
|
+
add_prod_datum(:pattern, data[:pattern])
|
989
|
+
end
|
990
|
+
|
967
991
|
# [88] Path ::= PathAlternative
|
968
992
|
# output is a :Path or :iri
|
969
993
|
production(:Path) do |input, data, callback|
|
@@ -1092,29 +1116,24 @@ module SPARQL::Grammar
|
|
1092
1116
|
add_prod_datum(:path, data[:path])
|
1093
1117
|
end
|
1094
1118
|
|
1095
|
-
# [104] GraphNode ::=
|
1119
|
+
# [104] GraphNode ::= VarOrTermOrEmbTP | TriplesNode
|
1096
1120
|
production(:GraphNode) do |input, data, callback|
|
1097
|
-
term = data[:
|
1121
|
+
term = data[:VarOrTermOrEmbTP] || data[:TriplesNode]
|
1098
1122
|
add_prod_datum(:pattern, data[:pattern])
|
1099
1123
|
add_prod_datum(:GraphNode, term)
|
1100
1124
|
end
|
1101
1125
|
|
1102
|
-
# [105] GraphNodePath ::=
|
1126
|
+
# [105] GraphNodePath ::= VarOrTermOrEmbTP | TriplesNodePath
|
1103
1127
|
production(:GraphNodePath) do |input, data, callback|
|
1104
|
-
term = data[:
|
1128
|
+
term = data[:VarOrTermOrEmbTP] || data[:TriplesNode]
|
1105
1129
|
add_prod_datum(:pattern, data[:pattern])
|
1106
1130
|
add_prod_datum(:path, data[:path])
|
1107
1131
|
add_prod_datum(:GraphNode, term)
|
1108
1132
|
end
|
1109
1133
|
|
1110
|
-
# [106] VarOrTerm ::= Var | GraphTerm
|
1111
|
-
production(:VarOrTerm) do |input, data, callback|
|
1112
|
-
data.values.each {|v| add_prod_datum(:VarOrTerm, v)}
|
1113
|
-
end
|
1114
|
-
|
1115
1134
|
# [106s] VarOrTermOrEmbTP ::= Var | GraphTerm | EmbTP
|
1116
1135
|
production(:VarOrTermOrEmbTP) do |input, data, callback|
|
1117
|
-
data.values.each {|v| add_prod_datum(:
|
1136
|
+
data.values.each {|v| add_prod_datum(:VarOrTermOrEmbTP, v)}
|
1118
1137
|
end
|
1119
1138
|
|
1120
1139
|
# [107] VarOrIri ::= Var | iri
|
@@ -1287,6 +1306,7 @@ module SPARQL::Grammar
|
|
1287
1306
|
# | iriOrFunction | RDFLiteral
|
1288
1307
|
# | NumericLiteral | BooleanLiteral
|
1289
1308
|
# | Var
|
1309
|
+
# | EmbTP
|
1290
1310
|
production(:PrimaryExpression) do |input, data, callback|
|
1291
1311
|
if data[:Expression]
|
1292
1312
|
add_prod_datum(:Expression, data[:Expression])
|
@@ -1300,6 +1320,8 @@ module SPARQL::Grammar
|
|
1300
1320
|
add_prod_datum(:Expression, data[:literal])
|
1301
1321
|
elsif data[:Var]
|
1302
1322
|
add_prod_datum(:Expression, data[:Var])
|
1323
|
+
elsif data[:pattern]
|
1324
|
+
add_prod_datum(:Expression, data[:pattern])
|
1303
1325
|
end
|
1304
1326
|
|
1305
1327
|
# Keep track of this for parent UnaryExpression production
|
@@ -1470,6 +1492,43 @@ module SPARQL::Grammar
|
|
1470
1492
|
add_prod_datum(:UnaryExpression, data[:UnaryExpression])
|
1471
1493
|
end
|
1472
1494
|
|
1495
|
+
# [177] AnnotationPattern ::= '{|' PropertyListNotEmpty '|}'
|
1496
|
+
#start_production(:AnnotationPattern) do |input, data, callback|
|
1497
|
+
# data[:TriplesNode] = prod_data[:TriplesNode].first
|
1498
|
+
#end
|
1499
|
+
#production(:AnnotationPattern) do |input, data, callback|
|
1500
|
+
# add_prod_datum(:pattern, data[:pattern])
|
1501
|
+
#end
|
1502
|
+
|
1503
|
+
# [178] AnnotationPatternPath ::= '{|' PropertyListPathNotEmpty '|}'
|
1504
|
+
start_production(:AnnotationPatternPath) do |input, data, callback|
|
1505
|
+
data[:TriplesNode] = input[:TriplesNode]
|
1506
|
+
end
|
1507
|
+
production(:AnnotationPatternPath) do |input, data, callback|
|
1508
|
+
if data[:pattern]
|
1509
|
+
add_prod_datum(:pattern, data[:pattern])
|
1510
|
+
elsif data[:path]
|
1511
|
+
# Replace the subject in the path with the node being annotated.
|
1512
|
+
data[:path].first.operands[0] = data[:TriplesNode]
|
1513
|
+
add_prod_datum(:path, data[:path])
|
1514
|
+
end
|
1515
|
+
end
|
1516
|
+
|
1517
|
+
# [179] EmbTD ::= '<<' DataValueTerm ( iri | 'a' ) DataValueTerm '>>'
|
1518
|
+
production(:EmbTD) do |input, data, callback|
|
1519
|
+
subject, object = data[:DataValueTerm]
|
1520
|
+
predicate = data[:iri]
|
1521
|
+
add_pattern(:EmbTD,
|
1522
|
+
subject: subject,
|
1523
|
+
predicate: predicate,
|
1524
|
+
object: object)
|
1525
|
+
end
|
1526
|
+
|
1527
|
+
# [180] DataValueTerm ::= EmbTD | iri | RDFLiteral | NumericLiteral | BooleanLiteral
|
1528
|
+
production(:DataValueTerm) do |input, data, callback|
|
1529
|
+
add_prod_datum :DataValueTerm, data.values.first
|
1530
|
+
end
|
1531
|
+
|
1473
1532
|
##
|
1474
1533
|
# Initializes a new parser instance.
|
1475
1534
|
#
|
@@ -108,6 +108,7 @@ module SPARQL::Grammar
|
|
108
108
|
|TIMEZONE|TO|TZ|UCASE|UNDEF|UNION|URI|USING|UUID|VALUES
|
109
109
|
|WHERE|WITH|YEAR
|
110
110
|
|isBLANK|isIRI|isURI|isLITERAL|isNUMERIC|sameTerm
|
111
|
+
|isTRIPLE|TRIPLE|SUBJECT|PREDICATE|OBJECT
|
111
112
|
|true
|
112
113
|
|false
|
113
114
|
|<<|>>
|
@@ -133,6 +134,7 @@ module SPARQL::Grammar
|
|
133
134
|
TIMEZONE TO TZ UCASE UNDEF UNION URI USING UUID
|
134
135
|
VALUES WHERE WITH YEAR
|
135
136
|
isBLANK isIRI isURI isLITERAL isNUMERIC sameTerm
|
137
|
+
isTRIPLE TRIPLE SUBJECT PREDICATE OBJECT
|
136
138
|
true false
|
137
139
|
} + [
|
138
140
|
"DELETE DATA",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sparql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdf
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
version: '3.1'
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 3.1.
|
23
|
+
version: 3.1.12
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
version: '3.1'
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.1.
|
33
|
+
version: 3.1.12
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rdf-aggregate-repo
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -312,6 +312,7 @@ files:
|
|
312
312
|
- lib/sparql/algebra/operator/is_iri.rb
|
313
313
|
- lib/sparql/algebra/operator/is_literal.rb
|
314
314
|
- lib/sparql/algebra/operator/is_numeric.rb
|
315
|
+
- lib/sparql/algebra/operator/is_triple.rb
|
315
316
|
- lib/sparql/algebra/operator/join.rb
|
316
317
|
- lib/sparql/algebra/operator/lang.rb
|
317
318
|
- lib/sparql/algebra/operator/lang_matches.rb
|
@@ -336,6 +337,7 @@ files:
|
|
336
337
|
- lib/sparql/algebra/operator/notin.rb
|
337
338
|
- lib/sparql/algebra/operator/notoneof.rb
|
338
339
|
- lib/sparql/algebra/operator/now.rb
|
340
|
+
- lib/sparql/algebra/operator/object.rb
|
339
341
|
- lib/sparql/algebra/operator/or.rb
|
340
342
|
- lib/sparql/algebra/operator/order.rb
|
341
343
|
- lib/sparql/algebra/operator/path.rb
|
@@ -343,6 +345,7 @@ files:
|
|
343
345
|
- lib/sparql/algebra/operator/path_plus.rb
|
344
346
|
- lib/sparql/algebra/operator/path_star.rb
|
345
347
|
- lib/sparql/algebra/operator/plus.rb
|
348
|
+
- lib/sparql/algebra/operator/predicate.rb
|
346
349
|
- lib/sparql/algebra/operator/prefix.rb
|
347
350
|
- lib/sparql/algebra/operator/project.rb
|
348
351
|
- lib/sparql/algebra/operator/rand.rb
|
@@ -370,11 +373,13 @@ files:
|
|
370
373
|
- lib/sparql/algebra/operator/strlen.rb
|
371
374
|
- lib/sparql/algebra/operator/strstarts.rb
|
372
375
|
- lib/sparql/algebra/operator/struuid.rb
|
376
|
+
- lib/sparql/algebra/operator/subject.rb
|
373
377
|
- lib/sparql/algebra/operator/substr.rb
|
374
378
|
- lib/sparql/algebra/operator/subtract.rb
|
375
379
|
- lib/sparql/algebra/operator/sum.rb
|
376
380
|
- lib/sparql/algebra/operator/table.rb
|
377
381
|
- lib/sparql/algebra/operator/timezone.rb
|
382
|
+
- lib/sparql/algebra/operator/triple.rb
|
378
383
|
- lib/sparql/algebra/operator/tz.rb
|
379
384
|
- lib/sparql/algebra/operator/ucase.rb
|
380
385
|
- lib/sparql/algebra/operator/union.rb
|
@@ -413,7 +418,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
413
418
|
- !ruby/object:Gem::Version
|
414
419
|
version: '0'
|
415
420
|
requirements: []
|
416
|
-
rubygems_version: 3.
|
421
|
+
rubygems_version: 3.2.3
|
417
422
|
signing_key:
|
418
423
|
specification_version: 4
|
419
424
|
summary: SPARQL Query and Update library for Ruby.
|