lib/sequitur/formatter/base_text.rb in sequitur-0.1.23 vs lib/sequitur/formatter/base_text.rb in sequitur-0.1.24
- old
+ new
@@ -10,10 +10,12 @@
# # Output the result to the standard console output
# formatter = Sequitur::Formatter::BaseText.new(STDOUT)
# # Render the grammar (through a visitor)
# formatter.run(some_grammar.visitor)
class BaseText < BaseFormatter
+ attr_reader :prod_lookup
+
# Constructor.
# @param anIO [IO] The output stream to which the rendered grammar
# is written.
def initialize(anIO)
super(anIO)
@@ -71,20 +73,14 @@
output.print ".\n"
end
private
- # Read accessor of the production lookup
- def prod_lookup
- return @prod_lookup
- end
-
# Generate a name of a given production.
# @param aProduction [Production]
def prod_name(aProduction)
prod_index = prod_lookup[aProduction]
- name = prod_index.zero? ? 'start' : "P#{prod_index}"
- return name
+ prod_index.zero? ? 'start' : "P#{prod_index}"
end
end # class
end # module
end # module