Class: Grammar::NT

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol, index = 0) ⇒ NT

Returns a new instance of NT.



19
20
21
22
23
# File 'lib/zipf/grammar.rb', line 19

def initialize symbol, index=0
  @symbol = symbol
  @index = index
  @span = Span.new
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



17
18
19
# File 'lib/zipf/grammar.rb', line 17

def index
  @index
end

#spanObject

Returns the value of attribute span.



17
18
19
# File 'lib/zipf/grammar.rb', line 17

def span
  @span
end

#symbolObject

Returns the value of attribute symbol.



17
18
19
# File 'lib/zipf/grammar.rb', line 17

def symbol
  @symbol
end

Instance Method Details

#to_sObject



25
26
27
# File 'lib/zipf/grammar.rb', line 25

def to_s
  "NT(#{@span.left},#{@span.right})<#{@symbol},#{@index}>"
end