jonestristand / hledger-parser

A parser for ledger/hledger journal files based on Chevrotain
MIT License
13 stars 2 forks source link

feat: fully implemented amount formats as per hledger spec #10

Closed darylwright closed 1 year ago

darylwright commented 1 year ago

fixes #6

darylwright commented 1 year ago

Prod build currently fails, still have some cleanup to do.

Edit: Completed.

jonestristand commented 1 year ago

Sorry - had an interesting CPU hardware issue that was preventing me from running the test suite without getting segfaults. Item replaced now and I'll have a look at this and merge. Thanks for all your work!

darylwright commented 1 year ago

Thanks! The parsing algorithm for the amount is particularly complex as you'll see in the diagram. I think I got it right, but could use a bit of scrutiny. Also, I tried to represent the amount in the raw type as simply as possible, but I'm open to suggestions on how to communicate the location of whitespace, commodity, and signs. For now, I just ensure the number, commodity, and sign are stored in their own respective fields, while the full expression of the amount with whitespace is just a single string field.

jonestristand commented 1 year ago

image You weren't kidding :-)

jonestristand commented 1 year ago

This looks actually spot on to me. Well done!

darylwright commented 1 year ago

Awesome, thanks for the merge! This will make it easier to implement the commodity directive. It was during development of that feature where I realized I needed the correct amount parsing algorithm.