module ANTLR3::Main::Options
Defines command-line options and attribute mappings shared by all types of Main
classes.
Attributes
debug_socket[RW]
encoding[RW]
the input encoding type; defaults to nil
(currently, not used)
input[RW]
the input stream used by the Main
script; defaults to $stdin
interactive[RW]
a boolean flag indicating whether or not to run the Main
script in interactive mode; defaults to false
no_output[RW]
profile[RW]
ruby_prof[RW]
Public Class Methods
new( options = {} )
click to toggle source
# File lib/antlr3/main.rb, line 68 def initialize( options = {} ) @no_output = options.fetch( :no_output, false ) @profile = options.fetch( :profile, false ) @debug_socket = options.fetch( :debug_socket, false ) @ruby_prof = options.fetch( :ruby_prof, false ) @encoding = options.fetch( :encoding, nil ) @interactive = options.fetch( :interactive, false ) @input = options.fetch( :input, $stdin ) end
Public Instance Methods
parse_options( argv = ARGV )
click to toggle source
constructs an OptionParser and parses the argument list provided by argv
# File lib/antlr3/main.rb, line 79 def parse_options( argv = ARGV ) oparser = OptionParser.new do | o | o.separator 'Input Options:' o.on( '-i', '-e', '--input "text to process"', doc( <<-END ) ) { |val| @input = val } | a string to use as direct input to the recognizer END o.on( '-I', '--interactive', doc( <<-END ) ) { @interactive = true } | run an interactive session with the recognizer END end setup_options( oparser ) return oparser.parse( argv ) end
Private Instance Methods
doc( description_string )
click to toggle source
# File lib/antlr3/main.rb, line 102 def doc( description_string ) description_string.chomp! description_string.gsub!( /^ *\| ?/, '' ) description_string.gsub!( /\s+/, ' ' ) return description_string end
setup_options( oparser )
click to toggle source
# File lib/antlr3/main.rb, line 98 def setup_options( oparser ) # overridable hook to modify / append options end