Skip to content

Commit

Permalink
Remove dead code from parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 11, 2016
1 parent c03a7fe commit d035f78
Showing 1 changed file with 10 additions and 61 deletions.
71 changes: 10 additions & 61 deletions lib/ld/patch/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,26 +349,6 @@ def initialize(input = nil, options = {}, &block)
end
end

##
# Returns `true` if the input string is syntactically valid.
#
# @return [Boolean]
def valid?
parse
true
rescue ParseError
false
end

# @return [String]
def to_sxp_bin
@result
end

def to_s
@result.to_sxp
end

##
# Accumulated errors found during processing
# @return [Array<String>]
Expand Down Expand Up @@ -514,57 +494,26 @@ def validate?
# Return variable allocated to an ID.
# If no ID is provided, a new variable
# is allocated. Otherwise, any previous assignment will be used.
#
# The variable has a #distinguished? method applied depending on if this
# is a disinguished or non-distinguished variable. Non-distinguished
# variables are effectively the same as BNodes.
# @return [RDF::Query::Variable]
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
end
else
unless distinguished
# Allocate a non-distinguished variable identifier
id = @nd_var_gen
@nd_var_gen = id.succ
end
@vars[id] ||= begin
v = RDF::Query::Variable.new(id)
v.distinguished = distinguished
v
end
end

# Used for generating BNode labels
attr_accessor :nd_var_gen

# Reset the bnode cache, always generating new nodes, and start generating BNodes instead of non-distinguished variables
def clear_bnode_cache
@nd_var_gen = false
@bnode_cache = {}
end

# Generate a BNode identifier
def bnode(id = nil)
if @nd_var_gen
# Use non-distinguished variables within patterns
variable(id, false)
else
unless id
id = @options[:anon_base]
@options[:anon_base] = @options[:anon_base].succ
end
# Don't use provided ID to avoid aliasing issues when re-serializing the graph, when the bnode identifiers are re-used
(@bnode_cache ||= {})[id.to_s] ||= begin
new_bnode = RDF::Node.new
new_bnode.lexical = "_:#{id}"
new_bnode
end
unless id
id = @options[:anon_base]
@options[:anon_base] = @options[:anon_base].succ
end
# Don't use provided ID to avoid aliasing issues when re-serializing the graph, when the bnode identifiers are re-used
(@bnode_cache ||= {})[id.to_s] ||= begin
new_bnode = RDF::Node.new
new_bnode.lexical = "_:#{id}"
new_bnode
end
end

Expand Down

0 comments on commit d035f78

Please sign in to comment.