Skip to content

Commit

Permalink
Merge branch 'main' into tutorial_integers
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriella439 authored Nov 20, 2023
2 parents 3fbfb65 + 5d4391c commit fc5a85f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion dhall/src/Dhall/Parser/Token.hs
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,14 @@ integerLiteral = (do
-}
naturalLiteral :: Parser Natural
naturalLiteral = (do
a <- try (char '0' >> char 'x' >> Text.Megaparsec.Char.Lexer.hexadecimal)
a <- binary
<|> hexadecimal
<|> decimal
<|> (char '0' $> 0)
return a ) <?> "literal"
where
binary = try (char '0' >> char 'b' >> Text.Megaparsec.Char.Lexer.binary)
hexadecimal = try (char '0' >> char 'x' >> Text.Megaparsec.Char.Lexer.hexadecimal)
decimal = do
n <- headDigit
ns <- many tailDigit
Expand Down
2 changes: 1 addition & 1 deletion dhall/tests/format/numericLiteralsA.dhall
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ example0 = 0x42, example1 = +0x42, example2 = 1.2e20 }
{ example0 = 0x42, example1 = +0x42, example2 = 1.2e20, example3 = -0b0111 }
2 changes: 1 addition & 1 deletion dhall/tests/format/numericLiteralsB.dhall
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ example0 = 0x42, example1 = +0x42, example2 = 1.2e20 }
{ example0 = 0x42, example1 = +0x42, example2 = 1.2e20, example3 = -0b0111 }

0 comments on commit fc5a85f

Please sign in to comment.