class Antelope::Generator::HTML

Generates an output file, mainly for debugging. Included always as a generator for a grammar.

Public Class Methods

new(*) click to toggle source

Defines singleton method for every mod that the grammar passed to the generator.

@see Generator#initialize

Calls superclass method Antelope::Generator::Base::new
# File lib/antelope/generator/html.rb, line 18
def initialize(*)
  super
  mods.each do |k, v|
    define_singleton_method (k) { v }
  end
end

Public Instance Methods

generate() click to toggle source

Actually performs the generation. Uses the template in output.erb, and generates the file ‘<file>.output`.

@return [void]

# File lib/antelope/generator/html.rb, line 44
def generate
  template "html/html", "#{file}.html"
  template "html/css", "#{file}.css"
  template "html/js", "#{file}.js"
end
unused_symbols() click to toggle source
# File lib/antelope/generator/html.rb, line 25
def unused_symbols
  @_unused_symbols ||= begin
    used = grammar.all_productions.map(&:items).flatten.uniq
    all  = grammar.symbols.map do |s|
      if Symbol === s
        grammar.find_token(s)
      else
        s
      end
    end

    all - used - [grammar.find_token(:"$start")]
  end
end