Parser::Lexer::Explanation

Public Class Methods

included(klass) click to toggle source
# File lib/parser/lexer/explanation.rb, line 5
def self.included(klass)
  klass.class_exec do
    alias_method :state_before_explanation=,  :state=
    alias_method :advance_before_explanation, :advance

    remove_method :state=, :advance
  end
end

Public Instance Methods

advance() click to toggle source

Like advance, but also pretty-print the token and its position in the stream to `stdout`.

# File lib/parser/lexer/explanation.rb, line 16
def advance
  type, (val, range) = advance_before_explanation

  puts decorate(range,
                "\e[0;32m#{type} #{val.inspect}\e[0m",
                "#{state.to_s.ljust(12)} #{@cond} #{@cmdarg}\e[0m")

  [ type, [val, range] ]
end
state=(new_state) click to toggle source
# File lib/parser/lexer/explanation.rb, line 26
def state=(new_state)
  puts "  \e[1;33m>>> STATE SET <<<\e[0m " +
       "#{new_state.to_s.ljust(12)} #{@cond} #{@cmdarg}".rjust(66)

  self.state_before_explanation = new_state
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.