Class: Ruco::Identifier

Inherits:
Object
  • Object
show all
Defined in:
lib/ruco.rb

Direct Known Subclasses

Variation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Identifier

Returns a new instance of Identifier.



28
29
30
31
# File 'lib/ruco.rb', line 28

def initialize(name)
	@name = name
	@prodset = prodset
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



27
28
29
# File 'lib/ruco.rb', line 27

def name
  @name
end

#prodsetObject

Returns the value of attribute prodset.



27
28
29
# File 'lib/ruco.rb', line 27

def prodset
  @prodset
end

Instance Method Details

#generate(indent = 0) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/ruco.rb', line 33

def generate(indent=0)

	code = "production->#{name.downcase} = #{name.downcase};"
	if @prodset[name][:count] > 1
		code = "production->#{name.downcase.pluralize}.push_back(#{name.downcase});"
	end
	"#{("\t"*indent)}#{name}<#{name.downcase}> (. #{code} .)"
end