mojoshader_parser_hlsl.lemon
author Ryan C. Gordon <icculus@icculus.org>
Tue, 09 Feb 2010 02:55:38 -0500
branchcalculator-experiment
changeset 827 2f955ce29b7b
parent 796 ab5e4797e0cb
child 836 d975fa785f1e
permissions -rw-r--r--
Moved the calculator experiment work back into the compiler. At least we know the expression parser works! :) Lots of other bits of new infrastructure in there, too.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
     1
/**
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
     2
 * MojoShader; generate shader programs from bytecode of compiled
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
     3
 *  Direct3D shaders.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
     4
 *
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
     5
 * Please see the file LICENSE.txt in the source's root directory.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
     6
 *
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
     7
 *  This file written by Ryan C. Gordon.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
     8
 */
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    10
// This is a Lemon Parser grammar for HLSL. It is based on an ANSI C YACC
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    11
//  grammar by Jeff Lee: http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    13
// Lemon is here: http://www.hwaci.com/sw/lemon/  ...  the source is included
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    14
//  with MojoShader, and built with the library, so you don't have to track
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    15
//  down the dependency.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    16
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    17
// HLSL syntax is described, informally, here:
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    18
//  http://msdn.microsoft.com/en-us/library/bb509615(VS.85).aspx
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    20
%name ParseHLSL
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    21
787
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
    22
// Some shift-reduce conflicts are basically unavoidable, but if the final
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
    23
//  conflict count matches this value, we consider it known and acceptable.
788
9f4d32456f78 Allow vector initializers, like "float4 x = {a,b,c,d};"
Ryan C. Gordon <icculus@icculus.org>
parents: 787
diff changeset
    24
%expect 2
787
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
    25
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    26
%start_symbol shader
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    27
%token_prefix TOKEN_HLSL_
778
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 777
diff changeset
    28
%token_type { TokenData }
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    29
%extra_argument { Context *ctx }
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    31
%include {
709
6fbd0e20b40f Removed some ANSI C things from the HLSL grammar that shaders don't do.
Ryan C. Gordon <icculus@icculus.org>
parents: 707
diff changeset
    32
#ifndef __MOJOSHADER_HLSL_COMPILER__
6fbd0e20b40f Removed some ANSI C things from the HLSL grammar that shaders don't do.
Ryan C. Gordon <icculus@icculus.org>
parents: 707
diff changeset
    33
#error Do not compile this file directly.
6fbd0e20b40f Removed some ANSI C things from the HLSL grammar that shaders don't do.
Ryan C. Gordon <icculus@icculus.org>
parents: 707
diff changeset
    34
#endif
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    35
}
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
785
5a0a763d74e1 Added totally unhelpful syntax error output.
Ryan C. Gordon <icculus@icculus.org>
parents: 783
diff changeset
    37
%syntax_error {
5a0a763d74e1 Added totally unhelpful syntax error output.
Ryan C. Gordon <icculus@icculus.org>
parents: 783
diff changeset
    38
    fprintf(stderr,"Syntax error\n");
5a0a763d74e1 Added totally unhelpful syntax error output.
Ryan C. Gordon <icculus@icculus.org>
parents: 783
diff changeset
    39
}
5a0a763d74e1 Added totally unhelpful syntax error output.
Ryan C. Gordon <icculus@icculus.org>
parents: 783
diff changeset
    40
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    41
%parse_failure {
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
    42
    // !!! FIXME: make this a proper fail() function.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
    43
    ctx->isfail = 1;
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    44
    fprintf(stderr,"Giving up.  Parser is hopelessly lost...\n");
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    45
}
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    46
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    47
%stack_overflow {
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
    48
    // !!! FIXME: make this a proper fail() function.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
    49
    ctx->isfail = 1;
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    50
    fprintf(stderr,"Giving up.  Parser stack overflow\n");
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    51
}
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    53
// operator precedence (matches C spec)...
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    55
%left COMMA.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    56
%right ASSIGN ADDASSIGN SUBASSIGN MULASSIGN DIVASSIGN MODASSIGN LSHIFTASSIGN
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    57
       RSHIFTASSIGN ANDASSIGN ORASSIGN XORASSIGN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    58
%right QUESTION.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    59
%left OROR.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    60
%left ANDAND.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    61
%left OR.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    62
%left XOR.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    63
%left AND.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    64
%left EQL NEQ.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    65
%left LT LEQ GT GEQ.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    66
%left LSHIFT RSHIFT.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    67
%left PLUS MINUS.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    68
%left STAR SLASH PERCENT.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    69
%right TYPECAST EXCLAMATION COMPLEMENT MINUSMINUS PLUSPLUS.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    70
%left DOT LBRACKET RBRACKET LPAREN RPAREN.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
704
292ea2611014 Resolved "dangling else" problem in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 703
diff changeset
    72
// bump up the precedence of ELSE, to avoid shift/reduce conflict on the
292ea2611014 Resolved "dangling else" problem in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 703
diff changeset
    73
