Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using classical recursion instead of manual recursion for the generator #16

Open
josecelano opened this issue Dec 4, 2024 · 0 comments

Comments

@josecelano
Copy link
Member

Relates to: #12

The JSON generator uses a manual recursion (with the help of the custom type Stack).

@da2ce7 made a proposal using classical recursion here.

We could try to refactor the generator and compare both implementations.

I have the feeling that classical recursion would increase readability, and I don't think that would have a big impact in performace. I used the Stack becuase:

  • I decided to port the C implementaion first without making changes and refactor later after adding tests.
  • My first attempt was not succesfull. In fact, I started from scratch with classical recursion but without separating tokenizer from generator (parser). It was a mess and I decided to go with the port from C and refactor later.

If we implement this, I think we would have a 100% classical approach: tokenizer + parser with recursion. I think that's good because I think it's a common pattern. On the other hand, I think it would be even easier to add generators for other formats.

We can also continue with the current version until we add other formats. I don't think the Stack version is very hard to follow.

cc @da2ce7 @magecnion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant