Convert much of the ExtendedSyntax to variable width numbers

This commit is contained in:
Anthony Cerruti 2020-04-23 20:49:50 -07:00
parent ae5c55c0eb
commit 0aa77a612d
2 changed files with 10 additions and 4 deletions

View File

@ -72,10 +72,16 @@ value = Lit <$> literal <|>
try (Unit <$ op "()") <|>
Undefined <$> parens (kw "#undefined" *> op "::" *> typeAnnot)
wordLiteral :: Parser Lit
wordLiteral = lexeme (LWord <$> (integer <* C.char 'u') <*> L.decimal)
intLiteral :: Parser Lit
intLiteral = lexeme (LInt <$> (signedInteger <* C.char 'i') <*> L.decimal)
literal :: Parser Lit
literal = (try $ LFloat . realToFrac <$> signedFloat) <|>
(try $ LWord64 . fromIntegral <$> lexeme (L.decimal <* C.char 'u')) <|>
(try $ LInt64 . fromIntegral <$> signedInteger) <|>
(try $ wordLiteral) <|>
(try $ intLiteral) <|>
(try $ LBool <$> (True <$ kw "#True" <|> False <$ kw "#False")) <|>
(try $ LString <$> lexeme (C.char '#' *> quotedString)) <|>
(try $ LChar <$> lexeme (C.string "#'" *> (escaped <|> anySingle) <* C.char '\''))

View File

@ -53,8 +53,8 @@ isExternalName es n = n `Prelude.elem` (eName <$> es)
-- QUESTION: Now #undefined can be pattern matched on.
-- Should the linter warn about this?
data Lit
= LInt64 Int64
| LWord64 Word64
= LInt Word32 Int
| LWord Word32 Word
| LFloat Float
| LBool Bool
| LString Text