tree-sitter-beancount icon indicating copy to clipboard operation
tree-sitter-beancount copied to clipboard

Matching key-value lines to postings where applicable

Open korrat opened this issue 1 year ago • 1 comments

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?

korrat avatar Oct 07 '24 16:10 korrat

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

polarmutex avatar Oct 29 '24 20:10 polarmutex

The issue request, while understandable, would require compromising grammar correctness. The current implementation is optimal for a tree-sitter grammar.

polarmutex avatar Jul 11 '25 00:07 polarmutex