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

- old
+ new

@@ -1413,11 +1413,11 @@ if data[:string] lit = data.dup str = lit.delete(:string) lit[:datatype] = lit.delete(:iri) if lit[:iri] lit[:language] = lit.delete(:language).last.downcase if lit[:language] - input[:literal] = RDF::Literal.new(str, lit) if str + input[:literal] = RDF::Literal.new(str, **lit) if str end end # [132] NumericLiteralPositive ::= INTEGER_POSITIVE # | DECIMAL_POSITIVE @@ -1464,11 +1464,11 @@ # Detailed debug output # @yield [parser] `self` # @yieldparam [SPARQL::Grammar::Parser] parser # @yieldreturn [void] ignored # @return [SPARQL::Grammar::Parser] - def initialize(input = nil, options = {}, &block) + def initialize(input = nil, **options, &block) @input = case input when IO, StringIO then input.read else input.to_s.dup end @input.encode!(Encoding::UTF_8) if @input.respond_to?(:encode!) @@ -1528,14 +1528,17 @@ # It may be a URI from the grammar, or a symbol representing the local_name portion of the grammar URI. # @return [Array] # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra # @see http://axel.deri.ie/sparqltutorial/ESWC2007_SPARQL_Tutorial_unit2b.pdf def parse(prod = START) - ll1_parse(@input, prod.to_sym, @options.merge(branch: BRANCH, - first: FIRST, - follow: FOLLOW, - whitespace: WS) + ll1_parse(@input, + prod.to_sym, + branch: BRANCH, + first: FIRST, + follow: FOLLOW, + whitespace: WS, + **@options ) do |context, *data| case context when :trace level, lineno, depth, *args = data message = args.to_sse @@ -1716,23 +1719,19 @@ def variable(id, distinguished = true) id = nil if id.to_s.empty? if id @vars[id] ||= begin - v = RDF::Query::Variable.new(id) - v.distinguished = distinguished - v + RDF::Query::Variable.new(id, distinguished: distinguished) end else unless distinguished # Allocate a non-distinguished variable identifier id = @nd_var_gen @nd_var_gen = id.succ end - v = RDF::Query::Variable.new(id) - v.distinguished = distinguished - v + RDF::Query::Variable.new(id, distinguished: distinguished) end end # Create URIs def iri(value) @@ -1756,20 +1755,20 @@ iri.lexical = "#{prefix}:#{suffix}" unless resolve_iris? iri end # Create a literal - def literal(value, options = {}) + def literal(value, **options) options = options.dup # Internal representation is to not use xsd:string, although it could arguably go the other way. options.delete(:datatype) if options[:datatype] == RDF::XSD.string debug("literal") do "value: #{value.inspect}, " + "options: #{options.inspect}, " + "validate: #{validate?.inspect}, " end - RDF::Literal.new(value, options.merge(validate: validate?)) + RDF::Literal.new(value, validate: validate?, **options) end # Take collection of objects and create RDF Collection using rdf:first, rdf:rest and rdf:nil # @param [Hash] data Production Data def expand_collection(data) @@ -1796,11 +1795,11 @@ # add a pattern # # @param [String] production Production generating pattern # @param [Hash{Symbol => Object}] options - def add_pattern(production, options) + def add_pattern(production, **options) progress(production, "[:pattern, #{options[:subject]}, #{options[:predicate]}, #{options[:object]}]") triple = {} options.each_pair do |r, v| if v.is_a?(Array) && v.flatten.length == 1 v = v.flatten.first @@ -1878,11 +1877,10 @@ expr.replace_aggregate! do |function| if avf = aggregates.detect {|(_, f)| f == function} avf.first else # Allocate a temporary variable for this function, and retain the mapping for outside the group - av = RDF::Query::Variable.new(".#{agg}") - av.distinguished = false + av = RDF::Query::Variable.new(".#{agg}", distinguished: false) agg += 1 aggregates << [av, function] av end end