jonestristand / hledger-parser

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

Reorganization of lexer token and mode file structure to avoid circular imports #7

Closed darylwright closed 1 year ago

darylwright commented 1 year ago

I'm submitting a ... [ ] bug report [ * ] feature request [ ] question about the decisions made in the repository [ ] question about how to use this project

Summary

The current file structure for the lexer tokens and modes are prone to circular imports. When a circular import occurs, a module is referenced before its exports are defined, causing undefined to show up when not intended. The consequence of this issue is seen most easily during testing, when tests fail due to accesses on undefined.

Resolving this issue will make it easier to implement the remainder of the hledger spec, as we would not have to develop around the possibility of circular imports.

jonestristand commented 1 year ago

Can you give me some examples of where specifically you are getting circular dependencies? Will make it easier for me to restructure it in a useful way!

darylwright commented 1 year ago

I encountered this issue while trying to create new lexing modes and tokens. It's a bit difficult to describe, but I'm close to completing some work on this that I'll issue a PR for. You can take those changes or modify my approach if you had something different in mind.