lib/sparql/grammar/parser11.rb in sparql-3.0.1 vs lib/sparql/grammar/parser11.rb in sparql-3.0.2

- old
+ new

@@ -214,11 +214,11 @@ # [4] Prologue ::= ( BaseDecl | PrefixDecl )* production(:Prologue) do |input, data, callback| 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 # [5] BaseDecl ::= 'BASE' IRI_REF production(:BaseDecl) do |input, data, callback| @@ -622,15 +622,18 @@ end end 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 # [56] GraphPatternNotTriples ::= GroupOrUnionGraphPattern @@ -854,15 +857,12 @@ start_production(:ObjectList) do |input, data, callback| # Called after Verb. The prod_data stack should have Subject and Verb elements 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]) add_prod_datum(:path, data[:path]) end @@ -872,11 +872,11 @@ object = data[:VarOrTerm] || data[:TriplesNode] || data[:GraphNode] if object 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, prod_data[:VerbPath], object.first)) @@ -884,33 +884,28 @@ end end # [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 )? )* start_production(:PropertyListPathNotEmpty) do |input, data, callback| subject = input[:VarOrTerm] || input[:TriplesNode] || input[:GraphNode] error(nil, "Expected VarOrTerm, got nothing", production: :PropertyListPathNotEmpty) if validate? && !subject 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] end end