//  usual "dangling else ambiguity" ...
292ea2611014 Resolved "dangling else" problem in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 703
diff changeset
    74
%right ELSE.
292ea2611014 Resolved "dangling else" problem in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 703
diff changeset
    75
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    77
// The rules...
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    78
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
    79
%type shader { int }                // !!! FIXME: remove this later.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
    80
%destructor shader { (void) ctx; }  // !!! FIXME: remove this later.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    81
shader ::= compilation_units.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    82
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    83
compilation_units ::= compilation_unit.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    84
compilation_units ::= compilation_units compilation_unit.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    85
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    86
compilation_unit ::= function_declaration.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    87
compilation_unit ::= function_definition.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    88
compilation_unit ::= global_variable.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    89
compilation_unit ::= typedef_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    90
compilation_unit ::= struct_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    91
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    92
function_declaration ::= function_signature SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    93
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    94
function_definition ::= function_signature statement_block.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    95
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    96
function_signature ::= function_storageclass function_details semantic.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    97
function_signature ::= function_storageclass function_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    98
function_signature ::= function_details semantic.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    99
function_signature ::= function_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   100
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   101
function_details ::= datatype IDENTIFIER LPAREN function_arguments RPAREN.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   102
function_details ::= VOID IDENTIFIER LPAREN function_arguments RPAREN.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   103
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   104
// !!! FIXME: there is a "target" storage class that is the name of the
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   105
// !!! FIXME:  platform that this function is meant for...but I don't know
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   106
// !!! FIXME:  what tokens are valid here.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   107
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   108
// !!! FIXME: Also, the docs say "one of" inline or target, but I bet you can
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   109
// !!! FIXME:  specify both.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   110
//function_storageclass ::= target.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   111
function_storageclass ::= INLINE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   112
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   113
function_arguments ::= VOID.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   114
function_arguments ::= function_argument_list.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   115
function_arguments ::= .
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   116
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   117
function_argument_list ::= function_argument.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   118
function_argument_list ::= function_argument_list COMMA function_argument.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   119
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   120
function_argument ::= input_modifier datatype IDENTIFIER semantic interpolation_mod initializer.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   121
function_argument ::= input_modifier datatype IDENTIFIER semantic interpolation_mod.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   122
function_argument ::= input_modifier datatype IDENTIFIER semantic initializer.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   123
function_argument ::= input_modifier datatype IDENTIFIER semantic.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   124
function_argument ::= input_modifier datatype IDENTIFIER interpolation_mod initializer.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   125
function_argument ::= input_modifier datatype IDENTIFIER interpolation_mod.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   126
function_argument ::= input_modifier datatype IDENTIFIER initializer.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   127
function_argument ::= input_modifier datatype IDENTIFIER.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   128
function_argument ::= datatype IDENTIFIER semantic interpolation_mod initializer.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   129
function_argument ::= datatype IDENTIFIER semantic interpolation_mod.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   130
function_argument ::= datatype IDENTIFIER semantic initializer.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   131
function_argument ::= datatype IDENTIFIER semantic.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   132
function_argument ::= datatype IDENTIFIER interpolation_mod initializer.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   133
function_argument ::= datatype IDENTIFIER interpolation_mod.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   134
function_argument ::= datatype IDENTIFIER initializer.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   135
function_argument ::= datatype IDENTIFIER.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   136
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   137
input_modifier ::= IN.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   138
input_modifier ::= INOUT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   139
input_modifier ::= OUT.
780
4a35087ba839 Apparently "inout" and "in out" are both legal for HLSL function parameters.
Ryan C. Gordon <icculus@icculus.org>
parents: 779
diff changeset
   140
input_modifier ::= IN OUT.
4a35087ba839 Apparently "inout" and "in out" are both legal for HLSL function parameters.
Ryan C. Gordon <icculus@icculus.org>
parents: 779
diff changeset
   141
input_modifier ::= OUT IN.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   142
input_modifier ::= UNIFORM.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   143
730
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 726
diff changeset
   144
