Class: Dhaka::Channel
- Inherits:
-
Object
- Object
- Dhaka::Channel
- Defined in:
- lib/dhaka/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/dhaka/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:
4 5 6 |
# File 'lib/dhaka/parser/channel.rb', line 4 def end_item @end_item end |
#start_item ⇒ Object (readonly)
:nodoc:
4 5 6 |
# File 'lib/dhaka/parser/channel.rb', line 4 def start_item @start_item end |
Instance Method Details
#eql?(other) ⇒ Boolean
22 23 24 |
# File 'lib/dhaka/parser/channel.rb', line 22 def eql? other start_item.eql?(other.start_item) && end_item.eql?(other.end_item) end |
#hash ⇒ Object
26 27 28 |
# File 'lib/dhaka/parser/channel.rb', line 26 def hash start_item.hash ^ end_item.hash end |
#propagate(cargo) ⇒ Object
12 13 14 15 16 |
# File 'lib/dhaka/parser/channel.rb', line 12 def propagate cargo initial_size = end_item.lookaheadset.size end_item.lookaheadset.merge(cargo) (end_item.lookaheadset.size - initial_size) > 0 end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/dhaka/parser/channel.rb', line 18 def to_s "Channel from #{start_item} to #{end_item}" end |