Determine the reduce actions for each parser state
This commit is contained in:
1 parent
5af3179ff2
commit
60e2818075
5 files changed
+169
-4
No files matched your search
@@ -86,10 +86,26 @@ class Propane
|
||||
# That is, the symbol which follows the parse position marker in the
|
||||
# current Item.
|
||||
#
|
||||
# @param offset [Integer]
|
||||
# Offset from current parse position to examine.
|
||||
#
|
||||
# @return [Token, RuleSet, nil]
|
||||
# Following symbol for the Item.
|
||||
def following_symbol
|
||||
@rule.components[@position]
|
||||
def following_symbol(offset = 0)
|
||||
@rule.components[@position + offset]
|
||||
end
|
||||
|
||||
# Get the previous symbol for the Item.
|
||||
#
|
||||
# That is, the symbol which precedes the parse position marker in the
|
||||
# current Item.
|
||||
#
|
||||
# @return [Token, RuleSet, nil]
|
||||
# Previous symbol for this Item.
|
||||
def previous_symbol
|
||||
if @position > 0
|
||||
@rule.components[@position - 1]
|
||||
end
|
||||
end
|
||||
|
||||
# Get whether this Item is followed by the provided symbol.
|
||||
|
||||
@@ -21,6 +21,14 @@ class Propane
|
||||
# ItemSets leading to this item set.
|
||||
attr_reader :in_sets
|
||||
|
||||
# @return [Hash]
|
||||
# ItemSets reached from this item set. Key is a Token or Rule.
|
||||
attr_reader :out_sets
|
||||
|
||||
# @return [nil, Rule, Hash]
|
||||
# Reduce actions, mapping lookahead tokens to rules.
|
||||
attr_accessor :reduce_actions
|
||||
|
||||
# Build an ItemSet.
|
||||
#
|
||||
# @param items [Array<Item>]
|
||||
@@ -29,6 +37,7 @@ class Propane
|
||||
@items = Set.new(items)
|
||||
@following_item_set = {}
|
||||
@in_sets = Set.new
|
||||
@out_sets = {}
|
||||
close!
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user