Merge branch 'master' of https://github.com/dopefishh/cc1516
[cc1516.git] / lex.icl
diff --git a/lex.icl b/lex.icl
index 21a29e9..aa34987 100644 (file)
--- a/lex.icl
+++ b/lex.icl
@@ -1,14 +1,16 @@
 implementation module lex
 
 import Control.Monad, Control.Applicative
-import Data.Either, Data.Func
+import Data.Either, Data.Func, Data.Void
 from StdFunc import o
 import StdBool
 import StdList
 import StdChar
 import StdString
+import StdTuple
 
 import yard
+import AST
 
 :: LexItem
        = LexToken Int TokenValue
@@ -18,9 +20,7 @@ import yard
        | LexItemError String
 
 lexer :: [Char] -> LexerOutput
-lexer r = case runParser (lexProgram 1 1) r of
-       (Right p, _) = Right p
-       (Left e, _) = Left e
+lexer r = fst $ runParser (lexProgram 1 1) r
 
 lexProgram :: Int Int -> Parser Char [Token]
 lexProgram line column = lexToken >>= \t->case t of
@@ -30,7 +30,7 @@ lexProgram line column = lexToken >>= \t->case t of
        (LexItemError e) = fail <?>
                PositionalError line column ("LexerError: " +++ e)
        (LexToken c t) = lexProgram line (column+c)
-               >>= \rest->pure [{line=line, column=column, token=t}:rest]
+               >>= \rest->pure [({line=line,col=column}, t):rest]
 
 lexToken :: Parser Char LexItem
 lexToken =