Skip to content

Make generated parsers usable on the web #461

Description

@stephanemagnenat

As discussed in #145, currently the generated parsers are not available on WebAssembly in browsers, due to Instant::now() panicking. I have an application (https://cand.li) which requires me to run the generated parser on the browser, so I would like to solve this compatibility problem. I see two ways forward:

  • use a poly-fill such as web-time,
  • modify grmtools to disable timeout, for example by creating an abstraction around the notion of "enough work has been done", and allow other conditions such as number of trials.

I do not have a strong opinion either way.

Alternatively (or in addition, also mentioned in #145, but never done), we could also slightly refactor parser.rs:371 to not call Instant::now() when recovery is not used. That might be the cheapest way, in term of changes, but of course only brings us half way (works on the web without error recovery, but at least it would allow the traditional lex/yacc use case there). As an additional benefit, it would enable using the parser without error recovery even when Instant::now() is unsupported, for example in worklets, which I would say is strictly a good thing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions