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

Add unexpectedRule option and feature #661

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

log4b0at
Copy link

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
  • I have added tests to cover my changes: no

Description

A little patch to add the unexpected rule feature. See #607

Usage:

  • Add the unexpectedRule option to set the unexpected rule name, like in the following example
PEG.generate(/* source */, {unexpectedRule: 'unexpected'})
  • Add the rule in your parser grammar
unexpected =
  Function { error("unexpected function declaration here"); } /
  Identifier { error("unexpected identifier here"); };

Note:
Maybe we should add a correct error message when the unexpectedRule is defined but the rule named isn't present in the grammar.

@vercel
Copy link

vercel bot commented Feb 28, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/peg-js/pegjs/HWN44mi97JRnyM95gF2U42RffmFZ
✅ Preview: https://pegjs-git-fork-log4b0at-master-peg-js.vercel.app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant