mojoshader_parser_hlsl.lemon
author Ryan C. Gordon <icculus@icculus.org>
Tue, 25 Aug 2009 23:44:04 -0400
changeset 789 10a36d0c418c
parent 788 9f4d32456f78
child 790 0cf8abbbc9fa
permissions -rw-r--r--
Variable declarations can have empty array bounds, like "float x[] = {a,b,c};"
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 {
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    42
    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
    43
}
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    44
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    45
%stack_overflow {
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    46
    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
    47
}
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    49
// operator precedence (matches C spec)...
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    51
%left COMMA.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    52
%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
    53
       RSHIFTASSIGN ANDASSIGN ORASSIGN XORASSIGN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    54
%right QUESTION.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    55
%left OROR.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    56
%left ANDAND.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    57
%left OR.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    58
%left XOR.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    59
%left AND.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    60
%left EQL NEQ.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    61
%left LT LEQ GT GEQ.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    62
%left LSHIFT RSHIFT.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    63
%left PLUS MINUS.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    64
%left STAR SLASH PERCENT.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    65
%right TYPECAST EXCLAMATION COMPLEMENT MINUSMINUS PLUSPLUS.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    66
%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
    67
704
292ea2611014 Resolved "dangling else" problem in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 703
diff changeset
    68
// 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
    69
//  usual "dangling else ambiguity" ...
292ea2611014 Resolved "dangling else" problem in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 703
diff changeset
    70
%right ELSE.
292ea2611014 Resolved "dangling else" problem in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 703
diff changeset
    71
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    73
// The rules...
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
    74
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    75
shader ::= compilation_units.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    76
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    77
compilation_units ::= compilation_unit.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    78
compilation_units ::= compilation_units compilation_unit.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    79
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    80
compilation_unit ::= function_declaration.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    81
compilation_unit ::= function_definition.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    82
compilation_unit ::= global_variable.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    83
compilation_unit ::= typedef_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    84
compilation_unit ::= struct_statement.
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
function_declaration ::= function_signature SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    87
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    88
function_definition ::= function_signature statement_block.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    89
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    90
function_signature ::= function_storageclass function_details semantic.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    91
function_signature ::= function_storageclass function_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    92
function_signature ::= function_details semantic.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    93
function_signature ::= function_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    94
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    95
function_details ::= datatype identifier LPAREN function_arguments RPAREN.
779
160b46d02cc0 Fixed parsing of HLSL functions that return void.
Ryan C. Gordon <icculus@icculus.org>
parents: 778
diff changeset
    96
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
    97
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
    98
// !!! 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
    99
// !!! 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
   100
// !!! FIXME:  what tokens are valid here.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   101
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   102
// !!! 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
   103
// !!! FIXME:  specify both.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   104
//function_storageclass ::= target.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   105
function_storageclass ::= INLINE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   106
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   107
function_arguments ::= VOID.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   108
function_arguments ::= function_argument_list.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   109
function_arguments ::= .
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   110
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   111
function_argument_list ::= function_argument.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   112
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
   113
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   114
function_argument ::= input_modifier datatype identifier semantic interpolation_mod initializer.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   115
function_argument ::= input_modifier datatype identifier semantic interpolation_mod.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   116
function_argument ::= input_modifier datatype identifier semantic initializer.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   117
function_argument ::= input_modifier datatype identifier semantic.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   118
function_argument ::= input_modifier datatype identifier interpolation_mod initializer.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   119
function_argument ::= input_modifier datatype identifier interpolation_mod.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   120
function_argument ::= input_modifier datatype identifier initializer.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   121
function_argument ::= input_modifier datatype identifier.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   122
function_argument ::= datatype identifier semantic interpolation_mod initializer.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   123
function_argument ::= datatype identifier semantic interpolation_mod.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   124
function_argument ::= datatype identifier semantic initializer.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   125
function_argument ::= datatype identifier semantic.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   126
function_argument ::= datatype identifier interpolation_mod initializer.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   127
function_argument ::= datatype identifier interpolation_mod.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   128
function_argument ::= datatype identifier initializer.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   129
function_argument ::= datatype identifier.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   130
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   131
input_modifier ::= IN.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   132
input_modifier ::= INOUT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   133
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
   134
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
   135
input_modifier ::= OUT IN.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   136
input_modifier ::= UNIFORM.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   137
730
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 726
diff changeset
   138
semantic ::= COLON SEMANTIC.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   139
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   140
// DX10 only?
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   141
interpolation_mod ::= LINEAR.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   142
interpolation_mod ::= CENTROID.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   143
interpolation_mod ::= NOINTERPOLATION.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   144
interpolation_mod ::= NOPERSPECTIVE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   145
interpolation_mod ::= SAMPLE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   146
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   147
global_variable ::= variable_declaration.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   148
725
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   149
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
   150
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
   151
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
   152
725
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   153
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
   154
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
   155
5e3c35b63abd Reworked variable declaration syntax in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   156
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
   157
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
   158
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
   159
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
   160
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
   161
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
   162
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
   163
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
   164
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
   165
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
   166
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
   167
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
   168
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
   169
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
   170
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
   171
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
   172
724
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   173
// !!! 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
   174
778
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 777
diff changeset
   175
struct_declaration ::= STRUCT identifier(A) LBRACE struct_member_list RBRACE.
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 777
diff changeset
   176
{
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 777
diff changeset
   177
    add_usertype(ctx, A.token, A.tokenlen);
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 777
diff changeset
   178
}
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   179
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   180
struct_member_list ::= struct_member.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   181
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
   182
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   183
struct_member ::= interpolation_mod struct_member_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   184
struct_member ::= struct_member_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   185
726
9f58e2b0ed8a Fixed struct declaration in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 725
diff changeset
   186
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
   187
777
5ab8bb0ac2af Fixed HLSL parsing of structs with array fields.
Ryan C. Gordon <icculus@icculus.org>
parents: 730
diff changeset
   188
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
   189
struct_member_item_list ::= scalar_or_array semantic.
726
9f58e2b0ed8a Fixed struct declaration in the HLSL parser grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 725
diff changeset
   190
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
   191
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   192
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
   193
typedef_statement ::= TYPEDEF datatype scalar_or_array.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   194
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   195
variable_lowlevel ::= packoffset register.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   196
variable_lowlevel ::= packoffset.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   197
variable_lowlevel ::= register.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   198
789
10a36d0c418c Variable declarations can have empty array bounds, like "float x[] = {a,b,c};"
Ryan C. Gordon <icculus@icculus.org>
parents: 788
diff changeset
   199
scalar_or_array ::= identifier LBRACKET RBRACKET.
782
778852cf7aaf HLSL array declarations can be expressions, like "float4 x[(1 + 1) / 2];" ...
Ryan C. Gordon <icculus@icculus.org>
parents: 781
diff changeset
   200
scalar_or_array ::= identifier LBRACKET expression RBRACKET.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   201
scalar_or_array ::= identifier.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   202
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   203
packoffset ::= PACKOFFSET LPAREN identifier identifier RPAREN.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   204
packoffset ::= PACKOFFSET LPAREN identifier RPAREN.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   205
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   206
register ::= COLON REGISTER LPAREN identifier RPAREN.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   207
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   208
annotations ::= LT annotation_list GT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   209
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   210
annotation_list ::= annotation.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   211
annotation_list ::= annotation_list annotation.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   212
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   213
annotation ::= datatype_scalar initializer SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   214
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   215
variable_attribute_list ::= variable_attribute.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   216
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
   217
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   218
variable_attribute ::= EXTERN.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   219
variable_attribute ::= NOINTERPOLATION.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   220
variable_attribute ::= SHARED.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   221
variable_attribute ::= STATIC.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   222
variable_attribute ::= UNIFORM.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   223
variable_attribute ::= VOLATILE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   224
variable_attribute ::= CONST.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   225
variable_attribute ::= ROWMAJOR.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   226
variable_attribute ::= COLUMNMAJOR.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   227
788
9f4d32456f78 Allow vector initializers, like "float4 x = {a,b,c,d};"
Ryan C. Gordon <icculus@icculus.org>
parents: 787
diff changeset
   228
initializer_block_list ::= expression.
9f4d32456f78 Allow vector initializers, like "float4 x = {a,b,c,d};"
Ryan C. Gordon <icculus@icculus.org>
parents: 787
diff changeset
   229
initializer_block_list ::= initializer_block_list COMMA expression.
9f4d32456f78 Allow vector initializers, like "float4 x = {a,b,c,d};"
Ryan C. Gordon <icculus@icculus.org>
parents: 787
diff changeset
   230
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
   231
9f4d32456f78 Allow vector initializers, like "float4 x = {a,b,c,d};"
Ryan C. Gordon <icculus@icculus.org>
parents: 787
diff changeset
   232
initializer ::= ASSIGN initializer_block.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   233
initializer ::= ASSIGN expression.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   234
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   235
intrinsic_datatype ::= datatype_vector.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   236
intrinsic_datatype ::= datatype_matrix.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   237
intrinsic_datatype ::= datatype_scalar.
724
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   238
intrinsic_datatype ::= datatype_sampler.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   239
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   240
datatype ::= intrinsic_datatype.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   241
datatype ::= USERTYPE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   242
724
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   243
datatype_sampler ::= SAMPLER.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   244
datatype_sampler ::= SAMPLER1D.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   245
datatype_sampler ::= SAMPLER2D.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   246
datatype_sampler ::= SAMPLER3D.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   247
datatype_sampler ::= SAMPLERCUBE.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   248
datatype_sampler ::= SAMPLER_STATE.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   249
datatype_sampler ::= SAMPLERSTATE.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   250
datatype_sampler ::= SAMPLERCOMPARISONSTATE.
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 722
diff changeset
   251
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   252
datatype_scalar ::= BOOL.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   253
datatype_scalar ::= INT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   254
datatype_scalar ::= UINT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   255
datatype_scalar ::= HALF.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   256
datatype_scalar ::= FLOAT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   257
datatype_scalar ::= DOUBLE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   258
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
   259
datatype_scalar ::= SNORM FLOAT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   260
datatype_scalar ::= UNORM FLOAT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   261
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
   262
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   263
// !!! 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
   264
// !!! FIXME:  before parsing begins, like:
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   265
// !!! FIXME: typedef matrix <bool,4,3> bool4x3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   266
// !!! 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
   267
// !!! FIXME:  them at startup?
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   268
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
   269
datatype_vector ::= BOOL1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   270
datatype_vector ::= BOOL2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   271
datatype_vector ::= BOOL3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   272
datatype_vector ::= BOOL4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   273
datatype_vector ::= INT1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   274
datatype_vector ::= INT2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   275
datatype_vector ::= INT3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   276
datatype_vector ::= INT4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   277
datatype_vector ::= UINT1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   278
datatype_vector ::= UINT2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   279
datatype_vector ::= UINT3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   280
datatype_vector ::= UINT4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   281
datatype_vector ::= HALF1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   282
datatype_vector ::= HALF2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   283
datatype_vector ::= HALF3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   284
datatype_vector ::= HALF4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   285
datatype_vector ::= FLOAT1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   286
datatype_vector ::= FLOAT2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   287
datatype_vector ::= FLOAT3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   288
datatype_vector ::= FLOAT4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   289
datatype_vector ::= DOUBLE1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   290
datatype_vector ::= DOUBLE2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   291
datatype_vector ::= DOUBLE3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   292
datatype_vector ::= DOUBLE4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   293
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   294
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
   295
