From 5533b072706a64d52d354988856b809ecf50bcbe Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Mon, 24 Aug 2020 14:17:53 +0400 Subject: [PATCH] Fix pattern defs for pascaligo --- src/test/contracts/FA1.2.religo | 4 ++-- tools/lsp/squirrel/app/Main.hs | 4 ++-- tools/lsp/squirrel/grammar/pascaligo/grammar.js | 4 +++- tools/lsp/squirrel/src/AST/Pascaligo/Parser.hs | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/test/contracts/FA1.2.religo b/src/test/contracts/FA1.2.religo index 37b194738..3cec488b2 100644 --- a/src/test/contracts/FA1.2.religo +++ b/src/test/contracts/FA1.2.religo @@ -41,7 +41,7 @@ type action = | GetTotalSupply ( getTotalSupply ) let transfer = ((p,s) : (transfer, storage)) : (list (operation), storage) => { - let new_allowances = + let new_allowances = if (Tezos.sender == p.address_from) { s.allowances; } else { let authorized_value = switch (Big_map.find_opt ((Tezos.sender,p.address_from), s.allowances)) { @@ -105,7 +105,7 @@ let getTotalSupply = ((p,s) : (getTotalSupply, storage)) : (list (operation), st }; -let main = ((a,s): (action, storage)) => +let main = ((a,s): (action, storage)) => switch a { | Transfer p => transfer ((p,s)) | Approve p => approve ((p,s)) diff --git a/tools/lsp/squirrel/app/Main.hs b/tools/lsp/squirrel/app/Main.hs index 8745cc148..bd161e104 100644 --- a/tools/lsp/squirrel/app/Main.hs +++ b/tools/lsp/squirrel/app/Main.hs @@ -188,7 +188,7 @@ eventLoop funs chan = do respondWith funs req RspFindReferences $ J.List [] ReqCompletion req -> do - stopDyingAlready funs req $ do + stopDyingAlready funs req $ do U.logs $ "got completion request: " <> show req let uri = req ^. J.params . J.textDocument . J.uri let pos = posToRange $ req ^. J.params . J.position @@ -198,7 +198,7 @@ eventLoop funs chan = do -- Additional callback executed after completion was made, currently no-op ReqCompletionItemResolve req -> do - stopDyingAlready funs req $ do + stopDyingAlready funs req $ do U.logs $ "got completion resolve request: " <> show req respondWith funs req RspCompletionItemResolve (req ^. J.params) diff --git a/tools/lsp/squirrel/grammar/pascaligo/grammar.js b/tools/lsp/squirrel/grammar/pascaligo/grammar.js index 22379ed41..5b94192b3 100644 --- a/tools/lsp/squirrel/grammar/pascaligo/grammar.js +++ b/tools/lsp/squirrel/grammar/pascaligo/grammar.js @@ -733,7 +733,7 @@ module.exports = grammar({ _core_pattern: $ => choice( - $.Name, + $.var_pattern, '_', $.Int, $.Nat, @@ -743,6 +743,8 @@ module.exports = grammar({ $._constr_pattern, ), + var_pattern: $ => field("name", $.Name), + _list_pattern: $ => choice( $.list_pattern, diff --git a/tools/lsp/squirrel/src/AST/Pascaligo/Parser.hs b/tools/lsp/squirrel/src/AST/Pascaligo/Parser.hs index dea15a431..8ae8cc03f 100644 --- a/tools/lsp/squirrel/src/AST/Pascaligo/Parser.hs +++ b/tools/lsp/squirrel/src/AST/Pascaligo/Parser.hs @@ -115,6 +115,7 @@ recognise = descent (error "Reasonligo.recognise") $ map usingScope "nil" -> return $ IsList [] "list_pattern" -> IsList <$> fields "element" "cons_pattern" -> IsCons <$> field "head" <*> field "tail" + "var_pattern" -> IsVar <$> field "name" _ -> fallthrough -- Alt