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.



597
598
599
# File 'lib/lxl.rb', line 597

def initialize(re_to_chr)
  @re_to_chr = re_to_chr
end

Instance Method Details

#scan(string) ⇒ Object



601
602
603
604
605
606
607
608
# File 'lib/lxl.rb', line 601

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