From fd506a6817092af667ee0e5eb677f8786844d89e Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 4 Jul 2007 01:49:16 +0000 Subject: [PATCH] better parse error message when only one space before an amount --- NOTES | 3 --- Parse.hs | 8 +++++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/NOTES b/NOTES index a6d980ee5..87cbf8f0a 100644 --- a/NOTES +++ b/NOTES @@ -2,9 +2,6 @@ hledger project notes * TO DO ** bugs -*** unclear parse error when only one space before amount - unexpected "$" - expecting letter or digit, ":", "/", "_", amount, comment or new-line *** handle unknown currencies ** compatibility ** basic features diff --git a/Parse.hs b/Parse.hs index 163908f1d..8bdbf4a00 100644 --- a/Parse.hs +++ b/Parse.hs @@ -210,8 +210,8 @@ ledgertransactions = (ledgertransaction "transaction") `manyTill` (do {newli ledgertransaction :: Parser Transaction ledgertransaction = do many1 spacenonewline - account <- ledgeraccount "account" - amount <- ledgeramount "amount" + account <- ledgeraccount + amount <- ledgeramount many spacenonewline ledgereol many ledgercomment @@ -219,7 +219,9 @@ ledgertransaction = do -- account names may have single spaces in them, and are terminated by two or more spaces ledgeraccount :: Parser String -ledgeraccount = many1 (alphaNum <|> char ':' <|> char '/' <|> char '_' <|> try (do {spacenonewline; do {notFollowedBy spacenonewline; return ' '}})) +ledgeraccount = + many1 ((alphaNum <|> char ':' <|> char '/' <|> char '_' "account name") + <|> try (do {spacenonewline; do {notFollowedBy spacenonewline; return ' '}} "double space")) ledgeramount :: Parser Amount ledgeramount =