I find myself wanting/needing to write various utilities which annotate or 
otherwise modify transactions in files. In keeping with the Ledger Way, I 
do not want ledger itself to be able to make these changes, but I would 
like to be able to reliably read a journal file from an external program, 
make the modifications necessary, and write out that journal file as 
identical as possible to the original (other than my modifications, of 
course.)

Looking at instance_t::read_next_directive() in textual.cc (is that the 
right place?) it seems that such a line-by-line reconstruction would not be 
possible because certain things are thrown away (e.g. comments).

What if the code in textual.cc was augmented so that as the case statement 
in read_next_directive() dispatches control to the various *_directive() 
methods (and as those methods do their own parsing of e.g. transaction 
parts) some stream of tokens could be emitted? Then something that could 
read those tokens could then operate on that set of tokens, perhaps adding 
new ones, removing, etc., and then feed it back into something which would 
re-construct the ledger file.

There are a number of implementation details to sort out but is this sort 
of thing something people would find useful? The alternative (for my use 
cases) would be to essentially duplicate the parsing logic in textual.cc to 
be able to generate my own token stream. Which is obviously not ideal for a 
variety of reasons.

Thanks,
David

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to