Reordered to match Syntax type def
This commit is contained in:
@@ -163,13 +163,27 @@ parseExpression = do
|
||||
space
|
||||
try $
|
||||
choice
|
||||
[ parseTrue,
|
||||
parseFalse,
|
||||
parseInt
|
||||
[ parseInt,
|
||||
parseTrue,
|
||||
parseFalse
|
||||
]
|
||||
|
||||
--- Literals
|
||||
|
||||
-- Numbers
|
||||
|
||||
parseInt :: Parser Expression
|
||||
parseInt = do
|
||||
sign <- optional . try $ char '-'
|
||||
magnitude <- many digitChar
|
||||
let value = maybe magnitude (: magnitude) sign
|
||||
in case readMaybe value of
|
||||
Just val -> return $ LiteralInt val
|
||||
Nothing -> fail ""
|
||||
|
||||
parseFloat :: Parser Expression
|
||||
parseFloat = undefined
|
||||
|
||||
-- Booleans
|
||||
|
||||
parseBool :: Text -> Bool -> Parser Expression
|
||||
@@ -183,14 +197,3 @@ parseTrue = parseBool "true" True
|
||||
|
||||
parseFalse :: Parser Expression
|
||||
parseFalse = parseBool "false" False
|
||||
|
||||
-- Numbers
|
||||
|
||||
parseInt :: Parser Expression
|
||||
parseInt = do
|
||||
sign <- optional . try $ char '-'
|
||||
magnitude <- many digitChar
|
||||
let value = maybe magnitude (: magnitude) sign
|
||||
in case readMaybe value of
|
||||
Just val -> return $ LiteralInt val
|
||||
Nothing -> fail ""
|
||||
Reference in New Issue
Block a user