imp: config files (and maybe timedot files) no longer require a final newline

This commit is contained in:
Simon Michael 2025-04-25 13:59:18 -10:00
parent 8f46eca6ec
commit bf40d28c8b
2 changed files with 5 additions and 4 deletions

View File

@ -426,7 +426,7 @@ getYear = fmap jparsedefaultyear get
dp :: String -> TextParser m ()
dp = const $ return () -- no-op
-- dp = dbgparse 1 -- trace parse state at this --debug level
-- dp = dbgparse 0 -- trace parse state at this --debug level
-- | Get the decimal mark that has been specified for parsing, if any
-- (eg by the CSV decimal-mark rule, or possibly a future journal directive).
@ -1299,6 +1299,7 @@ emptyorcommentlinep = do
-- | A newer comment line parser.
-- Parses a line which is empty, all blanks, or whose first non-blank character is one of those provided.
-- A final newline is optional.
emptyorcommentlinep2 :: [Char] -> TextParser m ()
emptyorcommentlinep2 cs =
label ("empty line or comment line beginning with "++cs) $ do
@ -1308,7 +1309,7 @@ emptyorcommentlinep2 cs =
where
commentp = do
choice (map (some.char) cs)
takeWhileP Nothing (/='\n') <* newline
takeWhileP Nothing (/='\n') <* optional newline
-- | Is this a character that, as the first non-whitespace on a line,
-- starts a comment line ?

View File

@ -227,7 +227,7 @@ parseConf = runParser confp
dp :: String -> TextParser m ()
dp = const $ return () -- no-op
-- dp = dbgparse 1 -- trace parse state at this --debug level
-- dp = dbgparse 0 -- trace parse state at this --debug level
whitespacep, commentlinesp, restoflinep :: TextParser Identity ()
whitespacep = void $ {- dp "whitespacep" >> -} many spacenonewline
@ -274,7 +274,7 @@ arglinep = do
-- dp "arglinep3"
a <- some $ noneOf "#\n"
-- dp "arglinep4"
restoflinep
restoflinep <|> whitespacep -- whitespace / same-line comment, possibly with no newline
commentlinesp
return $ strip a