class ANTLR3::AST::Wizard::PatternLexer
A class that is used internally by AST::Wizard
to tokenize tree patterns
Constants
- PATTERNS
Attributes
error[R]
error?[R]
pattern[R]
text[R]
Public Class Methods
new( pattern )
click to toggle source
# File lib/antlr3/tree/wizard.rb, line 145 def initialize( pattern ) @pattern = pattern.to_s @scanner = StringScanner.new( pattern ) @text = '' @error = false end
Public Instance Methods
next_token()
click to toggle source
# File lib/antlr3/tree/wizard.rb, line 152 def next_token begin @scanner.eos? and return EOF type, = PATTERNS.find do |type, pattern| @scanner.scan( pattern ) end case type when nil type, @text, @error = EOF, '', true break when :identifier then @text = @scanner.matched when :argument # remove escapes from \] sequences in the text argument ( @text = @scanner[ 1 ] ).gsub!( /\\(?=[\[\]])/, '' ) end end while type == :space return type end