Class: Rly::LRItem
- Inherits:
-
Object
- Object
- Rly::LRItem
- Defined in:
- lib/rly/parse/lr_item.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#lookaheads ⇒ Object
readonly
Returns the value of attribute lookaheads.
-
#lr_after ⇒ Object
Returns the value of attribute lr_after.
-
#lr_before ⇒ Object
Returns the value of attribute lr_before.
-
#lr_index ⇒ Object
readonly
Returns the value of attribute lr_index.
-
#lr_next ⇒ Object
Returns the value of attribute lr_next.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prod ⇒ Object
readonly
Returns the value of attribute prod.
-
#usyms ⇒ Object
readonly
Returns the value of attribute usyms.
Instance Method Summary collapse
-
#initialize(p, n) ⇒ LRItem
constructor
A new instance of LRItem.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(p, n) ⇒ LRItem
Returns a new instance of LRItem.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rly/parse/lr_item.rb', line 6 def initialize(p, n) @name = p.name @prod = p.prod.dup @index = p.index @lr_index = n @lookaheads = {} @prod.insert(n, :'.') @length = @prod.length @usyms = p.usyms @lr_items = [] @lr_next = nil end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
4 5 6 |
# File 'lib/rly/parse/lr_item.rb', line 4 def index @index end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
4 5 6 |
# File 'lib/rly/parse/lr_item.rb', line 4 def length @length end |
#lookaheads ⇒ Object (readonly)
Returns the value of attribute lookaheads.
4 5 6 |
# File 'lib/rly/parse/lr_item.rb', line 4 def lookaheads @lookaheads end |
#lr_after ⇒ Object
Returns the value of attribute lr_after.
3 4 5 |
# File 'lib/rly/parse/lr_item.rb', line 3 def lr_after @lr_after end |
#lr_before ⇒ Object
Returns the value of attribute lr_before.
3 4 5 |
# File 'lib/rly/parse/lr_item.rb', line 3 def lr_before @lr_before end |
#lr_index ⇒ Object (readonly)
Returns the value of attribute lr_index.
4 5 6 |
# File 'lib/rly/parse/lr_item.rb', line 4 def lr_index @lr_index end |
#lr_next ⇒ Object
Returns the value of attribute lr_next.
3 4 5 |
# File 'lib/rly/parse/lr_item.rb', line 3 def lr_next @lr_next end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/rly/parse/lr_item.rb', line 4 def name @name end |
#prod ⇒ Object (readonly)
Returns the value of attribute prod.
4 5 6 |
# File 'lib/rly/parse/lr_item.rb', line 4 def prod @prod end |
#usyms ⇒ Object (readonly)
Returns the value of attribute usyms.
4 5 6 |
# File 'lib/rly/parse/lr_item.rb', line 4 def usyms @usyms end |
Instance Method Details
#inspect ⇒ Object
28 29 30 |
# File 'lib/rly/parse/lr_item.rb', line 28 def inspect "#<LRItem #{to_s}>" end |
#to_s ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/rly/parse/lr_item.rb', line 20 def to_s if @prod "#{@name} -> #{@prod.join(' ')}" else "#{@name} -> <empty>" end end |