lib: tweak whitespace parsing for better parse errors
- expands the set of expected tokens when e.g. parsing the invalid posting `account $1 a` - whitespace can affect parse errors because of the longest match rule where errors that occur later take precedence over those that occur earlier
This commit is contained in:
parent
ed0106b209
commit
9674f2a8cc
@ -523,6 +523,7 @@ test_spaceandamountormissingp = do
|
||||
amountp :: JournalParser m Amount
|
||||
amountp = label "amount" $ do
|
||||
amount <- amountwithoutpricep
|
||||
lift $ skipMany spacenonewline
|
||||
price <- priceamountp
|
||||
pure $ amount { aprice = price }
|
||||
|
||||
@ -657,7 +658,7 @@ simplecommoditysymbolp = takeWhile1P Nothing (not . isNonsimpleCommodityChar)
|
||||
|
||||
priceamountp :: JournalParser m Price
|
||||
priceamountp = option NoPrice $ do
|
||||
try $ lift (skipMany spacenonewline) *> char '@'
|
||||
char '@'
|
||||
priceConstructor <- char '@' *> pure TotalPrice <|> pure UnitPrice
|
||||
|
||||
lift (skipMany spacenonewline)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user