From c3f0a27f3a81659fbf4ac1d0d77ebd03ff556a1b Mon Sep 17 00:00:00 2001 From: Vanessa McHale Date: Tue, 29 Jan 2019 12:05:29 -0600 Subject: [PATCH] Update for better compliance with the spec (#587) * allow use of 'byte' suffix for sizes --- language-plutus-core/src/Language/PlutusCore/Lexer.x | 4 ++++ .../test/normalize-types/addIntegerCorrect.plc | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/language-plutus-core/src/Language/PlutusCore/Lexer.x b/language-plutus-core/src/Language/PlutusCore/Lexer.x index d4a4cc5637b..2815c7a212f 100644 --- a/language-plutus-core/src/Language/PlutusCore/Lexer.x +++ b/language-plutus-core/src/Language/PlutusCore/Lexer.x @@ -113,6 +113,7 @@ tokens :- -- Integer/size literals <0> @size { tok (\p s -> alex $ LexNat p (readBSL s)) } + <0> @size bytes { tok (\p s -> alex $ LexNat p (readBSL (trimBytes s))) } <0> @integer { tok (\p s -> alex $ LexInt p (readBSL $ stripPlus s)) } -- Identifiers @@ -128,6 +129,9 @@ deriving instance Ord AlexPosn instance Pretty (AlexPosn) where pretty (AlexPn _ line col) = pretty line <> ":" <> pretty col +trimBytes :: BSL.ByteString -> BSL.ByteString +trimBytes str = BSL.take (BSL.length str - 5) str + handleChar :: Word8 -> Word8 handleChar x | x >= 48 && x <= 57 = x - 48 -- hexits 0-9 diff --git a/language-plutus-core/test/normalize-types/addIntegerCorrect.plc b/language-plutus-core/test/normalize-types/addIntegerCorrect.plc index e1cb9352d8d..fa6d5666720 100644 --- a/language-plutus-core/test/normalize-types/addIntegerCorrect.plc +++ b/language-plutus-core/test/normalize-types/addIntegerCorrect.plc @@ -1,6 +1,6 @@ (program 0.1.0 [ - (lam x [(con integer) (con 2)] + (lam x [(con integer) (con 2bytes)] [{(builtin addInteger) (con 2)} x (con 2 ! 2)]) (con 2 ! 2) ]