Class: ANTLR3::Test::Grammar::InlineGrammar
- Inherits:
-
ANTLR3::Test::Grammar
- Object
- ANTLR3::Test::Grammar
- ANTLR3::Test::Grammar::InlineGrammar
- Defined in:
- lib/antlr3/test/grammar.rb
Overview
class Grammar
Constant Summary
Constants inherited from ANTLR3::Test::Grammar
CLASS_TO_TYPE, GRAMMAR_TYPES, TYPE_TO_CLASS
Constants included from DependantFile
DependantFile::GLOBAL_DEPENDENCIES
Instance Attribute Summary collapse
-
#host_file ⇒ Object
Returns the value of attribute host_file.
-
#host_line ⇒ Object
Returns the value of attribute host_line.
Attributes inherited from ANTLR3::Test::Grammar
#name, #source, #type, #verbose
Attributes included from DependantFile
Instance Method Summary collapse
-
#initialize(source, options = {}) {|_self| ... } ⇒ InlineGrammar
constructor
A new instance of InlineGrammar.
- #inspect ⇒ Object
- #output_directory ⇒ Object
- #path=(v) ⇒ Object
Methods inherited from ANTLR3::Test::Grammar
#clean!, #combined?, #compile, #compile!, global_dependency, #has_lexer?, #has_parser?, #imported_target_files, #imports, inline, #lexer?, #lexer_class_name, #lexer_file_name, #parser?, #parser_class_name, #parser_file_name, #target_files, #tree?, #tree_parser_class_name, #tree_parser_file_name
Methods included from DependantFile
#dependencies, #depends_on, #stale?
Constructor Details
#initialize(source, options = {}) {|_self| ... } ⇒ InlineGrammar
Returns a new instance of InlineGrammar.
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/antlr3/test/grammar.rb', line 271 def initialize( source, = {} ) host = call_stack.find { |call| call.file != __FILE__ } @host_file = File.( [ :file ] || host.file ) @host_line = ( [ :line ] || host.line ) @output_directory = .fetch( :output_directory, File.dirname( @host_file ) ) @verbose = .fetch( :verbose, $VERBOSE ) @source = source.to_s.fixed_indent( 0 ) @source.strip! study write_to_disk build_dependencies yield( self ) if block_given? end |
Instance Attribute Details
#host_file ⇒ Object
Returns the value of attribute host_file.
269 270 271 |
# File 'lib/antlr3/test/grammar.rb', line 269 def host_file @host_file end |
#host_line ⇒ Object
Returns the value of attribute host_line.
269 270 271 |
# File 'lib/antlr3/test/grammar.rb', line 269 def host_line @host_line end |
Instance Method Details
#inspect ⇒ Object
299 300 301 |
# File 'lib/antlr3/test/grammar.rb', line 299 def inspect sprintf( 'inline grammar %s (%s:%s)', name, @host_file, @host_line ) end |
#output_directory ⇒ Object
289 290 291 292 |
# File 'lib/antlr3/test/grammar.rb', line 289 def output_directory @output_directory and return @output_directory File.basename( @host_file ) end |
#path=(v) ⇒ Object
294 295 296 297 |
# File 'lib/antlr3/test/grammar.rb', line 294 def path=( v ) previous, @path = @path, v.to_s previous == @path or write_to_disk end |