Object
# File lib/treetop/runtime/syntax_node.rb, line 45 45: def <=>(other) 46: self.interval.first <=> other.interval.first 47: end
# File lib/treetop/runtime/syntax_node.rb, line 89 89: def dot_id 90: @dot_id ||= @@dot_id_counter += 1 91: end
# File lib/treetop/runtime/syntax_node.rb, line 13 13: def elements 14: return @elements if terminal? 15: # replace the character class placeholders in the sequence (lazy instantiation) 16: last_element = nil 17: @comprehensive_elements ||= @elements.map do |element| 18: if element == true 19: index = last_element ? last_element.interval.last : interval.first 20: element = SyntaxNode.new(input, index...(index + 1)) 21: end 22: element.parent = self 23: last_element = element 24: end 25: 26: @comprehensive_elements 27: end
# File lib/treetop/runtime/syntax_node.rb, line 41 41: def empty? 42: interval.first == interval.last && interval.exclude_end? 43: end
# File lib/treetop/runtime/syntax_node.rb, line 49 49: def extension_modules 50: local_extensions = 51: class <<self 52: included_modules-Object.included_modules 53: end 54: if local_extensions.size > 0 55: local_extensions 56: else 57: [] # There weren't any; must be a literal node 58: end 59: end
# File lib/treetop/runtime/syntax_node.rb, line 61 61: def inspect(indent="") 62: em = extension_modules 63: interesting_methods = methods-[em.last ? em.last.methods : nil]-self.class.instance_methods 64: im = interesting_methods.size > 0 ? " (#{interesting_methods.join(",")})" : "" 65: tv = text_value 66: tv = "...#{tv[-20..-1]}" if tv.size > 20 67: 68: indent + 69: self.class.to_s.sub(/.*:/,'') + 70: em.map{|m| "+"+m.to_s.sub(/.*:/,'')}*"" + 71: " offset=#{interval.first}" + 72: ", #{tv.inspect}" + 73: im + 74: (elements && elements.size > 0 ? 75: ":" + 76: (elements||[]).map{|e| 77: begin 78: "\n"+e.inspect(indent+" ") 79: rescue # Defend against inspect not taking a parameter 80: "\n"+indent+" "+e.inspect 81: end 82: }.join("") : 83: "" 84: ) 85: end
# File lib/treetop/runtime/syntax_node.rb, line 33 33: def nonterminal? 34: !terminal? 35: end
# File lib/treetop/runtime/syntax_node.rb, line 29 29: def terminal? 30: @elements.nil? 31: end
# File lib/treetop/runtime/syntax_node.rb, line 37 37: def text_value 38: input[interval] 39: end
# File lib/treetop/runtime/syntax_node.rb, line 93 93: def write_dot(io) 94: io.puts "node#{dot_id} [label=\"'#{text_value}'\"];" 95: if nonterminal? then 96: elements.each do 97: |x| 98: io.puts "node#{dot_id} -> node#{x.dot_id};" 99: x.write_dot(io) 100: end 101: end 102: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.