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

Grammar action errors need to be more informative (inherited from PEGjs) #105

Closed
stoneRdev opened this issue Apr 23, 2021 · 3 comments · Fixed by #163
Closed

Grammar action errors need to be more informative (inherited from PEGjs) #105

stoneRdev opened this issue Apr 23, 2021 · 3 comments · Fixed by #163

Comments

@stoneRdev
Copy link

Issue type

  • Bug Report: no
  • Feature Request: yes
  • Question: no
  • Not an issue: no

Prerequisites

  • Can you reproduce the issue?: yes
  • Did you search the repository issues?: yes (kind of)
  • Did you check the forums?: no (what forums?)
  • Did you perform a web search (google, yahoo, etc)?: yes

Description

So, as it stands, grammar action errors are about as vague than C++ segfaults.
For example, take this small grammar:

{
	const def1 = 1
        const def2 = 2
	const a = [def1 def2]
}

line = i / l

i = [ \t\n\r+]
l = [a-z]i

The error output is: missing ] after element list
Now, while this is fine in such a small example (its easy to spot), errors like this in a large grammar file is a headache.

I'd like to request the action errors to be reported the same as grammar errors, for example:

line = i / l

i = [ \t\n\r+
l = [a-z]i

outputs Line 3, column 5: Expected "!", "$", "&", "(", ".", character class, comment, end of line, identifier, literal, or whitespace but "[" found., which is magnitudes more helpful.

I think a good solution to this would be to at least include the line number for the action errors

Steps to Reproduce

  1. Make a grammar file
  2. Make a small typo (or other mistake) in javascript action
  3. Observe cryptographically secure error message

Example code:
Oops, provided above in description

Expected behavior:

I'd expect errors in action contexts to at least be descriptive enough to find the error
Actual behavior:

Errors in action context are vague and not helpful

Software

  • PEG.js: ^0.10.0
  • Node.js: v14.16.0
  • NPM or Yarn: yarn (primary) 1.22.10, npm 6.14.11
  • Browser: N/A
  • OS: Windows 8.1 32 bit os, 64 bit processor
  • Editor: Sublime 3.2.2 all day
@stoneRdev
Copy link
Author

inherited from pegjs/pegjs#668

@hildjj
Copy link
Contributor

hildjj commented Apr 27, 2021

Plan of attack: add optional sourceMap support. Make sure that the debugging experience isn't too weird.

@hildjj
Copy link
Contributor

hildjj commented Mar 1, 2023

Closing this now that sourceMap support has landed.

@hildjj hildjj closed this as completed Mar 1, 2023
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 a pull request may close this issue.

2 participants