class LL::Rule
Class containing details of a single rule in a grammar.
Attributes
branches[R]
name[R]
references[R]
source_line[R]
Public Class Methods
new(name, source_line)
click to toggle source
@param [String] name @param [LL::SourceLine] source_line
# File lib/ll/rule.rb, line 12 def initialize(name, source_line) @name = name @branches = [] @source_line = source_line @references = 0 end
Public Instance Methods
add_branch(steps, source_line, ruby_code = nil)
click to toggle source
@see [LL::Branch#initialize]
# File lib/ll/rule.rb, line 22 def add_branch(steps, source_line, ruby_code = nil) branches << Branch.new(steps, source_line, ruby_code) end
first_set()
click to toggle source
Returns an Array containing the terminals that make up the FIRST() set of this rule.
@return [Array<LL::Terminal>]
# File lib/ll/rule.rb, line 36 def first_set terminals = [] branches.each do |branch| terminals += branch.first_set end return terminals end
increment_references()
click to toggle source
# File lib/ll/rule.rb, line 26 def increment_references @references += 1 end
inspect()
click to toggle source
@return [String]
# File lib/ll/rule.rb, line 49 def inspect return "Rule(name: #{name.inspect}, branches: #{branches.inspect})" end