1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

Construct Try terms

This commit is contained in:
joshvera 2016-07-29 15:58:55 -04:00
parent ad9c63ef42
commit f767ad20db

View File

@ -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