Fix 'field name not found' for reasonligo
This commit is contained in:
parent
5533b07270
commit
da6ca97a9d
5
src/test/contracts/refs.religo
Normal file
5
src/test/contracts/refs.religo
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
let f = (good : int) : (int, int) => {
|
||||||
|
let bad1: int = 1;
|
||||||
|
let bad: int = 1;
|
||||||
|
(good, bad, bad)
|
||||||
|
};
|
@ -159,7 +159,7 @@ module.exports = grammar({
|
|||||||
$.capture,
|
$.capture,
|
||||||
),
|
),
|
||||||
|
|
||||||
capture: $ => $.Name,
|
capture: $ => field("name", $.Name),
|
||||||
|
|
||||||
record_field: $ => seq(
|
record_field: $ => seq(
|
||||||
field("name", $.lhs),
|
field("name", $.lhs),
|
||||||
@ -183,7 +183,7 @@ module.exports = grammar({
|
|||||||
|
|
||||||
spread: $ => seq(
|
spread: $ => seq(
|
||||||
'...',
|
'...',
|
||||||
$._expr,
|
field("name", $._expr),
|
||||||
),
|
),
|
||||||
|
|
||||||
if: $ => seq(
|
if: $ => seq(
|
||||||
@ -304,13 +304,13 @@ module.exports = grammar({
|
|||||||
|
|
||||||
michelson_tuple: $ => seq(
|
michelson_tuple: $ => seq(
|
||||||
'(',
|
'(',
|
||||||
$._type_expr,
|
field("arg1", $._type_expr),
|
||||||
',',
|
',',
|
||||||
$.String,
|
field("label1", $.String),
|
||||||
',',
|
',',
|
||||||
$._type_expr,
|
field("arg2", $._type_expr),
|
||||||
',',
|
',',
|
||||||
$.String,
|
field("label2", $.String),
|
||||||
')',
|
')',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -66,27 +66,7 @@ example :: FilePath
|
|||||||
-- example = "../../../src/test/contracts/lambda2.mligo"
|
-- example = "../../../src/test/contracts/lambda2.mligo"
|
||||||
-- example = "../../../src/test/contracts/loop.mligo"
|
-- example = "../../../src/test/contracts/loop.mligo"
|
||||||
-- example = "../../../src/test/contracts/let_in_multi_bind.mligo"
|
-- example = "../../../src/test/contracts/let_in_multi_bind.mligo"
|
||||||
example = "../../../src/test/contracts/fibo2.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
|
|
||||||
|
|
||||||
recognise :: RawTree -> ParserM (LIGO Info)
|
recognise :: RawTree -> ParserM (LIGO Info)
|
||||||
recognise = descent (error "Reasonligo.recognise") $ map usingScope
|
recognise = descent (error "Reasonligo.recognise") $ map usingScope
|
||||||
|
@ -37,28 +37,6 @@ import ParseTree
|
|||||||
-- example = "../../../src/test/contracts/chain_id.ligo"
|
-- example = "../../../src/test/contracts/chain_id.ligo"
|
||||||
-- example = "../../../src/test/contracts/closure-3.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 :: RawTree -> ParserM (LIGO Info)
|
||||||
recognise = descent (error "Reasonligo.recognise") $ map usingScope
|
recognise = descent (error "Reasonligo.recognise") $ map usingScope
|
||||||
[ -- Contract
|
[ -- Contract
|
||||||
|
@ -37,12 +37,6 @@ import Product
|
|||||||
-- example = "./contracts/arithmetic.religo"
|
-- example = "./contracts/arithmetic.religo"
|
||||||
-- example = "./contracts/FA2.religo"
|
-- example = "./contracts/FA2.religo"
|
||||||
|
|
||||||
-- sample''' :: IO ()
|
|
||||||
-- sample'''
|
|
||||||
-- = toParseTree (Path example)
|
|
||||||
-- >>= runParserM . recognise
|
|
||||||
-- >>= print . pp . fst
|
|
||||||
|
|
||||||
recognise :: RawTree -> ParserM (LIGO Info)
|
recognise :: RawTree -> ParserM (LIGO Info)
|
||||||
recognise = descent (error "Reasonligo.recognise") $ map usingScope
|
recognise = descent (error "Reasonligo.recognise") $ map usingScope
|
||||||
[ -- Contract
|
[ -- Contract
|
||||||
@ -63,7 +57,6 @@ recognise = descent (error "Reasonligo.recognise") $ map usingScope
|
|||||||
"indexing" -> ListAccess <$> field "box" <*> fields "index"
|
"indexing" -> ListAccess <$> field "box" <*> fields "index"
|
||||||
"annot_expr" -> Annot <$> field "subject" <*> field "type"
|
"annot_expr" -> Annot <$> field "subject" <*> field "type"
|
||||||
"if" -> If <$> field "selector" <*> field "then" <*> fieldOpt "else"
|
"if" -> If <$> field "selector" <*> field "then" <*> fieldOpt "else"
|
||||||
-- TODO: possible support for multiple spreads
|
|
||||||
"record" -> Record <$> fields "assignment"
|
"record" -> Record <$> fields "assignment"
|
||||||
"tuple" -> Tuple <$> fields "item"
|
"tuple" -> Tuple <$> fields "item"
|
||||||
"switch" -> Case <$> field "subject" <*> fields "alt"
|
"switch" -> Case <$> field "subject" <*> fields "alt"
|
||||||
@ -73,10 +66,10 @@ recognise = descent (error "Reasonligo.recognise") $ map usingScope
|
|||||||
-- Pattern
|
-- Pattern
|
||||||
, Descent do
|
, Descent do
|
||||||
boilerplate $ \case
|
boilerplate $ \case
|
||||||
"tuple_pattern" -> IsTuple <$> fields "pattern"
|
"tuple_pattern" -> IsTuple <$> fields "pattern"
|
||||||
"annot_pattern" -> IsAnnot <$> field "subject" <*> field "type"
|
"annot_pattern" -> IsAnnot <$> field "subject" <*> field "type"
|
||||||
"list_pattern" -> IsList <$> fields "pattern"
|
"list_pattern" -> IsList <$> fields "pattern"
|
||||||
"var_pattern" -> IsVar <$> field "var"
|
"var_pattern" -> IsVar <$> field "var"
|
||||||
"wildcard" -> return IsWildcard
|
"wildcard" -> return IsWildcard
|
||||||
"nullary_constr_pattern" -> IsConstr <$> field "constructor" <*> return Nothing
|
"nullary_constr_pattern" -> IsConstr <$> field "constructor" <*> return Nothing
|
||||||
"unary_constr_pattern" -> IsConstr <$> field "constructor" <*> fieldOpt "arg"
|
"unary_constr_pattern" -> IsConstr <$> field "constructor" <*> fieldOpt "arg"
|
||||||
@ -95,7 +88,7 @@ recognise = descent (error "Reasonligo.recognise") $ map usingScope
|
|||||||
boilerplate $ \case
|
boilerplate $ \case
|
||||||
"record_field" -> FieldAssignment <$> field "name" <*> field "value"
|
"record_field" -> FieldAssignment <$> field "name" <*> field "value"
|
||||||
"spread" -> Spread <$> field "name"
|
"spread" -> Spread <$> field "name"
|
||||||
_ -> fallthrough
|
_ -> fallthrough
|
||||||
|
|
||||||
-- MapBinding
|
-- MapBinding
|
||||||
, Descent do
|
, Descent do
|
||||||
|
Loading…
Reference in New Issue
Block a user