glsl grammar question


On page 110 and 111 (glsl 1.50 revision 11), the init_declarator_list and single_declaration rules make possible to have a (fully specified) type, then a COMMA, then an identifier.

I’m not able to find why allowing a comma to follow directly the type is useful. Is there a useful situation where we would like it ?

Also, it is possible to have
invariant foo, bar[]
but not
invariant bar[]
What’s the reason ?

Page 112 in rule type_qualifier, the last alternative is ‘invariant’. I think it should be ‘INVARIANT’, i.e. a terminal, is it correct ?


You’ll find that the grammar allows a lot of nonsensical things to pass through. That makes the grammar easier to specify, but less useful in filtering legitimate input over nonsense.

Ok. Is there any conformance test suite out there for GLSL 1.40 and 1.50 (just for the parsing part, not for the implementation, would be enough)?

I don’t think Mesa/Gallium have started working on GLSL 1.4 yet, but that would be the first place to check. The source code for their compiler and test suite is readily available.