lib/antelope/generation/tableizer.rb in antelope-0.1.7 vs lib/antelope/generation/tableizer.rb in antelope-0.1.8

- old
+ new

@@ -19,10 +19,12 @@ # All rules in the grammar. # # @return [Hash<(Numeric, Recognizer::Rule)>] attr_accessor :rules + attr_reader :conflicts + # Initialize. # # @param grammar [Ace::Grammar] def initialize(grammar) @grammar = grammar @@ -80,10 +82,11 @@ # # @raise [UnresolvableConflictError] if a conflict could not be # resolved using precedence rules. # @return [void] def conflictize + @conflicts = Hash.new { |h, k| h[k] = {} } @table.each_with_index do |v, state| v.each do |on, data| if data.size == 1 @table[state][on] = data[0] next @@ -102,9 +105,12 @@ result = @rules[rule_part[1]].prec <=> terminal case result when 0 + conflicts[state][on] = [ + rule_part, other_part, terminal, @rules[rule_part[1]].prec + ] $stderr.puts \ "Could not determine move for #{on} in state " \ "#{state} (shift/reduce conflict)" when 1 @table[state][on] = rule_part