Class: RubyParserStuff::StackState
- Inherits:
-
Object
- Object
- RubyParserStuff::StackState
- Defined in:
- lib/ruby_parser/ruby_parser_extras.rb
Instance Attribute Summary (collapse)
-
- (Object) stack
readonly
Returns the value of attribute stack.
Instance Method Summary (collapse)
-
- (StackState) initialize(name)
constructor
A new instance of StackState.
- - (Object) inspect
- - (Object) is_in_state
- - (Object) lexpop
- - (Object) pop
- - (Object) push(val)
Constructor Details
- (StackState) initialize(name)
A new instance of StackState
997 998 999 1000 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 997 def initialize(name) @name = name @stack = [false] end |
Instance Attribute Details
- (Object) stack (readonly)
Returns the value of attribute stack
995 996 997 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 995 def stack @stack end |
Instance Method Details
- (Object) inspect
1002 1003 1004 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 1002 def inspect "StackState(#{@name}, #{@stack.inspect})" end |
- (Object) is_in_state
1006 1007 1008 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 1006 def is_in_state @stack.last end |
- (Object) lexpop
1010 1011 1012 1013 1014 1015 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 1010 def lexpop raise if @stack.size == 0 a = @stack.pop b = @stack.pop @stack.push(a || b) end |
- (Object) pop
1017 1018 1019 1020 1021 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 1017 def pop r = @stack.pop @stack.push false if @stack.size == 0 r end |
- (Object) push(val)
1023 1024 1025 |
# File 'lib/ruby_parser/ruby_parser_extras.rb', line 1023 def push val @stack.push val end |