Compare commits
No commits in common. "0f1c00d1a6ae0f1c360d52d9803a9fc067768d2b" and "d6e5c4325d1eb294e8f2df7d2761e987a504fe60" have entirely different histories.
0f1c00d1a6
...
d6e5c4325d
@ -72,15 +72,6 @@ class Propane
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return whether the item is "complete", meaning that the parse position
|
|
||||||
# marker is at the end of the rule.
|
|
||||||
#
|
|
||||||
# @return [Boolean]
|
|
||||||
# Whether the item is "complete".
|
|
||||||
def complete?
|
|
||||||
@position == @rule.components.size
|
|
||||||
end
|
|
||||||
|
|
||||||
# Get the following symbol for the Item.
|
# Get the following symbol for the Item.
|
||||||
#
|
#
|
||||||
# That is, the symbol which follows the parse position marker in the
|
# That is, the symbol which follows the parse position marker in the
|
||||||
|
@ -17,8 +17,8 @@ class Propane
|
|||||||
# Maps a following symbol to its ItemSet.
|
# Maps a following symbol to its ItemSet.
|
||||||
attr_reader :following_item_set
|
attr_reader :following_item_set
|
||||||
|
|
||||||
# @return [Set<ItemSet>]
|
# @return [Set]
|
||||||
# ItemSets leading to this item set.
|
# Item sets leading to this item set.
|
||||||
attr_reader :in_sets
|
attr_reader :in_sets
|
||||||
|
|
||||||
# Build an ItemSet.
|
# Build an ItemSet.
|
||||||
@ -81,18 +81,6 @@ class Propane
|
|||||||
self == other
|
self == other
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set of ItemSets that lead to this ItemSet.
|
|
||||||
#
|
|
||||||
# This set includes this ItemSet.
|
|
||||||
#
|
|
||||||
# @return [Set<ItemSet>]
|
|
||||||
# Set of all ItemSets that lead up to this ItemSet.
|
|
||||||
def leading_item_sets
|
|
||||||
@in_sets.reduce(Set[self]) do |result, item_set|
|
|
||||||
result + item_set.leading_item_sets
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Represent the ItemSet as a String.
|
# Represent the ItemSet as a String.
|
||||||
#
|
#
|
||||||
# @return [String]
|
# @return [String]
|
||||||
|
@ -42,16 +42,6 @@ class Propane
|
|||||||
@line_number = line_number
|
@line_number = line_number
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return whether the Rule is empty.
|
|
||||||
#
|
|
||||||
# A Rule is empty if it has no components.
|
|
||||||
#
|
|
||||||
# @return [Boolean]
|
|
||||||
# Whether the Rule is empty.
|
|
||||||
def empty?
|
|
||||||
@components.empty?
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -2,41 +2,17 @@ class Propane
|
|||||||
|
|
||||||
class RuleSet
|
class RuleSet
|
||||||
|
|
||||||
# @return [String]
|
|
||||||
# Name of the RuleSet.
|
|
||||||
attr_reader :name
|
attr_reader :name
|
||||||
|
|
||||||
# @return [Array<Rule>]
|
|
||||||
# Rules in the RuleSet.
|
|
||||||
attr_reader :rules
|
attr_reader :rules
|
||||||
|
|
||||||
# Construct a RuleSet.
|
|
||||||
#
|
|
||||||
# @param name [String]
|
|
||||||
# Name of the RuleSet.
|
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
@name = name
|
@name = name
|
||||||
@rules = []
|
@rules = []
|
||||||
@could_be_empty = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a Rule to the RuleSet.
|
|
||||||
#
|
|
||||||
# @param rule [Rule]
|
|
||||||
# Rule to add.
|
|
||||||
def <<(rule)
|
def <<(rule)
|
||||||
@rules << rule
|
@rules << rule
|
||||||
if rule.empty?
|
|
||||||
@could_be_empty = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Return whether any Rule in the RuleSet is empty.
|
|
||||||
#
|
|
||||||
# @return [Boolean]
|
|
||||||
# Whether any rule in the RuleSet is empty.
|
|
||||||
def could_be_empty?
|
|
||||||
@could_be_empty
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user