Class: Dhaka::Channel
- Inherits:
-
Object
- Object
- Dhaka::Channel
- Defined in:
- lib/parser/channel.rb
Overview
Represents channels for pumping of lookaheads between items
Direct Known Subclasses
Instance Attribute Summary collapse
-
#end_item ⇒ Object
readonly
:nodoc:.
-
#start_item ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(grammar, start_item, end_item) ⇒ Channel
constructor
A new instance of Channel.
- #propagate(cargo) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(grammar, start_item, end_item) ⇒ Channel
Returns a new instance of Channel.
6 7 8 9 10 |
# File 'lib/parser/channel.rb', line 6 def initialize(grammar, start_item, end_item) @grammar = grammar @start_item = start_item @end_item = end_item end |
Instance Attribute Details
#end_item ⇒ Object (readonly)
:nodoc:
5 6 7 |
# File 'lib/parser/channel.rb', line 5 def end_item @end_item end |
#start_item ⇒ Object (readonly)
:nodoc:
5 6 7 |
# File 'lib/parser/channel.rb', line 5 def start_item @start_item end |
Instance Method Details
#eql?(other) ⇒ Boolean
19 20 21 |
# File 'lib/parser/channel.rb', line 19 def eql? other @start_item.eql?(other.start_item) and @end_item.eql?(other.end_item) end |
#hash ⇒ Object
22 23 24 |
# File 'lib/parser/channel.rb', line 22 def hash @start_item.hash ^ @end_item.hash end |
#propagate(cargo) ⇒ Object
11 12 13 14 15 |
# File 'lib/parser/channel.rb', line 11 def propagate cargo diff = cargo - @end_item.lookaheadset @end_item.lookaheadset.merge(diff) !diff.empty? end |
#to_s ⇒ Object
16 17 18 |
# File 'lib/parser/channel.rb', line 16 def to_s "Channel from #{@start_item} to #{@end_item}" end |