semantic ::= COLON SEMANTIC.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   145
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   146
// DX10 only?
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   147
interpolation_mod ::= LINEAR.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   148
interpolation_mod ::= CENTROID.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   149
interpolation_mod ::= NOINTERPOLATION.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   150
interpolation_mod ::= NOPERSPECTIVE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   151
interpolation_mod ::= SAMPLE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   152
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   153
global_variable ::= variable_declaration.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   154
725
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   155
variable_declaration ::= variable_attribute_list datatype variable_declaration_details_list SEMICOLON.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   156
variable_declaration ::= datatype variable_declaration_details_list SEMICOLON.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   157
variable_declaration ::= struct_declaration scalar_or_array SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   158
725
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   159
variable_declaration_details_list ::= variable_declaration_details.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   160
variable_declaration_details_list ::= variable_declaration_details_list COMMA variable_declaration_details.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   161
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   162
variable_declaration_details ::= scalar_or_array semantic annotations initializer variable_lowlevel.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   163
variable_declaration_details ::= scalar_or_array semantic annotations initializer.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   164
variable_declaration_details ::= scalar_or_array semantic annotations variable_lowlevel.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   165
variable_declaration_details ::= scalar_or_array semantic annotations.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   166
variable_declaration_details ::= scalar_or_array semantic initializer variable_lowlevel.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   167
variable_declaration_details ::= scalar_or_array semantic initializer.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   168
variable_declaration_details ::= scalar_or_array semantic variable_lowlevel.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   169
variable_declaration_details ::= scalar_or_array semantic.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   170
variable_declaration_details ::= scalar_or_array annotations initializer variable_lowlevel.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   171
variable_declaration_details ::= scalar_or_array annotations initializer.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   172
variable_declaration_details ::= scalar_or_array annotations variable_lowlevel.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   173
variable_declaration_details ::= scalar_or_array annotations.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   174
variable_declaration_details ::= scalar_or_array initializer variable_lowlevel.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   175
variable_declaration_details ::= scalar_or_array initializer.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   176
variable_declaration_details ::= scalar_or_array variable_lowlevel.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   177
variable_declaration_details ::= scalar_or_array.
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   178
724
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   179
// !!! FIXME: we don't handle full sampler declarations at the moment.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   180
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   181
struct_declaration ::= STRUCT IDENTIFIER(A) LBRACE struct_member_list RBRACE.
778
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 777
diff changeset
   182
{
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   183
    add_usertype(ctx, A.string);
778
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 777
diff changeset
   184
}
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   185
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   186
struct_member_list ::= struct_member.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   187
struct_member_list ::= struct_member_list struct_member.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   188
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   189
struct_member ::= interpolation_mod struct_member_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   190
struct_member ::= struct_member_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   191
726
9f58e2b0ed8a Fixed struct declaration in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 725
diff changeset
   192
struct_member_details ::= datatype struct_member_item_list SEMICOLON.
9f58e2b0ed8a Fixed struct declaration in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 725
diff changeset
   193
777
5ab8bb0ac2af Fixed HLSL parsing of structs with array fields.
Ryan C. Gordon <icculus@icculus.org>
parents: 730
diff changeset
   194
struct_member_item_list ::= scalar_or_array.
781
8b80cf8692a4 HLSL struct fields can have semantics.
Ryan C. Gordon <icculus@icculus.org>
parents: 780
diff changeset
   195
struct_member_item_list ::= scalar_or_array semantic.
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   196
struct_member_item_list ::= struct_member_item_list COMMA IDENTIFIER.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   197
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   198
typedef_statement ::= TYPEDEF CONST datatype scalar_or_array.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   199
typedef_statement ::= TYPEDEF datatype scalar_or_array.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   200
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   201
variable_lowlevel ::= packoffset register.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   202
variable_lowlevel ::= packoffset.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   203
variable_lowlevel ::= register.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   204
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   205
scalar_or_array ::= IDENTIFIER LBRACKET RBRACKET.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   206
scalar_or_array ::= IDENTIFIER LBRACKET expression RBRACKET.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   207
scalar_or_array ::= IDENTIFIER.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   208
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   209
packoffset ::= PACKOFFSET LPAREN IDENTIFIER IDENTIFIER RPAREN.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   210
packoffset ::= PACKOFFSET LPAREN IDENTIFIER RPAREN.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   211
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   212
register ::= COLON REGISTER LPAREN IDENTIFIER RPAREN.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   213
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   214
annotations ::= LT annotation_list GT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   215
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   216
annotation_list ::= annotation.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   217
annotation_list ::= annotation_list annotation.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   218
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   219
annotation ::= datatype_scalar initializer SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   220
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   221
variable_attribute_list ::= variable_attribute.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   222
variable_attribute_list ::= variable_attribute_list variable_attribute.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   223
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   224
variable_attribute ::= EXTERN.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   225
variable_attribute ::= NOINTERPOLATION.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   226
variable_attribute ::= SHARED.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   227
variable_attribute ::= STATIC.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   228
variable_attribute ::= UNIFORM.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   229
variable_attribute ::= VOLATILE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   230
variable_attribute ::= CONST.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   231
variable_attribute ::= ROWMAJOR.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   232
variable_attribute ::= COLUMNMAJOR.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   233
788
9f4d32456f78 Allow vector initializers, like "float4 x = {a,b,c,d};"
Ryan C. Gordon <icculus@icculus.org>
parents: 787
diff changeset
   234
initializer_block_list ::= expression.
790
0cf8abbbc9fa Initializer blocks can nest, like "float4 x[] = { {a,b,c,d}, {a,b,c,d} };"
Ryan C. Gordon <icculus@icculus.org>
parents: 789
diff changeset
   235
