[Mesa-dev] [PATCH 2/6] glsl: Add productions to GLSL grammar for switch statement

Kenneth Graunke kenneth at whitecape.org
Mon Jun 27 10:36:45 PDT 2011


On 06/24/2011 12:59 PM, Dan McCabe wrote:
> On 06/20/2011 03:39 PM, Ian Romanick wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 06/17/2011 05:43 PM, Dan McCabe wrote:
>>> The grammar is modified to support switch statements. Rather than
>>> follow the
>>> grammar in the appendix, which allows case labels to be placed ANYWHERE
>>> as a regular statement, we follow the development of the grammar as
>>> described in the body of the GLSL.
>>>
>>> In this variation, the switch statement has a body which consists of
>>> a list
>>> of case statements. A case statement is preceded by a list of case
>>> labels and
>>> ends with a list of statements.
>> Either this patch or patch 6/6 is the right place to restrict
>> switch-statements and case labels to GLSL 1.30. From the looks of the
>> series, these patches will merrily allow switch-statements on any GLSL
>> version. That seems bad. :)
>
> Isn't that the purpose of the KYEWORD macro in glsl_lexer.ll ? Those
> macros already specify that that these are valid keywords in 1.3 or
> beyond already.
>
> cheers, danm

Yeah, the KEYWORD macro ensures that 'switch', 'default', and 'case' 
tokens are only returned for GLSL >= 1.30.  Prior to that, 'switch' and 
'default' will result in "reserved word" errors, while 'case' will be 
treated as an identifier.

So I don't think it's necessary to check for GLSL 1.30 in the grammar or 
AST->HIR code.

--Kenneth


More information about the mesa-dev mailing list