datatype_matrix ::= BOOL1X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   296
datatype_matrix ::= BOOL1X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   297
datatype_matrix ::= BOOL1X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   298
datatype_matrix ::= BOOL1X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   299
datatype_matrix ::= BOOL2X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   300
datatype_matrix ::= BOOL2X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   301
datatype_matrix ::= BOOL2X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   302
datatype_matrix ::= BOOL2X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   303
datatype_matrix ::= BOOL3X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   304
datatype_matrix ::= BOOL3X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   305
datatype_matrix ::= BOOL3X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   306
datatype_matrix ::= BOOL3X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   307
datatype_matrix ::= BOOL4X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   308
datatype_matrix ::= BOOL4X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   309
datatype_matrix ::= BOOL4X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   310
datatype_matrix ::= BOOL4X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   311
datatype_matrix ::= INT1X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   312
datatype_matrix ::= INT1X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   313
datatype_matrix ::= INT1X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   314
datatype_matrix ::= INT1X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   315
datatype_matrix ::= INT2X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   316
datatype_matrix ::= INT2X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   317
datatype_matrix ::= INT2X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   318
datatype_matrix ::= INT2X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   319
datatype_matrix ::= INT3X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   320
datatype_matrix ::= INT3X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   321
datatype_matrix ::= INT3X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   322
datatype_matrix ::= INT3X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   323
datatype_matrix ::= INT4X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   324
datatype_matrix ::= INT4X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   325
datatype_matrix ::= INT4X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   326
datatype_matrix ::= INT4X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   327
datatype_matrix ::= UINT1X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   328
datatype_matrix ::= UINT1X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   329
datatype_matrix ::= UINT1X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   330
datatype_matrix ::= UINT1X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   331
datatype_matrix ::= UINT2X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   332
datatype_matrix ::= UINT2X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   333
datatype_matrix ::= UINT2X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   334
datatype_matrix ::= UINT2X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   335
datatype_matrix ::= UINT3X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   336
datatype_matrix ::= UINT3X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   337
datatype_matrix ::= UINT3X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   338
datatype_matrix ::= UINT3X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   339
datatype_matrix ::= UINT4X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   340
datatype_matrix ::= UINT4X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   341
datatype_matrix ::= UINT4X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   342
datatype_matrix ::= UINT4X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   343
datatype_matrix ::= HALF1X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   344
datatype_matrix ::= HALF1X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   345
datatype_matrix ::= HALF1X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   346
datatype_matrix ::= HALF1X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   347
datatype_matrix ::= HALF2X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   348
datatype_matrix ::= HALF2X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   349
datatype_matrix ::= HALF2X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   350
datatype_matrix ::= HALF2X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   351
datatype_matrix ::= HALF3X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   352
datatype_matrix ::= HALF3X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   353
datatype_matrix ::= HALF3X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   354
datatype_matrix ::= HALF3X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   355
datatype_matrix ::= HALF4X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   356
datatype_matrix ::= HALF4X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   357
datatype_matrix ::= HALF4X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   358
datatype_matrix ::= HALF4X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   359
datatype_matrix ::= FLOAT1X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   360
datatype_matrix ::= FLOAT1X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   361
datatype_matrix ::= FLOAT1X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   362
datatype_matrix ::= FLOAT1X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   363
datatype_matrix ::= FLOAT2X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   364
datatype_matrix ::= FLOAT2X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   365
datatype_matrix ::= FLOAT2X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   366
datatype_matrix ::= FLOAT2X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   367
datatype_matrix ::= FLOAT3X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   368
datatype_matrix ::= FLOAT3X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   369
datatype_matrix ::= FLOAT3X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   370
datatype_matrix ::= FLOAT3X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   371
datatype_matrix ::= FLOAT4X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   372
datatype_matrix ::= FLOAT4X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   373
datatype_matrix ::= FLOAT4X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   374
datatype_matrix ::= FLOAT4X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   375
datatype_matrix ::= DOUBLE1X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   376
datatype_matrix ::= DOUBLE1X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   377
datatype_matrix ::= DOUBLE1X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   378
datatype_matrix ::= DOUBLE1X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   379
datatype_matrix ::= DOUBLE2X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   380
datatype_matrix ::= DOUBLE2X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   381
datatype_matrix ::= DOUBLE2X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   382
datatype_matrix ::= DOUBLE2X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   383
datatype_matrix ::= DOUBLE3X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   384
datatype_matrix ::= DOUBLE3X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   385
datatype_matrix ::= DOUBLE3X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   386
datatype_matrix ::= DOUBLE3X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   387
datatype_matrix ::= DOUBLE4X1.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   388
datatype_matrix ::= DOUBLE4X2.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   389
datatype_matrix ::= DOUBLE4X3.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   390
datatype_matrix ::= DOUBLE4X4.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   391
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   392
statement_block ::= LBRACE RBRACE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   393
statement_block ::= LBRACE statement_list RBRACE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   394
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   395
statement_list ::= statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   396
statement_list ::= statement_list statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   397
787
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   398
// 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
   399
statement_attribute_details ::= ISOLATE.
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   400
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
   401
