Skip to content

Commit

Permalink
Finish 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Aug 27, 2018
2 parents c3cebaf + 9148164 commit 87efc68
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
3.0.1
3.0.2
31 changes: 13 additions & 18 deletions lib/sparql/grammar/parser11.rb
Expand Up @@ -216,7 +216,7 @@ class Parser
unless resolve_iris?
# Only output if we're not resolving URIs internally
add_prod_datum(:BaseDecl, data[:BaseDecl])
add_prod_datum(:PrefixDecl, data[:PrefixDecl]) if data[:PrefixDecl]
add_prod_datum(:PrefixDecl, data[:PrefixDecl])
end
end

Expand Down Expand Up @@ -624,11 +624,14 @@ class Parser
if (lhs = (input.delete(:query) || []).first) && !lhs.empty?
query = SPARQL::Algebra::Operator::Join.new(lhs, query)
end
if data[:path]
query = SPARQL::Algebra::Operator::Join.new(query, Array(data[:path]).first)
end
add_prod_datum(:query, query)
elsif !Array(data[:query]).empty?
# Join query and path
add_prod_datum(:query, SPARQL::Algebra::Operator::Join.new(data[:path].first, data[:query].first))
else
elsif data[:path]
add_prod_datum(:query, data[:path])
end
end
Expand Down Expand Up @@ -856,11 +859,8 @@ class Parser
data[:Subject] = prod_data[:Subject]
error(nil, "Expected Subject", production: :ObjectList) if !prod_data[:Subject] && validate?
error(nil, "Expected Verb", production: :ObjectList) if !(prod_data[:Verb] || prod_data[:VerbPath]) && validate?
if prod_data[:Verb]
data[:Verb] = prod_data[:Verb]
else
data[:VerbPath] = prod_data[:VerbPath]
end
data[:Verb] = prod_data[:Verb] if prod_data[:Verb]
data[:VerbPath] = prod_data[:VerbPath] if prod_data[:VerbPath]
end
production(:ObjectList) do |input, data, callback|
add_prod_datum(:pattern, data[:pattern])
Expand All @@ -874,7 +874,7 @@ class Parser
if prod_data[:Verb]
add_pattern(:Object, subject: prod_data[:Subject], predicate: prod_data[:Verb], object: object)
add_prod_datum(:pattern, data[:pattern])
else
elsif prod_data[:VerbPath]
add_prod_datum(:path,
SPARQL::Algebra::Expression(:path,
prod_data[:Subject].first,
Expand All @@ -886,11 +886,8 @@ class Parser

# [81] TriplesSameSubjectPath ::= VarOrTerm PropertyListPathNotEmpty | TriplesNode PropertyListPath
production(:TriplesSameSubjectPath) do |input, data, callback|
if data[:pattern]
add_prod_datum(:pattern, data[:pattern])
else
add_prod_datum(:path, data[:path])
end
add_prod_datum(:pattern, data[:pattern])
add_prod_datum(:path, data[:path])
end

# [83] PropertyListPathNotEmpty ::= ( VerbPath | VerbSimple ) ObjectList ( ';' ( ( VerbPath | VerbSimple ) ObjectList )? )*
Expand All @@ -900,16 +897,14 @@ class Parser
data[:Subject] = subject
end
production(:PropertyListPathNotEmpty) do |input, data, callback|
if data[:pattern]
add_prod_datum(:pattern, data[:pattern])
else
add_prod_datum(:path, data[:path])
end
add_prod_datum(:pattern, data[:pattern])
add_prod_datum(:path, data[:path])
end

# [84] VerbPath ::= Path
production(:VerbPath) do |input, data, callback|
if data[:Path]
input.delete(:Verb)
input[:VerbPath] = data[:Path]
else
input[:Verb] = data[:iri]
Expand Down
7 changes: 1 addition & 6 deletions sparql.gemspec
Expand Up @@ -17,11 +17,7 @@ Gem::Specification.new do |gem|
gem.files = %w(AUTHORS CREDITS README.md UNLICENSE VERSION bin/sparql) + Dir.glob('lib/**/*.rb')
gem.bindir = %q(bin)
gem.executables = %w(sparql)
gem.default_executable = gem.executables.first
gem.require_paths = %w(lib)
gem.extensions = %w()
gem.test_files = %w()
gem.has_rdoc = false
gem.description = %(
Implements SPARQL grammar parsing to SPARQL Algebra, SPARQL Algebra processing
and includes SPARQL Client for accessing remote repositories.)
Expand All @@ -41,8 +37,7 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'rack', '~> 2.0'
gem.add_development_dependency 'rack-test', '~> 0.8'
gem.add_development_dependency 'rdf-spec', '~> 3.0'
#gem.add_development_dependency 'linkeddata', '~> 3.0'
gem.add_development_dependency 'linkeddata', '>= 2.2', '< 4.0'
gem.add_development_dependency 'linkeddata', '~> 3.0'
gem.add_development_dependency 'open-uri-cached', '~> 0.0', '>= 0.0.5'
gem.add_development_dependency 'rspec', '~> 3.7'
gem.add_development_dependency 'rspec-its', '~> 1.2'
Expand Down
19 changes: 19 additions & 0 deletions spec/grammar/misc_spec.rb
Expand Up @@ -78,6 +78,25 @@
(bgp (triple ?r <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> ?f))
)
)}
},
"issue 33" => {
query: %(
CONSTRUCT {
?uri <http://prop3> ?anotherURI .
}
WHERE
{
?uri a ?type ;
<http://prop1> / <http://prop2> ?anotherURI
}
),
sse: %{(construct
((triple ?uri <http://prop3> ?anotherURI))
(join
(bgp (triple ?uri a ?type))
(path ?uri (seq <http://prop1> <http://prop2>) ?anotherURI)
)
)}
}
}.each do |test, options|
it "parses #{test}" do
Expand Down

0 comments on commit 87efc68

Please sign in to comment.