Class: Parser::VariablesStack

Inherits:
Object
  • Object
show all
Defined in:
lib/parser/variables_stack.rb

Instance Method Summary collapse

Constructor Details

#initializeVariablesStack

Returns a new instance of VariablesStack.



6
7
8
9
# File 'lib/parser/variables_stack.rb', line 6

def initialize
  @stack = []
  push
end

Instance Method Details

#declare(name) ⇒ Object



27
28
29
# File 'lib/parser/variables_stack.rb', line 27

def declare(name)
  @stack.last << name.to_sym
end

#declared?(name) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/parser/variables_stack.rb', line 31

def declared?(name)
  @stack.last.include?(name.to_sym)
end

#empty?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/parser/variables_stack.rb', line 11

def empty?
  @stack.empty?
end

#popObject



19
20
21
# File 'lib/parser/variables_stack.rb', line 19

def pop
  @stack.pop
end

#pushObject



15
16
17
# File 'lib/parser/variables_stack.rb', line 15

def push
  @stack << Set.new
end

#resetObject



23
24
25
# File 'lib/parser/variables_stack.rb', line 23

def reset
  @stack.clear
end