From: Mart Lubbers Date: Thu, 23 Jun 2016 10:03:24 +0000 (+0200) Subject: mooie seplist X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=7aa09be0797c8d73a28dc43962f1cbf1ea0c5b46;p=cc1516.git mooie seplist --- diff --git a/examples/print.spl b/examples/print.spl new file mode 100644 index 0000000..058348c --- /dev/null +++ b/examples/print.spl @@ -0,0 +1,3 @@ +main(){ + print(1, 2, 3, 4, 5); +} diff --git a/parse.icl b/parse.icl index a6374c1..ebfc7a0 100644 --- a/parse.icl +++ b/parse.icl @@ -243,10 +243,9 @@ tokEq (StringToken _) (StringToken _) = True tokEq x y = gEq {|*|} x y parseSepList :: TokenValue (Parser Token a) -> Parser Token [a] -parseSepList sep p = - (p <* satTok sep >>= \v1-> parseSepList sep p >>= \vs -> pure [v1:vs]) - <|> (p >>= \v-> pure [v]) - <|> pure [] +parseSepList sep p = pSL` sep p <|> pure [] + where + pSL` sep p = (p <* satTok sep >>= \v1->parseSepList sep p >>= \vs->pure [v1:vs]) <|> (p >>= \v->pure [v]) parseIdent :: Parser Token String parseIdent = trans2 (IdentToken "") (\(IdentToken e)->toString e)