From a4128d037baa62b6e8f295bf1c95919d073ce260 Mon Sep 17 00:00:00 2001 From: Sander Spies Date: Tue, 26 May 2020 11:06:38 +0200 Subject: [PATCH 1/3] Add PPar around PTyped for proper pretty printing and CST equality with CameLIGO. --- src/passes/1-parser/reasonligo/Parser.mly | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/passes/1-parser/reasonligo/Parser.mly b/src/passes/1-parser/reasonligo/Parser.mly index 896eaabc4..74417ee1e 100644 --- a/src/passes/1-parser/reasonligo/Parser.mly +++ b/src/passes/1-parser/reasonligo/Parser.mly @@ -453,8 +453,15 @@ fun_expr(right_expr): ) | EAnnot {region; value = {inside = EVar v, colon, typ; _}} -> Scoping.check_reserved_name v; - let value = {pattern = PVar v; colon; type_expr = typ} - in PTyped {region; value} + let value = {pattern = PVar v; colon; type_expr = typ} in + PPar { + value = { + lpar = Region.ghost; + rpar = Region.ghost; + inside = PTyped {region; value} + }; + region + } | EPar p -> let value = {p.value with inside = arg_to_pattern p.value.inside} @@ -655,7 +662,6 @@ disj_expr_level: | par(tuple(disj_expr_level)) type_annotation_simple? { let region = nsepseq_to_region expr_to_region $1.value.inside in let tuple = ETuple {value=$1.value.inside; region} in - let tuple = EPar {$1 with value = {$1.value with inside=tuple}} in let region = match $2 with Some (_,s) -> cover $1.region (type_expr_to_region s) From 88c652a25fe4322d6db34cb870476080ab875c0f Mon Sep 17 00:00:00 2001 From: Sander Spies Date: Tue, 26 May 2020 12:33:32 +0200 Subject: [PATCH 2/3] Fix issue caused by addition of PPar. --- src/passes/1-parser/reasonligo/Parser.mly | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/passes/1-parser/reasonligo/Parser.mly b/src/passes/1-parser/reasonligo/Parser.mly index 74417ee1e..fe3503328 100644 --- a/src/passes/1-parser/reasonligo/Parser.mly +++ b/src/passes/1-parser/reasonligo/Parser.mly @@ -501,7 +501,13 @@ fun_expr(right_expr): (arg_to_pattern fun_arg, []) | EPar {value = {inside = EFun { value = { - binders = PTyped { value = { pattern; colon; type_expr }; region = fun_region }, []; + binders = PPar { + value = { + inside = PTyped { value = { pattern; colon; type_expr }; region = fun_region }; + _ + }; + _ + }, []; arrow; body; _ @@ -535,7 +541,7 @@ fun_expr(right_expr): }; region; }, [] - | EPar {value = {inside = fun_arg; _ }; _} -> + | EPar {value = {inside = fun_arg; _ }; _} -> arg_to_pattern fun_arg, [] | EAnnot _ as e -> arg_to_pattern e, [] From cade57a47c5d6164f565d3da0d2358d8fe7c4e72 Mon Sep 17 00:00:00 2001 From: Sander Spies Date: Tue, 26 May 2020 12:41:42 +0200 Subject: [PATCH 3/3] Fix expect help tests. --- src/bin/expect_tests/help_tests.ml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bin/expect_tests/help_tests.ml b/src/bin/expect_tests/help_tests.ml index d30f67155..4c00c7969 100644 --- a/src/bin/expect_tests/help_tests.ml +++ b/src/bin/expect_tests/help_tests.ml @@ -57,6 +57,9 @@ let%expect_test _ = Subcommand: Preprocess the source file. Warning: Intended for development of LIGO and can break at any time. + pretty-print + Subcommand: Pretty-print the source file. + print-ast Subcommand: Print the AST. Warning: Intended for development of LIGO and can break at any time. @@ -148,6 +151,9 @@ let%expect_test _ = Subcommand: Preprocess the source file. Warning: Intended for development of LIGO and can break at any time. + pretty-print + Subcommand: Pretty-print the source file. + print-ast Subcommand: Print the AST. Warning: Intended for development of LIGO and can break at any time.