Class: RubyParserStuff::StackState
- Inherits:
-
Object
- Object
- RubyParserStuff::StackState
- Defined in:
- lib/ruby_parser_extras.rb
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
Instance Method Summary collapse
-
#initialize(name) ⇒ StackState
constructor
A new instance of StackState.
- #inspect ⇒ Object
- #is_in_state ⇒ Object
- #lexpop ⇒ Object
- #pop ⇒ Object
- #push(val) ⇒ Object
Constructor Details
#initialize(name) ⇒ StackState
Returns a new instance of StackState.
1230 1231 1232 1233 1234 |
# File 'lib/ruby_parser_extras.rb', line 1230 def initialize(name) @name = name @stack = [false] @debug = false end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
1228 1229 1230 |
# File 'lib/ruby_parser_extras.rb', line 1228 def debug @debug end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
1226 1227 1228 |
# File 'lib/ruby_parser_extras.rb', line 1226 def name @name end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
1227 1228 1229 |
# File 'lib/ruby_parser_extras.rb', line 1227 def stack @stack end |
Instance Method Details
#inspect ⇒ Object
1236 1237 1238 |
# File 'lib/ruby_parser_extras.rb', line 1236 def inspect "StackState(#{@name}, #{@stack.inspect})" end |
#is_in_state ⇒ Object
1240 1241 1242 1243 |
# File 'lib/ruby_parser_extras.rb', line 1240 def is_in_state p :stack_is_in_state => [name, @stack.last, caller.first] if debug @stack.last end |
#lexpop ⇒ Object
1245 1246 1247 1248 1249 1250 1251 |
# File 'lib/ruby_parser_extras.rb', line 1245 def lexpop p :stack_lexpop => caller.first if debug raise if @stack.size == 0 a = @stack.pop b = @stack.pop @stack.push(a || b) end |
#pop ⇒ Object
1253 1254 1255 1256 1257 1258 |
# File 'lib/ruby_parser_extras.rb', line 1253 def pop r = @stack.pop p :stack_pop => [name, r, @stack, caller.first] if debug @stack.push false if @stack.size == 0 r end |
#push(val) ⇒ Object
1260 1261 1262 1263 1264 |
# File 'lib/ruby_parser_extras.rb', line 1260 def push val @stack.push val p :stack_push => [name, @stack, caller.first] if debug nil end |