Class: Dhaka::ReduceAction

Inherits:
Action
  • Object
show all
Defined in:
lib/parser/action.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes inherited from Action

#action_code

Instance Method Summary collapse

Constructor Details

#initialize(production) ⇒ ReduceAction

Returns a new instance of ReduceAction.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/parser/action.rb', line 26

def initialize(production)
  @production = production
  @action_code = Proc.new do
    composite_node = ParseTreeCompositeNode.new(production)

    production.expansion.each { |symbol| 
        state_stack.pop
        composite_node.child_nodes.unshift(node_stack.pop)
       }

    node_stack << composite_node

    unless composite_node.head_node?
      @symbol_queue += [@current_token.symbol_name, production.symbol.name]
    end
  end
end

Instance Attribute Details

#productionObject (readonly)

Returns the value of attribute production.



25
26
27
# File 'lib/parser/action.rb', line 25

def production
  @production
end

Instance Method Details

#compile_to_ruby_sourceObject



43
44
45
# File 'lib/parser/action.rb', line 43

def compile_to_ruby_source
  "reduce_with '#{@production.name}'"
end

#to_sObject



46
47
48
# File 'lib/parser/action.rb', line 46

def to_s
  "Reduce with #{production}"
end