statement_attribute_details ::= NOEXPRESSIONOPTIMIZATIONS.
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   402
statement_attribute_details ::= REMOVEUNUSEDINPUTS.
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   403
statement_attribute_details ::= UNUSED.
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   404
statement_attribute_details ::= XPS.
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   405
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   406
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
   407
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   408
statement ::= return_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   409
statement ::= BREAK SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   410
statement ::= CONTINUE SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   411
statement ::= DISCARD SEMICOLON.
787
04d5c34d8b40 Added statement block attributes to the HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 785
diff changeset
   412
statement ::= statement_attribute statement_block.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   413
statement ::= statement_block.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   414
statement ::= for_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   415
statement ::= do_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   416
statement ::= while_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   417
statement ::= if_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   418
statement ::= switch_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   419
statement ::= variable_declaration.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   420
statement ::= typedef_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   421
statement ::= expression_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   422
statement ::= struct_statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   423
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   424
struct_statement ::= struct_declaration SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   425
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   426
expression_statement ::= SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   427
expression_statement ::= expression SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   428
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   429
return_statement ::= RETURN SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   430
return_statement ::= RETURN expression SEMICOLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   431
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   432
while_statement ::= loop_attribute while_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   433
while_statement ::= while_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   434
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   435
while_details ::= WHILE LPAREN expression RPAREN statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   436
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   437
for_statement ::= loop_attribute for_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   438
for_statement ::= for_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   439
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   440
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
   441
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
   442
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
   443
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
   444
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
   445
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
   446
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
   447
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
   448
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
   449
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
   450
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
   451
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
   452
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   453
loop_attribute ::= UNROLL LPAREN INT_CONSTANT RPAREN.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   454
loop_attribute ::= UNROLL.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   455
loop_attribute ::= LOOP.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   456
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   457
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
   458
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   459
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
   460
if_statement ::= IF LPAREN expression RPAREN statement.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   461
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
   462
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
   463
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   464
if_attribute ::= BRANCH.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   465
if_attribute ::= FLATTEN.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   466
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   467
switch_statement ::= switch_attribute switch_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   468
switch_statement ::= switch_details.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   469
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   470
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
   471
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   472
switch_attribute ::= FLATTEN.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   473
switch_attribute ::= BRANCH.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   474
switch_attribute ::= FORCECASE.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   475
switch_attribute ::= CALL.
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_case_list ::= switch_case.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   478
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
   479
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   480
// 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
   481
//  ...so "case 3+2:" works.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   482
switch_case ::= CASE expression COLON statement_list.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   483
switch_case ::= CASE expression COLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   484
switch_case ::= DEFAULT COLON statement_list.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   485
switch_case ::= DEFAULT COLON.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   486
778
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 777
diff changeset
   487
%type identifier { TokenData }
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 777
diff changeset
   488
identifier(A) ::= IDENTIFIER(B).
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 777
diff changeset
   489
{
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 777
diff changeset
   490
    A.token = B.token;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 777
diff changeset
   491
    A.tokenlen = B.tokenlen;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 777
diff changeset
   492
}
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   493
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   494
// the expression stuff is based on Jeff Lee's ANSI C grammar.
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   495
primary_expr ::= identifier.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   496
primary_expr ::= INT_CONSTANT.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   497
primary_expr ::= FLOAT_CONSTANT.
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   498
primary_expr ::= STRING_LITERAL.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   499
primary_expr ::= LPAREN expression RPAREN.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   500
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   501
postfix_expr ::= primary_expr.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   502
postfix_expr ::= postfix_expr LBRACKET expression RBRACKET.
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   503
postfix_expr ::= postfix_expr LPAREN RPAREN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   504
postfix_expr ::= postfix_expr LPAREN argument_expr_list RPAREN.
722
d483a61ef502 Added HLSL constructor to the grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   505
postfix_expr ::= datatype LPAREN argument_expr_list RPAREN.  // HLSL constructor
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   506
postfix_expr ::= postfix_expr DOT identifier.
707
85b648e14089 Fixed lemon grammar to use correct tokens.
Ryan C. Gordon <icculus@icculus.org>
parents: 704
diff changeset
   507
postfix_expr ::= postfix_expr PLUSPLUS.
85b648e14089 Fixed lemon grammar to use correct tokens.
Ryan C. Gordon <icculus@icculus.org>
parents: 704
diff changeset
   508
