Class: Dhaka::ReduceAction
Overview
:nodoc:
Instance Attribute Summary collapse
-
#production ⇒ Object
readonly
Returns the value of attribute production.
Attributes inherited from Action
Instance Method Summary collapse
- #compile_to_ruby_source ⇒ Object
-
#initialize(production) ⇒ ReduceAction
constructor
A new instance of ReduceAction.
- #to_s ⇒ Object
Constructor Details
#initialize(production) ⇒ ReduceAction
Returns a new instance of ReduceAction.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dhaka/parser/action.rb', line 29 def initialize(production) @production = production @action_code = Proc.new do composite_node = ParseTreeCompositeNode.new(production) production.expansion.each do |symbol| state_stack.pop composite_node.child_nodes.unshift(node_stack.pop) end node_stack << composite_node.instance_eval(&production.action) unless composite_node.head_node? @symbol_queue.concat [@current_token.symbol_name, production.symbol.name] end end end |
Instance Attribute Details
#production ⇒ Object (readonly)
Returns the value of attribute production.
27 28 29 |
# File 'lib/dhaka/parser/action.rb', line 27 def production @production end |
Instance Method Details
#compile_to_ruby_source ⇒ Object
47 48 49 |
# File 'lib/dhaka/parser/action.rb', line 47 def compile_to_ruby_source "reduce_with #{production.name.inspect}" end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/dhaka/parser/action.rb', line 51 def to_s "Reduce with #{production}" end |