Skip to content

Commit

Permalink
Added statement block attributes to the HLSL grammar.
Browse files Browse the repository at this point in the history
These are supposedly only available to Shader Model 4 and Xbox 360 targets.
  • Loading branch information
icculus committed Aug 26, 2009
1 parent 0bd2877 commit bca8443
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mojoshader_compiler.c
Expand Up @@ -326,6 +326,11 @@ static int convert_to_lemon_token(const Context *ctx)
if (tokencmp("sampler_state")) return TOKEN_HLSL_SAMPLER_STATE;
if (tokencmp("SamplerState")) return TOKEN_HLSL_SAMPLERSTATE;
if (tokencmp("SamplerComparisonState")) return TOKEN_HLSL_SAMPLERCOMPARISONSTATE;
if (tokencmp("isolate")) return TOKEN_HLSL_ISOLATE;
if (tokencmp("maxInstructionCount")) return TOKEN_HLSL_MAXINSTRUCTIONCOUNT;
if (tokencmp("noExpressionOptimizations")) return TOKEN_HLSL_NOEXPRESSIONOPTIMIZATIONS;
if (tokencmp("unused")) return TOKEN_HLSL_UNUSED;
if (tokencmp("xps")) return TOKEN_HLSL_XPS;

#undef tokencmp

Expand Down
15 changes: 15 additions & 0 deletions mojoshader_parser_hlsl.lemon
Expand Up @@ -19,6 +19,10 @@

%name ParseHLSL

// Some shift-reduce conflicts are basically unavoidable, but if the final
// conflict count matches this value, we consider it known and acceptable.
%expect 1

%start_symbol shader
%token_prefix TOKEN_HLSL_
%token_type { TokenData }
Expand Down Expand Up @@ -385,10 +389,21 @@ statement_block ::= LBRACE statement_list RBRACE.
statement_list ::= statement.
statement_list ::= statement_list statement.

// These are for Shader Model 4 and Xbox 360 only, apparently.
statement_attribute_details ::= ISOLATE.
statement_attribute_details ::= MAXINSTRUCTIONCOUNT LPAREN INT_CONSTANT RPAREN.
statement_attribute_details ::= NOEXPRESSIONOPTIMIZATIONS.
statement_attribute_details ::= REMOVEUNUSEDINPUTS.
statement_attribute_details ::= UNUSED.
statement_attribute_details ::= XPS.

statement_attribute ::= LBRACKET statement_attribute_details RBRACKET.

statement ::= return_statement.
statement ::= BREAK SEMICOLON.
statement ::= CONTINUE SEMICOLON.
statement ::= DISCARD SEMICOLON.
statement ::= statement_attribute statement_block.
statement ::= statement_block.
statement ::= for_statement.
statement ::= do_statement.
Expand Down

0 comments on commit bca8443

Please sign in to comment.