diff options
Diffstat (limited to 'src/SPL')
-rw-r--r-- | src/SPL/Parse.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/SPL/Parse.hs b/src/SPL/Parse.hs index 2616d8c..e74d9cb 100644 --- a/src/SPL/Parse.hs +++ b/src/SPL/Parse.hs @@ -58,7 +58,8 @@ data Token lex :: (Monad m, Alternative m) => String -> m [Token] lex [] = pure [] -lex s = (item s <|> ident s <|> int s <|> char s <|> bool s <|> comment s) >>= +lex (c:s) | isSpace c = lex s +lex s = (comment s <|> item s <|> ident s <|> int s <|> char s <|> bool s) >>= \(t,s') -> lex s' >>= \ts -> pure (t:ts) where ident :: (Alternative m) => String -> m (Token, String) @@ -88,9 +89,9 @@ lex s = (item s <|> ident s <|> int s <|> char s <|> bool s <|> comment s) >>= (cs, s') = span (/= '\n') s comment ('/':'*':s) = pure (TBlockComment cs, s') where - (cs, s') = spanList (\case - ('*':'/':s) -> True - _ -> False) s + (cs, _:_:s') = spanList (\case + ('*':'/':s) -> False + _ -> True) s comment _ = empty item :: (Alternative m) => String -> m (Token, String) |