Class: Rly::LRItem

Inherits:
Object
  • Object
show all
Defined in:
lib/rly/parse/lr_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(p, n) ⇒ 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

#indexObject (readonly)

Returns the value of attribute index


4
5
6
# File 'lib/rly/parse/lr_item.rb', line 4

def index
  @index
end

#lengthObject (readonly)

Returns the value of attribute length


4
5
6
# File 'lib/rly/parse/lr_item.rb', line 4

def length
  @length
end

#lookaheadsObject (readonly)

Returns the value of attribute lookaheads


4
5
6
# File 'lib/rly/parse/lr_item.rb', line 4

def lookaheads
  @lookaheads
end

#lr_afterObject

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_beforeObject

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_indexObject (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_nextObject

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

#nameObject (readonly)

Returns the value of attribute name


4
5
6
# File 'lib/rly/parse/lr_item.rb', line 4

def name
  @name
end

#prodObject (readonly)

Returns the value of attribute prod


4
5
6
# File 'lib/rly/parse/lr_item.rb', line 4

def prod
  @prod
end

#usymsObject (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

#inspectObject


28
29
30
# File 'lib/rly/parse/lr_item.rb', line 28

def inspect
  "#<LRItem #{to_s}>"
end

#to_sObject


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