mirror of
https://github.com/grin-compiler/grin.git
synced 2024-09-11 07:25:28 +03:00
Convert much of the ExtendedSyntax to variable width numbers
This commit is contained in:
parent
ae5c55c0eb
commit
0aa77a612d
@ -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 '\''))
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user