allow spaces between sign and number, when parsing
This commit is contained in:
parent
4529d9e804
commit
f219bba494
@ -688,8 +688,10 @@ amountp' s =
|
|||||||
mamountp' :: String -> MixedAmount
|
mamountp' :: String -> MixedAmount
|
||||||
mamountp' = Mixed . (:[]) . amountp'
|
mamountp' = Mixed . (:[]) . amountp'
|
||||||
|
|
||||||
|
-- | Parse a minus or plus sign followed by zero or more spaces,
|
||||||
|
-- or nothing, returning a function that negates or does nothing.
|
||||||
signp :: Num a => TextParser m (a -> a)
|
signp :: Num a => TextParser m (a -> a)
|
||||||
signp = char '-' *> pure negate <|> char '+' *> pure id <|> pure id
|
signp = ((char '-' *> pure negate <|> char '+' *> pure id) <* many spacenonewline) <|> pure id
|
||||||
|
|
||||||
multiplierp :: TextParser m Bool
|
multiplierp :: TextParser m Bool
|
||||||
multiplierp = option False $ char '*' *> pure True
|
multiplierp = option False $ char '*' *> pure True
|
||||||
|
|||||||
@ -421,12 +421,18 @@ must be enclosed in double quotes:
|
|||||||
|
|
||||||
3 "no. 42 green apples"
|
3 "no. 42 green apples"
|
||||||
|
|
||||||
Amounts can be negative. The minus sign can be written before or after
|
Amounts can be preceded by a minus sign (or a plus sign, though plus is the default),
|
||||||
a left-side commodity symbol:
|
The sign can be written before or after a left-side commodity symbol:
|
||||||
|
|
||||||
-$1
|
-$1
|
||||||
$-1
|
$-1
|
||||||
|
|
||||||
|
One or more spaces between the sign and the number are acceptable
|
||||||
|
when parsing (but they won't be displayed in output):
|
||||||
|
|
||||||
|
+ $1
|
||||||
|
$- 1
|
||||||
|
|
||||||
Scientific E notation is allowed:
|
Scientific E notation is allowed:
|
||||||
|
|
||||||
1E-6
|
1E-6
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user