mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-29 13:22:27 +03:00
imp: journal: ignore end apply year, end apply tag, drop "pop" (ledger compat)
This commit is contained in:
parent
a5d6b42322
commit
a070875fe6
@ -237,11 +237,8 @@ directivep = (do
|
|||||||
,endaliasesdirectivep
|
,endaliasesdirectivep
|
||||||
,accountdirectivep
|
,accountdirectivep
|
||||||
,applyaccountdirectivep
|
,applyaccountdirectivep
|
||||||
,endapplyaccountdirectivep
|
|
||||||
,applyfixeddirectivep
|
,applyfixeddirectivep
|
||||||
,endapplyfixeddirectivep
|
|
||||||
,applytagdirectivep
|
,applytagdirectivep
|
||||||
,endapplytagdirectivep
|
|
||||||
,assertdirectivep
|
,assertdirectivep
|
||||||
,bucketdirectivep
|
,bucketdirectivep
|
||||||
,capturedirectivep
|
,capturedirectivep
|
||||||
@ -249,17 +246,21 @@ directivep = (do
|
|||||||
,commandlineflagdirectivep
|
,commandlineflagdirectivep
|
||||||
,commoditydirectivep
|
,commoditydirectivep
|
||||||
,commodityconversiondirectivep
|
,commodityconversiondirectivep
|
||||||
,definedirectivep
|
|
||||||
,evaldirectivep
|
|
||||||
,exprdirectivep
|
|
||||||
,payeedirectivep
|
|
||||||
,pythondirectivep
|
|
||||||
,decimalmarkdirectivep
|
,decimalmarkdirectivep
|
||||||
,defaultyeardirectivep
|
,defaultyeardirectivep
|
||||||
,defaultcommoditydirectivep
|
,defaultcommoditydirectivep
|
||||||
,ignoredpricecommoditydirectivep
|
,definedirectivep
|
||||||
,tagdirectivep
|
,endapplyaccountdirectivep
|
||||||
|
,endapplyfixeddirectivep
|
||||||
|
,endapplytagdirectivep
|
||||||
|
,endapplyyeardirectivep
|
||||||
,endtagdirectivep
|
,endtagdirectivep
|
||||||
|
,evaldirectivep
|
||||||
|
,exprdirectivep
|
||||||
|
,ignoredpricecommoditydirectivep
|
||||||
|
,payeedirectivep
|
||||||
|
,pythondirectivep
|
||||||
|
,tagdirectivep
|
||||||
,valuedirectivep
|
,valuedirectivep
|
||||||
]
|
]
|
||||||
) <?> "directive"
|
) <?> "directive"
|
||||||
@ -532,24 +533,25 @@ formatdirectivep expectedsym = do
|
|||||||
-- apply fixed, apply tag, assert, bucket, A, capture, check, define, expr
|
-- apply fixed, apply tag, assert, bucket, A, capture, check, define, expr
|
||||||
applyfixeddirectivep, endapplyfixeddirectivep, applytagdirectivep, endapplytagdirectivep,
|
applyfixeddirectivep, endapplyfixeddirectivep, applytagdirectivep, endapplytagdirectivep,
|
||||||
assertdirectivep, bucketdirectivep, capturedirectivep, checkdirectivep,
|
assertdirectivep, bucketdirectivep, capturedirectivep, checkdirectivep,
|
||||||
definedirectivep, exprdirectivep, valuedirectivep, pythondirectivep,
|
endapplyyeardirectivep, definedirectivep, exprdirectivep, valuedirectivep,
|
||||||
evaldirectivep, commandlineflagdirectivep
|
evaldirectivep, pythondirectivep, commandlineflagdirectivep
|
||||||
:: JournalParser m ()
|
:: JournalParser m ()
|
||||||
applyfixeddirectivep = do string "apply fixed" >> lift restofline >> return ()
|
applyfixeddirectivep = do string "apply fixed" >> lift restofline >> return ()
|
||||||
endapplyfixeddirectivep = do string "end apply fixed" >> lift restofline >> return ()
|
endapplyfixeddirectivep = do string "end apply fixed" >> lift restofline >> return ()
|
||||||
applytagdirectivep = do string "apply tag" >> lift restofline >> return ()
|
applytagdirectivep = do string "apply tag" >> lift restofline >> return ()
|
||||||
endapplytagdirectivep = do string "end apply tag" >> lift restofline >> return ()
|
endapplytagdirectivep = do string "end apply tag" >> lift restofline >> return ()
|
||||||
assertdirectivep = do string "assert" >> lift restofline >> return ()
|
endapplyyeardirectivep = do string "end apply year" >> lift restofline >> return ()
|
||||||
bucketdirectivep = do string "A " <|> string "bucket " >> lift restofline >> return ()
|
assertdirectivep = do string "assert" >> lift restofline >> return ()
|
||||||
capturedirectivep = do string "capture" >> lift restofline >> return ()
|
bucketdirectivep = do string "A " <|> string "bucket " >> lift restofline >> return ()
|
||||||
checkdirectivep = do string "check" >> lift restofline >> return ()
|
capturedirectivep = do string "capture" >> lift restofline >> return ()
|
||||||
definedirectivep = do string "define" >> lift restofline >> return ()
|
checkdirectivep = do string "check" >> lift restofline >> return ()
|
||||||
exprdirectivep = do string "expr" >> lift restofline >> return ()
|
definedirectivep = do string "define" >> lift restofline >> return ()
|
||||||
valuedirectivep = do string "value" >> lift restofline >> return ()
|
exprdirectivep = do string "expr" >> lift restofline >> return ()
|
||||||
pythondirectivep = do string "python" >> lift restofline >> many (indented $ lift restofline) >> return ()
|
valuedirectivep = do string "value" >> lift restofline >> return ()
|
||||||
|
evaldirectivep = do string "eval" >> lift restofline >> return ()
|
||||||
|
pythondirectivep = do string "python" >> lift restofline >> many (indented $ lift restofline) >> return ()
|
||||||
where
|
where
|
||||||
indented = (lift skipNonNewlineSpaces1 >>)
|
indented = (lift skipNonNewlineSpaces1 >>)
|
||||||
evaldirectivep = do string "eval" >> lift restofline >> return ()
|
|
||||||
commandlineflagdirectivep = do string "--" >> lift restofline >> return ()
|
commandlineflagdirectivep = do string "--" >> lift restofline >> return ()
|
||||||
|
|
||||||
keywordp :: String -> JournalParser m ()
|
keywordp :: String -> JournalParser m ()
|
||||||
@ -596,11 +598,17 @@ tagdirectivep = do
|
|||||||
skipMany indentedlinep
|
skipMany indentedlinep
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
|
-- end tag or end apply tag
|
||||||
endtagdirectivep :: JournalParser m ()
|
endtagdirectivep :: JournalParser m ()
|
||||||
endtagdirectivep = do
|
endtagdirectivep = (do
|
||||||
(keywordsp "end tag" <|> keywordp "pop") <?> "end tag or pop directive"
|
string "end"
|
||||||
lift restofline
|
lift skipNonNewlineSpaces1
|
||||||
|
optional $ string "apply" >> lift skipNonNewlineSpaces1
|
||||||
|
string "tag"
|
||||||
|
lift skipNonNewlineSpaces
|
||||||
|
eol
|
||||||
return ()
|
return ()
|
||||||
|
) <?> "end tag or end apply tag directive"
|
||||||
|
|
||||||
payeedirectivep :: JournalParser m ()
|
payeedirectivep :: JournalParser m ()
|
||||||
payeedirectivep = do
|
payeedirectivep = do
|
||||||
@ -1118,7 +1126,7 @@ tests_JournalReader = testGroup "JournalReader" [
|
|||||||
|
|
||||||
,testCase "endtagdirectivep" $ do
|
,testCase "endtagdirectivep" $ do
|
||||||
assertParse endtagdirectivep "end tag \n"
|
assertParse endtagdirectivep "end tag \n"
|
||||||
assertParse endtagdirectivep "pop \n"
|
assertParse endtagdirectivep "end apply tag \n"
|
||||||
|
|
||||||
,testGroup "journalp" [
|
,testGroup "journalp" [
|
||||||
testCase "empty file" $ assertParseEqE journalp "" nulljournal
|
testCase "empty file" $ assertParseEqE journalp "" nulljournal
|
||||||
|
@ -2741,15 +2741,17 @@ These other Ledger directives are currently ignored:
|
|||||||
|
|
||||||
```journal
|
```journal
|
||||||
apply fixed COMM AMT
|
apply fixed COMM AMT
|
||||||
end apply fixed
|
|
||||||
apply tag TAG
|
apply tag TAG
|
||||||
end apply tag
|
|
||||||
assert EXPR
|
assert EXPR
|
||||||
A ACCT
|
A ACCT
|
||||||
bucket ACCT
|
bucket ACCT
|
||||||
capture ACCT REGEX
|
capture ACCT REGEX
|
||||||
check EXPR
|
check EXPR
|
||||||
define VAR=EXPR
|
define VAR=EXPR
|
||||||
|
end apply fixed
|
||||||
|
end apply tag
|
||||||
|
end apply year
|
||||||
|
end tag
|
||||||
expr EXPR
|
expr EXPR
|
||||||
tag NAME
|
tag NAME
|
||||||
value EXPR
|
value EXPR
|
||||||
|
@ -49,9 +49,7 @@ $ hledger -f- print
|
|||||||
# ignored directives
|
# ignored directives
|
||||||
<
|
<
|
||||||
apply fixed CAD $0.90
|
apply fixed CAD $0.90
|
||||||
end apply fixed
|
|
||||||
apply tag tag1:val1
|
apply tag tag1:val1
|
||||||
end apply tag
|
|
||||||
assert 1
|
assert 1
|
||||||
bucket Assets:Checking
|
bucket Assets:Checking
|
||||||
A Assets:Checking
|
A Assets:Checking
|
||||||
@ -59,6 +57,10 @@ C $1 = USD 1
|
|||||||
capture Expenses:Deductible:Medical Medical
|
capture Expenses:Deductible:Medical Medical
|
||||||
check 1
|
check 1
|
||||||
define var_name=$100
|
define var_name=$100
|
||||||
|
end apply fixed
|
||||||
|
end apply tag
|
||||||
|
end apply year
|
||||||
|
end tag
|
||||||
expr 1
|
expr 1
|
||||||
N USD
|
N USD
|
||||||
tag Receipt
|
tag Receipt
|
||||||
|
Loading…
Reference in New Issue
Block a user