From: pimjager Date: Thu, 23 Jun 2016 09:57:36 +0000 (+0200) Subject: Improved parse sep list X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=8fb93659b4a234f433adad9958217beb3e342a2a;p=cc1516.git Improved parse sep list --- diff --git a/parse.icl b/parse.icl index 2dd8f1a..a6374c1 100644 --- a/parse.icl +++ b/parse.icl @@ -243,9 +243,10 @@ tokEq (StringToken _) (StringToken _) = True tokEq x y = gEq {|*|} x y parseSepList :: TokenValue (Parser Token a) -> Parser Token [a] -parseSepList sep p = - (liftM2 (\es->(\e->reverse [e:es])) (some (p <* satTok sep)) p) <|> - (liftM pure p) <|> pure empty +parseSepList sep p = + (p <* satTok sep >>= \v1-> parseSepList sep p >>= \vs -> pure [v1:vs]) + <|> (p >>= \v-> pure [v]) + <|> pure [] parseIdent :: Parser Token String parseIdent = trans2 (IdentToken "") (\(IdentToken e)->toString e)