Added parsing of floating point numbers
This commit is contained in:
parent
be520a67c1
commit
8bc4aa8f71
|
@ -35,5 +35,10 @@ symbolParser = Symbol <$> do
|
||||||
-- Parser for a number
|
-- Parser for a number
|
||||||
numberParser :: GenParser Char st Expression
|
numberParser :: GenParser Char st Expression
|
||||||
numberParser = do
|
numberParser = do
|
||||||
num <- read <$> many1 digit
|
intPart <- many1 digit
|
||||||
return $ Number num
|
decPart <- option "" parseDecPart
|
||||||
|
return $ Number $ read (intPart ++ decPart)
|
||||||
|
where parseDecPart = do
|
||||||
|
p <- char '.'
|
||||||
|
dec <- many digit
|
||||||
|
return $ p:dec
|
||||||
|
|
Loading…
Reference in New Issue