class Parser::Runner::RubyParse

Public Class Methods

new() click to toggle source
Calls superclass method Parser::Runner::new
# File lib/parser/runner/ruby_parse.rb, line 92
def initialize
  super

  @locate = false
  @emit_ruby = false
end

Private Instance Methods

process(buffer) click to toggle source
# File lib/parser/runner/ruby_parse.rb, line 131
def process(buffer)
  ast = @parser.parse(buffer)

  if @locate
    LocationProcessor.new.process(ast)
  elsif !@benchmark
    if @emit_ruby
      puts ast.inspect
    else
      puts ast.to_s
    end
  end
end
process_all_input() click to toggle source
Calls superclass method Parser::Runner#process_all_input
# File lib/parser/runner/ruby_parse.rb, line 123
def process_all_input
  if input_size > 1
    puts "Using #{@parser_class} to parse #{input_size} files."
  end

  super
end
runner_name() click to toggle source
# File lib/parser/runner/ruby_parse.rb, line 101
def runner_name
  'ruby-parse'
end
setup_option_parsing(opts) click to toggle source
Calls superclass method Parser::Runner#setup_option_parsing
# File lib/parser/runner/ruby_parse.rb, line 105
def setup_option_parsing(opts)
  super(opts)

  opts.on '-L', '--locate', 'Explain how source maps for AST nodes are laid out' do |v|
    @locate = v
  end

  opts.on '-E', '--explain', 'Explain how the source is tokenized' do
    ENV['RACC_DEBUG'] = '1'

    Lexer.send :include, Lexer::Explanation
  end

  opts.on '--emit-ruby', 'Emit S-expressions as valid Ruby code' do
    @emit_ruby = true
  end
end