require 'tokens'

module RbNFA
  class Lexer
    @@TOKENS = [ OneOrMoreToken, ZeroOrMoreToken, ZeroOrOneToken,
                 BeginGroupToken, EndGroupToken, AlternationToken]

    def lex(regexp)
      skip = false
      result = []
      regexp.chars.with_index do |char,index|
        if skip 
          skip = false
        elsif char == '\\'
          result << LiteralToken.new(regexp[index+1])
          skip = true
        else    
          possible = @@TOKENS.select { |token| token.cover(char) }
          if not possible.empty?
            result << possible.first.create(char)
          else
            result << LiteralToken.new(char)
          end
        end
      end
      result
    end
  end
end

require 'tokens'

module RbNFA
  class Lexer
    @@tokens = [ OneOrMoreToken, ZeroOrMoreToken, ZeroOrOneToken,
                 BeginGroupToken, EndGroupToken, AlternationToken]

    def lex(regexp)
      skip = false
      result = []
      regexp.chars.with_index do |char,index|
        if skip 
          skip = false
        elsif char == '\\'
          result << LiteralToken.new(regexp[index+1])
          skip = true
        else    
          possible = @@tokens.select { |token| token.cover(char) }
          if not possible.empty?
            result << possible.first.create(char)
          else
            result << LiteralToken.new(char)
          end
        end
      end
      result
    end
  end
end

--- 
+++ 
@@ -2,7 +2,7 @@
 
 module RbNFA
   class Lexer
-    @@tokens = [ OneOrMoreToken, ZeroOrMoreToken, ZeroOrOneToken,
+    @@TOKENS = [ OneOrMoreToken, ZeroOrMoreToken, ZeroOrOneToken,
                  BeginGroupToken, EndGroupToken, AlternationToken]
 
     def lex(regexp)
@@ -15,7 +15,7 @@
           result << LiteralToken.new(regexp[index+1])
           skip = true
         else    
-          possible = @@tokens.select { |token| token.cover(char) }
+          possible = @@TOKENS.select { |token| token.cover(char) }
           if not possible.empty?
             result << possible.first.create(char)
           else
Change tokens name to uppercase.