initializer_block_list ::= LBRACE initializer_block_list RBRACE.
0cf8abbbc9fa Initializer blocks can nest, like "float4 x[] = { {a,b,c,d}, {a,b,c,d} };"
Ryan C. Gordon <icculus@icculus.org>
parents: 789
diff changeset
   236
initializer_block_list ::= initializer_block_list COMMA initializer_block_list.
788
9f4d32456f78 Allow vector initializers, like "float4 x = {a,b,c,d};"
Ryan C. Gordon <icculus@icculus.org>
parents: 787
diff changeset
   237
initializer_block ::= LBRACE initializer_block_list RBRACE.
9f4d32456f78 Allow vector initializers, like "float4 x = {a,b,c,d};"
Ryan C. Gordon <icculus@icculus.org>
parents: 787
diff changeset
   238
9f4d32456f78 Allow vector initializers, like "float4 x = {a,b,c,d};"
Ryan C. Gordon <icculus@icculus.org>
parents: 787
diff changeset
   239
initializer ::= ASSIGN initializer_block.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   240
initializer ::= ASSIGN expression.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   241
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   242
intrinsic_datatype ::= datatype_vector.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   243
intrinsic_datatype ::= datatype_matrix.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   244
intrinsic_datatype ::= datatype_scalar.
724
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   245
intrinsic_datatype ::= datatype_sampler.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   246
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   247
datatype ::= intrinsic_datatype.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   248
datatype ::= USERTYPE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   249
724
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   250
datatype_sampler ::= SAMPLER.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   251
datatype_sampler ::= SAMPLER1D.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   252
datatype_sampler ::= SAMPLER2D.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   253
datatype_sampler ::= SAMPLER3D.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   254
datatype_sampler ::= SAMPLERCUBE.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   255
datatype_sampler ::= SAMPLER_STATE.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   256
datatype_sampler ::= SAMPLERSTATE.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   257
datatype_sampler ::= SAMPLERCOMPARISONSTATE.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   258
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   259
datatype_scalar ::= BOOL.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   260
datatype_scalar ::= INT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   261
datatype_scalar ::= UINT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   262
datatype_scalar ::= HALF.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   263
datatype_scalar ::= FLOAT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   264
datatype_scalar ::= DOUBLE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   265
datatype_scalar ::= STRING.  // this is for the effects framework, not HLSL.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   266
datatype_scalar ::= SNORM FLOAT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   267
datatype_scalar ::= UNORM FLOAT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   268
datatype_scalar ::= BUFFER LT datatype_scalar GT.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   269
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   270
// !!! FIXME: MSDN suggests that the matrix ones are just typedefs inserted
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   271
// !!! FIXME:  before parsing begins, like:
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   272
// !!! FIXME: typedef matrix <bool,4,3> bool4x3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   273
// !!! FIXME:  ...maybe we can rip these out of the grammar and just create
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   274
// !!! FIXME:  them at startup?
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   275
datatype_vector ::= VECTOR LT datatype_scalar COMMA INT_CONSTANT GT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   276
datatype_vector ::= BOOL1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   277
datatype_vector ::= BOOL2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   278
datatype_vector ::= BOOL3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   279
datatype_vector ::= BOOL4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   280
datatype_vector ::= INT1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   281
datatype_vector ::= INT2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   282
datatype_vector ::= INT3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   283
datatype_vector ::= INT4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   284
datatype_vector ::= UINT1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   285
datatype_vector ::= UINT2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   286
datatype_vector ::= UINT3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   287
datatype_vector ::= UINT4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   288
datatype_vector ::= HALF1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   289
datatype_vector ::= HALF2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   290
datatype_vector ::= HALF3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   291
datatype_vector ::= HALF4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   292
datatype_vector ::= FLOAT1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   293
datatype_vector ::= FLOAT2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   294
datatype_vector ::= FLOAT3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   295
datatype_vector ::= FLOAT4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   296
datatype_vector ::= DOUBLE1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   297
datatype_vector ::= DOUBLE2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   298
datatype_vector ::= DOUBLE3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   299
datatype_vector ::= DOUBLE4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   300
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   301
datatype_matrix ::= MATRIX LT datatype_scalar COMMA INT_CONSTANT COMMA INT_CONSTANT GT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   302
datatype_matrix ::= BOOL1X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   303
datatype_matrix ::= BOOL1X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   304
datatype_matrix ::= BOOL1X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   305
datatype_matrix ::= BOOL1X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   306
datatype_matrix ::= BOOL2X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   307
datatype_matrix ::= BOOL2X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   308
datatype_matrix ::= BOOL2X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   309
datatype_matrix ::= BOOL2X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   310
datatype_matrix ::= BOOL3X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   311
datatype_matrix ::= BOOL3X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   312
datatype_matrix ::= BOOL3X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   313
datatype_matrix ::= BOOL3X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   314
datatype_matrix ::= BOOL4X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   315
datatype_matrix ::= BOOL4X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   316
datatype_matrix ::= BOOL4X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   317
datatype_matrix ::= BOOL4X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   318
datatype_matrix ::= INT1X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   319
datatype_matrix ::= INT1X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   320
datatype_matrix ::= INT1X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   321
datatype_matrix ::= INT1X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   322
datatype_matrix ::= INT2X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   323
datatype_matrix ::= INT2X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   324
datatype_matrix ::= INT2X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   325
datatype_matrix ::= INT2X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   326
datatype_matrix ::= INT3X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   327
datatype_matrix ::= INT3X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   328
datatype_matrix ::= INT3X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   329
datatype_matrix ::= INT3X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   330
datatype_matrix ::= INT4X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   331
datatype_matrix ::= INT4X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   332
datatype_matrix ::= INT4X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   333
datatype_matrix ::= INT4X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   334
datatype_matrix ::= UINT1X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   335
datatype_matrix ::= UINT1X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   336
datatype_matrix ::= UINT1X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   337
datatype_matrix ::= UINT1X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   338
datatype_matrix ::= UINT2X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   339
datatype_matrix ::= UINT2X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   340
datatype_matrix ::= UINT2X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   341
datatype_matrix ::= UINT2X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   342
datatype_matrix ::= UINT3X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   343
datatype_matrix ::= UINT3X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   344
datatype_matrix ::= UINT3X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   345
datatype_matrix ::= UINT3X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   346
datatype_matrix ::= UINT4X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   347
datatype_matrix ::= UINT4X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   348
datatype_matrix ::= UINT4X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   349
datatype_matrix ::= UINT4X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   350
datatype_matrix ::= HALF1X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   351
datatype_matrix ::= HALF1X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   352
datatype_matrix ::= HALF1X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   353
datatype_matrix ::= HALF1X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   354
datatype_matrix ::= HALF2X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   355
datatype_matrix ::= HALF2X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   356
datatype_matrix ::= HALF2X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   357
datatype_matrix ::= HALF2X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   358
datatype_matrix ::= HALF3X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   359
datatype_matrix ::= HALF3X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   360
datatype_matrix ::= HALF3X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   361
datatype_matrix ::= HALF3X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   362
datatype_matrix ::= HALF4X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   363
datatype_matrix ::= HALF4X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   364
datatype_matrix ::= HALF4X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   365
datatype_matrix ::= HALF4X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   366
datatype_matrix ::= FLOAT1X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   367
datatype_matrix ::= FLOAT1X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   368
datatype_matrix ::= FLOAT1X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   369
datatype_matrix ::= FLOAT1X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   370
datatype_matrix ::= FLOAT2X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   371
datatype_matrix ::= FLOAT2X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   372
datatype_matrix ::= FLOAT2X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   373
datatype_matrix ::= FLOAT2X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   374
datatype_matrix ::= FLOAT3X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   375
datatype_matrix ::= FLOAT3X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   376
datatype_matrix ::= FLOAT3X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   377
datatype_matrix ::= FLOAT3X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   378
datatype_matrix ::= FLOAT4X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   379
datatype_matrix ::= FLOAT4X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   380
datatype_matrix ::= FLOAT4X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   381
datatype_matrix ::= FLOAT4X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   382
datatype_matrix ::= DOUBLE1X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   383
datatype_matrix ::= DOUBLE1X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   384
datatype_matrix ::= DOUBLE1X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   385
datatype_matrix ::= DOUBLE1X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   386
datatype_matrix ::= DOUBLE2X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   387
datatype_matrix ::= DOUBLE2X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   388
datatype_matrix ::= DOUBLE2X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   389
datatype_matrix ::= DOUBLE2X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   390
datatype_matrix ::= DOUBLE3X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   391
datatype_matrix ::= DOUBLE3X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   392
datatype_matrix ::= DOUBLE3X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   393
datatype_matrix ::= DOUBLE3X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   394
datatype_matrix ::= DOUBLE4X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   395
datatype_matrix ::= DOUBLE4X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   396
datatype_matrix ::= DOUBLE4X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   397
datatype_matrix ::= DOUBLE4X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   398
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   399
statement_block ::= LBRACE RBRACE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   400
statement_block ::= LBRACE statement_list RBRACE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   401
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   402
statement_list ::= statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   403
statement_list ::= statement_list statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   404
787
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   405
// These are for Shader Model 4 and Xbox 360 only, apparently.
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   406
statement_attribute_details ::= ISOLATE.
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   407
statement_attribute_details ::= MAXINSTRUCTIONCOUNT LPAREN INT_CONSTANT RPAREN.
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   408
statement_attribute_details ::= NOEXPRESSIONOPTIMIZATIONS.
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   409
statement_attribute_details ::= REMOVEUNUSEDINPUTS.
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   410
statement_attribute_details ::= UNUSED.
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   411
statement_attribute_details ::= XPS.
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   412
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   413
statement_attribute ::= LBRACKET statement_attribute_details RBRACKET.
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   414
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   415
statement ::= return_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   416
statement ::= BREAK SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   417
statement ::= CONTINUE SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   418
statement ::= DISCARD SEMICOLON.
787
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   419
statement ::= statement_attribute statement_block.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   420
statement ::= statement_block.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   421
statement ::= for_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   422
statement ::= do_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   423
statement ::= while_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   424
statement ::= if_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   425
statement ::= switch_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   426
statement ::= variable_declaration.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   427
statement ::= typedef_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   428
statement ::= expression_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   429
statement ::= struct_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   430
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   431
struct_statement ::= struct_declaration SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   432
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   433
expression_statement ::= SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   434
expression_statement ::= expression SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   435
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   436
return_statement ::= RETURN SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   437
return_statement ::= RETURN expression SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   438
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   439
while_statement ::= loop_attribute while_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   440
while_statement ::= while_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   441
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   442
while_details ::= WHILE LPAREN expression RPAREN statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   443
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   444
for_statement ::= loop_attribute for_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   445
for_statement ::= for_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   446
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   447
for_details ::= FOR LPAREN expression SEMICOLON expression SEMICOLON expression RPAREN statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   448
for_details ::= FOR LPAREN SEMICOLON SEMICOLON RPAREN statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   449
for_details ::= FOR LPAREN SEMICOLON SEMICOLON expression RPAREN statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   450
for_details ::= FOR LPAREN SEMICOLON expression SEMICOLON RPAREN statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   451
for_details ::= FOR LPAREN SEMICOLON expression SEMICOLON expression RPAREN statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   452
for_details ::= FOR LPAREN expression SEMICOLON SEMICOLON RPAREN statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   453
for_details ::= FOR LPAREN expression SEMICOLON SEMICOLON expression RPAREN statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   454
for_details ::= FOR LPAREN expression SEMICOLON expression SEMICOLON RPAREN statement.
783
49b40da02528 HLSL for loops can have variable declarations: "for (int x=0; x<10; x++) {}"
Ryan C. Gordon <icculus@icculus.org>
parents: 782
diff changeset
   455
