Add RuleSet#start_token_set

This commit is contained in:
josh committed 2022-06-17 01:35:02 -04:00
1 parent 11ea02fb86
commit 5af3179ff2
1 file changed
+24
+24
View File
@@ -40,6 +40,30 @@ class Propane
@could_be_empty @could_be_empty
end end
# Build the start token set for the RuleSet.
#
# @return [Set<Token>]
# Start token set for the RuleSet.
def start_token_set
if @_start_token_set.nil?
@_start_token_set = Set.new
@rules.each do |rule|
rule.components.each do |component|
if component.is_a?(Token)
@_start_token_set << component
break
else
@_start_token_set += component.start_token_set
unless component.could_be_empty?
break
end
end
end
end
end
@_start_token_set
end
end end
end end