twilco / beancount

Rust tooling surrounding beancount, a text-based double-entry bookkeeping language.
59 stars 13 forks source link

Pushtag and poptag #48

Closed jaypha closed 3 years ago

jaypha commented 3 years ago

Added code to support poptag and pushtag directives. ParseState maintains a HashMap ("stack") of tags. When a pushtag is encountered, the tag is added to the stack (+1 count). When a poptag is encountered the tag is -1 counted, and removed if count become zero. When a transaction is encountered, all the tags currently stored in the "stack" are added to the transactions tag set. An error is generated if a poptag is encountered for a tag that is not in the "stack", and an error is generated if there are still any tags left in the "stack" when the end of input is reached.

jaypha commented 3 years ago

Thanks for the feedback. I have implemented all of the suggested changes, plus added an extra unit test.

twilco commented 3 years ago

Thank you @jaypha!

jaypha commented 3 years ago

Your'e welcome. If there is anything else you would like help with, let me know.