Class: LXL::Lexer

Inherits:
Object
  • Object
show all
Defined in:
lib/lxl.rb

Overview

Based on John Carter’s LittleLexer (littlelexer.rubyforge.org).

Defined Under Namespace

Classes: LexerJammed

Instance Method Summary collapse

Constructor Details

#initialize(re_to_chr) ⇒ Lexer

Returns a new instance of Lexer.



624
625
626
# File 'lib/lxl.rb', line 624

def initialize(re_to_chr)
  @re_to_chr = re_to_chr
end

Instance Method Details

#scan(string) ⇒ Object



628
629
630
631
632
633
634
635
# File 'lib/lxl.rb', line 628

def scan(string)
  types,tokens = [],[]
  next_token(string) do |type,token|
    types << type
    tokens << token
  end
  [types,tokens]
end