Fix 'field name not found' for reasonligo

This commit is contained in:
Kirill Andreev 2020-08-24 20:05:24 +04:00
parent 5533b07270
commit da6ca97a9d
No known key found for this signature in database
GPG Key ID: CF7DA79DE4785A47
5 changed files with 16 additions and 60 deletions

View File

@ -0,0 +1,5 @@
let f = (good : int) : (int, int) => {
let bad1: int = 1;
let bad: int = 1;
(good, bad, bad)
};

View File

@ -159,7 +159,7 @@ module.exports = grammar({
$.capture,
),
capture: $ => $.Name,
capture: $ => field("name", $.Name),
record_field: $ => seq(
field("name", $.lhs),
@ -183,7 +183,7 @@ module.exports = grammar({
spread: $ => seq(
'...',
$._expr,
field("name", $._expr),
),
if: $ => seq(
@ -304,13 +304,13 @@ module.exports = grammar({
michelson_tuple: $ => seq(
'(',
$._type_expr,
field("arg1", $._type_expr),
',',
$.String,
field("label1", $.String),
',',
$._type_expr,
field("arg2", $._type_expr),
',',
$.String,
field("label2", $.String),
')',
),

View File

@ -66,27 +66,7 @@ example :: FilePath
-- example = "../../../src/test/contracts/lambda2.mligo"
-- example = "../../../src/test/contracts/loop.mligo"
-- example = "../../../src/test/contracts/let_in_multi_bind.mligo"
example = "../../../src/test/contracts/fibo2.mligo"
-- raw :: IO ()
-- raw = toParseTree (Path example)
-- >>= print . pp
-- raw' :: FilePath -> IO ()
-- raw' example = toParseTree (Path example)
-- >>= print . pp
sample :: IO ()
sample
= toParseTree (Path example)
>>= runParserM . recognise
>>= print . pp . fst
sample' :: FilePath -> IO ()
sample' example
= toParseTree (Path example)
>>= runParserM . recognise
>>= print . pp . fst
-- example = "../../../src/test/contracts/fibo2.mligo"
recognise :: RawTree -> ParserM (LIGO Info)
recognise = descent (error "Reasonligo.recognise") $ map usingScope

View File

@ -37,28 +37,6 @@ import ParseTree
-- example = "../../../src/test/contracts/chain_id.ligo"
-- example = "../../../src/test/contracts/closure-3.ligo"
-- sample' :: FilePath -> IO (LIGO Info)
-- sample' f
-- = toParseTree (Path f)
-- >>= runParserM . recognise
-- >>= return . fst
-- source' :: FilePath -> IO ()
-- source' f
-- = toParseTree (Path f)
-- >>= print . pp
-- sample :: IO ()
-- sample
-- = toParseTree (Path example)
-- >>= runParserM . recognise
-- >>= print . pp . fst
-- source :: IO ()
-- source
-- = toParseTree (Path example)
-- >>= print . pp
recognise :: RawTree -> ParserM (LIGO Info)
recognise = descent (error "Reasonligo.recognise") $ map usingScope
[ -- Contract

View File

@ -37,12 +37,6 @@ import Product
-- example = "./contracts/arithmetic.religo"
-- example = "./contracts/FA2.religo"
-- sample''' :: IO ()
-- sample'''
-- = toParseTree (Path example)
-- >>= runParserM . recognise
-- >>= print . pp . fst
recognise :: RawTree -> ParserM (LIGO Info)
recognise = descent (error "Reasonligo.recognise") $ map usingScope
[ -- Contract
@ -63,7 +57,6 @@ recognise = descent (error "Reasonligo.recognise") $ map usingScope
"indexing" -> ListAccess <$> field "box" <*> fields "index"
"annot_expr" -> Annot <$> field "subject" <*> field "type"
"if" -> If <$> field "selector" <*> field "then" <*> fieldOpt "else"
-- TODO: possible support for multiple spreads
"record" -> Record <$> fields "assignment"
"tuple" -> Tuple <$> fields "item"
"switch" -> Case <$> field "subject" <*> fields "alt"
@ -73,10 +66,10 @@ recognise = descent (error "Reasonligo.recognise") $ map usingScope
-- Pattern
, Descent do
boilerplate $ \case
"tuple_pattern" -> IsTuple <$> fields "pattern"
"tuple_pattern" -> IsTuple <$> fields "pattern"
"annot_pattern" -> IsAnnot <$> field "subject" <*> field "type"
"list_pattern" -> IsList <$> fields "pattern"
"var_pattern" -> IsVar <$> field "var"
"list_pattern" -> IsList <$> fields "pattern"
"var_pattern" -> IsVar <$> field "var"
"wildcard" -> return IsWildcard
"nullary_constr_pattern" -> IsConstr <$> field "constructor" <*> return Nothing
"unary_constr_pattern" -> IsConstr <$> field "constructor" <*> fieldOpt "arg"
@ -95,7 +88,7 @@ recognise = descent (error "Reasonligo.recognise") $ map usingScope
boilerplate $ \case
"record_field" -> FieldAssignment <$> field "name" <*> field "value"
"spread" -> Spread <$> field "name"
_ -> fallthrough
_ -> fallthrough
-- MapBinding
, Descent do