comments parsen is kapot
[cc1516.git] / src / lex.icl
index bedb75f..4cf915c 100644 (file)
@@ -16,7 +16,7 @@ lexer r = case runParser lexProgram r of
 
 lexProgram :: Parser Char [Token]
 lexProgram = some lexToken <* many (satisfy isSpace) <* eof
-       >>= \ts->pure (map (\t->(0, 0, t)) ts)
+       >>= \ts->pure $ (map (\t->(0, 0, t)) ts) ++ [(0, 0, EndOfFileToken)]
 
 lexToken :: Parser Char TokenValue
 lexToken = 
@@ -59,10 +59,10 @@ lexToken =
        //Number tokens
        (liftM (NumberToken o toInt o toString) $ some $ satisfy isDigit) <|>
        //Ident tokens
-       (liftM IdentToken $ some $ satisfy isIdentChar) <|>
+       (liftM (IdentToken o toString) $ some $ satisfy isIdentChar) <|>
        (satisfy isSpace >>| lexToken)
        where
-               lexUntilNL = top until ((item '\n' >>| return Void) <|> eof)
+               lexUntilNL = top until (eof <|> (item '\n' >>| pure Void))
                lexUntilCommentClose = top until list (fromString "*/")
                isIdentChar c = isAlphanum c || c == '_'
                lexOp s tv = list (fromString s) >>| pure tv