class Nydp::LexicalContext
Attributes
at_0[RW]
at_1[RW]
at_2[RW]
at_3[RW]
at_4[RW]
at_5[RW]
at_6[RW]
at_7[RW]
at_8[RW]
at_9[RW]
parent[R]
Public Class Methods
new(parent)
click to toggle source
# File lib/nydp/lexical_context.rb, line 7 def initialize parent @parent = parent end
Public Instance Methods
at_index(index)
click to toggle source
# File lib/nydp/lexical_context.rb, line 22 def at_index index instance_variable_get :"@at_#{index}" end
method_missing(mname, *args)
click to toggle source
Calls superclass method
# File lib/nydp/lexical_context.rb, line 30 def method_missing mname, *args if mname.to_s =~ /at_\d+=/ instance_variable_set :"@#{mname.to_s.sub(/=/, '')}", args[0] elsif mname.to_s =~ /at_\d+/ instance_variable_get :"@#{mname}" else super end end
nth(n)
click to toggle source
# File lib/nydp/lexical_context.rb, line 11 def nth n case n when 0 self when -1 raise "wrong nesting level" else parent.nth(n - 1) end end
pretty()
click to toggle source
# File lib/nydp/lexical_context.rb, line 47 def pretty to_s_with_indent '' end
set_index(index, value)
click to toggle source
# File lib/nydp/lexical_context.rb, line 26 def set_index index, value instance_variable_set :"@at_#{index}", value end
to_s()
click to toggle source
# File lib/nydp/lexical_context.rb, line 51 def to_s # values = [] # n = 0 # while at_index n # values << at_index(n)._nydp_inspect # n += 1 # end # parent_s = parent ? " parent #{parent.to_s}" : "" # "(context (#{values.join ' '})#{parent_s})" "(NEW context)" end
to_s_with_indent(str)
click to toggle source
# File lib/nydp/lexical_context.rb, line 40 def to_s_with_indent str me = (@values || { }).map { |k, v| [str, k, "=>", v].join ' ' }.join "\n" me + (parent ? parent.to_s_with_indent(" #{str}") : '') end