Skip to content

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

@josecelano

Description

@josecelano

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions