From f767ad20dbc2e551618ccbd1152c05e0db42626e Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:58:55 -0400 Subject: [PATCH] Construct Try terms --- src/Parser.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Parser.hs b/src/Parser.hs index 4f408596e..70e839609 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -101,5 +101,13 @@ termConstructor source sourceSpan info = cofree . construct withDefaultInfo $ S.While expr body construct children | DoWhile == (category info), [expr, body] <- children = withDefaultInfo $ S.DoWhile expr body + construct children | Try == category info = case children of + [body] -> withDefaultInfo $ S.Try body Nothing Nothing + [body, catch] | Catch <- category (extract catch) -> withDefaultInfo $ S.Try body (Just catch) Nothing + [body, finally] | Finally <- category (extract finally) -> withDefaultInfo $ S.Try body Nothing (Just finally) + [body, catch, finally] | Catch <- category (extract catch), + Finally <- category (extract finally) -> + withDefaultInfo $ S.Try body (Just catch) (Just finally) + _ -> S.Error sourceSpan children construct children = withDefaultInfo $ S.Indexed children