Skip to content

Commit d035f78

Browse files
committed
Remove dead code from parser.
1 parent c03a7fe commit d035f78

1 file changed

Lines changed: 10 additions & 61 deletions

File tree

lib/ld/patch/parser.rb

Lines changed: 10 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -349,26 +349,6 @@ def initialize(input = nil, options = {}, &block)
349349
end
350350
end
351351

352-
##
353-
# Returns `true` if the input string is syntactically valid.
354-
#
355-
# @return [Boolean]
356-
def valid?
357-
parse
358-
true
359-
rescue ParseError
360-
false
361-
end
362-
363-
# @return [String]
364-
def to_sxp_bin
365-
@result
366-
end
367-
368-
def to_s
369-
@result.to_sxp
370-
end
371-
372352
##
373353
# Accumulated errors found during processing
374354
# @return [Array<String>]
@@ -514,57 +494,26 @@ def validate?
514494
# Return variable allocated to an ID.
515495
# If no ID is provided, a new variable
516496
# is allocated. Otherwise, any previous assignment will be used.
517-
#
518-
# The variable has a #distinguished? method applied depending on if this
519-
# is a disinguished or non-distinguished variable. Non-distinguished
520-
# variables are effectively the same as BNodes.
521497
# @return [RDF::Query::Variable]
522498
def variable(id, distinguished = true)
523-
id = nil if id.to_s.empty?
524-
525-
if id
526-
@vars[id] ||= begin
527-
v = RDF::Query::Variable.new(id)
528-
v.distinguished = distinguished
529-
v
530-
end
531-
else
532-
unless distinguished
533-
# Allocate a non-distinguished variable identifier
534-
id = @nd_var_gen
535-
@nd_var_gen = id.succ
536-
end
499+
@vars[id] ||= begin
537500
v = RDF::Query::Variable.new(id)
538501
v.distinguished = distinguished
539502
v
540503
end
541504
end
542505

543-
# Used for generating BNode labels
544-
attr_accessor :nd_var_gen
545-
546-
# Reset the bnode cache, always generating new nodes, and start generating BNodes instead of non-distinguished variables
547-
def clear_bnode_cache
548-
@nd_var_gen = false
549-
@bnode_cache = {}
550-
end
551-
552506
# Generate a BNode identifier
553507
def bnode(id = nil)
554-
if @nd_var_gen
555-
# Use non-distinguished variables within patterns
556-
variable(id, false)
557-
else
558-
unless id
559-
id = @options[:anon_base]
560-
@options[:anon_base] = @options[:anon_base].succ
561-
end
562-
# Don't use provided ID to avoid aliasing issues when re-serializing the graph, when the bnode identifiers are re-used
563-
(@bnode_cache ||= {})[id.to_s] ||= begin
564-
new_bnode = RDF::Node.new
565-
new_bnode.lexical = "_:#{id}"
566-
new_bnode
567-
end
508+
unless id
509+
id = @options[:anon_base]
510+
@options[:anon_base] = @options[:anon_base].succ
511+
end
512+
# Don't use provided ID to avoid aliasing issues when re-serializing the graph, when the bnode identifiers are re-used
513+
(@bnode_cache ||= {})[id.to_s] ||= begin
514+
new_bnode = RDF::Node.new
515+
new_bnode.lexical = "_:#{id}"
516+
new_bnode
568517
end
569518
end
570519

0 commit comments

Comments
 (0)