From a5d6b42322ebe09b1c5ea9499498d0fdc9120d4e Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 22 Dec 2022 01:12:56 -1000 Subject: [PATCH] imp: journal: ignore end apply fixed, end apply tag directives (ledger compat) --- hledger-lib/Hledger/Read/JournalReader.hs | 11 ++++++++--- hledger/hledger.m4.md | 2 ++ .../syntax/hledger-ledger-unsupported.test | 4 +++- hledger/test/ledger-compat/syntax/hledger-other.test | 6 ++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index caa5db5a7..fce8ece0b 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -239,7 +239,9 @@ directivep = (do ,applyaccountdirectivep ,endapplyaccountdirectivep ,applyfixeddirectivep + ,endapplyfixeddirectivep ,applytagdirectivep + ,endapplytagdirectivep ,assertdirectivep ,bucketdirectivep ,capturedirectivep @@ -528,12 +530,15 @@ formatdirectivep expectedsym = do -- More Ledger directives, ignore for now: -- apply fixed, apply tag, assert, bucket, A, capture, check, define, expr -applyfixeddirectivep, applytagdirectivep, assertdirectivep, bucketdirectivep, - capturedirectivep, checkdirectivep, definedirectivep, exprdirectivep, - valuedirectivep, pythondirectivep, evaldirectivep, commandlineflagdirectivep +applyfixeddirectivep, endapplyfixeddirectivep, applytagdirectivep, endapplytagdirectivep, + assertdirectivep, bucketdirectivep, capturedirectivep, checkdirectivep, + definedirectivep, exprdirectivep, valuedirectivep, pythondirectivep, + evaldirectivep, commandlineflagdirectivep :: JournalParser m () applyfixeddirectivep = do string "apply fixed" >> lift restofline >> return () +endapplyfixeddirectivep = do string "end apply fixed" >> lift restofline >> return () applytagdirectivep = do string "apply tag" >> lift restofline >> return () +endapplytagdirectivep = do string "end apply tag" >> lift restofline >> return () assertdirectivep = do string "assert" >> lift restofline >> return () bucketdirectivep = do string "A " <|> string "bucket " >> lift restofline >> return () capturedirectivep = do string "capture" >> lift restofline >> return () diff --git a/hledger/hledger.m4.md b/hledger/hledger.m4.md index 2c5065f78..c1847f33d 100644 --- a/hledger/hledger.m4.md +++ b/hledger/hledger.m4.md @@ -2741,7 +2741,9 @@ These other Ledger directives are currently ignored: ```journal apply fixed COMM AMT +end apply fixed apply tag TAG +end apply tag assert EXPR A ACCT bucket ACCT diff --git a/hledger/test/ledger-compat/syntax/hledger-ledger-unsupported.test b/hledger/test/ledger-compat/syntax/hledger-ledger-unsupported.test index a5e18c21b..b09c158c3 100644 --- a/hledger/test/ledger-compat/syntax/hledger-ledger-unsupported.test +++ b/hledger/test/ledger-compat/syntax/hledger-ledger-unsupported.test @@ -9,9 +9,11 @@ $ hledger -f- check >2// >=1 -# `end` close block commands like `apply` or `comment` (ignores any words after "end") +# Just `end` or `end apply` as shorthand for closing the most recent "apply FOO". < apply account a +end apply +apply account a end $ hledger -f- check >2// diff --git a/hledger/test/ledger-compat/syntax/hledger-other.test b/hledger/test/ledger-compat/syntax/hledger-other.test index 141205d46..d06ab61fc 100644 --- a/hledger/test/ledger-compat/syntax/hledger-other.test +++ b/hledger/test/ledger-compat/syntax/hledger-other.test @@ -35,17 +35,23 @@ Y 1111 1/1 year 2222 2/2 +apply year 3333 +3/3 $ hledger -f- print 1111-01-01 2222-02-02 +3333-03-03 + >= # ignored directives < apply fixed CAD $0.90 +end apply fixed apply tag tag1:val1 +end apply tag assert 1 bucket Assets:Checking A Assets:Checking