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 96 def initialize super @locate = false @emit_ruby = false @emit_json = false end
Private Instance Methods
process(buffer)
click to toggle source
# File lib/parser/runner/ruby_parse.rb, line 140 def process(buffer) ast = @parser.parse(buffer) if @locate LocationProcessor.new.process(ast) elsif !@benchmark if @emit_ruby puts ast.inspect elsif @emit_json puts(ast ? JSON.generate(ast.to_sexp_array) : nil) 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 132 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 106 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 110 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 opts.on '--emit-json', 'Emit S-expressions as valid JSON' do @emit_json = true end end