pegjs icon indicating copy to clipboard operation
pegjs copied to clipboard

Allow lifting local failure to global failure

Open ghost opened this issue 5 years ago • 5 comments

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

ghost avatar Dec 09 '18 08:12 ghost

This pull request is automatically deployed with Now. To access deployments, click Details below or on the icon next to each push.

vercel[bot] avatar Dec 09 '18 08:12 vercel[bot]

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:

ghost avatar Dec 09 '18 09:12 ghost

  1. It's probably best to use a more descriptive name instead of global_fail, like fatal_fallback
  2. Same as 1, only for context.failGlobally (e.g. context.fatalFallback)
  3. Have you tested this with a complex grammar?
  4. Documentation needs updating (only syntax documentation I think)
  5. If you're comfortable with TypeScript, can you update the typings, otherwise I'll do it if this is merged

futagoza avatar Dec 09 '18 11:12 futagoza

@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.

ghost avatar Dec 09 '18 15:12 ghost

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?

StoneCypher avatar Feb 03 '20 02:02 StoneCypher