lib: restrict backtracking when parsing postings (#747)
This commit is contained in:
parent
129f6e6839
commit
a409d09435
@ -581,7 +581,7 @@ test_transactionp = do
|
|||||||
-- Parse the following whitespace-beginning lines as postings, posting
|
-- Parse the following whitespace-beginning lines as postings, posting
|
||||||
-- tags, and/or comments (inferring year, if needed, from the given date).
|
-- tags, and/or comments (inferring year, if needed, from the given date).
|
||||||
postingsp :: MonadIO m => Maybe Day -> ErroringJournalParser m [Posting]
|
postingsp :: MonadIO m => Maybe Day -> ErroringJournalParser m [Posting]
|
||||||
postingsp mdate = many (try $ postingp mdate) <?> "postings"
|
postingsp mdate = many (postingp mdate) <?> "postings"
|
||||||
|
|
||||||
-- linebeginningwithspaces :: Monad m => JournalParser m String
|
-- linebeginningwithspaces :: Monad m => JournalParser m String
|
||||||
-- linebeginningwithspaces = do
|
-- linebeginningwithspaces = do
|
||||||
@ -593,10 +593,12 @@ postingsp mdate = many (try $ postingp mdate) <?> "postings"
|
|||||||
postingp :: MonadIO m => Maybe Day -> ErroringJournalParser m Posting
|
postingp :: MonadIO m => Maybe Day -> ErroringJournalParser m Posting
|
||||||
postingp mtdate = do
|
postingp mtdate = do
|
||||||
-- pdbg 0 "postingp"
|
-- pdbg 0 "postingp"
|
||||||
lift (skipSome spacenonewline)
|
(status, account) <- try $ do
|
||||||
status <- lift statusp
|
lift (skipSome spacenonewline)
|
||||||
lift (skipMany spacenonewline)
|
status <- lift statusp
|
||||||
account <- modifiedaccountnamep
|
lift (skipMany spacenonewline)
|
||||||
|
account <- modifiedaccountnamep
|
||||||
|
return (status, account)
|
||||||
let (ptype, account') = (accountNamePostingType account, textUnbracket account)
|
let (ptype, account') = (accountNamePostingType account, textUnbracket account)
|
||||||
amount <- spaceandamountormissingp
|
amount <- spaceandamountormissingp
|
||||||
massertion <- partialbalanceassertionp
|
massertion <- partialbalanceassertionp
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user