class ANTLR3::Debug::RuleTracer
RuleTracer
is simple debug event listener that writes the names of rule methods as they are entered and exitted to an output stream.
Constants
- ARROW_IN
- ARROW_OUT
Attributes
device[RW]
level[R]
spaces_per_indent[RW]
Public Class Methods
new( options = {} )
click to toggle source
# File lib/antlr3/debug/rule-tracer.rb, line 21 def initialize( options = {} ) @input = options[ :input ] @level = 0 @spaces_per_indent = options[ :spaces_per_indent ] || 2 @device = options[ :device ] || options[ :output ] || $stderr end
Public Instance Methods
enter_rule( grammar_file, name )
click to toggle source
# File lib/antlr3/debug/rule-tracer.rb, line 28 def enter_rule( grammar_file, name ) indent = @level * @spaces_per_indent @device.print( ' ' * indent, ARROW_IN, name ) if @input input_symbol = @input.look || :EOF @device.puts( " look = %p" % input_symbol ) else @device.print( "\n" ) end @level += 1 end
exit_rule( grammar_file, name )
click to toggle source
# File lib/antlr3/debug/rule-tracer.rb, line 41 def exit_rule( grammar_file, name ) @level -= 1 indent = @level * @spaces_per_indent @device.print( ' ' * indent, ARROW_OUT, name ) if @input input_symbol = ( @input.look || :EOF ) @device.puts( " look = %p" % input_symbol ) else @device.print( "\n" ) end end