From 63086db0f1e39bf4b747de4f074694cab2cf46af Mon Sep 17 00:00:00 2001 From: Sander Spies Date: Fri, 5 Jun 2020 16:01:18 +0200 Subject: [PATCH] More ReasonLIGO pretty printer improvements. --- src/passes/01-parser/reasonligo/Pretty.ml | 7 +++- .../contracts/expected/letin.religo.expected | 9 ++-- .../contracts/expected/loop.religo.expected | 10 ++++- ...tuples_sequences_functions.religo.expected | 42 +++++++++---------- 4 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/passes/01-parser/reasonligo/Pretty.ml b/src/passes/01-parser/reasonligo/Pretty.ml index 3c3f31915..84b8d7495 100644 --- a/src/passes/01-parser/reasonligo/Pretty.ml +++ b/src/passes/01-parser/reasonligo/Pretty.ml @@ -46,8 +46,11 @@ and pp_let_binding let_ (binding : let_binding) = | Some (_,e) -> patterns ^^ group (break 0 ^^ string ": " ^^ pp_type_expr e ^^ string " = ") in - let rhs = pp_expr let_rhs - in prefix 2 0 lhs rhs + let rhs = pp_expr let_rhs in + match let_rhs with + | ESeq _ + | ERecord _ -> lhs ^^ rhs + | _ -> prefix 2 0 lhs rhs and pp_pattern = function PConstr p -> pp_pconstr p diff --git a/src/test/contracts/expected/letin.religo.expected b/src/test/contracts/expected/letin.religo.expected index df249df49..0bb052da1 100644 --- a/src/test/contracts/expected/letin.religo.expected +++ b/src/test/contracts/expected/letin.religo.expected @@ -2,11 +2,10 @@ type storage = (int, int); let main = (n: (int, storage)): (list(operation), storage) => { - let x: (int, int) = - { - let x: int = 7; - (x + n[0], n[1][0] + n[1][1]) - }; + let x: (int, int) = { + let x: int = 7; + (x + n[0], n[1][0] + n[1][1]) + }; ([] : list(operation), x) }; diff --git a/src/test/contracts/expected/loop.religo.expected b/src/test/contracts/expected/loop.religo.expected index 1bafc75ea..aac2af16c 100644 --- a/src/test/contracts/expected/loop.religo.expected +++ b/src/test/contracts/expected/loop.religo.expected @@ -12,7 +12,10 @@ type sum_aggregator = {counter: int, sum: int }; let counter = (n: int): int => { - let initial: sum_aggregator = {counter: 0, sum: 0 }; + let initial: sum_aggregator = { + counter: 0, + sum: 0 + }; let rec aggregate = (prev: sum_aggregator): int => if(prev.counter <= n) { @@ -40,7 +43,10 @@ let rec aux_nest = let counter_nest = (n: int): int => { - let initial: sum_aggregator = {counter: 0, sum: 0 }; + let initial: sum_aggregator = { + counter: 0, + sum: 0 + }; let out: sum_aggregator = aux_nest(initial); out.sum }; diff --git a/src/test/contracts/expected/tuples_sequences_functions.religo.expected b/src/test/contracts/expected/tuples_sequences_functions.religo.expected index 12c911779..ee569df68 100644 --- a/src/test/contracts/expected/tuples_sequences_functions.religo.expected +++ b/src/test/contracts/expected/tuples_sequences_functions.religo.expected @@ -18,11 +18,10 @@ let i = (a: int, b: int) => a + b; let j = (a: int, b: int) => a - b; -let m = - { - let z = 3; - z - }; +let m = { + let z = 3; + z +}; let n = (a: int): int => a + 1; @@ -32,28 +31,25 @@ let n = (a: int, b: int): int => a + 1; let o = (a: int, b: int): int => a + 1; -let p = +let p = { { - { - 3 - } - }; + 3 + } +}; -let q = - { - f: 3, - g: 6, - h: {i: "bla", j: 1 + 2, k: {l: 1, z: 2 } } - }; +let q = { + f: 3, + g: 6, + h: {i: "bla", j: 1 + 2, k: {l: 1, z: 2 } } +}; -let s = +let s = { + let a = 2; { - let a = 2; - { - z: a, - a: a - } - }; + z: a, + a: a + } +}; let t = (((((((2)))))));