Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/RenderSystems/GL/src/nvparse/_vs1.0_parser.cpp @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

File size: 48.3 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2006 Torus Knot Software Ltd
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29/* A Bison parser, made by GNU Bison 1.875.  */
30
31/* Skeleton parser for Yacc-like parsing with Bison,
32   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
33
34   This program is free software; you can redistribute it and/or modify
35   it under the terms of the GNU General Public License as published by
36   the Free Software Foundation; either version 2, or (at your option)
37   any later version.
38
39   This program is distributed in the hope that it will be useful,
40   but WITHOUT ANY WARRANTY; without even the implied warranty of
41   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
42   GNU General Public License for more details.
43
44   You should have received a copy of the GNU General Public License
45   along with this program; if not, write to the Free Software
46   Foundation, Inc., 59 Temple Place - Suite 330,
47   Boston, MA 02111-1307, USA.  */
48
49/* As a special exception, when this file is copied by Bison into a
50   Bison output file, you may use that output file without restriction.
51   This special exception was added by the Free Software Foundation
52   in version 1.24 of Bison.  */
53
54/* Written by Richard Stallman by simplifying the original so called
55   ``semantic'' parser.  */
56
57/* All symbols defined below should begin with yy or YY, to avoid
58   infringing on user name space.  This should be done even for local
59   variables, as they might otherwise be expanded by user macros.
60   There are some unavoidable exceptions within include files to
61   define necessary library symbols; they are noted "INFRINGES ON
62   USER NAME SPACE" below.  */
63
64/* Identify Bison output.  */
65#define YYBISON 1
66
67/* Skeleton name.  */
68#define YYSKELETON_NAME "yacc.c"
69
70/* Pure parsers.  */
71#define YYPURE 0
72
73/* Using locations.  */
74#define YYLSP_NEEDED 0
75
76/* If NAME_PREFIX is specified substitute the variables and functions
77   names.  */
78#define yyparse vs10_parse
79#define yylex   vs10_lex
80#define yyerror vs10_error
81#define yylval  vs10_lval
82#define yychar  vs10_char
83#define yydebug vs10_debug
84#define yynerrs vs10_nerrs
85
86
87/* Tokens.  */
88#ifndef YYTOKENTYPE
89# define YYTOKENTYPE
90   /* Put the tokens into the symbol table, so that GDB and other debuggers
91      know about them.  */
92   enum yytokentype {
93     VERTEX_SHADER = 258,
94     ADD_INSTR = 259,
95     DP3_INSTR = 260,
96     DP4_INSTR = 261,
97     DST_INSTR = 262,
98     EXP_INSTR = 263,
99     EXPP_INSTR = 264,
100     FRC_INSTR = 265,
101     LIT_INSTR = 266,
102     LOG_INSTR = 267,
103     LOGP_INSTR = 268,
104     M3X2_INSTR = 269,
105     M3X3_INSTR = 270,
106     M3X4_INSTR = 271,
107     M4X3_INSTR = 272,
108     M4X4_INSTR = 273,
109     MAD_INSTR = 274,
110     MAX_INSTR = 275,
111     MIN_INSTR = 276,
112     MOV_INSTR = 277,
113     MUL_INSTR = 278,
114     NOP_INSTR = 279,
115     RCP_INSTR = 280,
116     RSQ_INSTR = 281,
117     SGE_INSTR = 282,
118     SLT_INSTR = 283,
119     SUB_INSTR = 284,
120     ILLEGAL = 285,
121     UNKNOWN_STRING = 286,
122     INTVAL = 287,
123     REGISTER = 288,
124     XYZW_MODIFIER = 289,
125     COMMENT = 290
126   };
127#endif
128#define VERTEX_SHADER 258
129#define ADD_INSTR 259
130#define DP3_INSTR 260
131#define DP4_INSTR 261
132#define DST_INSTR 262
133#define EXP_INSTR 263
134#define EXPP_INSTR 264
135#define FRC_INSTR 265
136#define LIT_INSTR 266
137#define LOG_INSTR 267
138#define LOGP_INSTR 268
139#define M3X2_INSTR 269
140#define M3X3_INSTR 270
141#define M3X4_INSTR 271
142#define M4X3_INSTR 272
143#define M4X4_INSTR 273
144#define MAD_INSTR 274
145#define MAX_INSTR 275
146#define MIN_INSTR 276
147#define MOV_INSTR 277
148#define MUL_INSTR 278
149#define NOP_INSTR 279
150#define RCP_INSTR 280
151#define RSQ_INSTR 281
152#define SGE_INSTR 282
153#define SLT_INSTR 283
154#define SUB_INSTR 284
155#define ILLEGAL 285
156#define UNKNOWN_STRING 286
157#define INTVAL 287
158#define REGISTER 288
159#define XYZW_MODIFIER 289
160#define COMMENT 290
161
162
163
164
165/* Copy the first part of user declarations.  */
166#line 3 "vs1.0_grammar.y"
167
168void yyerror(char *s);
169int yylex(void);
170
171#include <math.h>
172#include <string>
173
174#include <stdlib.h>
175#include "vs1.0_inst_list.h"
176#include "nvparse_errors.h"
177#include "nvparse_externs.h"
178
179//extern bool gbTempInsideMacro;
180//extern unsigned int &base_linenumber;
181void LexError(char *format, ...);
182extern int line_incr;
183
184#define do_linenum_incr()               { line_number+=line_incr; line_incr = 0; }
185//int get_linenum()                     { return( gbTempInsideMacro ? base_linenumber : line_number ); }
186int get_linenum()                       { return( line_number ); }
187
188#define YYDEBUG 1
189
190
191
192/* Enabling traces.  */
193#ifndef YYDEBUG
194# define YYDEBUG 0
195#endif
196
197/* Enabling verbose error messages.  */
198#ifdef YYERROR_VERBOSE
199# undef YYERROR_VERBOSE
200# define YYERROR_VERBOSE 1
201#else
202# define YYERROR_VERBOSE 0
203#endif
204
205#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
206#line 27 "vs1.0_grammar.y"
207typedef union YYSTYPE {
208  int ival;
209  unsigned int lval;
210  float fval;
211  char mask[4];
212  char *comment;
213  VS10Reg reg;
214  VS10InstPtr inst;
215  VS10InstListPtr instList;
216} YYSTYPE;
217/* Line 191 of yacc.c.  */
218#line 190 "_vs1.0_parser.c"
219# define yystype YYSTYPE /* obsolescent; will be withdrawn */
220# define YYSTYPE_IS_DECLARED 1
221# define YYSTYPE_IS_TRIVIAL 1
222#endif
223
224
225
226/* Copy the second part of user declarations.  */
227
228
229/* Line 214 of yacc.c.  */
230#line 202 "_vs1.0_parser.c"
231
232#if ! defined (yyoverflow) || YYERROR_VERBOSE
233
234/* The parser invokes alloca or malloc; define the necessary symbols.  */
235
236# if YYSTACK_USE_ALLOCA
237#  define YYSTACK_ALLOC alloca
238# else
239#  ifndef YYSTACK_USE_ALLOCA
240#   if defined (alloca) || defined (_ALLOCA_H)
241#    define YYSTACK_ALLOC alloca
242#   else
243#    ifdef __GNUC__
244#     define YYSTACK_ALLOC __builtin_alloca
245#    endif
246#   endif
247#  endif
248# endif
249
250# ifdef YYSTACK_ALLOC
251   /* Pacify GCC's `empty if-body' warning. */
252#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
253# else
254#  if defined (__STDC__) || defined (__cplusplus)
255#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
256#   define YYSIZE_T size_t
257#  endif
258#  define YYSTACK_ALLOC malloc
259#  define YYSTACK_FREE free
260# endif
261#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
262
263
264#if (! defined (yyoverflow) \
265     && (! defined (__cplusplus) \
266         || (YYSTYPE_IS_TRIVIAL)))
267
268/* A type that is properly aligned for any stack member.  */
269union yyalloc
270{
271  short yyss;
272  YYSTYPE yyvs;
273  };
274
275/* The size of the maximum gap between one aligned stack and the next.  */
276# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
277
278/* The size of an array large to enough to hold all stacks, each with
279   N elements.  */
280# define YYSTACK_BYTES(N) \
281     ((N) * (sizeof (short) + sizeof (YYSTYPE))                         \
282      + YYSTACK_GAP_MAXIMUM)
283
284/* Copy COUNT objects from FROM to TO.  The source and destination do
285   not overlap.  */
286# ifndef YYCOPY
287#  if 1 < __GNUC__
288#   define YYCOPY(To, From, Count) \
289      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
290#  else
291#   define YYCOPY(To, From, Count)              \
292      do                                        \
293        {                                       \
294          register YYSIZE_T yyi;                \
295          for (yyi = 0; yyi < (Count); yyi++)   \
296            (To)[yyi] = (From)[yyi];            \
297        }                                       \
298      while (0)
299#  endif
300# endif
301
302/* Relocate STACK from its old location to the new one.  The
303   local variables YYSIZE and YYSTACKSIZE give the old and new number of
304   elements in the stack, and YYPTR gives the new location of the
305   stack.  Advance YYPTR to a properly aligned location for the next
306   stack.  */
307# define YYSTACK_RELOCATE(Stack)                                        \
308    do                                                                  \
309      {                                                                 \
310        YYSIZE_T yynewbytes;                                            \
311        YYCOPY (&yyptr->Stack, Stack, yysize);                          \
312        Stack = &yyptr->Stack;                                          \
313        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
314        yyptr += yynewbytes / sizeof (*yyptr);                          \
315      }                                                                 \
316    while (0)
317
318#endif
319
320#if defined (__STDC__) || defined (__cplusplus)
321   typedef signed char yysigned_char;
322#else
323   typedef short yysigned_char;
324#endif
325
326/* YYFINAL -- State number of the termination state. */
327#define YYFINAL  44
328/* YYLAST -- Last index in YYTABLE.  */
329#define YYLAST   88
330
331/* YYNTOKENS -- Number of terminals. */
332#define YYNTOKENS  44
333/* YYNNTS -- Number of nonterminals. */
334#define YYNNTS  18
335/* YYNRULES -- Number of rules. */
336#define YYNRULES  59
337/* YYNRULES -- Number of states. */
338#define YYNSTATES  103
339
340/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
341#define YYUNDEFTOK  2
342#define YYMAXUTOK   290
343
344#define YYTRANSLATE(YYX)                                                \
345  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
346
347/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
348static const unsigned char yytranslate[] =
349{
350       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
351      36,     2,     2,     2,     2,     2,     2,     2,     2,     2,
352       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
353       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
354       2,     2,     2,    43,    37,    38,    39,     2,     2,     2,
355       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
356       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
357       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
358       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
359       2,    41,     2,    42,     2,     2,     2,     2,     2,    40,
360       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
361       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
362       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
363       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
364       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
365       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
366       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
367       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
368       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
369       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
370       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
371       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
372       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
373       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
374       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
375       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
376       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
377      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
378      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
379      35
380};
381
382#if YYDEBUG
383/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
384   YYRHS.  */
385static const unsigned char yyprhs[] =
386{
387       0,     0,     3,     5,     8,    10,    12,    14,    16,    18,
388      20,    22,    24,    26,    28,    30,    35,    40,    44,    47,
389      49,    51,    53,    58,    65,    74,    79,    86,    92,   100,
390     108,   118,   123,   128,   135,   144,   146,   148,   150,   152,
391     154,   156,   158,   160,   162,   164,   166,   168,   170,   172,
392     174,   176,   178,   180,   182,   184,   186,   188,   190,   192
393};
394
395/* YYRHS -- A `-1'-separated list of the rules' RHS. */
396static const yysigned_char yyrhs[] =
397{
398      45,     0,    -1,    46,    -1,    46,    47,    -1,    47,    -1,
399      48,    -1,    36,    -1,    49,    -1,    53,    -1,    54,    -1,
400      55,    -1,    56,    -1,    24,    -1,    35,    -1,     3,    -1,
401      57,    50,    37,    50,    -1,    38,    51,    39,    34,    -1,
402      51,    39,    34,    -1,    38,    51,    -1,    51,    -1,    33,
403      -1,    52,    -1,    40,    41,    32,    42,    -1,    40,    41,
404      33,    39,    34,    42,    -1,    40,    41,    33,    39,    34,
405      43,    32,    42,    -1,    40,    41,    33,    42,    -1,    40,
406      41,    33,    43,    32,    42,    -1,    40,    41,    38,    33,
407      42,    -1,    40,    41,    38,    33,    43,    32,    42,    -1,
408      40,    41,    38,    33,    39,    34,    42,    -1,    40,    41,
409      38,    33,    39,    34,    43,    32,    42,    -1,    58,    50,
410      37,    50,    -1,    59,    50,    37,    50,    -1,    60,    50,
411      37,    50,    37,    50,    -1,    61,    50,    37,    50,    37,
412      50,    37,    50,    -1,    22,    -1,    11,    -1,    25,    -1,
413      26,    -1,     8,    -1,     9,    -1,    12,    -1,    13,    -1,
414      10,    -1,    23,    -1,     4,    -1,     5,    -1,     6,    -1,
415       7,    -1,    21,    -1,    20,    -1,    28,    -1,    27,    -1,
416      14,    -1,    15,    -1,    16,    -1,    17,    -1,    18,    -1,
417      29,    -1,    19,    -1
418};
419
420/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
421static const unsigned short yyrline[] =
422{
423       0,    96,    96,   104,   110,   122,   127,   134,   135,   136,
424     137,   138,   139,   143,   147,   153,   159,   169,   179,   189,
425     200,   200,   204,   211,   246,   282,   287,   292,   297,   302,
426     307,   314,   320,   326,   332,   339,   343,   349,   353,   357,
427     361,   365,   369,   375,   381,   385,   389,   393,   397,   401,
428     405,   409,   413,   417,   421,   425,   429,   433,   437,   443
429};
430#endif
431
432#if YYDEBUG || YYERROR_VERBOSE
433/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
434   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
435static const char *const yytname[] =
436{
437  "$end", "error", "$undefined", "VERTEX_SHADER", "ADD_INSTR", "DP3_INSTR", 
438  "DP4_INSTR", "DST_INSTR", "EXP_INSTR", "EXPP_INSTR", "FRC_INSTR", 
439  "LIT_INSTR", "LOG_INSTR", "LOGP_INSTR", "M3X2_INSTR", "M3X3_INSTR", 
440  "M3X4_INSTR", "M4X3_INSTR", "M4X4_INSTR", "MAD_INSTR", "MAX_INSTR", 
441  "MIN_INSTR", "MOV_INSTR", "MUL_INSTR", "NOP_INSTR", "RCP_INSTR", 
442  "RSQ_INSTR", "SGE_INSTR", "SLT_INSTR", "SUB_INSTR", "ILLEGAL", 
443  "UNKNOWN_STRING", "INTVAL", "REGISTER", "XYZW_MODIFIER", "COMMENT", 
444  "'\\n'", "','", "'-'", "'.'", "'c'", "'['", "']'", "'+'", "$accept", 
445  "VS10Program", "InstSequence", "InstLine", "Instruction", 
446  "VECTORopinstruction", "genericReg", "genReg", "constantReg", 
447  "SCALARopinstruction", "UNARYopinstruction", "BINopinstruction", 
448  "TRIopinstruction", "VECTORop", "SCALARop", "UNARYop", "BINop", "TRIop", 0
449};
450#endif
451
452# ifdef YYPRINT
453/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
454   token YYLEX-NUM.  */
455static const unsigned short yytoknum[] =
456{
457       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
458     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
459     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
460     285,   286,   287,   288,   289,   290,    10,    44,    45,    46,
461      99,    91,    93,    43
462};
463# endif
464
465/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
466static const unsigned char yyr1[] =
467{
468       0,    44,    45,    46,    46,    47,    47,    48,    48,    48,
469      48,    48,    48,    48,    48,    49,    50,    50,    50,    50,
470      51,    51,    52,    52,    52,    52,    52,    52,    52,    52,
471      52,    53,    54,    55,    56,    57,    57,    58,    58,    58,
472      58,    58,    58,    59,    60,    60,    60,    60,    60,    60,
473      60,    60,    60,    60,    60,    60,    60,    60,    60,    61
474};
475
476/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
477static const unsigned char yyr2[] =
478{
479       0,     2,     1,     2,     1,     1,     1,     1,     1,     1,
480       1,     1,     1,     1,     1,     4,     4,     3,     2,     1,
481       1,     1,     4,     6,     8,     4,     6,     5,     7,     7,
482       9,     4,     4,     6,     8,     1,     1,     1,     1,     1,
483       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
484       1,     1,     1,     1,     1,     1,     1,     1,     1,     1
485};
486
487/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
488   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
489   means the default is an error.  */
490static const unsigned char yydefact[] =
491{
492       0,    14,    45,    46,    47,    48,    39,    40,    43,    36,
493      41,    42,    53,    54,    55,    56,    57,    59,    50,    49,
494      35,    44,    12,    37,    38,    52,    51,    58,    13,     6,
495       0,     2,     4,     5,     7,     8,     9,    10,    11,     0,
496       0,     0,     0,     0,     1,     3,    20,     0,     0,     0,
497      19,    21,     0,     0,     0,     0,    18,     0,     0,     0,
498       0,     0,     0,     0,     0,     0,     0,     0,    15,    17,
499      31,    32,     0,     0,    16,    22,     0,    25,     0,     0,
500       0,     0,     0,     0,     0,    27,     0,    33,     0,    23,
501       0,    26,     0,     0,     0,     0,    29,     0,    28,    34,
502      24,     0,    30
503};
504
505/* YYDEFGOTO[NTERM-NUM]. */
506static const yysigned_char yydefgoto[] =
507{
508      -1,    30,    31,    32,    33,    34,    49,    50,    51,    35,
509      36,    37,    38,    39,    40,    41,    42,    43
510};
511
512/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
513   STATE-NUM.  */
514#define YYPACT_NINF -41
515static const yysigned_char yypact[] =
516{
517      52,   -41,   -41,   -41,   -41,   -41,   -41,   -41,   -41,   -41,
518     -41,   -41,   -41,   -41,   -41,   -41,   -41,   -41,   -41,   -41,
519     -41,   -41,   -41,   -41,   -41,   -41,   -41,   -41,   -41,   -41,
520       6,    52,   -41,   -41,   -41,   -41,   -41,   -41,   -41,   -29,
521     -29,   -29,   -29,   -29,   -41,   -41,   -41,   -28,   -31,   -23,
522     -22,   -41,   -18,   -12,    -4,    -3,    -2,   -25,   -29,     1,
523     -29,   -29,   -29,   -29,     2,     0,   -15,     5,   -41,   -41,
524     -41,   -41,     7,     8,   -41,   -41,     9,   -41,    14,   -13,
525     -29,   -29,   -27,    10,    13,   -41,    16,   -41,    12,   -41,
526      18,   -41,   -11,    11,   -29,    40,   -41,    19,   -41,   -41,
527     -41,    41,   -41
528};
529
530/* YYPGOTO[NTERM-NUM].  */
531static const yysigned_char yypgoto[] =
532{
533     -41,   -41,   -41,    53,   -41,   -41,   -40,    -8,   -41,   -41,
534     -41,   -41,   -41,   -41,   -41,   -41,   -41,   -41
535};
536
537/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
538   positive, shift that token.  If negative, reduce the rule which
539   number is the opposite.  If zero, do what YYDEFACT says.
540   If YYTABLE_NINF, syntax error.  */
541#define YYTABLE_NINF -1
542static const unsigned char yytable[] =
543{
544      52,    53,    54,    55,    46,    46,    44,    65,    66,    47,
545      57,    48,    48,    67,    58,    89,    90,    59,    68,    60,
546      70,    71,    72,    73,    76,    61,    84,    77,    78,    85,
547      86,    96,    97,    62,    63,    69,    74,    64,    79,    56,
548      87,    88,    75,    82,    80,    81,    83,    92,    93,    94,
549      95,   101,    91,    98,    99,     1,     2,     3,     4,     5,
550       6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
551      16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
552      26,    27,   100,   102,    45,     0,     0,    28,    29
553};
554
555static const yysigned_char yycheck[] =
556{
557      40,    41,    42,    43,    33,    33,     0,    32,    33,    38,
558      41,    40,    40,    38,    37,    42,    43,    39,    58,    37,
559      60,    61,    62,    63,    39,    37,    39,    42,    43,    42,
560      43,    42,    43,    37,    37,    34,    34,    39,    33,    47,
561      80,    81,    42,    34,    37,    37,    32,    34,    32,    37,
562      32,    32,    42,    42,    94,     3,     4,     5,     6,     7,
563       8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
564      18,    19,    20,    21,    22,    23,    24,    25,    26,    27,
565      28,    29,    42,    42,    31,    -1,    -1,    35,    36
566};
567
568/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
569   symbol of state STATE-NUM.  */
570static const unsigned char yystos[] =
571{
572       0,     3,     4,     5,     6,     7,     8,     9,    10,    11,
573      12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
574      22,    23,    24,    25,    26,    27,    28,    29,    35,    36,
575      45,    46,    47,    48,    49,    53,    54,    55,    56,    57,
576      58,    59,    60,    61,     0,    47,    33,    38,    40,    50,
577      51,    52,    50,    50,    50,    50,    51,    41,    37,    39,
578      37,    37,    37,    37,    39,    32,    33,    38,    50,    34,
579      50,    50,    50,    50,    34,    42,    39,    42,    43,    33,
580      37,    37,    34,    32,    39,    42,    43,    50,    50,    42,
581      43,    42,    34,    32,    37,    32,    42,    43,    42,    50,
582      42,    32,    42
583};
584
585#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
586# define YYSIZE_T __SIZE_TYPE__
587#endif
588#if ! defined (YYSIZE_T) && defined (size_t)
589# define YYSIZE_T size_t
590#endif
591#if ! defined (YYSIZE_T)
592# if defined (__STDC__) || defined (__cplusplus)
593#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
594#  define YYSIZE_T size_t
595# endif
596#endif
597#if ! defined (YYSIZE_T)
598# define YYSIZE_T unsigned int
599#endif
600
601#define yyerrok         (yyerrstatus = 0)
602#define yyclearin       (yychar = YYEMPTY)
603#define YYEMPTY         (-2)
604#define YYEOF           0
605
606#define YYACCEPT        goto yyacceptlab
607#define YYABORT         goto yyabortlab
608#define YYERROR         goto yyerrlab1
609
610
611/* Like YYERROR except do call yyerror.  This remains here temporarily
612   to ease the transition to the new meaning of YYERROR, for GCC.
613   Once GCC version 2 has supplanted version 1, this can go.  */
614
615#define YYFAIL          goto yyerrlab
616
617#define YYRECOVERING()  (!!yyerrstatus)
618
619#define YYBACKUP(Token, Value)                                  \
620do                                                              \
621  if (yychar == YYEMPTY && yylen == 1)                          \
622    {                                                           \
623      yychar = (Token);                                         \
624      yylval = (Value);                                         \
625      yytoken = YYTRANSLATE (yychar);                           \
626      YYPOPSTACK;                                               \
627      goto yybackup;                                            \
628    }                                                           \
629  else                                                          \
630    {                                                           \
631      yyerror ("syntax error: cannot back up");\
632      YYERROR;                                                  \
633    }                                                           \
634while (0)
635
636#define YYTERROR        1
637#define YYERRCODE       256
638
639/* YYLLOC_DEFAULT -- Compute the default location (before the actions
640   are run).  */
641
642#ifndef YYLLOC_DEFAULT
643# define YYLLOC_DEFAULT(Current, Rhs, N)         \
644  Current.first_line   = Rhs[1].first_line;      \
645  Current.first_column = Rhs[1].first_column;    \
646  Current.last_line    = Rhs[N].last_line;       \
647  Current.last_column  = Rhs[N].last_column;
648#endif
649
650/* YYLEX -- calling `yylex' with the right arguments.  */
651
652#ifdef YYLEX_PARAM
653# define YYLEX yylex (YYLEX_PARAM)
654#else
655# define YYLEX yylex ()
656#endif
657
658/* Enable debugging if requested.  */
659#if YYDEBUG
660
661# ifndef YYFPRINTF
662#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
663#  define YYFPRINTF fprintf
664# endif
665
666# define YYDPRINTF(Args)                        \
667do {                                            \
668  if (yydebug)                                  \
669    YYFPRINTF Args;                             \
670} while (0)
671
672# define YYDSYMPRINT(Args)                      \
673do {                                            \
674  if (yydebug)                                  \
675    yysymprint Args;                            \
676} while (0)
677
678# define YYDSYMPRINTF(Title, Token, Value, Location)            \
679do {                                                            \
680  if (yydebug)                                                  \
681    {                                                           \
682      YYFPRINTF (stderr, "%s ", Title);                         \
683      yysymprint (stderr,                                       \
684                  Token, Value);        \
685      YYFPRINTF (stderr, "\n");                                 \
686    }                                                           \
687} while (0)
688
689/*------------------------------------------------------------------.
690| yy_stack_print -- Print the state stack from its BOTTOM up to its |
691| TOP (cinluded).                                                   |
692`------------------------------------------------------------------*/
693
694#if defined (__STDC__) || defined (__cplusplus)
695static void
696yy_stack_print (short *bottom, short *top)
697#else
698static void
699yy_stack_print (bottom, top)
700    short *bottom;
701    short *top;
702#endif
703{
704  YYFPRINTF (stderr, "Stack now");
705  for (/* Nothing. */; bottom <= top; ++bottom)
706    YYFPRINTF (stderr, " %d", *bottom);
707  YYFPRINTF (stderr, "\n");
708}
709
710# define YY_STACK_PRINT(Bottom, Top)                            \
711do {                                                            \
712  if (yydebug)                                                  \
713    yy_stack_print ((Bottom), (Top));                           \
714} while (0)
715
716
717/*------------------------------------------------.
718| Report that the YYRULE is going to be reduced.  |
719`------------------------------------------------*/
720
721#if defined (__STDC__) || defined (__cplusplus)
722static void
723yy_reduce_print (int yyrule)
724#else
725static void
726yy_reduce_print (yyrule)
727    int yyrule;
728#endif
729{
730  int yyi;
731  unsigned int yylineno = yyrline[yyrule];
732  YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
733             yyrule - 1, yylineno);
734  /* Print the symbols being reduced, and their result.  */
735  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
736    YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
737  YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
738}
739
740# define YY_REDUCE_PRINT(Rule)          \
741do {                                    \
742  if (yydebug)                          \
743    yy_reduce_print (Rule);             \
744} while (0)
745
746/* Nonzero means print parse trace.  It is left uninitialized so that
747   multiple parsers can coexist.  */
748int yydebug;
749#else /* !YYDEBUG */
750# define YYDPRINTF(Args)
751# define YYDSYMPRINT(Args)
752# define YYDSYMPRINTF(Title, Token, Value, Location)
753# define YY_STACK_PRINT(Bottom, Top)
754# define YY_REDUCE_PRINT(Rule)
755#endif /* !YYDEBUG */
756
757
758/* YYINITDEPTH -- initial size of the parser's stacks.  */
759#ifndef YYINITDEPTH
760# define YYINITDEPTH 200
761#endif
762
763/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
764   if the built-in stack extension method is used).
765
766   Do not make this value too large; the results are undefined if
767   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
768   evaluated with infinite-precision integer arithmetic.  */
769
770#if YYMAXDEPTH == 0
771# undef YYMAXDEPTH
772#endif
773
774#ifndef YYMAXDEPTH
775# define YYMAXDEPTH 10000
776#endif
777
778
779
780#if YYERROR_VERBOSE
781
782# ifndef yystrlen
783#  if defined (__GLIBC__) && defined (_STRING_H)
784#   define yystrlen strlen
785#  else
786/* Return the length of YYSTR.  */
787static YYSIZE_T
788#   if defined (__STDC__) || defined (__cplusplus)
789yystrlen (const char *yystr)
790#   else
791yystrlen (yystr)
792     const char *yystr;
793#   endif
794{
795  register const char *yys = yystr;
796
797  while (*yys++ != '\0')
798    continue;
799
800  return yys - yystr - 1;
801}
802#  endif
803# endif
804
805# ifndef yystpcpy
806#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
807#   define yystpcpy stpcpy
808#  else
809/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
810   YYDEST.  */
811static char *
812#   if defined (__STDC__) || defined (__cplusplus)
813yystpcpy (char *yydest, const char *yysrc)
814#   else
815yystpcpy (yydest, yysrc)
816     char *yydest;
817     const char *yysrc;
818#   endif
819{
820  register char *yyd = yydest;
821  register const char *yys = yysrc;
822
823  while ((*yyd++ = *yys++) != '\0')
824    continue;
825
826  return yyd - 1;
827}
828#  endif
829# endif
830
831#endif /* !YYERROR_VERBOSE */
832
833
834
835#if YYDEBUG
836/*--------------------------------.
837| Print this symbol on YYOUTPUT.  |
838`--------------------------------*/
839
840#if defined (__STDC__) || defined (__cplusplus)
841static void
842yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
843#else
844static void
845yysymprint (yyoutput, yytype, yyvaluep)
846    FILE *yyoutput;
847    int yytype;
848    YYSTYPE *yyvaluep;
849#endif
850{
851  /* Pacify ``unused variable'' warnings.  */
852  (void) yyvaluep;
853
854  if (yytype < YYNTOKENS)
855    {
856      YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
857# ifdef YYPRINT
858      YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
859# endif
860    }
861  else
862    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
863
864  switch (yytype)
865    {
866      default:
867        break;
868    }
869  YYFPRINTF (yyoutput, ")");
870}
871
872#endif /* ! YYDEBUG */
873/*-----------------------------------------------.
874| Release the memory associated to this symbol.  |
875`-----------------------------------------------*/
876
877#if defined (__STDC__) || defined (__cplusplus)
878static void
879yydestruct (int yytype, YYSTYPE *yyvaluep)
880#else
881static void
882yydestruct (yytype, yyvaluep)
883    int yytype;
884    YYSTYPE *yyvaluep;
885#endif
886{
887  /* Pacify ``unused variable'' warnings.  */
888  (void) yyvaluep;
889
890  switch (yytype)
891    {
892
893      default:
894        break;
895    }
896}
897
898
899/* Prevent warnings from -Wmissing-prototypes.  */
900
901#ifdef YYPARSE_PARAM
902# if defined (__STDC__) || defined (__cplusplus)
903int yyparse (void *YYPARSE_PARAM);
904# else
905int yyparse ();
906# endif
907#else /* ! YYPARSE_PARAM */
908#if defined (__STDC__) || defined (__cplusplus)
909int yyparse (void);
910#else
911int yyparse ();
912#endif
913#endif /* ! YYPARSE_PARAM */
914
915
916
917/* The lookahead symbol.  */
918int yychar;
919
920/* The semantic value of the lookahead symbol.  */
921YYSTYPE yylval;
922
923/* Number of syntax errors so far.  */
924int yynerrs;
925
926
927
928/*----------.
929| yyparse.  |
930`----------*/
931
932#ifdef YYPARSE_PARAM
933# if defined (__STDC__) || defined (__cplusplus)
934int yyparse (void *YYPARSE_PARAM)
935# else
936int yyparse (YYPARSE_PARAM)
937  void *YYPARSE_PARAM;
938# endif
939#else /* ! YYPARSE_PARAM */
940#if defined (__STDC__) || defined (__cplusplus)
941int
942yyparse (void)
943#else
944int
945yyparse ()
946
947#endif
948#endif
949{
950 
951  register int yystate;
952  register int yyn;
953  int yyresult;
954  /* Number of tokens to shift before error messages enabled.  */
955  int yyerrstatus;
956  /* Lookahead token as an internal (translated) token number.  */
957  int yytoken = 0;
958
959  /* Three stacks and their tools:
960     `yyss': related to states,
961     `yyvs': related to semantic values,
962     `yyls': related to locations.
963
964     Refer to the stacks thru separate pointers, to allow yyoverflow
965     to reallocate them elsewhere.  */
966
967  /* The state stack.  */
968  short yyssa[YYINITDEPTH];
969  short *yyss = yyssa;
970  register short *yyssp;
971
972  /* The semantic value stack.  */
973  YYSTYPE yyvsa[YYINITDEPTH];
974  YYSTYPE *yyvs = yyvsa;
975  register YYSTYPE *yyvsp;
976
977
978
979#define YYPOPSTACK   (yyvsp--, yyssp--)
980
981  YYSIZE_T yystacksize = YYINITDEPTH;
982
983  /* The variables used to return semantic value and location from the
984     action routines.  */
985  YYSTYPE yyval;
986
987
988  /* When reducing, the number of symbols on the RHS of the reduced
989     rule.  */
990  int yylen;
991
992  YYDPRINTF ((stderr, "Starting parse\n"));
993
994  yystate = 0;
995  yyerrstatus = 0;
996  yynerrs = 0;
997  yychar = YYEMPTY;             /* Cause a token to be read.  */
998
999  /* Initialize stack pointers.
1000     Waste one element of value and location stack
1001     so that they stay on the same level as the state stack.
1002     The wasted elements are never initialized.  */
1003
1004  yyssp = yyss;
1005  yyvsp = yyvs;
1006
1007  goto yysetstate;
1008
1009/*------------------------------------------------------------.
1010| yynewstate -- Push a new state, which is found in yystate.  |
1011`------------------------------------------------------------*/
1012 yynewstate:
1013  /* In all cases, when you get here, the value and location stacks
1014     have just been pushed. so pushing a state here evens the stacks.
1015     */
1016  yyssp++;
1017
1018 yysetstate:
1019  *yyssp = yystate;
1020
1021  if (yyss + yystacksize - 1 <= yyssp)
1022    {
1023      /* Get the current used size of the three stacks, in elements.  */
1024      YYSIZE_T yysize = yyssp - yyss + 1;
1025
1026#ifdef yyoverflow
1027      {
1028        /* Give user a chance to reallocate the stack. Use copies of
1029           these so that the &'s don't force the real ones into
1030           memory.  */
1031        YYSTYPE *yyvs1 = yyvs;
1032        short *yyss1 = yyss;
1033
1034
1035        /* Each stack pointer address is followed by the size of the
1036           data in use in that stack, in bytes.  This used to be a
1037           conditional around just the two extra args, but that might
1038           be undefined if yyoverflow is a macro.  */
1039        yyoverflow ("parser stack overflow",
1040                    &yyss1, yysize * sizeof (*yyssp),
1041                    &yyvs1, yysize * sizeof (*yyvsp),
1042
1043                    &yystacksize);
1044
1045        yyss = yyss1;
1046        yyvs = yyvs1;
1047      }
1048#else /* no yyoverflow */
1049# ifndef YYSTACK_RELOCATE
1050      goto yyoverflowlab;
1051# else
1052      /* Extend the stack our own way.  */
1053      if (YYMAXDEPTH <= yystacksize)
1054        goto yyoverflowlab;
1055      yystacksize *= 2;
1056      if (YYMAXDEPTH < yystacksize)
1057        yystacksize = YYMAXDEPTH;
1058
1059      {
1060        short *yyss1 = yyss;
1061        union yyalloc *yyptr =
1062          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1063        if (! yyptr)
1064          goto yyoverflowlab;
1065        YYSTACK_RELOCATE (yyss);
1066        YYSTACK_RELOCATE (yyvs);
1067
1068#  undef YYSTACK_RELOCATE
1069        if (yyss1 != yyssa)
1070          YYSTACK_FREE (yyss1);
1071      }
1072# endif
1073#endif /* no yyoverflow */
1074
1075      yyssp = yyss + yysize - 1;
1076      yyvsp = yyvs + yysize - 1;
1077
1078
1079      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1080                  (unsigned long int) yystacksize));
1081
1082      if (yyss + yystacksize - 1 <= yyssp)
1083        YYABORT;
1084    }
1085
1086  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1087
1088  goto yybackup;
1089
1090/*-----------.
1091| yybackup.  |
1092`-----------*/
1093yybackup:
1094
1095/* Do appropriate processing given the current state.  */
1096/* Read a lookahead token if we need one and don't already have one.  */
1097/* yyresume: */
1098
1099  /* First try to decide what to do without reference to lookahead token.  */
1100
1101  yyn = yypact[yystate];
1102  if (yyn == YYPACT_NINF)
1103    goto yydefault;
1104
1105  /* Not known => get a lookahead token if don't already have one.  */
1106
1107  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1108  if (yychar == YYEMPTY)
1109    {
1110      YYDPRINTF ((stderr, "Reading a token: "));
1111      yychar = YYLEX;
1112    }
1113
1114  if (yychar <= YYEOF)
1115    {
1116      yychar = yytoken = YYEOF;
1117      YYDPRINTF ((stderr, "Now at end of input.\n"));
1118    }
1119  else
1120    {
1121      yytoken = YYTRANSLATE (yychar);
1122      YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1123    }
1124
1125  /* If the proper action on seeing token YYTOKEN is to reduce or to
1126     detect an error, take that action.  */
1127  yyn += yytoken;
1128  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1129    goto yydefault;
1130  yyn = yytable[yyn];
1131  if (yyn <= 0)
1132    {
1133      if (yyn == 0 || yyn == YYTABLE_NINF)
1134        goto yyerrlab;
1135      yyn = -yyn;
1136      goto yyreduce;
1137    }
1138
1139  if (yyn == YYFINAL)
1140    YYACCEPT;
1141
1142  /* Shift the lookahead token.  */
1143  YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1144
1145  /* Discard the token being shifted unless it is eof.  */
1146  if (yychar != YYEOF)
1147    yychar = YYEMPTY;
1148
1149  *++yyvsp = yylval;
1150
1151
1152  /* Count tokens shifted since error; after three, turn off error
1153     status.  */
1154  if (yyerrstatus)
1155    yyerrstatus--;
1156
1157  yystate = yyn;
1158  goto yynewstate;
1159
1160
1161/*-----------------------------------------------------------.
1162| yydefault -- do the default action for the current state.  |
1163`-----------------------------------------------------------*/
1164yydefault:
1165  yyn = yydefact[yystate];
1166  if (yyn == 0)
1167    goto yyerrlab;
1168  goto yyreduce;
1169
1170
1171/*-----------------------------.
1172| yyreduce -- Do a reduction.  |
1173`-----------------------------*/
1174yyreduce:
1175  /* yyn is the number of a rule to reduce with.  */
1176  yylen = yyr2[yyn];
1177
1178  /* If YYLEN is nonzero, implement the default value of the action:
1179     `$$ = $1'.
1180
1181     Otherwise, the following line sets YYVAL to garbage.
1182     This behavior is undocumented and Bison
1183     users should not rely upon it.  Assigning to YYVAL
1184     unconditionally makes the parser a bit smaller, and it avoids a
1185     GCC warning that YYVAL may be used uninitialized.  */
1186  yyval = yyvsp[1-yylen];
1187
1188
1189  YY_REDUCE_PRINT (yyn);
1190  switch (yyn)
1191    {
1192        case 2:
1193#line 97 "vs1.0_grammar.y"
1194    {
1195        yyvsp[0].instList->Validate();
1196        yyvsp[0].instList->Translate();
1197        delete yyvsp[0].instList;
1198        ;}
1199    break;
1200
1201  case 3:
1202#line 105 "vs1.0_grammar.y"
1203    {
1204                *(yyvsp[-1].instList) += yyvsp[0].inst;
1205                delete yyvsp[0].inst;
1206                yyval.instList = yyvsp[-1].instList
1207        ;}
1208    break;
1209
1210  case 4:
1211#line 111 "vs1.0_grammar.y"
1212    {
1213                VS10InstListPtr instList = new VS10InstList;
1214                if ( yyvsp[0].inst != NULL )
1215                        {
1216                        *instList += yyvsp[0].inst;
1217                        delete yyvsp[0].inst;
1218                        }
1219                yyval.instList = instList;
1220        ;}
1221    break;
1222
1223  case 5:
1224#line 123 "vs1.0_grammar.y"
1225    {
1226                yyval.inst = yyvsp[0].inst;
1227                do_linenum_incr();
1228        ;}
1229    break;
1230
1231  case 6:
1232#line 128 "vs1.0_grammar.y"
1233    {
1234                yyval.inst = new VS10Inst( get_linenum() );
1235                do_linenum_incr();
1236        ;}
1237    break;
1238
1239  case 12:
1240#line 140 "vs1.0_grammar.y"
1241    {
1242                   yyval.inst = new VS10Inst( get_linenum(), VS10_NOP );
1243                   ;}
1244    break;
1245
1246  case 13:
1247#line 144 "vs1.0_grammar.y"
1248    {
1249                   yyval.inst = new VS10Inst( get_linenum(), VS10_COMMENT, yyvsp[0].comment );
1250                   ;}
1251    break;
1252
1253  case 14:
1254#line 148 "vs1.0_grammar.y"
1255    {
1256                   yyval.inst = new VS10Inst( get_linenum(), VS10_HEADER );
1257                   ;}
1258    break;
1259
1260  case 15:
1261#line 154 "vs1.0_grammar.y"
1262    {
1263                yyval.inst = new VS10Inst( get_linenum(), yyvsp[-3].ival, yyvsp[-2].reg, yyvsp[0].reg );
1264        ;}
1265    break;
1266
1267  case 16:
1268#line 160 "vs1.0_grammar.y"
1269    {
1270                   VS10Reg reg;
1271                   reg = yyvsp[-2].reg;
1272                   reg.sign = -1;
1273                   reg.type = yyvsp[-2].reg.type;
1274                   reg.index = yyvsp[-2].reg.index;
1275                   for ( int i = 0; i < 4; i++ ) reg.mask[i] = yyvsp[0].mask[i];
1276                   yyval.reg = reg;
1277                   ;}
1278    break;
1279
1280  case 17:
1281#line 170 "vs1.0_grammar.y"
1282    {
1283                   VS10Reg reg;
1284                   reg = yyvsp[-2].reg;
1285                   reg.sign = 1;
1286                   reg.type = yyvsp[-2].reg.type;
1287                   reg.index = yyvsp[-2].reg.index;
1288                   for ( int i = 0; i < 4; i++ ) reg.mask[i] = yyvsp[0].mask[i];
1289                   yyval.reg = reg;
1290                   ;}
1291    break;
1292
1293  case 18:
1294#line 180 "vs1.0_grammar.y"
1295    {
1296                   VS10Reg reg;
1297                   reg = yyvsp[0].reg;
1298                   reg.sign = -1;
1299                   reg.type = yyvsp[0].reg.type;
1300                   reg.index = yyvsp[0].reg.index;
1301                   for ( int i = 0; i < 4; i++ ) reg.mask[i] = 0;
1302                   yyval.reg = reg;
1303                   ;}
1304    break;
1305
1306  case 19:
1307#line 190 "vs1.0_grammar.y"
1308    {
1309                   VS10Reg reg;
1310                   reg = yyvsp[0].reg;
1311                   reg.sign = 1;
1312                   reg.type = yyvsp[0].reg.type;
1313                   reg.index = yyvsp[0].reg.index;
1314                   for ( int i = 0; i < 4; i++ ) reg.mask[i] = 0;
1315                   yyval.reg = reg;
1316                   ;}
1317    break;
1318
1319  case 21:
1320#line 201 "vs1.0_grammar.y"
1321    {
1322          ;}
1323    break;
1324
1325  case 22:
1326#line 205 "vs1.0_grammar.y"
1327    {
1328                   VS10Reg reg;
1329                   reg.type = TYPE_CONSTANT_MEM_REG;
1330                   reg.index = yyvsp[-1].ival;
1331                   yyval.reg = reg;
1332                   ;}
1333    break;
1334
1335  case 23:
1336#line 212 "vs1.0_grammar.y"
1337    {
1338                   // Register is valid only if
1339                   //   type = TYPE_ADDRESS_REG
1340                   //   index = 0
1341                   //   len(mask) = 1
1342                   //   mask[0] = 'x'
1343                   VS10Reg reg;
1344                   yyval.reg.type = TYPE_CONSTANT_A0_REG;
1345                   if ( yyvsp[-3].reg.type != TYPE_ADDRESS_REG )
1346                       {
1347                           LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
1348                           }
1349                       else if ( yyvsp[-3].reg.index != 0 )
1350                           {
1351                           LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
1352                           }
1353                           else
1354                           {
1355                               int len = 0;
1356                                   while ( len < 2 )
1357                                   {
1358                                       if ( yyvsp[-1].mask[len] == 0 )
1359                                           break;
1360                                           len++;
1361                                   }
1362                                   if ( len != 1 || yyvsp[-1].mask[0] != 'x' )
1363                                   {
1364                               LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
1365                                   }
1366
1367                                   reg.type = TYPE_CONSTANT_A0_REG;
1368                                   yyval.reg = reg;
1369                           }
1370                   ;}
1371    break;
1372
1373  case 24:
1374#line 247 "vs1.0_grammar.y"
1375    {
1376                   // Register is valid only if
1377                   //   type = TYPE_ADDRESS_REG
1378                   //   index = 0
1379                   //   len(mask) = 1
1380                   //   mask[0] = 'x'
1381                   VS10Reg reg;
1382                   yyval.reg.type = TYPE_CONSTANT_A0_OFFSET_REG;
1383                   if ( yyvsp[-5].reg.type != TYPE_ADDRESS_REG )
1384                       {
1385                           LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
1386                           }
1387                       else if ( yyvsp[-5].reg.index != 0 )
1388                           {
1389                           LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
1390                           }
1391                           else
1392                           {
1393                               int len = 0;
1394                                   while ( len < 2 )
1395                                   {
1396                                       if ( yyvsp[-3].mask[len] == 0 )
1397                                           break;
1398                                           len++;
1399                                   }
1400                                   if ( len != 1 || yyvsp[-3].mask[0] != 'x' )
1401                                   {
1402                               LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
1403                                   }
1404
1405                                   reg.type = TYPE_CONSTANT_A0_OFFSET_REG;
1406                                   reg.index = yyvsp[-1].ival;
1407                                   yyval.reg = reg;
1408                           }
1409                   ;}
1410    break;
1411
1412  case 25:
1413#line 283 "vs1.0_grammar.y"
1414    {
1415                       yyval.reg.type = TYPE_CONSTANT_A0_REG;
1416                           LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
1417                   ;}
1418    break;
1419
1420  case 26:
1421#line 288 "vs1.0_grammar.y"
1422    {
1423                       yyval.reg.type = TYPE_CONSTANT_A0_REG;
1424                           LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
1425                   ;}
1426    break;
1427
1428  case 27:
1429#line 293 "vs1.0_grammar.y"
1430    {
1431                       yyval.reg.type = TYPE_CONSTANT_A0_REG;
1432                           LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
1433                   ;}
1434    break;
1435
1436  case 28:
1437#line 298 "vs1.0_grammar.y"
1438    {
1439                       yyval.reg.type = TYPE_CONSTANT_A0_REG;
1440                           LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
1441                   ;}
1442    break;
1443
1444  case 29:
1445#line 303 "vs1.0_grammar.y"
1446    {
1447                       yyval.reg.type = TYPE_CONSTANT_A0_REG;
1448                           LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
1449                   ;}
1450    break;
1451
1452  case 30:
1453#line 308 "vs1.0_grammar.y"
1454    {
1455                       yyval.reg.type = TYPE_CONSTANT_A0_REG;
1456                           LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
1457                   ;}
1458    break;
1459
1460  case 31:
1461#line 315 "vs1.0_grammar.y"
1462    {
1463                yyval.inst = new VS10Inst( get_linenum(), yyvsp[-3].ival, yyvsp[-2].reg, yyvsp[0].reg );
1464        ;}
1465    break;
1466
1467  case 32:
1468#line 321 "vs1.0_grammar.y"
1469    {
1470                yyval.inst = new VS10Inst( get_linenum(), yyvsp[-3].ival, yyvsp[-2].reg, yyvsp[0].reg );
1471        ;}
1472    break;
1473
1474  case 33:
1475#line 327 "vs1.0_grammar.y"
1476    {
1477                yyval.inst = new VS10Inst( get_linenum(), yyvsp[-5].ival, yyvsp[-4].reg, yyvsp[-2].reg, yyvsp[0].reg );
1478        ;}
1479    break;
1480
1481  case 34:
1482#line 334 "vs1.0_grammar.y"
1483    {
1484                yyval.inst = new VS10Inst( get_linenum(), yyvsp[-7].ival, yyvsp[-6].reg, yyvsp[-4].reg, yyvsp[-2].reg, yyvsp[0].reg );
1485        ;}
1486    break;
1487
1488  case 35:
1489#line 340 "vs1.0_grammar.y"
1490    {
1491                yyval.ival = VS10_MOV;
1492        ;}
1493    break;
1494
1495  case 36:
1496#line 344 "vs1.0_grammar.y"
1497    {
1498                yyval.ival = VS10_LIT;
1499        ;}
1500    break;
1501
1502  case 37:
1503#line 350 "vs1.0_grammar.y"
1504    {
1505        yyval.ival = VS10_RCP;
1506        ;}
1507    break;
1508
1509  case 38:
1510#line 354 "vs1.0_grammar.y"
1511    {
1512        yyval.ival = VS10_RSQ;
1513        ;}
1514    break;
1515
1516  case 39:
1517#line 358 "vs1.0_grammar.y"
1518    {
1519        yyval.ival = VS10_EXP;
1520        ;}
1521    break;
1522
1523  case 40:
1524#line 362 "vs1.0_grammar.y"
1525    {
1526        yyval.ival = VS10_EXPP;
1527        ;}
1528    break;
1529
1530  case 41:
1531#line 366 "vs1.0_grammar.y"
1532    {
1533        yyval.ival = VS10_LOG;
1534        ;}
1535    break;
1536
1537  case 42:
1538#line 370 "vs1.0_grammar.y"
1539    {
1540        yyval.ival = VS10_LOGP;
1541        ;}
1542    break;
1543
1544  case 43:
1545#line 376 "vs1.0_grammar.y"
1546    {
1547        yyval.ival = VS10_FRC;
1548        ;}
1549    break;
1550
1551  case 44:
1552#line 382 "vs1.0_grammar.y"
1553    {
1554        yyval.ival = VS10_MUL;
1555        ;}
1556    break;
1557
1558  case 45:
1559#line 386 "vs1.0_grammar.y"
1560    {
1561        yyval.ival = VS10_ADD;
1562        ;}
1563    break;
1564
1565  case 46:
1566#line 390 "vs1.0_grammar.y"
1567    {
1568        yyval.ival = VS10_DP3;
1569        ;}
1570    break;
1571
1572  case 47:
1573#line 394 "vs1.0_grammar.y"
1574    {
1575        yyval.ival = VS10_DP4;
1576        ;}
1577    break;
1578
1579  case 48:
1580#line 398 "vs1.0_grammar.y"
1581    {
1582        yyval.ival = VS10_DST;
1583        ;}
1584    break;
1585
1586  case 49:
1587#line 402 "vs1.0_grammar.y"
1588    {
1589        yyval.ival = VS10_MIN;
1590        ;}
1591    break;
1592
1593  case 50:
1594#line 406 "vs1.0_grammar.y"
1595    {
1596        yyval.ival = VS10_MAX;
1597        ;}
1598    break;
1599
1600  case 51:
1601#line 410 "vs1.0_grammar.y"
1602    {
1603        yyval.ival = VS10_SLT;
1604        ;}
1605    break;
1606
1607  case 52:
1608#line 414 "vs1.0_grammar.y"
1609    {
1610        yyval.ival = VS10_SGE;
1611        ;}
1612    break;
1613
1614  case 53:
1615#line 418 "vs1.0_grammar.y"
1616    {
1617        yyval.ival = VS10_M3X2;
1618        ;}
1619    break;
1620
1621  case 54:
1622#line 422 "vs1.0_grammar.y"
1623    {
1624        yyval.ival = VS10_M3X3;
1625        ;}
1626    break;
1627
1628  case 55:
1629#line 426 "vs1.0_grammar.y"
1630    {
1631        yyval.ival = VS10_M3X4;
1632        ;}
1633    break;
1634
1635  case 56:
1636#line 430 "vs1.0_grammar.y"
1637    {
1638        yyval.ival = VS10_M4X3;
1639        ;}
1640    break;
1641
1642  case 57:
1643#line 434 "vs1.0_grammar.y"
1644    {
1645        yyval.ival = VS10_M4X4;
1646        ;}
1647    break;
1648
1649  case 58:
1650#line 438 "vs1.0_grammar.y"
1651    {
1652        yyval.ival = VS10_SUB;
1653        ;}
1654    break;
1655
1656  case 59:
1657#line 444 "vs1.0_grammar.y"
1658    {
1659        yyval.ival = VS10_MAD;
1660        ;}
1661    break;
1662
1663
1664    }
1665
1666/* Line 999 of yacc.c.  */
1667#line 1639 "_vs1.0_parser.c"
1668
1669  yyvsp -= yylen;
1670  yyssp -= yylen;
1671
1672
1673  YY_STACK_PRINT (yyss, yyssp);
1674
1675  *++yyvsp = yyval;
1676
1677
1678  /* Now `shift' the result of the reduction.  Determine what state
1679     that goes to, based on the state we popped back to and the rule
1680     number reduced by.  */
1681
1682  yyn = yyr1[yyn];
1683
1684  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1685  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1686    yystate = yytable[yystate];
1687  else
1688    yystate = yydefgoto[yyn - YYNTOKENS];
1689
1690  goto yynewstate;
1691
1692
1693/*------------------------------------.
1694| yyerrlab -- here on detecting error |
1695`------------------------------------*/
1696yyerrlab:
1697  /* If not already recovering from an error, report this error.  */
1698  if (!yyerrstatus)
1699    {
1700      ++yynerrs;
1701#if YYERROR_VERBOSE
1702      yyn = yypact[yystate];
1703
1704      if (YYPACT_NINF < yyn && yyn < YYLAST)
1705        {
1706          YYSIZE_T yysize = 0;
1707          int yytype = YYTRANSLATE (yychar);
1708          char *yymsg;
1709          int yyx, yycount;
1710
1711          yycount = 0;
1712          /* Start YYX at -YYN if negative to avoid negative indexes in
1713             YYCHECK.  */
1714          for (yyx = yyn < 0 ? -yyn : 0;
1715               yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1716            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1717              yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1718          yysize += yystrlen ("syntax error, unexpected ") + 1;
1719          yysize += yystrlen (yytname[yytype]);
1720          yymsg = (char *) YYSTACK_ALLOC (yysize);
1721          if (yymsg != 0)
1722            {
1723              char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1724              yyp = yystpcpy (yyp, yytname[yytype]);
1725
1726              if (yycount < 5)
1727                {
1728                  yycount = 0;
1729                  for (yyx = yyn < 0 ? -yyn : 0;
1730                       yyx < (int) (sizeof (yytname) / sizeof (char *));
1731                       yyx++)
1732                    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1733                      {
1734                        const char *yyq = ! yycount ? ", expecting " : " or ";
1735                        yyp = yystpcpy (yyp, yyq);
1736                        yyp = yystpcpy (yyp, yytname[yyx]);
1737                        yycount++;
1738                      }
1739                }
1740              yyerror (yymsg);
1741              YYSTACK_FREE (yymsg);
1742            }
1743          else
1744            yyerror ("syntax error; also virtual memory exhausted");
1745        }
1746      else
1747#endif /* YYERROR_VERBOSE */
1748        yyerror ("syntax error");
1749    }
1750
1751
1752
1753  if (yyerrstatus == 3)
1754    {
1755      /* If just tried and failed to reuse lookahead token after an
1756         error, discard it.  */
1757
1758      /* Return failure if at end of input.  */
1759      if (yychar == YYEOF)
1760        {
1761          /* Pop the error token.  */
1762          YYPOPSTACK;
1763          /* Pop the rest of the stack.  */
1764          while (yyss < yyssp)
1765            {
1766              YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1767              yydestruct (yystos[*yyssp], yyvsp);
1768              YYPOPSTACK;
1769            }
1770          YYABORT;
1771        }
1772
1773      YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1774      yydestruct (yytoken, &yylval);
1775      yychar = YYEMPTY;
1776
1777    }
1778
1779  /* Else will try to reuse lookahead token after shifting the error
1780     token.  */
1781  goto yyerrlab1;
1782
1783
1784/*----------------------------------------------------.
1785| yyerrlab1 -- error raised explicitly by an action.  |
1786`----------------------------------------------------*/
1787yyerrlab1:
1788  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1789
1790  for (;;)
1791    {
1792      yyn = yypact[yystate];
1793      if (yyn != YYPACT_NINF)
1794        {
1795          yyn += YYTERROR;
1796          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1797            {
1798              yyn = yytable[yyn];
1799              if (0 < yyn)
1800                break;
1801            }
1802        }
1803
1804      /* Pop the current state because it cannot handle the error token.  */
1805      if (yyssp == yyss)
1806        YYABORT;
1807
1808      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1809      yydestruct (yystos[yystate], yyvsp);
1810      yyvsp--;
1811      yystate = *--yyssp;
1812
1813      YY_STACK_PRINT (yyss, yyssp);
1814    }
1815
1816  if (yyn == YYFINAL)
1817    YYACCEPT;
1818
1819  YYDPRINTF ((stderr, "Shifting error token, "));
1820
1821  *++yyvsp = yylval;
1822
1823
1824  yystate = yyn;
1825  goto yynewstate;
1826
1827
1828/*-------------------------------------.
1829| yyacceptlab -- YYACCEPT comes here.  |
1830`-------------------------------------*/
1831yyacceptlab:
1832  yyresult = 0;
1833  goto yyreturn;
1834
1835/*-----------------------------------.
1836| yyabortlab -- YYABORT comes here.  |
1837`-----------------------------------*/
1838yyabortlab:
1839  yyresult = 1;
1840  goto yyreturn;
1841
1842#ifndef yyoverflow
1843/*----------------------------------------------.
1844| yyoverflowlab -- parser overflow comes here.  |
1845`----------------------------------------------*/
1846yyoverflowlab:
1847  yyerror ("parser stack overflow");
1848  yyresult = 2;
1849  /* Fall through.  */
1850#endif
1851
1852yyreturn:
1853#ifndef yyoverflow
1854  if (yyss != yyssa)
1855    YYSTACK_FREE (yyss);
1856#endif
1857  return yyresult;
1858}
1859
1860
1861#line 450 "vs1.0_grammar.y"
1862
1863void yyerror(char* s)
1864{
1865    LexError( "Syntax Error.\n" );
1866    //errors.set(s);
1867    //errors.set("unrecognized token");
1868}
1869
Note: See TracBrowser for help on using the repository browser.