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