dev: refactor: move emptyorcommentlinep'; hlint
This commit is contained in:
parent
46cda5e7de
commit
07a4b21620
@ -96,6 +96,7 @@ module Hledger.Read.Common (
|
|||||||
isSameLineCommentStart,
|
isSameLineCommentStart,
|
||||||
multilinecommentp,
|
multilinecommentp,
|
||||||
emptyorcommentlinep,
|
emptyorcommentlinep,
|
||||||
|
emptyorcommentlinep',
|
||||||
followingcommentp,
|
followingcommentp,
|
||||||
transactioncommentp,
|
transactioncommentp,
|
||||||
commenttagsp,
|
commenttagsp,
|
||||||
@ -361,7 +362,7 @@ journalFinalise iopts@InputOpts{auto_,balancingopts_,infer_costs_,infer_equity_,
|
|||||||
-- >>= Right . dbg0With (concatMap (T.unpack.showTransaction).jtxns)
|
-- >>= Right . dbg0With (concatMap (T.unpack.showTransaction).jtxns)
|
||||||
-- >>= \j -> deepseq (concatMap (T.unpack.showTransaction).jtxns $ j) (return j)
|
-- >>= \j -> deepseq (concatMap (T.unpack.showTransaction).jtxns $ j) (return j)
|
||||||
<&> dbg9With (lbl "amounts after styling, forecasting, auto-posting".showJournalAmountsDebug)
|
<&> dbg9With (lbl "amounts after styling, forecasting, auto-posting".showJournalAmountsDebug)
|
||||||
>>= (\j -> if checkordereddates then journalCheckOrdereddates j <&> const j else Right j) -- check ordereddates before assertions. The outer parentheses are needed.
|
>>= (\j -> if checkordereddates then journalCheckOrdereddates j $> j else Right j) -- check ordereddates before assertions. The outer parentheses are needed.
|
||||||
>>= journalBalanceTransactions balancingopts_{ignore_assertions_=not checkassertions} -- infer balance assignments and missing amounts, and maybe check balance assertions.
|
>>= journalBalanceTransactions balancingopts_{ignore_assertions_=not checkassertions} -- infer balance assignments and missing amounts, and maybe check balance assertions.
|
||||||
<&> dbg9With (lbl "amounts after transaction-balancing".showJournalAmountsDebug)
|
<&> dbg9With (lbl "amounts after transaction-balancing".showJournalAmountsDebug)
|
||||||
-- <&> dbg9With (("journalFinalise amounts after styling, forecasting, auto postings, transaction balancing"<>).showJournalAmountsDebug)
|
-- <&> dbg9With (("journalFinalise amounts after styling, forecasting, auto postings, transaction balancing"<>).showJournalAmountsDebug)
|
||||||
@ -1277,6 +1278,24 @@ emptyorcommentlinep = do
|
|||||||
|
|
||||||
{-# INLINABLE emptyorcommentlinep #-}
|
{-# INLINABLE emptyorcommentlinep #-}
|
||||||
|
|
||||||
|
-- | A new comment line parser (from TimedotReader).
|
||||||
|
-- Parse empty lines, all-blank lines, and lines beginning with any of
|
||||||
|
-- the provided comment-beginning characters.
|
||||||
|
emptyorcommentlinep' :: [Char] -> TextParser m ()
|
||||||
|
emptyorcommentlinep' cs =
|
||||||
|
label ("empty line or comment line beginning with "++cs) $ do
|
||||||
|
-- traceparse "emptyorcommentlinep" -- XXX possible to combine label and traceparse ?
|
||||||
|
skipNonNewlineSpaces
|
||||||
|
void newline <|> void commentp
|
||||||
|
-- traceparse' "emptyorcommentlinep"
|
||||||
|
where
|
||||||
|
commentp = do
|
||||||
|
choice (map (some.char) cs)
|
||||||
|
void $ takeWhileP Nothing (/='\n')
|
||||||
|
void $ optional newline
|
||||||
|
|
||||||
|
{-# INLINABLE emptyorcommentlinep' #-}
|
||||||
|
|
||||||
-- | Is this a character that, as the first non-whitespace on a line,
|
-- | Is this a character that, as the first non-whitespace on a line,
|
||||||
-- starts a comment line ?
|
-- starts a comment line ?
|
||||||
isLineCommentStart :: Char -> Bool
|
isLineCommentStart :: Char -> Bool
|
||||||
|
|||||||
@ -114,7 +114,7 @@ timedotp = preamblep >> many dayp >> eof >> get
|
|||||||
preamblep :: JournalParser m ()
|
preamblep :: JournalParser m ()
|
||||||
preamblep = do
|
preamblep = do
|
||||||
lift $ traceparse "preamblep"
|
lift $ traceparse "preamblep"
|
||||||
many $ notFollowedBy datelinep >> (lift $ emptyorcommentlinep "#;*")
|
many $ notFollowedBy datelinep >> (lift $ emptyorcommentlinep' "#;*")
|
||||||
lift $ traceparse' "preamblep"
|
lift $ traceparse' "preamblep"
|
||||||
|
|
||||||
-- | Parse timedot day entries to multi-posting time transactions for that day.
|
-- | Parse timedot day entries to multi-posting time transactions for that day.
|
||||||
@ -157,7 +157,7 @@ datelinep = do
|
|||||||
commentlinesp :: JournalParser m ()
|
commentlinesp :: JournalParser m ()
|
||||||
commentlinesp = do
|
commentlinesp = do
|
||||||
lift $ traceparse "commentlinesp"
|
lift $ traceparse "commentlinesp"
|
||||||
void $ many $ try $ lift $ emptyorcommentlinep "#;"
|
void $ many $ try $ lift $ emptyorcommentlinep' "#;"
|
||||||
|
|
||||||
-- orgnondatelinep :: JournalParser m ()
|
-- orgnondatelinep :: JournalParser m ()
|
||||||
-- orgnondatelinep = do
|
-- orgnondatelinep = do
|
||||||
@ -277,18 +277,3 @@ letterquantitiesp =
|
|||||||
]
|
]
|
||||||
return groups
|
return groups
|
||||||
|
|
||||||
-- | XXX new comment line parser, move to Hledger.Read.Common.emptyorcommentlinep
|
|
||||||
-- Parse empty lines, all-blank lines, and lines beginning with any of the provided
|
|
||||||
-- comment-beginning characters.
|
|
||||||
emptyorcommentlinep :: [Char] -> TextParser m ()
|
|
||||||
emptyorcommentlinep cs =
|
|
||||||
label ("empty line or comment line beginning with "++cs) $ do
|
|
||||||
traceparse "emptyorcommentlinep" -- XXX possible to combine label and traceparse ?
|
|
||||||
skipNonNewlineSpaces
|
|
||||||
void newline <|> void commentp
|
|
||||||
traceparse' "emptyorcommentlinep"
|
|
||||||
where
|
|
||||||
commentp = do
|
|
||||||
choice (map (some.char) cs)
|
|
||||||
takeWhileP Nothing (/='\n') <* newline
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user