Module: ANTLR3::Main::Options
- Included in:
- Main
- Defined in:
- lib/antlr3/main.rb
Overview
Defines command-line options and attribute mappings shared by all types of Main classes.
Instance Attribute Summary collapse
-
#debug_socket ⇒ Object
Returns the value of attribute debug_socket.
-
#encoding ⇒ Object
the input encoding type; defaults to
nil
(currently, not used). -
#input ⇒ Object
the input stream used by the Main script; defaults to
$stdin
. -
#interactive ⇒ Object
a boolean flag indicating whether or not to run the Main script in interactive mode; defaults to
false
. -
#no_output ⇒ Object
Returns the value of attribute no_output.
-
#profile ⇒ Object
Returns the value of attribute profile.
-
#ruby_prof ⇒ Object
Returns the value of attribute ruby_prof.
Instance Method Summary collapse
- #initialize(options = {}) ⇒ Object
-
#parse_options(argv = ARGV) ⇒ Object
constructs an OptionParser and parses the argument list provided by
argv
.
Instance Attribute Details
#debug_socket ⇒ Object
Returns the value of attribute debug_socket.
65 66 67 |
# File 'lib/antlr3/main.rb', line 65 def debug_socket @debug_socket end |
#encoding ⇒ Object
the input encoding type; defaults to nil
(currently, not used)
57 58 59 |
# File 'lib/antlr3/main.rb', line 57 def encoding @encoding end |
#input ⇒ Object
the input stream used by the Main script; defaults to $stdin
59 60 61 |
# File 'lib/antlr3/main.rb', line 59 def input @input end |
#interactive ⇒ Object
a boolean flag indicating whether or not to run the Main script in interactive mode; defaults to false
62 63 64 |
# File 'lib/antlr3/main.rb', line 62 def interactive @interactive end |
#no_output ⇒ Object
Returns the value of attribute no_output.
63 64 65 |
# File 'lib/antlr3/main.rb', line 63 def no_output @no_output end |
#profile ⇒ Object
Returns the value of attribute profile.
64 65 66 |
# File 'lib/antlr3/main.rb', line 64 def profile @profile end |
#ruby_prof ⇒ Object
Returns the value of attribute ruby_prof.
66 67 68 |
# File 'lib/antlr3/main.rb', line 66 def ruby_prof @ruby_prof end |
Instance Method Details
#initialize(options = {}) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/antlr3/main.rb', line 68 def initialize( = {} ) @no_output = .fetch( :no_output, false ) @profile = .fetch( :profile, false ) @debug_socket = .fetch( :debug_socket, false ) @ruby_prof = .fetch( :ruby_prof, false ) @encoding = .fetch( :encoding, nil ) @interactive = .fetch( :interactive, false ) @input = .fetch( :input, $stdin ) end |
#parse_options(argv = ARGV) ⇒ Object
constructs an OptionParser and parses the argument list provided by argv
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/antlr3/main.rb', line 79 def ( 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 ( oparser ) return oparser.parse( argv ) end |