From 8d3d00b7a5120e9cd0f8b971f4bc723a913b2625 Mon Sep 17 00:00:00 2001 From: Macocian Adrian Radu <34056556+macocianradu@users.noreply.github.com> Date: Mon, 16 May 2022 13:03:22 +0200 Subject: [PATCH] fixed functions without input --- resources/Rosetta/test-multiple.rosetta | 42 +++++++++++++++++++++++++ src/Parser/Function.hs | 6 ++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/resources/Rosetta/test-multiple.rosetta b/resources/Rosetta/test-multiple.rosetta index c65f3a1..7e37103 100644 --- a/resources/Rosetta/test-multiple.rosetta +++ b/resources/Rosetta/test-multiple.rosetta @@ -63,3 +63,45 @@ type Contract_Get: contract Contract (1..1) type Contract_Anytime: contract Contract (1..1) + +func MkZero: + output: + contract Contract (1..1) + assign-output contract -> zero -> unit: + 1 // create the zero contract dummy value + +func MkExpired: + output: + contract Contract (1..1) + assign-output contract -> expired -> unit: + 1 // create the expired contract dummy value + +func MkOne: + inputs: + currency UnitType (1..1) + output: + contract Contract (1..1) + assign-output contract -> one -> currency: + currency + +func MkOr: + inputs: + left Contract (1..1) + right Contract (1..1) + output: + contract Contract (1..1) + assign-output contract -> orContract -> left: + left + assign-output contract -> orContract -> right: + right + +func MkBoth: + inputs: + left Contract (1..1) + right Contract (1..1) + output: + contract Contract (1..1) + assign-output contract -> both -> left: + left + assign-output contract -> both -> right: + right \ No newline at end of file diff --git a/src/Parser/Function.hs b/src/Parser/Function.hs index 39d0243..1dfc0e8 100644 --- a/src/Parser/Function.hs +++ b/src/Parser/Function.hs @@ -37,8 +37,10 @@ assignmentParser = inputAttributesParser :: Parser [TypeAttribute] inputAttributesParser = do - _ <- lexeme $ string "inputs:" - many $ try attributeParser + inp <- observing $ lexeme $ string "inputs:" + case inp of + Left _ -> return [] + Right _ -> many $ try attributeParser -- |Parses the output attribute of a function statement in Rosetta into a TypeAttribute outputAttributeParser :: Parser TypeAttribute