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

Smarter behavior for 'input currently matches' in parse errors #13

Open
tedinski opened this issue May 8, 2017 · 1 comment
Open

Smarter behavior for 'input currently matches' in parse errors #13

tedinski opened this issue May 8, 2017 · 1 comment

Comments

@tedinski
Copy link
Member

tedinski commented May 8, 2017

I remembered and wanted to write down this issue today.

Right now, whenever there is a syntax error in a Silver source file, we get this as part of the parse error:

   Input currently matches:
   [silver:extension:templating:syntax:QuoteWater,
    silver:extension:templating:syntax:SingleLineQuoteWater]

These terminals are pretty much [^"]+ regexes, so naturally maximal-munch prefers them, almost always, over anything else, despite these terminals only being valid in rare contexts. Nearly always, something more specific should be reported.

I'm not sure if there's a perfect solution to this problem. Possibly a simple heuristic would be to resort to using an "all terminals are valid" lex for error reporting ONLY if there are NO matches for the set of terminals valid in the current parser state. But this may not be enough?

I'm not sure if there's any sensible way to try to enlarge the scope of valid terminals without going all the way to recognizing everything.

@schwerdf
Copy link
Contributor

schwerdf commented May 8, 2017

The real challenge is how to restrict the scope of the union scans in a composable way.

One could manually assign some kind of "priority" to terminals and, when a syntax error occurs, run the union scan on each priority class in descending order until a match is found. It might even be possible to use smart means to assign a priority when the user does not provide one explicitly. This, however, would create composition issues if extension writers did not coordinate on a priority scheme.

Another possibility is to eliminate the use of maximal munch when running union scans -- collecting the longest match of each terminal instead of the longest match, period. This is composition-safe but might result in somewhat match lists.

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

No branches or pull requests

2 participants