lib/antelope/generation/constructor/follow.rb in antelope-0.1.1 vs lib/antelope/generation/constructor/follow.rb in antelope-0.1.2
- old
+ new
@@ -1,5 +1,7 @@
+# encoding: utf-8
+
module Antelope
module Generation
class Constructor
# Contains the methods to find the FOLLOW sets of nonterminals.
@@ -68,9 +70,12 @@
# Set it to the empty set so we don't end up recursing.
@follows[token] = Set.new
# This is going to be the output set.
set = Set.new
+
+ productions = grammar.states.map(&:rules).flatten.
+ inject(Set.new, :merge)
productions.each do |rule|
items = rule.right
# Find all of the positions within the rule that our token