Module: Parser::Lexer::Explanation
- Defined in:
- lib/parser/lexer/explanation.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#advance ⇒ Object
Like #advance, but also pretty-print the token and its position in the stream to ‘stdout`.
- #state=(new_state) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/parser/lexer/explanation.rb', line 7 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 |
Instance Method Details
#advance ⇒ Object
Like #advance, but also pretty-print the token and its position in the stream to ‘stdout`.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/parser/lexer/explanation.rb', line 18 def advance type, (val, range) = advance_before_explanation more = "(in-kwarg)" if @context.in_kwarg puts decorate(range, Color.green("#{type} #{val.inspect}"), "#{state.to_s.ljust(12)} #{@cond} #{@cmdarg} #{more}") [ type, [val, range] ] end |