Added statement block attributes to the HLSL grammar.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 25 Aug 2009 23:20:02 -0400
changeset 787 04d5c34d8b40
parent 786 795e7762da7f
child 788 9f4d32456f78
Added statement block attributes to the HLSL grammar. These are supposedly only available to Shader Model 4 and Xbox 360 targets.
mojoshader_compiler.c
mojoshader_parser_hlsl.lemon
--- a/mojoshader_compiler.c	Tue Aug 25 23:17:38 2009 -0400
+++ b/mojoshader_compiler.c	Tue Aug 25 23:20:02 2009 -0400
@@ -326,6 +326,11 @@
             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
 
--- a/mojoshader_parser_hlsl.lemon	Tue Aug 25 23:17:38 2009 -0400
+++ b/mojoshader_parser_hlsl.lemon	Tue Aug 25 23:20:02 2009 -0400
@@ -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 }
@@ -385,10 +389,21 @@
 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.