for_details ::= FOR LPAREN variable_declaration expression SEMICOLON expression RPAREN statement.
49b40da02528 HLSL for loops can have variable declarations: "for (int x=0; x<10; x++) {}"
Ryan C. Gordon <icculus@icculus.org>
parents: 782
diff changeset
   456
for_details ::= FOR LPAREN variable_declaration SEMICOLON RPAREN statement.
49b40da02528 HLSL for loops can have variable declarations: "for (int x=0; x<10; x++) {}"
Ryan C. Gordon <icculus@icculus.org>
parents: 782
diff changeset
   457
for_details ::= FOR LPAREN variable_declaration SEMICOLON expression RPAREN statement.
49b40da02528 HLSL for loops can have variable declarations: "for (int x=0; x<10; x++) {}"
Ryan C. Gordon <icculus@icculus.org>
parents: 782
diff changeset
   458
for_details ::= FOR LPAREN variable_declaration expression SEMICOLON RPAREN statement.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   459
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   460
loop_attribute ::= UNROLL LPAREN INT_CONSTANT RPAREN.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   461
loop_attribute ::= UNROLL.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   462
loop_attribute ::= LOOP.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   463
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   464
do_statement ::= DO statement WHILE LPAREN expression RPAREN SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   465
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   466
if_statement ::= if_attribute IF LPAREN expression RPAREN statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   467
if_statement ::= IF LPAREN expression RPAREN statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   468
if_statement ::= if_attribute IF LPAREN expression RPAREN statement ELSE statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   469
if_statement ::= IF LPAREN expression RPAREN statement ELSE statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   470
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   471
if_attribute ::= BRANCH.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   472
if_attribute ::= FLATTEN.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   473
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   474
switch_statement ::= switch_attribute switch_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   475
switch_statement ::= switch_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   476
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   477
switch_details ::= SWITCH LPAREN expression RPAREN LBRACE switch_case_list RBRACE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   478
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   479
switch_attribute ::= FLATTEN.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   480
switch_attribute ::= BRANCH.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   481
switch_attribute ::= FORCECASE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   482
switch_attribute ::= CALL.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   483
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   484
switch_case_list ::= switch_case.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   485
switch_case_list ::= switch_case_list switch_case.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   486
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   487
// You can do math here, apparently, as long as it produces an int constant.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   488
//  ...so "case 3+2:" works.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   489
switch_case ::= CASE expression COLON statement_list.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   490
switch_case ::= CASE expression COLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   491
switch_case ::= DEFAULT COLON statement_list.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   492
switch_case ::= DEFAULT COLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   493
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   494
// the expression stuff is based on Jeff Lee's ANSI C grammar.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   495
%type primary_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   496
primary_expr(A) ::= IDENTIFIER(B). { A = new_identifier_expr(ctx, B.string); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   497
primary_expr(A) ::= INT_CONSTANT(B). { A = new_literal_int_expr(ctx, B.i64); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   498
primary_expr(A) ::= FLOAT_CONSTANT(B). { A = new_literal_float_expr(ctx, B.dbl); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   499
primary_expr(A) ::= STRING_LITERAL(B). { A = new_literal_string_expr(ctx, B.string); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   500
primary_expr(A) ::= LPAREN expression(B) RPAREN. { A = B; }
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   501
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   502
%type postfix_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   503
postfix_expr(A) ::= primary_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   504
postfix_expr(A) ::= postfix_expr(B) LBRACKET expression(C) RBRACKET. { A = new_binary_expr(ctx, OP_DEREF_ARRAY, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   505
postfix_expr(A) ::= postfix_expr(B) LPAREN RPAREN. { A = new_binary_expr(ctx, OP_CALLFUNC, B, NULL); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   506
postfix_expr(A) ::= postfix_expr(B) LPAREN argument_expr_list(C) RPAREN. { A = new_binary_expr(ctx, OP_CALLFUNC, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   507
//postfix_expr(A) ::= datatype(B) LPAREN argument_expr_list(C) RPAREN. { A = new_constructor_expr(ctx, B, C); } // HLSL constructor
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   508
postfix_expr(A) ::= postfix_expr(B) DOT IDENTIFIER(C). { A = new_binary_expr(ctx, OP_DEREF_STRUCT, B, new_identifier_expr(ctx, C.string)); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   509
postfix_expr(A) ::= postfix_expr(B) PLUSPLUS. { A = new_unary_expr(ctx, OP_POSTINCREMENT, B); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   510
postfix_expr(A) ::= postfix_expr(B) MINUSMINUS. { A = new_unary_expr(ctx, OP_POSTDECREMENT, B); }
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   511
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   512
%type argument_expr_list { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   513
argument_expr_list(A) ::= assignment_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   514
argument_expr_list(A) ::= argument_expr_list(B) COMMA assignment_expr(C). { A = new_binary_expr(ctx, OP_COMMA, B, C); }
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   515
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   516
%type unary_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   517
unary_expr(A) ::= postfix_expr(B).  { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   518
unary_expr(A) ::= PLUSPLUS unary_expr(B). { A = new_unary_expr(ctx, OP_PREINCREMENT, B); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   519
unary_expr(A) ::= MINUSMINUS unary_expr(B). { A = new_unary_expr(ctx, OP_PREDECREMENT, B); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   520
unary_expr(A) ::= PLUS cast_expr(B). { A = B; }  // unary "+x" is always a no-op, so throw it away here.
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   521
unary_expr(A) ::= MINUS cast_expr(B). { A = new_unary_expr(ctx, OP_NEGATE, B); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   522
unary_expr(A) ::= COMPLEMENT cast_expr(B). { A = new_unary_expr(ctx, OP_COMPLEMENT, B); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   523
unary_expr(A) ::= EXCLAMATION cast_expr(B). { A = new_unary_expr(ctx, OP_NOT, B); }
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   524
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   525
%type cast_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   526
cast_expr(A) ::= unary_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   527
//cast_expr(A) ::= LPAREN datatype(B) RPAREN cast_expr(C). { A = new_cast_expr(ctx, B, C); }
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   528
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   529
%type multiplicative_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   530
multiplicative_expr(A) ::= cast_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   531
multiplicative_expr(A) ::= multiplicative_expr(B) STAR cast_expr(C). { A = new_binary_expr(ctx, OP_MULTIPLY, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   532
multiplicative_expr(A) ::= multiplicative_expr(B) SLASH cast_expr(C). { A = new_binary_expr(ctx, OP_DIVIDE, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   533
multiplicative_expr(A) ::= multiplicative_expr(B) PERCENT cast_expr(C). { A = new_binary_expr(ctx, OP_MODULO, B, C); }
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   534
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   535
%type additive_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   536
additive_expr(A) ::= multiplicative_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   537
additive_expr(A) ::= additive_expr(B) PLUS multiplicative_expr(C). { A = new_binary_expr(ctx, OP_ADD, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   538
additive_expr(A) ::= additive_expr(B) MINUS multiplicative_expr(C). { A = new_binary_expr(ctx, OP_SUBTRACT, B, C); }
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   539
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   540
%type shift_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   541
shift_expr(A) ::= additive_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   542
shift_expr(A) ::= shift_expr(B) LSHIFT additive_expr(C). { A = new_binary_expr(ctx, OP_LSHIFT, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   543
shift_expr(A) ::= shift_expr(B) RSHIFT additive_expr(C). { A = new_binary_expr(ctx, OP_RSHIFT, B, C); }
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   544
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   545
%type relational_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   546
relational_expr(A) ::= shift_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   547
relational_expr(A) ::= relational_expr(B) LT shift_expr(C). { A = new_binary_expr(ctx, OP_LESSTHAN, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   548
relational_expr(A) ::= relational_expr(B) GT shift_expr(C). { A = new_binary_expr(ctx, OP_GREATERTHAN, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   549
relational_expr(A) ::= relational_expr(B) LEQ shift_expr(C). { A = new_binary_expr(ctx, OP_LESSTHANOREQUAL, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   550
relational_expr(A) ::= relational_expr(B) GEQ shift_expr(C). { A = new_binary_expr(ctx, OP_GREATERTHANOREQUAL, B, C); }
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   551
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   552
%type equality_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   553
equality_expr(A) ::= relational_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   554
equality_expr(A) ::= equality_expr(B) EQL relational_expr(C). { A = new_binary_expr(ctx, OP_EQUAL, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   555
equality_expr(A) ::= equality_expr(B) NEQ relational_expr(C). { A = new_binary_expr(ctx, OP_NOTEQUAL, B, C); }
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   556
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   557
%type and_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   558
and_expr(A) ::= equality_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   559
and_expr(A) ::= and_expr(B) AND equality_expr(C). { A = new_binary_expr(ctx, OP_BINARYAND, B, C); }
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   560
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   561
%type exclusive_or_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   562
exclusive_or_expr(A) ::= and_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   563
exclusive_or_expr(A) ::= exclusive_or_expr(B) XOR and_expr(C). { A = new_binary_expr(ctx, OP_BINARYXOR, B, C); }
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   564
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   565
%type inclusive_or_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   566
inclusive_or_expr(A) ::= exclusive_or_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   567
inclusive_or_expr(A) ::= inclusive_or_expr(B) OR exclusive_or_expr(C). { A = new_binary_expr(ctx, OP_BINARYOR, B, C); }
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   568
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   569
%type logical_and_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   570
logical_and_expr(A) ::= inclusive_or_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   571
logical_and_expr(A) ::= logical_and_expr(B) ANDAND inclusive_or_expr(C). { A = new_binary_expr(ctx, OP_LOGICALAND, B, C); }
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   572
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   573
%type logical_or_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   574
logical_or_expr(A) ::= logical_and_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   575
logical_or_expr(A) ::= logical_or_expr(B) OROR logical_and_expr(C). { A = new_binary_expr(ctx, OP_LOGICALOR, B, C); }
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   576
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   577
%type conditional_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   578
conditional_expr(A) ::= logical_or_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   579
conditional_expr(A) ::= logical_or_expr(B) QUESTION logical_or_expr(C) COLON conditional_expr(D). { A = new_ternary_expr(ctx, OP_CONDITIONAL, B, C, D); }
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   580
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   581
%type assignment_expr { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   582
assignment_expr(A) ::= conditional_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   583
assignment_expr(A) ::= unary_expr(B) ASSIGN assignment_expr(C). { A = new_binary_expr(ctx, OP_ASSIGN, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   584
assignment_expr(A) ::= unary_expr(B) MULASSIGN assignment_expr(C). { A = new_binary_expr(ctx, OP_MULASSIGN, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   585
assignment_expr(A) ::= unary_expr(B) DIVASSIGN assignment_expr(C). { A = new_binary_expr(ctx, OP_DIVASSIGN, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   586
assignment_expr(A) ::= unary_expr(B) MODASSIGN assignment_expr(C). { A = new_binary_expr(ctx, OP_MODASSIGN, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   587
assignment_expr(A) ::= unary_expr(B) ADDASSIGN assignment_expr(C). { A = new_binary_expr(ctx, OP_ADDASSIGN, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   588
assignment_expr(A) ::= unary_expr(B) SUBASSIGN assignment_expr(C). { A = new_binary_expr(ctx, OP_SUBASSIGN, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   589
assignment_expr(A) ::= unary_expr(B) LSHIFTASSIGN assignment_expr(C). { A = new_binary_expr(ctx, OP_LSHIFTASSIGN, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   590
assignment_expr(A) ::= unary_expr(B) RSHIFTASSIGN assignment_expr(C). { A = new_binary_expr(ctx, OP_RSHIFTASSIGN, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   591
assignment_expr(A) ::= unary_expr(B) ANDASSIGN assignment_expr(C). { A = new_binary_expr(ctx, OP_ANDASSIGN, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   592
assignment_expr(A) ::= unary_expr(B) XORASSIGN assignment_expr(C). { A = new_binary_expr(ctx, OP_XORASSIGN, B, C); }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   593
assignment_expr(A) ::= unary_expr(B) ORASSIGN assignment_expr(C). { A = new_binary_expr(ctx, OP_ORASSIGN, B, C); }
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   594
827
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   595
%type expression { Expression * }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   596
expression(A) ::= assignment_expr(B). { A = B; }
2f955ce29b7b Moved the calculator experiment work back into the compiler.
Ryan C. Gordon <icculus@icculus.org>
parents: 796
diff changeset
   597
expression(A) ::= expression(B) COMMA assignment_expr(C). { A = new_binary_expr(ctx, OP_COMMA, B, C); }
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   598
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   599
// end of mojoshader_parser_hlsl.lemon ...
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   600