Class: Parser::CurrentArgStack Private
- Inherits:
-
Object
- Object
- Parser::CurrentArgStack
- Defined in:
- lib/parser/current_arg_stack.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Stack that holds names of current arguments, i.e. while parsing
def m1(a = (def m2(b = def m3(c = 1); end); end)); end
^
stack is [:a, :b, :c]
Emulates ‘p->cur_arg` in MRI’s parse.y
Instance Attribute Summary collapse
- #stack ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize ⇒ CurrentArgStack
constructor
private
A new instance of CurrentArgStack.
- #pop ⇒ Object private
- #push(value) ⇒ Object private
- #reset ⇒ Object private
- #set(value) ⇒ Object private
- #top ⇒ Object private
Constructor Details
#initialize ⇒ CurrentArgStack
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of CurrentArgStack.
17 18 19 20 |
# File 'lib/parser/current_arg_stack.rb', line 17 def initialize @stack = [] freeze end |
Instance Attribute Details
#stack ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/parser/current_arg_stack.rb', line 15 def stack @stack end |
Instance Method Details
#pop ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/parser/current_arg_stack.rb', line 31 def pop @stack.pop end |
#push(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'lib/parser/current_arg_stack.rb', line 22 def push(value) @stack << value end |
#reset ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 |
# File 'lib/parser/current_arg_stack.rb', line 35 def reset @stack.clear end |
#set(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 |
# File 'lib/parser/current_arg_stack.rb', line 26 def set(value) pop push(value) end |
#top ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 |
# File 'lib/parser/current_arg_stack.rb', line 39 def top @stack.last end |