lib/ebnf/ll1.rb in ebnf-1.0.1 vs lib/ebnf/ll1.rb in ebnf-1.0.2

- old
+ new

@@ -283,11 +283,11 @@ if rule.alt? # A First/Follow conflict appears when _eps is in the first # of one rule and there is a token in the first and # follow of the same rule - if rule.first.include?(:_eps) && !(overlap = ((rule.first & rule.follow) - [:eps])).empty? + if rule.first.include?(:_eps) && !(overlap = ((rule.first & (rule.follow || [])) - [:eps])).empty? error("First/Follow Conflict: #{overlap.first.inspect} is both first and follow of #{rule.sym}") end # Add entries for each alternative, based on the alternative's first/seq rule.expr[1..-1].each do |prod| @@ -304,10 +304,11 @@ else prod_rule.first.reject{|f| f == :_eps}.each do |f| # A First/First conflict appears when there are two rules having # the same first, so the parser can't know which one to choose. if branchDict.has_key?(f) - error("First/First Conflict: #{f.inspect} is also the condition for #{branchDict[f].first}") + #require 'byebug'; byebug + error("First/First Conflict: #{f.inspect} is the condition for both #{prod_rule.sym} and #{branchDict[f].first}") end debug(" alt") {"[#{f}] => #{prod}"} branchDict[f] = [prod] end