diff options
author | Son Ho | 2022-02-03 19:44:26 +0100 |
---|---|---|
committer | Son Ho | 2022-02-03 19:44:26 +0100 |
commit | 5eacfc7cdbe99f401d6cf925cbb50d63c3a780c3 (patch) | |
tree | 940463f3d64b43534bb09bafafd8beccee366d43 /src/PureUtils.ml | |
parent | 1dd71ca1d37d5ca7fae5a7e9766e03194dfb764f (diff) |
Implement extraction of `if ... then ... else ...`
Diffstat (limited to 'src/PureUtils.ml')
-rw-r--r-- | src/PureUtils.ml | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/PureUtils.ml b/src/PureUtils.ml index dfa8c1a3..aa383d8c 100644 --- a/src/PureUtils.ml +++ b/src/PureUtils.ml @@ -183,3 +183,14 @@ let functions_not_mutually_recursive (funs : fun_def list) : bool = with Utils.Found -> false in List.for_all body_only_calls_itself funs + +(** We use this to check whether we need to add parentheses around expressions. + We only look for outer monadic let-bindings. + *) +let rec expression_requires_parentheses (e : texpression) : bool = + match e.e with + | Value _ | Call _ -> false + | Let (monadic, _, _, next_e) -> + if monadic then true else expression_requires_parentheses next_e + | Switch (_, _) -> false + | Meta (_, next_e) -> expression_requires_parentheses next_e |