Class: EBNFLL1Parser::ProdResult

Inherits:
Object
  • Object
show all
Defined in:
examples/ebnf-ll1-parser/parser.rb

Overview

An internal class used for capturing the values of a production.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prod, *values) ⇒ ProdResult

Returns a new instance of ProdResult.



21
22
23
# File 'examples/ebnf-ll1-parser/parser.rb', line 21

def initialize(prod, *values)
  @prod, @values = prod, values
end

Instance Attribute Details

#prodObject

Returns the value of attribute prod.



18
19
20
# File 'examples/ebnf-ll1-parser/parser.rb', line 18

def prod
  @prod
end

#valuesObject

Returns the value of attribute values.



19
20
21
# File 'examples/ebnf-ll1-parser/parser.rb', line 19

def values
  @values
end

Instance Method Details

#inspectObject



29
30
31
# File 'examples/ebnf-ll1-parser/parser.rb', line 29

def inspect
  "(#{prod} #{values.map(&:inspect).join(' ')})"
end

#to_aryObject



25
26
27
# File 'examples/ebnf-ll1-parser/parser.rb', line 25

def to_ary
  values.map {|v| v.respond_to?(:to_ary) ? v.to_ary : v}.unshift(@prod)
end