don't let ledgercomment parser always pass

This commit is contained in:
Simon Michael 2009-06-20 04:01:25 +00:00
parent 29bf134624
commit 79880de744

View File

@ -251,13 +251,11 @@ emptyLine = do many spacenonewline
return () return ()
ledgercomment :: GenParser Char st String ledgercomment :: GenParser Char st String
ledgercomment = ledgercomment = do
try (do many1 $ char ';'
char ';' many spacenonewline
many spacenonewline many (noneOf "\n")
many (noneOf "\n") <?> "comment"
)
<|> return "" <?> "comment"
ledgercommentline :: GenParser Char st String ledgercommentline :: GenParser Char st String
ledgercommentline = do ledgercommentline = do
@ -316,7 +314,7 @@ ledgerTransaction = do
status <- ledgerstatus status <- ledgerstatus
code <- ledgercode code <- ledgercode
description <- many1 spacenonewline >> liftM rstrip (many1 (noneOf ";\n") <?> "description") description <- many1 spacenonewline >> liftM rstrip (many1 (noneOf ";\n") <?> "description")
comment <- ledgercomment comment <- ledgercomment <|> return ""
restofline restofline
postings <- ledgerpostings postings <- ledgerpostings
let t = LedgerTransaction date edate status code description comment postings "" let t = LedgerTransaction date edate status code description comment postings ""
@ -392,7 +390,7 @@ ledgerposting = do
let (ptype, account') = (postingTypeFromAccountName account, unbracket account) let (ptype, account') = (postingTypeFromAccountName account, unbracket account)
amount <- postingamount amount <- postingamount
many spacenonewline many spacenonewline
comment <- ledgercomment comment <- ledgercomment <|> return ""
restofline restofline
return (Posting status account' amount comment ptype) return (Posting status account' amount comment ptype)