tree-sitter-beancount
tree-sitter-beancount copied to clipboard
Matching key-value lines to postings where applicable
Currently, the tree-sitter grammar recognizes all key-value lines within a transaction as children of that transaction node. This behaviour is in line with the beancount grammar and parser behaviour. However, it necessitates a post-processing step to match key-value lines to postings or the transaction itself.
With some light trickery in the grammar/scanner, it should be possible to match key-value lines to postings during parsing. However, this would cause some deviation of the grammar from beancount's.
Would this be an acceptable change in your opinion?
I think that is probably how it should be.
- any key value before postings goes onto the transaction
- any key value after a posting goes on the posting before
The issue request, while understandable, would require compromising grammar correctness. The current implementation is optimal for a tree-sitter grammar.