More ReasonLIGO pretty printer improvements.

This commit is contained in:
Sander Spies 2020-06-05 16:01:18 +02:00
parent db0fdf4abd
commit 63086db0f1
4 changed files with 36 additions and 32 deletions

View File

@ -46,8 +46,11 @@ and pp_let_binding let_ (binding : let_binding) =
| Some (_,e) -> | Some (_,e) ->
patterns ^^ group (break 0 ^^ string ": " ^^ pp_type_expr e ^^ string " = ") patterns ^^ group (break 0 ^^ string ": " ^^ pp_type_expr e ^^ string " = ")
in in
let rhs = pp_expr let_rhs let rhs = pp_expr let_rhs in
in prefix 2 0 lhs rhs match let_rhs with
| ESeq _
| ERecord _ -> lhs ^^ rhs
| _ -> prefix 2 0 lhs rhs
and pp_pattern = function and pp_pattern = function
PConstr p -> pp_pconstr p PConstr p -> pp_pconstr p

View File

@ -2,8 +2,7 @@ type storage = (int, int);
let main = let main =
(n: (int, storage)): (list(operation), storage) => { (n: (int, storage)): (list(operation), storage) => {
let x: (int, int) = let x: (int, int) = {
{
let x: int = 7; let x: int = 7;
(x + n[0], n[1][0] + n[1][1]) (x + n[0], n[1][0] + n[1][1])
}; };

View File

@ -12,7 +12,10 @@ type sum_aggregator = {counter: int, sum: int };
let counter = let counter =
(n: int): int => { (n: int): int => {
let initial: sum_aggregator = {counter: 0, sum: 0 }; let initial: sum_aggregator = {
counter: 0,
sum: 0
};
let rec aggregate = let rec aggregate =
(prev: sum_aggregator): int => (prev: sum_aggregator): int =>
if(prev.counter <= n) { if(prev.counter <= n) {
@ -40,7 +43,10 @@ let rec aux_nest =
let counter_nest = let counter_nest =
(n: int): int => { (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); let out: sum_aggregator = aux_nest(initial);
out.sum out.sum
}; };

View File

@ -18,11 +18,10 @@ let i = (a: int, b: int) => a + b;
let j = (a: int, b: int) => a - b; let j = (a: int, b: int) => a - b;
let m = let m = {
{
let z = 3; let z = 3;
z z
}; };
let n = (a: int): int => a + 1; 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 o = (a: int, b: int): int => a + 1;
let p = let p = {
{
{ {
3 3
} }
}; };
let q = let q = {
{
f: 3, f: 3,
g: 6, g: 6,
h: {i: "bla", j: 1 + 2, k: {l: 1, z: 2 } } h: {i: "bla", j: 1 + 2, k: {l: 1, z: 2 } }
}; };
let s = let s = {
{
let a = 2; let a = 2;
{ {
z: a, z: a,
a: a a: a
} }
}; };
let t = (((((((2))))))); let t = (((((((2)))))));