Skip to content

Commit

Permalink
Update for better compliance with the spec (#587)
Browse files Browse the repository at this point in the history
* allow use of 'byte' suffix for sizes
  • Loading branch information
vmchale committed Jan 29, 2019
1 parent 1c9d628 commit c3f0a27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions language-plutus-core/src/Language/PlutusCore/Lexer.x
Expand Up @@ -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
Expand All @@ -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
Expand Down
@@ -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)
]
Expand Down

0 comments on commit c3f0a27

Please sign in to comment.