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

Trampolining and error recovery #1583

Open
verytactical opened this issue Jan 27, 2025 · 0 comments
Open

Trampolining and error recovery #1583

verytactical opened this issue Jan 27, 2025 · 0 comments
Labels
scope: parser Implementation of parser (src/grammar)

Comments

@verytactical
Copy link
Contributor

Try to write an implementation of seq, sel etc. where everything is a generator.

When error<Parser, "message"> is encountered, yield Recovered("message").

On entering a rule (a call), return child generator wrapped in Batch(), effectively trampolining it.

Make runParser(gen: () => Generator<...>) that

  • when gen yields a Batch, push current generator on a const stack = []; and continue with the new generator
  • when gen yields a Recovered, yield it

In order to prevent Tact running in browser from making the page freeze (before we implement better measures such as Worker; those require peculiar build process, major changes to API and making the code isomorphic)

  • every N steps do a check
    • if delta on Date.now() between current and previous check is larger than M
      • await Promise.resolve(); to ensure other threads have time to do their job

Blocker to #1582

@verytactical verytactical added the scope: parser Implementation of parser (src/grammar) label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: parser Implementation of parser (src/grammar)
Projects
None yet
Development

No branches or pull requests

1 participant