[D3DCOMPILER_43]
[reactos.git] / reactos / dll / directx / wine / d3dcompiler_43 / hlsl.tab.c
1 /* A Bison parser, made by GNU Bison 2.5. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
29
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
35
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
42
43 /* Identify Bison output. */
44 #define YYBISON 1
45
46 /* Bison version. */
47 #define YYBISON_VERSION "2.5"
48
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers. */
53 #define YYPURE 0
54
55 /* Push parsers. */
56 #define YYPUSH 0
57
58 /* Pull parsers. */
59 #define YYPULL 1
60
61 /* Using locations. */
62 #define YYLSP_NEEDED 1
63
64 /* Substitute the variable and function names. */
65 #define yyparse hlsl_parse
66 #define yylex hlsl_lex
67 #define yyerror hlsl_error
68 #define yylval hlsl_lval
69 #define yychar hlsl_char
70 #define yydebug hlsl_debug
71 #define yynerrs hlsl_nerrs
72 #define yylloc hlsl_lloc
73
74 /* Copy the first part of user declarations. */
75
76 /* Line 268 of yacc.c */
77 #line 21 "hlsl.y"
78
79 #include "d3dcompiler_private.h"
80
81 WINE_DEFAULT_DEBUG_CHANNEL(hlsl_parser);
82
83 int hlsl_lex(void);
84
85 struct hlsl_parse_ctx hlsl_ctx;
86
87 struct YYLTYPE;
88 static void set_location(struct source_location *loc, const struct YYLTYPE *l);
89
90 void hlsl_message(const char *fmt, ...)
91 {
92 va_list args;
93
94 va_start(args, fmt);
95 compilation_message(&hlsl_ctx.messages, fmt, args);
96 va_end(args);
97 }
98
99 static const char *hlsl_get_error_level_name(enum hlsl_error_level level)
100 {
101 const char *names[] =
102 {
103 "error",
104 "warning",
105 "note",
106 };
107 return names[level];
108 }
109
110 void hlsl_report_message(const char *filename, DWORD line, DWORD column,
111 enum hlsl_error_level level, const char *fmt, ...)
112 {
113 va_list args;
114 char *string = NULL;
115 int rc, size = 0;
116
117 while (1)
118 {
119 va_start(args, fmt);
120 rc = vsnprintf(string, size, fmt, args);
121 va_end(args);
122
123 if (rc >= 0 && rc < size)
124 break;
125
126 if (rc >= size)
127 size = rc + 1;
128 else
129 size = size ? size * 2 : 32;
130
131 if (!string)
132 string = d3dcompiler_alloc(size);
133 else
134 string = d3dcompiler_realloc(string, size);
135 if (!string)
136 {
137 ERR("Error reallocating memory for a string.\n");
138 return;
139 }
140 }
141
142 hlsl_message("%s:%u:%u: %s: %s\n", filename, line, column, hlsl_get_error_level_name(level), string);
143 d3dcompiler_free(string);
144
145 if (level == HLSL_LEVEL_ERROR)
146 set_parse_status(&hlsl_ctx.status, PARSE_ERR);
147 else if (level == HLSL_LEVEL_WARNING)
148 set_parse_status(&hlsl_ctx.status, PARSE_WARN);
149 }
150
151 static void hlsl_error(const char *s)
152 {
153 hlsl_report_message(hlsl_ctx.source_file, hlsl_ctx.line_no, hlsl_ctx.column, HLSL_LEVEL_ERROR, "%s", s);
154 }
155
156 static void debug_dump_decl(struct hlsl_type *type, DWORD modifiers, const char *declname, unsigned int line_no)
157 {
158 TRACE("Line %u: ", line_no);
159 if (modifiers)
160 TRACE("%s ", debug_modifiers(modifiers));
161 TRACE("%s %s;\n", debug_hlsl_type(type), declname);
162 }
163
164 static void check_invalid_matrix_modifiers(DWORD modifiers, struct source_location *loc)
165 {
166 if (modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR))
167 {
168 hlsl_report_message(loc->file, loc->line, loc->col, HLSL_LEVEL_ERROR,
169 "'row_major' or 'column_major' modifiers are only allowed for matrices");
170 }
171 }
172
173 static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
174 {
175 BOOL ret;
176
177 TRACE("Declaring variable %s.\n", decl->name);
178 if (decl->node.data_type->type == HLSL_CLASS_MATRIX)
179 {
180 if (!(decl->modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)))
181 {
182 decl->modifiers |= hlsl_ctx.matrix_majority == HLSL_ROW_MAJOR
183 ? HLSL_MODIFIER_ROW_MAJOR : HLSL_MODIFIER_COLUMN_MAJOR;
184 }
185 }
186 else
187 check_invalid_matrix_modifiers(decl->modifiers, &decl->node.loc);
188
189 if (local)
190 {
191 DWORD invalid = decl->modifiers & (HLSL_STORAGE_EXTERN | HLSL_STORAGE_SHARED
192 | HLSL_STORAGE_GROUPSHARED | HLSL_STORAGE_UNIFORM);
193 if (invalid)
194 {
195 hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_ERROR,
196 "modifier '%s' invalid for local variables", debug_modifiers(invalid));
197 }
198 if (decl->semantic)
199 {
200 hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_ERROR,
201 "semantics are not allowed on local variables");
202 return FALSE;
203 }
204 }
205 else
206 {
207 if (find_function(decl->name))
208 {
209 hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_ERROR,
210 "redefinition of '%s'", decl->name);
211 return FALSE;
212 }
213 }
214 ret = add_declaration(hlsl_ctx.cur_scope, decl, local);
215 if (!ret)
216 {
217 struct hlsl_ir_var *old = get_variable(hlsl_ctx.cur_scope, decl->name);
218
219 hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_ERROR,
220 "\"%s\" already declared", decl->name);
221 hlsl_report_message(old->node.loc.file, old->node.loc.line, old->node.loc.col, HLSL_LEVEL_NOTE,
222 "\"%s\" was previously declared here", old->name);
223 return FALSE;
224 }
225 return TRUE;
226 }
227
228 static DWORD add_modifier(DWORD modifiers, DWORD mod, const struct YYLTYPE *loc);
229
230 static BOOL check_type_modifiers(DWORD modifiers, struct source_location *loc)
231 {
232 if (modifiers & ~HLSL_TYPE_MODIFIERS_MASK)
233 {
234 hlsl_report_message(loc->file, loc->line, loc->col, HLSL_LEVEL_ERROR,
235 "modifier not allowed on typedefs");
236 return FALSE;
237 }
238 return TRUE;
239 }
240
241 static BOOL add_type_to_scope(struct hlsl_scope *scope, struct hlsl_type *def)
242 {
243 if (get_type(scope, def->name, FALSE))
244 return FALSE;
245
246 wine_rb_put(&scope->types, def->name, &def->scope_entry);
247 return TRUE;
248 }
249
250 static void declare_predefined_types(struct hlsl_scope *scope)
251 {
252 struct hlsl_type *type;
253 unsigned int x, y, bt;
254 static const char *names[] =
255 {
256 "float",
257 "half",
258 "double",
259 "int",
260 "uint",
261 "bool",
262 };
263 char name[10];
264
265 for (bt = 0; bt <= HLSL_TYPE_LAST_SCALAR; ++bt)
266 {
267 for (y = 1; y <= 4; ++y)
268 {
269 for (x = 1; x <= 4; ++x)
270 {
271 sprintf(name, "%s%ux%u", names[bt], x, y);
272 type = new_hlsl_type(d3dcompiler_strdup(name), HLSL_CLASS_MATRIX, bt, x, y);
273 add_type_to_scope(scope, type);
274
275 if (y == 1)
276 {
277 sprintf(name, "%s%u", names[bt], x);
278 type = new_hlsl_type(d3dcompiler_strdup(name), HLSL_CLASS_VECTOR, bt, x, y);
279 add_type_to_scope(scope, type);
280
281 if (x == 1)
282 {
283 sprintf(name, "%s", names[bt]);
284 type = new_hlsl_type(d3dcompiler_strdup(name), HLSL_CLASS_SCALAR, bt, x, y);
285 add_type_to_scope(scope, type);
286 }
287 }
288 }
289 }
290 }
291
292 /* DX8 effects predefined types */
293 type = new_hlsl_type(d3dcompiler_strdup("DWORD"), HLSL_CLASS_SCALAR, HLSL_TYPE_INT, 1, 1);
294 add_type_to_scope(scope, type);
295 type = new_hlsl_type(d3dcompiler_strdup("FLOAT"), HLSL_CLASS_SCALAR, HLSL_TYPE_FLOAT, 1, 1);
296 add_type_to_scope(scope, type);
297 type = new_hlsl_type(d3dcompiler_strdup("VECTOR"), HLSL_CLASS_VECTOR, HLSL_TYPE_FLOAT, 4, 1);
298 add_type_to_scope(scope, type);
299 type = new_hlsl_type(d3dcompiler_strdup("MATRIX"), HLSL_CLASS_MATRIX, HLSL_TYPE_FLOAT, 4, 4);
300 add_type_to_scope(scope, type);
301 type = new_hlsl_type(d3dcompiler_strdup("STRING"), HLSL_CLASS_OBJECT, HLSL_TYPE_STRING, 1, 1);
302 add_type_to_scope(scope, type);
303 type = new_hlsl_type(d3dcompiler_strdup("TEXTURE"), HLSL_CLASS_OBJECT, HLSL_TYPE_TEXTURE, 1, 1);
304 add_type_to_scope(scope, type);
305 type = new_hlsl_type(d3dcompiler_strdup("PIXELSHADER"), HLSL_CLASS_OBJECT, HLSL_TYPE_PIXELSHADER, 1, 1);
306 add_type_to_scope(scope, type);
307 type = new_hlsl_type(d3dcompiler_strdup("VERTEXSHADER"), HLSL_CLASS_OBJECT, HLSL_TYPE_VERTEXSHADER, 1, 1);
308 add_type_to_scope(scope, type);
309 }
310
311 static struct hlsl_ir_if *loop_condition(struct list *cond_list)
312 {
313 struct hlsl_ir_if *out_cond;
314 struct hlsl_ir_expr *not_cond;
315 struct hlsl_ir_node *cond, *operands[3];
316 struct hlsl_ir_jump *jump;
317 unsigned int count = list_count(cond_list);
318
319 if (!count)
320 return NULL;
321 if (count != 1)
322 ERR("Got multiple expressions in a for condition.\n");
323
324 cond = LIST_ENTRY(list_head(cond_list), struct hlsl_ir_node, entry);
325 out_cond = d3dcompiler_alloc(sizeof(*out_cond));
326 if (!out_cond)
327 {
328 ERR("Out of memory.\n");
329 return NULL;
330 }
331 out_cond->node.type = HLSL_IR_IF;
332 operands[0] = cond;
333 operands[1] = operands[2] = NULL;
334 not_cond = new_expr(HLSL_IR_UNOP_LOGIC_NOT, operands, &cond->loc);
335 if (!not_cond)
336 {
337 ERR("Out of memory.\n");
338 d3dcompiler_free(out_cond);
339 return NULL;
340 }
341 out_cond->condition = &not_cond->node;
342 jump = d3dcompiler_alloc(sizeof(*jump));
343 if (!jump)
344 {
345 ERR("Out of memory.\n");
346 d3dcompiler_free(out_cond);
347 d3dcompiler_free(not_cond);
348 return NULL;
349 }
350 jump->node.type = HLSL_IR_JUMP;
351 jump->type = HLSL_IR_JUMP_BREAK;
352 out_cond->then_instrs = d3dcompiler_alloc(sizeof(*out_cond->then_instrs));
353 if (!out_cond->then_instrs)
354 {
355 ERR("Out of memory.\n");
356 d3dcompiler_free(out_cond);
357 d3dcompiler_free(not_cond);
358 d3dcompiler_free(jump);
359 return NULL;
360 }
361 list_init(out_cond->then_instrs);
362 list_add_head(out_cond->then_instrs, &jump->node.entry);
363
364 return out_cond;
365 }
366
367 enum loop_type
368 {
369 LOOP_FOR,
370 LOOP_WHILE,
371 LOOP_DO_WHILE
372 };
373
374 static struct list *create_loop(enum loop_type type, struct list *init, struct list *cond,
375 struct hlsl_ir_node *iter, struct list *body, struct source_location *loc)
376 {
377 struct list *list = NULL;
378 struct hlsl_ir_loop *loop = NULL;
379 struct hlsl_ir_if *cond_jump = NULL;
380
381 list = d3dcompiler_alloc(sizeof(*list));
382 if (!list)
383 goto oom;
384 list_init(list);
385
386 if (init)
387 list_move_head(list, init);
388
389 loop = d3dcompiler_alloc(sizeof(*loop));
390 if (!loop)
391 goto oom;
392 loop->node.type = HLSL_IR_LOOP;
393 loop->node.loc = *loc;
394 list_add_tail(list, &loop->node.entry);
395 loop->body = d3dcompiler_alloc(sizeof(*loop->body));
396 if (!loop->body)
397 goto oom;
398 list_init(loop->body);
399
400 cond_jump = loop_condition(cond);
401 if (!cond_jump)
402 goto oom;
403
404 if (type != LOOP_DO_WHILE)
405 list_add_tail(loop->body, &cond_jump->node.entry);
406
407 list_move_tail(loop->body, body);
408
409 if (iter)
410 list_add_tail(loop->body, &iter->entry);
411
412 if (type == LOOP_DO_WHILE)
413 list_add_tail(loop->body, &cond_jump->node.entry);
414
415 d3dcompiler_free(init);
416 d3dcompiler_free(cond);
417 d3dcompiler_free(body);
418 return list;
419
420 oom:
421 ERR("Out of memory.\n");
422 if (loop)
423 d3dcompiler_free(loop->body);
424 d3dcompiler_free(loop);
425 d3dcompiler_free(cond_jump);
426 d3dcompiler_free(list);
427 free_instr_list(init);
428 free_instr_list(cond);
429 free_instr(iter);
430 free_instr_list(body);
431 return NULL;
432 }
433
434 static unsigned int initializer_size(struct list *initializer)
435 {
436 unsigned int count = 0;
437 struct hlsl_ir_node *node;
438
439 LIST_FOR_EACH_ENTRY(node, initializer, struct hlsl_ir_node, entry)
440 {
441 count += components_count_type(node->data_type);
442 }
443 TRACE("Initializer size = %u\n", count);
444 return count;
445 }
446
447 static unsigned int components_count_expr_list(struct list *list)
448 {
449 struct hlsl_ir_node *node;
450 unsigned int count = 0;
451
452 LIST_FOR_EACH_ENTRY(node, list, struct hlsl_ir_node, entry)
453 {
454 count += components_count_type(node->data_type);
455 }
456 return count;
457 }
458
459 static struct hlsl_ir_swizzle *new_swizzle(DWORD s, unsigned int components,
460 struct hlsl_ir_node *val, struct source_location *loc)
461 {
462 struct hlsl_ir_swizzle *swizzle = d3dcompiler_alloc(sizeof(*swizzle));
463
464 if (!swizzle)
465 return NULL;
466 swizzle->node.type = HLSL_IR_SWIZZLE;
467 swizzle->node.loc = *loc;
468 swizzle->node.data_type = new_hlsl_type(NULL, HLSL_CLASS_VECTOR, val->data_type->base_type, components, 1);
469 swizzle->val = val;
470 swizzle->swizzle = s;
471 return swizzle;
472 }
473
474 static struct hlsl_ir_swizzle *get_swizzle(struct hlsl_ir_node *value, const char *swizzle,
475 struct source_location *loc)
476 {
477 unsigned int len = strlen(swizzle), component = 0;
478 unsigned int i, set, swiz = 0;
479 BOOL valid;
480
481 if (value->data_type->type == HLSL_CLASS_MATRIX)
482 {
483 /* Matrix swizzle */
484 BOOL m_swizzle;
485 unsigned int inc, x, y;
486
487 if (len < 3 || swizzle[0] != '_')
488 return NULL;
489 m_swizzle = swizzle[1] == 'm';
490 inc = m_swizzle ? 4 : 3;
491
492 if (len % inc || len > inc * 4)
493 return NULL;
494
495 for (i = 0; i < len; i += inc)
496 {
497 if (swizzle[i] != '_')
498 return NULL;
499 if (m_swizzle)
500 {
501 if (swizzle[i + 1] != 'm')
502 return NULL;
503 x = swizzle[i + 2] - '0';
504 y = swizzle[i + 3] - '0';
505 }
506 else
507 {
508 x = swizzle[i + 1] - '1';
509 y = swizzle[i + 2] - '1';
510 }
511
512 if (x >= value->data_type->dimx || y >= value->data_type->dimy)
513 return NULL;
514 swiz |= (y << 4 | x) << component * 8;
515 component++;
516 }
517 return new_swizzle(swiz, component, value, loc);
518 }
519
520 /* Vector swizzle */
521 if (len > 4)
522 return NULL;
523
524 for (set = 0; set < 2; ++set)
525 {
526 valid = TRUE;
527 component = 0;
528 for (i = 0; i < len; ++i)
529 {
530 char c[2][4] = {{'x', 'y', 'z', 'w'}, {'r', 'g', 'b', 'a'}};
531 unsigned int s = 0;
532
533 for (s = 0; s < 4; ++s)
534 {
535 if (swizzle[i] == c[set][s])
536 break;
537 }
538 if (s == 4)
539 {
540 valid = FALSE;
541 break;
542 }
543
544 if (s >= value->data_type->dimx)
545 return NULL;
546 swiz |= s << component * 2;
547 component++;
548 }
549 if (valid)
550 return new_swizzle(swiz, component, value, loc);
551 }
552
553 return NULL;
554 }
555
556 static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var, struct list *initializer)
557 {
558 struct hlsl_type *type = var->node.data_type;
559 struct hlsl_ir_node *node;
560 struct hlsl_struct_field *field;
561 struct list *cur_node;
562 struct hlsl_ir_node *assignment;
563 struct hlsl_ir_deref *deref;
564
565 if (initializer_size(initializer) != components_count_type(type))
566 {
567 hlsl_report_message(var->node.loc.file, var->node.loc.line, var->node.loc.col, HLSL_LEVEL_ERROR,
568 "structure initializer mismatch");
569 free_instr_list(initializer);
570 return;
571 }
572 cur_node = list_head(initializer);
573 assert(cur_node);
574 node = LIST_ENTRY(cur_node, struct hlsl_ir_node, entry);
575 LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry)
576 {
577 if (!cur_node)
578 {
579 d3dcompiler_free(initializer);
580 return;
581 }
582 if (components_count_type(field->type) == components_count_type(node->data_type))
583 {
584 deref = new_record_deref(&var->node, field);
585 if (!deref)
586 {
587 ERR("Out of memory.\n");
588 break;
589 }
590 deref->node.loc = node->loc;
591 assignment = make_assignment(&deref->node, ASSIGN_OP_ASSIGN, BWRITERSP_WRITEMASK_ALL, node);
592 list_add_tail(list, &assignment->entry);
593 }
594 else
595 FIXME("Initializing with \"mismatched\" fields is not supported yet.\n");
596 cur_node = list_next(initializer, cur_node);
597 node = LIST_ENTRY(cur_node, struct hlsl_ir_node, entry);
598 }
599
600 /* Free initializer elements in excess. */
601 while (cur_node)
602 {
603 struct list *next = list_next(initializer, cur_node);
604 free_instr(node);
605 cur_node = next;
606 node = LIST_ENTRY(cur_node, struct hlsl_ir_node, entry);
607 }
608 d3dcompiler_free(initializer);
609 }
610
611 static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers, struct list *var_list)
612 {
613 struct hlsl_type *type;
614 struct parse_variable_def *v, *v_next;
615 struct hlsl_ir_var *var;
616 struct hlsl_ir_node *assignment;
617 BOOL ret, local = TRUE;
618 struct list *statements_list = d3dcompiler_alloc(sizeof(*statements_list));
619
620 if (!statements_list)
621 {
622 ERR("Out of memory.\n");
623 LIST_FOR_EACH_ENTRY_SAFE(v, v_next, var_list, struct parse_variable_def, entry)
624 d3dcompiler_free(v);
625 d3dcompiler_free(var_list);
626 return NULL;
627 }
628 list_init(statements_list);
629
630 if (!var_list)
631 return statements_list;
632
633 LIST_FOR_EACH_ENTRY_SAFE(v, v_next, var_list, struct parse_variable_def, entry)
634 {
635 var = d3dcompiler_alloc(sizeof(*var));
636 if (!var)
637 {
638 ERR("Out of memory.\n");
639 d3dcompiler_free(v);
640 continue;
641 }
642 var->node.type = HLSL_IR_VAR;
643 if (v->array_size)
644 type = new_array_type(basic_type, v->array_size);
645 else
646 type = basic_type;
647 var->node.data_type = type;
648 var->node.loc = v->loc;
649 var->name = v->name;
650 var->modifiers = modifiers;
651 var->semantic = v->semantic;
652 debug_dump_decl(type, modifiers, v->name, v->loc.line);
653
654 if (hlsl_ctx.cur_scope == hlsl_ctx.globals)
655 {
656 var->modifiers |= HLSL_STORAGE_UNIFORM;
657 local = FALSE;
658 }
659
660 if (var->modifiers & HLSL_MODIFIER_CONST && !(var->modifiers & HLSL_STORAGE_UNIFORM) && !v->initializer)
661 {
662 hlsl_report_message(v->loc.file, v->loc.line, v->loc.col,
663 HLSL_LEVEL_ERROR, "const variable without initializer");
664 free_declaration(var);
665 d3dcompiler_free(v);
666 continue;
667 }
668
669 ret = declare_variable(var, local);
670 if (!ret)
671 {
672 free_declaration(var);
673 d3dcompiler_free(v);
674 continue;
675 }
676 TRACE("Declared variable %s.\n", var->name);
677
678 if (v->initializer)
679 {
680 unsigned int size = initializer_size(v->initializer);
681 struct hlsl_ir_node *node;
682
683 TRACE("Variable with initializer.\n");
684 if (type->type <= HLSL_CLASS_LAST_NUMERIC
685 && type->dimx * type->dimy != size && size != 1)
686 {
687 if (size < type->dimx * type->dimy)
688 {
689 hlsl_report_message(v->loc.file, v->loc.line, v->loc.col, HLSL_LEVEL_ERROR,
690 "'%s' initializer does not match", v->name);
691 free_instr_list(v->initializer);
692 d3dcompiler_free(v);
693 continue;
694 }
695 }
696 if ((type->type == HLSL_CLASS_STRUCT || type->type == HLSL_CLASS_ARRAY)
697 && components_count_type(type) != size)
698 {
699 hlsl_report_message(v->loc.file, v->loc.line, v->loc.col, HLSL_LEVEL_ERROR,
700 "'%s' initializer does not match", v->name);
701 free_instr_list(v->initializer);
702 d3dcompiler_free(v);
703 continue;
704 }
705
706 if (type->type == HLSL_CLASS_STRUCT)
707 {
708 struct_var_initializer(statements_list, var, v->initializer);
709 d3dcompiler_free(v);
710 continue;
711 }
712 if (type->type > HLSL_CLASS_LAST_NUMERIC)
713 {
714 FIXME("Initializers for non scalar/struct variables not supported yet.\n");
715 free_instr_list(v->initializer);
716 d3dcompiler_free(v);
717 continue;
718 }
719 if (v->array_size > 0)
720 {
721 FIXME("Initializing arrays is not supported yet.\n");
722 free_instr_list(v->initializer);
723 d3dcompiler_free(v);
724 continue;
725 }
726 if (list_count(v->initializer) > 1)
727 {
728 FIXME("Complex initializers are not supported yet.\n");
729 free_instr_list(v->initializer);
730 d3dcompiler_free(v);
731 continue;
732 }
733 node = LIST_ENTRY(list_head(v->initializer), struct hlsl_ir_node, entry);
734 assignment = make_assignment(&var->node, ASSIGN_OP_ASSIGN,
735 BWRITERSP_WRITEMASK_ALL, node);
736 list_add_tail(statements_list, &assignment->entry);
737 d3dcompiler_free(v->initializer);
738 }
739 d3dcompiler_free(v);
740 }
741 d3dcompiler_free(var_list);
742 return statements_list;
743 }
744
745 static BOOL add_struct_field(struct list *fields, struct hlsl_struct_field *field)
746 {
747 struct hlsl_struct_field *f;
748
749 LIST_FOR_EACH_ENTRY(f, fields, struct hlsl_struct_field, entry)
750 {
751 if (!strcmp(f->name, field->name))
752 return FALSE;
753 }
754 list_add_tail(fields, &field->entry);
755 return TRUE;
756 }
757
758 static struct list *gen_struct_fields(struct hlsl_type *type, DWORD modifiers, struct list *fields)
759 {
760 struct parse_variable_def *v, *v_next;
761 struct hlsl_struct_field *field;
762 struct list *list;
763
764 list = d3dcompiler_alloc(sizeof(*list));
765 if (!list)
766 {
767 ERR("Out of memory.\n");
768 return NULL;
769 }
770 list_init(list);
771 LIST_FOR_EACH_ENTRY_SAFE(v, v_next, fields, struct parse_variable_def, entry)
772 {
773 debug_dump_decl(type, 0, v->name, v->loc.line);
774 field = d3dcompiler_alloc(sizeof(*field));
775 if (!field)
776 {
777 ERR("Out of memory.\n");
778 d3dcompiler_free(v);
779 return list;
780 }
781 field->type = type;
782 field->name = v->name;
783 field->modifiers = modifiers;
784 field->semantic = v->semantic;
785 if (v->initializer)
786 {
787 hlsl_report_message(v->loc.file, v->loc.line, v->loc.col, HLSL_LEVEL_ERROR,
788 "struct field with an initializer.\n");
789 free_instr_list(v->initializer);
790 }
791 list_add_tail(list, &field->entry);
792 d3dcompiler_free(v);
793 }
794 d3dcompiler_free(fields);
795 return list;
796 }
797
798 static struct hlsl_type *new_struct_type(const char *name, DWORD modifiers, struct list *fields)
799 {
800 struct hlsl_type *type = d3dcompiler_alloc(sizeof(*type));
801
802 if (!type)
803 {
804 ERR("Out of memory.\n");
805 return NULL;
806 }
807 type->type = HLSL_CLASS_STRUCT;
808 type->name = name;
809 type->dimx = type->dimy = 1;
810 type->modifiers = modifiers;
811 type->e.elements = fields;
812
813 list_add_tail(&hlsl_ctx.types, &type->entry);
814
815 return type;
816 }
817
818 static BOOL add_typedef(DWORD modifiers, struct hlsl_type *orig_type, struct list *list,
819 struct source_location *loc)
820 {
821 BOOL ret;
822 struct hlsl_type *type;
823 struct parse_variable_def *v, *v_next;
824
825 if (!check_type_modifiers(modifiers, loc))
826 {
827 LIST_FOR_EACH_ENTRY_SAFE(v, v_next, list, struct parse_variable_def, entry)
828 d3dcompiler_free(v);
829 d3dcompiler_free(list);
830 return FALSE;
831 }
832
833 LIST_FOR_EACH_ENTRY_SAFE(v, v_next, list, struct parse_variable_def, entry)
834 {
835 if (v->array_size)
836 type = new_array_type(orig_type, v->array_size);
837 else
838 type = clone_hlsl_type(orig_type);
839 if (!type)
840 {
841 ERR("Out of memory\n");
842 return FALSE;
843 }
844 d3dcompiler_free((void *)type->name);
845 type->name = v->name;
846 type->modifiers |= modifiers;
847
848 if (type->type != HLSL_CLASS_MATRIX)
849 check_invalid_matrix_modifiers(type->modifiers, &v->loc);
850
851 ret = add_type_to_scope(hlsl_ctx.cur_scope, type);
852 if (!ret)
853 {
854 hlsl_report_message(v->loc.file, v->loc.line, v->loc.col, HLSL_LEVEL_ERROR,
855 "redefinition of custom type '%s'", v->name);
856 }
857 d3dcompiler_free(v);
858 }
859 d3dcompiler_free(list);
860 return TRUE;
861 }
862
863 static const struct hlsl_ir_function_decl *get_overloaded_func(struct wine_rb_tree *funcs, char *name,
864 struct list *params, BOOL exact_signature)
865 {
866 struct hlsl_ir_function *func;
867 struct wine_rb_entry *entry;
868
869 entry = wine_rb_get(funcs, name);
870 if (entry)
871 {
872 func = WINE_RB_ENTRY_VALUE(entry, struct hlsl_ir_function, entry);
873
874 entry = wine_rb_get(&func->overloads, params);
875 if (!entry)
876 {
877 if (!exact_signature)
878 FIXME("No exact match, search for a compatible overloaded function (if any).\n");
879 return NULL;
880 }
881 return WINE_RB_ENTRY_VALUE(entry, struct hlsl_ir_function_decl, entry);
882 }
883 return NULL;
884 }
885
886
887
888 /* Line 268 of yacc.c */
889 #line 895 "hlsl.tab.c"
890
891 /* Enabling traces. */
892 #ifndef YYDEBUG
893 # define YYDEBUG 0
894 #endif
895
896 /* Enabling verbose error messages. */
897 #ifdef YYERROR_VERBOSE
898 # undef YYERROR_VERBOSE
899 # define YYERROR_VERBOSE 1
900 #else
901 # define YYERROR_VERBOSE 1
902 #endif
903
904 /* Enabling the token table. */
905 #ifndef YYTOKEN_TABLE
906 # define YYTOKEN_TABLE 0
907 #endif
908
909
910 /* Tokens. */
911 #ifndef YYTOKENTYPE
912 # define YYTOKENTYPE
913 /* Put the tokens into the symbol table, so that GDB and other debuggers
914 know about them. */
915 enum yytokentype {
916 KW_BLENDSTATE = 258,
917 KW_BREAK = 259,
918 KW_BUFFER = 260,
919 KW_CBUFFER = 261,
920 KW_COLUMN_MAJOR = 262,
921 KW_COMPILE = 263,
922 KW_CONST = 264,
923 KW_CONTINUE = 265,
924 KW_DEPTHSTENCILSTATE = 266,
925 KW_DEPTHSTENCILVIEW = 267,
926 KW_DISCARD = 268,
927 KW_DO = 269,
928 KW_DOUBLE = 270,
929 KW_ELSE = 271,
930 KW_EXTERN = 272,
931 KW_FALSE = 273,
932 KW_FOR = 274,
933 KW_GEOMETRYSHADER = 275,
934 KW_GROUPSHARED = 276,
935 KW_IF = 277,
936 KW_IN = 278,
937 KW_INLINE = 279,
938 KW_INOUT = 280,
939 KW_MATRIX = 281,
940 KW_NAMESPACE = 282,
941 KW_NOINTERPOLATION = 283,
942 KW_OUT = 284,
943 KW_PASS = 285,
944 KW_PIXELSHADER = 286,
945 KW_PRECISE = 287,
946 KW_RASTERIZERSTATE = 288,
947 KW_RENDERTARGETVIEW = 289,
948 KW_RETURN = 290,
949 KW_REGISTER = 291,
950 KW_ROW_MAJOR = 292,
951 KW_SAMPLER = 293,
952 KW_SAMPLER1D = 294,
953 KW_SAMPLER2D = 295,
954 KW_SAMPLER3D = 296,
955 KW_SAMPLERCUBE = 297,
956 KW_SAMPLER_STATE = 298,
957 KW_SAMPLERCOMPARISONSTATE = 299,
958 KW_SHARED = 300,
959 KW_STATEBLOCK = 301,
960 KW_STATEBLOCK_STATE = 302,
961 KW_STATIC = 303,
962 KW_STRING = 304,
963 KW_STRUCT = 305,
964 KW_SWITCH = 306,
965 KW_TBUFFER = 307,
966 KW_TECHNIQUE = 308,
967 KW_TECHNIQUE10 = 309,
968 KW_TEXTURE = 310,
969 KW_TEXTURE1D = 311,
970 KW_TEXTURE1DARRAY = 312,
971 KW_TEXTURE2D = 313,
972 KW_TEXTURE2DARRAY = 314,
973 KW_TEXTURE2DMS = 315,
974 KW_TEXTURE2DMSARRAY = 316,
975 KW_TEXTURE3D = 317,
976 KW_TEXTURE3DARRAY = 318,
977 KW_TEXTURECUBE = 319,
978 KW_TRUE = 320,
979 KW_TYPEDEF = 321,
980 KW_UNIFORM = 322,
981 KW_VECTOR = 323,
982 KW_VERTEXSHADER = 324,
983 KW_VOID = 325,
984 KW_VOLATILE = 326,
985 KW_WHILE = 327,
986 OP_INC = 328,
987 OP_DEC = 329,
988 OP_AND = 330,
989 OP_OR = 331,
990 OP_EQ = 332,
991 OP_LEFTSHIFT = 333,
992 OP_LEFTSHIFTASSIGN = 334,
993 OP_RIGHTSHIFT = 335,
994 OP_RIGHTSHIFTASSIGN = 336,
995 OP_ELLIPSIS = 337,
996 OP_LE = 338,
997 OP_GE = 339,
998 OP_NE = 340,
999 OP_ADDASSIGN = 341,
1000 OP_SUBASSIGN = 342,
1001 OP_MULASSIGN = 343,
1002 OP_DIVASSIGN = 344,
1003 OP_MODASSIGN = 345,
1004 OP_ANDASSIGN = 346,
1005 OP_ORASSIGN = 347,
1006 OP_XORASSIGN = 348,
1007 OP_UNKNOWN1 = 349,
1008 OP_UNKNOWN2 = 350,
1009 OP_UNKNOWN3 = 351,
1010 OP_UNKNOWN4 = 352,
1011 PRE_LINE = 353,
1012 VAR_IDENTIFIER = 354,
1013 TYPE_IDENTIFIER = 355,
1014 NEW_IDENTIFIER = 356,
1015 STRING = 357,
1016 C_FLOAT = 358,
1017 C_INTEGER = 359
1018 };
1019 #endif
1020
1021
1022
1023 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1024 typedef union YYSTYPE
1025 {
1026
1027 /* Line 293 of yacc.c */
1028 #line 841 "hlsl.y"
1029
1030 struct hlsl_type *type;
1031 INT intval;
1032 FLOAT floatval;
1033 BOOL boolval;
1034 char *name;
1035 DWORD modifiers;
1036 struct hlsl_ir_var *var;
1037 struct hlsl_ir_node *instr;
1038 struct list *list;
1039 struct parse_function function;
1040 struct parse_parameter parameter;
1041 struct parse_variable_def *variable_def;
1042 struct parse_if_body if_body;
1043 enum parse_unary_op unary_op;
1044 enum parse_assign_op assign_op;
1045
1046
1047
1048 /* Line 293 of yacc.c */
1049 #line 1055 "hlsl.tab.c"
1050 } YYSTYPE;
1051 # define YYSTYPE_IS_TRIVIAL 1
1052 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
1053 # define YYSTYPE_IS_DECLARED 1
1054 #endif
1055
1056 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
1057 typedef struct YYLTYPE
1058 {
1059 int first_line;
1060 int first_column;
1061 int last_line;
1062 int last_column;
1063 } YYLTYPE;
1064 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
1065 # define YYLTYPE_IS_DECLARED 1
1066 # define YYLTYPE_IS_TRIVIAL 1
1067 #endif
1068
1069
1070 /* Copy the second part of user declarations. */
1071
1072
1073 /* Line 343 of yacc.c */
1074 #line 1080 "hlsl.tab.c"
1075
1076 #ifdef short
1077 # undef short
1078 #endif
1079
1080 #ifdef YYTYPE_UINT8
1081 typedef YYTYPE_UINT8 yytype_uint8;
1082 #else
1083 typedef unsigned char yytype_uint8;
1084 #endif
1085
1086 #ifdef YYTYPE_INT8
1087 typedef YYTYPE_INT8 yytype_int8;
1088 #elif (defined __STDC__ || defined __C99__FUNC__ \
1089 || defined __cplusplus || defined _MSC_VER)
1090 typedef signed char yytype_int8;
1091 #else
1092 typedef short int yytype_int8;
1093 #endif
1094
1095 #ifdef YYTYPE_UINT16
1096 typedef YYTYPE_UINT16 yytype_uint16;
1097 #else
1098 typedef unsigned short int yytype_uint16;
1099 #endif
1100
1101 #ifdef YYTYPE_INT16
1102 typedef YYTYPE_INT16 yytype_int16;
1103 #else
1104 typedef short int yytype_int16;
1105 #endif
1106
1107 #ifndef YYSIZE_T
1108 # ifdef __SIZE_TYPE__
1109 # define YYSIZE_T __SIZE_TYPE__
1110 # elif defined size_t
1111 # define YYSIZE_T size_t
1112 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1113 || defined __cplusplus || defined _MSC_VER)
1114 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1115 # define YYSIZE_T size_t
1116 # else
1117 # define YYSIZE_T unsigned int
1118 # endif
1119 #endif
1120
1121 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1122
1123 #ifndef YY_
1124 # if defined YYENABLE_NLS && YYENABLE_NLS
1125 # if ENABLE_NLS
1126 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1127 # define YY_(msgid) dgettext ("bison-runtime", msgid)
1128 # endif
1129 # endif
1130 # ifndef YY_
1131 # define YY_(msgid) msgid
1132 # endif
1133 #endif
1134
1135 /* Suppress unused-variable warnings by "using" E. */
1136 #if ! defined lint || defined __GNUC__
1137 # define YYUSE(e) ((void) (e))
1138 #else
1139 # define YYUSE(e) /* empty */
1140 #endif
1141
1142 /* Identity function, used to suppress warnings about constant conditions. */
1143 #ifndef lint
1144 # define YYID(n) (n)
1145 #else
1146 #if (defined __STDC__ || defined __C99__FUNC__ \
1147 || defined __cplusplus || defined _MSC_VER)
1148 static int
1149 YYID (int yyi)
1150 #else
1151 static int
1152 YYID (yyi)
1153 int yyi;
1154 #endif
1155 {
1156 return yyi;
1157 }
1158 #endif
1159
1160 #if ! defined yyoverflow || YYERROR_VERBOSE
1161
1162 /* The parser invokes alloca or malloc; define the necessary symbols. */
1163
1164 # ifdef YYSTACK_USE_ALLOCA
1165 # if YYSTACK_USE_ALLOCA
1166 # ifdef __GNUC__
1167 # define YYSTACK_ALLOC __builtin_alloca
1168 # elif defined __BUILTIN_VA_ARG_INCR
1169 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1170 # elif defined _AIX
1171 # define YYSTACK_ALLOC __alloca
1172 # elif defined _MSC_VER
1173 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1174 # define alloca _alloca
1175 # else
1176 # define YYSTACK_ALLOC alloca
1177 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
1178 || defined __cplusplus || defined _MSC_VER)
1179 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1180 # ifndef EXIT_SUCCESS
1181 # define EXIT_SUCCESS 0
1182 # endif
1183 # endif
1184 # endif
1185 # endif
1186 # endif
1187
1188 # ifdef YYSTACK_ALLOC
1189 /* Pacify GCC's `empty if-body' warning. */
1190 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1191 # ifndef YYSTACK_ALLOC_MAXIMUM
1192 /* The OS might guarantee only one guard page at the bottom of the stack,
1193 and a page size can be as small as 4096 bytes. So we cannot safely
1194 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1195 to allow for a few compiler-allocated temporary stack slots. */
1196 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1197 # endif
1198 # else
1199 # define YYSTACK_ALLOC YYMALLOC
1200 # define YYSTACK_FREE YYFREE
1201 # ifndef YYSTACK_ALLOC_MAXIMUM
1202 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1203 # endif
1204 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
1205 && ! ((defined YYMALLOC || defined malloc) \
1206 && (defined YYFREE || defined free)))
1207 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1208 # ifndef EXIT_SUCCESS
1209 # define EXIT_SUCCESS 0
1210 # endif
1211 # endif
1212 # ifndef YYMALLOC
1213 # define YYMALLOC malloc
1214 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
1215 || defined __cplusplus || defined _MSC_VER)
1216 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1217 # endif
1218 # endif
1219 # ifndef YYFREE
1220 # define YYFREE free
1221 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
1222 || defined __cplusplus || defined _MSC_VER)
1223 void free (void *); /* INFRINGES ON USER NAME SPACE */
1224 # endif
1225 # endif
1226 # endif
1227 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1228
1229
1230 #if (! defined yyoverflow \
1231 && (! defined __cplusplus \
1232 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
1233 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1234
1235 /* A type that is properly aligned for any stack member. */
1236 union yyalloc
1237 {
1238 yytype_int16 yyss_alloc;
1239 YYSTYPE yyvs_alloc;
1240 YYLTYPE yyls_alloc;
1241 };
1242
1243 /* The size of the maximum gap between one aligned stack and the next. */
1244 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1245
1246 /* The size of an array large to enough to hold all stacks, each with
1247 N elements. */
1248 # define YYSTACK_BYTES(N) \
1249 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
1250 + 2 * YYSTACK_GAP_MAXIMUM)
1251
1252 # define YYCOPY_NEEDED 1
1253
1254 /* Relocate STACK from its old location to the new one. The
1255 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1256 elements in the stack, and YYPTR gives the new location of the
1257 stack. Advance YYPTR to a properly aligned location for the next
1258 stack. */
1259 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
1260 do \
1261 { \
1262 YYSIZE_T yynewbytes; \
1263 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
1264 Stack = &yyptr->Stack_alloc; \
1265 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1266 yyptr += yynewbytes / sizeof (*yyptr); \
1267 } \
1268 while (YYID (0))
1269
1270 #endif
1271
1272 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
1273 /* Copy COUNT objects from FROM to TO. The source and destination do
1274 not overlap. */
1275 # ifndef YYCOPY
1276 # if defined __GNUC__ && 1 < __GNUC__
1277 # define YYCOPY(To, From, Count) \
1278 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1279 # else
1280 # define YYCOPY(To, From, Count) \
1281 do \
1282 { \
1283 YYSIZE_T yyi; \
1284 for (yyi = 0; yyi < (Count); yyi++) \
1285 (To)[yyi] = (From)[yyi]; \
1286 } \
1287 while (YYID (0))
1288 # endif
1289 # endif
1290 #endif /* !YYCOPY_NEEDED */
1291
1292 /* YYFINAL -- State number of the termination state. */
1293 #define YYFINAL 2
1294 /* YYLAST -- Last index in YYTABLE. */
1295 #define YYLAST 848
1296
1297 /* YYNTOKENS -- Number of terminals. */
1298 #define YYNTOKENS 129
1299 /* YYNNTS -- Number of nonterminals. */
1300 #define YYNNTS 63
1301 /* YYNRULES -- Number of rules. */
1302 #define YYNRULES 171
1303 /* YYNRULES -- Number of states. */
1304 #define YYNSTATES 312
1305
1306 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1307 #define YYUNDEFTOK 2
1308 #define YYMAXUTOK 359
1309
1310 #define YYTRANSLATE(YYX) \
1311 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1312
1313 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1314 static const yytype_uint8 yytranslate[] =
1315 {
1316 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1317 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1318 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1319 2, 2, 2, 120, 2, 2, 2, 124, 125, 2,
1320 108, 109, 122, 118, 111, 119, 117, 123, 2, 2,
1321 2, 2, 2, 2, 2, 2, 2, 2, 110, 105,
1322 112, 114, 113, 128, 2, 2, 2, 2, 2, 2,
1323 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1324 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1325 2, 115, 2, 116, 126, 2, 2, 2, 2, 2,
1326 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1327 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1328 2, 2, 2, 106, 127, 107, 121, 2, 2, 2,
1329 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1330 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1331 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1332 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1333 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1334 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1335 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1336 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1337 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1338 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1339 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1340 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1341 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1342 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1343 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1344 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1345 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1346 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1347 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1348 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1349 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1350 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1351 95, 96, 97, 98, 99, 100, 101, 102, 103, 104
1352 };
1353
1354 #if YYDEBUG
1355 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1356 YYRHS. */
1357 static const yytype_uint16 yyprhs[] =
1358 {
1359 0, 0, 3, 4, 7, 10, 13, 16, 19, 23,
1360 25, 27, 34, 40, 42, 44, 46, 47, 50, 55,
1361 59, 62, 65, 73, 76, 81, 82, 84, 86, 87,
1362 90, 92, 95, 97, 101, 107, 108, 111, 113, 115,
1363 117, 119, 126, 135, 137, 139, 141, 143, 145, 147,
1364 149, 152, 154, 156, 158, 164, 169, 171, 175, 178,
1365 183, 184, 186, 188, 192, 196, 202, 203, 207, 208,
1366 211, 214, 217, 220, 223, 226, 229, 232, 235, 238,
1367 241, 243, 247, 252, 254, 256, 260, 262, 264, 266,
1368 269, 271, 273, 275, 277, 279, 281, 285, 291, 293,
1369 297, 303, 311, 320, 329, 331, 334, 336, 338, 340,
1370 342, 346, 348, 350, 353, 356, 360, 365, 371, 373,
1371 376, 379, 382, 389, 391, 393, 395, 397, 399, 403,
1372 407, 411, 413, 417, 421, 423, 427, 431, 433, 437,
1373 441, 445, 449, 451, 455, 459, 461, 465, 467, 471,
1374 473, 477, 479, 483, 485, 489, 491, 497, 499, 503,
1375 505, 507, 509, 511, 513, 515, 517, 519, 521, 523,
1376 525, 527
1377 };
1378
1379 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
1380 static const yytype_int16 yyrhs[] =
1381 {
1382 130, 0, -1, -1, 130, 139, -1, 130, 152, -1,
1383 130, 131, -1, 130, 105, -1, 98, 102, -1, 133,
1384 157, 105, -1, 134, -1, 135, -1, 161, 50, 136,
1385 106, 137, 107, -1, 161, 50, 106, 137, 107, -1,
1386 99, -1, 100, -1, 101, -1, -1, 137, 138, -1,
1387 161, 150, 158, 105, -1, 135, 158, 105, -1, 140,
1388 141, -1, 140, 105, -1, 161, 150, 143, 108, 145,
1389 109, 144, -1, 106, 107, -1, 106, 142, 166, 107,
1390 -1, -1, 99, -1, 101, -1, -1, 110, 136, -1,
1391 142, -1, 142, 146, -1, 147, -1, 146, 111, 147,
1392 -1, 148, 161, 150, 136, 144, -1, -1, 148, 149,
1393 -1, 23, -1, 29, -1, 25, -1, 151, -1, 68,
1394 112, 151, 111, 104, 113, -1, 26, 112, 151, 111,
1395 104, 111, 104, 113, -1, 70, -1, 38, -1, 39,
1396 -1, 40, -1, 41, -1, 42, -1, 100, -1, 50,
1397 100, -1, 156, -1, 132, -1, 153, -1, 66, 161,
1398 150, 154, 105, -1, 66, 133, 154, 105, -1, 155,
1399 -1, 154, 111, 155, -1, 136, 160, -1, 161, 150,
1400 158, 105, -1, -1, 158, -1, 159, -1, 158, 111,
1401 159, -1, 136, 160, 144, -1, 136, 160, 144, 114,
1402 162, -1, -1, 115, 191, 116, -1, -1, 17, 161,
1403 -1, 28, 161, -1, 32, 161, -1, 45, 161, -1,
1404 21, 161, -1, 48, 161, -1, 67, 161, -1, 71,
1405 161, -1, 9, 161, -1, 37, 161, -1, 7, 161,
1406 -1, 163, -1, 106, 164, 107, -1, 106, 164, 111,
1407 107, -1, 189, -1, 163, -1, 164, 111, 163, -1,
1408 65, -1, 18, -1, 167, -1, 166, 167, -1, 152,
1409 -1, 172, -1, 141, -1, 168, -1, 169, -1, 171,
1410 -1, 35, 191, 105, -1, 22, 108, 191, 109, 170,
1411 -1, 167, -1, 167, 16, 167, -1, 72, 108, 191,
1412 109, 167, -1, 14, 167, 72, 108, 191, 109, 105,
1413 -1, 19, 108, 142, 172, 172, 191, 109, 167, -1,
1414 19, 108, 142, 156, 172, 191, 109, 167, -1, 105,
1415 -1, 191, 105, -1, 103, -1, 104, -1, 165, -1,
1416 174, -1, 108, 191, 109, -1, 99, -1, 173, -1,
1417 175, 73, -1, 175, 74, -1, 175, 117, 136, -1,
1418 175, 115, 191, 116, -1, 161, 150, 108, 164, 109,
1419 -1, 175, -1, 73, 176, -1, 74, 176, -1, 177,
1420 176, -1, 108, 161, 150, 160, 109, 176, -1, 118,
1421 -1, 119, -1, 120, -1, 121, -1, 176, -1, 178,
1422 122, 176, -1, 178, 123, 176, -1, 178, 124, 176,
1423 -1, 178, -1, 179, 118, 178, -1, 179, 119, 178,
1424 -1, 179, -1, 180, 78, 179, -1, 180, 80, 179,
1425 -1, 180, -1, 181, 112, 180, -1, 181, 113, 180,
1426 -1, 181, 83, 180, -1, 181, 84, 180, -1, 181,
1427 -1, 182, 77, 181, -1, 182, 85, 181, -1, 182,
1428 -1, 183, 125, 182, -1, 183, -1, 184, 126, 183,
1429 -1, 184, -1, 185, 127, 184, -1, 185, -1, 186,
1430 75, 185, -1, 186, -1, 187, 76, 186, -1, 187,
1431 -1, 187, 128, 191, 110, 189, -1, 188, -1, 176,
1432 190, 189, -1, 114, -1, 86, -1, 87, -1, 88,
1433 -1, 89, -1, 90, -1, 79, -1, 81, -1, 91,
1434 -1, 92, -1, 93, -1, 189, -1, 191, 111, 189,
1435 -1
1436 };
1437
1438 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1439 static const yytype_uint16 yyrline[] =
1440 {
1441 0, 1022, 1022, 1024, 1061, 1065, 1068, 1073, 1092, 1109,
1442 1110, 1112, 1138, 1148, 1149, 1150, 1153, 1157, 1176, 1180,
1443 1185, 1192, 1199, 1224, 1229, 1236, 1240, 1241, 1244, 1247,
1444 1252, 1257, 1262, 1276, 1290, 1300, 1303, 1314, 1318, 1322,
1445 1327, 1331, 1350, 1370, 1374, 1379, 1384, 1389, 1394, 1399,
1446 1408, 1427, 1428, 1429, 1440, 1448, 1457, 1463, 1469, 1477,
1447 1483, 1486, 1491, 1497, 1503, 1511, 1523, 1526, 1534, 1537,
1448 1541, 1545, 1549, 1553, 1557, 1561, 1565, 1569, 1573, 1577,
1449 1582, 1588, 1592, 1597, 1602, 1608, 1614, 1618, 1623, 1627,
1450 1634, 1635, 1636, 1637, 1638, 1639, 1642, 1665, 1689, 1694,
1451 1700, 1715, 1730, 1738, 1750, 1755, 1763, 1777, 1791, 1805,
1452 1816, 1821, 1835, 1839, 1858, 1877, 1931, 1991, 2027, 2031,
1453 2047, 2063, 2083, 2115, 2119, 2123, 2127, 2132, 2136, 2143,
1454 2150, 2158, 2162, 2169, 2177, 2181, 2185, 2190, 2194, 2201,
1455 2208, 2215, 2223, 2227, 2234, 2242, 2246, 2251, 2255, 2260,
1456 2264, 2269, 2273, 2278, 2282, 2287, 2291, 2296, 2300, 2317,
1457 2321, 2325, 2329, 2333, 2337, 2341, 2345, 2349, 2353, 2357,
1458 2362, 2366
1459 };
1460 #endif
1461
1462 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1463 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1464 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1465 static const char *const yytname[] =
1466 {
1467 "$end", "error", "$undefined", "KW_BLENDSTATE", "KW_BREAK", "KW_BUFFER",
1468 "KW_CBUFFER", "KW_COLUMN_MAJOR", "KW_COMPILE", "KW_CONST", "KW_CONTINUE",
1469 "KW_DEPTHSTENCILSTATE", "KW_DEPTHSTENCILVIEW", "KW_DISCARD", "KW_DO",
1470 "KW_DOUBLE", "KW_ELSE", "KW_EXTERN", "KW_FALSE", "KW_FOR",
1471 "KW_GEOMETRYSHADER", "KW_GROUPSHARED", "KW_IF", "KW_IN", "KW_INLINE",
1472 "KW_INOUT", "KW_MATRIX", "KW_NAMESPACE", "KW_NOINTERPOLATION", "KW_OUT",
1473 "KW_PASS", "KW_PIXELSHADER", "KW_PRECISE", "KW_RASTERIZERSTATE",
1474 "KW_RENDERTARGETVIEW", "KW_RETURN", "KW_REGISTER", "KW_ROW_MAJOR",
1475 "KW_SAMPLER", "KW_SAMPLER1D", "KW_SAMPLER2D", "KW_SAMPLER3D",
1476 "KW_SAMPLERCUBE", "KW_SAMPLER_STATE", "KW_SAMPLERCOMPARISONSTATE",
1477 "KW_SHARED", "KW_STATEBLOCK", "KW_STATEBLOCK_STATE", "KW_STATIC",
1478 "KW_STRING", "KW_STRUCT", "KW_SWITCH", "KW_TBUFFER", "KW_TECHNIQUE",
1479 "KW_TECHNIQUE10", "KW_TEXTURE", "KW_TEXTURE1D", "KW_TEXTURE1DARRAY",
1480 "KW_TEXTURE2D", "KW_TEXTURE2DARRAY", "KW_TEXTURE2DMS",
1481 "KW_TEXTURE2DMSARRAY", "KW_TEXTURE3D", "KW_TEXTURE3DARRAY",
1482 "KW_TEXTURECUBE", "KW_TRUE", "KW_TYPEDEF", "KW_UNIFORM", "KW_VECTOR",
1483 "KW_VERTEXSHADER", "KW_VOID", "KW_VOLATILE", "KW_WHILE", "OP_INC",
1484 "OP_DEC", "OP_AND", "OP_OR", "OP_EQ", "OP_LEFTSHIFT",
1485 "OP_LEFTSHIFTASSIGN", "OP_RIGHTSHIFT", "OP_RIGHTSHIFTASSIGN",
1486 "OP_ELLIPSIS", "OP_LE", "OP_GE", "OP_NE", "OP_ADDASSIGN", "OP_SUBASSIGN",
1487 "OP_MULASSIGN", "OP_DIVASSIGN", "OP_MODASSIGN", "OP_ANDASSIGN",
1488 "OP_ORASSIGN", "OP_XORASSIGN", "OP_UNKNOWN1", "OP_UNKNOWN2",
1489 "OP_UNKNOWN3", "OP_UNKNOWN4", "PRE_LINE", "VAR_IDENTIFIER",
1490 "TYPE_IDENTIFIER", "NEW_IDENTIFIER", "STRING", "C_FLOAT", "C_INTEGER",
1491 "';'", "'{'", "'}'", "'('", "')'", "':'", "','", "'<'", "'>'", "'='",
1492 "'['", "']'", "'.'", "'+'", "'-'", "'!'", "'~'", "'*'", "'/'", "'%'",
1493 "'&'", "'^'", "'|'", "'?'", "$accept", "hlsl_prog", "preproc_directive",
1494 "struct_declaration", "struct_spec", "named_struct_spec",
1495 "unnamed_struct_spec", "any_identifier", "fields_list", "field",
1496 "func_declaration", "func_prototype", "compound_statement",
1497 "scope_start", "var_identifier", "semantic", "parameters", "param_list",
1498 "parameter", "input_mods", "input_mod", "type", "base_type",
1499 "declaration_statement", "typedef", "type_specs", "type_spec",
1500 "declaration", "variables_def_optional", "variables_def", "variable_def",
1501 "array", "var_modifiers", "complex_initializer", "initializer_expr",
1502 "initializer_expr_list", "boolean", "statement_list", "statement",
1503 "jump_statement", "selection_statement", "if_body", "loop_statement",
1504 "expr_statement", "primary_expr", "variable", "postfix_expr",
1505 "unary_expr", "unary_op", "mul_expr", "add_expr", "shift_expr",
1506 "relational_expr", "equality_expr", "bitand_expr", "bitxor_expr",
1507 "bitor_expr", "logicand_expr", "logicor_expr", "conditional_expr",
1508 "assignment_expr", "assign_op", "expr", 0
1509 };
1510 #endif
1511
1512 # ifdef YYPRINT
1513 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1514 token YYLEX-NUM. */
1515 static const yytype_uint16 yytoknum[] =
1516 {
1517 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1518 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1519 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1520 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1521 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1522 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1523 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1524 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1525 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1526 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1527 355, 356, 357, 358, 359, 59, 123, 125, 40, 41,
1528 58, 44, 60, 62, 61, 91, 93, 46, 43, 45,
1529 33, 126, 42, 47, 37, 38, 94, 124, 63
1530 };
1531 # endif
1532
1533 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1534 static const yytype_uint8 yyr1[] =
1535 {
1536 0, 129, 130, 130, 130, 130, 130, 131, 132, 133,
1537 133, 134, 135, 136, 136, 136, 137, 137, 138, 138,
1538 139, 139, 140, 141, 141, 142, 143, 143, 144, 144,
1539 145, 145, 146, 146, 147, 148, 148, 149, 149, 149,
1540 150, 150, 150, 151, 151, 151, 151, 151, 151, 151,
1541 151, 152, 152, 152, 153, 153, 154, 154, 155, 156,
1542 157, 157, 158, 158, 159, 159, 160, 160, 161, 161,
1543 161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
1544 162, 162, 162, 163, 164, 164, 165, 165, 166, 166,
1545 167, 167, 167, 167, 167, 167, 168, 169, 170, 170,
1546 171, 171, 171, 171, 172, 172, 173, 173, 173, 173,
1547 173, 174, 175, 175, 175, 175, 175, 175, 176, 176,
1548 176, 176, 176, 177, 177, 177, 177, 178, 178, 178,
1549 178, 179, 179, 179, 180, 180, 180, 181, 181, 181,
1550 181, 181, 182, 182, 182, 183, 183, 184, 184, 185,
1551 185, 186, 186, 187, 187, 188, 188, 189, 189, 190,
1552 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
1553 191, 191
1554 };
1555
1556 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1557 static const yytype_uint8 yyr2[] =
1558 {
1559 0, 2, 0, 2, 2, 2, 2, 2, 3, 1,
1560 1, 6, 5, 1, 1, 1, 0, 2, 4, 3,
1561 2, 2, 7, 2, 4, 0, 1, 1, 0, 2,
1562 1, 2, 1, 3, 5, 0, 2, 1, 1, 1,
1563 1, 6, 8, 1, 1, 1, 1, 1, 1, 1,
1564 2, 1, 1, 1, 5, 4, 1, 3, 2, 4,
1565 0, 1, 1, 3, 3, 5, 0, 3, 0, 2,
1566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1567 1, 3, 4, 1, 1, 3, 1, 1, 1, 2,
1568 1, 1, 1, 1, 1, 1, 3, 5, 1, 3,
1569 5, 7, 8, 8, 1, 2, 1, 1, 1, 1,
1570 3, 1, 1, 2, 2, 3, 4, 5, 1, 2,
1571 2, 2, 6, 1, 1, 1, 1, 1, 3, 3,
1572 3, 1, 3, 3, 1, 3, 3, 1, 3, 3,
1573 3, 3, 1, 3, 3, 1, 3, 1, 3, 1,
1574 3, 1, 3, 1, 3, 1, 5, 1, 3, 1,
1575 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1576 1, 3
1577 };
1578
1579 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
1580 Performed when YYTABLE doesn't specify something else to do. Zero
1581 means the default is an error. */
1582 static const yytype_uint8 yydefact[] =
1583 {
1584 2, 68, 1, 68, 68, 68, 68, 68, 68, 68,
1585 68, 68, 68, 68, 68, 0, 6, 5, 52, 60,
1586 9, 10, 3, 0, 4, 53, 51, 0, 79, 77,
1587 69, 73, 70, 71, 78, 72, 74, 0, 0, 75,
1588 76, 7, 13, 14, 15, 66, 0, 61, 62, 21,
1589 25, 20, 0, 44, 45, 46, 47, 48, 0, 0,
1590 43, 49, 0, 40, 66, 0, 56, 0, 68, 28,
1591 8, 0, 23, 68, 0, 50, 16, 0, 0, 13,
1592 15, 0, 0, 58, 55, 0, 0, 87, 86, 68,
1593 68, 111, 106, 107, 68, 123, 124, 125, 126, 0,
1594 108, 112, 109, 118, 127, 68, 131, 134, 137, 142,
1595 145, 147, 149, 151, 153, 155, 157, 170, 0, 0,
1596 64, 63, 68, 0, 0, 68, 0, 104, 92, 90,
1597 0, 68, 88, 93, 94, 95, 91, 0, 0, 0,
1598 68, 16, 0, 25, 59, 57, 54, 119, 120, 0,
1599 0, 0, 113, 114, 68, 0, 165, 166, 160, 161,
1600 162, 163, 164, 167, 168, 169, 159, 68, 121, 68,
1601 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
1602 68, 68, 68, 68, 68, 68, 68, 68, 68, 67,
1603 29, 68, 0, 25, 68, 0, 68, 0, 24, 89,
1604 105, 50, 0, 12, 0, 17, 0, 68, 0, 35,
1605 0, 66, 110, 68, 0, 115, 158, 128, 129, 130,
1606 127, 132, 133, 135, 136, 140, 141, 138, 139, 143,
1607 144, 146, 148, 150, 152, 154, 0, 171, 68, 65,
1608 80, 83, 0, 68, 0, 96, 0, 0, 0, 0,
1609 0, 11, 0, 31, 32, 68, 28, 0, 84, 0,
1610 116, 68, 0, 68, 68, 0, 68, 68, 68, 0,
1611 19, 0, 41, 35, 37, 39, 38, 36, 0, 22,
1612 68, 117, 68, 156, 81, 68, 0, 68, 68, 98,
1613 97, 100, 0, 18, 33, 0, 122, 85, 82, 0,
1614 0, 0, 68, 42, 28, 101, 68, 68, 99, 34,
1615 103, 102
1616 };
1617
1618 /* YYDEFGOTO[NTERM-NUM]. */
1619 static const yytype_int16 yydefgoto[] =
1620 {
1621 -1, 1, 17, 18, 19, 20, 21, 45, 140, 205,
1622 22, 23, 128, 73, 81, 120, 210, 253, 254, 255,
1623 277, 197, 63, 129, 25, 65, 66, 26, 46, 82,
1624 48, 69, 99, 239, 258, 259, 100, 131, 132, 133,
1625 134, 290, 135, 136, 101, 102, 103, 104, 105, 106,
1626 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1627 117, 167, 137
1628 };
1629
1630 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1631 STATE-NUM. */
1632 #define YYPACT_NINF -231
1633 static const yytype_int16 yypact[] =
1634 {
1635 -231, 640, -231, 777, 777, 777, 777, 777, 777, 777,
1636 777, 777, 777, 777, 777, -69, -231, -231, -231, 32,
1637 -231, -231, -231, 118, -231, -231, -231, 12, -231, -231,
1638 -231, -231, -231, -231, -231, -231, -231, 32, 12, -231,
1639 -231, -231, -231, -231, -231, -67, -41, -26, -231, -231,
1640 8, -231, -20, -231, -231, -231, -231, -231, -60, 14,
1641 -231, -231, 72, -231, -67, -81, -231, 32, 579, -39,
1642 -231, 32, -231, 320, 145, 28, -231, 34, 145, 15,
1643 35, 74, -15, -231, -231, 32, -10, -231, -231, 579,
1644 579, -231, -231, -231, 579, -231, -231, -231, -231, 37,
1645 -231, -231, -231, -18, 182, 579, 52, 86, -19, -55,
1646 -40, 66, 70, 90, 126, -44, -231, -231, 2, 32,
1647 127, -231, 320, 105, 124, 579, 135, -231, -231, -231,
1648 12, 212, -231, -231, -231, -231, -231, -7, 125, 137,
1649 684, -231, 141, -231, -231, -231, -231, -231, -231, 37,
1650 79, 147, -231, -231, 579, 32, -231, -231, -231, -231,
1651 -231, -231, -231, -231, -231, -231, -231, 579, -231, 579,
1652 579, 579, 579, 579, 579, 579, 579, 579, 579, 579,
1653 579, 579, 579, 579, 579, 579, 579, 579, 579, -231,
1654 -231, 399, 181, -231, 579, -5, 579, -65, -231, -231,
1655 -231, -231, 154, -231, 32, -231, 139, 716, 158, 155,
1656 167, -48, -231, 579, 11, -231, -231, -231, -231, -231,
1657 -231, 52, 52, 86, 86, -19, -19, -19, -19, -55,
1658 -55, -40, 66, 70, 90, 126, 117, -231, 579, -231,
1659 -231, -231, 174, 439, 83, -231, 88, 176, -2, 10,
1660 32, -231, 175, 178, -231, 745, -39, 183, -231, 99,
1661 -231, 579, 17, 579, 439, 37, 439, 320, 320, 186,
1662 -231, 9, -231, -231, -231, -231, -231, -231, 37, -231,
1663 579, -231, 579, -231, -231, 518, 103, 579, 579, 275,
1664 -231, -231, 180, -231, -231, 32, -231, -231, -231, 189,
1665 107, 111, 320, -231, -39, -231, 320, 320, -231, -231,
1666 -231, -231
1667 };
1668
1669 /* YYPGOTO[NTERM-NUM]. */
1670 static const yytype_int16 yypgoto[] =
1671 {
1672 -231, -231, -231, -231, 283, -231, -119, -36, 156, -231,
1673 -231, -231, 276, -123, -231, -230, -231, -231, 25, -231,
1674 -231, -13, 51, 299, -231, 235, 218, 61, -231, -4,
1675 236, -45, -1, -231, -174, 71, -231, -231, -104, -231,
1676 -231, -231, -231, -175, -231, -231, -231, -24, -231, 65,
1677 76, -9, 100, 128, 129, 130, 123, 136, -231, -231,
1678 -144, -231, -52
1679 };
1680
1681 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1682 positive, shift that token. If negative, reduce the rule which
1683 number is the opposite. If YYTABLE_NINF, syntax error. */
1684 #define YYTABLE_NINF -31
1685 static const yytype_int16 yytable[] =
1686 {
1687 27, 64, 28, 29, 30, 31, 32, 33, 34, 35,
1688 36, 38, 39, 40, 62, 47, 118, 240, 192, 83,
1689 209, 204, 77, 216, 84, 67, 279, 199, 176, 177,
1690 85, 64, 186, 41, 42, 43, 44, 180, 52, 42,
1691 75, 44, 150, 213, 237, 181, 76, 241, 68, 64,
1692 53, 54, 55, 56, 57, 152, 153, 178, 179, 174,
1693 213, 175, 58, 52, 70, 147, 148, 68, 266, 241,
1694 243, 119, 130, 195, 309, 53, 54, 55, 56, 57,
1695 59, 168, 60, 190, 187, 71, 151, 138, 204, 287,
1696 144, 288, 74, 149, 241, 146, 71, 154, 200, 155,
1697 245, 85, 214, 270, 188, 59, 188, 60, 297, 71,
1698 201, 297, 61, 188, 293, 72, 76, 283, 189, 215,
1699 71, 130, 188, -26, 284, 139, 78, 260, 285, 142,
1700 130, 42, 43, 44, -14, 236, 211, 61, 241, 206,
1701 141, 241, 244, -27, 246, 217, 218, 219, 220, 220,
1702 220, 220, 220, 220, 220, 220, 220, 220, 220, 220,
1703 220, 220, 220, 289, 291, 52, 257, 225, 226, 227,
1704 228, 79, 43, 80, 169, 170, 171, 53, 54, 55,
1705 56, 57, 143, 53, 54, 55, 56, 57, 212, 249,
1706 188, 182, 267, 250, 188, 138, 183, 268, 308, 188,
1707 248, 185, 310, 311, 172, 173, 206, 59, 281, 60,
1708 282, 286, 299, 193, 188, 60, 306, 184, 188, 3,
1709 307, 4, 188, 49, 50, 201, 122, 261, 188, 5,
1710 87, 123, 194, 6, 124, 300, 301, 221, 222, 61,
1711 7, 191, 265, 196, 8, 61, 271, 125, 202, 9,
1712 223, 224, 208, 242, 278, 213, 296, 10, 247, 304,
1713 11, 156, 252, 157, -30, 295, 130, 130, 158, 159,
1714 160, 161, 162, 163, 164, 165, 256, 88, 12, 13,
1715 229, 230, 263, 14, 126, 89, 90, 269, 272, 273,
1716 292, 302, 280, 303, 305, 37, 166, 207, 294, 51,
1717 24, 130, 86, 145, 264, 130, 130, 121, 234, 262,
1718 231, 91, 232, 0, 233, 92, 93, 127, 50, 198,
1719 94, 0, 235, 0, 0, 0, 0, 3, 0, 4,
1720 95, 96, 97, 98, 122, 0, 0, 5, 87, 123,
1721 0, 6, 124, 0, 0, 0, 0, 0, 7, 0,
1722 0, 0, 8, 0, 0, 125, 0, 9, 0, 0,
1723 0, 0, 0, 0, 0, 10, 0, 0, 11, 0,
1724 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1725 0, 0, 0, 0, 0, 88, 12, 13, 0, 0,
1726 0, 14, 126, 89, 90, 0, 0, 0, 0, 0,
1727 0, 0, 0, 0, 0, 0, 3, 0, 4, 0,
1728 0, 0, 0, 0, 0, 0, 5, 87, 0, 91,
1729 6, 0, 0, 92, 93, 127, 50, 7, 94, 0,
1730 0, 8, 0, 0, 0, 0, 9, 0, 95, 96,
1731 97, 98, 0, 0, 10, 0, 3, 11, 4, 0,
1732 0, 0, 0, 0, 0, 0, 5, 87, 0, 0,
1733 6, 0, 0, 0, 88, 0, 13, 7, 0, 0,
1734 14, 8, 89, 90, 0, 0, 9, 0, 0, 0,
1735 0, 0, 0, 0, 10, 0, 0, 11, 0, 0,
1736 0, 0, 0, 0, 0, 0, 0, 0, 91, 0,
1737 0, 0, 92, 93, 88, 238, 13, 94, 0, 0,
1738 14, 0, 89, 90, 0, 0, 0, 95, 96, 97,
1739 98, 0, 0, 0, 0, 3, 0, 4, 0, 0,
1740 0, 0, 0, 0, 0, 5, 87, 0, 91, 6,
1741 0, 0, 92, 93, 127, 0, 7, 94, 0, 0,
1742 8, 0, 0, 0, 0, 9, 0, 95, 96, 97,
1743 98, 0, 0, 10, 0, 0, 11, 0, 0, 0,
1744 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1745 0, 0, 0, 88, 0, 13, 3, 0, 4, 14,
1746 0, 89, 90, 0, 0, 0, 5, 87, 0, 0,
1747 6, 0, 0, 0, 0, 0, 0, 7, 0, 0,
1748 0, 8, 0, 0, 0, 0, 9, 91, 0, 0,
1749 0, 92, 93, 0, 10, 298, 94, 11, 0, 0,
1750 0, 0, 0, 0, 0, 0, 95, 96, 97, 98,
1751 2, 0, 0, 0, 88, 0, 13, 3, 0, 4,
1752 14, 0, 89, 90, 0, 0, 0, 5, 0, 0,
1753 0, 6, 0, 0, 0, 0, 0, 0, 7, 0,
1754 0, 0, 8, 0, 0, 0, 0, 9, 91, 0,
1755 0, 0, 92, 93, 0, 10, 0, 94, 11, 0,
1756 0, 3, 0, 4, 0, 0, 0, 95, 96, 97,
1757 98, 5, 0, 0, 0, 6, 12, 13, 0, 0,
1758 0, 14, 7, 0, 0, 0, 8, 0, 0, 0,
1759 0, 9, 0, 3, 0, 4, 0, 0, 0, 10,
1760 0, 0, 11, 5, 0, 0, 0, 6, 15, 0,
1761 0, 0, 0, 0, 7, 16, 0, 0, 8, 0,
1762 0, 13, 3, 9, 4, 14, 0, 0, 0, 0,
1763 0, 10, 5, 0, 11, 0, 6, 0, 274, 0,
1764 275, 0, 0, 7, 276, 0, 0, 8, 0, 0,
1765 0, 0, 9, 13, 3, 0, 4, 14, 0, 0,
1766 10, 203, 0, 11, 5, 0, 0, 0, 6, 0,
1767 0, 0, 0, 0, 0, 7, 0, 0, 0, 8,
1768 0, 0, 13, 0, 9, 0, 14, 0, 0, 0,
1769 0, 0, 10, 251, 0, 11, 0, 0, 0, 0,
1770 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1771 0, 0, 0, 0, 13, 0, 0, 0, 14
1772 };
1773
1774 #define yypact_value_is_default(yystate) \
1775 ((yystate) == (-231))
1776
1777 #define yytable_value_is_error(yytable_value) \
1778 YYID (0)
1779
1780 static const yytype_int16 yycheck[] =
1781 {
1782 1, 37, 3, 4, 5, 6, 7, 8, 9, 10,
1783 11, 12, 13, 14, 27, 19, 68, 191, 122, 64,
1784 143, 140, 58, 167, 105, 38, 256, 131, 83, 84,
1785 111, 67, 76, 102, 99, 100, 101, 77, 26, 99,
1786 100, 101, 94, 108, 188, 85, 106, 191, 115, 85,
1787 38, 39, 40, 41, 42, 73, 74, 112, 113, 78,
1788 108, 80, 50, 26, 105, 89, 90, 115, 243, 213,
1789 193, 110, 73, 125, 304, 38, 39, 40, 41, 42,
1790 68, 105, 70, 119, 128, 111, 99, 50, 207, 264,
1791 105, 266, 112, 94, 238, 105, 111, 115, 105, 117,
1792 105, 111, 154, 105, 111, 68, 111, 70, 282, 111,
1793 100, 285, 100, 111, 105, 107, 106, 261, 116, 155,
1794 111, 122, 111, 108, 107, 74, 112, 116, 111, 78,
1795 131, 99, 100, 101, 106, 187, 149, 100, 282, 140,
1796 106, 285, 194, 108, 196, 169, 170, 171, 172, 173,
1797 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
1798 184, 185, 186, 267, 268, 26, 211, 176, 177, 178,
1799 179, 99, 100, 101, 122, 123, 124, 38, 39, 40,
1800 41, 42, 108, 38, 39, 40, 41, 42, 109, 50,
1801 111, 125, 109, 206, 111, 50, 126, 109, 302, 111,
1802 204, 75, 306, 307, 118, 119, 207, 68, 109, 70,
1803 111, 263, 109, 108, 111, 70, 109, 127, 111, 7,
1804 109, 9, 111, 105, 106, 100, 14, 110, 111, 17,
1805 18, 19, 108, 21, 22, 287, 288, 172, 173, 100,
1806 28, 114, 243, 108, 32, 100, 250, 35, 111, 37,
1807 174, 175, 111, 72, 255, 108, 280, 45, 104, 295,
1808 48, 79, 104, 81, 109, 278, 267, 268, 86, 87,
1809 88, 89, 90, 91, 92, 93, 109, 65, 66, 67,
1810 180, 181, 108, 71, 72, 73, 74, 111, 113, 111,
1811 104, 16, 109, 113, 105, 12, 114, 141, 273, 23,
1812 1, 302, 67, 85, 243, 306, 307, 71, 185, 238,
1813 182, 99, 183, -1, 184, 103, 104, 105, 106, 107,
1814 108, -1, 186, -1, -1, -1, -1, 7, -1, 9,
1815 118, 119, 120, 121, 14, -1, -1, 17, 18, 19,
1816 -1, 21, 22, -1, -1, -1, -1, -1, 28, -1,
1817 -1, -1, 32, -1, -1, 35, -1, 37, -1, -1,
1818 -1, -1, -1, -1, -1, 45, -1, -1, 48, -1,
1819 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1820 -1, -1, -1, -1, -1, 65, 66, 67, -1, -1,
1821 -1, 71, 72, 73, 74, -1, -1, -1, -1, -1,
1822 -1, -1, -1, -1, -1, -1, 7, -1, 9, -1,
1823 -1, -1, -1, -1, -1, -1, 17, 18, -1, 99,
1824 21, -1, -1, 103, 104, 105, 106, 28, 108, -1,
1825 -1, 32, -1, -1, -1, -1, 37, -1, 118, 119,
1826 120, 121, -1, -1, 45, -1, 7, 48, 9, -1,
1827 -1, -1, -1, -1, -1, -1, 17, 18, -1, -1,
1828 21, -1, -1, -1, 65, -1, 67, 28, -1, -1,
1829 71, 32, 73, 74, -1, -1, 37, -1, -1, -1,
1830 -1, -1, -1, -1, 45, -1, -1, 48, -1, -1,
1831 -1, -1, -1, -1, -1, -1, -1, -1, 99, -1,
1832 -1, -1, 103, 104, 65, 106, 67, 108, -1, -1,
1833 71, -1, 73, 74, -1, -1, -1, 118, 119, 120,
1834 121, -1, -1, -1, -1, 7, -1, 9, -1, -1,
1835 -1, -1, -1, -1, -1, 17, 18, -1, 99, 21,
1836 -1, -1, 103, 104, 105, -1, 28, 108, -1, -1,
1837 32, -1, -1, -1, -1, 37, -1, 118, 119, 120,
1838 121, -1, -1, 45, -1, -1, 48, -1, -1, -1,
1839 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1840 -1, -1, -1, 65, -1, 67, 7, -1, 9, 71,
1841 -1, 73, 74, -1, -1, -1, 17, 18, -1, -1,
1842 21, -1, -1, -1, -1, -1, -1, 28, -1, -1,
1843 -1, 32, -1, -1, -1, -1, 37, 99, -1, -1,
1844 -1, 103, 104, -1, 45, 107, 108, 48, -1, -1,
1845 -1, -1, -1, -1, -1, -1, 118, 119, 120, 121,
1846 0, -1, -1, -1, 65, -1, 67, 7, -1, 9,
1847 71, -1, 73, 74, -1, -1, -1, 17, -1, -1,
1848 -1, 21, -1, -1, -1, -1, -1, -1, 28, -1,
1849 -1, -1, 32, -1, -1, -1, -1, 37, 99, -1,
1850 -1, -1, 103, 104, -1, 45, -1, 108, 48, -1,
1851 -1, 7, -1, 9, -1, -1, -1, 118, 119, 120,
1852 121, 17, -1, -1, -1, 21, 66, 67, -1, -1,
1853 -1, 71, 28, -1, -1, -1, 32, -1, -1, -1,
1854 -1, 37, -1, 7, -1, 9, -1, -1, -1, 45,
1855 -1, -1, 48, 17, -1, -1, -1, 21, 98, -1,
1856 -1, -1, -1, -1, 28, 105, -1, -1, 32, -1,
1857 -1, 67, 7, 37, 9, 71, -1, -1, -1, -1,
1858 -1, 45, 17, -1, 48, -1, 21, -1, 23, -1,
1859 25, -1, -1, 28, 29, -1, -1, 32, -1, -1,
1860 -1, -1, 37, 67, 7, -1, 9, 71, -1, -1,
1861 45, 107, -1, 48, 17, -1, -1, -1, 21, -1,
1862 -1, -1, -1, -1, -1, 28, -1, -1, -1, 32,
1863 -1, -1, 67, -1, 37, -1, 71, -1, -1, -1,
1864 -1, -1, 45, 107, -1, 48, -1, -1, -1, -1,
1865 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1866 -1, -1, -1, -1, 67, -1, -1, -1, 71
1867 };
1868
1869 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1870 symbol of state STATE-NUM. */
1871 static const yytype_uint8 yystos[] =
1872 {
1873 0, 130, 0, 7, 9, 17, 21, 28, 32, 37,
1874 45, 48, 66, 67, 71, 98, 105, 131, 132, 133,
1875 134, 135, 139, 140, 152, 153, 156, 161, 161, 161,
1876 161, 161, 161, 161, 161, 161, 161, 133, 161, 161,
1877 161, 102, 99, 100, 101, 136, 157, 158, 159, 105,
1878 106, 141, 26, 38, 39, 40, 41, 42, 50, 68,
1879 70, 100, 150, 151, 136, 154, 155, 150, 115, 160,
1880 105, 111, 107, 142, 112, 100, 106, 136, 112, 99,
1881 101, 143, 158, 160, 105, 111, 154, 18, 65, 73,
1882 74, 99, 103, 104, 108, 118, 119, 120, 121, 161,
1883 165, 173, 174, 175, 176, 177, 178, 179, 180, 181,
1884 182, 183, 184, 185, 186, 187, 188, 189, 191, 110,
1885 144, 159, 14, 19, 22, 35, 72, 105, 141, 152,
1886 161, 166, 167, 168, 169, 171, 172, 191, 50, 151,
1887 137, 106, 151, 108, 105, 155, 105, 176, 176, 161,
1888 191, 150, 73, 74, 115, 117, 79, 81, 86, 87,
1889 88, 89, 90, 91, 92, 93, 114, 190, 176, 122,
1890 123, 124, 118, 119, 78, 80, 83, 84, 112, 113,
1891 77, 85, 125, 126, 127, 75, 76, 128, 111, 116,
1892 136, 114, 167, 108, 108, 191, 108, 150, 107, 167,
1893 105, 100, 111, 107, 135, 138, 161, 137, 111, 142,
1894 145, 150, 109, 108, 191, 136, 189, 176, 176, 176,
1895 176, 178, 178, 179, 179, 180, 180, 180, 180, 181,
1896 181, 182, 183, 184, 185, 186, 191, 189, 106, 162,
1897 163, 189, 72, 142, 191, 105, 191, 104, 158, 50,
1898 150, 107, 104, 146, 147, 148, 109, 160, 163, 164,
1899 116, 110, 164, 108, 156, 161, 172, 109, 109, 111,
1900 105, 158, 113, 111, 23, 25, 29, 149, 161, 144,
1901 109, 109, 111, 189, 107, 111, 191, 172, 172, 167,
1902 170, 167, 104, 105, 147, 150, 176, 163, 107, 109,
1903 191, 191, 16, 113, 136, 105, 109, 109, 167, 144,
1904 167, 167
1905 };
1906
1907 #define yyerrok (yyerrstatus = 0)
1908 #define yyclearin (yychar = YYEMPTY)
1909 #define YYEMPTY (-2)
1910 #define YYEOF 0
1911
1912 #define YYACCEPT goto yyacceptlab
1913 #define YYABORT goto yyabortlab
1914 #define YYERROR goto yyerrorlab
1915
1916
1917 /* Like YYERROR except do call yyerror. This remains here temporarily
1918 to ease the transition to the new meaning of YYERROR, for GCC.
1919 Once GCC version 2 has supplanted version 1, this can go. However,
1920 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
1921 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
1922 discussed. */
1923
1924 #define YYFAIL goto yyerrlab
1925 #if defined YYFAIL
1926 /* This is here to suppress warnings from the GCC cpp's
1927 -Wunused-macros. Normally we don't worry about that warning, but
1928 some users do, and we want to make it easy for users to remove
1929 YYFAIL uses, which will produce warnings from Bison 2.5. */
1930 #endif
1931
1932 #define YYRECOVERING() (!!yyerrstatus)
1933
1934 #define YYBACKUP(Token, Value) \
1935 do \
1936 if (yychar == YYEMPTY && yylen == 1) \
1937 { \
1938 yychar = (Token); \
1939 yylval = (Value); \
1940 YYPOPSTACK (1); \
1941 goto yybackup; \
1942 } \
1943 else \
1944 { \
1945 yyerror (YY_("syntax error: cannot back up")); \
1946 YYERROR; \
1947 } \
1948 while (YYID (0))
1949
1950
1951 #define YYTERROR 1
1952 #define YYERRCODE 256
1953
1954
1955 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
1956 If N is 0, then set CURRENT to the empty location which ends
1957 the previous symbol: RHS[0] (always defined). */
1958
1959 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
1960 #ifndef YYLLOC_DEFAULT
1961 # define YYLLOC_DEFAULT(Current, Rhs, N) \
1962 do \
1963 if (YYID (N)) \
1964 { \
1965 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
1966 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
1967 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
1968 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
1969 } \
1970 else \
1971 { \
1972 (Current).first_line = (Current).last_line = \
1973 YYRHSLOC (Rhs, 0).last_line; \
1974 (Current).first_column = (Current).last_column = \
1975 YYRHSLOC (Rhs, 0).last_column; \
1976 } \
1977 while (YYID (0))
1978 #endif
1979
1980
1981 /* YY_LOCATION_PRINT -- Print the location on the stream.
1982 This macro was not mandated originally: define only if we know
1983 we won't break user code: when these are the locations we know. */
1984
1985 #ifndef YY_LOCATION_PRINT
1986 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1987 # define YY_LOCATION_PRINT(File, Loc) \
1988 fprintf (File, "%d.%d-%d.%d", \
1989 (Loc).first_line, (Loc).first_column, \
1990 (Loc).last_line, (Loc).last_column)
1991 # else
1992 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1993 # endif
1994 #endif
1995
1996
1997 /* YYLEX -- calling `yylex' with the right arguments. */
1998
1999 #ifdef YYLEX_PARAM
2000 # define YYLEX yylex (YYLEX_PARAM)
2001 #else
2002 # define YYLEX yylex ()
2003 #endif
2004
2005 /* Enable debugging if requested. */
2006 #if YYDEBUG
2007
2008 # ifndef YYFPRINTF
2009 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2010 # define YYFPRINTF fprintf
2011 # endif
2012
2013 # define YYDPRINTF(Args) \
2014 do { \
2015 if (yydebug) \
2016 YYFPRINTF Args; \
2017 } while (YYID (0))
2018
2019 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2020 do { \
2021 if (yydebug) \
2022 { \
2023 YYFPRINTF (stderr, "%s ", Title); \
2024 yy_symbol_print (stderr, \
2025 Type, Value, Location); \
2026 YYFPRINTF (stderr, "\n"); \
2027 } \
2028 } while (YYID (0))
2029
2030
2031 /*--------------------------------.
2032 | Print this symbol on YYOUTPUT. |
2033 `--------------------------------*/
2034
2035 /*ARGSUSED*/
2036 #if (defined __STDC__ || defined __C99__FUNC__ \
2037 || defined __cplusplus || defined _MSC_VER)
2038 static void
2039 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
2040 #else
2041 static void
2042 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
2043 FILE *yyoutput;
2044 int yytype;
2045 YYSTYPE const * const yyvaluep;
2046 YYLTYPE const * const yylocationp;
2047 #endif
2048 {
2049 if (!yyvaluep)
2050 return;
2051 YYUSE (yylocationp);
2052 # ifdef YYPRINT
2053 if (yytype < YYNTOKENS)
2054 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2055 # else
2056 YYUSE (yyoutput);
2057 # endif
2058 switch (yytype)
2059 {
2060 default:
2061 break;
2062 }
2063 }
2064
2065
2066 /*--------------------------------.
2067 | Print this symbol on YYOUTPUT. |
2068 `--------------------------------*/
2069
2070 #if (defined __STDC__ || defined __C99__FUNC__ \
2071 || defined __cplusplus || defined _MSC_VER)
2072 static void
2073 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
2074 #else
2075 static void
2076 yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp)
2077 FILE *yyoutput;
2078 int yytype;
2079 YYSTYPE const * const yyvaluep;
2080 YYLTYPE const * const yylocationp;
2081 #endif
2082 {
2083 if (yytype < YYNTOKENS)
2084 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2085 else
2086 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2087
2088 YY_LOCATION_PRINT (yyoutput, *yylocationp);
2089 YYFPRINTF (yyoutput, ": ");
2090 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
2091 YYFPRINTF (yyoutput, ")");
2092 }
2093
2094 /*------------------------------------------------------------------.
2095 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
2096 | TOP (included). |
2097 `------------------------------------------------------------------*/
2098
2099 #if (defined __STDC__ || defined __C99__FUNC__ \
2100 || defined __cplusplus || defined _MSC_VER)
2101 static void
2102 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
2103 #else
2104 static void
2105 yy_stack_print (yybottom, yytop)
2106 yytype_int16 *yybottom;
2107 yytype_int16 *yytop;
2108 #endif
2109 {
2110 YYFPRINTF (stderr, "Stack now");
2111 for (; yybottom <= yytop; yybottom++)
2112 {
2113 int yybot = *yybottom;
2114 YYFPRINTF (stderr, " %d", yybot);
2115 }
2116 YYFPRINTF (stderr, "\n");
2117 }
2118
2119 # define YY_STACK_PRINT(Bottom, Top) \
2120 do { \
2121 if (yydebug) \
2122 yy_stack_print ((Bottom), (Top)); \
2123 } while (YYID (0))
2124
2125
2126 /*------------------------------------------------.
2127 | Report that the YYRULE is going to be reduced. |
2128 `------------------------------------------------*/
2129
2130 #if (defined __STDC__ || defined __C99__FUNC__ \
2131 || defined __cplusplus || defined _MSC_VER)
2132 static void
2133 yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
2134 #else
2135 static void
2136 yy_reduce_print (yyvsp, yylsp, yyrule)
2137 YYSTYPE *yyvsp;
2138 YYLTYPE *yylsp;
2139 int yyrule;
2140 #endif
2141 {
2142 int yynrhs = yyr2[yyrule];
2143 int yyi;
2144 unsigned long int yylno = yyrline[yyrule];
2145 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2146 yyrule - 1, yylno);
2147 /* The symbols being reduced. */
2148 for (yyi = 0; yyi < yynrhs; yyi++)
2149 {
2150 YYFPRINTF (stderr, " $%d = ", yyi + 1);
2151 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2152 &(yyvsp[(yyi + 1) - (yynrhs)])
2153 , &(yylsp[(yyi + 1) - (yynrhs)]) );
2154 YYFPRINTF (stderr, "\n");
2155 }
2156 }
2157
2158 # define YY_REDUCE_PRINT(Rule) \
2159 do { \
2160 if (yydebug) \
2161 yy_reduce_print (yyvsp, yylsp, Rule); \
2162 } while (YYID (0))
2163
2164 /* Nonzero means print parse trace. It is left uninitialized so that
2165 multiple parsers can coexist. */
2166 int yydebug;
2167 #else /* !YYDEBUG */
2168 # define YYDPRINTF(Args)
2169 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2170 # define YY_STACK_PRINT(Bottom, Top)
2171 # define YY_REDUCE_PRINT(Rule)
2172 #endif /* !YYDEBUG */
2173
2174
2175 /* YYINITDEPTH -- initial size of the parser's stacks. */
2176 #ifndef YYINITDEPTH
2177 # define YYINITDEPTH 200
2178 #endif
2179
2180 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2181 if the built-in stack extension method is used).
2182
2183 Do not make this value too large; the results are undefined if
2184 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2185 evaluated with infinite-precision integer arithmetic. */
2186
2187 #ifndef YYMAXDEPTH
2188 # define YYMAXDEPTH 10000
2189 #endif
2190
2191
2192 #if YYERROR_VERBOSE
2193
2194 # ifndef yystrlen
2195 # if defined __GLIBC__ && defined _STRING_H
2196 # define yystrlen strlen
2197 # else
2198 /* Return the length of YYSTR. */
2199 #if (defined __STDC__ || defined __C99__FUNC__ \
2200 || defined __cplusplus || defined _MSC_VER)
2201 static YYSIZE_T
2202 yystrlen (const char *yystr)
2203 #else
2204 static YYSIZE_T
2205 yystrlen (yystr)
2206 const char *yystr;
2207 #endif
2208 {
2209 YYSIZE_T yylen;
2210 for (yylen = 0; yystr[yylen]; yylen++)
2211 continue;
2212 return yylen;
2213 }
2214 # endif
2215 # endif
2216
2217 # ifndef yystpcpy
2218 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2219 # define yystpcpy stpcpy
2220 # else
2221 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2222 YYDEST. */
2223 #if (defined __STDC__ || defined __C99__FUNC__ \
2224 || defined __cplusplus || defined _MSC_VER)
2225 static char *
2226 yystpcpy (char *yydest, const char *yysrc)
2227 #else
2228 static char *
2229 yystpcpy (yydest, yysrc)
2230 char *yydest;
2231 const char *yysrc;
2232 #endif
2233 {
2234 char *yyd = yydest;
2235 const char *yys = yysrc;
2236
2237 while ((*yyd++ = *yys++) != '\0')
2238 continue;
2239
2240 return yyd - 1;
2241 }
2242 # endif
2243 # endif
2244
2245 # ifndef yytnamerr
2246 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2247 quotes and backslashes, so that it's suitable for yyerror. The
2248 heuristic is that double-quoting is unnecessary unless the string
2249 contains an apostrophe, a comma, or backslash (other than
2250 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2251 null, do not copy; instead, return the length of what the result
2252 would have been. */
2253 static YYSIZE_T
2254 yytnamerr (char *yyres, const char *yystr)
2255 {
2256 if (*yystr == '"')
2257 {
2258 YYSIZE_T yyn = 0;
2259 char const *yyp = yystr;
2260
2261 for (;;)
2262 switch (*++yyp)
2263 {
2264 case '\'':
2265 case ',':
2266 goto do_not_strip_quotes;
2267
2268 case '\\':
2269 if (*++yyp != '\\')
2270 goto do_not_strip_quotes;
2271 /* Fall through. */
2272 default:
2273 if (yyres)
2274 yyres[yyn] = *yyp;
2275 yyn++;
2276 break;
2277
2278 case '"':
2279 if (yyres)
2280 yyres[yyn] = '\0';
2281 return yyn;
2282 }
2283 do_not_strip_quotes: ;
2284 }
2285
2286 if (! yyres)
2287 return yystrlen (yystr);
2288
2289 return yystpcpy (yyres, yystr) - yyres;
2290 }
2291 # endif
2292
2293 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
2294 about the unexpected token YYTOKEN for the state stack whose top is
2295 YYSSP.
2296
2297 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
2298 not large enough to hold the message. In that case, also set
2299 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
2300 required number of bytes is too large to store. */
2301 static int
2302 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
2303 yytype_int16 *yyssp, int yytoken)
2304 {
2305 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
2306 YYSIZE_T yysize = yysize0;
2307 YYSIZE_T yysize1;
2308 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
2309 /* Internationalized format string. */
2310 const char *yyformat = 0;
2311 /* Arguments of yyformat. */
2312 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
2313 /* Number of reported tokens (one for the "unexpected", one per
2314 "expected"). */
2315 int yycount = 0;
2316
2317 /* There are many possibilities here to consider:
2318 - Assume YYFAIL is not used. It's too flawed to consider. See
2319 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
2320 for details. YYERROR is fine as it does not invoke this
2321 function.
2322 - If this state is a consistent state with a default action, then
2323 the only way this function was invoked is if the default action
2324 is an error action. In that case, don't check for expected
2325 tokens because there are none.
2326 - The only way there can be no lookahead present (in yychar) is if
2327 this state is a consistent state with a default action. Thus,
2328 detecting the absence of a lookahead is sufficient to determine
2329 that there is no unexpected or expected token to report. In that
2330 case, just report a simple "syntax error".
2331 - Don't assume there isn't a lookahead just because this state is a
2332 consistent state with a default action. There might have been a
2333 previous inconsistent state, consistent state with a non-default
2334 action, or user semantic action that manipulated yychar.
2335 - Of course, the expected token list depends on states to have
2336 correct lookahead information, and it depends on the parser not
2337 to perform extra reductions after fetching a lookahead from the
2338 scanner and before detecting a syntax error. Thus, state merging
2339 (from LALR or IELR) and default reductions corrupt the expected
2340 token list. However, the list is correct for canonical LR with
2341 one exception: it will still contain any token that will not be
2342 accepted due to an error action in a later state.
2343 */
2344 if (yytoken != YYEMPTY)
2345 {
2346 int yyn = yypact[*yyssp];
2347 yyarg[yycount++] = yytname[yytoken];
2348 if (!yypact_value_is_default (yyn))
2349 {
2350 /* Start YYX at -YYN if negative to avoid negative indexes in
2351 YYCHECK. In other words, skip the first -YYN actions for
2352 this state because they are default actions. */
2353 int yyxbegin = yyn < 0 ? -yyn : 0;
2354 /* Stay within bounds of both yycheck and yytname. */
2355 int yychecklim = YYLAST - yyn + 1;
2356 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2357 int yyx;
2358
2359 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2360 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
2361 && !yytable_value_is_error (yytable[yyx + yyn]))
2362 {
2363 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
2364 {
2365 yycount = 1;
2366 yysize = yysize0;
2367 break;
2368 }
2369 yyarg[yycount++] = yytname[yyx];
2370 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
2371 if (! (yysize <= yysize1
2372 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
2373 return 2;
2374 yysize = yysize1;
2375 }
2376 }
2377 }
2378
2379 switch (yycount)
2380 {
2381 # define YYCASE_(N, S) \
2382 case N: \
2383 yyformat = S; \
2384 break
2385 YYCASE_(0, YY_("syntax error"));
2386 YYCASE_(1, YY_("syntax error, unexpected %s"));
2387 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
2388 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
2389 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
2390 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
2391 # undef YYCASE_
2392 }
2393
2394 yysize1 = yysize + yystrlen (yyformat);
2395 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
2396 return 2;
2397 yysize = yysize1;
2398
2399 if (*yymsg_alloc < yysize)
2400 {
2401 *yymsg_alloc = 2 * yysize;
2402 if (! (yysize <= *yymsg_alloc
2403 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
2404 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
2405 return 1;
2406 }
2407
2408 /* Avoid sprintf, as that infringes on the user's name space.
2409 Don't have undefined behavior even if the translation
2410 produced a string with the wrong number of "%s"s. */
2411 {
2412 char *yyp = *yymsg;
2413 int yyi = 0;
2414 while ((*yyp = *yyformat) != '\0')
2415 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
2416 {
2417 yyp += yytnamerr (yyp, yyarg[yyi++]);
2418 yyformat += 2;
2419 }
2420 else
2421 {
2422 yyp++;
2423 yyformat++;
2424 }
2425 }
2426 return 0;
2427 }
2428 #endif /* YYERROR_VERBOSE */
2429
2430 /*-----------------------------------------------.
2431 | Release the memory associated to this symbol. |
2432 `-----------------------------------------------*/
2433
2434 /*ARGSUSED*/
2435 #if (defined __STDC__ || defined __C99__FUNC__ \
2436 || defined __cplusplus || defined _MSC_VER)
2437 static void
2438 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
2439 #else
2440 static void
2441 yydestruct (yymsg, yytype, yyvaluep, yylocationp)
2442 const char *yymsg;
2443 int yytype;
2444 YYSTYPE *yyvaluep;
2445 YYLTYPE *yylocationp;
2446 #endif
2447 {
2448 YYUSE (yyvaluep);
2449 YYUSE (yylocationp);
2450
2451 if (!yymsg)
2452 yymsg = "Deleting";
2453 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2454
2455 switch (yytype)
2456 {
2457
2458 default:
2459 break;
2460 }
2461 }
2462
2463
2464 /* Prevent warnings from -Wmissing-prototypes. */
2465 #ifdef YYPARSE_PARAM
2466 #if defined __STDC__ || defined __cplusplus
2467 int yyparse (void *YYPARSE_PARAM);
2468 #else
2469 int yyparse ();
2470 #endif
2471 #else /* ! YYPARSE_PARAM */
2472 #if defined __STDC__ || defined __cplusplus
2473 int yyparse (void);
2474 #else
2475 int yyparse ();
2476 #endif
2477 #endif /* ! YYPARSE_PARAM */
2478
2479
2480 /* The lookahead symbol. */
2481 int yychar;
2482
2483 /* The semantic value of the lookahead symbol. */
2484 YYSTYPE yylval;
2485
2486 /* Location data for the lookahead symbol. */
2487 YYLTYPE yylloc;
2488
2489 /* Number of syntax errors so far. */
2490 int yynerrs;
2491
2492
2493 /*----------.
2494 | yyparse. |
2495 `----------*/
2496
2497 #ifdef YYPARSE_PARAM
2498 #if (defined __STDC__ || defined __C99__FUNC__ \
2499 || defined __cplusplus || defined _MSC_VER)
2500 int
2501 yyparse (void *YYPARSE_PARAM)
2502 #else
2503 int
2504 yyparse (YYPARSE_PARAM)
2505 void *YYPARSE_PARAM;
2506 #endif
2507 #else /* ! YYPARSE_PARAM */
2508 #if (defined __STDC__ || defined __C99__FUNC__ \
2509 || defined __cplusplus || defined _MSC_VER)
2510 int
2511 yyparse (void)
2512 #else
2513 int
2514 yyparse ()
2515
2516 #endif
2517 #endif
2518 {
2519 int yystate;
2520 /* Number of tokens to shift before error messages enabled. */
2521 int yyerrstatus;
2522
2523 /* The stacks and their tools:
2524 `yyss': related to states.
2525 `yyvs': related to semantic values.
2526 `yyls': related to locations.
2527
2528 Refer to the stacks thru separate pointers, to allow yyoverflow
2529 to reallocate them elsewhere. */
2530
2531 /* The state stack. */
2532 yytype_int16 yyssa[YYINITDEPTH];
2533 yytype_int16 *yyss;
2534 yytype_int16 *yyssp;
2535
2536 /* The semantic value stack. */
2537 YYSTYPE yyvsa[YYINITDEPTH];
2538 YYSTYPE *yyvs;
2539 YYSTYPE *yyvsp;
2540
2541 /* The location stack. */
2542 YYLTYPE yylsa[YYINITDEPTH];
2543 YYLTYPE *yyls;
2544 YYLTYPE *yylsp;
2545
2546 /* The locations where the error started and ended. */
2547 YYLTYPE yyerror_range[3];
2548
2549 YYSIZE_T yystacksize;
2550
2551 int yyn;
2552 int yyresult;
2553 /* Lookahead token as an internal (translated) token number. */
2554 int yytoken;
2555 /* The variables used to return semantic value and location from the
2556 action routines. */
2557 YYSTYPE yyval;
2558 YYLTYPE yyloc;
2559
2560 #if YYERROR_VERBOSE
2561 /* Buffer for error messages, and its allocated size. */
2562 char yymsgbuf[128];
2563 char *yymsg = yymsgbuf;
2564 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
2565 #endif
2566
2567 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
2568
2569 /* The number of symbols on the RHS of the reduced rule.
2570 Keep to zero when no symbol should be popped. */
2571 int yylen = 0;
2572
2573 yytoken = 0;
2574 yyss = yyssa;
2575 yyvs = yyvsa;
2576 yyls = yylsa;
2577 yystacksize = YYINITDEPTH;
2578
2579 YYDPRINTF ((stderr, "Starting parse\n"));
2580
2581 yystate = 0;
2582 yyerrstatus = 0;
2583 yynerrs = 0;
2584 yychar = YYEMPTY; /* Cause a token to be read. */
2585
2586 /* Initialize stack pointers.
2587 Waste one element of value and location stack
2588 so that they stay on the same level as the state stack.
2589 The wasted elements are never initialized. */
2590 yyssp = yyss;
2591 yyvsp = yyvs;
2592 yylsp = yyls;
2593
2594 #if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
2595 /* Initialize the default location before parsing starts. */
2596 yylloc.first_line = yylloc.last_line = 1;
2597 yylloc.first_column = yylloc.last_column = 1;
2598 #endif
2599
2600 goto yysetstate;
2601
2602 /*------------------------------------------------------------.
2603 | yynewstate -- Push a new state, which is found in yystate. |
2604 `------------------------------------------------------------*/
2605 yynewstate:
2606 /* In all cases, when you get here, the value and location stacks
2607 have just been pushed. So pushing a state here evens the stacks. */
2608 yyssp++;
2609
2610 yysetstate:
2611 *yyssp = yystate;
2612
2613 if (yyss + yystacksize - 1 <= yyssp)
2614 {
2615 /* Get the current used size of the three stacks, in elements. */
2616 YYSIZE_T yysize = yyssp - yyss + 1;
2617
2618 #ifdef yyoverflow
2619 {
2620 /* Give user a chance to reallocate the stack. Use copies of
2621 these so that the &'s don't force the real ones into
2622 memory. */
2623 YYSTYPE *yyvs1 = yyvs;
2624 yytype_int16 *yyss1 = yyss;
2625 YYLTYPE *yyls1 = yyls;
2626
2627 /* Each stack pointer address is followed by the size of the
2628 data in use in that stack, in bytes. This used to be a
2629 conditional around just the two extra args, but that might
2630 be undefined if yyoverflow is a macro. */
2631 yyoverflow (YY_("memory exhausted"),
2632 &yyss1, yysize * sizeof (*yyssp),
2633 &yyvs1, yysize * sizeof (*yyvsp),
2634 &yyls1, yysize * sizeof (*yylsp),
2635 &yystacksize);
2636
2637 yyls = yyls1;
2638 yyss = yyss1;
2639 yyvs = yyvs1;
2640 }
2641 #else /* no yyoverflow */
2642 # ifndef YYSTACK_RELOCATE
2643 goto yyexhaustedlab;
2644 # else
2645 /* Extend the stack our own way. */
2646 if (YYMAXDEPTH <= yystacksize)
2647 goto yyexhaustedlab;
2648 yystacksize *= 2;
2649 if (YYMAXDEPTH < yystacksize)
2650 yystacksize = YYMAXDEPTH;
2651
2652 {
2653 yytype_int16 *yyss1 = yyss;
2654 union yyalloc *yyptr =
2655 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2656 if (! yyptr)
2657 goto yyexhaustedlab;
2658 YYSTACK_RELOCATE (yyss_alloc, yyss);
2659 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
2660 YYSTACK_RELOCATE (yyls_alloc, yyls);
2661 # undef YYSTACK_RELOCATE
2662 if (yyss1 != yyssa)
2663 YYSTACK_FREE (yyss1);
2664 }
2665 # endif
2666 #endif /* no yyoverflow */
2667
2668 yyssp = yyss + yysize - 1;
2669 yyvsp = yyvs + yysize - 1;
2670 yylsp = yyls + yysize - 1;
2671
2672 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2673 (unsigned long int) yystacksize));
2674
2675 if (yyss + yystacksize - 1 <= yyssp)
2676 YYABORT;
2677 }
2678
2679 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
2680
2681 if (yystate == YYFINAL)
2682 YYACCEPT;
2683
2684 goto yybackup;
2685
2686 /*-----------.
2687 | yybackup. |
2688 `-----------*/
2689 yybackup:
2690
2691 /* Do appropriate processing given the current state. Read a
2692 lookahead token if we need one and don't already have one. */
2693
2694 /* First try to decide what to do without reference to lookahead token. */
2695 yyn = yypact[yystate];
2696 if (yypact_value_is_default (yyn))
2697 goto yydefault;
2698
2699 /* Not known => get a lookahead token if don't already have one. */
2700
2701 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
2702 if (yychar == YYEMPTY)
2703 {
2704 YYDPRINTF ((stderr, "Reading a token: "));
2705 yychar = YYLEX;
2706 }
2707
2708 if (yychar <= YYEOF)
2709 {
2710 yychar = yytoken = YYEOF;
2711 YYDPRINTF ((stderr, "Now at end of input.\n"));
2712 }
2713 else
2714 {
2715 yytoken = YYTRANSLATE (yychar);
2716 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
2717 }
2718
2719 /* If the proper action on seeing token YYTOKEN is to reduce or to
2720 detect an error, take that action. */
2721 yyn += yytoken;
2722 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
2723 goto yydefault;
2724 yyn = yytable[yyn];
2725 if (yyn <= 0)
2726 {
2727 if (yytable_value_is_error (yyn))
2728 goto yyerrlab;
2729 yyn = -yyn;
2730 goto yyreduce;
2731 }
2732
2733 /* Count tokens shifted since error; after three, turn off error
2734 status. */
2735 if (yyerrstatus)
2736 yyerrstatus--;
2737
2738 /* Shift the lookahead token. */
2739 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
2740
2741 /* Discard the shifted token. */
2742 yychar = YYEMPTY;
2743
2744 yystate = yyn;
2745 *++yyvsp = yylval;
2746 *++yylsp = yylloc;
2747 goto yynewstate;
2748
2749
2750 /*-----------------------------------------------------------.
2751 | yydefault -- do the default action for the current state. |
2752 `-----------------------------------------------------------*/
2753 yydefault:
2754 yyn = yydefact[yystate];
2755 if (yyn == 0)
2756 goto yyerrlab;
2757 goto yyreduce;
2758
2759
2760 /*-----------------------------.
2761 | yyreduce -- Do a reduction. |
2762 `-----------------------------*/
2763 yyreduce:
2764 /* yyn is the number of a rule to reduce with. */
2765 yylen = yyr2[yyn];
2766
2767 /* If YYLEN is nonzero, implement the default value of the action:
2768 `$$ = $1'.
2769
2770 Otherwise, the following line sets YYVAL to garbage.
2771 This behavior is undocumented and Bison
2772 users should not rely upon it. Assigning to YYVAL
2773 unconditionally makes the parser a bit smaller, and it avoids a
2774 GCC warning that YYVAL may be used uninitialized. */
2775 yyval = yyvsp[1-yylen];
2776
2777 /* Default location. */
2778 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
2779 YY_REDUCE_PRINT (yyn);
2780 switch (yyn)
2781 {
2782 case 2:
2783
2784 /* Line 1806 of yacc.c */
2785 #line 1022 "hlsl.y"
2786 {
2787 }
2788 break;
2789
2790 case 3:
2791
2792 /* Line 1806 of yacc.c */
2793 #line 1025 "hlsl.y"
2794 {
2795 const struct hlsl_ir_function_decl *decl;
2796
2797 decl = get_overloaded_func(&hlsl_ctx.functions, (yyvsp[(2) - (2)].function).name, (yyvsp[(2) - (2)].function).decl->parameters, TRUE);
2798 if (decl && !decl->func->intrinsic)
2799 {
2800 if (decl->body && (yyvsp[(2) - (2)].function).decl->body)
2801 {
2802 hlsl_report_message((yyvsp[(2) - (2)].function).decl->node.loc.file, (yyvsp[(2) - (2)].function).decl->node.loc.line,
2803 (yyvsp[(2) - (2)].function).decl->node.loc.col, HLSL_LEVEL_ERROR,
2804 "redefinition of function %s", debugstr_a((yyvsp[(2) - (2)].function).name));
2805 return 1;
2806 }
2807 else if (!compare_hlsl_types(decl->node.data_type, (yyvsp[(2) - (2)].function).decl->node.data_type))
2808 {
2809 hlsl_report_message((yyvsp[(2) - (2)].function).decl->node.loc.file, (yyvsp[(2) - (2)].function).decl->node.loc.line,
2810 (yyvsp[(2) - (2)].function).decl->node.loc.col, HLSL_LEVEL_ERROR,
2811 "redefining function %s with a different return type",
2812 debugstr_a((yyvsp[(2) - (2)].function).name));
2813 hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_NOTE,
2814 "%s previously declared here",
2815 debugstr_a((yyvsp[(2) - (2)].function).name));
2816 return 1;
2817 }
2818 }
2819
2820 if ((yyvsp[(2) - (2)].function).decl->node.data_type->base_type == HLSL_TYPE_VOID && (yyvsp[(2) - (2)].function).decl->semantic)
2821 {
2822 hlsl_report_message((yyvsp[(2) - (2)].function).decl->node.loc.file, (yyvsp[(2) - (2)].function).decl->node.loc.line,
2823 (yyvsp[(2) - (2)].function).decl->node.loc.col, HLSL_LEVEL_ERROR,
2824 "void function with a semantic");
2825 }
2826
2827 TRACE("Adding function '%s' to the function list.\n", (yyvsp[(2) - (2)].function).name);
2828 add_function_decl(&hlsl_ctx.functions, (yyvsp[(2) - (2)].function).name, (yyvsp[(2) - (2)].function).decl, FALSE);
2829 }
2830 break;
2831
2832 case 4:
2833
2834 /* Line 1806 of yacc.c */
2835 #line 1062 "hlsl.y"
2836 {
2837 TRACE("Declaration statement parsed.\n");
2838 }
2839 break;
2840
2841 case 5:
2842
2843 /* Line 1806 of yacc.c */
2844 #line 1066 "hlsl.y"
2845 {
2846 }
2847 break;
2848
2849 case 6:
2850
2851 /* Line 1806 of yacc.c */
2852 #line 1069 "hlsl.y"
2853 {
2854 TRACE("Skipping stray semicolon.\n");
2855 }
2856 break;
2857
2858 case 7:
2859
2860 /* Line 1806 of yacc.c */
2861 #line 1074 "hlsl.y"
2862 {
2863 TRACE("Updating line information to file %s, line %u\n", debugstr_a((yyvsp[(2) - (2)].name)), (yyvsp[(1) - (2)].intval));
2864 hlsl_ctx.line_no = (yyvsp[(1) - (2)].intval);
2865 if (strcmp((yyvsp[(2) - (2)].name), hlsl_ctx.source_file))
2866 {
2867 const char **new_array;
2868
2869 hlsl_ctx.source_file = (yyvsp[(2) - (2)].name);
2870 new_array = d3dcompiler_realloc(hlsl_ctx.source_files,
2871 sizeof(*hlsl_ctx.source_files) * hlsl_ctx.source_files_count + 1);
2872 if (new_array)
2873 {
2874 hlsl_ctx.source_files = new_array;
2875 hlsl_ctx.source_files[hlsl_ctx.source_files_count++] = (yyvsp[(2) - (2)].name);
2876 }
2877 }
2878 }
2879 break;
2880
2881 case 8:
2882
2883 /* Line 1806 of yacc.c */
2884 #line 1093 "hlsl.y"
2885 {
2886 struct source_location loc;
2887
2888 set_location(&loc, &(yylsp[(3) - (3)]));
2889 if (!(yyvsp[(2) - (3)].list))
2890 {
2891 if (!(yyvsp[(1) - (3)].type)->name)
2892 {
2893 hlsl_report_message(loc.file, loc.line, loc.col,
2894 HLSL_LEVEL_ERROR, "anonymous struct declaration with no variables");
2895 }
2896 check_type_modifiers((yyvsp[(1) - (3)].type)->modifiers, &loc);
2897 }
2898 (yyval.list) = declare_vars((yyvsp[(1) - (3)].type), 0, (yyvsp[(2) - (3)].list));
2899 }
2900 break;
2901
2902 case 11:
2903
2904 /* Line 1806 of yacc.c */
2905 #line 1113 "hlsl.y"
2906 {
2907 BOOL ret;
2908 struct source_location loc;
2909
2910 TRACE("Structure %s declaration.\n", debugstr_a((yyvsp[(3) - (6)].name)));
2911 set_location(&loc, &(yylsp[(1) - (6)]));
2912 check_invalid_matrix_modifiers((yyvsp[(1) - (6)].modifiers), &loc);
2913 (yyval.type) = new_struct_type((yyvsp[(3) - (6)].name), (yyvsp[(1) - (6)].modifiers), (yyvsp[(5) - (6)].list));
2914
2915 if (get_variable(hlsl_ctx.cur_scope, (yyvsp[(3) - (6)].name)))
2916 {
2917 hlsl_report_message(hlsl_ctx.source_file, (yylsp[(3) - (6)]).first_line, (yylsp[(3) - (6)]).first_column,
2918 HLSL_LEVEL_ERROR, "redefinition of '%s'", (yyvsp[(3) - (6)].name));
2919 return 1;
2920 }
2921
2922 ret = add_type_to_scope(hlsl_ctx.cur_scope, (yyval.type));
2923 if (!ret)
2924 {
2925 hlsl_report_message(hlsl_ctx.source_file, (yylsp[(3) - (6)]).first_line, (yylsp[(3) - (6)]).first_column,
2926 HLSL_LEVEL_ERROR, "redefinition of struct '%s'", (yyvsp[(3) - (6)].name));
2927 return 1;
2928 }
2929 }
2930 break;
2931
2932 case 12:
2933
2934 /* Line 1806 of yacc.c */
2935 #line 1139 "hlsl.y"
2936 {
2937 struct source_location loc;
2938
2939 TRACE("Anonymous structure declaration.\n");
2940 set_location(&loc, &(yylsp[(1) - (5)]));
2941 check_invalid_matrix_modifiers((yyvsp[(1) - (5)].modifiers), &loc);
2942 (yyval.type) = new_struct_type(NULL, (yyvsp[(1) - (5)].modifiers), (yyvsp[(4) - (5)].list));
2943 }
2944 break;
2945
2946 case 16:
2947
2948 /* Line 1806 of yacc.c */
2949 #line 1153 "hlsl.y"
2950 {
2951 (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
2952 list_init((yyval.list));
2953 }
2954 break;
2955
2956 case 17:
2957
2958 /* Line 1806 of yacc.c */
2959 #line 1158 "hlsl.y"
2960 {
2961 BOOL ret;
2962 struct hlsl_struct_field *field, *next;
2963
2964 (yyval.list) = (yyvsp[(1) - (2)].list);
2965 LIST_FOR_EACH_ENTRY_SAFE(field, next, (yyvsp[(2) - (2)].list), struct hlsl_struct_field, entry)
2966 {
2967 ret = add_struct_field((yyval.list), field);
2968 if (ret == FALSE)
2969 {
2970 hlsl_report_message(hlsl_ctx.source_file, (yylsp[(2) - (2)]).first_line, (yylsp[(2) - (2)]).first_column,
2971 HLSL_LEVEL_ERROR, "redefinition of '%s'", field->name);
2972 d3dcompiler_free(field);
2973 }
2974 }
2975 d3dcompiler_free((yyvsp[(2) - (2)].list));
2976 }
2977 break;
2978
2979 case 18:
2980
2981 /* Line 1806 of yacc.c */
2982 #line 1177 "hlsl.y"
2983 {
2984 (yyval.list) = gen_struct_fields((yyvsp[(2) - (4)].type), (yyvsp[(1) - (4)].modifiers), (yyvsp[(3) - (4)].list));
2985 }
2986 break;
2987
2988 case 19:
2989
2990 /* Line 1806 of yacc.c */
2991 #line 1181 "hlsl.y"
2992 {
2993 (yyval.list) = gen_struct_fields((yyvsp[(1) - (3)].type), 0, (yyvsp[(2) - (3)].list));
2994 }
2995 break;
2996
2997 case 20:
2998
2999 /* Line 1806 of yacc.c */
3000 #line 1186 "hlsl.y"
3001 {
3002 TRACE("Function %s parsed.\n", (yyvsp[(1) - (2)].function).name);
3003 (yyval.function) = (yyvsp[(1) - (2)].function);
3004 (yyval.function).decl->body = (yyvsp[(2) - (2)].list);
3005 pop_scope(&hlsl_ctx);
3006 }
3007 break;
3008
3009 case 21:
3010
3011 /* Line 1806 of yacc.c */
3012 #line 1193 "hlsl.y"
3013 {
3014 TRACE("Function prototype for %s.\n", (yyvsp[(1) - (2)].function).name);
3015 (yyval.function) = (yyvsp[(1) - (2)].function);
3016 pop_scope(&hlsl_ctx);
3017 }
3018 break;
3019
3020 case 22:
3021
3022 /* Line 1806 of yacc.c */
3023 #line 1200 "hlsl.y"
3024 {
3025 if (get_variable(hlsl_ctx.globals, (yyvsp[(3) - (7)].name)))
3026 {
3027 hlsl_report_message(hlsl_ctx.source_file, (yylsp[(3) - (7)]).first_line, (yylsp[(3) - (7)]).first_column,
3028 HLSL_LEVEL_ERROR, "redefinition of '%s'\n", (yyvsp[(3) - (7)].name));
3029 return 1;
3030 }
3031 if ((yyvsp[(2) - (7)].type)->base_type == HLSL_TYPE_VOID && (yyvsp[(7) - (7)].name))
3032 {
3033 hlsl_report_message(hlsl_ctx.source_file, (yylsp[(7) - (7)]).first_line, (yylsp[(7) - (7)]).first_column,
3034 HLSL_LEVEL_ERROR, "void function with a semantic");
3035 }
3036
3037 (yyval.function).decl = new_func_decl((yyvsp[(2) - (7)].type), (yyvsp[(5) - (7)].list));
3038 if (!(yyval.function).decl)
3039 {
3040 ERR("Out of memory.\n");
3041 return -1;
3042 }
3043 (yyval.function).name = (yyvsp[(3) - (7)].name);
3044 (yyval.function).decl->semantic = (yyvsp[(7) - (7)].name);
3045 set_location(&(yyval.function).decl->node.loc, &(yylsp[(3) - (7)]));
3046 }
3047 break;
3048
3049 case 23:
3050
3051 /* Line 1806 of yacc.c */
3052 #line 1225 "hlsl.y"
3053 {
3054 (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3055 list_init((yyval.list));
3056 }
3057 break;
3058
3059 case 24:
3060
3061 /* Line 1806 of yacc.c */
3062 #line 1230 "hlsl.y"
3063 {
3064 pop_scope(&hlsl_ctx);
3065 (yyval.list) = (yyvsp[(3) - (4)].list);
3066 }
3067 break;
3068
3069 case 25:
3070
3071 /* Line 1806 of yacc.c */
3072 #line 1236 "hlsl.y"
3073 {
3074 push_scope(&hlsl_ctx);
3075 }
3076 break;
3077
3078 case 28:
3079
3080 /* Line 1806 of yacc.c */
3081 #line 1244 "hlsl.y"
3082 {
3083 (yyval.name) = NULL;
3084 }
3085 break;
3086
3087 case 29:
3088
3089 /* Line 1806 of yacc.c */
3090 #line 1248 "hlsl.y"
3091 {
3092 (yyval.name) = (yyvsp[(2) - (2)].name);
3093 }
3094 break;
3095
3096 case 30:
3097
3098 /* Line 1806 of yacc.c */
3099 #line 1253 "hlsl.y"
3100 {
3101 (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3102 list_init((yyval.list));
3103 }
3104 break;
3105
3106 case 31:
3107
3108 /* Line 1806 of yacc.c */
3109 #line 1258 "hlsl.y"
3110 {
3111 (yyval.list) = (yyvsp[(2) - (2)].list);
3112 }
3113 break;
3114
3115 case 32:
3116
3117 /* Line 1806 of yacc.c */
3118 #line 1263 "hlsl.y"
3119 {
3120 struct source_location loc;
3121
3122 (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3123 list_init((yyval.list));
3124 set_location(&loc, &(yylsp[(1) - (1)]));
3125 if (!add_func_parameter((yyval.list), &(yyvsp[(1) - (1)].parameter), &loc))
3126 {
3127 ERR("Error adding function parameter %s.\n", (yyvsp[(1) - (1)].parameter).name);
3128 set_parse_status(&hlsl_ctx.status, PARSE_ERR);
3129 return -1;
3130 }
3131 }
3132 break;
3133
3134 case 33:
3135
3136 /* Line 1806 of yacc.c */
3137 #line 1277 "hlsl.y"
3138 {
3139 struct source_location loc;
3140
3141 (yyval.list) = (yyvsp[(1) - (3)].list);
3142 set_location(&loc, &(yylsp[(3) - (3)]));
3143 if (!add_func_parameter((yyval.list), &(yyvsp[(3) - (3)].parameter), &loc))
3144 {
3145 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
3146 "duplicate parameter %s", (yyvsp[(3) - (3)].parameter).name);
3147 return 1;
3148 }
3149 }
3150 break;
3151
3152 case 34:
3153
3154 /* Line 1806 of yacc.c */
3155 #line 1291 "hlsl.y"
3156 {
3157 (yyval.parameter).modifiers = (yyvsp[(1) - (5)].modifiers) ? (yyvsp[(1) - (5)].modifiers) : HLSL_MODIFIER_IN;
3158 (yyval.parameter).modifiers |= (yyvsp[(2) - (5)].modifiers);
3159 (yyval.parameter).type = (yyvsp[(3) - (5)].type);
3160 (yyval.parameter).name = (yyvsp[(4) - (5)].name);
3161 (yyval.parameter).semantic = (yyvsp[(5) - (5)].name);
3162 }
3163 break;
3164
3165 case 35:
3166
3167 /* Line 1806 of yacc.c */
3168 #line 1300 "hlsl.y"
3169 {
3170 (yyval.modifiers) = 0;
3171 }
3172 break;
3173
3174 case 36:
3175
3176 /* Line 1806 of yacc.c */
3177 #line 1304 "hlsl.y"
3178 {
3179 if ((yyvsp[(1) - (2)].modifiers) & (yyvsp[(2) - (2)].modifiers))
3180 {
3181 hlsl_report_message(hlsl_ctx.source_file, (yylsp[(2) - (2)]).first_line, (yylsp[(2) - (2)]).first_column,
3182 HLSL_LEVEL_ERROR, "duplicate input-output modifiers");
3183 return 1;
3184 }
3185 (yyval.modifiers) = (yyvsp[(1) - (2)].modifiers) | (yyvsp[(2) - (2)].modifiers);
3186 }
3187 break;
3188
3189 case 37:
3190
3191 /* Line 1806 of yacc.c */
3192 #line 1315 "hlsl.y"
3193 {
3194 (yyval.modifiers) = HLSL_MODIFIER_IN;
3195 }
3196 break;
3197
3198 case 38:
3199
3200 /* Line 1806 of yacc.c */
3201 #line 1319 "hlsl.y"
3202 {
3203 (yyval.modifiers) = HLSL_MODIFIER_OUT;
3204 }
3205 break;
3206
3207 case 39:
3208
3209 /* Line 1806 of yacc.c */
3210 #line 1323 "hlsl.y"
3211 {
3212 (yyval.modifiers) = HLSL_MODIFIER_IN | HLSL_MODIFIER_OUT;
3213 }
3214 break;
3215
3216 case 40:
3217
3218 /* Line 1806 of yacc.c */
3219 #line 1328 "hlsl.y"
3220 {
3221 (yyval.type) = (yyvsp[(1) - (1)].type);
3222 }
3223 break;
3224
3225 case 41:
3226
3227 /* Line 1806 of yacc.c */
3228 #line 1332 "hlsl.y"
3229 {
3230 if ((yyvsp[(3) - (6)].type)->type != HLSL_CLASS_SCALAR)
3231 {
3232 hlsl_message("Line %u: vectors of non-scalar types are not allowed.\n",
3233 hlsl_ctx.line_no);
3234 set_parse_status(&hlsl_ctx.status, PARSE_ERR);
3235 return 1;
3236 }
3237 if ((yyvsp[(5) - (6)].intval) < 1 || (yyvsp[(5) - (6)].intval) > 4)
3238 {
3239 hlsl_message("Line %u: vector size must be between 1 and 4.\n",
3240 hlsl_ctx.line_no);
3241 set_parse_status(&hlsl_ctx.status, PARSE_ERR);
3242 return 1;
3243 }
3244
3245 (yyval.type) = new_hlsl_type(NULL, HLSL_CLASS_VECTOR, (yyvsp[(3) - (6)].type)->base_type, (yyvsp[(5) - (6)].intval), 1);
3246 }
3247 break;
3248
3249 case 42:
3250
3251 /* Line 1806 of yacc.c */
3252 #line 1351 "hlsl.y"
3253 {
3254 if ((yyvsp[(3) - (8)].type)->type != HLSL_CLASS_SCALAR)
3255 {
3256 hlsl_message("Line %u: matrices of non-scalar types are not allowed.\n",
3257 hlsl_ctx.line_no);
3258 set_parse_status(&hlsl_ctx.status, PARSE_ERR);
3259 return 1;
3260 }
3261 if ((yyvsp[(5) - (8)].intval) < 1 || (yyvsp[(5) - (8)].intval) > 4 || (yyvsp[(7) - (8)].intval) < 1 || (yyvsp[(7) - (8)].intval) > 4)
3262 {
3263 hlsl_message("Line %u: matrix dimensions must be between 1 and 4.\n",
3264 hlsl_ctx.line_no);
3265 set_parse_status(&hlsl_ctx.status, PARSE_ERR);
3266 return 1;
3267 }
3268
3269 (yyval.type) = new_hlsl_type(NULL, HLSL_CLASS_MATRIX, (yyvsp[(3) - (8)].type)->base_type, (yyvsp[(5) - (8)].intval), (yyvsp[(7) - (8)].intval));
3270 }
3271 break;
3272
3273 case 43:
3274
3275 /* Line 1806 of yacc.c */
3276 #line 1371 "hlsl.y"
3277 {
3278 (yyval.type) = new_hlsl_type(d3dcompiler_strdup("void"), HLSL_CLASS_OBJECT, HLSL_TYPE_VOID, 1, 1);
3279 }
3280 break;
3281
3282 case 44:
3283
3284 /* Line 1806 of yacc.c */
3285 #line 1375 "hlsl.y"
3286 {
3287 (yyval.type) = new_hlsl_type(d3dcompiler_strdup("sampler"), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
3288 (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_GENERIC;
3289 }
3290 break;
3291
3292 case 45:
3293
3294 /* Line 1806 of yacc.c */
3295 #line 1380 "hlsl.y"
3296 {
3297 (yyval.type) = new_hlsl_type(d3dcompiler_strdup("sampler1D"), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
3298 (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_1D;
3299 }
3300 break;
3301
3302 case 46:
3303
3304 /* Line 1806 of yacc.c */
3305 #line 1385 "hlsl.y"
3306 {
3307 (yyval.type) = new_hlsl_type(d3dcompiler_strdup("sampler2D"), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
3308 (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_2D;
3309 }
3310 break;
3311
3312 case 47:
3313
3314 /* Line 1806 of yacc.c */
3315 #line 1390 "hlsl.y"
3316 {
3317 (yyval.type) = new_hlsl_type(d3dcompiler_strdup("sampler3D"), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
3318 (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_3D;
3319 }
3320 break;
3321
3322 case 48:
3323
3324 /* Line 1806 of yacc.c */
3325 #line 1395 "hlsl.y"
3326 {
3327 (yyval.type) = new_hlsl_type(d3dcompiler_strdup("samplerCUBE"), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
3328 (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_CUBE;
3329 }
3330 break;
3331
3332 case 49:
3333
3334 /* Line 1806 of yacc.c */
3335 #line 1400 "hlsl.y"
3336 {
3337 struct hlsl_type *type;
3338
3339 TRACE("Type %s.\n", (yyvsp[(1) - (1)].name));
3340 type = get_type(hlsl_ctx.cur_scope, (yyvsp[(1) - (1)].name), TRUE);
3341 (yyval.type) = type;
3342 d3dcompiler_free((yyvsp[(1) - (1)].name));
3343 }
3344 break;
3345
3346 case 50:
3347
3348 /* Line 1806 of yacc.c */
3349 #line 1409 "hlsl.y"
3350 {
3351 struct hlsl_type *type;
3352
3353 TRACE("Struct type %s.\n", (yyvsp[(2) - (2)].name));
3354 type = get_type(hlsl_ctx.cur_scope, (yyvsp[(2) - (2)].name), TRUE);
3355 if (type->type != HLSL_CLASS_STRUCT)
3356 {
3357 hlsl_message("Line %u: redefining %s as a structure.\n",
3358 hlsl_ctx.line_no, (yyvsp[(2) - (2)].name));
3359 set_parse_status(&hlsl_ctx.status, PARSE_ERR);
3360 }
3361 else
3362 {
3363 (yyval.type) = type;
3364 }
3365 d3dcompiler_free((yyvsp[(2) - (2)].name));
3366 }
3367 break;
3368
3369 case 53:
3370
3371 /* Line 1806 of yacc.c */
3372 #line 1430 "hlsl.y"
3373 {
3374 (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3375 if (!(yyval.list))
3376 {
3377 ERR("Out of memory\n");
3378 return -1;
3379 }
3380 list_init((yyval.list));
3381 }
3382 break;
3383
3384 case 54:
3385
3386 /* Line 1806 of yacc.c */
3387 #line 1441 "hlsl.y"
3388 {
3389 struct source_location loc;
3390
3391 set_location(&loc, &(yylsp[(1) - (5)]));
3392 if (!add_typedef((yyvsp[(2) - (5)].modifiers), (yyvsp[(3) - (5)].type), (yyvsp[(4) - (5)].list), &loc))
3393 return 1;
3394 }
3395 break;
3396
3397 case 55:
3398
3399 /* Line 1806 of yacc.c */
3400 #line 1449 "hlsl.y"
3401 {
3402 struct source_location loc;
3403
3404 set_location(&loc, &(yylsp[(1) - (4)]));
3405 if (!add_typedef(0, (yyvsp[(2) - (4)].type), (yyvsp[(3) - (4)].list), &loc))
3406 return 1;
3407 }
3408 break;
3409
3410 case 56:
3411
3412 /* Line 1806 of yacc.c */
3413 #line 1458 "hlsl.y"
3414 {
3415 (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3416 list_init((yyval.list));
3417 list_add_head((yyval.list), &(yyvsp[(1) - (1)].variable_def)->entry);
3418 }
3419 break;
3420
3421 case 57:
3422
3423 /* Line 1806 of yacc.c */
3424 #line 1464 "hlsl.y"
3425 {
3426 (yyval.list) = (yyvsp[(1) - (3)].list);
3427 list_add_tail((yyval.list), &(yyvsp[(3) - (3)].variable_def)->entry);
3428 }
3429 break;
3430
3431 case 58:
3432
3433 /* Line 1806 of yacc.c */
3434 #line 1470 "hlsl.y"
3435 {
3436 (yyval.variable_def) = d3dcompiler_alloc(sizeof(*(yyval.variable_def)));
3437 set_location(&(yyval.variable_def)->loc, &(yylsp[(1) - (2)]));
3438 (yyval.variable_def)->name = (yyvsp[(1) - (2)].name);
3439 (yyval.variable_def)->array_size = (yyvsp[(2) - (2)].intval);
3440 }
3441 break;
3442
3443 case 59:
3444
3445 /* Line 1806 of yacc.c */
3446 #line 1478 "hlsl.y"
3447 {
3448 (yyval.list) = declare_vars((yyvsp[(2) - (4)].type), (yyvsp[(1) - (4)].modifiers), (yyvsp[(3) - (4)].list));
3449 }
3450 break;
3451
3452 case 60:
3453
3454 /* Line 1806 of yacc.c */
3455 #line 1483 "hlsl.y"
3456 {
3457 (yyval.list) = NULL;
3458 }
3459 break;
3460
3461 case 61:
3462
3463 /* Line 1806 of yacc.c */
3464 #line 1487 "hlsl.y"
3465 {
3466 (yyval.list) = (yyvsp[(1) - (1)].list);
3467 }
3468 break;
3469
3470 case 62:
3471
3472 /* Line 1806 of yacc.c */
3473 #line 1492 "hlsl.y"
3474 {
3475 (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3476 list_init((yyval.list));
3477 list_add_head((yyval.list), &(yyvsp[(1) - (1)].variable_def)->entry);
3478 }
3479 break;
3480
3481 case 63:
3482
3483 /* Line 1806 of yacc.c */
3484 #line 1498 "hlsl.y"
3485 {
3486 (yyval.list) = (yyvsp[(1) - (3)].list);
3487 list_add_tail((yyval.list), &(yyvsp[(3) - (3)].variable_def)->entry);
3488 }
3489 break;
3490
3491 case 64:
3492
3493 /* Line 1806 of yacc.c */
3494 #line 1504 "hlsl.y"
3495 {
3496 (yyval.variable_def) = d3dcompiler_alloc(sizeof(*(yyval.variable_def)));
3497 set_location(&(yyval.variable_def)->loc, &(yylsp[(1) - (3)]));
3498 (yyval.variable_def)->name = (yyvsp[(1) - (3)].name);
3499 (yyval.variable_def)->array_size = (yyvsp[(2) - (3)].intval);
3500 (yyval.variable_def)->semantic = (yyvsp[(3) - (3)].name);
3501 }
3502 break;
3503
3504 case 65:
3505
3506 /* Line 1806 of yacc.c */
3507 #line 1512 "hlsl.y"
3508 {
3509 TRACE("Declaration with initializer.\n");
3510 (yyval.variable_def) = d3dcompiler_alloc(sizeof(*(yyval.variable_def)));
3511 set_location(&(yyval.variable_def)->loc, &(yylsp[(1) - (5)]));
3512 (yyval.variable_def)->name = (yyvsp[(1) - (5)].name);
3513 (yyval.variable_def)->array_size = (yyvsp[(2) - (5)].intval);
3514 (yyval.variable_def)->semantic = (yyvsp[(3) - (5)].name);
3515 (yyval.variable_def)->initializer = (yyvsp[(5) - (5)].list);
3516 }
3517 break;
3518
3519 case 66:
3520
3521 /* Line 1806 of yacc.c */
3522 #line 1523 "hlsl.y"
3523 {
3524 (yyval.intval) = 0;
3525 }
3526 break;
3527
3528 case 67:
3529
3530 /* Line 1806 of yacc.c */
3531 #line 1527 "hlsl.y"
3532 {
3533 FIXME("Array.\n");
3534 (yyval.intval) = 0;
3535 free_instr((yyvsp[(2) - (3)].instr));
3536 }
3537 break;
3538
3539 case 68:
3540
3541 /* Line 1806 of yacc.c */
3542 #line 1534 "hlsl.y"
3543 {
3544 (yyval.modifiers) = 0;
3545 }
3546 break;
3547
3548 case 69:
3549
3550 /* Line 1806 of yacc.c */
3551 #line 1538 "hlsl.y"
3552 {
3553 (yyval.modifiers) = add_modifier((yyvsp[(2) - (2)].modifiers), HLSL_STORAGE_EXTERN, &(yylsp[(1) - (2)]));
3554 }
3555 break;
3556
3557 case 70:
3558
3559 /* Line 1806 of yacc.c */
3560 #line 1542 "hlsl.y"
3561 {
3562 (yyval.modifiers) = add_modifier((yyvsp[(2) - (2)].modifiers), HLSL_STORAGE_NOINTERPOLATION, &(yylsp[(1) - (2)]));
3563 }
3564 break;
3565
3566 case 71:
3567
3568 /* Line 1806 of yacc.c */
3569 #line 1546 "hlsl.y"
3570 {
3571 (yyval.modifiers) = add_modifier((yyvsp[(2) - (2)].modifiers), HLSL_MODIFIER_PRECISE, &(yylsp[(1) - (2)]));
3572 }
3573 break;
3574
3575 case 72:
3576
3577 /* Line 1806 of yacc.c */
3578 #line 1550 "hlsl.y"
3579 {
3580 (yyval.modifiers) = add_modifier((yyvsp[(2) - (2)].modifiers), HLSL_STORAGE_SHARED, &(yylsp[(1) - (2)]));
3581 }
3582 break;
3583
3584 case 73:
3585
3586 /* Line 1806 of yacc.c */
3587 #line 1554 "hlsl.y"
3588 {
3589 (yyval.modifiers) = add_modifier((yyvsp[(2) - (2)].modifiers), HLSL_STORAGE_GROUPSHARED, &(yylsp[(1) - (2)]));
3590 }
3591 break;
3592
3593 case 74:
3594
3595 /* Line 1806 of yacc.c */
3596 #line 1558 "hlsl.y"
3597 {
3598 (yyval.modifiers) = add_modifier((yyvsp[(2) - (2)].modifiers), HLSL_STORAGE_STATIC, &(yylsp[(1) - (2)]));
3599 }
3600 break;
3601
3602 case 75:
3603
3604 /* Line 1806 of yacc.c */
3605 #line 1562 "hlsl.y"
3606 {
3607 (yyval.modifiers) = add_modifier((yyvsp[(2) - (2)].modifiers), HLSL_STORAGE_UNIFORM, &(yylsp[(1) - (2)]));
3608 }
3609 break;
3610
3611 case 76:
3612
3613 /* Line 1806 of yacc.c */
3614 #line 1566 "hlsl.y"
3615 {
3616 (yyval.modifiers) = add_modifier((yyvsp[(2) - (2)].modifiers), HLSL_STORAGE_VOLATILE, &(yylsp[(1) - (2)]));
3617 }
3618 break;
3619
3620 case 77:
3621
3622 /* Line 1806 of yacc.c */
3623 #line 1570 "hlsl.y"
3624 {
3625 (yyval.modifiers) = add_modifier((yyvsp[(2) - (2)].modifiers), HLSL_MODIFIER_CONST, &(yylsp[(1) - (2)]));
3626 }
3627 break;
3628
3629 case 78:
3630
3631 /* Line 1806 of yacc.c */
3632 #line 1574 "hlsl.y"
3633 {
3634 (yyval.modifiers) = add_modifier((yyvsp[(2) - (2)].modifiers), HLSL_MODIFIER_ROW_MAJOR, &(yylsp[(1) - (2)]));
3635 }
3636 break;
3637
3638 case 79:
3639
3640 /* Line 1806 of yacc.c */
3641 #line 1578 "hlsl.y"
3642 {
3643 (yyval.modifiers) = add_modifier((yyvsp[(2) - (2)].modifiers), HLSL_MODIFIER_COLUMN_MAJOR, &(yylsp[(1) - (2)]));
3644 }
3645 break;
3646
3647 case 80:
3648
3649 /* Line 1806 of yacc.c */
3650 #line 1583 "hlsl.y"
3651 {
3652 (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3653 list_init((yyval.list));
3654 list_add_head((yyval.list), &(yyvsp[(1) - (1)].instr)->entry);
3655 }
3656 break;
3657
3658 case 81:
3659
3660 /* Line 1806 of yacc.c */
3661 #line 1589 "hlsl.y"
3662 {
3663 (yyval.list) = (yyvsp[(2) - (3)].list);
3664 }
3665 break;
3666
3667 case 82:
3668
3669 /* Line 1806 of yacc.c */
3670 #line 1593 "hlsl.y"
3671 {
3672 (yyval.list) = (yyvsp[(2) - (4)].list);
3673 }
3674 break;
3675
3676 case 83:
3677
3678 /* Line 1806 of yacc.c */
3679 #line 1598 "hlsl.y"
3680 {
3681 (yyval.instr) = (yyvsp[(1) - (1)].instr);
3682 }
3683 break;
3684
3685 case 84:
3686
3687 /* Line 1806 of yacc.c */
3688 #line 1603 "hlsl.y"
3689 {
3690 (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3691 list_init((yyval.list));
3692 list_add_head((yyval.list), &(yyvsp[(1) - (1)].instr)->entry);
3693 }
3694 break;
3695
3696 case 85:
3697
3698 /* Line 1806 of yacc.c */
3699 #line 1609 "hlsl.y"
3700 {
3701 (yyval.list) = (yyvsp[(1) - (3)].list);
3702 list_add_tail((yyval.list), &(yyvsp[(3) - (3)].instr)->entry);
3703 }
3704 break;
3705
3706 case 86:
3707
3708 /* Line 1806 of yacc.c */
3709 #line 1615 "hlsl.y"
3710 {
3711 (yyval.boolval) = TRUE;
3712 }
3713 break;
3714
3715 case 87:
3716
3717 /* Line 1806 of yacc.c */
3718 #line 1619 "hlsl.y"
3719 {
3720 (yyval.boolval) = FALSE;
3721 }
3722 break;
3723
3724 case 88:
3725
3726 /* Line 1806 of yacc.c */
3727 #line 1624 "hlsl.y"
3728 {
3729 (yyval.list) = (yyvsp[(1) - (1)].list);
3730 }
3731 break;
3732
3733 case 89:
3734
3735 /* Line 1806 of yacc.c */
3736 #line 1628 "hlsl.y"
3737 {
3738 (yyval.list) = (yyvsp[(1) - (2)].list);
3739 list_move_tail((yyval.list), (yyvsp[(2) - (2)].list));
3740 d3dcompiler_free((yyvsp[(2) - (2)].list));
3741 }
3742 break;
3743
3744 case 96:
3745
3746 /* Line 1806 of yacc.c */
3747 #line 1643 "hlsl.y"
3748 {
3749 struct hlsl_ir_jump *jump = d3dcompiler_alloc(sizeof(*jump));
3750 if (!jump)
3751 {
3752 ERR("Out of memory\n");
3753 return -1;
3754 }
3755 jump->node.type = HLSL_IR_JUMP;
3756 set_location(&jump->node.loc, &(yylsp[(1) - (3)]));
3757 jump->type = HLSL_IR_JUMP_RETURN;
3758 jump->node.data_type = (yyvsp[(2) - (3)].instr)->data_type;
3759 jump->return_value = (yyvsp[(2) - (3)].instr);
3760
3761 FIXME("Check for valued return on void function.\n");
3762 FIXME("Implicit conversion to the return type if needed, "
3763 "error out if conversion not possible.\n");
3764
3765 (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3766 list_init((yyval.list));
3767 list_add_tail((yyval.list), &jump->node.entry);
3768 }
3769 break;
3770
3771 case 97:
3772
3773 /* Line 1806 of yacc.c */
3774 #line 1666 "hlsl.y"
3775 {
3776 struct hlsl_ir_if *instr = d3dcompiler_alloc(sizeof(*instr));
3777 if (!instr)
3778 {
3779 ERR("Out of memory\n");
3780 return -1;
3781 }
3782 instr->node.type = HLSL_IR_IF;
3783 set_location(&instr->node.loc, &(yylsp[(1) - (5)]));
3784 instr->condition = (yyvsp[(3) - (5)].instr);
3785 instr->then_instrs = (yyvsp[(5) - (5)].if_body).then_instrs;
3786 instr->else_instrs = (yyvsp[(5) - (5)].if_body).else_instrs;
3787 if ((yyvsp[(3) - (5)].instr)->data_type->dimx > 1 || (yyvsp[(3) - (5)].instr)->data_type->dimy > 1)
3788 {
3789 hlsl_report_message(instr->node.loc.file, instr->node.loc.line,
3790 instr->node.loc.col, HLSL_LEVEL_ERROR,
3791 "if condition requires a scalar");
3792 }
3793 (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3794 list_init((yyval.list));
3795 list_add_head((yyval.list), &instr->node.entry);
3796 }
3797 break;
3798
3799 case 98:
3800
3801 /* Line 1806 of yacc.c */
3802 #line 1690 "hlsl.y"
3803 {
3804 (yyval.if_body).then_instrs = (yyvsp[(1) - (1)].list);
3805 (yyval.if_body).else_instrs = NULL;
3806 }
3807 break;
3808
3809 case 99:
3810
3811 /* Line 1806 of yacc.c */
3812 #line 1695 "hlsl.y"
3813 {
3814 (yyval.if_body).then_instrs = (yyvsp[(1) - (3)].list);
3815 (yyval.if_body).else_instrs = (yyvsp[(3) - (3)].list);
3816 }
3817 break;
3818
3819 case 100:
3820
3821 /* Line 1806 of yacc.c */
3822 #line 1701 "hlsl.y"
3823 {
3824 struct source_location loc;
3825 struct list *cond = d3dcompiler_alloc(sizeof(*cond));
3826
3827 if (!cond)
3828 {
3829 ERR("Out of memory.\n");
3830 return -1;
3831 }
3832 list_init(cond);
3833 list_add_head(cond, &(yyvsp[(3) - (5)].instr)->entry);
3834 set_location(&loc, &(yylsp[(1) - (5)]));
3835 (yyval.list) = create_loop(LOOP_WHILE, NULL, cond, NULL, (yyvsp[(5) - (5)].list), &loc);
3836 }
3837 break;
3838
3839 case 101:
3840
3841 /* Line 1806 of yacc.c */
3842 #line 1716 "hlsl.y"
3843 {
3844 struct source_location loc;
3845 struct list *cond = d3dcompiler_alloc(sizeof(*cond));
3846
3847 if (!cond)
3848 {
3849 ERR("Out of memory.\n");
3850 return -1;
3851 }
3852 list_init(cond);
3853 list_add_head(cond, &(yyvsp[(5) - (7)].instr)->entry);
3854 set_location(&loc, &(yylsp[(1) - (7)]));
3855 (yyval.list) = create_loop(LOOP_DO_WHILE, NULL, cond, NULL, (yyvsp[(2) - (7)].list), &loc);
3856 }
3857 break;
3858
3859 case 102:
3860
3861 /* Line 1806 of yacc.c */
3862 #line 1731 "hlsl.y"
3863 {
3864 struct source_location loc;
3865
3866 set_location(&loc, &(yylsp[(1) - (8)]));
3867 (yyval.list) = create_loop(LOOP_FOR, (yyvsp[(4) - (8)].list), (yyvsp[(5) - (8)].list), (yyvsp[(6) - (8)].instr), (yyvsp[(8) - (8)].list), &loc);
3868 pop_scope(&hlsl_ctx);
3869 }
3870 break;
3871
3872 case 103:
3873
3874 /* Line 1806 of yacc.c */
3875 #line 1739 "hlsl.y"
3876 {
3877 struct source_location loc;
3878
3879 set_location(&loc, &(yylsp[(1) - (8)]));
3880 if (!(yyvsp[(4) - (8)].list))
3881 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_WARNING,
3882 "no expressions in for loop initializer");
3883 (yyval.list) = create_loop(LOOP_FOR, (yyvsp[(4) - (8)].list), (yyvsp[(5) - (8)].list), (yyvsp[(6) - (8)].instr), (yyvsp[(8) - (8)].list), &loc);
3884 pop_scope(&hlsl_ctx);
3885 }
3886 break;
3887
3888 case 104:
3889
3890 /* Line 1806 of yacc.c */
3891 #line 1751 "hlsl.y"
3892 {
3893 (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3894 list_init((yyval.list));
3895 }
3896 break;
3897
3898 case 105:
3899
3900 /* Line 1806 of yacc.c */
3901 #line 1756 "hlsl.y"
3902 {
3903 (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3904 list_init((yyval.list));
3905 if ((yyvsp[(1) - (2)].instr))
3906 list_add_head((yyval.list), &(yyvsp[(1) - (2)].instr)->entry);
3907 }
3908 break;
3909
3910 case 106:
3911
3912 /* Line 1806 of yacc.c */
3913 #line 1764 "hlsl.y"
3914 {
3915 struct hlsl_ir_constant *c = d3dcompiler_alloc(sizeof(*c));
3916 if (!c)
3917 {
3918 ERR("Out of memory.\n");
3919 return -1;
3920 }
3921 c->node.type = HLSL_IR_CONSTANT;
3922 set_location(&c->node.loc, &yylloc);
3923 c->node.data_type = new_hlsl_type(d3dcompiler_strdup("float"), HLSL_CLASS_SCALAR, HLSL_TYPE_FLOAT, 1, 1);
3924 c->v.value.f[0] = (yyvsp[(1) - (1)].floatval);
3925 (yyval.instr) = &c->node;
3926 }
3927 break;
3928
3929 case 107:
3930
3931 /* Line 1806 of yacc.c */
3932 #line 1778 "hlsl.y"
3933 {
3934 struct hlsl_ir_constant *c = d3dcompiler_alloc(sizeof(*c));
3935 if (!c)
3936 {
3937 ERR("Out of memory.\n");
3938 return -1;
3939 }
3940 c->node.type = HLSL_IR_CONSTANT;
3941 set_location(&c->node.loc, &yylloc);
3942 c->node.data_type = new_hlsl_type(d3dcompiler_strdup("int"), HLSL_CLASS_SCALAR, HLSL_TYPE_INT, 1, 1);
3943 c->v.value.i[0] = (yyvsp[(1) - (1)].intval);
3944 (yyval.instr) = &c->node;
3945 }
3946 break;
3947
3948 case 108:
3949
3950 /* Line 1806 of yacc.c */
3951 #line 1792 "hlsl.y"
3952 {
3953 struct hlsl_ir_constant *c = d3dcompiler_alloc(sizeof(*c));
3954 if (!c)
3955 {
3956 ERR("Out of memory.\n");
3957 return -1;
3958 }
3959 c->node.type = HLSL_IR_CONSTANT;
3960 set_location(&c->node.loc, &yylloc);
3961 c->node.data_type = new_hlsl_type(d3dcompiler_strdup("bool"), HLSL_CLASS_SCALAR, HLSL_TYPE_BOOL, 1, 1);
3962 c->v.value.b[0] = (yyvsp[(1) - (1)].boolval);
3963 (yyval.instr) = &c->node;
3964 }
3965 break;
3966
3967 case 109:
3968
3969 /* Line 1806 of yacc.c */
3970 #line 1806 "hlsl.y"
3971 {
3972 struct hlsl_ir_deref *deref = new_var_deref((yyvsp[(1) - (1)].var));
3973 if (deref)
3974 {
3975 (yyval.instr) = &deref->node;
3976 set_location(&(yyval.instr)->loc, &(yylsp[(1) - (1)]));
3977 }
3978 else
3979 (yyval.instr) = NULL;
3980 }
3981 break;
3982
3983 case 110:
3984
3985 /* Line 1806 of yacc.c */
3986 #line 1817 "hlsl.y"
3987 {
3988 (yyval.instr) = (yyvsp[(2) - (3)].instr);
3989 }
3990 break;
3991
3992 case 111:
3993
3994 /* Line 1806 of yacc.c */
3995 #line 1822 "hlsl.y"
3996 {
3997 struct hlsl_ir_var *var;
3998 var = get_variable(hlsl_ctx.cur_scope, (yyvsp[(1) - (1)].name));
3999 if (!var)
4000 {
4001 hlsl_message("Line %d: variable '%s' not declared\n",
4002 hlsl_ctx.line_no, (yyvsp[(1) - (1)].name));
4003 set_parse_status(&hlsl_ctx.status, PARSE_ERR);
4004 return 1;
4005 }
4006 (yyval.var) = var;
4007 }
4008 break;
4009
4010 case 112:
4011
4012 /* Line 1806 of yacc.c */
4013 #line 1836 "hlsl.y"
4014 {
4015 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4016 }
4017 break;
4018
4019 case 113:
4020
4021 /* Line 1806 of yacc.c */
4022 #line 1840 "hlsl.y"
4023 {
4024 struct hlsl_ir_node *operands[3];
4025 struct source_location loc;
4026
4027 set_location(&loc, &(yylsp[(2) - (2)]));
4028 if ((yyvsp[(1) - (2)].instr)->data_type->modifiers & HLSL_MODIFIER_CONST)
4029 {
4030 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
4031 "modifying a const expression");
4032 return 1;
4033 }
4034 operands[0] = (yyvsp[(1) - (2)].instr);
4035 operands[1] = operands[2] = NULL;
4036 (yyval.instr) = &new_expr(HLSL_IR_BINOP_POSTINC, operands, &loc)->node;
4037 /* Post increment/decrement expressions are considered const */
4038 (yyval.instr)->data_type = clone_hlsl_type((yyval.instr)->data_type);
4039 (yyval.instr)->data_type->modifiers |= HLSL_MODIFIER_CONST;
4040 }
4041 break;
4042
4043 case 114:
4044
4045 /* Line 1806 of yacc.c */
4046 #line 1859 "hlsl.y"
4047 {
4048 struct hlsl_ir_node *operands[3];
4049 struct source_location loc;
4050
4051 set_location(&loc, &(yylsp[(2) - (2)]));
4052 if ((yyvsp[(1) - (2)].instr)->data_type->modifiers & HLSL_MODIFIER_CONST)
4053 {
4054 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
4055 "modifying a const expression");
4056 return 1;
4057 }
4058 operands[0] = (yyvsp[(1) - (2)].instr);
4059 operands[1] = operands[2] = NULL;
4060 (yyval.instr) = &new_expr(HLSL_IR_BINOP_POSTDEC, operands, &loc)->node;
4061 /* Post increment/decrement expressions are considered const */
4062 (yyval.instr)->data_type = clone_hlsl_type((yyval.instr)->data_type);
4063 (yyval.instr)->data_type->modifiers |= HLSL_MODIFIER_CONST;
4064 }
4065 break;
4066
4067 case 115:
4068
4069 /* Line 1806 of yacc.c */
4070 #line 1878 "hlsl.y"
4071 {
4072 struct source_location loc;
4073
4074 set_location(&loc, &(yylsp[(2) - (3)]));
4075 if ((yyvsp[(1) - (3)].instr)->data_type->type == HLSL_CLASS_STRUCT)
4076 {
4077 struct hlsl_type *type = (yyvsp[(1) - (3)].instr)->data_type;
4078 struct hlsl_struct_field *field;
4079
4080 (yyval.instr) = NULL;
4081 LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry)
4082 {
4083 if (!strcmp((yyvsp[(3) - (3)].name), field->name))
4084 {
4085 struct hlsl_ir_deref *deref = new_record_deref((yyvsp[(1) - (3)].instr), field);
4086
4087 if (!deref)
4088 {
4089 ERR("Out of memory\n");
4090 return -1;
4091 }
4092 deref->node.loc = loc;
4093 (yyval.instr) = &deref->node;
4094 break;
4095 }
4096 }
4097 if (!(yyval.instr))
4098 {
4099 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
4100 "invalid subscript %s", debugstr_a((yyvsp[(3) - (3)].name)));
4101 return 1;
4102 }
4103 }
4104 else if ((yyvsp[(1) - (3)].instr)->data_type->type <= HLSL_CLASS_LAST_NUMERIC)
4105 {
4106 struct hlsl_ir_swizzle *swizzle;
4107
4108 swizzle = get_swizzle((yyvsp[(1) - (3)].instr), (yyvsp[(3) - (3)].name), &loc);
4109 if (!swizzle)
4110 {
4111 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
4112 "invalid swizzle %s", debugstr_a((yyvsp[(3) - (3)].name)));
4113 return 1;
4114 }
4115 (yyval.instr) = &swizzle->node;
4116 }
4117 else
4118 {
4119 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
4120 "invalid subscript %s", debugstr_a((yyvsp[(3) - (3)].name)));
4121 return 1;
4122 }
4123 }
4124 break;
4125
4126 case 116:
4127
4128 /* Line 1806 of yacc.c */
4129 #line 1932 "hlsl.y"
4130 {
4131 /* This may be an array dereference or a vector/matrix
4132 * subcomponent access.
4133 * We store it as an array dereference in any case. */
4134 struct hlsl_ir_deref *deref = d3dcompiler_alloc(sizeof(*deref));
4135 struct hlsl_type *expr_type = (yyvsp[(1) - (4)].instr)->data_type;
4136 struct source_location loc;
4137
4138 TRACE("Array dereference from type %s\n", debug_hlsl_type(expr_type));
4139 if (!deref)
4140 {
4141 ERR("Out of memory\n");
4142 return -1;
4143 }
4144 deref->node.type = HLSL_IR_DEREF;
4145 set_location(&loc, &(yylsp[(2) - (4)]));
4146 deref->node.loc = loc;
4147 if (expr_type->type == HLSL_CLASS_ARRAY)
4148 {
4149 deref->node.data_type = expr_type->e.array.type;
4150 }
4151 else if (expr_type->type == HLSL_CLASS_MATRIX)
4152 {
4153 deref->node.data_type = new_hlsl_type(NULL, HLSL_CLASS_VECTOR, expr_type->base_type, expr_type->dimx, 1);
4154 }
4155 else if (expr_type->type == HLSL_CLASS_VECTOR)
4156 {
4157 deref->node.data_type = new_hlsl_type(NULL, HLSL_CLASS_SCALAR, expr_type->base_type, 1, 1);
4158 }
4159 else
4160 {
4161 if (expr_type->type == HLSL_CLASS_SCALAR)
4162 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
4163 "array-indexed expression is scalar");
4164 else
4165 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
4166 "expression is not array-indexable");
4167 d3dcompiler_free(deref);
4168 free_instr((yyvsp[(1) - (4)].instr));
4169 free_instr((yyvsp[(3) - (4)].instr));
4170 return 1;
4171 }
4172 if ((yyvsp[(3) - (4)].instr)->data_type->type != HLSL_CLASS_SCALAR)
4173 {
4174 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
4175 "array index is not scalar");
4176 d3dcompiler_free(deref);
4177 free_instr((yyvsp[(1) - (4)].instr));
4178 free_instr((yyvsp[(3) - (4)].instr));
4179 return 1;
4180 }
4181 deref->type = HLSL_IR_DEREF_ARRAY;
4182 deref->v.array.array = (yyvsp[(1) - (4)].instr);
4183 deref->v.array.index = (yyvsp[(3) - (4)].instr);
4184
4185 (yyval.instr) = &deref->node;
4186 }
4187 break;
4188
4189 case 117:
4190
4191 /* Line 1806 of yacc.c */
4192 #line 1992 "hlsl.y"
4193 {
4194 struct hlsl_ir_constructor *constructor;
4195
4196 TRACE("%s constructor.\n", debug_hlsl_type((yyvsp[(2) - (5)].type)));
4197 if ((yyvsp[(1) - (5)].modifiers))
4198 {
4199 hlsl_message("Line %u: unexpected modifier in a constructor.\n",
4200 hlsl_ctx.line_no);
4201 set_parse_status(&hlsl_ctx.status, PARSE_ERR);
4202 return -1;
4203 }
4204 if ((yyvsp[(2) - (5)].type)->type > HLSL_CLASS_LAST_NUMERIC)
4205 {
4206 hlsl_message("Line %u: constructors are allowed only for numeric data types.\n",
4207 hlsl_ctx.line_no);
4208 set_parse_status(&hlsl_ctx.status, PARSE_ERR);
4209 return -1;
4210 }
4211 if ((yyvsp[(2) - (5)].type)->dimx * (yyvsp[(2) - (5)].type)->dimy != components_count_expr_list((yyvsp[(4) - (5)].list)))
4212 {
4213 hlsl_message("Line %u: wrong number of components in constructor.\n",
4214 hlsl_ctx.line_no);
4215 set_parse_status(&hlsl_ctx.status, PARSE_ERR);
4216 return -1;
4217 }
4218
4219 constructor = d3dcompiler_alloc(sizeof(*constructor));
4220 constructor->node.type = HLSL_IR_CONSTRUCTOR;
4221 set_location(&constructor->node.loc, &(yylsp[(3) - (5)]));
4222 constructor->node.data_type = (yyvsp[(2) - (5)].type);
4223 constructor->arguments = (yyvsp[(4) - (5)].list);
4224
4225 (yyval.instr) = &constructor->node;
4226 }
4227 break;
4228
4229 case 118:
4230
4231 /* Line 1806 of yacc.c */
4232 #line 2028 "hlsl.y"
4233 {
4234 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4235 }
4236 break;
4237
4238 case 119:
4239
4240 /* Line 1806 of yacc.c */
4241 #line 2032 "hlsl.y"
4242 {
4243 struct hlsl_ir_node *operands[3];
4244 struct source_location loc;
4245
4246 set_location(&loc, &(yylsp[(1) - (2)]));
4247 if ((yyvsp[(2) - (2)].instr)->data_type->modifiers & HLSL_MODIFIER_CONST)
4248 {
4249 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
4250 "modifying a const expression");
4251 return 1;
4252 }
4253 operands[0] = (yyvsp[(2) - (2)].instr);
4254 operands[1] = operands[2] = NULL;
4255 (yyval.instr) = &new_expr(HLSL_IR_BINOP_PREINC, operands, &loc)->node;
4256 }
4257 break;
4258
4259 case 120:
4260
4261 /* Line 1806 of yacc.c */
4262 #line 2048 "hlsl.y"
4263 {
4264 struct hlsl_ir_node *operands[3];
4265 struct source_location loc;
4266
4267 set_location(&loc, &(yylsp[(1) - (2)]));
4268 if ((yyvsp[(2) - (2)].instr)->data_type->modifiers & HLSL_MODIFIER_CONST)
4269 {
4270 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
4271 "modifying a const expression");
4272 return 1;
4273 }
4274 operands[0] = (yyvsp[(2) - (2)].instr);
4275 operands[1] = operands[2] = NULL;
4276 (yyval.instr) = &new_expr(HLSL_IR_BINOP_PREDEC, operands, &loc)->node;
4277 }
4278 break;
4279
4280 case 121:
4281
4282 /* Line 1806 of yacc.c */
4283 #line 2064 "hlsl.y"
4284 {
4285 enum hlsl_ir_expr_op ops[] = {0, HLSL_IR_UNOP_NEG,
4286 HLSL_IR_UNOP_LOGIC_NOT, HLSL_IR_UNOP_BIT_NOT};
4287 struct hlsl_ir_node *operands[3];
4288 struct source_location loc;
4289
4290 if ((yyvsp[(1) - (2)].unary_op) == UNARY_OP_PLUS)
4291 {
4292 (yyval.instr) = (yyvsp[(2) - (2)].instr);
4293 }
4294 else
4295 {
4296 operands[0] = (yyvsp[(2) - (2)].instr);
4297 operands[1] = operands[2] = NULL;
4298 set_location(&loc, &(yylsp[(1) - (2)]));
4299 (yyval.instr) = &new_expr(ops[(yyvsp[(1) - (2)].unary_op)], operands, &loc)->node;
4300 }
4301 }
4302 break;
4303
4304 case 122:
4305
4306 /* Line 1806 of yacc.c */
4307 #line 2084 "hlsl.y"
4308 {
4309 struct hlsl_ir_expr *expr;
4310 struct hlsl_type *src_type = (yyvsp[(6) - (6)].instr)->data_type;
4311 struct hlsl_type *dst_type;
4312 struct source_location loc;
4313
4314 set_location(&loc, &(yylsp[(3) - (6)]));
4315 if ((yyvsp[(2) - (6)].modifiers))
4316 {
4317 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
4318 "unexpected modifier in a cast");
4319 return 1;
4320 }
4321
4322 if ((yyvsp[(4) - (6)].intval))
4323 dst_type = new_array_type((yyvsp[(3) - (6)].type), (yyvsp[(4) - (6)].intval));
4324 else
4325 dst_type = (yyvsp[(3) - (6)].type);
4326
4327 if (!compatible_data_types(src_type, dst_type))
4328 {
4329 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
4330 "can't cast from %s to %s",
4331 debug_hlsl_type(src_type), debug_hlsl_type(dst_type));
4332 return 1;
4333 }
4334
4335 expr = new_cast((yyvsp[(6) - (6)].instr), dst_type, &loc);
4336 (yyval.instr) = expr ? &expr->node : NULL;
4337 }
4338 break;
4339
4340 case 123:
4341
4342 /* Line 1806 of yacc.c */
4343 #line 2116 "hlsl.y"
4344 {
4345 (yyval.unary_op) = UNARY_OP_PLUS;
4346 }
4347 break;
4348
4349 case 124:
4350
4351 /* Line 1806 of yacc.c */
4352 #line 2120 "hlsl.y"
4353 {
4354 (yyval.unary_op) = UNARY_OP_MINUS;
4355 }
4356 break;
4357
4358 case 125:
4359
4360 /* Line 1806 of yacc.c */
4361 #line 2124 "hlsl.y"
4362 {
4363 (yyval.unary_op) = UNARY_OP_LOGICNOT;
4364 }
4365 break;
4366
4367 case 126:
4368
4369 /* Line 1806 of yacc.c */
4370 #line 2128 "hlsl.y"
4371 {
4372 (yyval.unary_op) = UNARY_OP_BITNOT;
4373 }
4374 break;
4375
4376 case 127:
4377
4378 /* Line 1806 of yacc.c */
4379 #line 2133 "hlsl.y"
4380 {
4381 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4382 }
4383 break;
4384
4385 case 128:
4386
4387 /* Line 1806 of yacc.c */
4388 #line 2137 "hlsl.y"
4389 {
4390 struct source_location loc;
4391
4392 set_location(&loc, &(yylsp[(2) - (3)]));
4393 (yyval.instr) = &hlsl_mul((yyvsp[(1) - (3)].instr), (yyvsp[(3) - (3)].instr), &loc)->node;
4394 }
4395 break;
4396
4397 case 129:
4398
4399 /* Line 1806 of yacc.c */
4400 #line 2144 "hlsl.y"
4401 {
4402 struct source_location loc;
4403
4404 set_location(&loc, &(yylsp[(2) - (3)]));
4405 (yyval.instr) = &hlsl_div((yyvsp[(1) - (3)].instr), (yyvsp[(3) - (3)].instr), &loc)->node;
4406 }
4407 break;
4408
4409 case 130:
4410
4411 /* Line 1806 of yacc.c */
4412 #line 2151 "hlsl.y"
4413 {
4414 struct source_location loc;
4415
4416 set_location(&loc, &(yylsp[(2) - (3)]));
4417 (yyval.instr) = &hlsl_mod((yyvsp[(1) - (3)].instr), (yyvsp[(3) - (3)].instr), &loc)->node;
4418 }
4419 break;
4420
4421 case 131:
4422
4423 /* Line 1806 of yacc.c */
4424 #line 2159 "hlsl.y"
4425 {
4426 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4427 }
4428 break;
4429
4430 case 132:
4431
4432 /* Line 1806 of yacc.c */
4433 #line 2163 "hlsl.y"
4434 {
4435 struct source_location loc;
4436
4437 set_location(&loc, &(yylsp[(2) - (3)]));
4438 (yyval.instr) = &hlsl_add((yyvsp[(1) - (3)].instr), (yyvsp[(3) - (3)].instr), &loc)->node;
4439 }
4440 break;
4441
4442 case 133:
4443
4444 /* Line 1806 of yacc.c */
4445 #line 2170 "hlsl.y"
4446 {
4447 struct source_location loc;
4448
4449 set_location(&loc, &(yylsp[(2) - (3)]));
4450 (yyval.instr) = &hlsl_sub((yyvsp[(1) - (3)].instr), (yyvsp[(3) - (3)].instr), &loc)->node;
4451 }
4452 break;
4453
4454 case 134:
4455
4456 /* Line 1806 of yacc.c */
4457 #line 2178 "hlsl.y"
4458 {
4459 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4460 }
4461 break;
4462
4463 case 135:
4464
4465 /* Line 1806 of yacc.c */
4466 #line 2182 "hlsl.y"
4467 {
4468 FIXME("Left shift\n");
4469 }
4470 break;
4471
4472 case 136:
4473
4474 /* Line 1806 of yacc.c */
4475 #line 2186 "hlsl.y"
4476 {
4477 FIXME("Right shift\n");
4478 }
4479 break;
4480
4481 case 137:
4482
4483 /* Line 1806 of yacc.c */
4484 #line 2191 "hlsl.y"
4485 {
4486 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4487 }
4488 break;
4489
4490 case 138:
4491
4492 /* Line 1806 of yacc.c */
4493 #line 2195 "hlsl.y"
4494 {
4495 struct source_location loc;
4496
4497 set_location(&loc, &(yylsp[(2) - (3)]));
4498 (yyval.instr) = &hlsl_lt((yyvsp[(1) - (3)].instr), (yyvsp[(3) - (3)].instr), &loc)->node;
4499 }
4500 break;
4501
4502 case 139:
4503
4504 /* Line 1806 of yacc.c */
4505 #line 2202 "hlsl.y"
4506 {
4507 struct source_location loc;
4508
4509 set_location(&loc, &(yylsp[(2) - (3)]));
4510 (yyval.instr) = &hlsl_gt((yyvsp[(1) - (3)].instr), (yyvsp[(3) - (3)].instr), &loc)->node;
4511 }
4512 break;
4513
4514 case 140:
4515
4516 /* Line 1806 of yacc.c */
4517 #line 2209 "hlsl.y"
4518 {
4519 struct source_location loc;
4520
4521 set_location(&loc, &(yylsp[(2) - (3)]));
4522 (yyval.instr) = &hlsl_le((yyvsp[(1) - (3)].instr), (yyvsp[(3) - (3)].instr), &loc)->node;
4523 }
4524 break;
4525
4526 case 141:
4527
4528 /* Line 1806 of yacc.c */
4529 #line 2216 "hlsl.y"
4530 {
4531 struct source_location loc;
4532
4533 set_location(&loc, &(yylsp[(2) - (3)]));
4534 (yyval.instr) = &hlsl_ge((yyvsp[(1) - (3)].instr), (yyvsp[(3) - (3)].instr), &loc)->node;
4535 }
4536 break;
4537
4538 case 142:
4539
4540 /* Line 1806 of yacc.c */
4541 #line 2224 "hlsl.y"
4542 {
4543 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4544 }
4545 break;
4546
4547 case 143:
4548
4549 /* Line 1806 of yacc.c */
4550 #line 2228 "hlsl.y"
4551 {
4552 struct source_location loc;
4553
4554 set_location(&loc, &(yylsp[(2) - (3)]));
4555 (yyval.instr) = &hlsl_eq((yyvsp[(1) - (3)].instr), (yyvsp[(3) - (3)].instr), &loc)->node;
4556 }
4557 break;
4558
4559 case 144:
4560
4561 /* Line 1806 of yacc.c */
4562 #line 2235 "hlsl.y"
4563 {
4564 struct source_location loc;
4565
4566 set_location(&loc, &(yylsp[(2) - (3)]));
4567 (yyval.instr) = &hlsl_ne((yyvsp[(1) - (3)].instr), (yyvsp[(3) - (3)].instr), &loc)->node;
4568 }
4569 break;
4570
4571 case 145:
4572
4573 /* Line 1806 of yacc.c */
4574 #line 2243 "hlsl.y"
4575 {
4576 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4577 }
4578 break;
4579
4580 case 146:
4581
4582 /* Line 1806 of yacc.c */
4583 #line 2247 "hlsl.y"
4584 {
4585 FIXME("bitwise AND\n");
4586 }
4587 break;
4588
4589 case 147:
4590
4591 /* Line 1806 of yacc.c */
4592 #line 2252 "hlsl.y"
4593 {
4594 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4595 }
4596 break;
4597
4598 case 148:
4599
4600 /* Line 1806 of yacc.c */
4601 #line 2256 "hlsl.y"
4602 {
4603 FIXME("bitwise XOR\n");
4604 }
4605 break;
4606
4607 case 149:
4608
4609 /* Line 1806 of yacc.c */
4610 #line 2261 "hlsl.y"
4611 {
4612 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4613 }
4614 break;
4615
4616 case 150:
4617
4618 /* Line 1806 of yacc.c */
4619 #line 2265 "hlsl.y"
4620 {
4621 FIXME("bitwise OR\n");
4622 }
4623 break;
4624
4625 case 151:
4626
4627 /* Line 1806 of yacc.c */
4628 #line 2270 "hlsl.y"
4629 {
4630 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4631 }
4632 break;
4633
4634 case 152:
4635
4636 /* Line 1806 of yacc.c */
4637 #line 2274 "hlsl.y"
4638 {
4639 FIXME("logic AND\n");
4640 }
4641 break;
4642
4643 case 153:
4644
4645 /* Line 1806 of yacc.c */
4646 #line 2279 "hlsl.y"
4647 {
4648 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4649 }
4650 break;
4651
4652 case 154:
4653
4654 /* Line 1806 of yacc.c */
4655 #line 2283 "hlsl.y"
4656 {
4657 FIXME("logic OR\n");
4658 }
4659 break;
4660
4661 case 155:
4662
4663 /* Line 1806 of yacc.c */
4664 #line 2288 "hlsl.y"
4665 {
4666 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4667 }
4668 break;
4669
4670 case 156:
4671
4672 /* Line 1806 of yacc.c */
4673 #line 2292 "hlsl.y"
4674 {
4675 FIXME("ternary operator\n");
4676 }
4677 break;
4678
4679 case 157:
4680
4681 /* Line 1806 of yacc.c */
4682 #line 2297 "hlsl.y"
4683 {
4684 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4685 }
4686 break;
4687
4688 case 158:
4689
4690 /* Line 1806 of yacc.c */
4691 #line 2301 "hlsl.y"
4692 {
4693 struct source_location loc;
4694
4695 set_location(&loc, &(yylsp[(2) - (3)]));
4696 if ((yyvsp[(1) - (3)].instr)->data_type->modifiers & HLSL_MODIFIER_CONST)
4697 {
4698 hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
4699 "l-value is const");
4700 return 1;
4701 }
4702 (yyval.instr) = make_assignment((yyvsp[(1) - (3)].instr), (yyvsp[(2) - (3)].assign_op), BWRITERSP_WRITEMASK_ALL, (yyvsp[(3) - (3)].instr));
4703 if (!(yyval.instr))
4704 return 1;
4705 (yyval.instr)->loc = loc;
4706 }
4707 break;
4708
4709 case 159:
4710
4711 /* Line 1806 of yacc.c */
4712 #line 2318 "hlsl.y"
4713 {
4714 (yyval.assign_op) = ASSIGN_OP_ASSIGN;
4715 }
4716 break;
4717
4718 case 160:
4719
4720 /* Line 1806 of yacc.c */
4721 #line 2322 "hlsl.y"
4722 {
4723 (yyval.assign_op) = ASSIGN_OP_ADD;
4724 }
4725 break;
4726
4727 case 161:
4728
4729 /* Line 1806 of yacc.c */
4730 #line 2326 "hlsl.y"
4731 {
4732 (yyval.assign_op) = ASSIGN_OP_SUB;
4733 }
4734 break;
4735
4736 case 162:
4737
4738 /* Line 1806 of yacc.c */
4739 #line 2330 "hlsl.y"
4740 {
4741 (yyval.assign_op) = ASSIGN_OP_MUL;
4742 }
4743 break;
4744
4745 case 163:
4746
4747 /* Line 1806 of yacc.c */
4748 #line 2334 "hlsl.y"
4749 {
4750 (yyval.assign_op) = ASSIGN_OP_DIV;
4751 }
4752 break;
4753
4754 case 164:
4755
4756 /* Line 1806 of yacc.c */
4757 #line 2338 "hlsl.y"
4758 {
4759 (yyval.assign_op) = ASSIGN_OP_MOD;
4760 }
4761 break;
4762
4763 case 165:
4764
4765 /* Line 1806 of yacc.c */
4766 #line 2342 "hlsl.y"
4767 {
4768 (yyval.assign_op) = ASSIGN_OP_LSHIFT;
4769 }
4770 break;
4771
4772 case 166:
4773
4774 /* Line 1806 of yacc.c */
4775 #line 2346 "hlsl.y"
4776 {
4777 (yyval.assign_op) = ASSIGN_OP_RSHIFT;
4778 }
4779 break;
4780
4781 case 167:
4782
4783 /* Line 1806 of yacc.c */
4784 #line 2350 "hlsl.y"
4785 {
4786 (yyval.assign_op) = ASSIGN_OP_AND;
4787 }
4788 break;
4789
4790 case 168:
4791
4792 /* Line 1806 of yacc.c */
4793 #line 2354 "hlsl.y"
4794 {
4795 (yyval.assign_op) = ASSIGN_OP_OR;
4796 }
4797 break;
4798
4799 case 169:
4800
4801 /* Line 1806 of yacc.c */
4802 #line 2358 "hlsl.y"
4803 {
4804 (yyval.assign_op) = ASSIGN_OP_XOR;
4805 }
4806 break;
4807
4808 case 170:
4809
4810 /* Line 1806 of yacc.c */
4811 #line 2363 "hlsl.y"
4812 {
4813 (yyval.instr) = (yyvsp[(1) - (1)].instr);
4814 }
4815 break;
4816
4817 case 171:
4818
4819 /* Line 1806 of yacc.c */
4820 #line 2367 "hlsl.y"
4821 {
4822 FIXME("Comma expression\n");
4823 }
4824 break;
4825
4826
4827
4828 /* Line 1806 of yacc.c */
4829 #line 4835 "hlsl.tab.c"
4830 default: break;
4831 }
4832 /* User semantic actions sometimes alter yychar, and that requires
4833 that yytoken be updated with the new translation. We take the
4834 approach of translating immediately before every use of yytoken.
4835 One alternative is translating here after every semantic action,
4836 but that translation would be missed if the semantic action invokes
4837 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
4838 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
4839 incorrect destructor might then be invoked immediately. In the
4840 case of YYERROR or YYBACKUP, subsequent parser actions might lead
4841 to an incorrect destructor call or verbose syntax error message
4842 before the lookahead is translated. */
4843 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
4844
4845 YYPOPSTACK (yylen);
4846 yylen = 0;
4847 YY_STACK_PRINT (yyss, yyssp);
4848
4849 *++yyvsp = yyval;
4850 *++yylsp = yyloc;
4851
4852 /* Now `shift' the result of the reduction. Determine what state
4853 that goes to, based on the state we popped back to and the rule
4854 number reduced by. */
4855
4856 yyn = yyr1[yyn];
4857
4858 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
4859 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4860 yystate = yytable[yystate];
4861 else
4862 yystate = yydefgoto[yyn - YYNTOKENS];
4863
4864 goto yynewstate;
4865
4866
4867 /*------------------------------------.
4868 | yyerrlab -- here on detecting error |
4869 `------------------------------------*/
4870 yyerrlab:
4871 /* Make sure we have latest lookahead translation. See comments at
4872 user semantic actions for why this is necessary. */
4873 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
4874
4875 /* If not already recovering from an error, report this error. */
4876 if (!yyerrstatus)
4877 {
4878 ++yynerrs;
4879 #if ! YYERROR_VERBOSE
4880 yyerror (YY_("syntax error"));
4881 #else
4882 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
4883 yyssp, yytoken)
4884 {
4885 char const *yymsgp = YY_("syntax error");
4886 int yysyntax_error_status;
4887 yysyntax_error_status = YYSYNTAX_ERROR;
4888 if (yysyntax_error_status == 0)
4889 yymsgp = yymsg;
4890 else if (yysyntax_error_status == 1)
4891 {
4892 if (yymsg != yymsgbuf)
4893 YYSTACK_FREE (yymsg);
4894 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
4895 if (!yymsg)
4896 {
4897 yymsg = yymsgbuf;
4898 yymsg_alloc = sizeof yymsgbuf;
4899 yysyntax_error_status = 2;
4900 }
4901 else
4902 {
4903 yysyntax_error_status = YYSYNTAX_ERROR;
4904 yymsgp = yymsg;
4905 }
4906 }
4907 yyerror (yymsgp);
4908 if (yysyntax_error_status == 2)
4909 goto yyexhaustedlab;
4910 }
4911 # undef YYSYNTAX_ERROR
4912 #endif
4913 }
4914
4915 yyerror_range[1] = yylloc;
4916
4917 if (yyerrstatus == 3)
4918 {
4919 /* If just tried and failed to reuse lookahead token after an
4920 error, discard it. */
4921
4922 if (yychar <= YYEOF)
4923 {
4924 /* Return failure if at end of input. */
4925 if (yychar == YYEOF)
4926 YYABORT;
4927 }
4928 else
4929 {
4930 yydestruct ("Error: discarding",
4931 yytoken, &yylval, &yylloc);
4932 yychar = YYEMPTY;
4933 }
4934 }
4935
4936 /* Else will try to reuse lookahead token after shifting the error
4937 token. */
4938 goto yyerrlab1;
4939
4940
4941 /*---------------------------------------------------.
4942 | yyerrorlab -- error raised explicitly by YYERROR. |
4943 `---------------------------------------------------*/
4944 yyerrorlab:
4945
4946 /* Pacify compilers like GCC when the user code never invokes
4947 YYERROR and the label yyerrorlab therefore never appears in user
4948 code. */
4949 if (/*CONSTCOND*/ 0)
4950 goto yyerrorlab;
4951
4952 yyerror_range[1] = yylsp[1-yylen];
4953 /* Do not reclaim the symbols of the rule which action triggered
4954 this YYERROR. */
4955 YYPOPSTACK (yylen);
4956 yylen = 0;
4957 YY_STACK_PRINT (yyss, yyssp);
4958 yystate = *yyssp;
4959 goto yyerrlab1;
4960
4961
4962 /*-------------------------------------------------------------.
4963 | yyerrlab1 -- common code for both syntax error and YYERROR. |
4964 `-------------------------------------------------------------*/
4965 yyerrlab1:
4966 yyerrstatus = 3; /* Each real token shifted decrements this. */
4967
4968 for (;;)
4969 {
4970 yyn = yypact[yystate];
4971 if (!yypact_value_is_default (yyn))
4972 {
4973 yyn += YYTERROR;
4974 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
4975 {
4976 yyn = yytable[yyn];
4977 if (0 < yyn)
4978 break;
4979 }
4980 }
4981
4982 /* Pop the current state because it cannot handle the error token. */
4983 if (yyssp == yyss)
4984 YYABORT;
4985
4986 yyerror_range[1] = *yylsp;
4987 yydestruct ("Error: popping",
4988 yystos[yystate], yyvsp, yylsp);
4989 YYPOPSTACK (1);
4990 yystate = *yyssp;
4991 YY_STACK_PRINT (yyss, yyssp);
4992 }
4993
4994 *++yyvsp = yylval;
4995
4996 yyerror_range[2] = yylloc;
4997 /* Using YYLLOC is tempting, but would change the location of
4998 the lookahead. YYLOC is available though. */
4999 YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
5000 *++yylsp = yyloc;
5001
5002 /* Shift the error token. */
5003 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
5004
5005 yystate = yyn;
5006 goto yynewstate;
5007
5008
5009 /*-------------------------------------.
5010 | yyacceptlab -- YYACCEPT comes here. |
5011 `-------------------------------------*/
5012 yyacceptlab:
5013 yyresult = 0;
5014 goto yyreturn;
5015
5016 /*-----------------------------------.
5017 | yyabortlab -- YYABORT comes here. |
5018 `-----------------------------------*/
5019 yyabortlab:
5020 yyresult = 1;
5021 goto yyreturn;
5022
5023 #if !defined(yyoverflow) || YYERROR_VERBOSE
5024 /*-------------------------------------------------.
5025 | yyexhaustedlab -- memory exhaustion comes here. |
5026 `-------------------------------------------------*/
5027 yyexhaustedlab:
5028 yyerror (YY_("memory exhausted"));
5029 yyresult = 2;
5030 /* Fall through. */
5031 #endif
5032
5033 yyreturn:
5034 if (yychar != YYEMPTY)
5035 {
5036 /* Make sure we have latest lookahead translation. See comments at
5037 user semantic actions for why this is necessary. */
5038 yytoken = YYTRANSLATE (yychar);
5039 yydestruct ("Cleanup: discarding lookahead",
5040 yytoken, &yylval, &yylloc);
5041 }
5042 /* Do not reclaim the symbols of the rule which action triggered
5043 this YYABORT or YYACCEPT. */
5044 YYPOPSTACK (yylen);
5045 YY_STACK_PRINT (yyss, yyssp);
5046 while (yyssp != yyss)
5047 {
5048 yydestruct ("Cleanup: popping",
5049 yystos[*yyssp], yyvsp, yylsp);
5050 YYPOPSTACK (1);
5051 }
5052 #ifndef yyoverflow
5053 if (yyss != yyssa)
5054 YYSTACK_FREE (yyss);
5055 #endif
5056 #if YYERROR_VERBOSE
5057 if (yymsg != yymsgbuf)
5058 YYSTACK_FREE (yymsg);
5059 #endif
5060 /* Make sure YYID is used. */
5061 return YYID (yyresult);
5062 }
5063
5064
5065
5066 /* Line 2067 of yacc.c */
5067 #line 2371 "hlsl.y"
5068
5069
5070 static void set_location(struct source_location *loc, const struct YYLTYPE *l)
5071 {
5072 loc->file = hlsl_ctx.source_file;
5073 loc->line = l->first_line;
5074 loc->col = l->first_column;
5075 }
5076
5077 static DWORD add_modifier(DWORD modifiers, DWORD mod, const struct YYLTYPE *loc)
5078 {
5079 if (modifiers & mod)
5080 {
5081 hlsl_report_message(hlsl_ctx.source_file, loc->first_line, loc->first_column, HLSL_LEVEL_ERROR,
5082 "modifier '%s' already specified", debug_modifiers(mod));
5083 return modifiers;
5084 }
5085 if (mod & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)
5086 && modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR))
5087 {
5088 hlsl_report_message(hlsl_ctx.source_file, loc->first_line, loc->first_column, HLSL_LEVEL_ERROR,
5089 "more than one matrix majority keyword");
5090 return modifiers;
5091 }
5092 return modifiers | mod;
5093 }
5094
5095 static void dump_function_decl(struct wine_rb_entry *entry, void *context)
5096 {
5097 struct hlsl_ir_function_decl *func = WINE_RB_ENTRY_VALUE(entry, struct hlsl_ir_function_decl, entry);
5098 if (func->body)
5099 debug_dump_ir_function_decl(func);
5100 }
5101
5102 static void dump_function(struct wine_rb_entry *entry, void *context)
5103 {
5104 struct hlsl_ir_function *func = WINE_RB_ENTRY_VALUE(entry, struct hlsl_ir_function, entry);
5105 wine_rb_for_each_entry(&func->overloads, dump_function_decl, NULL);
5106 }
5107
5108 struct bwriter_shader *parse_hlsl(enum shader_type type, DWORD major, DWORD minor,
5109 const char *entrypoint, char **messages)
5110 {
5111 struct hlsl_scope *scope, *next_scope;
5112 struct hlsl_type *hlsl_type, *next_type;
5113 struct hlsl_ir_var *var, *next_var;
5114 unsigned int i;
5115
5116 hlsl_ctx.status = PARSE_SUCCESS;
5117 hlsl_ctx.messages.size = hlsl_ctx.messages.capacity = 0;
5118 hlsl_ctx.line_no = hlsl_ctx.column = 1;
5119 hlsl_ctx.source_file = d3dcompiler_strdup("");
5120 hlsl_ctx.source_files = d3dcompiler_alloc(sizeof(*hlsl_ctx.source_files));
5121 if (hlsl_ctx.source_files)
5122 hlsl_ctx.source_files[0] = hlsl_ctx.source_file;
5123 hlsl_ctx.source_files_count = 1;
5124 hlsl_ctx.cur_scope = NULL;
5125 hlsl_ctx.matrix_majority = HLSL_COLUMN_MAJOR;
5126 list_init(&hlsl_ctx.scopes);
5127 list_init(&hlsl_ctx.types);
5128 init_functions_tree(&hlsl_ctx.functions);
5129
5130 push_scope(&hlsl_ctx);
5131 hlsl_ctx.globals = hlsl_ctx.cur_scope;
5132 declare_predefined_types(hlsl_ctx.globals);
5133
5134 hlsl_parse();
5135
5136 if (TRACE_ON(hlsl_parser))
5137 {
5138 TRACE("IR dump.\n");
5139 wine_rb_for_each_entry(&hlsl_ctx.functions, dump_function, NULL);
5140 }
5141
5142 TRACE("Compilation status = %d\n", hlsl_ctx.status);
5143 if (messages)
5144 {
5145 if (hlsl_ctx.messages.size)
5146 *messages = hlsl_ctx.messages.string;
5147 else
5148 *messages = NULL;
5149 }
5150 else
5151 {
5152 if (hlsl_ctx.messages.capacity)
5153 d3dcompiler_free(hlsl_ctx.messages.string);
5154 }
5155
5156 for (i = 0; i < hlsl_ctx.source_files_count; ++i)
5157 d3dcompiler_free((void *)hlsl_ctx.source_files[i]);
5158 d3dcompiler_free(hlsl_ctx.source_files);
5159
5160 TRACE("Freeing functions IR.\n");
5161 wine_rb_destroy(&hlsl_ctx.functions, free_function_rb, NULL);
5162
5163 TRACE("Freeing variables.\n");
5164 LIST_FOR_EACH_ENTRY_SAFE(scope, next_scope, &hlsl_ctx.scopes, struct hlsl_scope, entry)
5165 {
5166 LIST_FOR_EACH_ENTRY_SAFE(var, next_var, &scope->vars, struct hlsl_ir_var, scope_entry)
5167 {
5168 free_declaration(var);
5169 }
5170 wine_rb_destroy(&scope->types, NULL, NULL);
5171 d3dcompiler_free(scope);
5172 }
5173
5174 TRACE("Freeing types.\n");
5175 LIST_FOR_EACH_ENTRY_SAFE(hlsl_type, next_type, &hlsl_ctx.types, struct hlsl_type, entry)
5176 {
5177 free_hlsl_type(hlsl_type);
5178 }
5179
5180 return NULL;
5181 }
5182