lib: journal: account: allow whitespace or a comment after the account name

This commit is contained in:
Simon Michael 2018-10-13 13:09:49 -07:00
parent 4f2d9dde4c
commit b72f9697a2

View File

@ -261,7 +261,7 @@ accountdirectivep = do
-- the account name, possibly modified by preceding alias or apply account directives -- the account name, possibly modified by preceding alias or apply account directives
acct <- modifiedaccountnamep acct <- modifiedaccountnamep
-- and maybe something else after two or more spaces ? -- and maybe something else after two or more spaces ?
matype :: Maybe AccountType <- lift $ fmap (fromMaybe Nothing) $ optional $ do matype :: Maybe AccountType <- lift $ fmap (fromMaybe Nothing) $ optional $ try $ do
skipSome spacenonewline -- at least one more space in addition to the one consumed by modifiedaccountp skipSome spacenonewline -- at least one more space in addition to the one consumed by modifiedaccountp
choice [ choice [
-- a numeric account code, as supported in 1.9-1.10 ? currently ignored -- a numeric account code, as supported in 1.9-1.10 ? currently ignored
@ -273,8 +273,9 @@ accountdirectivep = do
,char 'R' >> return (Just Revenue) ,char 'R' >> return (Just Revenue)
,char 'X' >> return (Just Expense) ,char 'X' >> return (Just Expense)
] ]
newline -- and maybe a comment on this and/or following lines ? (ignore for now)
-- Ledger-style indented subdirectives on following lines ? ignore (_cmt, _tags) <- lift transactioncommentp
-- and maybe Ledger-style subdirectives ? (ignore)
skipMany indentedlinep skipMany indentedlinep
-- update the journal -- update the journal
@ -820,7 +821,7 @@ tests_JournalReader = tests "JournalReader" [
] ]
,test "accountdirectivep" $ do ,test "accountdirectivep" $ do
test "account" $ expectParse accountdirectivep "account a:b\n" test "account" $ expectParse accountdirectivep "account a:b ; a comment and some:tag, another comment\n"
test "does not support !" $ expectParseError accountdirectivep "!account a:b\n" "" test "does not support !" $ expectParseError accountdirectivep "!account a:b\n" ""
,test "commodityconversiondirectivep" $ do ,test "commodityconversiondirectivep" $ do