postfix_expr ::= postfix_expr MINUSMINUS.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   509
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   510
argument_expr_list ::= assignment_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   511
argument_expr_list ::= argument_expr_list COMMA assignment_expr.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   512
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   513
unary_expr ::= postfix_expr.
707
85b648e14089 Fixed lemon grammar to use correct tokens.
Ryan C. Gordon <icculus@icculus.org>
parents: 704
diff changeset
   514
unary_expr ::= PLUSPLUS unary_expr.
85b648e14089 Fixed lemon grammar to use correct tokens.
Ryan C. Gordon <icculus@icculus.org>
parents: 704
diff changeset
   515
unary_expr ::= MINUSMINUS unary_expr.
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   516
unary_expr ::= unary_operator cast_expr.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   517
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   518
unary_operator ::= PLUS.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   519
unary_operator ::= MINUS.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   520
unary_operator ::= COMPLEMENT.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   521
unary_operator ::= EXCLAMATION.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   522
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   523
cast_expr ::= unary_expr.
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   524
cast_expr ::= LPAREN datatype RPAREN cast_expr.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   525
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   526
multiplicative_expr ::= cast_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   527
multiplicative_expr ::= multiplicative_expr STAR cast_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   528
multiplicative_expr ::= multiplicative_expr SLASH cast_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   529
multiplicative_expr ::= multiplicative_expr PERCENT cast_expr.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   530
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   531
additive_expr ::= multiplicative_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   532
additive_expr ::= additive_expr PLUS multiplicative_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   533
additive_expr ::= additive_expr MINUS multiplicative_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   534
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   535
shift_expr ::= additive_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   536
shift_expr ::= shift_expr LSHIFT additive_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   537
shift_expr ::= shift_expr RSHIFT additive_expr.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   538
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   539
relational_expr ::= shift_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   540
relational_expr ::= relational_expr LT shift_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   541
relational_expr ::= relational_expr GT shift_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   542
relational_expr ::= relational_expr LEQ shift_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   543
relational_expr ::= relational_expr GEQ shift_expr.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   544
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   545
equality_expr ::= relational_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   546
equality_expr ::= equality_expr EQL relational_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   547
equality_expr ::= equality_expr NEQ relational_expr.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   548
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   549
and_expr ::= equality_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   550
and_expr ::= and_expr AND equality_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   551
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   552
exclusive_or_expr ::= and_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   553
exclusive_or_expr ::= exclusive_or_expr XOR and_expr.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   554
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   555
inclusive_or_expr ::= exclusive_or_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   556
inclusive_or_expr ::= inclusive_or_expr OR exclusive_or_expr.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   557
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   558
logical_and_expr ::= inclusive_or_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   559
logical_and_expr ::= logical_and_expr ANDAND inclusive_or_expr.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   560
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   561
logical_or_expr ::= logical_and_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   562
logical_or_expr ::= logical_or_expr OROR logical_and_expr.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   563
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   564
conditional_expr ::= logical_or_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   565
conditional_expr ::= logical_or_expr QUESTION logical_or_expr COLON conditional_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   566
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   567
assignment_expr ::= conditional_expr.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   568
assignment_expr ::= unary_expr assignment_operator assignment_expr.
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   569
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   570
assignment_operator ::= ASSIGN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   571
assignment_operator ::= MULASSIGN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   572
assignment_operator ::= DIVASSIGN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   573
assignment_operator ::= MODASSIGN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   574
assignment_operator ::= ADDASSIGN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   575
assignment_operator ::= SUBASSIGN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   576
assignment_operator ::= LSHIFTASSIGN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   577
assignment_operator ::= RSHIFTASSIGN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   578
assignment_operator ::= ANDASSIGN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   579
assignment_operator ::= XORASSIGN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   580
assignment_operator ::= ORASSIGN.
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   581
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   582
expression ::= assignment_expr.
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 709
diff changeset
   583
expression ::= expression COMMA assignment_expr.
703
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   584
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   585
// end of mojoshader_parser_hlsl.lemon ...
8bc7b33377e7 Converted original YACC grammar to Lemon grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 702
diff changeset
   586