| 1 | %start WholeEnchilada |
|---|
| 2 | %name-prefix="ts10_" |
|---|
| 3 | %{ |
|---|
| 4 | void yyerror(char* s); |
|---|
| 5 | int yylex ( void ); |
|---|
| 6 | |
|---|
| 7 | #ifdef _WIN32 |
|---|
| 8 | # include <windows.h> |
|---|
| 9 | #endif |
|---|
| 10 | #include <stdio.h> |
|---|
| 11 | #include <stdlib.h> |
|---|
| 12 | #include "ts1.0_inst.h" |
|---|
| 13 | #include "ts1.0_inst_list.h" |
|---|
| 14 | #include "nvparse_errors.h" |
|---|
| 15 | #include "nvparse_externs.h" |
|---|
| 16 | |
|---|
| 17 | %} |
|---|
| 18 | %union { |
|---|
| 19 | float fval; |
|---|
| 20 | InstPtr inst; |
|---|
| 21 | InstListPtr instList; |
|---|
| 22 | MappedVariablePtr variable; |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | %token <fval> floatValue gequal less texVariable expandString |
|---|
| 26 | %token <fval> openParen closeParen semicolon comma |
|---|
| 27 | %token <fval> nop |
|---|
| 28 | %token <fval> texture_1d |
|---|
| 29 | %token <fval> texture_2d |
|---|
| 30 | %token <fval> texture_rectangle |
|---|
| 31 | %token <fval> texture_3d |
|---|
| 32 | %token <fval> texture_cube_map |
|---|
| 33 | %token <fval> cull_fragment |
|---|
| 34 | %token <fval> pass_through |
|---|
| 35 | %token <fval> offset_2d_scale |
|---|
| 36 | %token <fval> offset_2d |
|---|
| 37 | %token <fval> offset_rectangle_scale |
|---|
| 38 | %token <fval> offset_rectangle |
|---|
| 39 | %token <fval> dependent_ar |
|---|
| 40 | %token <fval> dependent_gb |
|---|
| 41 | %token <fval> dot_product_2d_1of2 |
|---|
| 42 | %token <fval> dot_product_2d_2of2 |
|---|
| 43 | %token <fval> dot_product_rectangle_1of2 |
|---|
| 44 | %token <fval> dot_product_rectangle_2of2 |
|---|
| 45 | %token <fval> dot_product_depth_replace_1of2 |
|---|
| 46 | %token <fval> dot_product_depth_replace_2of2 |
|---|
| 47 | %token <fval> dot_product_3d_1of3 |
|---|
| 48 | %token <fval> dot_product_3d_2of3 |
|---|
| 49 | %token <fval> dot_product_3d_3of3 |
|---|
| 50 | %token <fval> dot_product_cube_map_1of3 |
|---|
| 51 | %token <fval> dot_product_cube_map_2of3 |
|---|
| 52 | %token <fval> dot_product_cube_map_3of3 |
|---|
| 53 | %token <fval> dot_product_reflect_cube_map_eye_from_qs_1of3 |
|---|
| 54 | %token <fval> dot_product_reflect_cube_map_eye_from_qs_2of3 |
|---|
| 55 | %token <fval> dot_product_reflect_cube_map_eye_from_qs_3of3 |
|---|
| 56 | %token <fval> dot_product_reflect_cube_map_const_eye_1of3 |
|---|
| 57 | %token <fval> dot_product_reflect_cube_map_const_eye_2of3 |
|---|
| 58 | %token <fval> dot_product_reflect_cube_map_const_eye_3of3 |
|---|
| 59 | %token <fval> dot_product_cube_map_and_reflect_cube_map_eye_from_qs_1of3 |
|---|
| 60 | %token <fval> dot_product_cube_map_and_reflect_cube_map_eye_from_qs_2of3 |
|---|
| 61 | %token <fval> dot_product_cube_map_and_reflect_cube_map_eye_from_qs_3of3 |
|---|
| 62 | %token <fval> dot_product_cube_map_and_reflect_cube_map_const_eye_1of3 |
|---|
| 63 | %token <fval> dot_product_cube_map_and_reflect_cube_map_const_eye_2of3 |
|---|
| 64 | %token <fval> dot_product_cube_map_and_reflect_cube_map_const_eye_3of3 |
|---|
| 65 | |
|---|
| 66 | %type <instList> WholeEnchilada InstListDesc |
|---|
| 67 | %type <inst> InstDesc |
|---|
| 68 | %type <variable> MappedVariableDesc |
|---|
| 69 | %type <fval> CondDesc |
|---|
| 70 | |
|---|
| 71 | %% |
|---|
| 72 | |
|---|
| 73 | WholeEnchilada: InstListDesc |
|---|
| 74 | { |
|---|
| 75 | $1->Validate(); |
|---|
| 76 | $1->Invoke(); |
|---|
| 77 | delete $1; |
|---|
| 78 | } |
|---|
| 79 | ; |
|---|
| 80 | |
|---|
| 81 | InstListDesc: InstListDesc InstDesc semicolon |
|---|
| 82 | { |
|---|
| 83 | *($1) += $2; |
|---|
| 84 | delete $2; |
|---|
| 85 | $$ = $1; |
|---|
| 86 | } |
|---|
| 87 | | InstDesc semicolon |
|---|
| 88 | { |
|---|
| 89 | InstListPtr instList = new InstList; |
|---|
| 90 | *instList += $1; |
|---|
| 91 | delete $1; |
|---|
| 92 | $$ = instList; |
|---|
| 93 | } |
|---|
| 94 | ; |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | MappedVariableDesc: expandString openParen texVariable closeParen |
|---|
| 98 | { |
|---|
| 99 | $$ = new MappedVariable; |
|---|
| 100 | $$->var = $3; |
|---|
| 101 | $$->expand = true; |
|---|
| 102 | } |
|---|
| 103 | | texVariable |
|---|
| 104 | { |
|---|
| 105 | $$ = new MappedVariable; |
|---|
| 106 | $$->var = $1; |
|---|
| 107 | $$->expand = false; |
|---|
| 108 | } |
|---|
| 109 | ; |
|---|
| 110 | |
|---|
| 111 | InstDesc : nop openParen closeParen |
|---|
| 112 | { |
|---|
| 113 | $$ = new Inst(TSP_NOP); |
|---|
| 114 | } |
|---|
| 115 | | texture_1d openParen closeParen |
|---|
| 116 | { |
|---|
| 117 | $$ = new Inst(TSP_TEXTURE_1D); |
|---|
| 118 | } |
|---|
| 119 | | texture_2d openParen closeParen |
|---|
| 120 | { |
|---|
| 121 | $$ = new Inst(TSP_TEXTURE_2D); |
|---|
| 122 | } |
|---|
| 123 | | texture_rectangle openParen closeParen |
|---|
| 124 | { |
|---|
| 125 | $$ = new Inst(TSP_TEXTURE_RECTANGLE); |
|---|
| 126 | } |
|---|
| 127 | | texture_3d openParen closeParen |
|---|
| 128 | { |
|---|
| 129 | $$ = new Inst(TSP_TEXTURE_3D); |
|---|
| 130 | } |
|---|
| 131 | | texture_cube_map openParen closeParen |
|---|
| 132 | { |
|---|
| 133 | $$ = new Inst(TSP_TEXTURE_CUBE_MAP); |
|---|
| 134 | } |
|---|
| 135 | | cull_fragment openParen CondDesc comma CondDesc comma CondDesc comma CondDesc closeParen |
|---|
| 136 | { |
|---|
| 137 | $$ = new Inst(TSP_CULL_FRAGMENT, $3, $5, $7, $9); |
|---|
| 138 | } |
|---|
| 139 | | pass_through openParen closeParen |
|---|
| 140 | { |
|---|
| 141 | $$ = new Inst(TSP_PASS_THROUGH); |
|---|
| 142 | } |
|---|
| 143 | | offset_2d_scale openParen texVariable comma floatValue comma floatValue comma floatValue comma floatValue comma floatValue comma floatValue closeParen |
|---|
| 144 | { |
|---|
| 145 | $$ = new Inst(TSP_OFFSET_2D_SCALE, $3, $5, $7, $9, $11, $13, $15); |
|---|
| 146 | } |
|---|
| 147 | | offset_2d openParen texVariable comma floatValue comma floatValue comma floatValue comma floatValue closeParen |
|---|
| 148 | { |
|---|
| 149 | $$ = new Inst(TSP_OFFSET_2D, $3, $5, $7, $9, $11); |
|---|
| 150 | } |
|---|
| 151 | | offset_rectangle_scale openParen texVariable comma floatValue comma floatValue comma floatValue comma floatValue comma floatValue comma floatValue closeParen |
|---|
| 152 | { |
|---|
| 153 | $$ = new Inst(TSP_OFFSET_RECTANGLE_SCALE, $3, $5, $7, $9, $11, $13, $15); |
|---|
| 154 | } |
|---|
| 155 | | offset_rectangle openParen texVariable comma floatValue comma floatValue comma floatValue comma floatValue closeParen |
|---|
| 156 | { |
|---|
| 157 | $$ = new Inst(TSP_OFFSET_RECTANGLE, $3, $5, $7, $9, $11); |
|---|
| 158 | } |
|---|
| 159 | | dependent_ar openParen texVariable closeParen |
|---|
| 160 | { |
|---|
| 161 | $$ = new Inst(TSP_DEPENDENT_AR, $3); |
|---|
| 162 | } |
|---|
| 163 | | dependent_gb openParen texVariable closeParen |
|---|
| 164 | { |
|---|
| 165 | $$ = new Inst(TSP_DEPENDENT_GB, $3); |
|---|
| 166 | } |
|---|
| 167 | | dot_product_2d_1of2 openParen MappedVariableDesc closeParen |
|---|
| 168 | { |
|---|
| 169 | $$ = new Inst(TSP_DOT_PRODUCT_2D_1_OF_2, $3); |
|---|
| 170 | delete $3; |
|---|
| 171 | } |
|---|
| 172 | | dot_product_2d_2of2 openParen MappedVariableDesc closeParen |
|---|
| 173 | { |
|---|
| 174 | $$ = new Inst(TSP_DOT_PRODUCT_2D_2_OF_2, $3); |
|---|
| 175 | delete $3; |
|---|
| 176 | } |
|---|
| 177 | | dot_product_rectangle_1of2 openParen MappedVariableDesc closeParen |
|---|
| 178 | { |
|---|
| 179 | $$ = new Inst(TSP_DOT_PRODUCT_RECTANGLE_1_OF_2, $3); |
|---|
| 180 | delete $3; |
|---|
| 181 | } |
|---|
| 182 | | dot_product_rectangle_2of2 openParen MappedVariableDesc closeParen |
|---|
| 183 | { |
|---|
| 184 | $$ = new Inst(TSP_DOT_PRODUCT_RECTANGLE_2_OF_2, $3); |
|---|
| 185 | delete $3; |
|---|
| 186 | } |
|---|
| 187 | | dot_product_depth_replace_1of2 openParen MappedVariableDesc closeParen |
|---|
| 188 | { |
|---|
| 189 | $$ = new Inst(TSP_DOT_PRODUCT_DEPTH_REPLACE_1_OF_2, $3); |
|---|
| 190 | delete $3; |
|---|
| 191 | } |
|---|
| 192 | | dot_product_depth_replace_2of2 openParen MappedVariableDesc closeParen |
|---|
| 193 | { |
|---|
| 194 | $$ = new Inst(TSP_DOT_PRODUCT_DEPTH_REPLACE_2_OF_2, $3); |
|---|
| 195 | delete $3; |
|---|
| 196 | } |
|---|
| 197 | | dot_product_3d_1of3 openParen MappedVariableDesc closeParen |
|---|
| 198 | { |
|---|
| 199 | $$ = new Inst(TSP_DOT_PRODUCT_3D_1_OF_3, $3); |
|---|
| 200 | delete $3; |
|---|
| 201 | } |
|---|
| 202 | | dot_product_3d_2of3 openParen MappedVariableDesc closeParen |
|---|
| 203 | { |
|---|
| 204 | $$ = new Inst(TSP_DOT_PRODUCT_3D_2_OF_3, $3); |
|---|
| 205 | delete $3; |
|---|
| 206 | } |
|---|
| 207 | | dot_product_3d_3of3 openParen MappedVariableDesc closeParen |
|---|
| 208 | { |
|---|
| 209 | $$ = new Inst(TSP_DOT_PRODUCT_3D_3_OF_3, $3); |
|---|
| 210 | delete $3; |
|---|
| 211 | } |
|---|
| 212 | | dot_product_cube_map_1of3 openParen MappedVariableDesc closeParen |
|---|
| 213 | { |
|---|
| 214 | $$ = new Inst(TSP_DOT_PRODUCT_CUBE_MAP_1_OF_3, $3); |
|---|
| 215 | delete $3; |
|---|
| 216 | } |
|---|
| 217 | | dot_product_cube_map_2of3 openParen MappedVariableDesc closeParen |
|---|
| 218 | { |
|---|
| 219 | $$ = new Inst(TSP_DOT_PRODUCT_CUBE_MAP_2_OF_3, $3); |
|---|
| 220 | delete $3; |
|---|
| 221 | } |
|---|
| 222 | | dot_product_cube_map_3of3 openParen MappedVariableDesc closeParen |
|---|
| 223 | { |
|---|
| 224 | $$ = new Inst(TSP_DOT_PRODUCT_CUBE_MAP_3_OF_3, $3); |
|---|
| 225 | delete $3; |
|---|
| 226 | } |
|---|
| 227 | | dot_product_reflect_cube_map_eye_from_qs_1of3 openParen MappedVariableDesc closeParen |
|---|
| 228 | { |
|---|
| 229 | $$ = new Inst(TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_EYE_FROM_QS_1_OF_3, $3); |
|---|
| 230 | delete $3; |
|---|
| 231 | } |
|---|
| 232 | | dot_product_reflect_cube_map_eye_from_qs_2of3 openParen MappedVariableDesc closeParen |
|---|
| 233 | { |
|---|
| 234 | $$ = new Inst(TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_EYE_FROM_QS_2_OF_3, $3); |
|---|
| 235 | delete $3; |
|---|
| 236 | } |
|---|
| 237 | | dot_product_reflect_cube_map_eye_from_qs_3of3 openParen MappedVariableDesc closeParen |
|---|
| 238 | { |
|---|
| 239 | $$ = new Inst(TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_EYE_FROM_QS_3_OF_3, $3); |
|---|
| 240 | delete $3; |
|---|
| 241 | } |
|---|
| 242 | | dot_product_reflect_cube_map_const_eye_1of3 openParen MappedVariableDesc comma floatValue comma floatValue comma floatValue closeParen |
|---|
| 243 | { |
|---|
| 244 | $$ = new Inst(TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_CONST_EYE_1_OF_3, $3, $5, $7, $9); |
|---|
| 245 | delete $3; |
|---|
| 246 | } |
|---|
| 247 | | dot_product_reflect_cube_map_const_eye_2of3 openParen MappedVariableDesc closeParen |
|---|
| 248 | { |
|---|
| 249 | $$ = new Inst(TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_CONST_EYE_2_OF_3, $3); |
|---|
| 250 | delete $3; |
|---|
| 251 | } |
|---|
| 252 | | dot_product_reflect_cube_map_const_eye_3of3 openParen MappedVariableDesc closeParen |
|---|
| 253 | { |
|---|
| 254 | $$ = new Inst(TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_CONST_EYE_3_OF_3, $3); |
|---|
| 255 | delete $3; |
|---|
| 256 | } |
|---|
| 257 | | dot_product_cube_map_and_reflect_cube_map_eye_from_qs_1of3 openParen MappedVariableDesc closeParen |
|---|
| 258 | { |
|---|
| 259 | $$ = new Inst(TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_EYE_FROM_QS_1_OF_3, $3); |
|---|
| 260 | delete $3; |
|---|
| 261 | } |
|---|
| 262 | | dot_product_cube_map_and_reflect_cube_map_eye_from_qs_2of3 openParen MappedVariableDesc closeParen |
|---|
| 263 | { |
|---|
| 264 | $$ = new Inst(TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_EYE_FROM_QS_2_OF_3, $3); |
|---|
| 265 | delete $3; |
|---|
| 266 | } |
|---|
| 267 | | dot_product_cube_map_and_reflect_cube_map_eye_from_qs_3of3 openParen MappedVariableDesc closeParen |
|---|
| 268 | { |
|---|
| 269 | $$ = new Inst(TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_EYE_FROM_QS_3_OF_3, $3); |
|---|
| 270 | delete $3; |
|---|
| 271 | } |
|---|
| 272 | | dot_product_cube_map_and_reflect_cube_map_const_eye_1of3 openParen MappedVariableDesc comma floatValue comma floatValue comma floatValue closeParen |
|---|
| 273 | { |
|---|
| 274 | $$ = new Inst(TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_CONST_EYE_1_OF_3, $3, $5, $7, $9); |
|---|
| 275 | delete $3; |
|---|
| 276 | } |
|---|
| 277 | | dot_product_cube_map_and_reflect_cube_map_const_eye_2of3 openParen MappedVariableDesc closeParen |
|---|
| 278 | { |
|---|
| 279 | $$ = new Inst(TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_CONST_EYE_2_OF_3, $3); |
|---|
| 280 | delete $3; |
|---|
| 281 | } |
|---|
| 282 | | dot_product_cube_map_and_reflect_cube_map_const_eye_3of3 openParen MappedVariableDesc closeParen |
|---|
| 283 | { |
|---|
| 284 | $$ = new Inst(TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_CONST_EYE_3_OF_3, $3); |
|---|
| 285 | delete $3; |
|---|
| 286 | } |
|---|
| 287 | ; |
|---|
| 288 | |
|---|
| 289 | CondDesc : gequal |
|---|
| 290 | { |
|---|
| 291 | $$ = $1; |
|---|
| 292 | } |
|---|
| 293 | | less |
|---|
| 294 | { |
|---|
| 295 | $$ = $1; |
|---|
| 296 | } |
|---|
| 297 | ; |
|---|
| 298 | |
|---|
| 299 | |
|---|
| 300 | %% |
|---|
| 301 | void yyerror(char* s) |
|---|
| 302 | { |
|---|
| 303 | errors.set("unrecognized token"); |
|---|
| 304 | } |
|---|