From: Mart Lubbers Date: Tue, 1 Mar 2016 15:41:54 +0000 (+0100) Subject: better lexer X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=65f6bf827fa2f4d2f79f9e3bda990b7e4c4df5f1;p=cc1516.git better lexer --- diff --git a/src/lex.icl b/src/lex.icl index 1828e37..ac5168f 100644 --- a/src/lex.icl +++ b/src/lex.icl @@ -15,8 +15,8 @@ lexer r = case runParser lexProgram r of (Left e, _) = Left $ toString e lexProgram :: Parser Char [Token] -lexProgram = some lexToken <* eof - >>= \ts->pure $ (map (\t->(0, 0, t)) (catMaybes ts)) +lexProgram = catMaybes <$> some lexToken <* eof + >>= \ts->pure $ (map (\t->(0, 0, t)) ts) lexToken :: Parser Char (Maybe TokenValue) lexToken =