source: OGRE/trunk/ogrenew/RenderSystems/GL/src/nvparse/_vs1.0_parser.cpp @ 692

Revision 692, 48.8 KB checked in by mattausch, 18 years ago (diff)

adding ogre 1.2 and dependencies

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