Sha256: 4e3765d792ab34e8862bed0a3b4af2e26202e4025bf24435dd6bb0e90a8d0ca1
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
# encoding: utf-8 require "pp" module Antelope module Generator # Generates a ruby parser. class Ruby < Base register_as "ruby" # Creates an action table for the parser. # # @return [String] def generate_action_table out = "" PP.pp(table, out) out end # Outputs an array of all of the productions. # # @return [String] def generate_productions_list out = "[" productions.each do |(label, size, block)| out << "[" << label.name.inspect << ", " << size.inspect << ", " block = if block.empty? "proc { |_| _ }" else "proc #{production.block}" end out << block << "],\n" end out.chomp!(",\n") out << "]" end # Actually performs the generation. Takes the template from # ruby.erb and outputs it to `<file>_parser.rb`. # # @return [void] def generate template "ruby.erb", "#{file}.rb" do |body| sprintf(grammar.compiler.body, :write => body) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
antelope-0.1.8 | lib/antelope/generator/ruby.rb |