From 04724a1db2135ea1511e1344d116e1747d1d4189 Mon Sep 17 00:00:00 2001 From: Kirill Kuvshinov Date: Tue, 15 Sep 2020 11:22:15 +0300 Subject: [PATCH 1/2] [LIGO-47] Allow `let .. in` in lambda body Problem: In multisig.mligo, else clause on line 36 ends on line 55, while it should end on line 80. This happens because of incorrect lambda parsing on lines 42-43. In particular, `let valid, keys = vk` in lambda body gets parsed as a `tuple (fun_app "let" "valid") (binary_op "=" "keys" "vk")`, and `in` is considered as a part of the outer `let`. Solution: Allow `_program` instead of `_expr` as the lambda body. --- tools/lsp/squirrel/grammar/camligo/grammar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lsp/squirrel/grammar/camligo/grammar.js b/tools/lsp/squirrel/grammar/camligo/grammar.js index e3d9fb638..483fb2817 100644 --- a/tools/lsp/squirrel/grammar/camligo/grammar.js +++ b/tools/lsp/squirrel/grammar/camligo/grammar.js @@ -229,7 +229,7 @@ module.exports = grammar({ "fun", repeat1(field("arg", $._paren_pattern)), "->", - field("body", $._expr) + field("body", $._program) ), list_expr: $ => seq( From c44a35d4d1abedeed662d7ded07c2a8204e3fa34 Mon Sep 17 00:00:00 2001 From: Kirill Kuvshinov Date: Tue, 15 Sep 2020 11:25:21 +0300 Subject: [PATCH 2/2] [LIGO-47] PascaLIGO: Move `block` out of `case_block` alternatives Problem: In multisig.ligo:48, the case alternative block is interpreted as empty, while it is not. This happens because PascaLIGO parser expects to find `fields "statements"` inside a `case_block`. In practice, if a `case_block` contains a `block`, statements are deeper in the hierarchy, and get ignored. Solution: Move "block" option out of the "case_block" (to _if_clause). --- tools/lsp/squirrel/grammar/pascaligo/grammar.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/lsp/squirrel/grammar/pascaligo/grammar.js b/tools/lsp/squirrel/grammar/pascaligo/grammar.js index 5b94192b3..6ba30796c 100644 --- a/tools/lsp/squirrel/grammar/pascaligo/grammar.js +++ b/tools/lsp/squirrel/grammar/pascaligo/grammar.js @@ -363,13 +363,11 @@ module.exports = grammar({ choice( $._instruction, $.clause_block, + $.block, ), clause_block: $ => - choice( - field("block", $.block), - seq('{', sepBy1(';', field("statement", $._statement)), '}') - ), + seq('{', sepBy1(';', field("statement", $._statement)), '}'), block: $ => choice( @@ -822,4 +820,4 @@ module.exports = grammar({ skip: $ => 'skip', recursive: $ => 'recursive', } -}); \ No newline at end of file +});