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
- #empty? ⇒ Boolean private
-
#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
#empty? ⇒ Boolean
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 empty? @stack.size == 0 end |
#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.
34 35 36 |
# File 'lib/parser/current_arg_stack.rb', line 34 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.
26 27 28 |
# File 'lib/parser/current_arg_stack.rb', line 26 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.
38 39 40 |
# File 'lib/parser/current_arg_stack.rb', line 38 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.
30 31 32 |
# File 'lib/parser/current_arg_stack.rb', line 30 def set(value) @stack[@stack.length - 1] = 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.
42 43 44 |
# File 'lib/parser/current_arg_stack.rb', line 42 def top @stack.last end |