pegjs
pegjs copied to clipboard
Allow lifting local failure to global failure
PR type
- Bug fix (non-breaking change which fixes an issue): no
- New feature (non-breaking change which adds functionality): yes
- Breaking change (fix or feature that would cause existing functionality to change): no
- Documentation change: no
Prerequisites
- I have read the CONTRIBUTING.md document: yes
- I have updated the documentation accordingly: no (tbd)
- I have added tests to cover my changes: yes
Description
This is a proposed implementation of #593. It defines a new operator #
in the PEGJS grammar that converts any local failure to a global one. The bytecode generator and JavaScript generator have been updated accordingly.
Example:
VariableDefninition = VarToken __ name:#Identifier __ #"=" __ #Expression
This pull request is automatically deployed with Now. To access deployments, click Details below or on the icon next to each push.
Seems like I forgot to re-enable the ESLint task locally and missed the warnings. I'll try to fix the issues if this gets approved. In the meantime, back to messing my new language. :smile:
- It's probably best to use a more descriptive name instead of
global_fail
, likefatal_fallback
- Same as 1, only for
context.failGlobally
(e.g.context.fatalFallback
) - Have you tested this with a complex grammar?
- Documentation needs updating (only syntax documentation I think)
- If you're comfortable with TypeScript, can you update the typings, otherwise I'll do it if this is merged
@futagoza No problem, I'll update the documentation and the typings as well either today or tomorrow. Will also add some more tests to be sure everything works correctly.
Oh man, I wish this had gotten merged
It's really powerful, really difficult, slightly buggy, and the person who made it left github, so there's no way to ask for help 😦
This was super important. It didn't get merged because two underscores weren't added, and because someone wanted to know why a log comment had a space on it? And the bugs weren't noticed?