Avoid recalculating reduce_rules - #28
This commit is contained in:
parent
95b3dc6550
commit
61339aeae9
@ -140,20 +140,20 @@ class Propane
|
|||||||
if reduce_rules.size == 0
|
if reduce_rules.size == 0
|
||||||
nil
|
nil
|
||||||
else
|
else
|
||||||
build_lookahead_reduce_actions_for_item_set(item_set)
|
build_lookahead_reduce_actions_for_item_set(reduce_rules, item_set)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Build the reduce actions for a single item set (parser state).
|
# Build the reduce actions for a single item set (parser state).
|
||||||
#
|
#
|
||||||
|
# @param reduce_rules [Set<Rule>]
|
||||||
|
# Rules to look for lookahead tokens after.
|
||||||
# @param item_set [ItemSet]
|
# @param item_set [ItemSet]
|
||||||
# ItemSet (parser state)
|
# ItemSet (parser state)
|
||||||
#
|
#
|
||||||
# @return [Hash]
|
# @return [Hash]
|
||||||
# Mapping of lookahead Tokens to the Rules to reduce.
|
# Mapping of lookahead Tokens to the Rules to reduce.
|
||||||
def build_lookahead_reduce_actions_for_item_set(item_set)
|
def build_lookahead_reduce_actions_for_item_set(reduce_rules, item_set)
|
||||||
reduce_rules = Set.new(item_set.items.select(&:complete?).map(&:rule))
|
|
||||||
|
|
||||||
# We will be looking for all possible tokens that can follow instances of
|
# We will be looking for all possible tokens that can follow instances of
|
||||||
# these rules. Rather than looking through the entire grammar for the
|
# these rules. Rather than looking through the entire grammar for the
|
||||||
# possible following tokens, we will only look in the item sets leading
|
# possible following tokens, we will only look in the item sets leading
|
||||||
|
Loading…
x
Reference in New Issue
Block a user