Class: Rly::Production

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index, name, prod, precedence = [:right, 0], block = nil) ⇒ Production

FIXME line!!!



7
8
9
10
11
12
13
14
15
16
# File 'lib/rly/parse/production.rb', line 7

def initialize(index, name, prod, precedence=[:right, 0], block=nil)
  @index = index
  @name = name
  @prod = prod
  @precedence = precedence
  @block = block

  @usyms = []
  prod.each { |sym| @usyms << sym unless @usyms.include?(sym) }
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



3
4
5
# File 'lib/rly/parse/production.rb', line 3

def block
  @block
end

#indexObject (readonly)

Returns the value of attribute index.



3
4
5
# File 'lib/rly/parse/production.rb', line 3

def index
  @index
end

#lineObject (readonly)

Returns the value of attribute line.



3
4
5
# File 'lib/rly/parse/production.rb', line 3

def line
  @line
end

#lr0_addedObject

Returns the value of attribute lr0_added.



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

def lr0_added
  @lr0_added
end

#lr_itemsObject

Returns the value of attribute lr_items.



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

def lr_items
  @lr_items
end

#lr_nextObject

Returns the value of attribute lr_next.



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

def lr_next
  @lr_next
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rly/parse/production.rb', line 3

def name
  @name
end

#precedenceObject (readonly)

Returns the value of attribute precedence.



3
4
5
# File 'lib/rly/parse/production.rb', line 3

def precedence
  @precedence
end

#prodObject (readonly)

Returns the value of attribute prod.



3
4
5
# File 'lib/rly/parse/production.rb', line 3

def prod
  @prod
end

#reducedObject

Returns the value of attribute reduced.



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

def reduced
  @reduced
end

#usymsObject (readonly)

Returns the value of attribute usyms.



3
4
5
# File 'lib/rly/parse/production.rb', line 3

def usyms
  @usyms
end

Instance Method Details

#inspectObject



22
23
24
# File 'lib/rly/parse/production.rb', line 22

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

#lengthObject



26
27
28
# File 'lib/rly/parse/production.rb', line 26

def length
  @prod.length
end

#to_sObject



18
19
20
# File 'lib/rly/parse/production.rb', line 18

def to_s
  "#{name} -> #{@prod.map { |s| s.to_s }.join(' ')}"
end