1/* A Bison parser, made by GNU Bison 3.7.4.  */
2
3/* Bison implementation for Yacc-like parsers in C
4
5   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 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/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38   especially those whose name start with YY_ or yy_.  They are
39   private implementation details that can be changed or removed.  */
40
41/* All symbols defined below should begin with yy or YY, to avoid
42   infringing on user name space.  This should be done even for local
43   variables, as they might otherwise be expanded by user macros.
44   There are some unavoidable exceptions within include files to
45   define necessary library symbols; they are noted "INFRINGES ON
46   USER NAME SPACE" below.  */
47
48/* Identify Bison output, and Bison version.  */
49#define YYBISON 30704
50
51/* Bison version string.  */
52#define YYBISON_VERSION "3.7.4"
53
54/* Skeleton name.  */
55#define YYSKELETON_NAME "yacc.c"
56
57/* Pure parsers.  */
58#define YYPURE 1
59
60/* Push parsers.  */
61#define YYPUSH 0
62
63/* Pull parsers.  */
64#define YYPULL 1
65
66
67
68
69/* First part of user prologue.  */
70#line 1 "../src/mesa/program/program_parse.y"
71
72/*
73 * Copyright © 2009 Intel Corporation
74 *
75 * Permission is hereby granted, free of charge, to any person obtaining a
76 * copy of this software and associated documentation files (the "Software"),
77 * to deal in the Software without restriction, including without limitation
78 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
79 * and/or sell copies of the Software, and to permit persons to whom the
80 * Software is furnished to do so, subject to the following conditions:
81 *
82 * The above copyright notice and this permission notice (including the next
83 * paragraph) shall be included in all copies or substantial portions of the
84 * Software.
85 *
86 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
87 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
88 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
89 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
90 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
92 * DEALINGS IN THE SOFTWARE.
93 */
94
95#include <stdarg.h>
96#include <stdio.h>
97#include <stdlib.h>
98#include <string.h>
99
100#include "main/errors.h"
101#include "main/mtypes.h"
102
103#include "program/program.h"
104#include "program/prog_parameter.h"
105#include "program/prog_parameter_layout.h"
106#include "program/prog_statevars.h"
107#include "program/prog_instruction.h"
108
109#include "program/symbol_table.h"
110#include "program/program_parser.h"
111
112#include "util/u_math.h"
113#include "util/u_memory.h"
114
115enum {
116   STATE_MATRIX_NO_MODIFIER,
117   STATE_MATRIX_INVERSE,
118   STATE_MATRIX_TRANSPOSE,
119   STATE_MATRIX_INVTRANS,
120};
121
122extern void *yy_scan_string(char *);
123extern void yy_delete_buffer(void *);
124
125static struct asm_symbol *declare_variable(struct asm_parser_state *state,
126    char *name, enum asm_type t, struct YYLTYPE *locp);
127
128static int add_state_reference(struct gl_program_parameter_list *param_list,
129    const gl_state_index16 tokens[STATE_LENGTH]);
130
131static int initialize_symbol_from_state(struct gl_program *prog,
132    struct asm_symbol *param_var, const gl_state_index16 tokens[STATE_LENGTH]);
133
134static int initialize_symbol_from_param(struct gl_program *prog,
135    struct asm_symbol *param_var, const gl_state_index16 tokens[STATE_LENGTH]);
136
137static int initialize_symbol_from_const(struct gl_program *prog,
138    struct asm_symbol *param_var, const struct asm_vector *vec,
139    GLboolean allowSwizzle);
140
141static int yyparse(struct asm_parser_state *state);
142
143static char *make_error_string(const char *fmt, ...);
144
145static void yyerror(struct YYLTYPE *locp, struct asm_parser_state *state,
146    const char *s);
147
148static int validate_inputs(struct YYLTYPE *locp,
149    struct asm_parser_state *state);
150
151static void init_dst_reg(struct prog_dst_register *r);
152
153static void set_dst_reg(struct prog_dst_register *r,
154                        gl_register_file file, GLint index);
155
156static void init_src_reg(struct asm_src_register *r);
157
158static void set_src_reg(struct asm_src_register *r,
159                        gl_register_file file, GLint index);
160
161static void set_src_reg_swz(struct asm_src_register *r,
162                            gl_register_file file, GLint index, GLuint swizzle);
163
164static void asm_instruction_set_operands(struct asm_instruction *inst,
165    const struct prog_dst_register *dst, const struct asm_src_register *src0,
166    const struct asm_src_register *src1, const struct asm_src_register *src2);
167
168static struct asm_instruction *asm_instruction_ctor(enum prog_opcode op,
169    const struct prog_dst_register *dst, const struct asm_src_register *src0,
170    const struct asm_src_register *src1, const struct asm_src_register *src2);
171
172static struct asm_instruction *asm_instruction_copy_ctor(
173    const struct prog_instruction *base, const struct prog_dst_register *dst,
174    const struct asm_src_register *src0, const struct asm_src_register *src1,
175    const struct asm_src_register *src2);
176
177#ifndef FALSE
178#define FALSE 0
179#define TRUE (!FALSE)
180#endif
181
182#define YYLLOC_DEFAULT(Current, Rhs, N)					\
183   do {									\
184      if (N) {							\
185	 (Current).first_line = YYRHSLOC(Rhs, 1).first_line;		\
186	 (Current).first_column = YYRHSLOC(Rhs, 1).first_column;	\
187	 (Current).position = YYRHSLOC(Rhs, 1).position;		\
188	 (Current).last_line = YYRHSLOC(Rhs, N).last_line;		\
189	 (Current).last_column = YYRHSLOC(Rhs, N).last_column;		\
190      } else {								\
191	 (Current).first_line = YYRHSLOC(Rhs, 0).last_line;		\
192	 (Current).last_line = (Current).first_line;			\
193	 (Current).first_column = YYRHSLOC(Rhs, 0).last_column;		\
194	 (Current).last_column = (Current).first_column;		\
195	 (Current).position = YYRHSLOC(Rhs, 0).position			\
196	    + (Current).first_column;					\
197      }									\
198   } while(0)
199
200#line 201 "src/mesa/program/program_parse.tab.c"
201
202# ifndef YY_CAST
203#  ifdef __cplusplus
204#   define YY_CAST(Type, Val) static_cast<Type> (Val)
205#   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
206#  else
207#   define YY_CAST(Type, Val) ((Type) (Val))
208#   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
209#  endif
210# endif
211# ifndef YY_NULLPTR
212#  if defined __cplusplus
213#   if 201103L <= __cplusplus
214#    define YY_NULLPTR nullptr
215#   else
216#    define YY_NULLPTR 0
217#   endif
218#  else
219#   define YY_NULLPTR ((void*)0)
220#  endif
221# endif
222
223#include "program_parse.tab.h"
224/* Symbol kind.  */
225enum yysymbol_kind_t
226{
227  YYSYMBOL_YYEMPTY = -2,
228  YYSYMBOL_YYEOF = 0,                      /* "end of file"  */
229  YYSYMBOL_YYerror = 1,                    /* error  */
230  YYSYMBOL_YYUNDEF = 2,                    /* "invalid token"  */
231  YYSYMBOL_ARBvp_10 = 3,                   /* ARBvp_10  */
232  YYSYMBOL_ARBfp_10 = 4,                   /* ARBfp_10  */
233  YYSYMBOL_ADDRESS = 5,                    /* ADDRESS  */
234  YYSYMBOL_ALIAS = 6,                      /* ALIAS  */
235  YYSYMBOL_ATTRIB = 7,                     /* ATTRIB  */
236  YYSYMBOL_OPTION = 8,                     /* OPTION  */
237  YYSYMBOL_OUTPUT = 9,                     /* OUTPUT  */
238  YYSYMBOL_PARAM = 10,                     /* PARAM  */
239  YYSYMBOL_TEMP = 11,                      /* TEMP  */
240  YYSYMBOL_END = 12,                       /* END  */
241  YYSYMBOL_BIN_OP = 13,                    /* BIN_OP  */
242  YYSYMBOL_BINSC_OP = 14,                  /* BINSC_OP  */
243  YYSYMBOL_SAMPLE_OP = 15,                 /* SAMPLE_OP  */
244  YYSYMBOL_SCALAR_OP = 16,                 /* SCALAR_OP  */
245  YYSYMBOL_TRI_OP = 17,                    /* TRI_OP  */
246  YYSYMBOL_VECTOR_OP = 18,                 /* VECTOR_OP  */
247  YYSYMBOL_ARL = 19,                       /* ARL  */
248  YYSYMBOL_KIL = 20,                       /* KIL  */
249  YYSYMBOL_SWZ = 21,                       /* SWZ  */
250  YYSYMBOL_TXD_OP = 22,                    /* TXD_OP  */
251  YYSYMBOL_INTEGER = 23,                   /* INTEGER  */
252  YYSYMBOL_REAL = 24,                      /* REAL  */
253  YYSYMBOL_AMBIENT = 25,                   /* AMBIENT  */
254  YYSYMBOL_ATTENUATION = 26,               /* ATTENUATION  */
255  YYSYMBOL_BACK = 27,                      /* BACK  */
256  YYSYMBOL_CLIP = 28,                      /* CLIP  */
257  YYSYMBOL_COLOR = 29,                     /* COLOR  */
258  YYSYMBOL_DEPTH = 30,                     /* DEPTH  */
259  YYSYMBOL_DIFFUSE = 31,                   /* DIFFUSE  */
260  YYSYMBOL_DIRECTION = 32,                 /* DIRECTION  */
261  YYSYMBOL_EMISSION = 33,                  /* EMISSION  */
262  YYSYMBOL_ENV = 34,                       /* ENV  */
263  YYSYMBOL_EYE = 35,                       /* EYE  */
264  YYSYMBOL_FOG = 36,                       /* FOG  */
265  YYSYMBOL_FOGCOORD = 37,                  /* FOGCOORD  */
266  YYSYMBOL_FRAGMENT = 38,                  /* FRAGMENT  */
267  YYSYMBOL_FRONT = 39,                     /* FRONT  */
268  YYSYMBOL_HALF = 40,                      /* HALF  */
269  YYSYMBOL_INVERSE = 41,                   /* INVERSE  */
270  YYSYMBOL_INVTRANS = 42,                  /* INVTRANS  */
271  YYSYMBOL_LIGHT = 43,                     /* LIGHT  */
272  YYSYMBOL_LIGHTMODEL = 44,                /* LIGHTMODEL  */
273  YYSYMBOL_LIGHTPROD = 45,                 /* LIGHTPROD  */
274  YYSYMBOL_LOCAL = 46,                     /* LOCAL  */
275  YYSYMBOL_MATERIAL = 47,                  /* MATERIAL  */
276  YYSYMBOL_MAT_PROGRAM = 48,               /* MAT_PROGRAM  */
277  YYSYMBOL_MATRIX = 49,                    /* MATRIX  */
278  YYSYMBOL_MATRIXINDEX = 50,               /* MATRIXINDEX  */
279  YYSYMBOL_MODELVIEW = 51,                 /* MODELVIEW  */
280  YYSYMBOL_MVP = 52,                       /* MVP  */
281  YYSYMBOL_NORMAL = 53,                    /* NORMAL  */
282  YYSYMBOL_OBJECT = 54,                    /* OBJECT  */
283  YYSYMBOL_PALETTE = 55,                   /* PALETTE  */
284  YYSYMBOL_PARAMS = 56,                    /* PARAMS  */
285  YYSYMBOL_PLANE = 57,                     /* PLANE  */
286  YYSYMBOL_POINT_TOK = 58,                 /* POINT_TOK  */
287  YYSYMBOL_POINTSIZE = 59,                 /* POINTSIZE  */
288  YYSYMBOL_POSITION = 60,                  /* POSITION  */
289  YYSYMBOL_PRIMARY = 61,                   /* PRIMARY  */
290  YYSYMBOL_PROGRAM = 62,                   /* PROGRAM  */
291  YYSYMBOL_PROJECTION = 63,                /* PROJECTION  */
292  YYSYMBOL_RANGE = 64,                     /* RANGE  */
293  YYSYMBOL_RESULT = 65,                    /* RESULT  */
294  YYSYMBOL_ROW = 66,                       /* ROW  */
295  YYSYMBOL_SCENECOLOR = 67,                /* SCENECOLOR  */
296  YYSYMBOL_SECONDARY = 68,                 /* SECONDARY  */
297  YYSYMBOL_SHININESS = 69,                 /* SHININESS  */
298  YYSYMBOL_SIZE_TOK = 70,                  /* SIZE_TOK  */
299  YYSYMBOL_SPECULAR = 71,                  /* SPECULAR  */
300  YYSYMBOL_SPOT = 72,                      /* SPOT  */
301  YYSYMBOL_STATE = 73,                     /* STATE  */
302  YYSYMBOL_TEXCOORD = 74,                  /* TEXCOORD  */
303  YYSYMBOL_TEXENV = 75,                    /* TEXENV  */
304  YYSYMBOL_TEXGEN = 76,                    /* TEXGEN  */
305  YYSYMBOL_TEXGEN_Q = 77,                  /* TEXGEN_Q  */
306  YYSYMBOL_TEXGEN_R = 78,                  /* TEXGEN_R  */
307  YYSYMBOL_TEXGEN_S = 79,                  /* TEXGEN_S  */
308  YYSYMBOL_TEXGEN_T = 80,                  /* TEXGEN_T  */
309  YYSYMBOL_TEXTURE = 81,                   /* TEXTURE  */
310  YYSYMBOL_TRANSPOSE = 82,                 /* TRANSPOSE  */
311  YYSYMBOL_TEXTURE_UNIT = 83,              /* TEXTURE_UNIT  */
312  YYSYMBOL_TEX_1D = 84,                    /* TEX_1D  */
313  YYSYMBOL_TEX_2D = 85,                    /* TEX_2D  */
314  YYSYMBOL_TEX_3D = 86,                    /* TEX_3D  */
315  YYSYMBOL_TEX_CUBE = 87,                  /* TEX_CUBE  */
316  YYSYMBOL_TEX_RECT = 88,                  /* TEX_RECT  */
317  YYSYMBOL_TEX_SHADOW1D = 89,              /* TEX_SHADOW1D  */
318  YYSYMBOL_TEX_SHADOW2D = 90,              /* TEX_SHADOW2D  */
319  YYSYMBOL_TEX_SHADOWRECT = 91,            /* TEX_SHADOWRECT  */
320  YYSYMBOL_TEX_ARRAY1D = 92,               /* TEX_ARRAY1D  */
321  YYSYMBOL_TEX_ARRAY2D = 93,               /* TEX_ARRAY2D  */
322  YYSYMBOL_TEX_ARRAYSHADOW1D = 94,         /* TEX_ARRAYSHADOW1D  */
323  YYSYMBOL_TEX_ARRAYSHADOW2D = 95,         /* TEX_ARRAYSHADOW2D  */
324  YYSYMBOL_VERTEX = 96,                    /* VERTEX  */
325  YYSYMBOL_VTXATTRIB = 97,                 /* VTXATTRIB  */
326  YYSYMBOL_IDENTIFIER = 98,                /* IDENTIFIER  */
327  YYSYMBOL_USED_IDENTIFIER = 99,           /* USED_IDENTIFIER  */
328  YYSYMBOL_MASK4 = 100,                    /* MASK4  */
329  YYSYMBOL_MASK3 = 101,                    /* MASK3  */
330  YYSYMBOL_MASK2 = 102,                    /* MASK2  */
331  YYSYMBOL_MASK1 = 103,                    /* MASK1  */
332  YYSYMBOL_SWIZZLE = 104,                  /* SWIZZLE  */
333  YYSYMBOL_DOT_DOT = 105,                  /* DOT_DOT  */
334  YYSYMBOL_DOT = 106,                      /* DOT  */
335  YYSYMBOL_107_ = 107,                     /* ';'  */
336  YYSYMBOL_108_ = 108,                     /* ','  */
337  YYSYMBOL_109_ = 109,                     /* '['  */
338  YYSYMBOL_110_ = 110,                     /* ']'  */
339  YYSYMBOL_111_ = 111,                     /* '+'  */
340  YYSYMBOL_112_ = 112,                     /* '-'  */
341  YYSYMBOL_113_ = 113,                     /* '='  */
342  YYSYMBOL_114_ = 114,                     /* '{'  */
343  YYSYMBOL_115_ = 115,                     /* '}'  */
344  YYSYMBOL_YYACCEPT = 116,                 /* $accept  */
345  YYSYMBOL_program = 117,                  /* program  */
346  YYSYMBOL_language = 118,                 /* language  */
347  YYSYMBOL_optionSequence = 119,           /* optionSequence  */
348  YYSYMBOL_option = 120,                   /* option  */
349  YYSYMBOL_statementSequence = 121,        /* statementSequence  */
350  YYSYMBOL_statement = 122,                /* statement  */
351  YYSYMBOL_instruction = 123,              /* instruction  */
352  YYSYMBOL_ALU_instruction = 124,          /* ALU_instruction  */
353  YYSYMBOL_TexInstruction = 125,           /* TexInstruction  */
354  YYSYMBOL_ARL_instruction = 126,          /* ARL_instruction  */
355  YYSYMBOL_VECTORop_instruction = 127,     /* VECTORop_instruction  */
356  YYSYMBOL_SCALARop_instruction = 128,     /* SCALARop_instruction  */
357  YYSYMBOL_BINSCop_instruction = 129,      /* BINSCop_instruction  */
358  YYSYMBOL_BINop_instruction = 130,        /* BINop_instruction  */
359  YYSYMBOL_TRIop_instruction = 131,        /* TRIop_instruction  */
360  YYSYMBOL_SAMPLE_instruction = 132,       /* SAMPLE_instruction  */
361  YYSYMBOL_KIL_instruction = 133,          /* KIL_instruction  */
362  YYSYMBOL_TXD_instruction = 134,          /* TXD_instruction  */
363  YYSYMBOL_texImageUnit = 135,             /* texImageUnit  */
364  YYSYMBOL_texTarget = 136,                /* texTarget  */
365  YYSYMBOL_SWZ_instruction = 137,          /* SWZ_instruction  */
366  YYSYMBOL_scalarSrcReg = 138,             /* scalarSrcReg  */
367  YYSYMBOL_scalarUse = 139,                /* scalarUse  */
368  YYSYMBOL_swizzleSrcReg = 140,            /* swizzleSrcReg  */
369  YYSYMBOL_maskedDstReg = 141,             /* maskedDstReg  */
370  YYSYMBOL_maskedAddrReg = 142,            /* maskedAddrReg  */
371  YYSYMBOL_extendedSwizzle = 143,          /* extendedSwizzle  */
372  YYSYMBOL_extSwizComp = 144,              /* extSwizComp  */
373  YYSYMBOL_extSwizSel = 145,               /* extSwizSel  */
374  YYSYMBOL_srcReg = 146,                   /* srcReg  */
375  YYSYMBOL_dstReg = 147,                   /* dstReg  */
376  YYSYMBOL_progParamArray = 148,           /* progParamArray  */
377  YYSYMBOL_progParamArrayMem = 149,        /* progParamArrayMem  */
378  YYSYMBOL_progParamArrayAbs = 150,        /* progParamArrayAbs  */
379  YYSYMBOL_progParamArrayRel = 151,        /* progParamArrayRel  */
380  YYSYMBOL_addrRegRelOffset = 152,         /* addrRegRelOffset  */
381  YYSYMBOL_addrRegPosOffset = 153,         /* addrRegPosOffset  */
382  YYSYMBOL_addrRegNegOffset = 154,         /* addrRegNegOffset  */
383  YYSYMBOL_addrReg = 155,                  /* addrReg  */
384  YYSYMBOL_addrComponent = 156,            /* addrComponent  */
385  YYSYMBOL_addrWriteMask = 157,            /* addrWriteMask  */
386  YYSYMBOL_scalarSuffix = 158,             /* scalarSuffix  */
387  YYSYMBOL_swizzleSuffix = 159,            /* swizzleSuffix  */
388  YYSYMBOL_optionalMask = 160,             /* optionalMask  */
389  YYSYMBOL_namingStatement = 161,          /* namingStatement  */
390  YYSYMBOL_ATTRIB_statement = 162,         /* ATTRIB_statement  */
391  YYSYMBOL_attribBinding = 163,            /* attribBinding  */
392  YYSYMBOL_vtxAttribItem = 164,            /* vtxAttribItem  */
393  YYSYMBOL_vtxAttribNum = 165,             /* vtxAttribNum  */
394  YYSYMBOL_vtxWeightNum = 166,             /* vtxWeightNum  */
395  YYSYMBOL_fragAttribItem = 167,           /* fragAttribItem  */
396  YYSYMBOL_PARAM_statement = 168,          /* PARAM_statement  */
397  YYSYMBOL_PARAM_singleStmt = 169,         /* PARAM_singleStmt  */
398  YYSYMBOL_PARAM_multipleStmt = 170,       /* PARAM_multipleStmt  */
399  YYSYMBOL_optArraySize = 171,             /* optArraySize  */
400  YYSYMBOL_paramSingleInit = 172,          /* paramSingleInit  */
401  YYSYMBOL_paramMultipleInit = 173,        /* paramMultipleInit  */
402  YYSYMBOL_paramMultInitList = 174,        /* paramMultInitList  */
403  YYSYMBOL_paramSingleItemDecl = 175,      /* paramSingleItemDecl  */
404  YYSYMBOL_paramSingleItemUse = 176,       /* paramSingleItemUse  */
405  YYSYMBOL_paramMultipleItem = 177,        /* paramMultipleItem  */
406  YYSYMBOL_stateMultipleItem = 178,        /* stateMultipleItem  */
407  YYSYMBOL_stateSingleItem = 179,          /* stateSingleItem  */
408  YYSYMBOL_stateMaterialItem = 180,        /* stateMaterialItem  */
409  YYSYMBOL_stateMatProperty = 181,         /* stateMatProperty  */
410  YYSYMBOL_stateLightItem = 182,           /* stateLightItem  */
411  YYSYMBOL_stateLightProperty = 183,       /* stateLightProperty  */
412  YYSYMBOL_stateSpotProperty = 184,        /* stateSpotProperty  */
413  YYSYMBOL_stateLightModelItem = 185,      /* stateLightModelItem  */
414  YYSYMBOL_stateLModProperty = 186,        /* stateLModProperty  */
415  YYSYMBOL_stateLightProdItem = 187,       /* stateLightProdItem  */
416  YYSYMBOL_stateLProdProperty = 188,       /* stateLProdProperty  */
417  YYSYMBOL_stateTexEnvItem = 189,          /* stateTexEnvItem  */
418  YYSYMBOL_stateTexEnvProperty = 190,      /* stateTexEnvProperty  */
419  YYSYMBOL_ambDiffSpecPropertyMaterial = 191, /* ambDiffSpecPropertyMaterial  */
420  YYSYMBOL_ambDiffSpecPropertyLight = 192, /* ambDiffSpecPropertyLight  */
421  YYSYMBOL_stateLightNumber = 193,         /* stateLightNumber  */
422  YYSYMBOL_stateTexGenItem = 194,          /* stateTexGenItem  */
423  YYSYMBOL_stateTexGenType = 195,          /* stateTexGenType  */
424  YYSYMBOL_stateTexGenCoord = 196,         /* stateTexGenCoord  */
425  YYSYMBOL_stateFogItem = 197,             /* stateFogItem  */
426  YYSYMBOL_stateFogProperty = 198,         /* stateFogProperty  */
427  YYSYMBOL_stateClipPlaneItem = 199,       /* stateClipPlaneItem  */
428  YYSYMBOL_stateClipPlaneNum = 200,        /* stateClipPlaneNum  */
429  YYSYMBOL_statePointItem = 201,           /* statePointItem  */
430  YYSYMBOL_statePointProperty = 202,       /* statePointProperty  */
431  YYSYMBOL_stateMatrixRow = 203,           /* stateMatrixRow  */
432  YYSYMBOL_stateMatrixRows = 204,          /* stateMatrixRows  */
433  YYSYMBOL_optMatrixRows = 205,            /* optMatrixRows  */
434  YYSYMBOL_stateMatrixItem = 206,          /* stateMatrixItem  */
435  YYSYMBOL_stateOptMatModifier = 207,      /* stateOptMatModifier  */
436  YYSYMBOL_stateMatModifier = 208,         /* stateMatModifier  */
437  YYSYMBOL_stateMatrixRowNum = 209,        /* stateMatrixRowNum  */
438  YYSYMBOL_stateMatrixName = 210,          /* stateMatrixName  */
439  YYSYMBOL_stateOptModMatNum = 211,        /* stateOptModMatNum  */
440  YYSYMBOL_stateModMatNum = 212,           /* stateModMatNum  */
441  YYSYMBOL_statePaletteMatNum = 213,       /* statePaletteMatNum  */
442  YYSYMBOL_stateProgramMatNum = 214,       /* stateProgramMatNum  */
443  YYSYMBOL_stateDepthItem = 215,           /* stateDepthItem  */
444  YYSYMBOL_programSingleItem = 216,        /* programSingleItem  */
445  YYSYMBOL_programMultipleItem = 217,      /* programMultipleItem  */
446  YYSYMBOL_progEnvParams = 218,            /* progEnvParams  */
447  YYSYMBOL_progEnvParamNums = 219,         /* progEnvParamNums  */
448  YYSYMBOL_progEnvParam = 220,             /* progEnvParam  */
449  YYSYMBOL_progLocalParams = 221,          /* progLocalParams  */
450  YYSYMBOL_progLocalParamNums = 222,       /* progLocalParamNums  */
451  YYSYMBOL_progLocalParam = 223,           /* progLocalParam  */
452  YYSYMBOL_progEnvParamNum = 224,          /* progEnvParamNum  */
453  YYSYMBOL_progLocalParamNum = 225,        /* progLocalParamNum  */
454  YYSYMBOL_paramConstDecl = 226,           /* paramConstDecl  */
455  YYSYMBOL_paramConstUse = 227,            /* paramConstUse  */
456  YYSYMBOL_paramConstScalarDecl = 228,     /* paramConstScalarDecl  */
457  YYSYMBOL_paramConstScalarUse = 229,      /* paramConstScalarUse  */
458  YYSYMBOL_paramConstVector = 230,         /* paramConstVector  */
459  YYSYMBOL_signedFloatConstant = 231,      /* signedFloatConstant  */
460  YYSYMBOL_optionalSign = 232,             /* optionalSign  */
461  YYSYMBOL_TEMP_statement = 233,           /* TEMP_statement  */
462  YYSYMBOL_234_1 = 234,                    /* @1  */
463  YYSYMBOL_ADDRESS_statement = 235,        /* ADDRESS_statement  */
464  YYSYMBOL_236_2 = 236,                    /* @2  */
465  YYSYMBOL_varNameList = 237,              /* varNameList  */
466  YYSYMBOL_OUTPUT_statement = 238,         /* OUTPUT_statement  */
467  YYSYMBOL_resultBinding = 239,            /* resultBinding  */
468  YYSYMBOL_resultColBinding = 240,         /* resultColBinding  */
469  YYSYMBOL_optResultFaceType = 241,        /* optResultFaceType  */
470  YYSYMBOL_optResultColorType = 242,       /* optResultColorType  */
471  YYSYMBOL_optFaceType = 243,              /* optFaceType  */
472  YYSYMBOL_optColorType = 244,             /* optColorType  */
473  YYSYMBOL_optTexCoordUnitNum = 245,       /* optTexCoordUnitNum  */
474  YYSYMBOL_optTexImageUnitNum = 246,       /* optTexImageUnitNum  */
475  YYSYMBOL_optLegacyTexUnitNum = 247,      /* optLegacyTexUnitNum  */
476  YYSYMBOL_texCoordUnitNum = 248,          /* texCoordUnitNum  */
477  YYSYMBOL_texImageUnitNum = 249,          /* texImageUnitNum  */
478  YYSYMBOL_legacyTexUnitNum = 250,         /* legacyTexUnitNum  */
479  YYSYMBOL_ALIAS_statement = 251,          /* ALIAS_statement  */
480  YYSYMBOL_string = 252                    /* string  */
481};
482typedef enum yysymbol_kind_t yysymbol_kind_t;
483
484
485/* Second part of user prologue.  */
486#line 280 "../src/mesa/program/program_parse.y"
487
488extern int
489_mesa_program_lexer_lex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param,
490                        void *yyscanner);
491
492static int
493yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param,
494      struct asm_parser_state *state)
495{
496   return _mesa_program_lexer_lex(yylval_param, yylloc_param, state->scanner);
497}
498
499#line 500 "src/mesa/program/program_parse.tab.c"
500
501
502#ifdef short
503# undef short
504#endif
505
506/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
507   <limits.h> and (if available) <stdint.h> are included
508   so that the code can choose integer types of a good width.  */
509
510#ifndef __PTRDIFF_MAX__
511# include <limits.h> /* INFRINGES ON USER NAME SPACE */
512# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
513#  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
514#  define YY_STDINT_H
515# endif
516#endif
517
518/* Narrow types that promote to a signed type and that can represent a
519   signed or unsigned integer of at least N bits.  In tables they can
520   save space and decrease cache pressure.  Promoting to a signed type
521   helps avoid bugs in integer arithmetic.  */
522
523#ifdef __INT_LEAST8_MAX__
524typedef __INT_LEAST8_TYPE__ yytype_int8;
525#elif defined YY_STDINT_H
526typedef int_least8_t yytype_int8;
527#else
528typedef signed char yytype_int8;
529#endif
530
531#ifdef __INT_LEAST16_MAX__
532typedef __INT_LEAST16_TYPE__ yytype_int16;
533#elif defined YY_STDINT_H
534typedef int_least16_t yytype_int16;
535#else
536typedef short yytype_int16;
537#endif
538
539#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
540typedef __UINT_LEAST8_TYPE__ yytype_uint8;
541#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
542       && UINT_LEAST8_MAX <= INT_MAX)
543typedef uint_least8_t yytype_uint8;
544#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
545typedef unsigned char yytype_uint8;
546#else
547typedef short yytype_uint8;
548#endif
549
550#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
551typedef __UINT_LEAST16_TYPE__ yytype_uint16;
552#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
553       && UINT_LEAST16_MAX <= INT_MAX)
554typedef uint_least16_t yytype_uint16;
555#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
556typedef unsigned short yytype_uint16;
557#else
558typedef int yytype_uint16;
559#endif
560
561#ifndef YYPTRDIFF_T
562# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
563#  define YYPTRDIFF_T __PTRDIFF_TYPE__
564#  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
565# elif defined PTRDIFF_MAX
566#  ifndef ptrdiff_t
567#   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
568#  endif
569#  define YYPTRDIFF_T ptrdiff_t
570#  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
571# else
572#  define YYPTRDIFF_T long
573#  define YYPTRDIFF_MAXIMUM LONG_MAX
574# endif
575#endif
576
577#ifndef YYSIZE_T
578# ifdef __SIZE_TYPE__
579#  define YYSIZE_T __SIZE_TYPE__
580# elif defined size_t
581#  define YYSIZE_T size_t
582# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
583#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
584#  define YYSIZE_T size_t
585# else
586#  define YYSIZE_T unsigned
587# endif
588#endif
589
590#define YYSIZE_MAXIMUM                                  \
591  YY_CAST (YYPTRDIFF_T,                                 \
592           (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
593            ? YYPTRDIFF_MAXIMUM                         \
594            : YY_CAST (YYSIZE_T, -1)))
595
596#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
597
598
599/* Stored state numbers (used for stacks). */
600typedef yytype_int16 yy_state_t;
601
602/* State numbers in computations.  */
603typedef int yy_state_fast_t;
604
605#ifndef YY_
606# if defined YYENABLE_NLS && YYENABLE_NLS
607#  if ENABLE_NLS
608#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
609#   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
610#  endif
611# endif
612# ifndef YY_
613#  define YY_(Msgid) Msgid
614# endif
615#endif
616
617
618#ifndef YY_ATTRIBUTE_PURE
619# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
620#  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
621# else
622#  define YY_ATTRIBUTE_PURE
623# endif
624#endif
625
626#ifndef YY_ATTRIBUTE_UNUSED
627# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
628#  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
629# else
630#  define YY_ATTRIBUTE_UNUSED
631# endif
632#endif
633
634/* Suppress unused-variable warnings by "using" E.  */
635#if ! defined lint || defined __GNUC__
636# define YYUSE(E) ((void) (E))
637#else
638# define YYUSE(E) /* empty */
639#endif
640
641#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
642/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
643# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                            \
644    _Pragma ("GCC diagnostic push")                                     \
645    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
646    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
647# define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
648    _Pragma ("GCC diagnostic pop")
649#else
650# define YY_INITIAL_VALUE(Value) Value
651#endif
652#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
653# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
654# define YY_IGNORE_MAYBE_UNINITIALIZED_END
655#endif
656#ifndef YY_INITIAL_VALUE
657# define YY_INITIAL_VALUE(Value) /* Nothing. */
658#endif
659
660#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
661# define YY_IGNORE_USELESS_CAST_BEGIN                          \
662    _Pragma ("GCC diagnostic push")                            \
663    _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
664# define YY_IGNORE_USELESS_CAST_END            \
665    _Pragma ("GCC diagnostic pop")
666#endif
667#ifndef YY_IGNORE_USELESS_CAST_BEGIN
668# define YY_IGNORE_USELESS_CAST_BEGIN
669# define YY_IGNORE_USELESS_CAST_END
670#endif
671
672
673#define YY_ASSERT(E) ((void) (0 && (E)))
674
675#if 1
676
677/* The parser invokes alloca or malloc; define the necessary symbols.  */
678
679# ifdef YYSTACK_USE_ALLOCA
680#  if YYSTACK_USE_ALLOCA
681#   ifdef __GNUC__
682#    define YYSTACK_ALLOC __builtin_alloca
683#   elif defined __BUILTIN_VA_ARG_INCR
684#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
685#   elif defined _AIX
686#    define YYSTACK_ALLOC __alloca
687#   elif defined _MSC_VER
688#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
689#    define alloca _alloca
690#   else
691#    define YYSTACK_ALLOC alloca
692#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
693#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
694      /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
695#     ifndef EXIT_SUCCESS
696#      define EXIT_SUCCESS 0
697#     endif
698#    endif
699#   endif
700#  endif
701# endif
702
703# ifdef YYSTACK_ALLOC
704   /* Pacify GCC's 'empty if-body' warning.  */
705#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
706#  ifndef YYSTACK_ALLOC_MAXIMUM
707    /* The OS might guarantee only one guard page at the bottom of the stack,
708       and a page size can be as small as 4096 bytes.  So we cannot safely
709       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
710       to allow for a few compiler-allocated temporary stack slots.  */
711#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
712#  endif
713# else
714#  define YYSTACK_ALLOC YYMALLOC
715#  define YYSTACK_FREE YYFREE
716#  ifndef YYSTACK_ALLOC_MAXIMUM
717#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
718#  endif
719#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
720       && ! ((defined YYMALLOC || defined malloc) \
721             && (defined YYFREE || defined free)))
722#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
723#   ifndef EXIT_SUCCESS
724#    define EXIT_SUCCESS 0
725#   endif
726#  endif
727#  ifndef YYMALLOC
728#   define YYMALLOC malloc
729#   if ! defined malloc && ! defined EXIT_SUCCESS
730void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
731#   endif
732#  endif
733#  ifndef YYFREE
734#   define YYFREE free
735#   if ! defined free && ! defined EXIT_SUCCESS
736void free (void *); /* INFRINGES ON USER NAME SPACE */
737#   endif
738#  endif
739# endif
740#endif /* 1 */
741
742#if (! defined yyoverflow \
743     && (! defined __cplusplus \
744         || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
745             && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
746
747/* A type that is properly aligned for any stack member.  */
748union yyalloc
749{
750  yy_state_t yyss_alloc;
751  YYSTYPE yyvs_alloc;
752  YYLTYPE yyls_alloc;
753};
754
755/* The size of the maximum gap between one aligned stack and the next.  */
756# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
757
758/* The size of an array large to enough to hold all stacks, each with
759   N elements.  */
760# define YYSTACK_BYTES(N) \
761     ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \
762             + YYSIZEOF (YYLTYPE)) \
763      + 2 * YYSTACK_GAP_MAXIMUM)
764
765# define YYCOPY_NEEDED 1
766
767/* Relocate STACK from its old location to the new one.  The
768   local variables YYSIZE and YYSTACKSIZE give the old and new number of
769   elements in the stack, and YYPTR gives the new location of the
770   stack.  Advance YYPTR to a properly aligned location for the next
771   stack.  */
772# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
773    do                                                                  \
774      {                                                                 \
775        YYPTRDIFF_T yynewbytes;                                         \
776        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
777        Stack = &yyptr->Stack_alloc;                                    \
778        yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
779        yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
780      }                                                                 \
781    while (0)
782
783#endif
784
785#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
786/* Copy COUNT objects from SRC to DST.  The source and destination do
787   not overlap.  */
788# ifndef YYCOPY
789#  if defined __GNUC__ && 1 < __GNUC__
790#   define YYCOPY(Dst, Src, Count) \
791      __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
792#  else
793#   define YYCOPY(Dst, Src, Count)              \
794      do                                        \
795        {                                       \
796          YYPTRDIFF_T yyi;                      \
797          for (yyi = 0; yyi < (Count); yyi++)   \
798            (Dst)[yyi] = (Src)[yyi];            \
799        }                                       \
800      while (0)
801#  endif
802# endif
803#endif /* !YYCOPY_NEEDED */
804
805/* YYFINAL -- State number of the termination state.  */
806#define YYFINAL  5
807/* YYLAST -- Last index in YYTABLE.  */
808#define YYLAST   352
809
810/* YYNTOKENS -- Number of terminals.  */
811#define YYNTOKENS  116
812/* YYNNTS -- Number of nonterminals.  */
813#define YYNNTS  137
814/* YYNRULES -- Number of rules.  */
815#define YYNRULES  270
816/* YYNSTATES -- Number of states.  */
817#define YYNSTATES  453
818
819/* YYMAXUTOK -- Last valid token kind.  */
820#define YYMAXUTOK   361
821
822
823/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
824   as returned by yylex, with out-of-bounds checking.  */
825#define YYTRANSLATE(YYX)                                \
826  (0 <= (YYX) && (YYX) <= YYMAXUTOK                     \
827   ? YY_CAST (yysymbol_kind_t, yytranslate[YYX])        \
828   : YYSYMBOL_YYUNDEF)
829
830/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
831   as returned by yylex.  */
832static const yytype_int8 yytranslate[] =
833{
834       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
835       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
836       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
837       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
838       2,     2,     2,   111,   108,   112,     2,     2,     2,     2,
839       2,     2,     2,     2,     2,     2,     2,     2,     2,   107,
840       2,   113,     2,     2,     2,     2,     2,     2,     2,     2,
841       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
842       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
843       2,   109,     2,   110,     2,     2,     2,     2,     2,     2,
844       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
845       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
846       2,     2,     2,   114,     2,   115,     2,     2,     2,     2,
847       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
848       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
849       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
850       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
851       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
852       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
853       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
854       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
855       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
856       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
857       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
858       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
859       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
860       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
861      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
862      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
863      35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
864      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
865      55,    56,    57,    58,    59,    60,    61,    62,    63,    64,
866      65,    66,    67,    68,    69,    70,    71,    72,    73,    74,
867      75,    76,    77,    78,    79,    80,    81,    82,    83,    84,
868      85,    86,    87,    88,    89,    90,    91,    92,    93,    94,
869      95,    96,    97,    98,    99,   100,   101,   102,   103,   104,
870     105,   106
871};
872
873#if YYDEBUG
874  /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
875static const yytype_int16 yyrline[] =
876{
877       0,   295,   295,   298,   306,   318,   319,   322,   346,   347,
878     350,   365,   368,   373,   380,   381,   382,   383,   384,   385,
879     386,   389,   390,   391,   394,   400,   406,   412,   419,   425,
880     432,   476,   483,   527,   533,   534,   535,   536,   537,   538,
881     539,   540,   541,   542,   543,   544,   547,   559,   569,   578,
882     591,   613,   620,   653,   660,   676,   735,   778,   787,   809,
883     819,   823,   852,   871,   871,   873,   880,   892,   893,   894,
884     897,   911,   925,   945,   956,   968,   970,   971,   972,   973,
885     976,   976,   976,   976,   977,   980,   981,   982,   983,   984,
886     985,   988,  1007,  1011,  1017,  1021,  1025,  1029,  1033,  1037,
887    1042,  1048,  1059,  1061,  1065,  1069,  1073,  1079,  1079,  1081,
888    1099,  1125,  1128,  1143,  1149,  1155,  1156,  1163,  1169,  1175,
889    1183,  1189,  1195,  1203,  1209,  1215,  1223,  1224,  1227,  1228,
890    1229,  1230,  1231,  1232,  1233,  1234,  1235,  1236,  1237,  1240,
891    1249,  1253,  1257,  1263,  1272,  1276,  1280,  1289,  1293,  1299,
892    1305,  1312,  1317,  1325,  1335,  1337,  1345,  1351,  1355,  1359,
893    1365,  1369,  1373,  1379,  1390,  1399,  1403,  1408,  1412,  1416,
894    1420,  1426,  1433,  1437,  1443,  1451,  1462,  1469,  1473,  1479,
895    1488,  1498,  1502,  1520,  1529,  1532,  1538,  1542,  1546,  1552,
896    1563,  1568,  1573,  1578,  1583,  1588,  1596,  1599,  1604,  1617,
897    1625,  1636,  1644,  1644,  1646,  1646,  1648,  1658,  1663,  1670,
898    1680,  1689,  1694,  1701,  1711,  1721,  1733,  1733,  1734,  1734,
899    1736,  1746,  1754,  1764,  1772,  1780,  1789,  1800,  1804,  1810,
900    1811,  1812,  1815,  1815,  1818,  1818,  1821,  1828,  1837,  1851,
901    1860,  1869,  1873,  1882,  1891,  1902,  1909,  1919,  1947,  1956,
902    1968,  1971,  1980,  1991,  1992,  1993,  1996,  1997,  1998,  2001,
903    2002,  2005,  2006,  2009,  2010,  2013,  2024,  2035,  2046,  2072,
904    2073
905};
906#endif
907
908/** Accessing symbol of state STATE.  */
909#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
910
911#if 1
912/* The user-facing name of the symbol whose (internal) number is
913   YYSYMBOL.  No bounds checking.  */
914static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
915
916/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
917   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
918static const char *const yytname[] =
919{
920  "\"end of file\"", "error", "\"invalid token\"", "ARBvp_10", "ARBfp_10",
921  "ADDRESS", "ALIAS", "ATTRIB", "OPTION", "OUTPUT", "PARAM", "TEMP", "END",
922  "BIN_OP", "BINSC_OP", "SAMPLE_OP", "SCALAR_OP", "TRI_OP", "VECTOR_OP",
923  "ARL", "KIL", "SWZ", "TXD_OP", "INTEGER", "REAL", "AMBIENT",
924  "ATTENUATION", "BACK", "CLIP", "COLOR", "DEPTH", "DIFFUSE", "DIRECTION",
925  "EMISSION", "ENV", "EYE", "FOG", "FOGCOORD", "FRAGMENT", "FRONT", "HALF",
926  "INVERSE", "INVTRANS", "LIGHT", "LIGHTMODEL", "LIGHTPROD", "LOCAL",
927  "MATERIAL", "MAT_PROGRAM", "MATRIX", "MATRIXINDEX", "MODELVIEW", "MVP",
928  "NORMAL", "OBJECT", "PALETTE", "PARAMS", "PLANE", "POINT_TOK",
929  "POINTSIZE", "POSITION", "PRIMARY", "PROGRAM", "PROJECTION", "RANGE",
930  "RESULT", "ROW", "SCENECOLOR", "SECONDARY", "SHININESS", "SIZE_TOK",
931  "SPECULAR", "SPOT", "STATE", "TEXCOORD", "TEXENV", "TEXGEN", "TEXGEN_Q",
932  "TEXGEN_R", "TEXGEN_S", "TEXGEN_T", "TEXTURE", "TRANSPOSE",
933  "TEXTURE_UNIT", "TEX_1D", "TEX_2D", "TEX_3D", "TEX_CUBE", "TEX_RECT",
934  "TEX_SHADOW1D", "TEX_SHADOW2D", "TEX_SHADOWRECT", "TEX_ARRAY1D",
935  "TEX_ARRAY2D", "TEX_ARRAYSHADOW1D", "TEX_ARRAYSHADOW2D", "VERTEX",
936  "VTXATTRIB", "IDENTIFIER", "USED_IDENTIFIER", "MASK4", "MASK3", "MASK2",
937  "MASK1", "SWIZZLE", "DOT_DOT", "DOT", "';'", "','", "'['", "']'", "'+'",
938  "'-'", "'='", "'{'", "'}'", "$accept", "program", "language",
939  "optionSequence", "option", "statementSequence", "statement",
940  "instruction", "ALU_instruction", "TexInstruction", "ARL_instruction",
941  "VECTORop_instruction", "SCALARop_instruction", "BINSCop_instruction",
942  "BINop_instruction", "TRIop_instruction", "SAMPLE_instruction",
943  "KIL_instruction", "TXD_instruction", "texImageUnit", "texTarget",
944  "SWZ_instruction", "scalarSrcReg", "scalarUse", "swizzleSrcReg",
945  "maskedDstReg", "maskedAddrReg", "extendedSwizzle", "extSwizComp",
946  "extSwizSel", "srcReg", "dstReg", "progParamArray", "progParamArrayMem",
947  "progParamArrayAbs", "progParamArrayRel", "addrRegRelOffset",
948  "addrRegPosOffset", "addrRegNegOffset", "addrReg", "addrComponent",
949  "addrWriteMask", "scalarSuffix", "swizzleSuffix", "optionalMask",
950  "namingStatement", "ATTRIB_statement", "attribBinding", "vtxAttribItem",
951  "vtxAttribNum", "vtxWeightNum", "fragAttribItem", "PARAM_statement",
952  "PARAM_singleStmt", "PARAM_multipleStmt", "optArraySize",
953  "paramSingleInit", "paramMultipleInit", "paramMultInitList",
954  "paramSingleItemDecl", "paramSingleItemUse", "paramMultipleItem",
955  "stateMultipleItem", "stateSingleItem", "stateMaterialItem",
956  "stateMatProperty", "stateLightItem", "stateLightProperty",
957  "stateSpotProperty", "stateLightModelItem", "stateLModProperty",
958  "stateLightProdItem", "stateLProdProperty", "stateTexEnvItem",
959  "stateTexEnvProperty", "ambDiffSpecPropertyMaterial",
960  "ambDiffSpecPropertyLight", "stateLightNumber", "stateTexGenItem",
961  "stateTexGenType", "stateTexGenCoord", "stateFogItem",
962  "stateFogProperty", "stateClipPlaneItem", "stateClipPlaneNum",
963  "statePointItem", "statePointProperty", "stateMatrixRow",
964  "stateMatrixRows", "optMatrixRows", "stateMatrixItem",
965  "stateOptMatModifier", "stateMatModifier", "stateMatrixRowNum",
966  "stateMatrixName", "stateOptModMatNum", "stateModMatNum",
967  "statePaletteMatNum", "stateProgramMatNum", "stateDepthItem",
968  "programSingleItem", "programMultipleItem", "progEnvParams",
969  "progEnvParamNums", "progEnvParam", "progLocalParams",
970  "progLocalParamNums", "progLocalParam", "progEnvParamNum",
971  "progLocalParamNum", "paramConstDecl", "paramConstUse",
972  "paramConstScalarDecl", "paramConstScalarUse", "paramConstVector",
973  "signedFloatConstant", "optionalSign", "TEMP_statement", "@1",
974  "ADDRESS_statement", "@2", "varNameList", "OUTPUT_statement",
975  "resultBinding", "resultColBinding", "optResultFaceType",
976  "optResultColorType", "optFaceType", "optColorType",
977  "optTexCoordUnitNum", "optTexImageUnitNum", "optLegacyTexUnitNum",
978  "texCoordUnitNum", "texImageUnitNum", "legacyTexUnitNum",
979  "ALIAS_statement", "string", YY_NULLPTR
980};
981
982static const char *
983yysymbol_name (yysymbol_kind_t yysymbol)
984{
985  return yytname[yysymbol];
986}
987#endif
988
989#ifdef YYPRINT
990/* YYTOKNUM[NUM] -- (External) token number corresponding to the
991   (internal) symbol number NUM (which must be that of a token).  */
992static const yytype_int16 yytoknum[] =
993{
994       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
995     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
996     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
997     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
998     295,   296,   297,   298,   299,   300,   301,   302,   303,   304,
999     305,   306,   307,   308,   309,   310,   311,   312,   313,   314,
1000     315,   316,   317,   318,   319,   320,   321,   322,   323,   324,
1001     325,   326,   327,   328,   329,   330,   331,   332,   333,   334,
1002     335,   336,   337,   338,   339,   340,   341,   342,   343,   344,
1003     345,   346,   347,   348,   349,   350,   351,   352,   353,   354,
1004     355,   356,   357,   358,   359,   360,   361,    59,    44,    91,
1005      93,    43,    45,    61,   123,   125
1006};
1007#endif
1008
1009#define YYPACT_NINF (-403)
1010
1011#define yypact_value_is_default(Yyn) \
1012  ((Yyn) == YYPACT_NINF)
1013
1014#define YYTABLE_NINF (-63)
1015
1016#define yytable_value_is_error(Yyn) \
1017  0
1018
1019  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1020     STATE-NUM.  */
1021static const yytype_int16 yypact[] =
1022{
1023     117,  -403,  -403,    35,  -403,  -403,    18,    -9,  -403,   177,
1024    -403,  -403,   -52,  -403,   -29,   -27,    14,    34,  -403,  -403,
1025     -32,   -32,   -32,   -32,   -32,   -32,    11,    47,   -32,   -32,
1026    -403,    31,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,
1027    -403,  -403,  -403,  -403,    43,  -403,  -403,  -403,  -403,  -403,
1028    -403,  -403,  -403,  -403,    37,    58,    65,    72,    44,    37,
1029      86,  -403,   118,    67,  -403,   119,   120,   121,   122,   123,
1030    -403,   124,    77,  -403,  -403,  -403,   -16,   125,   126,  -403,
1031    -403,  -403,   127,   137,   -21,   160,   219,   -35,  -403,   127,
1032     -14,  -403,  -403,  -403,  -403,   134,  -403,    47,  -403,  -403,
1033    -403,  -403,  -403,    47,    47,    47,    47,    47,    47,  -403,
1034    -403,  -403,  -403,    -1,    80,    64,     0,   135,    47,    61,
1035     136,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,
1036     -16,    47,   148,  -403,  -403,  -403,  -403,   138,  -403,  -403,
1037    -403,  -403,  -403,  -403,  -403,   153,  -403,  -403,   224,     4,
1038     226,  -403,   142,   143,   -16,   145,  -403,   146,  -403,  -403,
1039      38,  -403,  -403,   134,  -403,   147,   149,   150,   188,    12,
1040     151,    78,   152,    92,   100,     8,   154,   134,  -403,  -403,
1041    -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,   189,  -403,
1042      38,  -403,   155,  -403,  -403,   134,   157,  -403,    26,  -403,
1043    -403,  -403,  -403,    -3,   159,   163,  -403,   161,  -403,  -403,
1044     158,  -403,  -403,  -403,  -403,   162,    47,    47,  -403,   170,
1045     174,    47,  -403,  -403,  -403,  -403,   239,   252,   253,  -403,
1046    -403,  -403,  -403,   254,  -403,  -403,  -403,  -403,   211,   254,
1047      33,   171,   172,  -403,   173,  -403,   134,     6,  -403,  -403,
1048    -403,   256,   255,     9,   176,  -403,   260,  -403,   263,    47,
1049    -403,  -403,   178,  -403,  -403,   184,    47,    47,   175,  -403,
1050    -403,  -403,  -403,  -403,  -403,  -403,   181,   183,   185,  -403,
1051     182,  -403,   186,  -403,   187,  -403,   190,  -403,   192,  -403,
1052    -403,  -403,  -403,  -403,  -403,  -403,   271,   272,  -403,   275,
1053    -403,  -403,  -403,  -403,  -403,  -403,  -403,   193,  -403,  -403,
1054    -403,  -403,   144,   276,  -403,   194,  -403,   195,    28,  -403,
1055    -403,   106,  -403,   199,   -12,   200,   -30,   278,  -403,   116,
1056      47,  -403,  -403,   257,   102,    92,  -403,   201,  -403,   202,
1057    -403,   203,  -403,  -403,  -403,  -403,  -403,  -403,  -403,   205,
1058    -403,  -403,    47,  -403,   286,   287,  -403,    47,  -403,  -403,
1059    -403,    47,    91,    64,    39,  -403,  -403,  -403,  -403,  -403,
1060    -403,  -403,  -403,   206,  -403,  -403,  -403,  -403,  -403,  -403,
1061    -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,
1062    -403,  -403,  -403,  -403,  -403,   285,  -403,  -403,    20,  -403,
1063    -403,  -403,  -403,    41,  -403,  -403,  -403,  -403,   210,   212,
1064     213,   214,  -403,   258,   -30,  -403,  -403,  -403,  -403,  -403,
1065    -403,    47,  -403,    47,   174,   239,   252,   216,  -403,  -403,
1066     204,   218,   222,   221,   227,   223,   230,   276,  -403,    47,
1067     116,  -403,   239,  -403,   252,   -49,  -403,  -403,  -403,  -403,
1068     276,   228,  -403
1069};
1070
1071  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
1072     Performed when YYTABLE does not specify something else to do.  Zero
1073     means the default is an error.  */
1074static const yytype_int16 yydefact[] =
1075{
1076       0,     3,     4,     0,     6,     1,     9,     0,     5,     0,
1077     269,   270,     0,   234,     0,     0,     0,     0,   232,     2,
1078       0,     0,     0,     0,     0,     0,     0,   231,     0,     0,
1079       8,     0,    12,    13,    14,    15,    16,    17,    18,    19,
1080      21,    22,    23,    20,     0,    85,    86,   107,   108,    87,
1081      88,    89,    90,     7,     0,     0,     0,     0,     0,     0,
1082       0,    61,     0,    84,    60,     0,     0,     0,     0,     0,
1083      72,     0,     0,   229,   230,    31,     0,     0,     0,    10,
1084      11,   237,   235,     0,     0,     0,   111,   231,   109,   233,
1085     246,   244,   240,   242,   239,   259,   241,   231,    80,    81,
1086      82,    83,    50,   231,   231,   231,   231,   231,   231,    74,
1087      51,   222,   221,     0,     0,     0,     0,    56,   231,    79,
1088       0,    57,    59,   120,   121,   202,   203,   122,   218,   219,
1089       0,   231,     0,   268,    91,   238,   112,     0,   113,   117,
1090     118,   119,   216,   217,   220,     0,   249,   248,     0,   250,
1091       0,   243,     0,     0,     0,     0,    26,     0,    25,    24,
1092     256,   105,   103,   259,    93,     0,     0,     0,     0,     0,
1093       0,   253,     0,   253,     0,     0,   263,   259,   128,   129,
1094     130,   131,   133,   132,   134,   135,   136,   137,     0,   138,
1095     256,    97,     0,    95,    94,   259,     0,    92,     0,    77,
1096      76,    78,    49,     0,     0,     0,   236,     0,   228,   227,
1097       0,   251,   252,   245,   265,     0,   231,   231,    47,     0,
1098       0,   231,   257,   258,   104,   106,     0,     0,     0,   201,
1099     172,   173,   171,     0,   151,   255,   254,   150,     0,     0,
1100       0,     0,   196,   192,     0,   191,   259,   184,   178,   177,
1101     176,     0,     0,     0,     0,    96,     0,    98,     0,   231,
1102     223,    65,     0,    63,    64,     0,   231,   231,     0,   110,
1103     247,   260,    28,    27,    75,    48,   261,     0,     0,   214,
1104       0,   215,     0,   175,     0,   163,     0,   152,     0,   157,
1105     158,   141,   142,   159,   139,   140,     0,     0,   190,     0,
1106     193,   186,   188,   187,   183,   185,   267,     0,   156,   155,
1107     165,   166,     0,     0,   102,     0,   101,     0,     0,    58,
1108      73,    67,    46,     0,     0,     0,   231,     0,    33,     0,
1109     231,   209,   213,     0,     0,   253,   200,     0,   198,     0,
1110     199,     0,   264,   170,   169,   167,   168,   164,   189,     0,
1111      99,   100,   231,   224,     0,     0,    66,   231,    54,    53,
1112      55,   231,     0,     0,     0,   115,   123,   126,   124,   204,
1113     205,   125,   266,     0,    34,    35,    36,    37,    38,    39,
1114      40,    41,    42,    43,    44,    45,    30,    29,   174,   160,
1115     146,   161,   148,   145,   162,     0,   143,   144,     0,   195,
1116     197,   194,   179,     0,    70,    68,    71,    69,     0,     0,
1117       0,     0,   127,   181,   231,   114,   262,   149,   147,   153,
1118     154,   231,   225,   231,     0,     0,     0,     0,   180,   116,
1119       0,     0,     0,     0,   207,     0,   211,     0,   226,   231,
1120       0,   206,     0,   210,     0,     0,    52,    32,   208,   212,
1121       0,     0,   182
1122};
1123
1124  /* YYPGOTO[NTERM-NUM].  */
1125static const yytype_int16 yypgoto[] =
1126{
1127    -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,
1128    -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -103,
1129    -101,  -403,   -99,  -403,   -92,   191,  -403,  -403,  -338,  -403,
1130    -100,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,   139,
1131    -403,  -403,  -403,  -403,  -403,  -403,  -403,   259,  -403,  -403,
1132    -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,
1133    -403,   -77,  -403,   -86,  -403,  -403,  -403,  -403,  -403,  -403,
1134    -403,  -403,  -403,  -403,  -403,   -58,  -403,   105,  -403,  -403,
1135    -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -403,
1136     -22,  -403,  -403,  -388,  -403,  -403,  -403,  -403,  -403,  -403,
1137     261,  -403,  -403,  -403,  -403,  -403,  -403,  -403,  -402,  -374,
1138     262,  -403,  -403,  -403,   -85,  -115,   -87,  -403,  -403,  -403,
1139    -403,   288,  -403,   265,  -403,  -403,  -403,  -169,   156,  -153,
1140    -403,  -403,  -403,  -403,  -403,  -403,    21
1141};
1142
1143  /* YYDEFGOTO[NTERM-NUM].  */
1144static const yytype_int16 yydefgoto[] =
1145{
1146      -1,     3,     4,     6,     8,     9,    30,    31,    32,    33,
1147      34,    35,    36,    37,    38,    39,    40,    41,    42,   277,
1148     386,    43,   153,   218,    75,    62,    71,   322,   323,   359,
1149     119,    63,   120,   262,   263,   264,   356,   405,   407,    72,
1150     321,   110,   275,   202,   102,    44,    45,   121,   197,   317,
1151     315,   164,    46,    47,    48,   137,    88,   269,   364,   138,
1152     122,   365,   366,   123,   178,   294,   179,   396,   418,   180,
1153     237,   181,   419,   182,   309,   295,   397,   286,   183,   312,
1154     347,   184,   232,   185,   284,   186,   250,   187,   412,   428,
1155     188,   304,   305,   349,   247,   298,   339,   341,   337,   189,
1156     124,   368,   369,   433,   125,   370,   435,   126,   280,   282,
1157     371,   127,   142,   128,   129,   144,    76,    49,    59,    50,
1158      54,    82,    51,    64,    96,   149,   213,   238,   224,   151,
1159     328,   252,   215,   373,   307,    52,    12
1160};
1161
1162  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
1163     positive, shift that token.  If negative, reduce the rule whose
1164     number is the opposite.  If YYTABLE_NINF, syntax error.  */
1165static const yytype_int16 yytable[] =
1166{
1167     145,   139,   143,   198,   240,   152,   156,   111,   112,   159,
1168     225,   358,   155,   146,   157,   158,   154,   113,   154,   408,
1169     261,   154,   113,   434,   253,   147,     7,   114,   160,   190,
1170     204,   145,   362,    60,   248,     5,   161,   191,   115,   205,
1171     448,   230,   257,   363,   310,   289,   114,   301,   302,   445,
1172     192,   290,   436,   193,   219,    53,   450,   115,   289,   162,
1173     194,   402,   451,   311,   290,   211,   291,    61,   231,    55,
1174     449,    56,   212,   163,   195,   116,    73,    74,   249,   118,
1175     116,    73,    74,   117,   118,   431,    10,    11,   303,    10,
1176      11,   293,   167,   300,   168,   148,    70,   196,   118,   222,
1177     169,   446,   292,   234,   293,   235,   223,   170,   171,   172,
1178      70,   173,    57,   174,   165,    90,    91,   236,   273,   235,
1179       1,     2,   175,    92,   272,   410,   166,   389,   390,   278,
1180     154,   236,    58,   391,   259,    81,   352,   411,    79,   176,
1181     177,   260,   392,   353,   318,    93,    94,   414,   241,   421,
1182      80,   242,   243,    86,   415,   244,   422,    87,    73,    74,
1183      95,   199,   393,   245,   200,   201,   398,    98,    99,   100,
1184     101,    83,   145,   394,   395,   325,   208,   209,    84,   324,
1185     109,   246,    13,    14,    15,    85,    16,    17,    18,    19,
1186      20,    21,    22,    23,    24,    25,    26,    27,    28,    29,
1187     374,   375,   376,   377,   378,   379,   380,   381,   382,   383,
1188     384,   385,    65,    66,    67,    68,    69,   354,   355,    77,
1189      78,   343,   344,   345,   346,    60,    97,   103,   104,   105,
1190     106,   107,   108,   130,   131,   132,   133,   403,   387,   145,
1191     367,   143,   136,   150,   -62,   203,   206,   210,   207,   214,
1192     216,   217,   229,   220,   221,   254,   226,   276,   227,   228,
1193     233,   239,   279,   251,   256,   145,   258,   266,   270,   409,
1194     324,   267,   271,   274,   268,   281,   283,   285,   287,   306,
1195     296,   297,   299,   314,   308,   313,   316,   320,   319,   326,
1196     327,   329,   331,   330,   336,   338,   332,   333,   340,   348,
1197     334,   372,   335,   342,   350,   351,   430,   357,   361,   404,
1198     406,   399,   400,   401,   388,   402,   416,   417,   423,   438,
1199     424,   432,   425,   426,   427,   437,   439,   145,   367,   143,
1200     440,   441,   442,   443,   145,   444,   324,   429,   452,   447,
1201     420,   413,   265,   134,   288,   360,   255,    89,   140,   141,
1202     135,     0,   324
1203};
1204
1205static const yytype_int16 yycheck[] =
1206{
1207      87,    87,    87,   118,   173,    97,   105,    23,    24,   108,
1208     163,    23,   104,    27,   106,   107,   103,    38,   105,   357,
1209      23,   108,    38,   425,   177,    39,     8,    62,    29,    29,
1210     130,   118,    62,    65,    26,     0,    37,    37,    73,   131,
1211     442,    29,   195,    73,    35,    25,    62,    41,    42,   437,
1212      50,    31,   426,    53,   154,   107,   105,    73,    25,    60,
1213      60,   110,   450,    54,    31,    61,    33,    99,    56,    98,
1214     444,    98,    68,    74,    74,    96,   111,   112,    70,   114,
1215      96,   111,   112,    99,   114,   423,    98,    99,    82,    98,
1216      99,    71,    28,   246,    30,   109,    99,    97,   114,    61,
1217      36,   439,    69,    25,    71,    27,    68,    43,    44,    45,
1218      99,    47,    98,    49,    34,    29,    30,    39,   217,    27,
1219       3,     4,    58,    37,   216,    34,    46,    25,    26,   221,
1220     217,    39,    98,    31,   108,    98,   108,    46,   107,    75,
1221      76,   115,    40,   115,   259,    59,    60,   108,    48,   108,
1222     107,    51,    52,   109,   115,    55,   115,   113,   111,   112,
1223      74,   100,    60,    63,   103,   104,   335,   100,   101,   102,
1224     103,   113,   259,    71,    72,   267,    23,    24,   113,   266,
1225     103,    81,     5,     6,     7,   113,     9,    10,    11,    12,
1226      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
1227      84,    85,    86,    87,    88,    89,    90,    91,    92,    93,
1228      94,    95,    21,    22,    23,    24,    25,   111,   112,    28,
1229      29,    77,    78,    79,    80,    65,   108,   108,   108,   108,
1230     108,   108,   108,   108,   108,   108,    99,   352,   330,   326,
1231     326,   326,    23,   109,   109,   109,    98,    23,   110,    23,
1232     108,   108,    64,   108,   108,    66,   109,    83,   109,   109,
1233     109,   109,    23,   109,   109,   352,   109,   108,   110,   361,
1234     357,   108,   110,   103,   113,    23,    23,    23,    67,    23,
1235     109,   109,   109,    23,    29,   109,    23,   103,   110,   114,
1236     109,   108,   110,   108,    23,    23,   110,   110,    23,    23,
1237     110,    23,   110,   110,   110,   110,   421,   108,   108,    23,
1238      23,   110,   110,   110,    57,   110,   110,    32,   108,   115,
1239     108,   424,   109,   109,    66,   109,   108,   414,   414,   414,
1240     108,   110,   105,   110,   421,   105,   423,   414,   110,   440,
1241     398,   363,   203,    84,   239,   324,   190,    59,    87,    87,
1242      85,    -1,   439
1243};
1244
1245  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1246     symbol of state STATE-NUM.  */
1247static const yytype_uint8 yystos[] =
1248{
1249       0,     3,     4,   117,   118,     0,   119,     8,   120,   121,
1250      98,    99,   252,     5,     6,     7,     9,    10,    11,    12,
1251      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
1252     122,   123,   124,   125,   126,   127,   128,   129,   130,   131,
1253     132,   133,   134,   137,   161,   162,   168,   169,   170,   233,
1254     235,   238,   251,   107,   236,    98,    98,    98,    98,   234,
1255      65,    99,   141,   147,   239,   141,   141,   141,   141,   141,
1256      99,   142,   155,   111,   112,   140,   232,   141,   141,   107,
1257     107,    98,   237,   113,   113,   113,   109,   113,   172,   237,
1258      29,    30,    37,    59,    60,    74,   240,   108,   100,   101,
1259     102,   103,   160,   108,   108,   108,   108,   108,   108,   103,
1260     157,    23,    24,    38,    62,    73,    96,    99,   114,   146,
1261     148,   163,   176,   179,   216,   220,   223,   227,   229,   230,
1262     108,   108,   108,    99,   163,   239,    23,   171,   175,   179,
1263     216,   226,   228,   230,   231,   232,    27,    39,   109,   241,
1264     109,   245,   140,   138,   232,   140,   138,   140,   140,   138,
1265      29,    37,    60,    74,   167,    34,    46,    28,    30,    36,
1266      43,    44,    45,    47,    49,    58,    75,    76,   180,   182,
1267     185,   187,   189,   194,   197,   199,   201,   203,   206,   215,
1268      29,    37,    50,    53,    60,    74,    97,   164,   231,   100,
1269     103,   104,   159,   109,   146,   140,    98,   110,    23,    24,
1270      23,    61,    68,   242,    23,   248,   108,   108,   139,   146,
1271     108,   108,    61,    68,   244,   245,   109,   109,   109,    64,
1272      29,    56,   198,   109,    25,    27,    39,   186,   243,   109,
1273     243,    48,    51,    52,    55,    63,    81,   210,    26,    70,
1274     202,   109,   247,   245,    66,   244,   109,   245,   109,   108,
1275     115,    23,   149,   150,   151,   155,   108,   108,   113,   173,
1276     110,   110,   140,   138,   103,   158,    83,   135,   140,    23,
1277     224,    23,   225,    23,   200,    23,   193,    67,   193,    25,
1278      31,    33,    69,    71,   181,   191,   109,   109,   211,   109,
1279     245,    41,    42,    82,   207,   208,    23,   250,    29,   190,
1280      35,    54,   195,   109,    23,   166,    23,   165,   231,   110,
1281     103,   156,   143,   144,   232,   140,   114,   109,   246,   108,
1282     108,   110,   110,   110,   110,   110,    23,   214,    23,   212,
1283      23,   213,   110,    77,    78,    79,    80,   196,    23,   209,
1284     110,   110,   108,   115,   111,   112,   152,   108,    23,   145,
1285     252,   108,    62,    73,   174,   177,   178,   179,   217,   218,
1286     221,   226,    23,   249,    84,    85,    86,    87,    88,    89,
1287      90,    91,    92,    93,    94,    95,   136,   140,    57,    25,
1288      26,    31,    40,    60,    71,    72,   183,   192,   243,   110,
1289     110,   110,   110,   231,    23,   153,    23,   154,   144,   140,
1290      34,    46,   204,   206,   108,   115,   110,    32,   184,   188,
1291     191,   108,   115,   108,   108,   109,   109,    66,   205,   177,
1292     231,   144,   135,   219,   224,   222,   225,   109,   115,   108,
1293     108,   110,   105,   110,   105,   209,   144,   136,   224,   225,
1294     105,   209,   110
1295};
1296
1297  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
1298static const yytype_uint8 yyr1[] =
1299{
1300       0,   116,   117,   118,   118,   119,   119,   120,   121,   121,
1301     122,   122,   123,   123,   124,   124,   124,   124,   124,   124,
1302     124,   125,   125,   125,   126,   127,   128,   129,   130,   131,
1303     132,   133,   134,   135,   136,   136,   136,   136,   136,   136,
1304     136,   136,   136,   136,   136,   136,   137,   138,   139,   140,
1305     141,   142,   143,   144,   145,   145,   146,   146,   146,   146,
1306     147,   147,   148,   149,   149,   150,   151,   152,   152,   152,
1307     153,   154,   155,   156,   157,   158,   159,   159,   159,   159,
1308     160,   160,   160,   160,   160,   161,   161,   161,   161,   161,
1309     161,   162,   163,   163,   164,   164,   164,   164,   164,   164,
1310     164,   165,   166,   167,   167,   167,   167,   168,   168,   169,
1311     170,   171,   171,   172,   173,   174,   174,   175,   175,   175,
1312     176,   176,   176,   177,   177,   177,   178,   178,   179,   179,
1313     179,   179,   179,   179,   179,   179,   179,   179,   179,   180,
1314     181,   181,   181,   182,   183,   183,   183,   183,   183,   184,
1315     185,   186,   186,   187,   188,   189,   190,   191,   191,   191,
1316     192,   192,   192,   193,   194,   195,   195,   196,   196,   196,
1317     196,   197,   198,   198,   199,   200,   201,   202,   202,   203,
1318     204,   205,   205,   206,   207,   207,   208,   208,   208,   209,
1319     210,   210,   210,   210,   210,   210,   211,   211,   212,   213,
1320     214,   215,   216,   216,   217,   217,   218,   219,   219,   220,
1321     221,   222,   222,   223,   224,   225,   226,   226,   227,   227,
1322     228,   229,   229,   230,   230,   230,   230,   231,   231,   232,
1323     232,   232,   234,   233,   236,   235,   237,   237,   238,   239,
1324     239,   239,   239,   239,   239,   240,   241,   241,   241,   241,
1325     242,   242,   242,   243,   243,   243,   244,   244,   244,   245,
1326     245,   246,   246,   247,   247,   248,   249,   250,   251,   252,
1327     252
1328};
1329
1330  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
1331static const yytype_int8 yyr2[] =
1332{
1333       0,     2,     4,     1,     1,     2,     0,     3,     2,     0,
1334       2,     2,     1,     1,     1,     1,     1,     1,     1,     1,
1335       1,     1,     1,     1,     4,     4,     4,     6,     6,     8,
1336       8,     2,    12,     2,     1,     1,     1,     1,     1,     1,
1337       1,     1,     1,     1,     1,     1,     6,     2,     2,     3,
1338       2,     2,     7,     2,     1,     1,     1,     1,     4,     1,
1339       1,     1,     1,     1,     1,     1,     3,     0,     2,     2,
1340       1,     1,     1,     1,     1,     1,     1,     1,     1,     0,
1341       1,     1,     1,     1,     0,     1,     1,     1,     1,     1,
1342       1,     4,     2,     2,     1,     1,     2,     1,     2,     4,
1343       4,     1,     1,     1,     2,     1,     2,     1,     1,     3,
1344       6,     0,     1,     2,     4,     1,     3,     1,     1,     1,
1345       1,     1,     1,     1,     1,     1,     1,     2,     2,     2,
1346       2,     2,     2,     2,     2,     2,     2,     2,     2,     3,
1347       1,     1,     1,     5,     1,     1,     1,     2,     1,     1,
1348       2,     1,     2,     6,     1,     3,     1,     1,     1,     1,
1349       1,     1,     1,     1,     4,     1,     1,     1,     1,     1,
1350       1,     2,     1,     1,     5,     1,     2,     1,     1,     5,
1351       2,     0,     6,     3,     0,     1,     1,     1,     1,     1,
1352       2,     1,     1,     2,     4,     4,     0,     3,     1,     1,
1353       1,     2,     1,     1,     1,     1,     5,     1,     3,     5,
1354       5,     1,     3,     5,     1,     1,     1,     1,     1,     1,
1355       1,     1,     1,     3,     5,     7,     9,     2,     2,     1,
1356       1,     0,     0,     3,     0,     3,     3,     1,     4,     2,
1357       2,     2,     2,     3,     2,     3,     0,     3,     1,     1,
1358       0,     1,     1,     0,     1,     1,     0,     1,     1,     0,
1359       3,     0,     3,     0,     3,     1,     1,     1,     4,     1,
1360       1
1361};
1362
1363
1364enum { YYENOMEM = -2 };
1365
1366#define yyerrok         (yyerrstatus = 0)
1367#define yyclearin       (yychar = YYEMPTY)
1368
1369#define YYACCEPT        goto yyacceptlab
1370#define YYABORT         goto yyabortlab
1371#define YYERROR         goto yyerrorlab
1372
1373
1374#define YYRECOVERING()  (!!yyerrstatus)
1375
1376#define YYBACKUP(Token, Value)                                    \
1377  do                                                              \
1378    if (yychar == YYEMPTY)                                        \
1379      {                                                           \
1380        yychar = (Token);                                         \
1381        yylval = (Value);                                         \
1382        YYPOPSTACK (yylen);                                       \
1383        yystate = *yyssp;                                         \
1384        goto yybackup;                                            \
1385      }                                                           \
1386    else                                                          \
1387      {                                                           \
1388        yyerror (&yylloc, state, YY_("syntax error: cannot back up")); \
1389        YYERROR;                                                  \
1390      }                                                           \
1391  while (0)
1392
1393/* Backward compatibility with an undocumented macro.
1394   Use YYerror or YYUNDEF. */
1395#define YYERRCODE YYUNDEF
1396
1397/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
1398   If N is 0, then set CURRENT to the empty location which ends
1399   the previous symbol: RHS[0] (always defined).  */
1400
1401#ifndef YYLLOC_DEFAULT
1402# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
1403    do                                                                  \
1404      if (N)                                                            \
1405        {                                                               \
1406          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
1407          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
1408          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
1409          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
1410        }                                                               \
1411      else                                                              \
1412        {                                                               \
1413          (Current).first_line   = (Current).last_line   =              \
1414            YYRHSLOC (Rhs, 0).last_line;                                \
1415          (Current).first_column = (Current).last_column =              \
1416            YYRHSLOC (Rhs, 0).last_column;                              \
1417        }                                                               \
1418    while (0)
1419#endif
1420
1421#define YYRHSLOC(Rhs, K) ((Rhs)[K])
1422
1423
1424/* Enable debugging if requested.  */
1425#if YYDEBUG
1426
1427# ifndef YYFPRINTF
1428#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1429#  define YYFPRINTF fprintf
1430# endif
1431
1432# define YYDPRINTF(Args)                        \
1433do {                                            \
1434  if (yydebug)                                  \
1435    YYFPRINTF Args;                             \
1436} while (0)
1437
1438
1439/* YY_LOCATION_PRINT -- Print the location on the stream.
1440   This macro was not mandated originally: define only if we know
1441   we won't break user code: when these are the locations we know.  */
1442
1443# ifndef YY_LOCATION_PRINT
1444#  if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1445
1446/* Print *YYLOCP on YYO.  Private, do not rely on its existence. */
1447
1448YY_ATTRIBUTE_UNUSED
1449static int
1450yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
1451{
1452  int res = 0;
1453  int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
1454  if (0 <= yylocp->first_line)
1455    {
1456      res += YYFPRINTF (yyo, "%d", yylocp->first_line);
1457      if (0 <= yylocp->first_column)
1458        res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
1459    }
1460  if (0 <= yylocp->last_line)
1461    {
1462      if (yylocp->first_line < yylocp->last_line)
1463        {
1464          res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
1465          if (0 <= end_col)
1466            res += YYFPRINTF (yyo, ".%d", end_col);
1467        }
1468      else if (0 <= end_col && yylocp->first_column < end_col)
1469        res += YYFPRINTF (yyo, "-%d", end_col);
1470    }
1471  return res;
1472 }
1473
1474#   define YY_LOCATION_PRINT(File, Loc)          \
1475  yy_location_print_ (File, &(Loc))
1476
1477#  else
1478#   define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1479#  endif
1480# endif /* !defined YY_LOCATION_PRINT */
1481
1482
1483# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)                    \
1484do {                                                                      \
1485  if (yydebug)                                                            \
1486    {                                                                     \
1487      YYFPRINTF (stderr, "%s ", Title);                                   \
1488      yy_symbol_print (stderr,                                            \
1489                  Kind, Value, Location, state); \
1490      YYFPRINTF (stderr, "\n");                                           \
1491    }                                                                     \
1492} while (0)
1493
1494
1495/*-----------------------------------.
1496| Print this symbol's value on YYO.  |
1497`-----------------------------------*/
1498
1499static void
1500yy_symbol_value_print (FILE *yyo,
1501                       yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct asm_parser_state *state)
1502{
1503  FILE *yyoutput = yyo;
1504  YYUSE (yyoutput);
1505  YYUSE (yylocationp);
1506  YYUSE (state);
1507  if (!yyvaluep)
1508    return;
1509# ifdef YYPRINT
1510  if (yykind < YYNTOKENS)
1511    YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
1512# endif
1513  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1514  YYUSE (yykind);
1515  YY_IGNORE_MAYBE_UNINITIALIZED_END
1516}
1517
1518
1519/*---------------------------.
1520| Print this symbol on YYO.  |
1521`---------------------------*/
1522
1523static void
1524yy_symbol_print (FILE *yyo,
1525                 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct asm_parser_state *state)
1526{
1527  YYFPRINTF (yyo, "%s %s (",
1528             yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
1529
1530  YY_LOCATION_PRINT (yyo, *yylocationp);
1531  YYFPRINTF (yyo, ": ");
1532  yy_symbol_value_print (yyo, yykind, yyvaluep, yylocationp, state);
1533  YYFPRINTF (yyo, ")");
1534}
1535
1536/*------------------------------------------------------------------.
1537| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1538| TOP (included).                                                   |
1539`------------------------------------------------------------------*/
1540
1541static void
1542yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
1543{
1544  YYFPRINTF (stderr, "Stack now");
1545  for (; yybottom <= yytop; yybottom++)
1546    {
1547      int yybot = *yybottom;
1548      YYFPRINTF (stderr, " %d", yybot);
1549    }
1550  YYFPRINTF (stderr, "\n");
1551}
1552
1553# define YY_STACK_PRINT(Bottom, Top)                            \
1554do {                                                            \
1555  if (yydebug)                                                  \
1556    yy_stack_print ((Bottom), (Top));                           \
1557} while (0)
1558
1559
1560/*------------------------------------------------.
1561| Report that the YYRULE is going to be reduced.  |
1562`------------------------------------------------*/
1563
1564static void
1565yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp,
1566                 int yyrule, struct asm_parser_state *state)
1567{
1568  int yylno = yyrline[yyrule];
1569  int yynrhs = yyr2[yyrule];
1570  int yyi;
1571  YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
1572             yyrule - 1, yylno);
1573  /* The symbols being reduced.  */
1574  for (yyi = 0; yyi < yynrhs; yyi++)
1575    {
1576      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
1577      yy_symbol_print (stderr,
1578                       YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
1579                       &yyvsp[(yyi + 1) - (yynrhs)],
1580                       &(yylsp[(yyi + 1) - (yynrhs)]), state);
1581      YYFPRINTF (stderr, "\n");
1582    }
1583}
1584
1585# define YY_REDUCE_PRINT(Rule)          \
1586do {                                    \
1587  if (yydebug)                          \
1588    yy_reduce_print (yyssp, yyvsp, yylsp, Rule, state); \
1589} while (0)
1590
1591/* Nonzero means print parse trace.  It is left uninitialized so that
1592   multiple parsers can coexist.  */
1593int yydebug;
1594#else /* !YYDEBUG */
1595# define YYDPRINTF(Args) ((void) 0)
1596# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
1597# define YY_STACK_PRINT(Bottom, Top)
1598# define YY_REDUCE_PRINT(Rule)
1599#endif /* !YYDEBUG */
1600
1601
1602/* YYINITDEPTH -- initial size of the parser's stacks.  */
1603#ifndef YYINITDEPTH
1604# define YYINITDEPTH 200
1605#endif
1606
1607/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1608   if the built-in stack extension method is used).
1609
1610   Do not make this value too large; the results are undefined if
1611   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1612   evaluated with infinite-precision integer arithmetic.  */
1613
1614#ifndef YYMAXDEPTH
1615# define YYMAXDEPTH 10000
1616#endif
1617
1618
1619/* Context of a parse error.  */
1620typedef struct
1621{
1622  yy_state_t *yyssp;
1623  yysymbol_kind_t yytoken;
1624  YYLTYPE *yylloc;
1625} yypcontext_t;
1626
1627/* Put in YYARG at most YYARGN of the expected tokens given the
1628   current YYCTX, and return the number of tokens stored in YYARG.  If
1629   YYARG is null, return the number of expected tokens (guaranteed to
1630   be less than YYNTOKENS).  Return YYENOMEM on memory exhaustion.
1631   Return 0 if there are more than YYARGN expected tokens, yet fill
1632   YYARG up to YYARGN. */
1633static int
1634yypcontext_expected_tokens (const yypcontext_t *yyctx,
1635                            yysymbol_kind_t yyarg[], int yyargn)
1636{
1637  /* Actual size of YYARG. */
1638  int yycount = 0;
1639  int yyn = yypact[+*yyctx->yyssp];
1640  if (!yypact_value_is_default (yyn))
1641    {
1642      /* Start YYX at -YYN if negative to avoid negative indexes in
1643         YYCHECK.  In other words, skip the first -YYN actions for
1644         this state because they are default actions.  */
1645      int yyxbegin = yyn < 0 ? -yyn : 0;
1646      /* Stay within bounds of both yycheck and yytname.  */
1647      int yychecklim = YYLAST - yyn + 1;
1648      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1649      int yyx;
1650      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1651        if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_YYerror
1652            && !yytable_value_is_error (yytable[yyx + yyn]))
1653          {
1654            if (!yyarg)
1655              ++yycount;
1656            else if (yycount == yyargn)
1657              return 0;
1658            else
1659              yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);
1660          }
1661    }
1662  if (yyarg && yycount == 0 && 0 < yyargn)
1663    yyarg[0] = YYSYMBOL_YYEMPTY;
1664  return yycount;
1665}
1666
1667
1668
1669
1670#ifndef yystrlen
1671# if defined __GLIBC__ && defined _STRING_H
1672#  define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
1673# else
1674/* Return the length of YYSTR.  */
1675static YYPTRDIFF_T
1676yystrlen (const char *yystr)
1677{
1678  YYPTRDIFF_T yylen;
1679  for (yylen = 0; yystr[yylen]; yylen++)
1680    continue;
1681  return yylen;
1682}
1683# endif
1684#endif
1685
1686#ifndef yystpcpy
1687# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1688#  define yystpcpy stpcpy
1689# else
1690/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1691   YYDEST.  */
1692static char *
1693yystpcpy (char *yydest, const char *yysrc)
1694{
1695  char *yyd = yydest;
1696  const char *yys = yysrc;
1697
1698  while ((*yyd++ = *yys++) != '\0')
1699    continue;
1700
1701  return yyd - 1;
1702}
1703# endif
1704#endif
1705
1706#ifndef yytnamerr
1707/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1708   quotes and backslashes, so that it's suitable for yyerror.  The
1709   heuristic is that double-quoting is unnecessary unless the string
1710   contains an apostrophe, a comma, or backslash (other than
1711   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1712   null, do not copy; instead, return the length of what the result
1713   would have been.  */
1714static YYPTRDIFF_T
1715yytnamerr (char *yyres, const char *yystr)
1716{
1717  if (*yystr == '"')
1718    {
1719      YYPTRDIFF_T yyn = 0;
1720      char const *yyp = yystr;
1721      for (;;)
1722        switch (*++yyp)
1723          {
1724          case '\'':
1725          case ',':
1726            goto do_not_strip_quotes;
1727
1728          case '\\':
1729            if (*++yyp != '\\')
1730              goto do_not_strip_quotes;
1731            else
1732              goto append;
1733
1734          append:
1735          default:
1736            if (yyres)
1737              yyres[yyn] = *yyp;
1738            yyn++;
1739            break;
1740
1741          case '"':
1742            if (yyres)
1743              yyres[yyn] = '\0';
1744            return yyn;
1745          }
1746    do_not_strip_quotes: ;
1747    }
1748
1749  if (yyres)
1750    return yystpcpy (yyres, yystr) - yyres;
1751  else
1752    return yystrlen (yystr);
1753}
1754#endif
1755
1756
1757static int
1758yy_syntax_error_arguments (const yypcontext_t *yyctx,
1759                           yysymbol_kind_t yyarg[], int yyargn)
1760{
1761  /* Actual size of YYARG. */
1762  int yycount = 0;
1763  /* There are many possibilities here to consider:
1764     - If this state is a consistent state with a default action, then
1765       the only way this function was invoked is if the default action
1766       is an error action.  In that case, don't check for expected
1767       tokens because there are none.
1768     - The only way there can be no lookahead present (in yychar) is if
1769       this state is a consistent state with a default action.  Thus,
1770       detecting the absence of a lookahead is sufficient to determine
1771       that there is no unexpected or expected token to report.  In that
1772       case, just report a simple "syntax error".
1773     - Don't assume there isn't a lookahead just because this state is a
1774       consistent state with a default action.  There might have been a
1775       previous inconsistent state, consistent state with a non-default
1776       action, or user semantic action that manipulated yychar.
1777     - Of course, the expected token list depends on states to have
1778       correct lookahead information, and it depends on the parser not
1779       to perform extra reductions after fetching a lookahead from the
1780       scanner and before detecting a syntax error.  Thus, state merging
1781       (from LALR or IELR) and default reductions corrupt the expected
1782       token list.  However, the list is correct for canonical LR with
1783       one exception: it will still contain any token that will not be
1784       accepted due to an error action in a later state.
1785  */
1786  if (yyctx->yytoken != YYSYMBOL_YYEMPTY)
1787    {
1788      int yyn;
1789      if (yyarg)
1790        yyarg[yycount] = yyctx->yytoken;
1791      ++yycount;
1792      yyn = yypcontext_expected_tokens (yyctx,
1793                                        yyarg ? yyarg + 1 : yyarg, yyargn - 1);
1794      if (yyn == YYENOMEM)
1795        return YYENOMEM;
1796      else
1797        yycount += yyn;
1798    }
1799  return yycount;
1800}
1801
1802/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1803   about the unexpected token YYTOKEN for the state stack whose top is
1804   YYSSP.
1805
1806   Return 0 if *YYMSG was successfully written.  Return -1 if *YYMSG is
1807   not large enough to hold the message.  In that case, also set
1808   *YYMSG_ALLOC to the required number of bytes.  Return YYENOMEM if the
1809   required number of bytes is too large to store.  */
1810static int
1811yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
1812                const yypcontext_t *yyctx)
1813{
1814  enum { YYARGS_MAX = 5 };
1815  /* Internationalized format string. */
1816  const char *yyformat = YY_NULLPTR;
1817  /* Arguments of yyformat: reported tokens (one for the "unexpected",
1818     one per "expected"). */
1819  yysymbol_kind_t yyarg[YYARGS_MAX];
1820  /* Cumulated lengths of YYARG.  */
1821  YYPTRDIFF_T yysize = 0;
1822
1823  /* Actual size of YYARG. */
1824  int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX);
1825  if (yycount == YYENOMEM)
1826    return YYENOMEM;
1827
1828  switch (yycount)
1829    {
1830#define YYCASE_(N, S)                       \
1831      case N:                               \
1832        yyformat = S;                       \
1833        break
1834    default: /* Avoid compiler warnings. */
1835      YYCASE_(0, YY_("syntax error"));
1836      YYCASE_(1, YY_("syntax error, unexpected %s"));
1837      YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1838      YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1839      YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1840      YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1841#undef YYCASE_
1842    }
1843
1844  /* Compute error message size.  Don't count the "%s"s, but reserve
1845     room for the terminator.  */
1846  yysize = yystrlen (yyformat) - 2 * yycount + 1;
1847  {
1848    int yyi;
1849    for (yyi = 0; yyi < yycount; ++yyi)
1850      {
1851        YYPTRDIFF_T yysize1
1852          = yysize + yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]]);
1853        if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1854          yysize = yysize1;
1855        else
1856          return YYENOMEM;
1857      }
1858  }
1859
1860  if (*yymsg_alloc < yysize)
1861    {
1862      *yymsg_alloc = 2 * yysize;
1863      if (! (yysize <= *yymsg_alloc
1864             && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1865        *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1866      return -1;
1867    }
1868
1869  /* Avoid sprintf, as that infringes on the user's name space.
1870     Don't have undefined behavior even if the translation
1871     produced a string with the wrong number of "%s"s.  */
1872  {
1873    char *yyp = *yymsg;
1874    int yyi = 0;
1875    while ((*yyp = *yyformat) != '\0')
1876      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1877        {
1878          yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);
1879          yyformat += 2;
1880        }
1881      else
1882        {
1883          ++yyp;
1884          ++yyformat;
1885        }
1886  }
1887  return 0;
1888}
1889
1890
1891/*-----------------------------------------------.
1892| Release the memory associated to this symbol.  |
1893`-----------------------------------------------*/
1894
1895static void
1896yydestruct (const char *yymsg,
1897            yysymbol_kind_t yykind, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, struct asm_parser_state *state)
1898{
1899  YYUSE (yyvaluep);
1900  YYUSE (yylocationp);
1901  YYUSE (state);
1902  if (!yymsg)
1903    yymsg = "Deleting";
1904  YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1905
1906  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1907  YYUSE (yykind);
1908  YY_IGNORE_MAYBE_UNINITIALIZED_END
1909}
1910
1911
1912
1913
1914
1915
1916/*----------.
1917| yyparse.  |
1918`----------*/
1919
1920int
1921yyparse (struct asm_parser_state *state)
1922{
1923/* Lookahead token kind.  */
1924int yychar;
1925
1926
1927/* The semantic value of the lookahead symbol.  */
1928/* Default value used for initialization, for pacifying older GCCs
1929   or non-GCC compilers.  */
1930YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1931YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1932
1933/* Location data for the lookahead symbol.  */
1934static YYLTYPE yyloc_default
1935# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1936  = { 1, 1, 1, 1 }
1937# endif
1938;
1939YYLTYPE yylloc = yyloc_default;
1940
1941    /* Number of syntax errors so far.  */
1942    int yynerrs = 0;
1943
1944    yy_state_fast_t yystate = 0;
1945    /* Number of tokens to shift before error messages enabled.  */
1946    int yyerrstatus = 0;
1947
1948    /* Refer to the stacks through separate pointers, to allow yyoverflow
1949       to reallocate them elsewhere.  */
1950
1951    /* Their size.  */
1952    YYPTRDIFF_T yystacksize = YYINITDEPTH;
1953
1954    /* The state stack: array, bottom, top.  */
1955    yy_state_t yyssa[YYINITDEPTH];
1956    yy_state_t *yyss = yyssa;
1957    yy_state_t *yyssp = yyss;
1958
1959    /* The semantic value stack: array, bottom, top.  */
1960    YYSTYPE yyvsa[YYINITDEPTH];
1961    YYSTYPE *yyvs = yyvsa;
1962    YYSTYPE *yyvsp = yyvs;
1963
1964    /* The location stack: array, bottom, top.  */
1965    YYLTYPE yylsa[YYINITDEPTH];
1966    YYLTYPE *yyls = yylsa;
1967    YYLTYPE *yylsp = yyls;
1968
1969  int yyn;
1970  /* The return value of yyparse.  */
1971  int yyresult;
1972  /* Lookahead symbol kind.  */
1973  yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1974  /* The variables used to return semantic value and location from the
1975     action routines.  */
1976  YYSTYPE yyval;
1977  YYLTYPE yyloc;
1978
1979  /* The locations where the error started and ended.  */
1980  YYLTYPE yyerror_range[3];
1981
1982  /* Buffer for error messages, and its allocated size.  */
1983  char yymsgbuf[128];
1984  char *yymsg = yymsgbuf;
1985  YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
1986
1987#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1988
1989  /* The number of symbols on the RHS of the reduced rule.
1990     Keep to zero when no symbol should be popped.  */
1991  int yylen = 0;
1992
1993  YYDPRINTF ((stderr, "Starting parse\n"));
1994
1995  yychar = YYEMPTY; /* Cause a token to be read.  */
1996  yylsp[0] = yylloc;
1997  goto yysetstate;
1998
1999
2000/*------------------------------------------------------------.
2001| yynewstate -- push a new state, which is found in yystate.  |
2002`------------------------------------------------------------*/
2003yynewstate:
2004  /* In all cases, when you get here, the value and location stacks
2005     have just been pushed.  So pushing a state here evens the stacks.  */
2006  yyssp++;
2007
2008
2009/*--------------------------------------------------------------------.
2010| yysetstate -- set current state (the top of the stack) to yystate.  |
2011`--------------------------------------------------------------------*/
2012yysetstate:
2013  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
2014  YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
2015  YY_IGNORE_USELESS_CAST_BEGIN
2016  *yyssp = YY_CAST (yy_state_t, yystate);
2017  YY_IGNORE_USELESS_CAST_END
2018  YY_STACK_PRINT (yyss, yyssp);
2019
2020  if (yyss + yystacksize - 1 <= yyssp)
2021#if !defined yyoverflow && !defined YYSTACK_RELOCATE
2022    goto yyexhaustedlab;
2023#else
2024    {
2025      /* Get the current used size of the three stacks, in elements.  */
2026      YYPTRDIFF_T yysize = yyssp - yyss + 1;
2027
2028# if defined yyoverflow
2029      {
2030        /* Give user a chance to reallocate the stack.  Use copies of
2031           these so that the &'s don't force the real ones into
2032           memory.  */
2033        yy_state_t *yyss1 = yyss;
2034        YYSTYPE *yyvs1 = yyvs;
2035        YYLTYPE *yyls1 = yyls;
2036
2037        /* Each stack pointer address is followed by the size of the
2038           data in use in that stack, in bytes.  This used to be a
2039           conditional around just the two extra args, but that might
2040           be undefined if yyoverflow is a macro.  */
2041        yyoverflow (YY_("memory exhausted"),
2042                    &yyss1, yysize * YYSIZEOF (*yyssp),
2043                    &yyvs1, yysize * YYSIZEOF (*yyvsp),
2044                    &yyls1, yysize * YYSIZEOF (*yylsp),
2045                    &yystacksize);
2046        yyss = yyss1;
2047        yyvs = yyvs1;
2048        yyls = yyls1;
2049      }
2050# else /* defined YYSTACK_RELOCATE */
2051      /* Extend the stack our own way.  */
2052      if (YYMAXDEPTH <= yystacksize)
2053        goto yyexhaustedlab;
2054      yystacksize *= 2;
2055      if (YYMAXDEPTH < yystacksize)
2056        yystacksize = YYMAXDEPTH;
2057
2058      {
2059        yy_state_t *yyss1 = yyss;
2060        union yyalloc *yyptr =
2061          YY_CAST (union yyalloc *,
2062                   YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
2063        if (! yyptr)
2064          goto yyexhaustedlab;
2065        YYSTACK_RELOCATE (yyss_alloc, yyss);
2066        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
2067        YYSTACK_RELOCATE (yyls_alloc, yyls);
2068#  undef YYSTACK_RELOCATE
2069        if (yyss1 != yyssa)
2070          YYSTACK_FREE (yyss1);
2071      }
2072# endif
2073
2074      yyssp = yyss + yysize - 1;
2075      yyvsp = yyvs + yysize - 1;
2076      yylsp = yyls + yysize - 1;
2077
2078      YY_IGNORE_USELESS_CAST_BEGIN
2079      YYDPRINTF ((stderr, "Stack size increased to %ld\n",
2080                  YY_CAST (long, yystacksize)));
2081      YY_IGNORE_USELESS_CAST_END
2082
2083      if (yyss + yystacksize - 1 <= yyssp)
2084        YYABORT;
2085    }
2086#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
2087
2088  if (yystate == YYFINAL)
2089    YYACCEPT;
2090
2091  goto yybackup;
2092
2093
2094/*-----------.
2095| yybackup.  |
2096`-----------*/
2097yybackup:
2098  /* Do appropriate processing given the current state.  Read a
2099     lookahead token if we need one and don't already have one.  */
2100
2101  /* First try to decide what to do without reference to lookahead token.  */
2102  yyn = yypact[yystate];
2103  if (yypact_value_is_default (yyn))
2104    goto yydefault;
2105
2106  /* Not known => get a lookahead token if don't already have one.  */
2107
2108  /* YYCHAR is either empty, or end-of-input, or a valid lookahead.  */
2109  if (yychar == YYEMPTY)
2110    {
2111      YYDPRINTF ((stderr, "Reading a token\n"));
2112      yychar = yylex (&yylval, &yylloc, state);
2113    }
2114
2115  if (yychar <= YYEOF)
2116    {
2117      yychar = YYEOF;
2118      yytoken = YYSYMBOL_YYEOF;
2119      YYDPRINTF ((stderr, "Now at end of input.\n"));
2120    }
2121  else if (yychar == YYerror)
2122    {
2123      /* The scanner already issued an error message, process directly
2124         to error recovery.  But do not keep the error token as
2125         lookahead, it is too special and may lead us to an endless
2126         loop in error recovery. */
2127      yychar = YYUNDEF;
2128      yytoken = YYSYMBOL_YYerror;
2129      yyerror_range[1] = yylloc;
2130      goto yyerrlab1;
2131    }
2132  else
2133    {
2134      yytoken = YYTRANSLATE (yychar);
2135      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
2136    }
2137
2138  /* If the proper action on seeing token YYTOKEN is to reduce or to
2139     detect an error, take that action.  */
2140  yyn += yytoken;
2141  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
2142    goto yydefault;
2143  yyn = yytable[yyn];
2144  if (yyn <= 0)
2145    {
2146      if (yytable_value_is_error (yyn))
2147        goto yyerrlab;
2148      yyn = -yyn;
2149      goto yyreduce;
2150    }
2151
2152  /* Count tokens shifted since error; after three, turn off error
2153     status.  */
2154  if (yyerrstatus)
2155    yyerrstatus--;
2156
2157  /* Shift the lookahead token.  */
2158  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
2159  yystate = yyn;
2160  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2161  *++yyvsp = yylval;
2162  YY_IGNORE_MAYBE_UNINITIALIZED_END
2163  *++yylsp = yylloc;
2164
2165  /* Discard the shifted token.  */
2166  yychar = YYEMPTY;
2167  goto yynewstate;
2168
2169
2170/*-----------------------------------------------------------.
2171| yydefault -- do the default action for the current state.  |
2172`-----------------------------------------------------------*/
2173yydefault:
2174  yyn = yydefact[yystate];
2175  if (yyn == 0)
2176    goto yyerrlab;
2177  goto yyreduce;
2178
2179
2180/*-----------------------------.
2181| yyreduce -- do a reduction.  |
2182`-----------------------------*/
2183yyreduce:
2184  /* yyn is the number of a rule to reduce with.  */
2185  yylen = yyr2[yyn];
2186
2187  /* If YYLEN is nonzero, implement the default value of the action:
2188     '$$ = $1'.
2189
2190     Otherwise, the following line sets YYVAL to garbage.
2191     This behavior is undocumented and Bison
2192     users should not rely upon it.  Assigning to YYVAL
2193     unconditionally makes the parser a bit smaller, and it avoids a
2194     GCC warning that YYVAL may be used uninitialized.  */
2195  yyval = yyvsp[1-yylen];
2196
2197  /* Default location. */
2198  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
2199  yyerror_range[1] = yyloc;
2200  YY_REDUCE_PRINT (yyn);
2201  switch (yyn)
2202    {
2203  case 3: /* language: ARBvp_10  */
2204#line 299 "../src/mesa/program/program_parse.y"
2205        {
2206	   if (state->prog->Target != GL_VERTEX_PROGRAM_ARB) {
2207	      yyerror(& (yylsp[0]), state, "invalid fragment program header");
2208
2209	   }
2210	   state->mode = ARB_vertex;
2211	}
2212#line 2213 "src/mesa/program/program_parse.tab.c"
2213    break;
2214
2215  case 4: /* language: ARBfp_10  */
2216#line 307 "../src/mesa/program/program_parse.y"
2217        {
2218	   if (state->prog->Target != GL_FRAGMENT_PROGRAM_ARB) {
2219	      yyerror(& (yylsp[0]), state, "invalid vertex program header");
2220	   }
2221	   state->mode = ARB_fragment;
2222
2223	   state->option.TexRect =
2224	      (state->ctx->Extensions.NV_texture_rectangle != GL_FALSE);
2225	}
2226#line 2227 "src/mesa/program/program_parse.tab.c"
2227    break;
2228
2229  case 7: /* option: OPTION string ';'  */
2230#line 323 "../src/mesa/program/program_parse.y"
2231        {
2232	   int valid = 0;
2233
2234	   if (state->mode == ARB_vertex) {
2235	      valid = _mesa_ARBvp_parse_option(state, (yyvsp[-1].string));
2236	   } else if (state->mode == ARB_fragment) {
2237	      valid = _mesa_ARBfp_parse_option(state, (yyvsp[-1].string));
2238	   }
2239
2240
2241	   free((yyvsp[-1].string));
2242
2243	   if (!valid) {
2244	      const char *const err_str = (state->mode == ARB_vertex)
2245		 ? "invalid ARB vertex program option"
2246		 : "invalid ARB fragment program option";
2247
2248	      yyerror(& (yylsp[-1]), state, err_str);
2249	      YYERROR;
2250	   }
2251	}
2252#line 2253 "src/mesa/program/program_parse.tab.c"
2253    break;
2254
2255  case 10: /* statement: instruction ';'  */
2256#line 351 "../src/mesa/program/program_parse.y"
2257        {
2258	   if ((yyvsp[-1].inst) != NULL) {
2259	      if (state->inst_tail == NULL) {
2260		 state->inst_head = (yyvsp[-1].inst);
2261	      } else {
2262		 state->inst_tail->next = (yyvsp[-1].inst);
2263	      }
2264
2265	      state->inst_tail = (yyvsp[-1].inst);
2266	      (yyvsp[-1].inst)->next = NULL;
2267
2268              state->prog->arb.NumInstructions++;
2269	   }
2270	}
2271#line 2272 "src/mesa/program/program_parse.tab.c"
2272    break;
2273
2274  case 12: /* instruction: ALU_instruction  */
2275#line 369 "../src/mesa/program/program_parse.y"
2276        {
2277	   (yyval.inst) = (yyvsp[0].inst);
2278           state->prog->arb.NumAluInstructions++;
2279	}
2280#line 2281 "src/mesa/program/program_parse.tab.c"
2281    break;
2282
2283  case 13: /* instruction: TexInstruction  */
2284#line 374 "../src/mesa/program/program_parse.y"
2285        {
2286	   (yyval.inst) = (yyvsp[0].inst);
2287           state->prog->arb.NumTexInstructions++;
2288	}
2289#line 2290 "src/mesa/program/program_parse.tab.c"
2290    break;
2291
2292  case 24: /* ARL_instruction: ARL maskedAddrReg ',' scalarSrcReg  */
2293#line 395 "../src/mesa/program/program_parse.y"
2294        {
2295	   (yyval.inst) = asm_instruction_ctor(OPCODE_ARL, & (yyvsp[-2].dst_reg), & (yyvsp[0].src_reg), NULL, NULL);
2296	}
2297#line 2298 "src/mesa/program/program_parse.tab.c"
2298    break;
2299
2300  case 25: /* VECTORop_instruction: VECTOR_OP maskedDstReg ',' swizzleSrcReg  */
2301#line 401 "../src/mesa/program/program_parse.y"
2302        {
2303	   (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[-3].temp_inst), & (yyvsp[-2].dst_reg), & (yyvsp[0].src_reg), NULL, NULL);
2304	}
2305#line 2306 "src/mesa/program/program_parse.tab.c"
2306    break;
2307
2308  case 26: /* SCALARop_instruction: SCALAR_OP maskedDstReg ',' scalarSrcReg  */
2309#line 407 "../src/mesa/program/program_parse.y"
2310        {
2311	   (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[-3].temp_inst), & (yyvsp[-2].dst_reg), & (yyvsp[0].src_reg), NULL, NULL);
2312	}
2313#line 2314 "src/mesa/program/program_parse.tab.c"
2314    break;
2315
2316  case 27: /* BINSCop_instruction: BINSC_OP maskedDstReg ',' scalarSrcReg ',' scalarSrcReg  */
2317#line 413 "../src/mesa/program/program_parse.y"
2318        {
2319	   (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[-5].temp_inst), & (yyvsp[-4].dst_reg), & (yyvsp[-2].src_reg), & (yyvsp[0].src_reg), NULL);
2320	}
2321#line 2322 "src/mesa/program/program_parse.tab.c"
2322    break;
2323
2324  case 28: /* BINop_instruction: BIN_OP maskedDstReg ',' swizzleSrcReg ',' swizzleSrcReg  */
2325#line 420 "../src/mesa/program/program_parse.y"
2326        {
2327	   (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[-5].temp_inst), & (yyvsp[-4].dst_reg), & (yyvsp[-2].src_reg), & (yyvsp[0].src_reg), NULL);
2328	}
2329#line 2330 "src/mesa/program/program_parse.tab.c"
2330    break;
2331
2332  case 29: /* TRIop_instruction: TRI_OP maskedDstReg ',' swizzleSrcReg ',' swizzleSrcReg ',' swizzleSrcReg  */
2333#line 427 "../src/mesa/program/program_parse.y"
2334        {
2335	   (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[-7].temp_inst), & (yyvsp[-6].dst_reg), & (yyvsp[-4].src_reg), & (yyvsp[-2].src_reg), & (yyvsp[0].src_reg));
2336	}
2337#line 2338 "src/mesa/program/program_parse.tab.c"
2338    break;
2339
2340  case 30: /* SAMPLE_instruction: SAMPLE_OP maskedDstReg ',' swizzleSrcReg ',' texImageUnit ',' texTarget  */
2341#line 433 "../src/mesa/program/program_parse.y"
2342        {
2343	   (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[-7].temp_inst), & (yyvsp[-6].dst_reg), & (yyvsp[-4].src_reg), NULL, NULL);
2344	   if ((yyval.inst) != NULL) {
2345	      const GLbitfield tex_mask = (1U << (yyvsp[-2].integer));
2346	      GLbitfield shadow_tex = 0;
2347	      GLbitfield target_mask = 0;
2348
2349
2350	      (yyval.inst)->Base.TexSrcUnit = (yyvsp[-2].integer);
2351
2352	      if ((yyvsp[0].integer) < 0) {
2353		 shadow_tex = tex_mask;
2354
2355		 (yyval.inst)->Base.TexSrcTarget = -(yyvsp[0].integer);
2356		 (yyval.inst)->Base.TexShadow = 1;
2357	      } else {
2358		 (yyval.inst)->Base.TexSrcTarget = (yyvsp[0].integer);
2359	      }
2360
2361	      target_mask = (1U << (yyval.inst)->Base.TexSrcTarget);
2362
2363	      /* If this texture unit was previously accessed and that access
2364	       * had a different texture target, generate an error.
2365	       *
2366	       * If this texture unit was previously accessed and that access
2367	       * had a different shadow mode, generate an error.
2368	       */
2369	      if ((state->prog->TexturesUsed[(yyvsp[-2].integer)] != 0)
2370		  && ((state->prog->TexturesUsed[(yyvsp[-2].integer)] != target_mask)
2371		      || ((state->prog->ShadowSamplers & tex_mask)
2372			  != shadow_tex))) {
2373		 yyerror(& (yylsp[0]), state,
2374			 "multiple targets used on one texture image unit");
2375		 YYERROR;
2376	      }
2377
2378
2379	      state->prog->TexturesUsed[(yyvsp[-2].integer)] |= target_mask;
2380	      state->prog->ShadowSamplers |= shadow_tex;
2381	   }
2382	}
2383#line 2384 "src/mesa/program/program_parse.tab.c"
2384    break;
2385
2386  case 31: /* KIL_instruction: KIL swizzleSrcReg  */
2387#line 477 "../src/mesa/program/program_parse.y"
2388        {
2389	   (yyval.inst) = asm_instruction_ctor(OPCODE_KIL, NULL, & (yyvsp[0].src_reg), NULL, NULL);
2390	   state->fragment.UsesKill = 1;
2391	}
2392#line 2393 "src/mesa/program/program_parse.tab.c"
2393    break;
2394
2395  case 32: /* TXD_instruction: TXD_OP maskedDstReg ',' swizzleSrcReg ',' swizzleSrcReg ',' swizzleSrcReg ',' texImageUnit ',' texTarget  */
2396#line 484 "../src/mesa/program/program_parse.y"
2397        {
2398	   (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[-11].temp_inst), & (yyvsp[-10].dst_reg), & (yyvsp[-8].src_reg), & (yyvsp[-6].src_reg), & (yyvsp[-4].src_reg));
2399	   if ((yyval.inst) != NULL) {
2400	      const GLbitfield tex_mask = (1U << (yyvsp[-2].integer));
2401	      GLbitfield shadow_tex = 0;
2402	      GLbitfield target_mask = 0;
2403
2404
2405	      (yyval.inst)->Base.TexSrcUnit = (yyvsp[-2].integer);
2406
2407	      if ((yyvsp[0].integer) < 0) {
2408		 shadow_tex = tex_mask;
2409
2410		 (yyval.inst)->Base.TexSrcTarget = -(yyvsp[0].integer);
2411		 (yyval.inst)->Base.TexShadow = 1;
2412	      } else {
2413		 (yyval.inst)->Base.TexSrcTarget = (yyvsp[0].integer);
2414	      }
2415
2416	      target_mask = (1U << (yyval.inst)->Base.TexSrcTarget);
2417
2418	      /* If this texture unit was previously accessed and that access
2419	       * had a different texture target, generate an error.
2420	       *
2421	       * If this texture unit was previously accessed and that access
2422	       * had a different shadow mode, generate an error.
2423	       */
2424	      if ((state->prog->TexturesUsed[(yyvsp[-2].integer)] != 0)
2425		  && ((state->prog->TexturesUsed[(yyvsp[-2].integer)] != target_mask)
2426		      || ((state->prog->ShadowSamplers & tex_mask)
2427			  != shadow_tex))) {
2428		 yyerror(& (yylsp[0]), state,
2429			 "multiple targets used on one texture image unit");
2430		 YYERROR;
2431	      }
2432
2433
2434	      state->prog->TexturesUsed[(yyvsp[-2].integer)] |= target_mask;
2435	      state->prog->ShadowSamplers |= shadow_tex;
2436	   }
2437	}
2438#line 2439 "src/mesa/program/program_parse.tab.c"
2439    break;
2440
2441  case 33: /* texImageUnit: TEXTURE_UNIT optTexImageUnitNum  */
2442#line 528 "../src/mesa/program/program_parse.y"
2443        {
2444	   (yyval.integer) = (yyvsp[0].integer);
2445	}
2446#line 2447 "src/mesa/program/program_parse.tab.c"
2447    break;
2448
2449  case 34: /* texTarget: TEX_1D  */
2450#line 533 "../src/mesa/program/program_parse.y"
2451                   { (yyval.integer) = TEXTURE_1D_INDEX; }
2452#line 2453 "src/mesa/program/program_parse.tab.c"
2453    break;
2454
2455  case 35: /* texTarget: TEX_2D  */
2456#line 534 "../src/mesa/program/program_parse.y"
2457                   { (yyval.integer) = TEXTURE_2D_INDEX; }
2458#line 2459 "src/mesa/program/program_parse.tab.c"
2459    break;
2460
2461  case 36: /* texTarget: TEX_3D  */
2462#line 535 "../src/mesa/program/program_parse.y"
2463                   { (yyval.integer) = TEXTURE_3D_INDEX; }
2464#line 2465 "src/mesa/program/program_parse.tab.c"
2465    break;
2466
2467  case 37: /* texTarget: TEX_CUBE  */
2468#line 536 "../src/mesa/program/program_parse.y"
2469                   { (yyval.integer) = TEXTURE_CUBE_INDEX; }
2470#line 2471 "src/mesa/program/program_parse.tab.c"
2471    break;
2472
2473  case 38: /* texTarget: TEX_RECT  */
2474#line 537 "../src/mesa/program/program_parse.y"
2475                   { (yyval.integer) = TEXTURE_RECT_INDEX; }
2476#line 2477 "src/mesa/program/program_parse.tab.c"
2477    break;
2478
2479  case 39: /* texTarget: TEX_SHADOW1D  */
2480#line 538 "../src/mesa/program/program_parse.y"
2481                         { (yyval.integer) = -TEXTURE_1D_INDEX; }
2482#line 2483 "src/mesa/program/program_parse.tab.c"
2483    break;
2484
2485  case 40: /* texTarget: TEX_SHADOW2D  */
2486#line 539 "../src/mesa/program/program_parse.y"
2487                         { (yyval.integer) = -TEXTURE_2D_INDEX; }
2488#line 2489 "src/mesa/program/program_parse.tab.c"
2489    break;
2490
2491  case 41: /* texTarget: TEX_SHADOWRECT  */
2492#line 540 "../src/mesa/program/program_parse.y"
2493                         { (yyval.integer) = -TEXTURE_RECT_INDEX; }
2494#line 2495 "src/mesa/program/program_parse.tab.c"
2495    break;
2496
2497  case 42: /* texTarget: TEX_ARRAY1D  */
2498#line 541 "../src/mesa/program/program_parse.y"
2499                              { (yyval.integer) = TEXTURE_1D_ARRAY_INDEX; }
2500#line 2501 "src/mesa/program/program_parse.tab.c"
2501    break;
2502
2503  case 43: /* texTarget: TEX_ARRAY2D  */
2504#line 542 "../src/mesa/program/program_parse.y"
2505                              { (yyval.integer) = TEXTURE_2D_ARRAY_INDEX; }
2506#line 2507 "src/mesa/program/program_parse.tab.c"
2507    break;
2508
2509  case 44: /* texTarget: TEX_ARRAYSHADOW1D  */
2510#line 543 "../src/mesa/program/program_parse.y"
2511                              { (yyval.integer) = -TEXTURE_1D_ARRAY_INDEX; }
2512#line 2513 "src/mesa/program/program_parse.tab.c"
2513    break;
2514
2515  case 45: /* texTarget: TEX_ARRAYSHADOW2D  */
2516#line 544 "../src/mesa/program/program_parse.y"
2517                              { (yyval.integer) = -TEXTURE_2D_ARRAY_INDEX; }
2518#line 2519 "src/mesa/program/program_parse.tab.c"
2519    break;
2520
2521  case 46: /* SWZ_instruction: SWZ maskedDstReg ',' srcReg ',' extendedSwizzle  */
2522#line 548 "../src/mesa/program/program_parse.y"
2523        {
2524	   /* FIXME: Is this correct?  Should the extenedSwizzle be applied
2525	    * FIXME: to the existing swizzle?
2526	    */
2527	   (yyvsp[-2].src_reg).Base.Swizzle = (yyvsp[0].swiz_mask).swizzle;
2528	   (yyvsp[-2].src_reg).Base.Negate = (yyvsp[0].swiz_mask).mask;
2529
2530	   (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[-5].temp_inst), & (yyvsp[-4].dst_reg), & (yyvsp[-2].src_reg), NULL, NULL);
2531	}
2532#line 2533 "src/mesa/program/program_parse.tab.c"
2533    break;
2534
2535  case 47: /* scalarSrcReg: optionalSign scalarUse  */
2536#line 560 "../src/mesa/program/program_parse.y"
2537        {
2538	   (yyval.src_reg) = (yyvsp[0].src_reg);
2539
2540	   if ((yyvsp[-1].negate)) {
2541	      (yyval.src_reg).Base.Negate = ~(yyval.src_reg).Base.Negate;
2542	   }
2543	}
2544#line 2545 "src/mesa/program/program_parse.tab.c"
2545    break;
2546
2547  case 48: /* scalarUse: srcReg scalarSuffix  */
2548#line 570 "../src/mesa/program/program_parse.y"
2549        {
2550	   (yyval.src_reg) = (yyvsp[-1].src_reg);
2551
2552	   (yyval.src_reg).Base.Swizzle = _mesa_combine_swizzles((yyval.src_reg).Base.Swizzle,
2553						    (yyvsp[0].swiz_mask).swizzle);
2554	}
2555#line 2556 "src/mesa/program/program_parse.tab.c"
2556    break;
2557
2558  case 49: /* swizzleSrcReg: optionalSign srcReg swizzleSuffix  */
2559#line 579 "../src/mesa/program/program_parse.y"
2560        {
2561	   (yyval.src_reg) = (yyvsp[-1].src_reg);
2562
2563	   if ((yyvsp[-2].negate)) {
2564	      (yyval.src_reg).Base.Negate = ~(yyval.src_reg).Base.Negate;
2565	   }
2566
2567	   (yyval.src_reg).Base.Swizzle = _mesa_combine_swizzles((yyval.src_reg).Base.Swizzle,
2568						    (yyvsp[0].swiz_mask).swizzle);
2569	}
2570#line 2571 "src/mesa/program/program_parse.tab.c"
2571    break;
2572
2573  case 50: /* maskedDstReg: dstReg optionalMask  */
2574#line 592 "../src/mesa/program/program_parse.y"
2575        {
2576	   (yyval.dst_reg) = (yyvsp[-1].dst_reg);
2577	   (yyval.dst_reg).WriteMask = (yyvsp[0].swiz_mask).mask;
2578
2579	   if ((yyval.dst_reg).File == PROGRAM_OUTPUT) {
2580	      /* Technically speaking, this should check that it is in
2581	       * vertex program mode.  However, PositionInvariant can never be
2582	       * set in fragment program mode, so it is somewhat irrelevant.
2583	       */
2584	      if (state->option.PositionInvariant
2585	       && ((yyval.dst_reg).Index == VARYING_SLOT_POS)) {
2586		 yyerror(& (yylsp[-1]), state, "position-invariant programs cannot "
2587			 "write position");
2588		 YYERROR;
2589	      }
2590
2591              state->prog->info.outputs_written |= BITFIELD64_BIT((yyval.dst_reg).Index);
2592	   }
2593	}
2594#line 2595 "src/mesa/program/program_parse.tab.c"
2595    break;
2596
2597  case 51: /* maskedAddrReg: addrReg addrWriteMask  */
2598#line 614 "../src/mesa/program/program_parse.y"
2599        {
2600	   set_dst_reg(& (yyval.dst_reg), PROGRAM_ADDRESS, 0);
2601	   (yyval.dst_reg).WriteMask = (yyvsp[0].swiz_mask).mask;
2602	}
2603#line 2604 "src/mesa/program/program_parse.tab.c"
2604    break;
2605
2606  case 52: /* extendedSwizzle: extSwizComp ',' extSwizComp ',' extSwizComp ',' extSwizComp  */
2607#line 621 "../src/mesa/program/program_parse.y"
2608        {
2609	   const unsigned xyzw_valid =
2610	      ((yyvsp[-6].ext_swizzle).xyzw_valid << 0)
2611	      | ((yyvsp[-4].ext_swizzle).xyzw_valid << 1)
2612	      | ((yyvsp[-2].ext_swizzle).xyzw_valid << 2)
2613	      | ((yyvsp[0].ext_swizzle).xyzw_valid << 3);
2614	   const unsigned rgba_valid =
2615	      ((yyvsp[-6].ext_swizzle).rgba_valid << 0)
2616	      | ((yyvsp[-4].ext_swizzle).rgba_valid << 1)
2617	      | ((yyvsp[-2].ext_swizzle).rgba_valid << 2)
2618	      | ((yyvsp[0].ext_swizzle).rgba_valid << 3);
2619
2620	   /* All of the swizzle components have to be valid in either RGBA
2621	    * or XYZW.  Note that 0 and 1 are valid in both, so both masks
2622	    * can have some bits set.
2623	    *
2624	    * We somewhat deviate from the spec here.  It would be really hard
2625	    * to figure out which component is the error, and there probably
2626	    * isn't a lot of benefit.
2627	    */
2628	   if ((rgba_valid != 0x0f) && (xyzw_valid != 0x0f)) {
2629	      yyerror(& (yylsp[-6]), state, "cannot combine RGBA and XYZW swizzle "
2630		      "components");
2631	      YYERROR;
2632	   }
2633
2634	   (yyval.swiz_mask).swizzle = MAKE_SWIZZLE4((yyvsp[-6].ext_swizzle).swz, (yyvsp[-4].ext_swizzle).swz, (yyvsp[-2].ext_swizzle).swz, (yyvsp[0].ext_swizzle).swz);
2635	   (yyval.swiz_mask).mask = ((yyvsp[-6].ext_swizzle).negate) | ((yyvsp[-4].ext_swizzle).negate << 1) | ((yyvsp[-2].ext_swizzle).negate << 2)
2636	      | ((yyvsp[0].ext_swizzle).negate << 3);
2637	}
2638#line 2639 "src/mesa/program/program_parse.tab.c"
2639    break;
2640
2641  case 53: /* extSwizComp: optionalSign extSwizSel  */
2642#line 654 "../src/mesa/program/program_parse.y"
2643        {
2644	   (yyval.ext_swizzle) = (yyvsp[0].ext_swizzle);
2645	   (yyval.ext_swizzle).negate = ((yyvsp[-1].negate)) ? 1 : 0;
2646	}
2647#line 2648 "src/mesa/program/program_parse.tab.c"
2648    break;
2649
2650  case 54: /* extSwizSel: INTEGER  */
2651#line 661 "../src/mesa/program/program_parse.y"
2652        {
2653	   if (((yyvsp[0].integer) != 0) && ((yyvsp[0].integer) != 1)) {
2654	      yyerror(& (yylsp[0]), state, "invalid extended swizzle selector");
2655	      YYERROR;
2656	   }
2657
2658	   (yyval.ext_swizzle).swz = ((yyvsp[0].integer) == 0) ? SWIZZLE_ZERO : SWIZZLE_ONE;
2659           (yyval.ext_swizzle).negate = 0;
2660
2661	   /* 0 and 1 are valid for both RGBA swizzle names and XYZW
2662	    * swizzle names.
2663	    */
2664	   (yyval.ext_swizzle).xyzw_valid = 1;
2665	   (yyval.ext_swizzle).rgba_valid = 1;
2666	}
2667#line 2668 "src/mesa/program/program_parse.tab.c"
2668    break;
2669
2670  case 55: /* extSwizSel: string  */
2671#line 677 "../src/mesa/program/program_parse.y"
2672        {
2673	   char s;
2674
2675	   if (strlen((yyvsp[0].string)) > 1) {
2676	      yyerror(& (yylsp[0]), state, "invalid extended swizzle selector");
2677	      YYERROR;
2678	   }
2679
2680	   s = (yyvsp[0].string)[0];
2681	   free((yyvsp[0].string));
2682
2683           (yyval.ext_swizzle).rgba_valid = 0;
2684           (yyval.ext_swizzle).xyzw_valid = 0;
2685           (yyval.ext_swizzle).negate = 0;
2686
2687	   switch (s) {
2688	   case 'x':
2689	      (yyval.ext_swizzle).swz = SWIZZLE_X;
2690	      (yyval.ext_swizzle).xyzw_valid = 1;
2691	      break;
2692	   case 'y':
2693	      (yyval.ext_swizzle).swz = SWIZZLE_Y;
2694	      (yyval.ext_swizzle).xyzw_valid = 1;
2695	      break;
2696	   case 'z':
2697	      (yyval.ext_swizzle).swz = SWIZZLE_Z;
2698	      (yyval.ext_swizzle).xyzw_valid = 1;
2699	      break;
2700	   case 'w':
2701	      (yyval.ext_swizzle).swz = SWIZZLE_W;
2702	      (yyval.ext_swizzle).xyzw_valid = 1;
2703	      break;
2704
2705	   case 'r':
2706	      (yyval.ext_swizzle).swz = SWIZZLE_X;
2707	      (yyval.ext_swizzle).rgba_valid = 1;
2708	      break;
2709	   case 'g':
2710	      (yyval.ext_swizzle).swz = SWIZZLE_Y;
2711	      (yyval.ext_swizzle).rgba_valid = 1;
2712	      break;
2713	   case 'b':
2714	      (yyval.ext_swizzle).swz = SWIZZLE_Z;
2715	      (yyval.ext_swizzle).rgba_valid = 1;
2716	      break;
2717	   case 'a':
2718	      (yyval.ext_swizzle).swz = SWIZZLE_W;
2719	      (yyval.ext_swizzle).rgba_valid = 1;
2720	      break;
2721
2722	   default:
2723	      yyerror(& (yylsp[0]), state, "invalid extended swizzle selector");
2724	      YYERROR;
2725	      break;
2726	   }
2727	}
2728#line 2729 "src/mesa/program/program_parse.tab.c"
2729    break;
2730
2731  case 56: /* srcReg: USED_IDENTIFIER  */
2732#line 736 "../src/mesa/program/program_parse.y"
2733        {
2734	   struct asm_symbol *const s = (struct asm_symbol *)
2735              _mesa_symbol_table_find_symbol(state->st, (yyvsp[0].string));
2736
2737	   free((yyvsp[0].string));
2738
2739	   if (s == NULL) {
2740	      yyerror(& (yylsp[0]), state, "invalid operand variable");
2741	      YYERROR;
2742	   } else if ((s->type != at_param) && (s->type != at_temp)
2743		      && (s->type != at_attrib)) {
2744	      yyerror(& (yylsp[0]), state, "invalid operand variable");
2745	      YYERROR;
2746	   } else if ((s->type == at_param) && s->param_is_array) {
2747	      yyerror(& (yylsp[0]), state, "non-array access to array PARAM");
2748	      YYERROR;
2749	   }
2750
2751	   init_src_reg(& (yyval.src_reg));
2752	   switch (s->type) {
2753	   case at_temp:
2754	      set_src_reg(& (yyval.src_reg), PROGRAM_TEMPORARY, s->temp_binding);
2755	      break;
2756	   case at_param:
2757              set_src_reg_swz(& (yyval.src_reg), s->param_binding_type,
2758                              s->param_binding_begin,
2759                              s->param_binding_swizzle);
2760	      break;
2761	   case at_attrib:
2762	      set_src_reg(& (yyval.src_reg), PROGRAM_INPUT, s->attrib_binding);
2763              state->prog->info.inputs_read |= BITFIELD64_BIT((yyval.src_reg).Base.Index);
2764
2765	      if (!validate_inputs(& (yylsp[0]), state)) {
2766		 YYERROR;
2767	      }
2768	      break;
2769
2770	   default:
2771	      YYERROR;
2772	      break;
2773	   }
2774	}
2775#line 2776 "src/mesa/program/program_parse.tab.c"
2776    break;
2777
2778  case 57: /* srcReg: attribBinding  */
2779#line 779 "../src/mesa/program/program_parse.y"
2780        {
2781	   set_src_reg(& (yyval.src_reg), PROGRAM_INPUT, (yyvsp[0].attrib));
2782           state->prog->info.inputs_read |= BITFIELD64_BIT((yyval.src_reg).Base.Index);
2783
2784	   if (!validate_inputs(& (yylsp[0]), state)) {
2785	      YYERROR;
2786	   }
2787	}
2788#line 2789 "src/mesa/program/program_parse.tab.c"
2789    break;
2790
2791  case 58: /* srcReg: progParamArray '[' progParamArrayMem ']'  */
2792#line 788 "../src/mesa/program/program_parse.y"
2793        {
2794	   if (! (yyvsp[-1].src_reg).Base.RelAddr
2795	       && ((unsigned) (yyvsp[-1].src_reg).Base.Index >= (yyvsp[-3].sym)->param_binding_length)) {
2796	      yyerror(& (yylsp[-1]), state, "out of bounds array access");
2797	      YYERROR;
2798	   }
2799
2800	   init_src_reg(& (yyval.src_reg));
2801	   (yyval.src_reg).Base.File = (yyvsp[-3].sym)->param_binding_type;
2802
2803	   if ((yyvsp[-1].src_reg).Base.RelAddr) {
2804              state->prog->arb.IndirectRegisterFiles |= (1 << (yyval.src_reg).Base.File);
2805	      (yyvsp[-3].sym)->param_accessed_indirectly = 1;
2806
2807	      (yyval.src_reg).Base.RelAddr = 1;
2808	      (yyval.src_reg).Base.Index = (yyvsp[-1].src_reg).Base.Index;
2809	      (yyval.src_reg).Symbol = (yyvsp[-3].sym);
2810	   } else {
2811	      (yyval.src_reg).Base.Index = (yyvsp[-3].sym)->param_binding_begin + (yyvsp[-1].src_reg).Base.Index;
2812	   }
2813	}
2814#line 2815 "src/mesa/program/program_parse.tab.c"
2815    break;
2816
2817  case 59: /* srcReg: paramSingleItemUse  */
2818#line 810 "../src/mesa/program/program_parse.y"
2819        {
2820           gl_register_file file = ((yyvsp[0].temp_sym).name != NULL)
2821	      ? (yyvsp[0].temp_sym).param_binding_type
2822	      : PROGRAM_CONSTANT;
2823           set_src_reg_swz(& (yyval.src_reg), file, (yyvsp[0].temp_sym).param_binding_begin,
2824                           (yyvsp[0].temp_sym).param_binding_swizzle);
2825	}
2826#line 2827 "src/mesa/program/program_parse.tab.c"
2827    break;
2828
2829  case 60: /* dstReg: resultBinding  */
2830#line 820 "../src/mesa/program/program_parse.y"
2831        {
2832	   set_dst_reg(& (yyval.dst_reg), PROGRAM_OUTPUT, (yyvsp[0].result));
2833	}
2834#line 2835 "src/mesa/program/program_parse.tab.c"
2835    break;
2836
2837  case 61: /* dstReg: USED_IDENTIFIER  */
2838#line 824 "../src/mesa/program/program_parse.y"
2839        {
2840	   struct asm_symbol *const s = (struct asm_symbol *)
2841              _mesa_symbol_table_find_symbol(state->st, (yyvsp[0].string));
2842
2843	   free((yyvsp[0].string));
2844
2845	   if (s == NULL) {
2846	      yyerror(& (yylsp[0]), state, "invalid operand variable");
2847	      YYERROR;
2848	   } else if ((s->type != at_output) && (s->type != at_temp)) {
2849	      yyerror(& (yylsp[0]), state, "invalid operand variable");
2850	      YYERROR;
2851	   }
2852
2853	   switch (s->type) {
2854	   case at_temp:
2855	      set_dst_reg(& (yyval.dst_reg), PROGRAM_TEMPORARY, s->temp_binding);
2856	      break;
2857	   case at_output:
2858	      set_dst_reg(& (yyval.dst_reg), PROGRAM_OUTPUT, s->output_binding);
2859	      break;
2860	   default:
2861	      set_dst_reg(& (yyval.dst_reg), s->param_binding_type, s->param_binding_begin);
2862	      break;
2863	   }
2864	}
2865#line 2866 "src/mesa/program/program_parse.tab.c"
2866    break;
2867
2868  case 62: /* progParamArray: USED_IDENTIFIER  */
2869#line 853 "../src/mesa/program/program_parse.y"
2870        {
2871	   struct asm_symbol *const s = (struct asm_symbol *)
2872              _mesa_symbol_table_find_symbol(state->st, (yyvsp[0].string));
2873
2874	   free((yyvsp[0].string));
2875
2876	   if (s == NULL) {
2877	      yyerror(& (yylsp[0]), state, "invalid operand variable");
2878	      YYERROR;
2879	   } else if ((s->type != at_param) || !s->param_is_array) {
2880	      yyerror(& (yylsp[0]), state, "array access to non-PARAM variable");
2881	      YYERROR;
2882	   } else {
2883	      (yyval.sym) = s;
2884	   }
2885	}
2886#line 2887 "src/mesa/program/program_parse.tab.c"
2887    break;
2888
2889  case 65: /* progParamArrayAbs: INTEGER  */
2890#line 874 "../src/mesa/program/program_parse.y"
2891        {
2892	   init_src_reg(& (yyval.src_reg));
2893	   (yyval.src_reg).Base.Index = (yyvsp[0].integer);
2894	}
2895#line 2896 "src/mesa/program/program_parse.tab.c"
2896    break;
2897
2898  case 66: /* progParamArrayRel: addrReg addrComponent addrRegRelOffset  */
2899#line 881 "../src/mesa/program/program_parse.y"
2900        {
2901	   /* FINISHME: Add support for multiple address registers.
2902	    */
2903	   /* FINISHME: Add support for 4-component address registers.
2904	    */
2905	   init_src_reg(& (yyval.src_reg));
2906	   (yyval.src_reg).Base.RelAddr = 1;
2907	   (yyval.src_reg).Base.Index = (yyvsp[0].integer);
2908	}
2909#line 2910 "src/mesa/program/program_parse.tab.c"
2910    break;
2911
2912  case 67: /* addrRegRelOffset: %empty  */
2913#line 892 "../src/mesa/program/program_parse.y"
2914                               { (yyval.integer) = 0; }
2915#line 2916 "src/mesa/program/program_parse.tab.c"
2916    break;
2917
2918  case 68: /* addrRegRelOffset: '+' addrRegPosOffset  */
2919#line 893 "../src/mesa/program/program_parse.y"
2920                               { (yyval.integer) = (yyvsp[0].integer); }
2921#line 2922 "src/mesa/program/program_parse.tab.c"
2922    break;
2923
2924  case 69: /* addrRegRelOffset: '-' addrRegNegOffset  */
2925#line 894 "../src/mesa/program/program_parse.y"
2926                               { (yyval.integer) = -(yyvsp[0].integer); }
2927#line 2928 "src/mesa/program/program_parse.tab.c"
2928    break;
2929
2930  case 70: /* addrRegPosOffset: INTEGER  */
2931#line 898 "../src/mesa/program/program_parse.y"
2932        {
2933	   if (((yyvsp[0].integer) < 0) || ((yyvsp[0].integer) > (state->limits->MaxAddressOffset - 1))) {
2934              char s[100];
2935              snprintf(s, sizeof(s),
2936                             "relative address offset too large (%d)", (yyvsp[0].integer));
2937	      yyerror(& (yylsp[0]), state, s);
2938	      YYERROR;
2939	   } else {
2940	      (yyval.integer) = (yyvsp[0].integer);
2941	   }
2942	}
2943#line 2944 "src/mesa/program/program_parse.tab.c"
2944    break;
2945
2946  case 71: /* addrRegNegOffset: INTEGER  */
2947#line 912 "../src/mesa/program/program_parse.y"
2948        {
2949	   if (((yyvsp[0].integer) < 0) || ((yyvsp[0].integer) > state->limits->MaxAddressOffset)) {
2950              char s[100];
2951              snprintf(s, sizeof(s),
2952                             "relative address offset too large (%d)", (yyvsp[0].integer));
2953	      yyerror(& (yylsp[0]), state, s);
2954	      YYERROR;
2955	   } else {
2956	      (yyval.integer) = (yyvsp[0].integer);
2957	   }
2958	}
2959#line 2960 "src/mesa/program/program_parse.tab.c"
2960    break;
2961
2962  case 72: /* addrReg: USED_IDENTIFIER  */
2963#line 926 "../src/mesa/program/program_parse.y"
2964        {
2965	   struct asm_symbol *const s = (struct asm_symbol *)
2966              _mesa_symbol_table_find_symbol(state->st, (yyvsp[0].string));
2967
2968	   free((yyvsp[0].string));
2969
2970	   if (s == NULL) {
2971	      yyerror(& (yylsp[0]), state, "invalid array member");
2972	      YYERROR;
2973	   } else if (s->type != at_address) {
2974	      yyerror(& (yylsp[0]), state,
2975		      "invalid variable for indexed array access");
2976	      YYERROR;
2977	   } else {
2978	      (yyval.sym) = s;
2979	   }
2980	}
2981#line 2982 "src/mesa/program/program_parse.tab.c"
2982    break;
2983
2984  case 73: /* addrComponent: MASK1  */
2985#line 946 "../src/mesa/program/program_parse.y"
2986        {
2987	   if ((yyvsp[0].swiz_mask).mask != WRITEMASK_X) {
2988	      yyerror(& (yylsp[0]), state, "invalid address component selector");
2989	      YYERROR;
2990	   } else {
2991	      (yyval.swiz_mask) = (yyvsp[0].swiz_mask);
2992	   }
2993	}
2994#line 2995 "src/mesa/program/program_parse.tab.c"
2995    break;
2996
2997  case 74: /* addrWriteMask: MASK1  */
2998#line 957 "../src/mesa/program/program_parse.y"
2999        {
3000	   if ((yyvsp[0].swiz_mask).mask != WRITEMASK_X) {
3001	      yyerror(& (yylsp[0]), state,
3002		      "address register write mask must be \".x\"");
3003	      YYERROR;
3004	   } else {
3005	      (yyval.swiz_mask) = (yyvsp[0].swiz_mask);
3006	   }
3007	}
3008#line 3009 "src/mesa/program/program_parse.tab.c"
3009    break;
3010
3011  case 79: /* swizzleSuffix: %empty  */
3012#line 973 "../src/mesa/program/program_parse.y"
3013                       { (yyval.swiz_mask).swizzle = SWIZZLE_NOOP; (yyval.swiz_mask).mask = WRITEMASK_XYZW; }
3014#line 3015 "src/mesa/program/program_parse.tab.c"
3015    break;
3016
3017  case 84: /* optionalMask: %empty  */
3018#line 977 "../src/mesa/program/program_parse.y"
3019                       { (yyval.swiz_mask).swizzle = SWIZZLE_NOOP; (yyval.swiz_mask).mask = WRITEMASK_XYZW; }
3020#line 3021 "src/mesa/program/program_parse.tab.c"
3021    break;
3022
3023  case 91: /* ATTRIB_statement: ATTRIB IDENTIFIER '=' attribBinding  */
3024#line 989 "../src/mesa/program/program_parse.y"
3025        {
3026	   struct asm_symbol *const s =
3027	      declare_variable(state, (yyvsp[-2].string), at_attrib, & (yylsp[-2]));
3028
3029	   if (s == NULL) {
3030	      free((yyvsp[-2].string));
3031	      YYERROR;
3032	   } else {
3033	      s->attrib_binding = (yyvsp[0].attrib);
3034	      state->InputsBound |= BITFIELD64_BIT(s->attrib_binding);
3035
3036	      if (!validate_inputs(& (yylsp[0]), state)) {
3037		 YYERROR;
3038	      }
3039	   }
3040	}
3041#line 3042 "src/mesa/program/program_parse.tab.c"
3042    break;
3043
3044  case 92: /* attribBinding: VERTEX vtxAttribItem  */
3045#line 1008 "../src/mesa/program/program_parse.y"
3046        {
3047	   (yyval.attrib) = (yyvsp[0].attrib);
3048	}
3049#line 3050 "src/mesa/program/program_parse.tab.c"
3050    break;
3051
3052  case 93: /* attribBinding: FRAGMENT fragAttribItem  */
3053#line 1012 "../src/mesa/program/program_parse.y"
3054        {
3055	   (yyval.attrib) = (yyvsp[0].attrib);
3056	}
3057#line 3058 "src/mesa/program/program_parse.tab.c"
3058    break;
3059
3060  case 94: /* vtxAttribItem: POSITION  */
3061#line 1018 "../src/mesa/program/program_parse.y"
3062        {
3063	   (yyval.attrib) = VERT_ATTRIB_POS;
3064	}
3065#line 3066 "src/mesa/program/program_parse.tab.c"
3066    break;
3067
3068  case 95: /* vtxAttribItem: NORMAL  */
3069#line 1022 "../src/mesa/program/program_parse.y"
3070        {
3071	   (yyval.attrib) = VERT_ATTRIB_NORMAL;
3072	}
3073#line 3074 "src/mesa/program/program_parse.tab.c"
3074    break;
3075
3076  case 96: /* vtxAttribItem: COLOR optColorType  */
3077#line 1026 "../src/mesa/program/program_parse.y"
3078        {
3079	   (yyval.attrib) = VERT_ATTRIB_COLOR0 + (yyvsp[0].integer);
3080	}
3081#line 3082 "src/mesa/program/program_parse.tab.c"
3082    break;
3083
3084  case 97: /* vtxAttribItem: FOGCOORD  */
3085#line 1030 "../src/mesa/program/program_parse.y"
3086        {
3087	   (yyval.attrib) = VERT_ATTRIB_FOG;
3088	}
3089#line 3090 "src/mesa/program/program_parse.tab.c"
3090    break;
3091
3092  case 98: /* vtxAttribItem: TEXCOORD optTexCoordUnitNum  */
3093#line 1034 "../src/mesa/program/program_parse.y"
3094        {
3095	   (yyval.attrib) = VERT_ATTRIB_TEX0 + (yyvsp[0].integer);
3096	}
3097#line 3098 "src/mesa/program/program_parse.tab.c"
3098    break;
3099
3100  case 99: /* vtxAttribItem: MATRIXINDEX '[' vtxWeightNum ']'  */
3101#line 1038 "../src/mesa/program/program_parse.y"
3102        {
3103	   yyerror(& (yylsp[-3]), state, "GL_ARB_matrix_palette not supported");
3104	   YYERROR;
3105	}
3106#line 3107 "src/mesa/program/program_parse.tab.c"
3107    break;
3108
3109  case 100: /* vtxAttribItem: VTXATTRIB '[' vtxAttribNum ']'  */
3110#line 1043 "../src/mesa/program/program_parse.y"
3111        {
3112	   (yyval.attrib) = VERT_ATTRIB_GENERIC0 + (yyvsp[-1].integer);
3113	}
3114#line 3115 "src/mesa/program/program_parse.tab.c"
3115    break;
3116
3117  case 101: /* vtxAttribNum: INTEGER  */
3118#line 1049 "../src/mesa/program/program_parse.y"
3119        {
3120	   if ((unsigned) (yyvsp[0].integer) >= state->limits->MaxAttribs) {
3121	      yyerror(& (yylsp[0]), state, "invalid vertex attribute reference");
3122	      YYERROR;
3123	   }
3124
3125	   (yyval.integer) = (yyvsp[0].integer);
3126	}
3127#line 3128 "src/mesa/program/program_parse.tab.c"
3128    break;
3129
3130  case 103: /* fragAttribItem: POSITION  */
3131#line 1062 "../src/mesa/program/program_parse.y"
3132        {
3133	   (yyval.attrib) = VARYING_SLOT_POS;
3134	}
3135#line 3136 "src/mesa/program/program_parse.tab.c"
3136    break;
3137
3138  case 104: /* fragAttribItem: COLOR optColorType  */
3139#line 1066 "../src/mesa/program/program_parse.y"
3140        {
3141	   (yyval.attrib) = VARYING_SLOT_COL0 + (yyvsp[0].integer);
3142	}
3143#line 3144 "src/mesa/program/program_parse.tab.c"
3144    break;
3145
3146  case 105: /* fragAttribItem: FOGCOORD  */
3147#line 1070 "../src/mesa/program/program_parse.y"
3148        {
3149	   (yyval.attrib) = VARYING_SLOT_FOGC;
3150	}
3151#line 3152 "src/mesa/program/program_parse.tab.c"
3152    break;
3153
3154  case 106: /* fragAttribItem: TEXCOORD optTexCoordUnitNum  */
3155#line 1074 "../src/mesa/program/program_parse.y"
3156        {
3157	   (yyval.attrib) = VARYING_SLOT_TEX0 + (yyvsp[0].integer);
3158	}
3159#line 3160 "src/mesa/program/program_parse.tab.c"
3160    break;
3161
3162  case 109: /* PARAM_singleStmt: PARAM IDENTIFIER paramSingleInit  */
3163#line 1082 "../src/mesa/program/program_parse.y"
3164        {
3165	   struct asm_symbol *const s =
3166	      declare_variable(state, (yyvsp[-1].string), at_param, & (yylsp[-1]));
3167
3168	   if (s == NULL) {
3169	      free((yyvsp[-1].string));
3170	      YYERROR;
3171	   } else {
3172	      s->param_binding_type = (yyvsp[0].temp_sym).param_binding_type;
3173	      s->param_binding_begin = (yyvsp[0].temp_sym).param_binding_begin;
3174	      s->param_binding_length = (yyvsp[0].temp_sym).param_binding_length;
3175              s->param_binding_swizzle = (yyvsp[0].temp_sym).param_binding_swizzle;
3176	      s->param_is_array = 0;
3177	   }
3178	}
3179#line 3180 "src/mesa/program/program_parse.tab.c"
3180    break;
3181
3182  case 110: /* PARAM_multipleStmt: PARAM IDENTIFIER '[' optArraySize ']' paramMultipleInit  */
3183#line 1100 "../src/mesa/program/program_parse.y"
3184        {
3185	   if (((yyvsp[-2].integer) != 0) && ((unsigned) (yyvsp[-2].integer) != (yyvsp[0].temp_sym).param_binding_length)) {
3186	      free((yyvsp[-4].string));
3187	      yyerror(& (yylsp[-2]), state,
3188		      "parameter array size and number of bindings must match");
3189	      YYERROR;
3190	   } else {
3191	      struct asm_symbol *const s =
3192		 declare_variable(state, (yyvsp[-4].string), (yyvsp[0].temp_sym).type, & (yylsp[-4]));
3193
3194	      if (s == NULL) {
3195		 free((yyvsp[-4].string));
3196		 YYERROR;
3197	      } else {
3198		 s->param_binding_type = (yyvsp[0].temp_sym).param_binding_type;
3199		 s->param_binding_begin = (yyvsp[0].temp_sym).param_binding_begin;
3200		 s->param_binding_length = (yyvsp[0].temp_sym).param_binding_length;
3201                 s->param_binding_swizzle = SWIZZLE_XYZW;
3202		 s->param_is_array = 1;
3203	      }
3204	   }
3205	}
3206#line 3207 "src/mesa/program/program_parse.tab.c"
3207    break;
3208
3209  case 111: /* optArraySize: %empty  */
3210#line 1125 "../src/mesa/program/program_parse.y"
3211        {
3212	   (yyval.integer) = 0;
3213	}
3214#line 3215 "src/mesa/program/program_parse.tab.c"
3215    break;
3216
3217  case 112: /* optArraySize: INTEGER  */
3218#line 1129 "../src/mesa/program/program_parse.y"
3219        {
3220	   if (((yyvsp[0].integer) < 1) || ((unsigned) (yyvsp[0].integer) > state->limits->MaxParameters)) {
3221              char msg[100];
3222              snprintf(msg, sizeof(msg),
3223                             "invalid parameter array size (size=%d max=%u)",
3224                             (yyvsp[0].integer), state->limits->MaxParameters);
3225	      yyerror(& (yylsp[0]), state, msg);
3226	      YYERROR;
3227	   } else {
3228	      (yyval.integer) = (yyvsp[0].integer);
3229	   }
3230	}
3231#line 3232 "src/mesa/program/program_parse.tab.c"
3232    break;
3233
3234  case 113: /* paramSingleInit: '=' paramSingleItemDecl  */
3235#line 1144 "../src/mesa/program/program_parse.y"
3236        {
3237	   (yyval.temp_sym) = (yyvsp[0].temp_sym);
3238	}
3239#line 3240 "src/mesa/program/program_parse.tab.c"
3240    break;
3241
3242  case 114: /* paramMultipleInit: '=' '{' paramMultInitList '}'  */
3243#line 1150 "../src/mesa/program/program_parse.y"
3244        {
3245	   (yyval.temp_sym) = (yyvsp[-1].temp_sym);
3246	}
3247#line 3248 "src/mesa/program/program_parse.tab.c"
3248    break;
3249
3250  case 116: /* paramMultInitList: paramMultInitList ',' paramMultipleItem  */
3251#line 1157 "../src/mesa/program/program_parse.y"
3252        {
3253	   (yyvsp[-2].temp_sym).param_binding_length += (yyvsp[0].temp_sym).param_binding_length;
3254	   (yyval.temp_sym) = (yyvsp[-2].temp_sym);
3255	}
3256#line 3257 "src/mesa/program/program_parse.tab.c"
3257    break;
3258
3259  case 117: /* paramSingleItemDecl: stateSingleItem  */
3260#line 1164 "../src/mesa/program/program_parse.y"
3261        {
3262	   memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
3263	   (yyval.temp_sym).param_binding_begin = ~0;
3264	   initialize_symbol_from_state(state->prog, & (yyval.temp_sym), (yyvsp[0].state));
3265	}
3266#line 3267 "src/mesa/program/program_parse.tab.c"
3267    break;
3268
3269  case 118: /* paramSingleItemDecl: programSingleItem  */
3270#line 1170 "../src/mesa/program/program_parse.y"
3271        {
3272	   memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
3273	   (yyval.temp_sym).param_binding_begin = ~0;
3274	   initialize_symbol_from_param(state->prog, & (yyval.temp_sym), (yyvsp[0].state));
3275	}
3276#line 3277 "src/mesa/program/program_parse.tab.c"
3277    break;
3278
3279  case 119: /* paramSingleItemDecl: paramConstDecl  */
3280#line 1176 "../src/mesa/program/program_parse.y"
3281        {
3282	   memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
3283	   (yyval.temp_sym).param_binding_begin = ~0;
3284	   initialize_symbol_from_const(state->prog, & (yyval.temp_sym), & (yyvsp[0].vector), GL_TRUE);
3285	}
3286#line 3287 "src/mesa/program/program_parse.tab.c"
3287    break;
3288
3289  case 120: /* paramSingleItemUse: stateSingleItem  */
3290#line 1184 "../src/mesa/program/program_parse.y"
3291        {
3292	   memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
3293	   (yyval.temp_sym).param_binding_begin = ~0;
3294	   initialize_symbol_from_state(state->prog, & (yyval.temp_sym), (yyvsp[0].state));
3295	}
3296#line 3297 "src/mesa/program/program_parse.tab.c"
3297    break;
3298
3299  case 121: /* paramSingleItemUse: programSingleItem  */
3300#line 1190 "../src/mesa/program/program_parse.y"
3301        {
3302	   memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
3303	   (yyval.temp_sym).param_binding_begin = ~0;
3304	   initialize_symbol_from_param(state->prog, & (yyval.temp_sym), (yyvsp[0].state));
3305	}
3306#line 3307 "src/mesa/program/program_parse.tab.c"
3307    break;
3308
3309  case 122: /* paramSingleItemUse: paramConstUse  */
3310#line 1196 "../src/mesa/program/program_parse.y"
3311        {
3312	   memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
3313	   (yyval.temp_sym).param_binding_begin = ~0;
3314	   initialize_symbol_from_const(state->prog, & (yyval.temp_sym), & (yyvsp[0].vector), GL_TRUE);
3315	}
3316#line 3317 "src/mesa/program/program_parse.tab.c"
3317    break;
3318
3319  case 123: /* paramMultipleItem: stateMultipleItem  */
3320#line 1204 "../src/mesa/program/program_parse.y"
3321        {
3322	   memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
3323	   (yyval.temp_sym).param_binding_begin = ~0;
3324	   initialize_symbol_from_state(state->prog, & (yyval.temp_sym), (yyvsp[0].state));
3325	}
3326#line 3327 "src/mesa/program/program_parse.tab.c"
3327    break;
3328
3329  case 124: /* paramMultipleItem: programMultipleItem  */
3330#line 1210 "../src/mesa/program/program_parse.y"
3331        {
3332	   memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
3333	   (yyval.temp_sym).param_binding_begin = ~0;
3334	   initialize_symbol_from_param(state->prog, & (yyval.temp_sym), (yyvsp[0].state));
3335	}
3336#line 3337 "src/mesa/program/program_parse.tab.c"
3337    break;
3338
3339  case 125: /* paramMultipleItem: paramConstDecl  */
3340#line 1216 "../src/mesa/program/program_parse.y"
3341        {
3342	   memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
3343	   (yyval.temp_sym).param_binding_begin = ~0;
3344	   initialize_symbol_from_const(state->prog, & (yyval.temp_sym), & (yyvsp[0].vector), GL_FALSE);
3345	}
3346#line 3347 "src/mesa/program/program_parse.tab.c"
3347    break;
3348
3349  case 126: /* stateMultipleItem: stateSingleItem  */
3350#line 1223 "../src/mesa/program/program_parse.y"
3351                                          { memcpy((yyval.state), (yyvsp[0].state), sizeof((yyval.state))); }
3352#line 3353 "src/mesa/program/program_parse.tab.c"
3353    break;
3354
3355  case 127: /* stateMultipleItem: STATE stateMatrixRows  */
3356#line 1224 "../src/mesa/program/program_parse.y"
3357                                          { memcpy((yyval.state), (yyvsp[0].state), sizeof((yyval.state))); }
3358#line 3359 "src/mesa/program/program_parse.tab.c"
3359    break;
3360
3361  case 128: /* stateSingleItem: STATE stateMaterialItem  */
3362#line 1227 "../src/mesa/program/program_parse.y"
3363                                          { memcpy((yyval.state), (yyvsp[0].state), sizeof((yyval.state))); }
3364#line 3365 "src/mesa/program/program_parse.tab.c"
3365    break;
3366
3367  case 129: /* stateSingleItem: STATE stateLightItem  */
3368#line 1228 "../src/mesa/program/program_parse.y"
3369                                          { memcpy((yyval.state), (yyvsp[0].state), sizeof((yyval.state))); }
3370#line 3371 "src/mesa/program/program_parse.tab.c"
3371    break;
3372
3373  case 130: /* stateSingleItem: STATE stateLightModelItem  */
3374#line 1229 "../src/mesa/program/program_parse.y"
3375                                          { memcpy((yyval.state), (yyvsp[0].state), sizeof((yyval.state))); }
3376#line 3377 "src/mesa/program/program_parse.tab.c"
3377    break;
3378
3379  case 131: /* stateSingleItem: STATE stateLightProdItem  */
3380#line 1230 "../src/mesa/program/program_parse.y"
3381                                          { memcpy((yyval.state), (yyvsp[0].state), sizeof((yyval.state))); }
3382#line 3383 "src/mesa/program/program_parse.tab.c"
3383    break;
3384
3385  case 132: /* stateSingleItem: STATE stateTexGenItem  */
3386#line 1231 "../src/mesa/program/program_parse.y"
3387                                          { memcpy((yyval.state), (yyvsp[0].state), sizeof((yyval.state))); }
3388#line 3389 "src/mesa/program/program_parse.tab.c"
3389    break;
3390
3391  case 133: /* stateSingleItem: STATE stateTexEnvItem  */
3392#line 1232 "../src/mesa/program/program_parse.y"
3393                                          { memcpy((yyval.state), (yyvsp[0].state), sizeof((yyval.state))); }
3394#line 3395 "src/mesa/program/program_parse.tab.c"
3395    break;
3396
3397  case 134: /* stateSingleItem: STATE stateFogItem  */
3398#line 1233 "../src/mesa/program/program_parse.y"
3399                                          { memcpy((yyval.state), (yyvsp[0].state), sizeof((yyval.state))); }
3400#line 3401 "src/mesa/program/program_parse.tab.c"
3401    break;
3402
3403  case 135: /* stateSingleItem: STATE stateClipPlaneItem  */
3404#line 1234 "../src/mesa/program/program_parse.y"
3405                                          { memcpy((yyval.state), (yyvsp[0].state), sizeof((yyval.state))); }
3406#line 3407 "src/mesa/program/program_parse.tab.c"
3407    break;
3408
3409  case 136: /* stateSingleItem: STATE statePointItem  */
3410#line 1235 "../src/mesa/program/program_parse.y"
3411                                          { memcpy((yyval.state), (yyvsp[0].state), sizeof((yyval.state))); }
3412#line 3413 "src/mesa/program/program_parse.tab.c"
3413    break;
3414
3415  case 137: /* stateSingleItem: STATE stateMatrixRow  */
3416#line 1236 "../src/mesa/program/program_parse.y"
3417                                          { memcpy((yyval.state), (yyvsp[0].state), sizeof((yyval.state))); }
3418#line 3419 "src/mesa/program/program_parse.tab.c"
3419    break;
3420
3421  case 138: /* stateSingleItem: STATE stateDepthItem  */
3422#line 1237 "../src/mesa/program/program_parse.y"
3423                                          { memcpy((yyval.state), (yyvsp[0].state), sizeof((yyval.state))); }
3424#line 3425 "src/mesa/program/program_parse.tab.c"
3425    break;
3426
3427  case 139: /* stateMaterialItem: MATERIAL optFaceType stateMatProperty  */
3428#line 1241 "../src/mesa/program/program_parse.y"
3429        {
3430	   memset((yyval.state), 0, sizeof((yyval.state)));
3431	   (yyval.state)[0] = STATE_MATERIAL;
3432	   (yyval.state)[1] = (yyvsp[0].integer) + (yyvsp[-1].integer);
3433	   (yyval.state)[2] = 0;
3434	}
3435#line 3436 "src/mesa/program/program_parse.tab.c"
3436    break;
3437
3438  case 140: /* stateMatProperty: ambDiffSpecPropertyMaterial  */
3439#line 1250 "../src/mesa/program/program_parse.y"
3440        {
3441	   (yyval.integer) = (yyvsp[0].integer);
3442	}
3443#line 3444 "src/mesa/program/program_parse.tab.c"
3444    break;
3445
3446  case 141: /* stateMatProperty: EMISSION  */
3447#line 1254 "../src/mesa/program/program_parse.y"
3448        {
3449	   (yyval.integer) = MAT_ATTRIB_FRONT_EMISSION;
3450	}
3451#line 3452 "src/mesa/program/program_parse.tab.c"
3452    break;
3453
3454  case 142: /* stateMatProperty: SHININESS  */
3455#line 1258 "../src/mesa/program/program_parse.y"
3456        {
3457	   (yyval.integer) = MAT_ATTRIB_FRONT_SHININESS;
3458	}
3459#line 3460 "src/mesa/program/program_parse.tab.c"
3460    break;
3461
3462  case 143: /* stateLightItem: LIGHT '[' stateLightNumber ']' stateLightProperty  */
3463#line 1264 "../src/mesa/program/program_parse.y"
3464        {
3465	   memset((yyval.state), 0, sizeof((yyval.state)));
3466	   (yyval.state)[0] = STATE_LIGHT;
3467	   (yyval.state)[1] = (yyvsp[-2].integer);
3468	   (yyval.state)[2] = (yyvsp[0].integer);
3469	}
3470#line 3471 "src/mesa/program/program_parse.tab.c"
3471    break;
3472
3473  case 144: /* stateLightProperty: ambDiffSpecPropertyLight  */
3474#line 1273 "../src/mesa/program/program_parse.y"
3475        {
3476	   (yyval.integer) = (yyvsp[0].integer);
3477	}
3478#line 3479 "src/mesa/program/program_parse.tab.c"
3479    break;
3480
3481  case 145: /* stateLightProperty: POSITION  */
3482#line 1277 "../src/mesa/program/program_parse.y"
3483        {
3484	   (yyval.integer) = STATE_POSITION;
3485	}
3486#line 3487 "src/mesa/program/program_parse.tab.c"
3487    break;
3488
3489  case 146: /* stateLightProperty: ATTENUATION  */
3490#line 1281 "../src/mesa/program/program_parse.y"
3491        {
3492	   if (!state->ctx->Extensions.EXT_point_parameters) {
3493	      yyerror(& (yylsp[0]), state, "GL_ARB_point_parameters not supported");
3494	      YYERROR;
3495	   }
3496
3497	   (yyval.integer) = STATE_ATTENUATION;
3498	}
3499#line 3500 "src/mesa/program/program_parse.tab.c"
3500    break;
3501
3502  case 147: /* stateLightProperty: SPOT stateSpotProperty  */
3503#line 1290 "../src/mesa/program/program_parse.y"
3504        {
3505	   (yyval.integer) = (yyvsp[0].integer);
3506	}
3507#line 3508 "src/mesa/program/program_parse.tab.c"
3508    break;
3509
3510  case 148: /* stateLightProperty: HALF  */
3511#line 1294 "../src/mesa/program/program_parse.y"
3512        {
3513	   (yyval.integer) = STATE_HALF_VECTOR;
3514	}
3515#line 3516 "src/mesa/program/program_parse.tab.c"
3516    break;
3517
3518  case 149: /* stateSpotProperty: DIRECTION  */
3519#line 1300 "../src/mesa/program/program_parse.y"
3520        {
3521	   (yyval.integer) = STATE_SPOT_DIRECTION;
3522	}
3523#line 3524 "src/mesa/program/program_parse.tab.c"
3524    break;
3525
3526  case 150: /* stateLightModelItem: LIGHTMODEL stateLModProperty  */
3527#line 1306 "../src/mesa/program/program_parse.y"
3528        {
3529	   (yyval.state)[0] = (yyvsp[0].state)[0];
3530	   (yyval.state)[1] = (yyvsp[0].state)[1];
3531	}
3532#line 3533 "src/mesa/program/program_parse.tab.c"
3533    break;
3534
3535  case 151: /* stateLModProperty: AMBIENT  */
3536#line 1313 "../src/mesa/program/program_parse.y"
3537        {
3538	   memset((yyval.state), 0, sizeof((yyval.state)));
3539	   (yyval.state)[0] = STATE_LIGHTMODEL_AMBIENT;
3540	}
3541#line 3542 "src/mesa/program/program_parse.tab.c"
3542    break;
3543
3544  case 152: /* stateLModProperty: optFaceType SCENECOLOR  */
3545#line 1318 "../src/mesa/program/program_parse.y"
3546        {
3547	   memset((yyval.state), 0, sizeof((yyval.state)));
3548	   (yyval.state)[0] = STATE_LIGHTMODEL_SCENECOLOR;
3549	   (yyval.state)[1] = (yyvsp[-1].integer);
3550	}
3551#line 3552 "src/mesa/program/program_parse.tab.c"
3552    break;
3553
3554  case 153: /* stateLightProdItem: LIGHTPROD '[' stateLightNumber ']' optFaceType stateLProdProperty  */
3555#line 1326 "../src/mesa/program/program_parse.y"
3556        {
3557	   memset((yyval.state), 0, sizeof((yyval.state)));
3558	   (yyval.state)[0] = STATE_LIGHTPROD;
3559	   (yyval.state)[1] = (yyvsp[-3].integer);
3560	   (yyval.state)[2] = (yyvsp[0].integer) + (yyvsp[-1].integer);
3561	   (yyval.state)[3] = 0;
3562	}
3563#line 3564 "src/mesa/program/program_parse.tab.c"
3564    break;
3565
3566  case 155: /* stateTexEnvItem: TEXENV optLegacyTexUnitNum stateTexEnvProperty  */
3567#line 1338 "../src/mesa/program/program_parse.y"
3568        {
3569	   memset((yyval.state), 0, sizeof((yyval.state)));
3570	   (yyval.state)[0] = (yyvsp[0].integer);
3571	   (yyval.state)[1] = (yyvsp[-1].integer);
3572	}
3573#line 3574 "src/mesa/program/program_parse.tab.c"
3574    break;
3575
3576  case 156: /* stateTexEnvProperty: COLOR  */
3577#line 1346 "../src/mesa/program/program_parse.y"
3578        {
3579	   (yyval.integer) = STATE_TEXENV_COLOR;
3580	}
3581#line 3582 "src/mesa/program/program_parse.tab.c"
3582    break;
3583
3584  case 157: /* ambDiffSpecPropertyMaterial: AMBIENT  */
3585#line 1352 "../src/mesa/program/program_parse.y"
3586        {
3587	   (yyval.integer) = MAT_ATTRIB_FRONT_AMBIENT;
3588	}
3589#line 3590 "src/mesa/program/program_parse.tab.c"
3590    break;
3591
3592  case 158: /* ambDiffSpecPropertyMaterial: DIFFUSE  */
3593#line 1356 "../src/mesa/program/program_parse.y"
3594        {
3595	   (yyval.integer) = MAT_ATTRIB_FRONT_DIFFUSE;
3596	}
3597#line 3598 "src/mesa/program/program_parse.tab.c"
3598    break;
3599
3600  case 159: /* ambDiffSpecPropertyMaterial: SPECULAR  */
3601#line 1360 "../src/mesa/program/program_parse.y"
3602        {
3603	   (yyval.integer) = MAT_ATTRIB_FRONT_SPECULAR;
3604	}
3605#line 3606 "src/mesa/program/program_parse.tab.c"
3606    break;
3607
3608  case 160: /* ambDiffSpecPropertyLight: AMBIENT  */
3609#line 1366 "../src/mesa/program/program_parse.y"
3610        {
3611           (yyval.integer) = STATE_AMBIENT;
3612        }
3613#line 3614 "src/mesa/program/program_parse.tab.c"
3614    break;
3615
3616  case 161: /* ambDiffSpecPropertyLight: DIFFUSE  */
3617#line 1370 "../src/mesa/program/program_parse.y"
3618        {
3619           (yyval.integer) = STATE_DIFFUSE;
3620        }
3621#line 3622 "src/mesa/program/program_parse.tab.c"
3622    break;
3623
3624  case 162: /* ambDiffSpecPropertyLight: SPECULAR  */
3625#line 1374 "../src/mesa/program/program_parse.y"
3626        {
3627           (yyval.integer) = STATE_SPECULAR;
3628        }
3629#line 3630 "src/mesa/program/program_parse.tab.c"
3630    break;
3631
3632  case 163: /* stateLightNumber: INTEGER  */
3633#line 1380 "../src/mesa/program/program_parse.y"
3634        {
3635	   if ((unsigned) (yyvsp[0].integer) >= state->MaxLights) {
3636	      yyerror(& (yylsp[0]), state, "invalid light selector");
3637	      YYERROR;
3638	   }
3639
3640	   (yyval.integer) = (yyvsp[0].integer);
3641	}
3642#line 3643 "src/mesa/program/program_parse.tab.c"
3643    break;
3644
3645  case 164: /* stateTexGenItem: TEXGEN optTexCoordUnitNum stateTexGenType stateTexGenCoord  */
3646#line 1391 "../src/mesa/program/program_parse.y"
3647        {
3648	   memset((yyval.state), 0, sizeof((yyval.state)));
3649	   (yyval.state)[0] = STATE_TEXGEN;
3650	   (yyval.state)[1] = (yyvsp[-2].integer);
3651	   (yyval.state)[2] = (yyvsp[-1].integer) + (yyvsp[0].integer);
3652	}
3653#line 3654 "src/mesa/program/program_parse.tab.c"
3654    break;
3655
3656  case 165: /* stateTexGenType: EYE  */
3657#line 1400 "../src/mesa/program/program_parse.y"
3658        {
3659	   (yyval.integer) = STATE_TEXGEN_EYE_S;
3660	}
3661#line 3662 "src/mesa/program/program_parse.tab.c"
3662    break;
3663
3664  case 166: /* stateTexGenType: OBJECT  */
3665#line 1404 "../src/mesa/program/program_parse.y"
3666        {
3667	   (yyval.integer) = STATE_TEXGEN_OBJECT_S;
3668	}
3669#line 3670 "src/mesa/program/program_parse.tab.c"
3670    break;
3671
3672  case 167: /* stateTexGenCoord: TEXGEN_S  */
3673#line 1409 "../src/mesa/program/program_parse.y"
3674        {
3675	   (yyval.integer) = STATE_TEXGEN_EYE_S - STATE_TEXGEN_EYE_S;
3676	}
3677#line 3678 "src/mesa/program/program_parse.tab.c"
3678    break;
3679
3680  case 168: /* stateTexGenCoord: TEXGEN_T  */
3681#line 1413 "../src/mesa/program/program_parse.y"
3682        {
3683	   (yyval.integer) = STATE_TEXGEN_EYE_T - STATE_TEXGEN_EYE_S;
3684	}
3685#line 3686 "src/mesa/program/program_parse.tab.c"
3686    break;
3687
3688  case 169: /* stateTexGenCoord: TEXGEN_R  */
3689#line 1417 "../src/mesa/program/program_parse.y"
3690        {
3691	   (yyval.integer) = STATE_TEXGEN_EYE_R - STATE_TEXGEN_EYE_S;
3692	}
3693#line 3694 "src/mesa/program/program_parse.tab.c"
3694    break;
3695
3696  case 170: /* stateTexGenCoord: TEXGEN_Q  */
3697#line 1421 "../src/mesa/program/program_parse.y"
3698        {
3699	   (yyval.integer) = STATE_TEXGEN_EYE_Q - STATE_TEXGEN_EYE_S;
3700	}
3701#line 3702 "src/mesa/program/program_parse.tab.c"
3702    break;
3703
3704  case 171: /* stateFogItem: FOG stateFogProperty  */
3705#line 1427 "../src/mesa/program/program_parse.y"
3706        {
3707	   memset((yyval.state), 0, sizeof((yyval.state)));
3708	   (yyval.state)[0] = (yyvsp[0].integer);
3709	}
3710#line 3711 "src/mesa/program/program_parse.tab.c"
3711    break;
3712
3713  case 172: /* stateFogProperty: COLOR  */
3714#line 1434 "../src/mesa/program/program_parse.y"
3715        {
3716	   (yyval.integer) = STATE_FOG_COLOR;
3717	}
3718#line 3719 "src/mesa/program/program_parse.tab.c"
3719    break;
3720
3721  case 173: /* stateFogProperty: PARAMS  */
3722#line 1438 "../src/mesa/program/program_parse.y"
3723        {
3724	   (yyval.integer) = STATE_FOG_PARAMS;
3725	}
3726#line 3727 "src/mesa/program/program_parse.tab.c"
3727    break;
3728
3729  case 174: /* stateClipPlaneItem: CLIP '[' stateClipPlaneNum ']' PLANE  */
3730#line 1444 "../src/mesa/program/program_parse.y"
3731        {
3732	   memset((yyval.state), 0, sizeof((yyval.state)));
3733	   (yyval.state)[0] = STATE_CLIPPLANE;
3734	   (yyval.state)[1] = (yyvsp[-2].integer);
3735	}
3736#line 3737 "src/mesa/program/program_parse.tab.c"
3737    break;
3738
3739  case 175: /* stateClipPlaneNum: INTEGER  */
3740#line 1452 "../src/mesa/program/program_parse.y"
3741        {
3742	   if ((unsigned) (yyvsp[0].integer) >= state->MaxClipPlanes) {
3743	      yyerror(& (yylsp[0]), state, "invalid clip plane selector");
3744	      YYERROR;
3745	   }
3746
3747	   (yyval.integer) = (yyvsp[0].integer);
3748	}
3749#line 3750 "src/mesa/program/program_parse.tab.c"
3750    break;
3751
3752  case 176: /* statePointItem: POINT_TOK statePointProperty  */
3753#line 1463 "../src/mesa/program/program_parse.y"
3754        {
3755	   memset((yyval.state), 0, sizeof((yyval.state)));
3756	   (yyval.state)[0] = (yyvsp[0].integer);
3757	}
3758#line 3759 "src/mesa/program/program_parse.tab.c"
3759    break;
3760
3761  case 177: /* statePointProperty: SIZE_TOK  */
3762#line 1470 "../src/mesa/program/program_parse.y"
3763        {
3764	   (yyval.integer) = STATE_POINT_SIZE;
3765	}
3766#line 3767 "src/mesa/program/program_parse.tab.c"
3767    break;
3768
3769  case 178: /* statePointProperty: ATTENUATION  */
3770#line 1474 "../src/mesa/program/program_parse.y"
3771        {
3772	   (yyval.integer) = STATE_POINT_ATTENUATION;
3773	}
3774#line 3775 "src/mesa/program/program_parse.tab.c"
3775    break;
3776
3777  case 179: /* stateMatrixRow: stateMatrixItem ROW '[' stateMatrixRowNum ']'  */
3778#line 1480 "../src/mesa/program/program_parse.y"
3779        {
3780	   (yyval.state)[0] = (yyvsp[-4].state)[0] + (yyvsp[-4].state)[2];
3781	   (yyval.state)[1] = (yyvsp[-4].state)[1];
3782	   (yyval.state)[2] = (yyvsp[-1].integer);
3783	   (yyval.state)[3] = (yyvsp[-1].integer);
3784	}
3785#line 3786 "src/mesa/program/program_parse.tab.c"
3786    break;
3787
3788  case 180: /* stateMatrixRows: stateMatrixItem optMatrixRows  */
3789#line 1489 "../src/mesa/program/program_parse.y"
3790        {
3791	   (yyval.state)[0] = (yyvsp[-1].state)[0] + (yyvsp[-1].state)[2];
3792	   (yyval.state)[1] = (yyvsp[-1].state)[1];
3793	   (yyval.state)[2] = (yyvsp[0].state)[2];
3794	   (yyval.state)[3] = (yyvsp[0].state)[3];
3795	}
3796#line 3797 "src/mesa/program/program_parse.tab.c"
3797    break;
3798
3799  case 181: /* optMatrixRows: %empty  */
3800#line 1498 "../src/mesa/program/program_parse.y"
3801        {
3802	   (yyval.state)[2] = 0;
3803	   (yyval.state)[3] = 3;
3804	}
3805#line 3806 "src/mesa/program/program_parse.tab.c"
3806    break;
3807
3808  case 182: /* optMatrixRows: ROW '[' stateMatrixRowNum DOT_DOT stateMatrixRowNum ']'  */
3809#line 1503 "../src/mesa/program/program_parse.y"
3810        {
3811	   /* It seems logical that the matrix row range specifier would have
3812	    * to specify a range or more than one row (i.e., $5 > $3).
3813	    * However, the ARB_vertex_program spec says "a program will fail
3814	    * to load if <a> is greater than <b>."  This means that $3 == $5
3815	    * is valid.
3816	    */
3817	   if ((yyvsp[-3].integer) > (yyvsp[-1].integer)) {
3818	      yyerror(& (yylsp[-3]), state, "invalid matrix row range");
3819	      YYERROR;
3820	   }
3821
3822	   (yyval.state)[2] = (yyvsp[-3].integer);
3823	   (yyval.state)[3] = (yyvsp[-1].integer);
3824	}
3825#line 3826 "src/mesa/program/program_parse.tab.c"
3826    break;
3827
3828  case 183: /* stateMatrixItem: MATRIX stateMatrixName stateOptMatModifier  */
3829#line 1521 "../src/mesa/program/program_parse.y"
3830        {
3831	   (yyval.state)[0] = (yyvsp[-1].state)[0];
3832	   (yyval.state)[1] = (yyvsp[-1].state)[1];
3833	   (yyval.state)[2] = (yyvsp[0].integer);
3834	}
3835#line 3836 "src/mesa/program/program_parse.tab.c"
3836    break;
3837
3838  case 184: /* stateOptMatModifier: %empty  */
3839#line 1529 "../src/mesa/program/program_parse.y"
3840        {
3841	   (yyval.integer) = STATE_MATRIX_NO_MODIFIER;
3842	}
3843#line 3844 "src/mesa/program/program_parse.tab.c"
3844    break;
3845
3846  case 185: /* stateOptMatModifier: stateMatModifier  */
3847#line 1533 "../src/mesa/program/program_parse.y"
3848        {
3849	   (yyval.integer) = (yyvsp[0].integer);
3850	}
3851#line 3852 "src/mesa/program/program_parse.tab.c"
3852    break;
3853
3854  case 186: /* stateMatModifier: INVERSE  */
3855#line 1539 "../src/mesa/program/program_parse.y"
3856        {
3857	   (yyval.integer) = STATE_MATRIX_INVERSE;
3858	}
3859#line 3860 "src/mesa/program/program_parse.tab.c"
3860    break;
3861
3862  case 187: /* stateMatModifier: TRANSPOSE  */
3863#line 1543 "../src/mesa/program/program_parse.y"
3864        {
3865	   (yyval.integer) = STATE_MATRIX_TRANSPOSE;
3866	}
3867#line 3868 "src/mesa/program/program_parse.tab.c"
3868    break;
3869
3870  case 188: /* stateMatModifier: INVTRANS  */
3871#line 1547 "../src/mesa/program/program_parse.y"
3872        {
3873	   (yyval.integer) = STATE_MATRIX_INVTRANS;
3874	}
3875#line 3876 "src/mesa/program/program_parse.tab.c"
3876    break;
3877
3878  case 189: /* stateMatrixRowNum: INTEGER  */
3879#line 1553 "../src/mesa/program/program_parse.y"
3880        {
3881	   if ((yyvsp[0].integer) > 3) {
3882	      yyerror(& (yylsp[0]), state, "invalid matrix row reference");
3883	      YYERROR;
3884	   }
3885
3886	   (yyval.integer) = (yyvsp[0].integer);
3887	}
3888#line 3889 "src/mesa/program/program_parse.tab.c"
3889    break;
3890
3891  case 190: /* stateMatrixName: MODELVIEW stateOptModMatNum  */
3892#line 1564 "../src/mesa/program/program_parse.y"
3893        {
3894	   (yyval.state)[0] = STATE_MODELVIEW_MATRIX;
3895	   (yyval.state)[1] = (yyvsp[0].integer);
3896	}
3897#line 3898 "src/mesa/program/program_parse.tab.c"
3898    break;
3899
3900  case 191: /* stateMatrixName: PROJECTION  */
3901#line 1569 "../src/mesa/program/program_parse.y"
3902        {
3903	   (yyval.state)[0] = STATE_PROJECTION_MATRIX;
3904	   (yyval.state)[1] = 0;
3905	}
3906#line 3907 "src/mesa/program/program_parse.tab.c"
3907    break;
3908
3909  case 192: /* stateMatrixName: MVP  */
3910#line 1574 "../src/mesa/program/program_parse.y"
3911        {
3912	   (yyval.state)[0] = STATE_MVP_MATRIX;
3913	   (yyval.state)[1] = 0;
3914	}
3915#line 3916 "src/mesa/program/program_parse.tab.c"
3916    break;
3917
3918  case 193: /* stateMatrixName: TEXTURE optTexCoordUnitNum  */
3919#line 1579 "../src/mesa/program/program_parse.y"
3920        {
3921	   (yyval.state)[0] = STATE_TEXTURE_MATRIX;
3922	   (yyval.state)[1] = (yyvsp[0].integer);
3923	}
3924#line 3925 "src/mesa/program/program_parse.tab.c"
3925    break;
3926
3927  case 194: /* stateMatrixName: PALETTE '[' statePaletteMatNum ']'  */
3928#line 1584 "../src/mesa/program/program_parse.y"
3929        {
3930	   yyerror(& (yylsp[-3]), state, "GL_ARB_matrix_palette not supported");
3931	   YYERROR;
3932	}
3933#line 3934 "src/mesa/program/program_parse.tab.c"
3934    break;
3935
3936  case 195: /* stateMatrixName: MAT_PROGRAM '[' stateProgramMatNum ']'  */
3937#line 1589 "../src/mesa/program/program_parse.y"
3938        {
3939	   (yyval.state)[0] = STATE_PROGRAM_MATRIX;
3940	   (yyval.state)[1] = (yyvsp[-1].integer);
3941	}
3942#line 3943 "src/mesa/program/program_parse.tab.c"
3943    break;
3944
3945  case 196: /* stateOptModMatNum: %empty  */
3946#line 1596 "../src/mesa/program/program_parse.y"
3947        {
3948	   (yyval.integer) = 0;
3949	}
3950#line 3951 "src/mesa/program/program_parse.tab.c"
3951    break;
3952
3953  case 197: /* stateOptModMatNum: '[' stateModMatNum ']'  */
3954#line 1600 "../src/mesa/program/program_parse.y"
3955        {
3956	   (yyval.integer) = (yyvsp[-1].integer);
3957	}
3958#line 3959 "src/mesa/program/program_parse.tab.c"
3959    break;
3960
3961  case 198: /* stateModMatNum: INTEGER  */
3962#line 1605 "../src/mesa/program/program_parse.y"
3963        {
3964	   /* Since GL_ARB_vertex_blend isn't supported, only modelview matrix
3965	    * zero is valid.
3966	    */
3967	   if ((yyvsp[0].integer) != 0) {
3968	      yyerror(& (yylsp[0]), state, "invalid modelview matrix index");
3969	      YYERROR;
3970	   }
3971
3972	   (yyval.integer) = (yyvsp[0].integer);
3973	}
3974#line 3975 "src/mesa/program/program_parse.tab.c"
3975    break;
3976
3977  case 199: /* statePaletteMatNum: INTEGER  */
3978#line 1618 "../src/mesa/program/program_parse.y"
3979        {
3980	   /* Since GL_ARB_matrix_palette isn't supported, just let any value
3981	    * through here.  The error will be generated later.
3982	    */
3983	   (yyval.integer) = (yyvsp[0].integer);
3984	}
3985#line 3986 "src/mesa/program/program_parse.tab.c"
3986    break;
3987
3988  case 200: /* stateProgramMatNum: INTEGER  */
3989#line 1626 "../src/mesa/program/program_parse.y"
3990        {
3991	   if ((unsigned) (yyvsp[0].integer) >= state->MaxProgramMatrices) {
3992	      yyerror(& (yylsp[0]), state, "invalid program matrix selector");
3993	      YYERROR;
3994	   }
3995
3996	   (yyval.integer) = (yyvsp[0].integer);
3997	}
3998#line 3999 "src/mesa/program/program_parse.tab.c"
3999    break;
4000
4001  case 201: /* stateDepthItem: DEPTH RANGE  */
4002#line 1637 "../src/mesa/program/program_parse.y"
4003        {
4004	   memset((yyval.state), 0, sizeof((yyval.state)));
4005	   (yyval.state)[0] = STATE_DEPTH_RANGE;
4006	}
4007#line 4008 "src/mesa/program/program_parse.tab.c"
4008    break;
4009
4010  case 206: /* progEnvParams: PROGRAM ENV '[' progEnvParamNums ']'  */
4011#line 1649 "../src/mesa/program/program_parse.y"
4012        {
4013	   memset((yyval.state), 0, sizeof((yyval.state)));
4014	   (yyval.state)[0] = state->state_param_enum_env;
4015	   (yyval.state)[1] = (yyvsp[-1].state)[0];
4016	   (yyval.state)[2] = (yyvsp[-1].state)[1];
4017           (yyval.state)[3] = 0;
4018	}
4019#line 4020 "src/mesa/program/program_parse.tab.c"
4020    break;
4021
4022  case 207: /* progEnvParamNums: progEnvParamNum  */
4023#line 1659 "../src/mesa/program/program_parse.y"
4024        {
4025	   (yyval.state)[0] = (yyvsp[0].integer);
4026	   (yyval.state)[1] = (yyvsp[0].integer);
4027	}
4028#line 4029 "src/mesa/program/program_parse.tab.c"
4029    break;
4030
4031  case 208: /* progEnvParamNums: progEnvParamNum DOT_DOT progEnvParamNum  */
4032#line 1664 "../src/mesa/program/program_parse.y"
4033        {
4034	   (yyval.state)[0] = (yyvsp[-2].integer);
4035	   (yyval.state)[1] = (yyvsp[0].integer);
4036	}
4037#line 4038 "src/mesa/program/program_parse.tab.c"
4038    break;
4039
4040  case 209: /* progEnvParam: PROGRAM ENV '[' progEnvParamNum ']'  */
4041#line 1671 "../src/mesa/program/program_parse.y"
4042        {
4043	   memset((yyval.state), 0, sizeof((yyval.state)));
4044	   (yyval.state)[0] = state->state_param_enum_env;
4045	   (yyval.state)[1] = (yyvsp[-1].integer);
4046	   (yyval.state)[2] = (yyvsp[-1].integer);
4047           (yyval.state)[3] = 0;
4048	}
4049#line 4050 "src/mesa/program/program_parse.tab.c"
4050    break;
4051
4052  case 210: /* progLocalParams: PROGRAM LOCAL '[' progLocalParamNums ']'  */
4053#line 1681 "../src/mesa/program/program_parse.y"
4054        {
4055	   memset((yyval.state), 0, sizeof((yyval.state)));
4056	   (yyval.state)[0] = state->state_param_enum_local;
4057	   (yyval.state)[1] = (yyvsp[-1].state)[0];
4058	   (yyval.state)[2] = (yyvsp[-1].state)[1];
4059           (yyval.state)[3] = 0;
4060	}
4061#line 4062 "src/mesa/program/program_parse.tab.c"
4062    break;
4063
4064  case 211: /* progLocalParamNums: progLocalParamNum  */
4065#line 1690 "../src/mesa/program/program_parse.y"
4066        {
4067	   (yyval.state)[0] = (yyvsp[0].integer);
4068	   (yyval.state)[1] = (yyvsp[0].integer);
4069	}
4070#line 4071 "src/mesa/program/program_parse.tab.c"
4071    break;
4072
4073  case 212: /* progLocalParamNums: progLocalParamNum DOT_DOT progLocalParamNum  */
4074#line 1695 "../src/mesa/program/program_parse.y"
4075        {
4076	   (yyval.state)[0] = (yyvsp[-2].integer);
4077	   (yyval.state)[1] = (yyvsp[0].integer);
4078	}
4079#line 4080 "src/mesa/program/program_parse.tab.c"
4080    break;
4081
4082  case 213: /* progLocalParam: PROGRAM LOCAL '[' progLocalParamNum ']'  */
4083#line 1702 "../src/mesa/program/program_parse.y"
4084        {
4085	   memset((yyval.state), 0, sizeof((yyval.state)));
4086	   (yyval.state)[0] = state->state_param_enum_local;
4087	   (yyval.state)[1] = (yyvsp[-1].integer);
4088	   (yyval.state)[2] = (yyvsp[-1].integer);
4089           (yyval.state)[3] = 0;
4090	}
4091#line 4092 "src/mesa/program/program_parse.tab.c"
4092    break;
4093
4094  case 214: /* progEnvParamNum: INTEGER  */
4095#line 1712 "../src/mesa/program/program_parse.y"
4096        {
4097	   if ((unsigned) (yyvsp[0].integer) >= state->limits->MaxEnvParams) {
4098	      yyerror(& (yylsp[0]), state, "invalid environment parameter reference");
4099	      YYERROR;
4100	   }
4101	   (yyval.integer) = (yyvsp[0].integer);
4102	}
4103#line 4104 "src/mesa/program/program_parse.tab.c"
4104    break;
4105
4106  case 215: /* progLocalParamNum: INTEGER  */
4107#line 1722 "../src/mesa/program/program_parse.y"
4108        {
4109	   if ((unsigned) (yyvsp[0].integer) >= state->limits->MaxLocalParams) {
4110	      yyerror(& (yylsp[0]), state, "invalid local parameter reference");
4111	      YYERROR;
4112	   }
4113	   (yyval.integer) = (yyvsp[0].integer);
4114	}
4115#line 4116 "src/mesa/program/program_parse.tab.c"
4116    break;
4117
4118  case 220: /* paramConstScalarDecl: signedFloatConstant  */
4119#line 1737 "../src/mesa/program/program_parse.y"
4120        {
4121	   (yyval.vector).count = 4;
4122	   (yyval.vector).data[0].f = (yyvsp[0].real);
4123	   (yyval.vector).data[1].f = (yyvsp[0].real);
4124	   (yyval.vector).data[2].f = (yyvsp[0].real);
4125	   (yyval.vector).data[3].f = (yyvsp[0].real);
4126	}
4127#line 4128 "src/mesa/program/program_parse.tab.c"
4128    break;
4129
4130  case 221: /* paramConstScalarUse: REAL  */
4131#line 1747 "../src/mesa/program/program_parse.y"
4132        {
4133	   (yyval.vector).count = 1;
4134	   (yyval.vector).data[0].f = (yyvsp[0].real);
4135	   (yyval.vector).data[1].f = (yyvsp[0].real);
4136	   (yyval.vector).data[2].f = (yyvsp[0].real);
4137	   (yyval.vector).data[3].f = (yyvsp[0].real);
4138	}
4139#line 4140 "src/mesa/program/program_parse.tab.c"
4140    break;
4141
4142  case 222: /* paramConstScalarUse: INTEGER  */
4143#line 1755 "../src/mesa/program/program_parse.y"
4144        {
4145	   (yyval.vector).count = 1;
4146	   (yyval.vector).data[0].f = (float) (yyvsp[0].integer);
4147	   (yyval.vector).data[1].f = (float) (yyvsp[0].integer);
4148	   (yyval.vector).data[2].f = (float) (yyvsp[0].integer);
4149	   (yyval.vector).data[3].f = (float) (yyvsp[0].integer);
4150	}
4151#line 4152 "src/mesa/program/program_parse.tab.c"
4152    break;
4153
4154  case 223: /* paramConstVector: '{' signedFloatConstant '}'  */
4155#line 1765 "../src/mesa/program/program_parse.y"
4156        {
4157	   (yyval.vector).count = 4;
4158	   (yyval.vector).data[0].f = (yyvsp[-1].real);
4159	   (yyval.vector).data[1].f = 0.0f;
4160	   (yyval.vector).data[2].f = 0.0f;
4161	   (yyval.vector).data[3].f = 1.0f;
4162	}
4163#line 4164 "src/mesa/program/program_parse.tab.c"
4164    break;
4165
4166  case 224: /* paramConstVector: '{' signedFloatConstant ',' signedFloatConstant '}'  */
4167#line 1773 "../src/mesa/program/program_parse.y"
4168        {
4169	   (yyval.vector).count = 4;
4170	   (yyval.vector).data[0].f = (yyvsp[-3].real);
4171	   (yyval.vector).data[1].f = (yyvsp[-1].real);
4172	   (yyval.vector).data[2].f = 0.0f;
4173	   (yyval.vector).data[3].f = 1.0f;
4174	}
4175#line 4176 "src/mesa/program/program_parse.tab.c"
4176    break;
4177
4178  case 225: /* paramConstVector: '{' signedFloatConstant ',' signedFloatConstant ',' signedFloatConstant '}'  */
4179#line 1782 "../src/mesa/program/program_parse.y"
4180        {
4181	   (yyval.vector).count = 4;
4182	   (yyval.vector).data[0].f = (yyvsp[-5].real);
4183	   (yyval.vector).data[1].f = (yyvsp[-3].real);
4184	   (yyval.vector).data[2].f = (yyvsp[-1].real);
4185	   (yyval.vector).data[3].f = 1.0f;
4186	}
4187#line 4188 "src/mesa/program/program_parse.tab.c"
4188    break;
4189
4190  case 226: /* paramConstVector: '{' signedFloatConstant ',' signedFloatConstant ',' signedFloatConstant ',' signedFloatConstant '}'  */
4191#line 1791 "../src/mesa/program/program_parse.y"
4192        {
4193	   (yyval.vector).count = 4;
4194	   (yyval.vector).data[0].f = (yyvsp[-7].real);
4195	   (yyval.vector).data[1].f = (yyvsp[-5].real);
4196	   (yyval.vector).data[2].f = (yyvsp[-3].real);
4197	   (yyval.vector).data[3].f = (yyvsp[-1].real);
4198	}
4199#line 4200 "src/mesa/program/program_parse.tab.c"
4200    break;
4201
4202  case 227: /* signedFloatConstant: optionalSign REAL  */
4203#line 1801 "../src/mesa/program/program_parse.y"
4204        {
4205	   (yyval.real) = ((yyvsp[-1].negate)) ? -(yyvsp[0].real) : (yyvsp[0].real);
4206	}
4207#line 4208 "src/mesa/program/program_parse.tab.c"
4208    break;
4209
4210  case 228: /* signedFloatConstant: optionalSign INTEGER  */
4211#line 1805 "../src/mesa/program/program_parse.y"
4212        {
4213	   (yyval.real) = (float)(((yyvsp[-1].negate)) ? -(yyvsp[0].integer) : (yyvsp[0].integer));
4214	}
4215#line 4216 "src/mesa/program/program_parse.tab.c"
4216    break;
4217
4218  case 229: /* optionalSign: '+'  */
4219#line 1810 "../src/mesa/program/program_parse.y"
4220                         { (yyval.negate) = FALSE; }
4221#line 4222 "src/mesa/program/program_parse.tab.c"
4222    break;
4223
4224  case 230: /* optionalSign: '-'  */
4225#line 1811 "../src/mesa/program/program_parse.y"
4226                         { (yyval.negate) = TRUE;  }
4227#line 4228 "src/mesa/program/program_parse.tab.c"
4228    break;
4229
4230  case 231: /* optionalSign: %empty  */
4231#line 1812 "../src/mesa/program/program_parse.y"
4232                         { (yyval.negate) = FALSE; }
4233#line 4234 "src/mesa/program/program_parse.tab.c"
4234    break;
4235
4236  case 232: /* @1: %empty  */
4237#line 1815 "../src/mesa/program/program_parse.y"
4238                     { (yyval.integer) = (yyvsp[0].integer); }
4239#line 4240 "src/mesa/program/program_parse.tab.c"
4240    break;
4241
4242  case 234: /* @2: %empty  */
4243#line 1818 "../src/mesa/program/program_parse.y"
4244                           { (yyval.integer) = (yyvsp[0].integer); }
4245#line 4246 "src/mesa/program/program_parse.tab.c"
4246    break;
4247
4248  case 236: /* varNameList: varNameList ',' IDENTIFIER  */
4249#line 1822 "../src/mesa/program/program_parse.y"
4250        {
4251	   if (!declare_variable(state, (yyvsp[0].string), (yyvsp[-3].integer), & (yylsp[0]))) {
4252	      free((yyvsp[0].string));
4253	      YYERROR;
4254	   }
4255	}
4256#line 4257 "src/mesa/program/program_parse.tab.c"
4257    break;
4258
4259  case 237: /* varNameList: IDENTIFIER  */
4260#line 1829 "../src/mesa/program/program_parse.y"
4261        {
4262	   if (!declare_variable(state, (yyvsp[0].string), (yyvsp[-1].integer), & (yylsp[0]))) {
4263	      free((yyvsp[0].string));
4264	      YYERROR;
4265	   }
4266	}
4267#line 4268 "src/mesa/program/program_parse.tab.c"
4268    break;
4269
4270  case 238: /* OUTPUT_statement: OUTPUT IDENTIFIER '=' resultBinding  */
4271#line 1838 "../src/mesa/program/program_parse.y"
4272        {
4273	   struct asm_symbol *const s =
4274	      declare_variable(state, (yyvsp[-2].string), at_output, & (yylsp[-2]));
4275
4276	   if (s == NULL) {
4277	      free((yyvsp[-2].string));
4278	      YYERROR;
4279	   } else {
4280	      s->output_binding = (yyvsp[0].result);
4281	   }
4282	}
4283#line 4284 "src/mesa/program/program_parse.tab.c"
4284    break;
4285
4286  case 239: /* resultBinding: RESULT POSITION  */
4287#line 1852 "../src/mesa/program/program_parse.y"
4288        {
4289	   if (state->mode == ARB_vertex) {
4290	      (yyval.result) = VARYING_SLOT_POS;
4291	   } else {
4292	      yyerror(& (yylsp[0]), state, "invalid program result name");
4293	      YYERROR;
4294	   }
4295	}
4296#line 4297 "src/mesa/program/program_parse.tab.c"
4297    break;
4298
4299  case 240: /* resultBinding: RESULT FOGCOORD  */
4300#line 1861 "../src/mesa/program/program_parse.y"
4301        {
4302	   if (state->mode == ARB_vertex) {
4303	      (yyval.result) = VARYING_SLOT_FOGC;
4304	   } else {
4305	      yyerror(& (yylsp[0]), state, "invalid program result name");
4306	      YYERROR;
4307	   }
4308	}
4309#line 4310 "src/mesa/program/program_parse.tab.c"
4310    break;
4311
4312  case 241: /* resultBinding: RESULT resultColBinding  */
4313#line 1870 "../src/mesa/program/program_parse.y"
4314        {
4315	   (yyval.result) = (yyvsp[0].result);
4316	}
4317#line 4318 "src/mesa/program/program_parse.tab.c"
4318    break;
4319
4320  case 242: /* resultBinding: RESULT POINTSIZE  */
4321#line 1874 "../src/mesa/program/program_parse.y"
4322        {
4323	   if (state->mode == ARB_vertex) {
4324	      (yyval.result) = VARYING_SLOT_PSIZ;
4325	   } else {
4326	      yyerror(& (yylsp[0]), state, "invalid program result name");
4327	      YYERROR;
4328	   }
4329	}
4330#line 4331 "src/mesa/program/program_parse.tab.c"
4331    break;
4332
4333  case 243: /* resultBinding: RESULT TEXCOORD optTexCoordUnitNum  */
4334#line 1883 "../src/mesa/program/program_parse.y"
4335        {
4336	   if (state->mode == ARB_vertex) {
4337	      (yyval.result) = VARYING_SLOT_TEX0 + (yyvsp[0].integer);
4338	   } else {
4339	      yyerror(& (yylsp[-1]), state, "invalid program result name");
4340	      YYERROR;
4341	   }
4342	}
4343#line 4344 "src/mesa/program/program_parse.tab.c"
4344    break;
4345
4346  case 244: /* resultBinding: RESULT DEPTH  */
4347#line 1892 "../src/mesa/program/program_parse.y"
4348        {
4349	   if (state->mode == ARB_fragment) {
4350	      (yyval.result) = FRAG_RESULT_DEPTH;
4351	   } else {
4352	      yyerror(& (yylsp[0]), state, "invalid program result name");
4353	      YYERROR;
4354	   }
4355	}
4356#line 4357 "src/mesa/program/program_parse.tab.c"
4357    break;
4358
4359  case 245: /* resultColBinding: COLOR optResultFaceType optResultColorType  */
4360#line 1903 "../src/mesa/program/program_parse.y"
4361        {
4362	   (yyval.result) = (yyvsp[-1].integer) + (yyvsp[0].integer);
4363	}
4364#line 4365 "src/mesa/program/program_parse.tab.c"
4365    break;
4366
4367  case 246: /* optResultFaceType: %empty  */
4368#line 1909 "../src/mesa/program/program_parse.y"
4369        {
4370	   if (state->mode == ARB_vertex) {
4371	      (yyval.integer) = VARYING_SLOT_COL0;
4372	   } else {
4373	      if (state->option.DrawBuffers)
4374		 (yyval.integer) = FRAG_RESULT_DATA0;
4375	      else
4376		 (yyval.integer) = FRAG_RESULT_COLOR;
4377	   }
4378	}
4379#line 4380 "src/mesa/program/program_parse.tab.c"
4380    break;
4381
4382  case 247: /* optResultFaceType: '[' INTEGER ']'  */
4383#line 1920 "../src/mesa/program/program_parse.y"
4384        {
4385	   if (state->mode == ARB_vertex) {
4386	      yyerror(& (yylsp[-2]), state, "invalid program result name");
4387	      YYERROR;
4388	   } else {
4389	      if (!state->option.DrawBuffers) {
4390		 /* From the ARB_draw_buffers spec (same text exists
4391		  * for ATI_draw_buffers):
4392		  *
4393		  *     If this option is not specified, a fragment
4394		  *     program that attempts to bind
4395		  *     "result.color[n]" will fail to load, and only
4396		  *     "result.color" will be allowed.
4397		  */
4398		 yyerror(& (yylsp[-2]), state,
4399			 "result.color[] used without "
4400			 "`OPTION ARB_draw_buffers' or "
4401			 "`OPTION ATI_draw_buffers'");
4402		 YYERROR;
4403	      } else if ((yyvsp[-1].integer) >= state->MaxDrawBuffers) {
4404		 yyerror(& (yylsp[-2]), state,
4405			 "result.color[] exceeds MAX_DRAW_BUFFERS_ARB");
4406		 YYERROR;
4407	      }
4408	      (yyval.integer) = FRAG_RESULT_DATA0 + (yyvsp[-1].integer);
4409	   }
4410	}
4411#line 4412 "src/mesa/program/program_parse.tab.c"
4412    break;
4413
4414  case 248: /* optResultFaceType: FRONT  */
4415#line 1948 "../src/mesa/program/program_parse.y"
4416        {
4417	   if (state->mode == ARB_vertex) {
4418	      (yyval.integer) = VARYING_SLOT_COL0;
4419	   } else {
4420	      yyerror(& (yylsp[0]), state, "invalid program result name");
4421	      YYERROR;
4422	   }
4423	}
4424#line 4425 "src/mesa/program/program_parse.tab.c"
4425    break;
4426
4427  case 249: /* optResultFaceType: BACK  */
4428#line 1957 "../src/mesa/program/program_parse.y"
4429        {
4430	   if (state->mode == ARB_vertex) {
4431	      (yyval.integer) = VARYING_SLOT_BFC0;
4432	   } else {
4433	      yyerror(& (yylsp[0]), state, "invalid program result name");
4434	      YYERROR;
4435	   }
4436	}
4437#line 4438 "src/mesa/program/program_parse.tab.c"
4438    break;
4439
4440  case 250: /* optResultColorType: %empty  */
4441#line 1968 "../src/mesa/program/program_parse.y"
4442        {
4443	   (yyval.integer) = 0;
4444	}
4445#line 4446 "src/mesa/program/program_parse.tab.c"
4446    break;
4447
4448  case 251: /* optResultColorType: PRIMARY  */
4449#line 1972 "../src/mesa/program/program_parse.y"
4450        {
4451	   if (state->mode == ARB_vertex) {
4452	      (yyval.integer) = 0;
4453	   } else {
4454	      yyerror(& (yylsp[0]), state, "invalid program result name");
4455	      YYERROR;
4456	   }
4457	}
4458#line 4459 "src/mesa/program/program_parse.tab.c"
4459    break;
4460
4461  case 252: /* optResultColorType: SECONDARY  */
4462#line 1981 "../src/mesa/program/program_parse.y"
4463        {
4464	   if (state->mode == ARB_vertex) {
4465	      (yyval.integer) = 1;
4466	   } else {
4467	      yyerror(& (yylsp[0]), state, "invalid program result name");
4468	      YYERROR;
4469	   }
4470	}
4471#line 4472 "src/mesa/program/program_parse.tab.c"
4472    break;
4473
4474  case 253: /* optFaceType: %empty  */
4475#line 1991 "../src/mesa/program/program_parse.y"
4476                { (yyval.integer) = 0; }
4477#line 4478 "src/mesa/program/program_parse.tab.c"
4478    break;
4479
4480  case 254: /* optFaceType: FRONT  */
4481#line 1992 "../src/mesa/program/program_parse.y"
4482                { (yyval.integer) = 0; }
4483#line 4484 "src/mesa/program/program_parse.tab.c"
4484    break;
4485
4486  case 255: /* optFaceType: BACK  */
4487#line 1993 "../src/mesa/program/program_parse.y"
4488                { (yyval.integer) = 1; }
4489#line 4490 "src/mesa/program/program_parse.tab.c"
4490    break;
4491
4492  case 256: /* optColorType: %empty  */
4493#line 1996 "../src/mesa/program/program_parse.y"
4494                    { (yyval.integer) = 0; }
4495#line 4496 "src/mesa/program/program_parse.tab.c"
4496    break;
4497
4498  case 257: /* optColorType: PRIMARY  */
4499#line 1997 "../src/mesa/program/program_parse.y"
4500                    { (yyval.integer) = 0; }
4501#line 4502 "src/mesa/program/program_parse.tab.c"
4502    break;
4503
4504  case 258: /* optColorType: SECONDARY  */
4505#line 1998 "../src/mesa/program/program_parse.y"
4506                    { (yyval.integer) = 1; }
4507#line 4508 "src/mesa/program/program_parse.tab.c"
4508    break;
4509
4510  case 259: /* optTexCoordUnitNum: %empty  */
4511#line 2001 "../src/mesa/program/program_parse.y"
4512                                   { (yyval.integer) = 0; }
4513#line 4514 "src/mesa/program/program_parse.tab.c"
4514    break;
4515
4516  case 260: /* optTexCoordUnitNum: '[' texCoordUnitNum ']'  */
4517#line 2002 "../src/mesa/program/program_parse.y"
4518                                   { (yyval.integer) = (yyvsp[-1].integer); }
4519#line 4520 "src/mesa/program/program_parse.tab.c"
4520    break;
4521
4522  case 261: /* optTexImageUnitNum: %empty  */
4523#line 2005 "../src/mesa/program/program_parse.y"
4524                                   { (yyval.integer) = 0; }
4525#line 4526 "src/mesa/program/program_parse.tab.c"
4526    break;
4527
4528  case 262: /* optTexImageUnitNum: '[' texImageUnitNum ']'  */
4529#line 2006 "../src/mesa/program/program_parse.y"
4530                                   { (yyval.integer) = (yyvsp[-1].integer); }
4531#line 4532 "src/mesa/program/program_parse.tab.c"
4532    break;
4533
4534  case 263: /* optLegacyTexUnitNum: %empty  */
4535#line 2009 "../src/mesa/program/program_parse.y"
4536                                   { (yyval.integer) = 0; }
4537#line 4538 "src/mesa/program/program_parse.tab.c"
4538    break;
4539
4540  case 264: /* optLegacyTexUnitNum: '[' legacyTexUnitNum ']'  */
4541#line 2010 "../src/mesa/program/program_parse.y"
4542                                   { (yyval.integer) = (yyvsp[-1].integer); }
4543#line 4544 "src/mesa/program/program_parse.tab.c"
4544    break;
4545
4546  case 265: /* texCoordUnitNum: INTEGER  */
4547#line 2014 "../src/mesa/program/program_parse.y"
4548        {
4549	   if ((unsigned) (yyvsp[0].integer) >= state->MaxTextureCoordUnits) {
4550	      yyerror(& (yylsp[0]), state, "invalid texture coordinate unit selector");
4551	      YYERROR;
4552	   }
4553
4554	   (yyval.integer) = (yyvsp[0].integer);
4555	}
4556#line 4557 "src/mesa/program/program_parse.tab.c"
4557    break;
4558
4559  case 266: /* texImageUnitNum: INTEGER  */
4560#line 2025 "../src/mesa/program/program_parse.y"
4561        {
4562	   if ((unsigned) (yyvsp[0].integer) >= state->MaxTextureImageUnits) {
4563	      yyerror(& (yylsp[0]), state, "invalid texture image unit selector");
4564	      YYERROR;
4565	   }
4566
4567	   (yyval.integer) = (yyvsp[0].integer);
4568	}
4569#line 4570 "src/mesa/program/program_parse.tab.c"
4570    break;
4571
4572  case 267: /* legacyTexUnitNum: INTEGER  */
4573#line 2036 "../src/mesa/program/program_parse.y"
4574        {
4575	   if ((unsigned) (yyvsp[0].integer) >= state->MaxTextureUnits) {
4576	      yyerror(& (yylsp[0]), state, "invalid texture unit selector");
4577	      YYERROR;
4578	   }
4579
4580	   (yyval.integer) = (yyvsp[0].integer);
4581	}
4582#line 4583 "src/mesa/program/program_parse.tab.c"
4583    break;
4584
4585  case 268: /* ALIAS_statement: ALIAS IDENTIFIER '=' USED_IDENTIFIER  */
4586#line 2047 "../src/mesa/program/program_parse.y"
4587        {
4588	   struct asm_symbol *exist = (struct asm_symbol *)
4589              _mesa_symbol_table_find_symbol(state->st, (yyvsp[-2].string));
4590	   struct asm_symbol *target = (struct asm_symbol *)
4591              _mesa_symbol_table_find_symbol(state->st, (yyvsp[0].string));
4592
4593	   free((yyvsp[0].string));
4594
4595	   if (exist != NULL) {
4596	      char m[1000];
4597	      snprintf(m, sizeof(m), "redeclared identifier: %s", (yyvsp[-2].string));
4598	      free((yyvsp[-2].string));
4599	      yyerror(& (yylsp[-2]), state, m);
4600	      YYERROR;
4601	   } else if (target == NULL) {
4602	      free((yyvsp[-2].string));
4603	      yyerror(& (yylsp[0]), state,
4604		      "undefined variable binding in ALIAS statement");
4605	      YYERROR;
4606	   } else {
4607              _mesa_symbol_table_add_symbol(state->st, (yyvsp[-2].string), target);
4608	   }
4609	}
4610#line 4611 "src/mesa/program/program_parse.tab.c"
4611    break;
4612
4613
4614#line 4615 "src/mesa/program/program_parse.tab.c"
4615
4616      default: break;
4617    }
4618  /* User semantic actions sometimes alter yychar, and that requires
4619     that yytoken be updated with the new translation.  We take the
4620     approach of translating immediately before every use of yytoken.
4621     One alternative is translating here after every semantic action,
4622     but that translation would be missed if the semantic action invokes
4623     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
4624     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
4625     incorrect destructor might then be invoked immediately.  In the
4626     case of YYERROR or YYBACKUP, subsequent parser actions might lead
4627     to an incorrect destructor call or verbose syntax error message
4628     before the lookahead is translated.  */
4629  YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
4630
4631  YYPOPSTACK (yylen);
4632  yylen = 0;
4633
4634  *++yyvsp = yyval;
4635  *++yylsp = yyloc;
4636
4637  /* Now 'shift' the result of the reduction.  Determine what state
4638     that goes to, based on the state we popped back to and the rule
4639     number reduced by.  */
4640  {
4641    const int yylhs = yyr1[yyn] - YYNTOKENS;
4642    const int yyi = yypgoto[yylhs] + *yyssp;
4643    yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
4644               ? yytable[yyi]
4645               : yydefgoto[yylhs]);
4646  }
4647
4648  goto yynewstate;
4649
4650
4651/*--------------------------------------.
4652| yyerrlab -- here on detecting error.  |
4653`--------------------------------------*/
4654yyerrlab:
4655  /* Make sure we have latest lookahead translation.  See comments at
4656     user semantic actions for why this is necessary.  */
4657  yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
4658  /* If not already recovering from an error, report this error.  */
4659  if (!yyerrstatus)
4660    {
4661      ++yynerrs;
4662      {
4663        yypcontext_t yyctx
4664          = {yyssp, yytoken, &yylloc};
4665        char const *yymsgp = YY_("syntax error");
4666        int yysyntax_error_status;
4667        yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
4668        if (yysyntax_error_status == 0)
4669          yymsgp = yymsg;
4670        else if (yysyntax_error_status == -1)
4671          {
4672            if (yymsg != yymsgbuf)
4673              YYSTACK_FREE (yymsg);
4674            yymsg = YY_CAST (char *,
4675                             YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
4676            if (yymsg)
4677              {
4678                yysyntax_error_status
4679                  = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
4680                yymsgp = yymsg;
4681              }
4682            else
4683              {
4684                yymsg = yymsgbuf;
4685                yymsg_alloc = sizeof yymsgbuf;
4686                yysyntax_error_status = YYENOMEM;
4687              }
4688          }
4689        yyerror (&yylloc, state, yymsgp);
4690        if (yysyntax_error_status == YYENOMEM)
4691          goto yyexhaustedlab;
4692      }
4693    }
4694
4695  yyerror_range[1] = yylloc;
4696  if (yyerrstatus == 3)
4697    {
4698      /* If just tried and failed to reuse lookahead token after an
4699         error, discard it.  */
4700
4701      if (yychar <= YYEOF)
4702        {
4703          /* Return failure if at end of input.  */
4704          if (yychar == YYEOF)
4705            YYABORT;
4706        }
4707      else
4708        {
4709          yydestruct ("Error: discarding",
4710                      yytoken, &yylval, &yylloc, state);
4711          yychar = YYEMPTY;
4712        }
4713    }
4714
4715  /* Else will try to reuse lookahead token after shifting the error
4716     token.  */
4717  goto yyerrlab1;
4718
4719
4720/*---------------------------------------------------.
4721| yyerrorlab -- error raised explicitly by YYERROR.  |
4722`---------------------------------------------------*/
4723yyerrorlab:
4724  /* Pacify compilers when the user code never invokes YYERROR and the
4725     label yyerrorlab therefore never appears in user code.  */
4726  if (0)
4727    YYERROR;
4728
4729  /* Do not reclaim the symbols of the rule whose action triggered
4730     this YYERROR.  */
4731  YYPOPSTACK (yylen);
4732  yylen = 0;
4733  YY_STACK_PRINT (yyss, yyssp);
4734  yystate = *yyssp;
4735  goto yyerrlab1;
4736
4737
4738/*-------------------------------------------------------------.
4739| yyerrlab1 -- common code for both syntax error and YYERROR.  |
4740`-------------------------------------------------------------*/
4741yyerrlab1:
4742  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
4743
4744  /* Pop stack until we find a state that shifts the error token.  */
4745  for (;;)
4746    {
4747      yyn = yypact[yystate];
4748      if (!yypact_value_is_default (yyn))
4749        {
4750          yyn += YYSYMBOL_YYerror;
4751          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
4752            {
4753              yyn = yytable[yyn];
4754              if (0 < yyn)
4755                break;
4756            }
4757        }
4758
4759      /* Pop the current state because it cannot handle the error token.  */
4760      if (yyssp == yyss)
4761        YYABORT;
4762
4763      yyerror_range[1] = *yylsp;
4764      yydestruct ("Error: popping",
4765                  YY_ACCESSING_SYMBOL (yystate), yyvsp, yylsp, state);
4766      YYPOPSTACK (1);
4767      yystate = *yyssp;
4768      YY_STACK_PRINT (yyss, yyssp);
4769    }
4770
4771  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
4772  *++yyvsp = yylval;
4773  YY_IGNORE_MAYBE_UNINITIALIZED_END
4774
4775  yyerror_range[2] = yylloc;
4776  ++yylsp;
4777  YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);
4778
4779  /* Shift the error token.  */
4780  YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
4781
4782  yystate = yyn;
4783  goto yynewstate;
4784
4785
4786/*-------------------------------------.
4787| yyacceptlab -- YYACCEPT comes here.  |
4788`-------------------------------------*/
4789yyacceptlab:
4790  yyresult = 0;
4791  goto yyreturn;
4792
4793
4794/*-----------------------------------.
4795| yyabortlab -- YYABORT comes here.  |
4796`-----------------------------------*/
4797yyabortlab:
4798  yyresult = 1;
4799  goto yyreturn;
4800
4801
4802#if 1
4803/*-------------------------------------------------.
4804| yyexhaustedlab -- memory exhaustion comes here.  |
4805`-------------------------------------------------*/
4806yyexhaustedlab:
4807  yyerror (&yylloc, state, YY_("memory exhausted"));
4808  yyresult = 2;
4809  goto yyreturn;
4810#endif
4811
4812
4813/*-------------------------------------------------------.
4814| yyreturn -- parsing is finished, clean up and return.  |
4815`-------------------------------------------------------*/
4816yyreturn:
4817  if (yychar != YYEMPTY)
4818    {
4819      /* Make sure we have latest lookahead translation.  See comments at
4820         user semantic actions for why this is necessary.  */
4821      yytoken = YYTRANSLATE (yychar);
4822      yydestruct ("Cleanup: discarding lookahead",
4823                  yytoken, &yylval, &yylloc, state);
4824    }
4825  /* Do not reclaim the symbols of the rule whose action triggered
4826     this YYABORT or YYACCEPT.  */
4827  YYPOPSTACK (yylen);
4828  YY_STACK_PRINT (yyss, yyssp);
4829  while (yyssp != yyss)
4830    {
4831      yydestruct ("Cleanup: popping",
4832                  YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yylsp, state);
4833      YYPOPSTACK (1);
4834    }
4835#ifndef yyoverflow
4836  if (yyss != yyssa)
4837    YYSTACK_FREE (yyss);
4838#endif
4839  if (yymsg != yymsgbuf)
4840    YYSTACK_FREE (yymsg);
4841  return yyresult;
4842}
4843
4844#line 2076 "../src/mesa/program/program_parse.y"
4845
4846
4847void
4848asm_instruction_set_operands(struct asm_instruction *inst,
4849			     const struct prog_dst_register *dst,
4850			     const struct asm_src_register *src0,
4851			     const struct asm_src_register *src1,
4852			     const struct asm_src_register *src2)
4853{
4854   /* In the core ARB extensions only the KIL instruction doesn't have a
4855    * destination register.
4856    */
4857   if (dst == NULL) {
4858      init_dst_reg(& inst->Base.DstReg);
4859   } else {
4860      inst->Base.DstReg = *dst;
4861   }
4862
4863   if (src0 != NULL) {
4864      inst->Base.SrcReg[0] = src0->Base;
4865      inst->SrcReg[0] = *src0;
4866   } else {
4867      init_src_reg(& inst->SrcReg[0]);
4868   }
4869
4870   if (src1 != NULL) {
4871      inst->Base.SrcReg[1] = src1->Base;
4872      inst->SrcReg[1] = *src1;
4873   } else {
4874      init_src_reg(& inst->SrcReg[1]);
4875   }
4876
4877   if (src2 != NULL) {
4878      inst->Base.SrcReg[2] = src2->Base;
4879      inst->SrcReg[2] = *src2;
4880   } else {
4881      init_src_reg(& inst->SrcReg[2]);
4882   }
4883}
4884
4885
4886struct asm_instruction *
4887asm_instruction_ctor(enum prog_opcode op,
4888		     const struct prog_dst_register *dst,
4889		     const struct asm_src_register *src0,
4890		     const struct asm_src_register *src1,
4891		     const struct asm_src_register *src2)
4892{
4893   struct asm_instruction *inst = CALLOC_STRUCT(asm_instruction);
4894
4895   if (inst) {
4896      _mesa_init_instructions(& inst->Base, 1);
4897      inst->Base.Opcode = op;
4898
4899      asm_instruction_set_operands(inst, dst, src0, src1, src2);
4900   }
4901
4902   return inst;
4903}
4904
4905
4906struct asm_instruction *
4907asm_instruction_copy_ctor(const struct prog_instruction *base,
4908			  const struct prog_dst_register *dst,
4909			  const struct asm_src_register *src0,
4910			  const struct asm_src_register *src1,
4911			  const struct asm_src_register *src2)
4912{
4913   struct asm_instruction *inst = CALLOC_STRUCT(asm_instruction);
4914
4915   if (inst) {
4916      _mesa_init_instructions(& inst->Base, 1);
4917      inst->Base.Opcode = base->Opcode;
4918      inst->Base.Saturate = base->Saturate;
4919
4920      asm_instruction_set_operands(inst, dst, src0, src1, src2);
4921   }
4922
4923   return inst;
4924}
4925
4926
4927void
4928init_dst_reg(struct prog_dst_register *r)
4929{
4930   memset(r, 0, sizeof(*r));
4931   r->File = PROGRAM_UNDEFINED;
4932   r->WriteMask = WRITEMASK_XYZW;
4933}
4934
4935
4936/** Like init_dst_reg() but set the File and Index fields. */
4937void
4938set_dst_reg(struct prog_dst_register *r, gl_register_file file, GLint index)
4939{
4940   const GLint maxIndex = 1 << INST_INDEX_BITS;
4941   const GLint minIndex = 0;
4942   assert(index >= minIndex);
4943   (void) minIndex;
4944   assert(index <= maxIndex);
4945   (void) maxIndex;
4946   assert(file == PROGRAM_TEMPORARY ||
4947	  file == PROGRAM_ADDRESS ||
4948	  file == PROGRAM_OUTPUT);
4949   memset(r, 0, sizeof(*r));
4950   r->File = file;
4951   r->Index = index;
4952   r->WriteMask = WRITEMASK_XYZW;
4953}
4954
4955
4956void
4957init_src_reg(struct asm_src_register *r)
4958{
4959   memset(r, 0, sizeof(*r));
4960   r->Base.File = PROGRAM_UNDEFINED;
4961   r->Base.Swizzle = SWIZZLE_NOOP;
4962   r->Symbol = NULL;
4963}
4964
4965
4966/** Like init_src_reg() but set the File and Index fields.
4967 * \return GL_TRUE if a valid src register, GL_FALSE otherwise
4968 */
4969void
4970set_src_reg(struct asm_src_register *r, gl_register_file file, GLint index)
4971{
4972   set_src_reg_swz(r, file, index, SWIZZLE_XYZW);
4973}
4974
4975
4976void
4977set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index,
4978                GLuint swizzle)
4979{
4980   const GLint maxIndex = (1 << INST_INDEX_BITS) - 1;
4981   const GLint minIndex = -(1 << INST_INDEX_BITS);
4982   assert(file < PROGRAM_FILE_MAX);
4983   assert(index >= minIndex);
4984   (void) minIndex;
4985   assert(index <= maxIndex);
4986   (void) maxIndex;
4987   memset(r, 0, sizeof(*r));
4988   r->Base.File = file;
4989   r->Base.Index = index;
4990   r->Base.Swizzle = swizzle;
4991   r->Symbol = NULL;
4992}
4993
4994
4995/**
4996 * Validate the set of inputs used by a program
4997 *
4998 * Validates that legal sets of inputs are used by the program.  In this case
4999 * "used" included both reading the input or binding the input to a name using
5000 * the \c ATTRIB command.
5001 *
5002 * \return
5003 * \c TRUE if the combination of inputs used is valid, \c FALSE otherwise.
5004 */
5005int
5006validate_inputs(struct YYLTYPE *locp, struct asm_parser_state *state)
5007{
5008   const GLbitfield64 inputs = state->prog->info.inputs_read | state->InputsBound;
5009   GLbitfield ff_inputs = 0;
5010
5011   /* Since Mesa internal attribute indices are different from
5012    * how NV_vertex_program defines attribute aliasing, we have to construct
5013    * a separate usage mask based on how the aliasing is defined.
5014    *
5015    * Note that attribute aliasing is optional if NV_vertex_program is
5016    * unsupported.
5017    */
5018   if (inputs & VERT_BIT_POS)
5019      ff_inputs |= 1 << 0;
5020   if (inputs & VERT_BIT_NORMAL)
5021      ff_inputs |= 1 << 2;
5022   if (inputs & VERT_BIT_COLOR0)
5023      ff_inputs |= 1 << 3;
5024   if (inputs & VERT_BIT_COLOR1)
5025      ff_inputs |= 1 << 4;
5026   if (inputs & VERT_BIT_FOG)
5027      ff_inputs |= 1 << 5;
5028
5029   ff_inputs |= ((inputs & VERT_BIT_TEX_ALL) >> VERT_ATTRIB_TEX0) << 8;
5030
5031   if ((ff_inputs & (inputs >> VERT_ATTRIB_GENERIC0)) != 0) {
5032      yyerror(locp, state, "illegal use of generic attribute and name attribute");
5033      return 0;
5034   }
5035
5036   return 1;
5037}
5038
5039
5040struct asm_symbol *
5041declare_variable(struct asm_parser_state *state, char *name, enum asm_type t,
5042		 struct YYLTYPE *locp)
5043{
5044   struct asm_symbol *s = NULL;
5045   struct asm_symbol *exist = (struct asm_symbol *)
5046      _mesa_symbol_table_find_symbol(state->st, name);
5047
5048
5049   if (exist != NULL) {
5050      yyerror(locp, state, "redeclared identifier");
5051   } else {
5052      s = calloc(1, sizeof(struct asm_symbol));
5053      s->name = name;
5054      s->type = t;
5055
5056      switch (t) {
5057      case at_temp:
5058         if (state->prog->arb.NumTemporaries >= state->limits->MaxTemps) {
5059	    yyerror(locp, state, "too many temporaries declared");
5060	    free(s);
5061	    return NULL;
5062	 }
5063
5064         s->temp_binding = state->prog->arb.NumTemporaries;
5065         state->prog->arb.NumTemporaries++;
5066	 break;
5067
5068      case at_address:
5069         if (state->prog->arb.NumAddressRegs >=
5070             state->limits->MaxAddressRegs) {
5071	    yyerror(locp, state, "too many address registers declared");
5072	    free(s);
5073	    return NULL;
5074	 }
5075
5076	 /* FINISHME: Add support for multiple address registers.
5077	  */
5078         state->prog->arb.NumAddressRegs++;
5079	 break;
5080
5081      default:
5082	 break;
5083      }
5084
5085      _mesa_symbol_table_add_symbol(state->st, s->name, s);
5086      s->next = state->sym;
5087      state->sym = s;
5088   }
5089
5090   return s;
5091}
5092
5093
5094int add_state_reference(struct gl_program_parameter_list *param_list,
5095			const gl_state_index16 tokens[STATE_LENGTH])
5096{
5097   const GLuint size = 4; /* XXX fix */
5098   char *name;
5099   GLint index;
5100
5101   name = _mesa_program_state_string(tokens);
5102   index = _mesa_add_parameter(param_list, PROGRAM_STATE_VAR, name,
5103                               size, GL_NONE, NULL, tokens, true);
5104   param_list->StateFlags |= _mesa_program_state_flags(tokens);
5105
5106   /* free name string here since we duplicated it in add_parameter() */
5107   free(name);
5108
5109   return index;
5110}
5111
5112
5113int
5114initialize_symbol_from_state(struct gl_program *prog,
5115			     struct asm_symbol *param_var,
5116			     const gl_state_index16 tokens[STATE_LENGTH])
5117{
5118   int idx = -1;
5119   gl_state_index16 state_tokens[STATE_LENGTH];
5120
5121
5122   memcpy(state_tokens, tokens, sizeof(state_tokens));
5123
5124   param_var->type = at_param;
5125   param_var->param_binding_type = PROGRAM_STATE_VAR;
5126
5127   /* If we are adding a STATE_MATRIX that has multiple rows, we need to
5128    * unroll it and call add_state_reference() for each row
5129    */
5130   if (state_tokens[0] >= STATE_MODELVIEW_MATRIX &&
5131       state_tokens[0] <= STATE_PROGRAM_MATRIX_INVTRANS
5132       && (state_tokens[2] != state_tokens[3])) {
5133      int row;
5134      const int first_row = state_tokens[2];
5135      const int last_row = state_tokens[3];
5136
5137      for (row = first_row; row <= last_row; row++) {
5138	 state_tokens[2] = state_tokens[3] = row;
5139
5140	 idx = add_state_reference(prog->Parameters, state_tokens);
5141	 if (param_var->param_binding_begin == ~0U) {
5142	    param_var->param_binding_begin = idx;
5143            param_var->param_binding_swizzle = SWIZZLE_XYZW;
5144         }
5145
5146	 param_var->param_binding_length++;
5147      }
5148   }
5149   else {
5150      idx = add_state_reference(prog->Parameters, state_tokens);
5151      if (param_var->param_binding_begin == ~0U) {
5152	 param_var->param_binding_begin = idx;
5153         param_var->param_binding_swizzle = SWIZZLE_XYZW;
5154      }
5155      param_var->param_binding_length++;
5156   }
5157
5158   return idx;
5159}
5160
5161
5162int
5163initialize_symbol_from_param(struct gl_program *prog,
5164			     struct asm_symbol *param_var,
5165			     const gl_state_index16 tokens[STATE_LENGTH])
5166{
5167   int idx = -1;
5168   gl_state_index16 state_tokens[STATE_LENGTH];
5169
5170
5171   memcpy(state_tokens, tokens, sizeof(state_tokens));
5172
5173   assert(state_tokens[0] == STATE_VERTEX_PROGRAM_ENV ||
5174          state_tokens[0] == STATE_VERTEX_PROGRAM_LOCAL ||
5175          state_tokens[0] == STATE_FRAGMENT_PROGRAM_ENV ||
5176          state_tokens[0] == STATE_FRAGMENT_PROGRAM_LOCAL);
5177
5178   /*
5179    * The param type is STATE_VAR.  The program parameter entry will
5180    * effectively be a pointer into the LOCAL or ENV parameter array.
5181    */
5182   param_var->type = at_param;
5183   param_var->param_binding_type = PROGRAM_STATE_VAR;
5184
5185   /* If we are adding a STATE_ENV or STATE_LOCAL that has multiple elements,
5186    * we need to unroll it and call add_state_reference() for each row
5187    */
5188   if (state_tokens[1] != state_tokens[2]) {
5189      int row;
5190      const int first_row = state_tokens[1];
5191      const int last_row = state_tokens[2];
5192
5193      for (row = first_row; row <= last_row; row++) {
5194	 state_tokens[1] = state_tokens[2] = row;
5195
5196	 idx = add_state_reference(prog->Parameters, state_tokens);
5197	 if (param_var->param_binding_begin == ~0U) {
5198	    param_var->param_binding_begin = idx;
5199            param_var->param_binding_swizzle = SWIZZLE_XYZW;
5200         }
5201	 param_var->param_binding_length++;
5202      }
5203   }
5204   else {
5205      idx = add_state_reference(prog->Parameters, state_tokens);
5206      if (param_var->param_binding_begin == ~0U) {
5207	 param_var->param_binding_begin = idx;
5208         param_var->param_binding_swizzle = SWIZZLE_XYZW;
5209      }
5210      param_var->param_binding_length++;
5211   }
5212
5213   return idx;
5214}
5215
5216
5217/**
5218 * Put a float/vector constant/literal into the parameter list.
5219 * \param param_var  returns info about the parameter/constant's location,
5220 *                   binding, type, etc.
5221 * \param vec  the vector/constant to add
5222 * \param allowSwizzle  if true, try to consolidate constants which only differ
5223 *                      by a swizzle.  We don't want to do this when building
5224 *                      arrays of constants that may be indexed indirectly.
5225 * \return index of the constant in the parameter list.
5226 */
5227int
5228initialize_symbol_from_const(struct gl_program *prog,
5229			     struct asm_symbol *param_var,
5230			     const struct asm_vector *vec,
5231                             GLboolean allowSwizzle)
5232{
5233   unsigned swizzle;
5234   const int idx = _mesa_add_unnamed_constant(prog->Parameters,
5235                                              vec->data, vec->count,
5236                                              allowSwizzle ? &swizzle : NULL);
5237
5238   param_var->type = at_param;
5239   param_var->param_binding_type = PROGRAM_CONSTANT;
5240
5241   if (param_var->param_binding_begin == ~0U) {
5242      param_var->param_binding_begin = idx;
5243      param_var->param_binding_swizzle = allowSwizzle ? swizzle : SWIZZLE_XYZW;
5244   }
5245   param_var->param_binding_length++;
5246
5247   return idx;
5248}
5249
5250
5251char *
5252make_error_string(const char *fmt, ...)
5253{
5254   int length;
5255   char *str;
5256   va_list args;
5257
5258
5259   /* Call vsnprintf once to determine how large the final string is.  Call it
5260    * again to do the actual formatting.  from the vsnprintf manual page:
5261    *
5262    *    Upon successful return, these functions return the number of
5263    *    characters printed  (not including the trailing '\0' used to end
5264    *    output to strings).
5265    */
5266   va_start(args, fmt);
5267   length = 1 + vsnprintf(NULL, 0, fmt, args);
5268   va_end(args);
5269
5270   str = malloc(length);
5271   if (str) {
5272      va_start(args, fmt);
5273      vsnprintf(str, length, fmt, args);
5274      va_end(args);
5275   }
5276
5277   return str;
5278}
5279
5280
5281void
5282yyerror(YYLTYPE *locp, struct asm_parser_state *state, const char *s)
5283{
5284   char *err_str;
5285
5286
5287   err_str = make_error_string("glProgramStringARB(%s)\n", s);
5288   if (err_str) {
5289      _mesa_error(state->ctx, GL_INVALID_OPERATION, "%s", err_str);
5290      free(err_str);
5291   }
5292
5293   err_str = make_error_string("line %u, char %u: error: %s\n",
5294			       locp->first_line, locp->first_column, s);
5295   _mesa_set_program_error(state->ctx, locp->position, err_str);
5296
5297   if (err_str) {
5298      free(err_str);
5299   }
5300}
5301
5302
5303GLboolean
5304_mesa_parse_arb_program(struct gl_context *ctx, GLenum target, const GLubyte *str,
5305			GLsizei len, struct asm_parser_state *state)
5306{
5307   struct asm_instruction *inst;
5308   unsigned i;
5309   GLubyte *strz;
5310   GLboolean result = GL_FALSE;
5311   void *temp;
5312   struct asm_symbol *sym;
5313
5314   state->ctx = ctx;
5315   state->prog->Target = target;
5316   state->prog->Parameters = _mesa_new_parameter_list();
5317
5318   /* Make a copy of the program string and force it to be NUL-terminated.
5319    */
5320   strz = (GLubyte *) ralloc_size(state->mem_ctx, len + 1);
5321   if (strz == NULL) {
5322      if (state->prog->Parameters) {
5323         _mesa_free_parameter_list(state->prog->Parameters);
5324         state->prog->Parameters = NULL;
5325      }
5326      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
5327      return GL_FALSE;
5328   }
5329   memcpy (strz, str, len);
5330   strz[len] = '\0';
5331
5332   state->prog->String = strz;
5333
5334   state->st = _mesa_symbol_table_ctor();
5335
5336   state->limits = (target == GL_VERTEX_PROGRAM_ARB)
5337      ? & ctx->Const.Program[MESA_SHADER_VERTEX]
5338      : & ctx->Const.Program[MESA_SHADER_FRAGMENT];
5339
5340   state->MaxTextureImageUnits = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits;
5341   state->MaxTextureCoordUnits = ctx->Const.MaxTextureCoordUnits;
5342   state->MaxTextureUnits = ctx->Const.MaxTextureUnits;
5343   state->MaxClipPlanes = ctx->Const.MaxClipPlanes;
5344   state->MaxLights = ctx->Const.MaxLights;
5345   state->MaxProgramMatrices = ctx->Const.MaxProgramMatrices;
5346   state->MaxDrawBuffers = ctx->Const.MaxDrawBuffers;
5347
5348   state->state_param_enum_env = (target == GL_VERTEX_PROGRAM_ARB)
5349      ? STATE_VERTEX_PROGRAM_ENV : STATE_FRAGMENT_PROGRAM_ENV;
5350   state->state_param_enum_local = (target == GL_VERTEX_PROGRAM_ARB)
5351      ? STATE_VERTEX_PROGRAM_LOCAL : STATE_FRAGMENT_PROGRAM_LOCAL;
5352
5353   _mesa_set_program_error(ctx, -1, NULL);
5354
5355   _mesa_program_lexer_ctor(& state->scanner, state, (const char *) str, len);
5356   yyparse(state);
5357   _mesa_program_lexer_dtor(state->scanner);
5358
5359
5360   if (ctx->Program.ErrorPos != -1) {
5361      goto error;
5362   }
5363
5364   if (! _mesa_layout_parameters(state)) {
5365      struct YYLTYPE loc;
5366
5367      loc.first_line = 0;
5368      loc.first_column = 0;
5369      loc.position = len;
5370
5371      yyerror(& loc, state, "invalid PARAM usage");
5372      goto error;
5373   }
5374
5375
5376
5377   /* Add one instruction to store the "END" instruction.
5378    */
5379   state->prog->arb.Instructions =
5380      rzalloc_array(state->mem_ctx, struct prog_instruction,
5381                    state->prog->arb.NumInstructions + 1);
5382
5383   if (state->prog->arb.Instructions == NULL) {
5384      goto error;
5385   }
5386
5387   inst = state->inst_head;
5388   for (i = 0; i < state->prog->arb.NumInstructions; i++) {
5389      struct asm_instruction *const temp = inst->next;
5390
5391      state->prog->arb.Instructions[i] = inst->Base;
5392      inst = temp;
5393   }
5394
5395   /* Finally, tag on an OPCODE_END instruction */
5396   {
5397      const GLuint numInst = state->prog->arb.NumInstructions;
5398      _mesa_init_instructions(state->prog->arb.Instructions + numInst, 1);
5399      state->prog->arb.Instructions[numInst].Opcode = OPCODE_END;
5400   }
5401   state->prog->arb.NumInstructions++;
5402
5403   state->prog->arb.NumParameters = state->prog->Parameters->NumParameters;
5404   state->prog->arb.NumAttributes =
5405      util_bitcount64(state->prog->info.inputs_read);
5406
5407   /*
5408    * Initialize native counts to logical counts.  The device driver may
5409    * change them if program is translated into a hardware program.
5410    */
5411   state->prog->arb.NumNativeInstructions = state->prog->arb.NumInstructions;
5412   state->prog->arb.NumNativeTemporaries = state->prog->arb.NumTemporaries;
5413   state->prog->arb.NumNativeParameters = state->prog->arb.NumParameters;
5414   state->prog->arb.NumNativeAttributes = state->prog->arb.NumAttributes;
5415   state->prog->arb.NumNativeAddressRegs = state->prog->arb.NumAddressRegs;
5416
5417   result = GL_TRUE;
5418
5419error:
5420   for (inst = state->inst_head; inst != NULL; inst = temp) {
5421      temp = inst->next;
5422      free(inst);
5423   }
5424
5425   state->inst_head = NULL;
5426   state->inst_tail = NULL;
5427
5428   for (sym = state->sym; sym != NULL; sym = temp) {
5429      temp = sym->next;
5430
5431      free((void *) sym->name);
5432      free(sym);
5433   }
5434   state->sym = NULL;
5435
5436   _mesa_symbol_table_dtor(state->st);
5437   state->st = NULL;
5438
5439   if (result != GL_TRUE) {
5440      if (state->prog->Parameters) {
5441         _mesa_free_parameter_list(state->prog->Parameters);
5442         state->prog->Parameters = NULL;
5443      }
5444      ralloc_free(state->prog->String);
5445      state->prog->String = NULL;
5446   }
5447
5448   return result;
5449}
5450