-
Notifications
You must be signed in to change notification settings - Fork 845
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
Report statement errors #3559
base: main
Are you sure you want to change the base?
Report statement errors #3559
Conversation
This looks interesting, but it's going to take a little while for me to give this a proper review. |
Sounds good, surely there are some corner cases that can have been easy to miss, but I hope it's a small step in the right direction! |
@arcady-lunarg did you ever get a chance to review this? |
I am not sure I like the idea of mark_start/mark_end grammar rules. Maybe we need to update glslang's location type to be a span instead, i.e. having bot a start line/column and an end line/columns? I need to read bison's documentation a bit more as well, and I think the thing I would find the most helpful here is a before/after example of what effect this change has on some real use case. |
Sure, a second pair of eyes would be great. I mean, people working with more expierence in bison have a cleaner solution that I just didn't know about, so definitely open to ideas. Here's what I can tell you, what I remember on top of my head: I did have a play around with With regards to So if you have The first approach to me felt like I was running into a dead end given that I couldn't have any control over the parser stack so I figured the next best approach was marking statement boundaries manually, and use the look-a-head token to mark the location. For an real-world use case example, let's agree that shader complexity can outgrow where they are kept in a single file (see for example amd's fiddelity fx cacao). Basically there might be multiple shaders, often they do have shared function definitions that are reused. In one of the shaders you could have a definition like this, but just forgetting an semi-colon or a curly brace: attributes.glsl.inc:
material-a.glsl:
material-b.glsl:
So now you have these two materials a and b, when an grammar violation occurs bison reports you an message along the lines of epected Sometimes you don't really know, by looking at the shader or there might be so many includes it's obfuscated from the reader, and so even if you know the source is |
Initial changes to improve error reporting in combination with preprocessor directives. The intent of this changeset is the modify glslang in a way it reports location where the statement origionally begin, so that any syntax errors can report that location primarilly and/or report the type of statement.
All unit tests passed locally
This changeset modifies the glslang in the following ways:
Example
See #3544