Class: LL::Branch
- Inherits:
-
Object
- Object
- LL::Branch
- Defined in:
- lib/ll/branch.rb
Overview
The Branch class contains information of a single rule branch such as the steps and the associated callback code.
Instance Attribute Summary (collapse)
-
- (Object) ruby_code
readonly
Returns the value of attribute ruby_code.
-
- (Object) source_line
readonly
Returns the value of attribute source_line.
-
- (Object) steps
readonly
Returns the value of attribute steps.
Instance Method Summary (collapse)
-
- (Array<LL::Terminal>) first_set
Returns the FIRST() set of this branch.
-
- (Array<LL::Terminal>) follow_set
Returns the FOLLOW() set of this branch.
-
- (Branch) initialize(steps, source_line, ruby_code = nil)
constructor
A new instance of Branch.
-
- (String) inspect
Constructor Details
- (Branch) initialize(steps, source_line, ruby_code = nil)
Returns a new instance of Branch
14 15 16 17 18 |
# 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 |
Instance Attribute Details
- (Object) ruby_code (readonly)
Returns the value of attribute ruby_code
7 8 9 |
# File 'lib/ll/branch.rb', line 7 def ruby_code @ruby_code end |
- (Object) source_line (readonly)
Returns the value of attribute source_line
7 8 9 |
# File 'lib/ll/branch.rb', line 7 def source_line @source_line end |
- (Object) steps (readonly)
Returns the value of attribute steps
7 8 9 |
# File 'lib/ll/branch.rb', line 7 def steps @steps end |
Instance Method Details
- (Array<LL::Terminal>) first_set
Returns the FIRST() set of this branch.
25 26 27 28 29 30 31 32 33 34 35 |
# 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 |
- (Array<LL::Terminal>) follow_set
Returns the FOLLOW() set of this branch.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# 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 |
- (String) inspect
59 60 61 |
# File 'lib/ll/branch.rb', line 59 def inspect return "Branch(steps: #{steps.inspect}, ruby_code: #{ruby_code.inspect})" end |