journal: dates should be followed by whitespace or newline

This commit is contained in:
Simon Michael 2014-09-06 09:20:22 -07:00
parent 2992ce069d
commit efe7c7a029
2 changed files with 16 additions and 1 deletions

View File

@ -327,6 +327,7 @@ transaction = do
sourcepos <- getPosition
date <- datep <?> "transaction"
edate <- optionMaybe (secondarydatep date) <?> "secondary date"
lookAhead (spacenonewline <|> newline) <?> "whitespace or newline"
status <- status <?> "cleared flag"
code <- codep <?> "transaction code"
description <- descriptionp >>= return . strip
@ -492,7 +493,7 @@ secondarydatep primarydate = do
return edate
status :: GenParser Char JournalContext Bool
status = try (do { many spacenonewline; (char '*' <|> char '!') <?> "status"; return True } ) <|> return False
status = try (do { many1 spacenonewline; (char '*' <|> char '!') <?> "status"; return True } ) <|> return False
codep :: GenParser Char JournalContext String
codep = try (do { many1 spacenonewline; char '(' <?> "codep"; code <- anyChar `manyTill` char ')'; return code } ) <|> return ""

View File

@ -35,3 +35,17 @@ hledgerdev -f- print
b
>>>2 /bad date/
>>>= 1
# 5. dates should be followed by whitespace or newline
hledgerdev -f- print
<<<
2015/9/6:
a 0
>>>2 /unexpected ":"/
>>>= 1
# 6.
hledgerdev -f- print
<<<
2015/9/6=9/6* x
a 0
>>>2 /unexpected "*"/
>>>= 1