class LL::Branch

The Branch class contains information of a single rule branch such as the steps and the associated callback code.

Attributes

ruby_code[R]
source_line[R]
steps[R]

Public Class Methods

new(steps, source_line, ruby_code = nil) click to toggle source

@param [Array] steps @param [LL::SourceLine] source_line @param [String] ruby_code

# File lib/ll/branch.rb, line 14
def initialize(steps, source_line, ruby_code = nil)
  @steps       = steps
  @source_line = source_line
  @ruby_code   = ruby_code
end

Public Instance Methods

first_set() click to toggle source

Returns the FIRST() set of this branch.

@return [Array<LL::Terminal>]

# File lib/ll/branch.rb, line 25
def first_set
  first = steps[0]

  if first.is_a?(Rule)
    return first.first_set
  elsif first
    return [first]
  else
    return []
  end
end
follow_set() click to toggle source

Returns the FOLLOW() set of this branch.

@return [Array<LL::Terminal>]

# File lib/ll/branch.rb, line 42
def follow_set
  follow = steps[1]

  if follow.is_a?(Rule)
    set = follow.first_set
  elsif follow
    set = [follow]
  else
    set = []
  end

  return set
end
inspect() click to toggle source

@return [String]

# File lib/ll/branch.rb, line 59
def inspect
  return "Branch(steps: #{steps.inspect}, ruby_code: #{ruby_code.inspect})"
end