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 support for switch case #18

Closed
laurentlb opened this issue Apr 11, 2019 · 0 comments
Closed

Add support for switch case #18

laurentlb opened this issue Apr 11, 2019 · 0 comments

Comments

@laurentlb
Copy link
Owner

Apparently, some people use them. :)

The exact grammar is in the spec: https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.50.pdf

jwatzman added a commit to jwatzman/Shader_Minifier that referenced this issue Apr 27, 2022
This is relatively simple and straightforward.

Note that this is much more permissive than GLSL compilers seem to be;
for example I'm pretty sure this will allow much more in a case label
than it should (I think a literal int must come after). But I don't
think it will cause the minifier to emit invalid GLSL unless the input
was invalid already.

It's actually somewhat unclear what the right grammar even is here.
Looking at the 4.5 spec linked in laurentlb#18 -- section 9 (the normative
grammar), page 205 says that a `case_label` is `CASE expression COLON`,
but from testing with an actual compiler it looks like it needs to be a
literal integer. Also the definition of `switch_statement_list` doesn't
include `case_label`.  So by my reading that's a bug in the spec (or at
least a place that compilers are quite reasonably more restrictive) so
even if we did want to be perfectly correct here I'm not sure what
exactly that looks like :)

Fixes laurentlb#18.
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

No branches or pull requests

1 participant