blob: 07d663b018c3da2ee063d0e017e363474cd9f347 [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattner81779692006-03-30 22:51:12 +00002/* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y
3 by GNU Bison version 1.28 */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004
Chris Lattner81779692006-03-30 22:51:12 +00005#define YYBISON 1 /* Identify Bison output. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006
Reid Spencer68a24bd2005-08-27 18:50:39 +00007#define yyparse Fileparse
Chris Lattner81779692006-03-30 22:51:12 +00008#define yylex Filelex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror Fileerror
Chris Lattner81779692006-03-30 22:51:12 +000010#define yylval Filelval
11#define yychar Filechar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug Filedebug
13#define yynerrs Filenerrs
Chris Lattner81779692006-03-30 22:51:12 +000014#define INT 257
15#define BIT 258
16#define STRING 259
17#define BITS 260
18#define LIST 261
19#define CODE 262
20#define DAG 263
21#define CLASS 264
22#define DEF 265
23#define FIELD 266
24#define LET 267
25#define IN 268
26#define SHLTOK 269
27#define SRATOK 270
28#define SRLTOK 271
29#define INTVAL 272
30#define ID 273
31#define VARNAME 274
32#define STRVAL 275
33#define CODEFRAGMENT 276
Reid Spencer68a24bd2005-08-27 18:50:39 +000034
Chris Lattner81779692006-03-30 22:51:12 +000035#line 14 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +000036
37#include "Record.h"
38#include "llvm/ADT/StringExtras.h"
39#include <algorithm>
40#include <cstdio>
41#define YYERROR_VERBOSE 1
42
43int yyerror(const char *ErrorMsg);
44int yylex();
45
46namespace llvm {
47
48extern int Filelineno;
49static Record *CurRec = 0;
50static bool ParsingTemplateArgs = false;
51
52typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
53
54struct LetRecord {
55 std::string Name;
56 std::vector<unsigned> Bits;
57 Init *Value;
58 bool HasBits;
59 LetRecord(const std::string &N, std::vector<unsigned> *B, Init *V)
60 : Name(N), Value(V), HasBits(B != 0) {
61 if (HasBits) Bits = *B;
62 }
63};
64
65static std::vector<std::vector<LetRecord> > LetStack;
66
67
68extern std::ostream &err();
69
70static void addValue(const RecordVal &RV) {
71 if (RecordVal *ERV = CurRec->getValue(RV.getName())) {
72 // The value already exists in the class, treat this as a set...
73 if (ERV->setValue(RV.getValue())) {
74 err() << "New definition of '" << RV.getName() << "' of type '"
75 << *RV.getType() << "' is incompatible with previous "
76 << "definition of type '" << *ERV->getType() << "'!\n";
77 exit(1);
78 }
79 } else {
80 CurRec->addValue(RV);
81 }
82}
83
84static void addSuperClass(Record *SC) {
85 if (CurRec->isSubClassOf(SC)) {
86 err() << "Already subclass of '" << SC->getName() << "'!\n";
87 exit(1);
88 }
89 CurRec->addSuperClass(SC);
90}
91
92static void setValue(const std::string &ValName,
Chris Lattner81779692006-03-30 22:51:12 +000093 std::vector<unsigned> *BitList, Init *V) {
Reid Spencer68a24bd2005-08-27 18:50:39 +000094 if (!V) return;
95
96 RecordVal *RV = CurRec->getValue(ValName);
97 if (RV == 0) {
98 err() << "Value '" << ValName << "' unknown!\n";
99 exit(1);
100 }
101
102 // Do not allow assignments like 'X = X'. This will just cause infinite loops
103 // in the resolution machinery.
104 if (!BitList)
105 if (VarInit *VI = dynamic_cast<VarInit*>(V))
106 if (VI->getName() == ValName)
107 return;
108
109 // If we are assigning to a subset of the bits in the value... then we must be
110 // assigning to a field of BitsRecTy, which must have a BitsInit
111 // initializer...
112 //
113 if (BitList) {
114 BitsInit *CurVal = dynamic_cast<BitsInit*>(RV->getValue());
115 if (CurVal == 0) {
116 err() << "Value '" << ValName << "' is not a bits type!\n";
117 exit(1);
118 }
119
120 // Convert the incoming value to a bits type of the appropriate size...
121 Init *BI = V->convertInitializerTo(new BitsRecTy(BitList->size()));
122 if (BI == 0) {
123 V->convertInitializerTo(new BitsRecTy(BitList->size()));
124 err() << "Initializer '" << *V << "' not compatible with bit range!\n";
125 exit(1);
126 }
127
128 // We should have a BitsInit type now...
129 assert(dynamic_cast<BitsInit*>(BI) != 0 || &(std::cerr << *BI) == 0);
130 BitsInit *BInit = (BitsInit*)BI;
131
132 BitsInit *NewVal = new BitsInit(CurVal->getNumBits());
133
134 // Loop over bits, assigning values as appropriate...
135 for (unsigned i = 0, e = BitList->size(); i != e; ++i) {
136 unsigned Bit = (*BitList)[i];
137 if (NewVal->getBit(Bit)) {
138 err() << "Cannot set bit #" << Bit << " of value '" << ValName
139 << "' more than once!\n";
140 exit(1);
141 }
142 NewVal->setBit(Bit, BInit->getBit(i));
143 }
144
145 for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i)
146 if (NewVal->getBit(i) == 0)
147 NewVal->setBit(i, CurVal->getBit(i));
148
149 V = NewVal;
150 }
151
152 if (RV->setValue(V)) {
153 err() << "Value '" << ValName << "' of type '" << *RV->getType()
154 << "' is incompatible with initializer '" << *V << "'!\n";
155 exit(1);
156 }
157}
158
159// addSubClass - Add SC as a subclass to CurRec, resolving TemplateArgs as SC's
160// template arguments.
161static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
162 // Add all of the values in the subclass into the current class...
163 const std::vector<RecordVal> &Vals = SC->getValues();
164 for (unsigned i = 0, e = Vals.size(); i != e; ++i)
165 addValue(Vals[i]);
166
167 const std::vector<std::string> &TArgs = SC->getTemplateArgs();
168
169 // Ensure that an appropriate number of template arguments are specified...
170 if (TArgs.size() < TemplateArgs.size()) {
171 err() << "ERROR: More template args specified than expected!\n";
172 exit(1);
173 } else { // This class expects template arguments...
174 // Loop over all of the template arguments, setting them to the specified
175 // value or leaving them as the default if necessary.
176 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
177 if (i < TemplateArgs.size()) { // A value is specified for this temp-arg?
Chris Lattnerba4b1442005-09-08 18:22:57 +0000178 // Set it now.
179 setValue(TArgs[i], 0, TemplateArgs[i]);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000180
181 // Resolve it next.
182 CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
183
184
185 // Now remove it.
186 CurRec->removeValue(TArgs[i]);
187
188 } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
Chris Lattnerba4b1442005-09-08 18:22:57 +0000189 err() << "ERROR: Value not specified for template argument #"
190 << i << " (" << TArgs[i] << ") of subclass '" << SC->getName()
191 << "'!\n";
192 exit(1);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000193 }
194 }
195 }
196
197 // Since everything went well, we can now set the "superclass" list for the
198 // current record.
199 const std::vector<Record*> &SCs = SC->getSuperClasses();
200 for (unsigned i = 0, e = SCs.size(); i != e; ++i)
201 addSuperClass(SCs[i]);
202 addSuperClass(SC);
203}
204
205} // End llvm namespace
206
207using namespace llvm;
208
209
Chris Lattner81779692006-03-30 22:51:12 +0000210#line 189 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
211typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000212 std::string* StrVal;
213 int IntVal;
214 llvm::RecTy* Ty;
215 llvm::Init* Initializer;
216 std::vector<llvm::Init*>* FieldList;
217 std::vector<unsigned>* BitList;
218 llvm::Record* Rec;
219 SubClassRefTy* SubClassRef;
220 std::vector<SubClassRefTy>* SubClassList;
221 std::vector<std::pair<llvm::Init*, std::string> >* DagValueList;
222} YYSTYPE;
Chris Lattner81779692006-03-30 22:51:12 +0000223#include <stdio.h>
224
225#ifndef __cplusplus
226#ifndef __STDC__
227#define const
228#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000229#endif
230
231
232
Chris Lattner81779692006-03-30 22:51:12 +0000233#define YYFINAL 162
234#define YYFLAG -32768
235#define YYNTBASE 38
Reid Spencer68a24bd2005-08-27 18:50:39 +0000236
Chris Lattner81779692006-03-30 22:51:12 +0000237#define YYTRANSLATE(x) ((unsigned)(x) <= 276 ? yytranslate[x] : 79)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000238
Chris Lattner81779692006-03-30 22:51:12 +0000239static const char yytranslate[] = { 0,
240 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
241 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
242 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
243 2, 2, 2, 2, 2, 2, 2, 2, 2, 32,
244 33, 2, 2, 34, 36, 31, 2, 2, 2, 2,
245 2, 2, 2, 2, 2, 2, 2, 35, 37, 23,
246 25, 24, 26, 2, 2, 2, 2, 2, 2, 2,
247 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
248 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
249 29, 2, 30, 2, 2, 2, 2, 2, 2, 2,
250 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
251 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
252 2, 2, 27, 2, 28, 2, 2, 2, 2, 2,
253 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
254 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
255 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
256 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
257 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
258 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
259 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
260 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
261 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
262 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
263 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
264 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
265 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
266 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
267 17, 18, 19, 20, 21, 22
268};
Reid Spencer68a24bd2005-08-27 18:50:39 +0000269
Chris Lattner81779692006-03-30 22:51:12 +0000270#if YYDEBUG != 0
271static const short yyprhs[] = { 0,
272 0, 2, 4, 6, 11, 13, 18, 20, 22, 24,
273 25, 27, 28, 31, 33, 35, 37, 39, 41, 43,
274 47, 52, 57, 61, 65, 70, 75, 82, 89, 96,
275 97, 100, 103, 108, 109, 111, 113, 117, 120, 124,
276 130, 135, 137, 138, 142, 143, 145, 147, 151, 156,
277 159, 166, 167, 170, 172, 176, 178, 183, 185, 189,
278 190, 193, 195, 199, 203, 204, 206, 208, 209, 211,
279 213, 215, 216, 220, 221, 222, 229, 233, 235, 237,
280 242, 244, 248, 249, 254, 259, 262, 264, 267
281};
Reid Spencer68a24bd2005-08-27 18:50:39 +0000282
Chris Lattner81779692006-03-30 22:51:12 +0000283static const short yyrhs[] = { 19,
284 0, 5, 0, 4, 0, 6, 23, 18, 24, 0,
285 3, 0, 7, 23, 39, 24, 0, 8, 0, 9,
286 0, 38, 0, 0, 12, 0, 0, 25, 43, 0,
287 19, 0, 42, 0, 18, 0, 21, 0, 22, 0,
288 26, 0, 27, 50, 28, 0, 19, 23, 51, 24,
289 0, 43, 27, 48, 28, 0, 29, 50, 30, 0,
290 43, 31, 19, 0, 32, 42, 46, 33, 0, 43,
291 29, 48, 30, 0, 15, 32, 43, 34, 43, 33,
292 0, 16, 32, 43, 34, 43, 33, 0, 17, 32,
293 43, 34, 43, 33, 0, 0, 35, 20, 0, 43,
294 44, 0, 45, 34, 43, 44, 0, 0, 45, 0,
295 18, 0, 18, 36, 18, 0, 18, 18, 0, 47,
296 34, 18, 0, 47, 34, 18, 36, 18, 0, 47,
297 34, 18, 18, 0, 47, 0, 0, 27, 48, 28,
298 0, 0, 51, 0, 43, 0, 51, 34, 43, 0,
299 40, 39, 19, 41, 0, 52, 37, 0, 13, 19,
300 49, 25, 43, 37, 0, 0, 54, 53, 0, 37,
301 0, 27, 54, 28, 0, 38, 0, 38, 23, 51,
302 24, 0, 56, 0, 57, 34, 56, 0, 0, 35,
303 57, 0, 52, 0, 59, 34, 52, 0, 23, 59,
304 24, 0, 0, 60, 0, 19, 0, 0, 62, 0,
305 63, 0, 63, 0, 0, 58, 67, 55, 0, 0,
306 0, 10, 64, 69, 61, 70, 66, 0, 11, 65,
307 66, 0, 68, 0, 71, 0, 19, 49, 25, 43,
308 0, 73, 0, 74, 34, 73, 0, 0, 13, 76,
309 74, 14, 0, 75, 27, 77, 28, 0, 75, 72,
310 0, 72, 0, 77, 72, 0, 77, 0
311};
Reid Spencer68a24bd2005-08-27 18:50:39 +0000312
313#endif
314
Chris Lattner81779692006-03-30 22:51:12 +0000315#if YYDEBUG != 0
316static const short yyrline[] = { 0,
317 223, 234, 236, 238, 240, 242, 244, 246, 248, 252,
318 252, 254, 254, 256, 273, 275, 277, 280, 283, 285,
319 298, 326, 333, 336, 343, 346, 354, 360, 366, 374,
320 377, 381, 386, 392, 395, 398, 401, 414, 428, 430,
321 443, 459, 461, 461, 465, 467, 471, 474, 478, 488,
322 490, 496, 496, 497, 497, 499, 501, 505, 510, 515,
323 518, 522, 525, 530, 531, 531, 533, 533, 535, 542,
324 560, 572, 586, 591, 593, 595, 599, 608, 608, 610,
325 615, 615, 618, 618, 621, 624, 628, 628, 630
326};
327#endif
328
329
330#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
331
332static const char * const yytname[] = { "$","error","$undefined.","INT","BIT",
333"STRING","BITS","LIST","CODE","DAG","CLASS","DEF","FIELD","LET","IN","SHLTOK",
334"SRATOK","SRLTOK","INTVAL","ID","VARNAME","STRVAL","CODEFRAGMENT","'<'","'>'",
335"'='","'?'","'{'","'}'","'['","']'","'.'","'('","')'","','","':'","'-'","';'",
336"ClassID","Type","OptPrefix","OptValue","IDValue","Value","OptVarName","DagArgListNE",
337"DagArgList","RBitList","BitList","OptBitList","ValueList","ValueListNE","Declaration",
338"BodyItem","BodyList","Body","SubClassRef","ClassListNE","ClassList","DeclListNE",
339"TemplateArgList","OptTemplateArgList","OptID","ObjectName","ClassName","DefName",
340"ObjectBody","@1","ClassInst","@2","@3","DefInst","Object","LETItem","LETList",
341"LETCommand","@4","ObjectList","File", NULL
342};
343#endif
344
345static const short yyr1[] = { 0,
346 38, 39, 39, 39, 39, 39, 39, 39, 39, 40,
347 40, 41, 41, 42, 43, 43, 43, 43, 43, 43,
348 43, 43, 43, 43, 43, 43, 43, 43, 43, 44,
349 44, 45, 45, 46, 46, 47, 47, 47, 47, 47,
350 47, 48, 49, 49, 50, 50, 51, 51, 52, 53,
351 53, 54, 54, 55, 55, 56, 56, 57, 57, 58,
352 58, 59, 59, 60, 61, 61, 62, 62, 63, 64,
353 65, 67, 66, 69, 70, 68, 71, 72, 72, 73,
354 74, 74, 76, 75, 72, 72, 77, 77, 78
355};
356
357static const short yyr2[] = { 0,
358 1, 1, 1, 4, 1, 4, 1, 1, 1, 0,
359 1, 0, 2, 1, 1, 1, 1, 1, 1, 3,
360 4, 4, 3, 3, 4, 4, 6, 6, 6, 0,
361 2, 2, 4, 0, 1, 1, 3, 2, 3, 5,
362 4, 1, 0, 3, 0, 1, 1, 3, 4, 2,
363 6, 0, 2, 1, 3, 1, 4, 1, 3, 0,
364 2, 1, 3, 3, 0, 1, 1, 0, 1, 1,
365 1, 0, 3, 0, 0, 6, 3, 1, 1, 4,
366 1, 3, 0, 4, 4, 2, 1, 2, 1
367};
368
369static const short yydefact[] = { 0,
370 68, 68, 83, 78, 79, 87, 0, 89, 67, 69,
371 70, 74, 71, 60, 0, 0, 86, 88, 65, 0,
372 72, 77, 43, 81, 0, 0, 10, 66, 75, 1,
373 56, 58, 61, 0, 0, 0, 84, 0, 85, 11,
374 0, 62, 0, 60, 0, 0, 52, 54, 73, 36,
375 42, 0, 0, 82, 5, 3, 2, 0, 0, 7,
376 8, 9, 0, 64, 10, 76, 0, 0, 0, 16,
377 14, 17, 18, 19, 45, 45, 0, 15, 47, 0,
378 59, 10, 38, 0, 0, 44, 80, 0, 0, 12,
379 63, 0, 0, 0, 0, 0, 46, 0, 14, 34,
380 0, 0, 0, 57, 0, 0, 55, 0, 53, 37,
381 39, 0, 0, 0, 49, 0, 0, 0, 0, 20,
382 23, 30, 35, 0, 0, 0, 24, 48, 43, 50,
383 41, 0, 4, 6, 13, 0, 0, 0, 21, 0,
384 32, 0, 25, 22, 26, 0, 40, 0, 0, 0,
385 31, 30, 0, 27, 28, 29, 33, 0, 51, 0,
386 0, 0
387};
388
389static const short yydefgoto[] = { 31,
390 63, 41, 115, 78, 79, 141, 123, 124, 51, 52,
391 36, 96, 97, 42, 109, 82, 49, 32, 33, 21,
392 43, 28, 29, 10, 11, 12, 14, 22, 34, 4,
393 19, 44, 5, 6, 24, 25, 7, 15, 8, 160
394};
395
396static const short yypact[] = { 5,
397 7, 7,-32768,-32768,-32768,-32768, 1, 5,-32768,-32768,
398-32768,-32768,-32768, -18, 25, 5,-32768,-32768, 23, 30,
399-32768,-32768, 44,-32768, -11, -3, 60,-32768,-32768,-32768,
400 54,-32768, 40, -8, 63, 62,-32768, 25,-32768,-32768,
401 50,-32768, 39, -18, 16, 30,-32768,-32768,-32768, -14,
402 45, 65, 16,-32768,-32768,-32768,-32768, 68, 74,-32768,
403-32768,-32768, 80,-32768, 60,-32768, 87, 91, 92,-32768,
404 98,-32768,-32768,-32768, 16, 16, 106,-32768, 76, 41,
405-32768, 8,-32768, 108, 109,-32768, 76, 110, 50, 104,
406-32768, 16, 16, 16, 16, 102, 97, 103,-32768, 16,
407 63, 63, 113,-32768, 16, 115,-32768, 99,-32768,-32768,
408 -9, 111, 114, 16,-32768, 61, 67, 75, 42,-32768,
409-32768, 51, 105, 107, 116, 112,-32768, 76, 44,-32768,
410-32768, 119,-32768,-32768, 76, 16, 16, 16,-32768, 121,
411-32768, 16,-32768,-32768,-32768, 118,-32768, 81, 84, 89,
412-32768, 51, 16,-32768,-32768,-32768,-32768, 33,-32768, 145,
413 146,-32768
414};
415
416static const short yypgoto[] = { -39,
417 58,-32768,-32768, 71, -53, -1,-32768,-32768,-32768, -34,
418 20, 77, -44, -52,-32768,-32768,-32768, 117,-32768,-32768,
419-32768,-32768,-32768,-32768, 148,-32768,-32768, 120,-32768,-32768,
420-32768,-32768,-32768, -2, 122,-32768,-32768,-32768, 136,-32768
421};
422
423
424#define YYLAST 164
425
426
427static const short yytable[] = { 87,
428 80, 62, 37, 83, 17, 18, 1, 2, 131, 3,
429 1, 2, 91, 3, 1, 2, 20, 3, 47, 40,
430 106, 84, 38, 18, 39, 9, 132, 16, 48, 108,
431 67, 68, 69, 70, 71, 107, 72, 73, 116, 117,
432 118, 74, 75, 23, 76, 27, 122, 77, 30, 62,
433 119, 128, 55, 56, 57, 58, 59, 60, 61, 101,
434 135, 102, 64, 103, 104, 139, 125, 126, 30, 159,
435 35, 40, 65, 46, 105, 105, 45, 101, 85, 102,
436 50, 103, 148, 149, 150, 140, 53, 101, 152, 102,
437 88, 103, 86, 101, 136, 102, 89, 103, 90, 158,
438 137, 101, 101, 102, 102, 103, 103, 101, 138, 102,
439 101, 103, 102, 154, 103, 101, 155, 102, 92, 103,
440 95, 156, 93, 94, 99, 110, 111, 112, 114, 120,
441 105, 127, 121, 129, 133, 130, 147, 134, 142, 143,
442 151, 145, 153, 144, 161, 162, 113, 100, 146, 13,
443 157, 26, 98, 0, 0, 0, 0, 0, 0, 54,
444 0, 0, 81, 66
445};
446
447static const short yycheck[] = { 53,
448 45, 41, 14, 18, 7, 8, 10, 11, 18, 13,
449 10, 11, 65, 13, 10, 11, 35, 13, 27, 12,
450 13, 36, 34, 26, 28, 19, 36, 27, 37, 82,
451 15, 16, 17, 18, 19, 28, 21, 22, 92, 93,
452 94, 26, 27, 19, 29, 23, 100, 32, 19, 89,
453 95, 105, 3, 4, 5, 6, 7, 8, 9, 27,
454 114, 29, 24, 31, 24, 24, 101, 102, 19, 37,
455 27, 12, 34, 34, 34, 34, 23, 27, 34, 29,
456 18, 31, 136, 137, 138, 35, 25, 27, 142, 29,
457 23, 31, 28, 27, 34, 29, 23, 31, 19, 153,
458 34, 27, 27, 29, 29, 31, 31, 27, 34, 29,
459 27, 31, 29, 33, 31, 27, 33, 29, 32, 31,
460 23, 33, 32, 32, 19, 18, 18, 18, 25, 28,
461 34, 19, 30, 19, 24, 37, 18, 24, 34, 33,
462 20, 30, 25, 28, 0, 0, 89, 77, 129, 2,
463 152, 16, 76, -1, -1, -1, -1, -1, -1, 38,
464 -1, -1, 46, 44
465};
466/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
467#line 3 "/usr/share/bison.simple"
468/* This file comes from bison-1.28. */
469
470/* Skeleton output parser for bison,
471 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
472
473 This program is free software; you can redistribute it and/or modify
474 it under the terms of the GNU General Public License as published by
475 the Free Software Foundation; either version 2, or (at your option)
476 any later version.
477
478 This program is distributed in the hope that it will be useful,
479 but WITHOUT ANY WARRANTY; without even the implied warranty of
480 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
481 GNU General Public License for more details.
482
483 You should have received a copy of the GNU General Public License
484 along with this program; if not, write to the Free Software
485 Foundation, Inc., 59 Temple Place - Suite 330,
486 Boston, MA 02111-1307, USA. */
487
488/* As a special exception, when this file is copied by Bison into a
489 Bison output file, you may use that output file without restriction.
490 This special exception was added by the Free Software Foundation
491 in version 1.24 of Bison. */
492
493/* This is the parser code that is written into each bison parser
494 when the %semantic_parser declaration is not specified in the grammar.
495 It was written by Richard Stallman by simplifying the hairy parser
496 used when %semantic_parser is specified. */
497
498#ifndef YYSTACK_USE_ALLOCA
499#ifdef alloca
500#define YYSTACK_USE_ALLOCA
501#else /* alloca not defined */
502#ifdef __GNUC__
503#define YYSTACK_USE_ALLOCA
504#define alloca __builtin_alloca
505#else /* not GNU C. */
506#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
507#define YYSTACK_USE_ALLOCA
508#include <alloca.h>
509#else /* not sparc */
510/* We think this test detects Watcom and Microsoft C. */
511/* This used to test MSDOS, but that is a bad idea
512 since that symbol is in the user namespace. */
513#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
514#if 0 /* No need for malloc.h, which pollutes the namespace;
515 instead, just don't use alloca. */
516#include <malloc.h>
517#endif
518#else /* not MSDOS, or __TURBOC__ */
519#if defined(_AIX)
520/* I don't know what this was needed for, but it pollutes the namespace.
521 So I turned it off. rms, 2 May 1997. */
522/* #include <malloc.h> */
523 #pragma alloca
524#define YYSTACK_USE_ALLOCA
525#else /* not MSDOS, or __TURBOC__, or _AIX */
526#if 0
527#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
528 and on HPUX 10. Eventually we can turn this on. */
529#define YYSTACK_USE_ALLOCA
530#define alloca __builtin_alloca
531#endif /* __hpux */
532#endif
533#endif /* not _AIX */
534#endif /* not MSDOS, or __TURBOC__ */
535#endif /* not sparc */
536#endif /* not GNU C */
537#endif /* alloca not defined */
538#endif /* YYSTACK_USE_ALLOCA not defined */
539
540#ifdef YYSTACK_USE_ALLOCA
541#define YYSTACK_ALLOC alloca
Reid Spencer68a24bd2005-08-27 18:50:39 +0000542#else
Chris Lattner81779692006-03-30 22:51:12 +0000543#define YYSTACK_ALLOC malloc
Reid Spencer68a24bd2005-08-27 18:50:39 +0000544#endif
545
Chris Lattner81779692006-03-30 22:51:12 +0000546/* Note: there must be only one dollar sign in this file.
547 It is replaced by the list of actions, each action
548 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000549
550#define yyerrok (yyerrstatus = 0)
551#define yyclearin (yychar = YYEMPTY)
Chris Lattner81779692006-03-30 22:51:12 +0000552#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +0000553#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +0000554#define YYACCEPT goto yyacceptlab
Chris Lattner81779692006-03-30 22:51:12 +0000555#define YYABORT goto yyabortlab
Chris Lattnerba4b1442005-09-08 18:22:57 +0000556#define YYERROR goto yyerrlab1
Chris Lattner81779692006-03-30 22:51:12 +0000557/* Like YYERROR except do call yyerror.
558 This remains here temporarily to ease the
559 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000560 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000561#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +0000562#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner81779692006-03-30 22:51:12 +0000563#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +0000564do \
565 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner81779692006-03-30 22:51:12 +0000566 { yychar = (token), yylval = (value); \
567 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer68a24bd2005-08-27 18:50:39 +0000568 YYPOPSTACK; \
569 goto yybackup; \
570 } \
571 else \
Chris Lattner81779692006-03-30 22:51:12 +0000572 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencer68a24bd2005-08-27 18:50:39 +0000573while (0)
574
575#define YYTERROR 1
576#define YYERRCODE 256
577
Chris Lattner81779692006-03-30 22:51:12 +0000578#ifndef YYPURE
579#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +0000580#endif
581
Chris Lattner81779692006-03-30 22:51:12 +0000582#ifdef YYPURE
583#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +0000584#ifdef YYLEX_PARAM
Chris Lattner81779692006-03-30 22:51:12 +0000585#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000586#else
Chris Lattner81779692006-03-30 22:51:12 +0000587#define YYLEX yylex(&yylval, &yylloc)
588#endif
589#else /* not YYLSP_NEEDED */
590#ifdef YYLEX_PARAM
591#define YYLEX yylex(&yylval, YYLEX_PARAM)
592#else
593#define YYLEX yylex(&yylval)
594#endif
595#endif /* not YYLSP_NEEDED */
Chris Lattner8d354e92005-09-30 04:11:27 +0000596#endif
John Criswelld7881242006-01-17 17:01:34 +0000597
Chris Lattner81779692006-03-30 22:51:12 +0000598/* If nonreentrant, generate the variables here */
John Criswelld7881242006-01-17 17:01:34 +0000599
Chris Lattner81779692006-03-30 22:51:12 +0000600#ifndef YYPURE
John Criswelld7881242006-01-17 17:01:34 +0000601
Chris Lattner81779692006-03-30 22:51:12 +0000602int yychar; /* the lookahead symbol */
603YYSTYPE yylval; /* the semantic value of the */
604 /* lookahead symbol */
John Criswelld7881242006-01-17 17:01:34 +0000605
Chris Lattner81779692006-03-30 22:51:12 +0000606#ifdef YYLSP_NEEDED
607YYLTYPE yylloc; /* location data for the lookahead */
608 /* symbol */
Chris Lattner8d354e92005-09-30 04:11:27 +0000609#endif
John Criswelld7881242006-01-17 17:01:34 +0000610
Chris Lattner81779692006-03-30 22:51:12 +0000611int yynerrs; /* number of parse errors so far */
612#endif /* not YYPURE */
John Criswelld7881242006-01-17 17:01:34 +0000613
Chris Lattner81779692006-03-30 22:51:12 +0000614#if YYDEBUG != 0
615int yydebug; /* nonzero means print parse trace */
616/* Since this is uninitialized, it does not stop multiple parsers
617 from coexisting. */
Chris Lattnerba4b1442005-09-08 18:22:57 +0000618#endif
Chris Lattner2b931e82005-09-12 05:30:06 +0000619
Chris Lattner81779692006-03-30 22:51:12 +0000620/* YYINITDEPTH indicates the initial size of the parser's stacks */
Chris Lattner2b931e82005-09-12 05:30:06 +0000621
Reid Spencer68a24bd2005-08-27 18:50:39 +0000622#ifndef YYINITDEPTH
Chris Lattner81779692006-03-30 22:51:12 +0000623#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +0000624#endif
625
Chris Lattner81779692006-03-30 22:51:12 +0000626/* YYMAXDEPTH is the maximum size the stacks can grow to
627 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000628
Chris Lattnerba4b1442005-09-08 18:22:57 +0000629#if YYMAXDEPTH == 0
Chris Lattner81779692006-03-30 22:51:12 +0000630#undef YYMAXDEPTH
Reid Spencer68a24bd2005-08-27 18:50:39 +0000631#endif
632
633#ifndef YYMAXDEPTH
Chris Lattner81779692006-03-30 22:51:12 +0000634#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +0000635#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000636
Chris Lattner81779692006-03-30 22:51:12 +0000637/* Define __yy_memcpy. Note that the size argument
638 should be passed with type unsigned int, because that is what the non-GCC
639 definitions require. With GCC, __builtin_memcpy takes an arg
640 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000641
Chris Lattner81779692006-03-30 22:51:12 +0000642#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
643#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
644#else /* not GNU C or C++ */
645#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +0000646
Chris Lattner81779692006-03-30 22:51:12 +0000647/* This is the most reliable way to avoid incompatibilities
648 in available built-in functions on various systems. */
John Criswelld7881242006-01-17 17:01:34 +0000649static void
Chris Lattner81779692006-03-30 22:51:12 +0000650__yy_memcpy (to, from, count)
651 char *to;
652 char *from;
653 unsigned int count;
654{
655 register char *f = from;
656 register char *t = to;
657 register int i = count;
658
659 while (i-- > 0)
660 *t++ = *f++;
661}
662
663#else /* __cplusplus */
664
665/* This is the most reliable way to avoid incompatibilities
666 in available built-in functions on various systems. */
John Criswelld7881242006-01-17 17:01:34 +0000667static void
Chris Lattner81779692006-03-30 22:51:12 +0000668__yy_memcpy (char *to, char *from, unsigned int count)
669{
670 register char *t = to;
671 register char *f = from;
672 register int i = count;
673
674 while (i-- > 0)
675 *t++ = *f++;
676}
677
Chris Lattner2b931e82005-09-12 05:30:06 +0000678#endif
John Criswelld7881242006-01-17 17:01:34 +0000679#endif
John Criswelld7881242006-01-17 17:01:34 +0000680
Chris Lattner81779692006-03-30 22:51:12 +0000681#line 217 "/usr/share/bison.simple"
John Criswelld7881242006-01-17 17:01:34 +0000682
Chris Lattner81779692006-03-30 22:51:12 +0000683/* The user can define YYPARSE_PARAM as the name of an argument to be passed
684 into yyparse. The argument should have type void *.
685 It should actually point to an object.
686 Grammar actions can access the variable by casting it
687 to the proper pointer type. */
John Criswelld7881242006-01-17 17:01:34 +0000688
689#ifdef YYPARSE_PARAM
Chris Lattner81779692006-03-30 22:51:12 +0000690#ifdef __cplusplus
691#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
692#define YYPARSE_PARAM_DECL
693#else /* not __cplusplus */
694#define YYPARSE_PARAM_ARG YYPARSE_PARAM
695#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
696#endif /* not __cplusplus */
697#else /* not YYPARSE_PARAM */
698#define YYPARSE_PARAM_ARG
699#define YYPARSE_PARAM_DECL
700#endif /* not YYPARSE_PARAM */
701
702/* Prevent warning if -Wstrict-prototypes. */
703#ifdef __GNUC__
704#ifdef YYPARSE_PARAM
705int yyparse (void *);
706#else
John Criswelld7881242006-01-17 17:01:34 +0000707int yyparse (void);
John Criswelld7881242006-01-17 17:01:34 +0000708#endif
Chris Lattner81779692006-03-30 22:51:12 +0000709#endif
John Criswelld7881242006-01-17 17:01:34 +0000710
John Criswelld7881242006-01-17 17:01:34 +0000711int
Chris Lattner81779692006-03-30 22:51:12 +0000712yyparse(YYPARSE_PARAM_ARG)
713 YYPARSE_PARAM_DECL
John Criswelld7881242006-01-17 17:01:34 +0000714{
Reid Spencer68a24bd2005-08-27 18:50:39 +0000715 register int yystate;
716 register int yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000717 register short *yyssp;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000718 register YYSTYPE *yyvsp;
Chris Lattner81779692006-03-30 22:51:12 +0000719 int yyerrstatus; /* number of tokens to shift before error messages enabled */
720 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000721
Chris Lattner81779692006-03-30 22:51:12 +0000722 short yyssa[YYINITDEPTH]; /* the state stack */
723 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000724
Chris Lattner81779692006-03-30 22:51:12 +0000725 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
726 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000727
Chris Lattner81779692006-03-30 22:51:12 +0000728#ifdef YYLSP_NEEDED
729 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
730 YYLTYPE *yyls = yylsa;
731 YYLTYPE *yylsp;
732
733#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
734#else
Reid Spencer68a24bd2005-08-27 18:50:39 +0000735#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattner81779692006-03-30 22:51:12 +0000736#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000737
Chris Lattner81779692006-03-30 22:51:12 +0000738 int yystacksize = YYINITDEPTH;
739 int yyfree_stacks = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000740
Chris Lattner81779692006-03-30 22:51:12 +0000741#ifdef YYPURE
742 int yychar;
743 YYSTYPE yylval;
744 int yynerrs;
745#ifdef YYLSP_NEEDED
746 YYLTYPE yylloc;
747#endif
748#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000749
Chris Lattner81779692006-03-30 22:51:12 +0000750 YYSTYPE yyval; /* the variable used to return */
751 /* semantic values from the action */
752 /* routines */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000753
Reid Spencer68a24bd2005-08-27 18:50:39 +0000754 int yylen;
755
Chris Lattner81779692006-03-30 22:51:12 +0000756#if YYDEBUG != 0
757 if (yydebug)
758 fprintf(stderr, "Starting parse\n");
759#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000760
761 yystate = 0;
762 yyerrstatus = 0;
763 yynerrs = 0;
764 yychar = YYEMPTY; /* Cause a token to be read. */
765
766 /* Initialize stack pointers.
767 Waste one element of value and location stack
768 so that they stay on the same level as the state stack.
769 The wasted elements are never initialized. */
770
Chris Lattner81779692006-03-30 22:51:12 +0000771 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000772 yyvsp = yyvs;
Chris Lattner81779692006-03-30 22:51:12 +0000773#ifdef YYLSP_NEEDED
774 yylsp = yyls;
775#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000776
Chris Lattner81779692006-03-30 22:51:12 +0000777/* Push a new state, which is found in yystate . */
778/* In all cases, when you get here, the value and location stacks
779 have just been pushed. so pushing a state here evens the stacks. */
780yynewstate:
Reid Spencer68a24bd2005-08-27 18:50:39 +0000781
Chris Lattner81779692006-03-30 22:51:12 +0000782 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000783
Chris Lattner81779692006-03-30 22:51:12 +0000784 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000785 {
Chris Lattner81779692006-03-30 22:51:12 +0000786 /* Give user a chance to reallocate the stack */
787 /* Use copies of these so that the &'s don't force the real ones into memory. */
788 YYSTYPE *yyvs1 = yyvs;
789 short *yyss1 = yyss;
790#ifdef YYLSP_NEEDED
791 YYLTYPE *yyls1 = yyls;
792#endif
793
Reid Spencer68a24bd2005-08-27 18:50:39 +0000794 /* Get the current used size of the three stacks, in elements. */
Chris Lattner81779692006-03-30 22:51:12 +0000795 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000796
797#ifdef yyoverflow
Chris Lattner81779692006-03-30 22:51:12 +0000798 /* Each stack pointer address is followed by the size of
799 the data in use in that stack, in bytes. */
800#ifdef YYLSP_NEEDED
801 /* This used to be a conditional around just the two extra args,
802 but that might be undefined if yyoverflow is a macro. */
803 yyoverflow("parser stack overflow",
804 &yyss1, size * sizeof (*yyssp),
805 &yyvs1, size * sizeof (*yyvsp),
806 &yyls1, size * sizeof (*yylsp),
807 &yystacksize);
808#else
809 yyoverflow("parser stack overflow",
810 &yyss1, size * sizeof (*yyssp),
811 &yyvs1, size * sizeof (*yyvsp),
812 &yystacksize);
813#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000814
Chris Lattner81779692006-03-30 22:51:12 +0000815 yyss = yyss1; yyvs = yyvs1;
816#ifdef YYLSP_NEEDED
817 yyls = yyls1;
818#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000819#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000820 /* Extend the stack our own way. */
Chris Lattner81779692006-03-30 22:51:12 +0000821 if (yystacksize >= YYMAXDEPTH)
822 {
823 yyerror("parser stack overflow");
824 if (yyfree_stacks)
825 {
826 free (yyss);
827 free (yyvs);
828#ifdef YYLSP_NEEDED
829 free (yyls);
830#endif
831 }
832 return 2;
833 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000834 yystacksize *= 2;
Chris Lattner81779692006-03-30 22:51:12 +0000835 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000836 yystacksize = YYMAXDEPTH;
Chris Lattner81779692006-03-30 22:51:12 +0000837#ifndef YYSTACK_USE_ALLOCA
838 yyfree_stacks = 1;
839#endif
840 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
841 __yy_memcpy ((char *)yyss, (char *)yyss1,
842 size * (unsigned int) sizeof (*yyssp));
843 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
844 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
845 size * (unsigned int) sizeof (*yyvsp));
846#ifdef YYLSP_NEEDED
847 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
848 __yy_memcpy ((char *)yyls, (char *)yyls1,
849 size * (unsigned int) sizeof (*yylsp));
850#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000851#endif /* no yyoverflow */
852
Chris Lattner81779692006-03-30 22:51:12 +0000853 yyssp = yyss + size - 1;
854 yyvsp = yyvs + size - 1;
855#ifdef YYLSP_NEEDED
856 yylsp = yyls + size - 1;
857#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000858
Chris Lattner81779692006-03-30 22:51:12 +0000859#if YYDEBUG != 0
860 if (yydebug)
861 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
862#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000863
Chris Lattner81779692006-03-30 22:51:12 +0000864 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000865 YYABORT;
866 }
867
Chris Lattner81779692006-03-30 22:51:12 +0000868#if YYDEBUG != 0
869 if (yydebug)
870 fprintf(stderr, "Entering state %d\n", yystate);
871#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000872
873 goto yybackup;
Chris Lattner81779692006-03-30 22:51:12 +0000874 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +0000875
876/* Do appropriate processing given the current state. */
877/* Read a lookahead token if we need one and don't already have one. */
878/* yyresume: */
879
880 /* First try to decide what to do without reference to lookahead token. */
881
882 yyn = yypact[yystate];
Chris Lattner81779692006-03-30 22:51:12 +0000883 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000884 goto yydefault;
885
886 /* Not known => get a lookahead token if don't already have one. */
887
Chris Lattner81779692006-03-30 22:51:12 +0000888 /* yychar is either YYEMPTY or YYEOF
889 or a valid token in external form. */
890
Reid Spencer68a24bd2005-08-27 18:50:39 +0000891 if (yychar == YYEMPTY)
892 {
Chris Lattner81779692006-03-30 22:51:12 +0000893#if YYDEBUG != 0
894 if (yydebug)
895 fprintf(stderr, "Reading a token: ");
896#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000897 yychar = YYLEX;
898 }
899
Chris Lattner81779692006-03-30 22:51:12 +0000900 /* Convert token to internal form (in yychar1) for indexing tables with */
901
902 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000903 {
Chris Lattner81779692006-03-30 22:51:12 +0000904 yychar1 = 0;
905 yychar = YYEOF; /* Don't call YYLEX any more */
906
907#if YYDEBUG != 0
908 if (yydebug)
909 fprintf(stderr, "Now at end of input.\n");
910#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000911 }
912 else
913 {
Chris Lattner81779692006-03-30 22:51:12 +0000914 yychar1 = YYTRANSLATE(yychar);
915
916#if YYDEBUG != 0
917 if (yydebug)
918 {
919 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
920 /* Give the individual parser a way to print the precise meaning
921 of a token, for further debugging info. */
922#ifdef YYPRINT
923 YYPRINT (stderr, yychar, yylval);
924#endif
925 fprintf (stderr, ")\n");
926 }
927#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000928 }
929
Chris Lattner81779692006-03-30 22:51:12 +0000930 yyn += yychar1;
931 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000932 goto yydefault;
Chris Lattner81779692006-03-30 22:51:12 +0000933
Reid Spencer68a24bd2005-08-27 18:50:39 +0000934 yyn = yytable[yyn];
Chris Lattner81779692006-03-30 22:51:12 +0000935
936 /* yyn is what to do for this token type in this state.
937 Negative => reduce, -yyn is rule number.
938 Positive => shift, yyn is new state.
939 New state is final state => don't bother to shift,
940 just return success.
941 0, or most negative number => error. */
942
943 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000944 {
Chris Lattner81779692006-03-30 22:51:12 +0000945 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000946 goto yyerrlab;
947 yyn = -yyn;
948 goto yyreduce;
949 }
Chris Lattner81779692006-03-30 22:51:12 +0000950 else if (yyn == 0)
951 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000952
953 if (yyn == YYFINAL)
954 YYACCEPT;
955
956 /* Shift the lookahead token. */
Chris Lattner81779692006-03-30 22:51:12 +0000957
958#if YYDEBUG != 0
959 if (yydebug)
960 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
961#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000962
963 /* Discard the token being shifted unless it is eof. */
964 if (yychar != YYEOF)
965 yychar = YYEMPTY;
966
967 *++yyvsp = yylval;
Chris Lattner81779692006-03-30 22:51:12 +0000968#ifdef YYLSP_NEEDED
969 *++yylsp = yylloc;
970#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000971
Chris Lattner81779692006-03-30 22:51:12 +0000972 /* count tokens shifted since error; after three, turn off error status. */
973 if (yyerrstatus) yyerrstatus--;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000974
975 yystate = yyn;
976 goto yynewstate;
977
Chris Lattner81779692006-03-30 22:51:12 +0000978/* Do the default action for the current state. */
John Criswelld7881242006-01-17 17:01:34 +0000979yydefault:
Chris Lattner81779692006-03-30 22:51:12 +0000980
Reid Spencer68a24bd2005-08-27 18:50:39 +0000981 yyn = yydefact[yystate];
982 if (yyn == 0)
983 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000984
Chris Lattner81779692006-03-30 22:51:12 +0000985/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000986yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +0000987 yylen = yyr2[yyn];
Chris Lattner81779692006-03-30 22:51:12 +0000988 if (yylen > 0)
989 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000990
Chris Lattner81779692006-03-30 22:51:12 +0000991#if YYDEBUG != 0
992 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000993 {
Chris Lattner81779692006-03-30 22:51:12 +0000994 int i;
995
996 fprintf (stderr, "Reducing via rule %d (line %d), ",
997 yyn, yyrline[yyn]);
998
999 /* Print the symbols being reduced, and their result. */
1000 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1001 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1002 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1003 }
1004#endif
1005
1006
1007 switch (yyn) {
1008
1009case 1:
1010#line 223 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1011{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001012 yyval.Rec = Records.getClass(*yyvsp[0].StrVal);
1013 if (yyval.Rec == 0) {
1014 err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1015 exit(1);
1016 }
1017 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001018 ;
1019 break;}
1020case 2:
1021#line 234 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1022{ // string type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001023 yyval.Ty = new StringRecTy();
Chris Lattner81779692006-03-30 22:51:12 +00001024 ;
1025 break;}
1026case 3:
1027#line 236 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1028{ // bit type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001029 yyval.Ty = new BitRecTy();
Chris Lattner81779692006-03-30 22:51:12 +00001030 ;
1031 break;}
1032case 4:
1033#line 238 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1034{ // bits<x> type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001035 yyval.Ty = new BitsRecTy(yyvsp[-1].IntVal);
Chris Lattner81779692006-03-30 22:51:12 +00001036 ;
1037 break;}
1038case 5:
1039#line 240 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1040{ // int type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001041 yyval.Ty = new IntRecTy();
Chris Lattner81779692006-03-30 22:51:12 +00001042 ;
1043 break;}
1044case 6:
1045#line 242 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1046{ // list<x> type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001047 yyval.Ty = new ListRecTy(yyvsp[-1].Ty);
Chris Lattner81779692006-03-30 22:51:12 +00001048 ;
1049 break;}
1050case 7:
1051#line 244 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1052{ // code type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001053 yyval.Ty = new CodeRecTy();
Chris Lattner81779692006-03-30 22:51:12 +00001054 ;
1055 break;}
1056case 8:
1057#line 246 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1058{ // dag type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001059 yyval.Ty = new DagRecTy();
Chris Lattner81779692006-03-30 22:51:12 +00001060 ;
1061 break;}
1062case 9:
1063#line 248 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1064{ // Record Type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001065 yyval.Ty = new RecordRecTy(yyvsp[0].Rec);
Chris Lattner81779692006-03-30 22:51:12 +00001066 ;
1067 break;}
1068case 10:
1069#line 252 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1070{ yyval.IntVal = 0; ;
1071 break;}
1072case 11:
1073#line 252 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1074{ yyval.IntVal = 1; ;
1075 break;}
1076case 12:
1077#line 254 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1078{ yyval.Initializer = 0; ;
1079 break;}
1080case 13:
1081#line 254 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1082{ yyval.Initializer = yyvsp[0].Initializer; ;
1083 break;}
1084case 14:
1085#line 256 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1086{
1087 if (const RecordVal *RV = (CurRec ? CurRec->getValue(*yyvsp[0].StrVal) : 0)) {
1088 yyval.Initializer = new VarInit(*yyvsp[0].StrVal, RV->getType());
1089 } else if (CurRec && CurRec->isTemplateArg(CurRec->getName()+":"+*yyvsp[0].StrVal)) {
1090 const RecordVal *RV = CurRec->getValue(CurRec->getName()+":"+*yyvsp[0].StrVal);
1091 assert(RV && "Template arg doesn't exist??");
1092 yyval.Initializer = new VarInit(CurRec->getName()+":"+*yyvsp[0].StrVal, RV->getType());
1093 } else if (Record *D = Records.getDef(*yyvsp[0].StrVal)) {
1094 yyval.Initializer = new DefInit(D);
1095 } else {
1096 err() << "Variable not defined: '" << *yyvsp[0].StrVal << "'!\n";
1097 exit(1);
1098 }
1099
1100 delete yyvsp[0].StrVal;
1101;
1102 break;}
1103case 15:
1104#line 273 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1105{
1106 yyval.Initializer = yyvsp[0].Initializer;
1107 ;
1108 break;}
1109case 16:
1110#line 275 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1111{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001112 yyval.Initializer = new IntInit(yyvsp[0].IntVal);
Chris Lattner81779692006-03-30 22:51:12 +00001113 ;
1114 break;}
1115case 17:
1116#line 277 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1117{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001118 yyval.Initializer = new StringInit(*yyvsp[0].StrVal);
1119 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001120 ;
1121 break;}
1122case 18:
1123#line 280 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1124{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001125 yyval.Initializer = new CodeInit(*yyvsp[0].StrVal);
1126 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001127 ;
1128 break;}
1129case 19:
1130#line 283 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1131{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001132 yyval.Initializer = new UnsetInit();
Chris Lattner81779692006-03-30 22:51:12 +00001133 ;
1134 break;}
1135case 20:
1136#line 285 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1137{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001138 BitsInit *Init = new BitsInit(yyvsp[-1].FieldList->size());
1139 for (unsigned i = 0, e = yyvsp[-1].FieldList->size(); i != e; ++i) {
1140 struct Init *Bit = (*yyvsp[-1].FieldList)[i]->convertInitializerTo(new BitRecTy());
1141 if (Bit == 0) {
Chris Lattnerba4b1442005-09-08 18:22:57 +00001142 err() << "Element #" << i << " (" << *(*yyvsp[-1].FieldList)[i]
1143 << ") is not convertable to a bit!\n";
1144 exit(1);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001145 }
1146 Init->setBit(yyvsp[-1].FieldList->size()-i-1, Bit);
1147 }
1148 yyval.Initializer = Init;
1149 delete yyvsp[-1].FieldList;
Chris Lattner81779692006-03-30 22:51:12 +00001150 ;
1151 break;}
1152case 21:
1153#line 298 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1154{
Chris Lattnerca572be2005-09-08 18:48:47 +00001155 // This is a CLASS<initvalslist> expression. This is supposed to synthesize
1156 // a new anonymous definition, deriving from CLASS<initvalslist> with no
1157 // body.
1158 Record *Class = Records.getClass(*yyvsp[-3].StrVal);
1159 if (!Class) {
1160 err() << "Expected a class, got '" << *yyvsp[-3].StrVal << "'!\n";
1161 exit(1);
1162 }
1163 delete yyvsp[-3].StrVal;
1164
1165 static unsigned AnonCounter = 0;
1166 Record *OldRec = CurRec; // Save CurRec.
1167
1168 // Create the new record, set it as CurRec temporarily.
1169 CurRec = new Record("anonymous.val."+utostr(AnonCounter++));
1170 addSubClass(Class, *yyvsp[-1].FieldList); // Add info about the subclass to CurRec.
1171 delete yyvsp[-1].FieldList; // Free up the template args.
1172
Chris Lattner751eabf2005-09-08 19:47:28 +00001173 CurRec->resolveReferences();
Chris Lattnerca572be2005-09-08 18:48:47 +00001174
1175 Records.addDef(CurRec);
1176
1177 // The result of the expression is a reference to the new record.
1178 yyval.Initializer = new DefInit(CurRec);
1179
1180 // Restore the old CurRec
1181 CurRec = OldRec;
Chris Lattner81779692006-03-30 22:51:12 +00001182 ;
1183 break;}
1184case 22:
1185#line 326 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1186{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001187 yyval.Initializer = yyvsp[-3].Initializer->convertInitializerBitRange(*yyvsp[-1].BitList);
1188 if (yyval.Initializer == 0) {
1189 err() << "Invalid bit range for value '" << *yyvsp[-3].Initializer << "'!\n";
1190 exit(1);
1191 }
1192 delete yyvsp[-1].BitList;
Chris Lattner81779692006-03-30 22:51:12 +00001193 ;
1194 break;}
1195case 23:
1196#line 333 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1197{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001198 yyval.Initializer = new ListInit(*yyvsp[-1].FieldList);
1199 delete yyvsp[-1].FieldList;
Chris Lattner81779692006-03-30 22:51:12 +00001200 ;
1201 break;}
1202case 24:
1203#line 336 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1204{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001205 if (!yyvsp[-2].Initializer->getFieldType(*yyvsp[0].StrVal)) {
1206 err() << "Cannot access field '" << *yyvsp[0].StrVal << "' of value '" << *yyvsp[-2].Initializer << "!\n";
1207 exit(1);
1208 }
1209 yyval.Initializer = new FieldInit(yyvsp[-2].Initializer, *yyvsp[0].StrVal);
1210 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001211 ;
1212 break;}
1213case 25:
1214#line 343 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1215{
1216 yyval.Initializer = new DagInit(yyvsp[-2].Initializer, *yyvsp[-1].DagValueList);
1217 delete yyvsp[-1].DagValueList;
1218 ;
1219 break;}
1220case 26:
1221#line 346 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1222{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001223 std::reverse(yyvsp[-1].BitList->begin(), yyvsp[-1].BitList->end());
1224 yyval.Initializer = yyvsp[-3].Initializer->convertInitListSlice(*yyvsp[-1].BitList);
1225 if (yyval.Initializer == 0) {
1226 err() << "Invalid list slice for value '" << *yyvsp[-3].Initializer << "'!\n";
1227 exit(1);
1228 }
1229 delete yyvsp[-1].BitList;
Chris Lattner81779692006-03-30 22:51:12 +00001230 ;
1231 break;}
1232case 27:
1233#line 354 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1234{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001235 yyval.Initializer = yyvsp[-3].Initializer->getBinaryOp(Init::SHL, yyvsp[-1].Initializer);
1236 if (yyval.Initializer == 0) {
1237 err() << "Cannot shift values '" << *yyvsp[-3].Initializer << "' and '" << *yyvsp[-1].Initializer << "'!\n";
1238 exit(1);
1239 }
Chris Lattner81779692006-03-30 22:51:12 +00001240 ;
1241 break;}
1242case 28:
1243#line 360 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1244{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001245 yyval.Initializer = yyvsp[-3].Initializer->getBinaryOp(Init::SRA, yyvsp[-1].Initializer);
1246 if (yyval.Initializer == 0) {
1247 err() << "Cannot shift values '" << *yyvsp[-3].Initializer << "' and '" << *yyvsp[-1].Initializer << "'!\n";
1248 exit(1);
1249 }
Chris Lattner81779692006-03-30 22:51:12 +00001250 ;
1251 break;}
1252case 29:
1253#line 366 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1254{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001255 yyval.Initializer = yyvsp[-3].Initializer->getBinaryOp(Init::SRL, yyvsp[-1].Initializer);
1256 if (yyval.Initializer == 0) {
1257 err() << "Cannot shift values '" << *yyvsp[-3].Initializer << "' and '" << *yyvsp[-1].Initializer << "'!\n";
1258 exit(1);
1259 }
Chris Lattner81779692006-03-30 22:51:12 +00001260 ;
1261 break;}
1262case 30:
1263#line 374 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1264{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001265 yyval.StrVal = new std::string();
Chris Lattner81779692006-03-30 22:51:12 +00001266 ;
1267 break;}
1268case 31:
1269#line 377 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1270{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001271 yyval.StrVal = yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001272 ;
1273 break;}
1274case 32:
1275#line 381 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1276{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001277 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1278 yyval.DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1279 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001280 ;
1281 break;}
1282case 33:
1283#line 386 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1284{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001285 yyvsp[-3].DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1286 delete yyvsp[0].StrVal;
1287 yyval.DagValueList = yyvsp[-3].DagValueList;
Chris Lattner81779692006-03-30 22:51:12 +00001288 ;
1289 break;}
1290case 34:
1291#line 392 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1292{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001293 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
Chris Lattner81779692006-03-30 22:51:12 +00001294 ;
1295 break;}
1296case 35:
1297#line 395 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1298{ yyval.DagValueList = yyvsp[0].DagValueList; ;
1299 break;}
1300case 36:
1301#line 398 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1302{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001303 yyval.BitList = new std::vector<unsigned>();
1304 yyval.BitList->push_back(yyvsp[0].IntVal);
Chris Lattner81779692006-03-30 22:51:12 +00001305 ;
1306 break;}
1307case 37:
1308#line 401 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1309{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001310 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1311 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1312 exit(1);
1313 }
1314 yyval.BitList = new std::vector<unsigned>();
1315 if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1316 for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1317 yyval.BitList->push_back(i);
1318 } else {
1319 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1320 yyval.BitList->push_back(i);
1321 }
Chris Lattner81779692006-03-30 22:51:12 +00001322 ;
1323 break;}
1324case 38:
1325#line 414 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1326{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001327 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1328 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1329 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1330 exit(1);
1331 }
1332 yyval.BitList = new std::vector<unsigned>();
1333 if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1334 for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1335 yyval.BitList->push_back(i);
1336 } else {
1337 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1338 yyval.BitList->push_back(i);
1339 }
Chris Lattner81779692006-03-30 22:51:12 +00001340 ;
1341 break;}
1342case 39:
1343#line 428 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1344{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001345 (yyval.BitList=yyvsp[-2].BitList)->push_back(yyvsp[0].IntVal);
Chris Lattner81779692006-03-30 22:51:12 +00001346 ;
1347 break;}
1348case 40:
1349#line 430 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1350{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001351 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1352 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1353 exit(1);
1354 }
1355 yyval.BitList = yyvsp[-4].BitList;
1356 if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1357 for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1358 yyval.BitList->push_back(i);
1359 } else {
1360 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1361 yyval.BitList->push_back(i);
1362 }
Chris Lattner81779692006-03-30 22:51:12 +00001363 ;
1364 break;}
1365case 41:
1366#line 443 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1367{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001368 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1369 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1370 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1371 exit(1);
1372 }
1373 yyval.BitList = yyvsp[-3].BitList;
1374 if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1375 for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1376 yyval.BitList->push_back(i);
1377 } else {
1378 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1379 yyval.BitList->push_back(i);
1380 }
Chris Lattner81779692006-03-30 22:51:12 +00001381 ;
1382 break;}
1383case 42:
1384#line 459 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1385{ yyval.BitList = yyvsp[0].BitList; std::reverse(yyvsp[0].BitList->begin(), yyvsp[0].BitList->end()); ;
1386 break;}
1387case 43:
1388#line 461 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1389{ yyval.BitList = 0; ;
1390 break;}
1391case 44:
1392#line 461 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1393{ yyval.BitList = yyvsp[-1].BitList; ;
1394 break;}
1395case 45:
1396#line 465 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1397{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001398 yyval.FieldList = new std::vector<Init*>();
Chris Lattner81779692006-03-30 22:51:12 +00001399 ;
1400 break;}
1401case 46:
1402#line 467 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1403{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001404 yyval.FieldList = yyvsp[0].FieldList;
Chris Lattner81779692006-03-30 22:51:12 +00001405 ;
1406 break;}
1407case 47:
1408#line 471 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1409{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001410 yyval.FieldList = new std::vector<Init*>();
1411 yyval.FieldList->push_back(yyvsp[0].Initializer);
Chris Lattner81779692006-03-30 22:51:12 +00001412 ;
1413 break;}
1414case 48:
1415#line 474 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1416{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001417 (yyval.FieldList = yyvsp[-2].FieldList)->push_back(yyvsp[0].Initializer);
Chris Lattner81779692006-03-30 22:51:12 +00001418 ;
1419 break;}
1420case 49:
1421#line 478 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1422{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001423 std::string DecName = *yyvsp[-1].StrVal;
1424 if (ParsingTemplateArgs)
1425 DecName = CurRec->getName() + ":" + DecName;
1426
1427 addValue(RecordVal(DecName, yyvsp[-2].Ty, yyvsp[-3].IntVal));
1428 setValue(DecName, 0, yyvsp[0].Initializer);
1429 yyval.StrVal = new std::string(DecName);
Chris Lattner81779692006-03-30 22:51:12 +00001430;
1431 break;}
1432case 50:
1433#line 488 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1434{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001435 delete yyvsp[-1].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001436;
1437 break;}
1438case 51:
1439#line 490 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1440{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001441 setValue(*yyvsp[-4].StrVal, yyvsp[-3].BitList, yyvsp[-1].Initializer);
1442 delete yyvsp[-4].StrVal;
1443 delete yyvsp[-3].BitList;
Chris Lattner81779692006-03-30 22:51:12 +00001444;
1445 break;}
1446case 56:
1447#line 499 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1448{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001449 yyval.SubClassRef = new SubClassRefTy(yyvsp[0].Rec, new std::vector<Init*>());
Chris Lattner81779692006-03-30 22:51:12 +00001450 ;
1451 break;}
1452case 57:
1453#line 501 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1454{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001455 yyval.SubClassRef = new SubClassRefTy(yyvsp[-3].Rec, yyvsp[-1].FieldList);
Chris Lattner81779692006-03-30 22:51:12 +00001456 ;
1457 break;}
1458case 58:
1459#line 505 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1460{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001461 yyval.SubClassList = new std::vector<SubClassRefTy>();
1462 yyval.SubClassList->push_back(*yyvsp[0].SubClassRef);
1463 delete yyvsp[0].SubClassRef;
Chris Lattner81779692006-03-30 22:51:12 +00001464 ;
1465 break;}
1466case 59:
1467#line 510 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1468{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001469 (yyval.SubClassList=yyvsp[-2].SubClassList)->push_back(*yyvsp[0].SubClassRef);
1470 delete yyvsp[0].SubClassRef;
Chris Lattner81779692006-03-30 22:51:12 +00001471 ;
1472 break;}
1473case 60:
1474#line 515 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1475{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001476 yyval.SubClassList = new std::vector<SubClassRefTy>();
Chris Lattner81779692006-03-30 22:51:12 +00001477 ;
1478 break;}
1479case 61:
1480#line 518 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1481{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001482 yyval.SubClassList = yyvsp[0].SubClassList;
Chris Lattner81779692006-03-30 22:51:12 +00001483 ;
1484 break;}
1485case 62:
1486#line 522 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1487{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001488 CurRec->addTemplateArg(*yyvsp[0].StrVal);
1489 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001490;
1491 break;}
1492case 63:
1493#line 525 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1494{
Chris Lattnerca572be2005-09-08 18:48:47 +00001495 CurRec->addTemplateArg(*yyvsp[0].StrVal);
1496 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001497;
1498 break;}
1499case 64:
1500#line 530 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1501{;
1502 break;}
1503case 67:
1504#line 533 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1505{ yyval.StrVal = yyvsp[0].StrVal; ;
1506 break;}
1507case 68:
1508#line 533 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1509{ yyval.StrVal = new std::string(); ;
1510 break;}
1511case 69:
1512#line 535 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1513{
Chris Lattner8d354e92005-09-30 04:11:27 +00001514 static unsigned AnonCounter = 0;
1515 if (yyvsp[0].StrVal->empty())
1516 *yyvsp[0].StrVal = "anonymous."+utostr(AnonCounter++);
Chris Lattner946ac932005-09-30 04:53:25 +00001517 yyval.StrVal = yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001518;
1519 break;}
1520case 70:
1521#line 542 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1522{
Chris Lattner946ac932005-09-30 04:53:25 +00001523 // If a class of this name already exists, it must be a forward ref.
Chris Lattner88b7e6e2005-09-30 06:09:50 +00001524 if ((CurRec = Records.getClass(*yyvsp[0].StrVal))) {
Chris Lattner946ac932005-09-30 04:53:25 +00001525 // If the body was previously defined, this is an error.
1526 if (!CurRec->getValues().empty() ||
1527 !CurRec->getSuperClasses().empty() ||
1528 !CurRec->getTemplateArgs().empty()) {
1529 err() << "Class '" << CurRec->getName() << "' already defined!\n";
1530 exit(1);
1531 }
1532 } else {
1533 // If this is the first reference to this class, create and add it.
1534 CurRec = new Record(*yyvsp[0].StrVal);
1535 Records.addClass(CurRec);
Chris Lattner8d354e92005-09-30 04:11:27 +00001536 }
Chris Lattner946ac932005-09-30 04:53:25 +00001537 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001538;
1539 break;}
1540case 71:
1541#line 560 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1542{
Chris Lattner946ac932005-09-30 04:53:25 +00001543 CurRec = new Record(*yyvsp[0].StrVal);
1544 delete yyvsp[0].StrVal;
1545
Chris Lattner8d354e92005-09-30 04:11:27 +00001546 // Ensure redefinition doesn't happen.
1547 if (Records.getDef(CurRec->getName())) {
1548 err() << "Def '" << CurRec->getName() << "' already defined!\n";
1549 exit(1);
1550 }
1551 Records.addDef(CurRec);
Chris Lattner81779692006-03-30 22:51:12 +00001552;
1553 break;}
1554case 72:
1555#line 572 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1556{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001557 for (unsigned i = 0, e = yyvsp[0].SubClassList->size(); i != e; ++i) {
Chris Lattnerba4b1442005-09-08 18:22:57 +00001558 addSubClass((*yyvsp[0].SubClassList)[i].first, *(*yyvsp[0].SubClassList)[i].second);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001559 // Delete the template arg values for the class
1560 delete (*yyvsp[0].SubClassList)[i].second;
1561 }
1562 delete yyvsp[0].SubClassList; // Delete the class list...
Chris Lattner0a284052005-09-30 04:42:56 +00001563
Chris Lattnerba4b1442005-09-08 18:22:57 +00001564 // Process any variables on the set stack...
1565 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001566 for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
1567 setValue(LetStack[i][j].Name,
1568 LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
1569 LetStack[i][j].Value);
Chris Lattner81779692006-03-30 22:51:12 +00001570 ;
1571 break;}
1572case 73:
1573#line 586 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1574{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001575 yyval.Rec = CurRec;
1576 CurRec = 0;
Chris Lattner81779692006-03-30 22:51:12 +00001577 ;
1578 break;}
1579case 74:
1580#line 591 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1581{
Chris Lattner946ac932005-09-30 04:53:25 +00001582 ParsingTemplateArgs = true;
Chris Lattner81779692006-03-30 22:51:12 +00001583 ;
1584 break;}
1585case 75:
1586#line 593 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1587{
Chris Lattner946ac932005-09-30 04:53:25 +00001588 ParsingTemplateArgs = false;
Chris Lattner81779692006-03-30 22:51:12 +00001589 ;
1590 break;}
1591case 76:
1592#line 595 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1593{
Chris Lattner0a284052005-09-30 04:42:56 +00001594 yyval.Rec = yyvsp[0].Rec;
Chris Lattner81779692006-03-30 22:51:12 +00001595 ;
1596 break;}
1597case 77:
1598#line 599 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1599{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001600 yyvsp[0].Rec->resolveReferences();
1601
Chris Lattnerca572be2005-09-08 18:48:47 +00001602 // If ObjectBody has template arguments, it's an error.
Chris Lattner0a284052005-09-30 04:42:56 +00001603 assert(yyvsp[0].Rec->getTemplateArgs().empty() && "How'd this get template args?");
Chris Lattner8d354e92005-09-30 04:11:27 +00001604 yyval.Rec = yyvsp[0].Rec;
Chris Lattner81779692006-03-30 22:51:12 +00001605;
1606 break;}
1607case 80:
1608#line 610 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1609{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001610 LetStack.back().push_back(LetRecord(*yyvsp[-3].StrVal, yyvsp[-2].BitList, yyvsp[0].Initializer));
1611 delete yyvsp[-3].StrVal; delete yyvsp[-2].BitList;
Chris Lattner81779692006-03-30 22:51:12 +00001612;
1613 break;}
1614case 83:
1615#line 618 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1616{ LetStack.push_back(std::vector<LetRecord>()); ;
1617 break;}
1618case 85:
1619#line 621 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1620{
Chris Lattner946ac932005-09-30 04:53:25 +00001621 LetStack.pop_back();
Chris Lattner81779692006-03-30 22:51:12 +00001622 ;
1623 break;}
1624case 86:
1625#line 624 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1626{
Chris Lattner946ac932005-09-30 04:53:25 +00001627 LetStack.pop_back();
Chris Lattner81779692006-03-30 22:51:12 +00001628 ;
1629 break;}
1630case 87:
1631#line 628 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1632{;
1633 break;}
1634case 88:
1635#line 628 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1636{;
1637 break;}
1638case 89:
1639#line 630 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1640{;
1641 break;}
1642}
1643 /* the action file gets copied in in place of this dollarsign */
1644#line 543 "/usr/share/bison.simple"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001645
1646 yyvsp -= yylen;
1647 yyssp -= yylen;
Chris Lattner81779692006-03-30 22:51:12 +00001648#ifdef YYLSP_NEEDED
1649 yylsp -= yylen;
1650#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001651
Chris Lattner81779692006-03-30 22:51:12 +00001652#if YYDEBUG != 0
1653 if (yydebug)
1654 {
1655 short *ssp1 = yyss - 1;
1656 fprintf (stderr, "state stack now");
1657 while (ssp1 != yyssp)
1658 fprintf (stderr, " %d", *++ssp1);
1659 fprintf (stderr, "\n");
1660 }
1661#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001662
1663 *++yyvsp = yyval;
1664
Chris Lattner81779692006-03-30 22:51:12 +00001665#ifdef YYLSP_NEEDED
1666 yylsp++;
1667 if (yylen == 0)
1668 {
1669 yylsp->first_line = yylloc.first_line;
1670 yylsp->first_column = yylloc.first_column;
1671 yylsp->last_line = (yylsp-1)->last_line;
1672 yylsp->last_column = (yylsp-1)->last_column;
1673 yylsp->text = 0;
1674 }
1675 else
1676 {
1677 yylsp->last_line = (yylsp+yylen-1)->last_line;
1678 yylsp->last_column = (yylsp+yylen-1)->last_column;
1679 }
1680#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001681
Chris Lattner81779692006-03-30 22:51:12 +00001682 /* Now "shift" the result of the reduction.
1683 Determine what state that goes to,
1684 based on the state we popped back to
1685 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001686
1687 yyn = yyr1[yyn];
1688
Chris Lattner81779692006-03-30 22:51:12 +00001689 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1690 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001691 yystate = yytable[yystate];
1692 else
Chris Lattner81779692006-03-30 22:51:12 +00001693 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00001694
1695 goto yynewstate;
1696
Chris Lattner81779692006-03-30 22:51:12 +00001697yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001698
Chris Lattner81779692006-03-30 22:51:12 +00001699 if (! yyerrstatus)
1700 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001701 {
1702 ++yynerrs;
Chris Lattner81779692006-03-30 22:51:12 +00001703
1704#ifdef YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00001705 yyn = yypact[yystate];
1706
Chris Lattner81779692006-03-30 22:51:12 +00001707 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001708 {
Chris Lattner81779692006-03-30 22:51:12 +00001709 int size = 0;
1710 char *msg;
1711 int x, count;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001712
Chris Lattner81779692006-03-30 22:51:12 +00001713 count = 0;
1714 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1715 for (x = (yyn < 0 ? -yyn : 0);
1716 x < (sizeof(yytname) / sizeof(char *)); x++)
1717 if (yycheck[x + yyn] == x)
1718 size += strlen(yytname[x]) + 15, count++;
1719 msg = (char *) malloc(size + 15);
1720 if (msg != 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001721 {
Chris Lattner81779692006-03-30 22:51:12 +00001722 strcpy(msg, "parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001723
Chris Lattner81779692006-03-30 22:51:12 +00001724 if (count < 5)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001725 {
Chris Lattner81779692006-03-30 22:51:12 +00001726 count = 0;
1727 for (x = (yyn < 0 ? -yyn : 0);
1728 x < (sizeof(yytname) / sizeof(char *)); x++)
1729 if (yycheck[x + yyn] == x)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001730 {
Chris Lattner81779692006-03-30 22:51:12 +00001731 strcat(msg, count == 0 ? ", expecting `" : " or `");
1732 strcat(msg, yytname[x]);
1733 strcat(msg, "'");
1734 count++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001735 }
1736 }
Chris Lattner81779692006-03-30 22:51:12 +00001737 yyerror(msg);
1738 free(msg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001739 }
1740 else
Chris Lattner81779692006-03-30 22:51:12 +00001741 yyerror ("parse error; also virtual memory exceeded");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001742 }
1743 else
1744#endif /* YYERROR_VERBOSE */
Chris Lattner81779692006-03-30 22:51:12 +00001745 yyerror("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001746 }
1747
Chris Lattner81779692006-03-30 22:51:12 +00001748 goto yyerrlab1;
1749yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001750
1751 if (yyerrstatus == 3)
1752 {
Chris Lattner81779692006-03-30 22:51:12 +00001753 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001754
Chris Lattner81779692006-03-30 22:51:12 +00001755 /* return failure if at end of input */
Chris Lattnerba4b1442005-09-08 18:22:57 +00001756 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001757 YYABORT;
1758
Chris Lattner81779692006-03-30 22:51:12 +00001759#if YYDEBUG != 0
1760 if (yydebug)
1761 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1762#endif
Chris Lattnerba4b1442005-09-08 18:22:57 +00001763
Chris Lattner81779692006-03-30 22:51:12 +00001764 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001765 }
1766
Chris Lattner81779692006-03-30 22:51:12 +00001767 /* Else will try to reuse lookahead token
1768 after shifting the error token. */
1769
1770 yyerrstatus = 3; /* Each real token shifted decrements this */
1771
1772 goto yyerrhandle;
1773
1774yyerrdefault: /* current state does not do anything special for the error token. */
1775
1776#if 0
1777 /* This is wrong; only states that explicitly want error tokens
1778 should shift them. */
1779 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1780 if (yyn) goto yydefault;
1781#endif
1782
1783yyerrpop: /* pop the current state because it cannot handle the error token */
1784
1785 if (yyssp == yyss) YYABORT;
1786 yyvsp--;
1787 yystate = *--yyssp;
1788#ifdef YYLSP_NEEDED
1789 yylsp--;
1790#endif
1791
1792#if YYDEBUG != 0
1793 if (yydebug)
1794 {
1795 short *ssp1 = yyss - 1;
1796 fprintf (stderr, "Error: state stack now");
1797 while (ssp1 != yyssp)
1798 fprintf (stderr, " %d", *++ssp1);
1799 fprintf (stderr, "\n");
1800 }
1801#endif
1802
1803yyerrhandle:
1804
1805 yyn = yypact[yystate];
1806 if (yyn == YYFLAG)
1807 goto yyerrdefault;
1808
1809 yyn += YYTERROR;
1810 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1811 goto yyerrdefault;
1812
1813 yyn = yytable[yyn];
1814 if (yyn < 0)
1815 {
1816 if (yyn == YYFLAG)
1817 goto yyerrpop;
1818 yyn = -yyn;
1819 goto yyreduce;
1820 }
1821 else if (yyn == 0)
1822 goto yyerrpop;
1823
Reid Spencer68a24bd2005-08-27 18:50:39 +00001824 if (yyn == YYFINAL)
1825 YYACCEPT;
1826
Chris Lattner81779692006-03-30 22:51:12 +00001827#if YYDEBUG != 0
1828 if (yydebug)
1829 fprintf(stderr, "Shifting error token, ");
1830#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001831
1832 *++yyvsp = yylval;
Chris Lattner81779692006-03-30 22:51:12 +00001833#ifdef YYLSP_NEEDED
1834 *++yylsp = yylloc;
1835#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001836
1837 yystate = yyn;
1838 goto yynewstate;
1839
Chris Lattner81779692006-03-30 22:51:12 +00001840 yyacceptlab:
1841 /* YYACCEPT comes here. */
1842 if (yyfree_stacks)
1843 {
1844 free (yyss);
1845 free (yyvs);
1846#ifdef YYLSP_NEEDED
1847 free (yyls);
Chris Lattner2b931e82005-09-12 05:30:06 +00001848#endif
Chris Lattner81779692006-03-30 22:51:12 +00001849 }
1850 return 0;
John Criswelld7881242006-01-17 17:01:34 +00001851
Chris Lattner81779692006-03-30 22:51:12 +00001852 yyabortlab:
1853 /* YYABORT comes here. */
1854 if (yyfree_stacks)
1855 {
1856 free (yyss);
1857 free (yyvs);
1858#ifdef YYLSP_NEEDED
1859 free (yyls);
John Criswelld7881242006-01-17 17:01:34 +00001860#endif
Chris Lattner81779692006-03-30 22:51:12 +00001861 }
1862 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001863}
Chris Lattner81779692006-03-30 22:51:12 +00001864#line 632 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001865
1866
1867int yyerror(const char *ErrorMsg) {
1868 err() << "Error parsing: " << ErrorMsg << "\n";
1869 exit(1);
1870}