Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: milestone2
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (33 sloc) 0.584 kb
class SymbolTable
attr_accessor :parent
def initialize(parent=nil)
@parent = parent
@st = {}
end
def get(name)
v = @st[name]
# if not found, try parent tree
unless v
p = @parent
while p
v = p.get(name)
return v if v != nil
p = p.parent
end
end
# return whatever we got
return v
end
def set(name, value)
@st[name] = value
end
def try_set(name, value)
if @st[name] == nil
self.set(name, value)
end
return self.get(name)
end
def inspect
@st.inspect
end
end
Jump to Line
Something went wrong with that request. Please try again.