blob: 2ab93adc704a77d53f38f948bc4af18625764fac [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattner8d354e92005-09-30 04:11:27 +00002/* A Bison parser, made from /Users/sabre/llvm/utils/TableGen/FileParser.y
3 by GNU Bison version 1.28 */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004
Chris Lattner8d354e92005-09-30 04:11:27 +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 Lattner8d354e92005-09-30 04:11:27 +00008#define yylex Filelex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror Fileerror
Chris Lattner8d354e92005-09-30 04:11:27 +000010#define yylval Filelval
11#define yychar Filechar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug Filedebug
13#define yynerrs Filenerrs
Chris Lattner8d354e92005-09-30 04:11:27 +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 Lattner8d354e92005-09-30 04:11:27 +000035#line 14 "/Users/sabre/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,
93 std::vector<unsigned> *BitList, Init *V) {
94 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 Lattner8d354e92005-09-30 04:11:27 +0000210#line 189 "/Users/sabre/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 Lattner8d354e92005-09-30 04:11:27 +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 Lattner946ac932005-09-30 04:53:25 +0000233#define YYFINAL 160
Chris Lattner8d354e92005-09-30 04:11:27 +0000234#define YYFLAG -32768
235#define YYNTBASE 38
Reid Spencer68a24bd2005-08-27 18:50:39 +0000236
Chris Lattner946ac932005-09-30 04:53:25 +0000237#define YYTRANSLATE(x) ((unsigned)(x) <= 276 ? yytranslate[x] : 78)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000238
Chris Lattner8d354e92005-09-30 04:11:27 +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 Lattner8d354e92005-09-30 04:11:27 +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, 43, 48,
274 50, 55, 59, 63, 68, 73, 80, 87, 94, 95,
275 98, 101, 106, 107, 109, 111, 115, 118, 122, 128,
276 133, 135, 136, 140, 141, 143, 145, 149, 154, 157,
277 164, 165, 168, 170, 174, 176, 181, 183, 187, 188,
278 191, 193, 197, 201, 202, 204, 206, 207, 209, 211,
Chris Lattner946ac932005-09-30 04:53:25 +0000279 213, 214, 218, 219, 220, 227, 231, 233, 235, 240,
280 242, 246, 247, 252, 257, 260, 262, 265
Chris Lattner8d354e92005-09-30 04:11:27 +0000281};
Reid Spencer68a24bd2005-08-27 18:50:39 +0000282
Chris Lattner8d354e92005-09-30 04:11:27 +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, 42, 0,
287 18, 0, 21, 0, 22, 0, 26, 0, 27, 49,
288 28, 0, 19, 23, 50, 24, 0, 19, 0, 42,
289 27, 47, 28, 0, 29, 49, 30, 0, 42, 31,
290 19, 0, 32, 19, 45, 33, 0, 42, 29, 47,
291 30, 0, 15, 32, 42, 34, 42, 33, 0, 16,
292 32, 42, 34, 42, 33, 0, 17, 32, 42, 34,
293 42, 33, 0, 0, 35, 20, 0, 42, 43, 0,
294 44, 34, 42, 43, 0, 0, 44, 0, 18, 0,
295 18, 36, 18, 0, 18, 18, 0, 46, 34, 18,
296 0, 46, 34, 18, 36, 18, 0, 46, 34, 18,
297 18, 0, 46, 0, 0, 27, 47, 28, 0, 0,
298 50, 0, 42, 0, 50, 34, 42, 0, 40, 39,
299 19, 41, 0, 51, 37, 0, 13, 19, 48, 25,
300 42, 37, 0, 0, 53, 52, 0, 37, 0, 27,
301 53, 28, 0, 38, 0, 38, 23, 50, 24, 0,
302 55, 0, 56, 34, 55, 0, 0, 35, 56, 0,
303 51, 0, 58, 34, 51, 0, 23, 58, 24, 0,
304 0, 59, 0, 19, 0, 0, 61, 0, 62, 0,
Chris Lattner946ac932005-09-30 04:53:25 +0000305 62, 0, 0, 57, 66, 54, 0, 0, 0, 10,
306 63, 68, 60, 69, 65, 0, 11, 64, 65, 0,
307 67, 0, 70, 0, 19, 48, 25, 42, 0, 72,
308 0, 73, 34, 72, 0, 0, 13, 75, 73, 14,
309 0, 74, 27, 76, 28, 0, 74, 71, 0, 71,
310 0, 76, 71, 0, 76, 0
Chris Lattner8d354e92005-09-30 04:11:27 +0000311};
Reid Spencer68a24bd2005-08-27 18:50:39 +0000312
313#endif
314
Chris Lattner8d354e92005-09-30 04:11:27 +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, 258, 261, 264, 266, 279, 307,
319 322, 329, 332, 339, 347, 355, 361, 367, 375, 378,
320 382, 387, 393, 396, 399, 402, 415, 429, 431, 444,
321 460, 462, 462, 466, 468, 472, 475, 479, 489, 491,
322 497, 497, 498, 498, 500, 502, 506, 511, 516, 519,
Chris Lattner946ac932005-09-30 04:53:25 +0000323 523, 526, 531, 532, 532, 534, 534, 536, 543, 561,
324 573, 587, 592, 594, 596, 600, 609, 609, 611, 616,
325 616, 619, 619, 622, 625, 629, 629, 631
Chris Lattner8d354e92005-09-30 04:11:27 +0000326};
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","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",
Chris Lattner946ac932005-09-30 04:53:25 +0000340"ObjectBody","@1","ClassInst","@2","@3","DefInst","Object","LETItem","LETList",
341"LETCommand","@4","ObjectList","File", NULL
Chris Lattner8d354e92005-09-30 04:11:27 +0000342};
343#endif
344
345static const short yyr1[] = { 0,
346 38, 39, 39, 39, 39, 39, 39, 39, 39, 40,
347 40, 41, 41, 42, 42, 42, 42, 42, 42, 42,
348 42, 42, 42, 42, 42, 42, 42, 42, 43, 43,
349 44, 44, 45, 45, 46, 46, 46, 46, 46, 46,
350 47, 48, 48, 49, 49, 50, 50, 51, 52, 52,
351 53, 53, 54, 54, 55, 55, 56, 56, 57, 57,
352 58, 58, 59, 60, 60, 61, 61, 62, 63, 64,
Chris Lattner946ac932005-09-30 04:53:25 +0000353 66, 65, 68, 69, 67, 70, 71, 71, 72, 73,
354 73, 75, 74, 71, 71, 76, 76, 77
Chris Lattner8d354e92005-09-30 04:11:27 +0000355};
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, 3, 4, 1,
360 4, 3, 3, 4, 4, 6, 6, 6, 0, 2,
361 2, 4, 0, 1, 1, 3, 2, 3, 5, 4,
362 1, 0, 3, 0, 1, 1, 3, 4, 2, 6,
363 0, 2, 1, 3, 1, 4, 1, 3, 0, 2,
364 1, 3, 3, 0, 1, 1, 0, 1, 1, 1,
Chris Lattner946ac932005-09-30 04:53:25 +0000365 0, 3, 0, 0, 6, 3, 1, 1, 4, 1,
366 3, 0, 4, 4, 2, 1, 2, 1
Chris Lattner8d354e92005-09-30 04:11:27 +0000367};
368
369static const short yydefact[] = { 0,
Chris Lattner946ac932005-09-30 04:53:25 +0000370 67, 67, 82, 77, 78, 86, 0, 88, 66, 68,
371 69, 73, 70, 59, 0, 0, 85, 87, 64, 0,
372 71, 76, 42, 80, 0, 0, 10, 65, 74, 1,
373 55, 57, 60, 0, 0, 0, 83, 0, 84, 11,
374 0, 61, 0, 59, 0, 0, 51, 53, 72, 35,
375 41, 0, 0, 81, 5, 3, 2, 0, 0, 7,
376 8, 9, 0, 63, 10, 75, 0, 0, 0, 14,
377 20, 15, 16, 17, 44, 44, 0, 46, 0, 58,
378 10, 37, 0, 0, 43, 79, 0, 0, 12, 62,
379 0, 0, 0, 0, 0, 45, 0, 33, 0, 0,
380 0, 56, 0, 0, 54, 0, 52, 36, 38, 0,
381 0, 0, 48, 0, 0, 0, 0, 18, 22, 29,
382 34, 0, 0, 0, 23, 47, 42, 49, 40, 0,
383 4, 6, 13, 0, 0, 0, 19, 0, 31, 0,
384 24, 21, 25, 0, 39, 0, 0, 0, 30, 29,
385 0, 26, 27, 28, 32, 0, 50, 0, 0, 0
Chris Lattner8d354e92005-09-30 04:11:27 +0000386};
387
Chris Lattner946ac932005-09-30 04:53:25 +0000388static const short yydefgoto[] = { 31,
389 63, 41, 113, 78, 139, 121, 122, 51, 52, 36,
390 95, 96, 42, 107, 81, 49, 32, 33, 21, 43,
391 28, 29, 10, 11, 12, 14, 22, 34, 4, 19,
392 44, 5, 6, 24, 25, 7, 15, 8, 158
Chris Lattner8d354e92005-09-30 04:11:27 +0000393};
394
Chris Lattner946ac932005-09-30 04:53:25 +0000395static const short yypact[] = { 56,
396 -4, -4,-32768,-32768,-32768,-32768, 1, 56,-32768,-32768,
397-32768,-32768,-32768, 8, 2, 56,-32768,-32768, 23, 30,
398-32768,-32768, 50,-32768, -11, -3, 66,-32768,-32768,-32768,
399 62,-32768, 55, 34, 61, 68,-32768, 2,-32768,-32768,
400 49,-32768, -8, 8, 15, 30,-32768,-32768,-32768, -14,
401 82, 67, 15,-32768,-32768,-32768,-32768, 95, 97,-32768,
402-32768,-32768, 77,-32768, 66,-32768, 89, 90, 91,-32768,
403 101,-32768,-32768,-32768, 15, 15, 106, 73, 39,-32768,
404 7,-32768, 108, 109,-32768, 73, 110, 49, 104,-32768,
405 15, 15, 15, 15, 102, 98, 103, 15, 61, 61,
406 112,-32768, 15, 115,-32768, 99,-32768,-32768, -9, 111,
407 113, 15,-32768, 57, 63, 72, 41,-32768,-32768, 45,
408 105, 107, 114, 116,-32768, 73, 50,-32768,-32768, 120,
409-32768,-32768, 73, 15, 15, 15,-32768, 121,-32768, 15,
410-32768,-32768,-32768, 118,-32768, 78, 81, 86,-32768, 45,
411 15,-32768,-32768,-32768,-32768, 33,-32768, 144, 145,-32768
Chris Lattner8d354e92005-09-30 04:11:27 +0000412};
413
Chris Lattner946ac932005-09-30 04:53:25 +0000414static const short yypgoto[] = { -40,
415 59,-32768,-32768, -53, -1,-32768,-32768,-32768, -82, 21,
416 74, -43, -52,-32768,-32768,-32768, 117,-32768,-32768,-32768,
417-32768,-32768,-32768, 149,-32768,-32768, 122,-32768,-32768,-32768,
418-32768,-32768, -2, 119,-32768,-32768,-32768, 136,-32768
Chris Lattner8d354e92005-09-30 04:11:27 +0000419};
420
421
Chris Lattner946ac932005-09-30 04:53:25 +0000422#define YYLAST 166
Chris Lattner8d354e92005-09-30 04:11:27 +0000423
424
Chris Lattner946ac932005-09-30 04:53:25 +0000425static const short yytable[] = { 86,
426 62, 79, 37, 82, 17, 18, 1, 2, 129, 3,
427 1, 2, 90, 3, 9, 64, 123, 124, 40, 104,
428 23, 83, 38, 18, 39, 65, 130, 16, 106, 67,
429 68, 69, 70, 71, 105, 72, 73, 114, 115, 116,
430 74, 75, 20, 76, 120, 27, 77, 62, 30, 126,
431 117, 55, 56, 57, 58, 59, 60, 61, 133, 99,
432 47, 100, 102, 101, 137, 1, 2, 30, 3, 157,
433 48, 99, 103, 100, 103, 101, 35, 40, 50, 138,
434 146, 147, 148, 99, 45, 100, 150, 101, 46, 99,
435 134, 100, 53, 101, 85, 89, 135, 156, 99, 99,
436 100, 100, 101, 101, 99, 136, 100, 99, 101, 100,
437 152, 101, 99, 153, 100, 84, 101, 87, 154, 88,
438 91, 92, 93, 94, 98, 108, 109, 110, 112, 118,
439 125, 103, 119, 127, 131, 128, 132, 145, 140, 141,
440 149, 142, 151, 159, 160, 143, 111, 144, 155, 97,
441 13, 26, 0, 0, 0, 0, 54, 0, 0, 0,
442 0, 0, 80, 0, 0, 66
Chris Lattner8d354e92005-09-30 04:11:27 +0000443};
444
Chris Lattner946ac932005-09-30 04:53:25 +0000445static const short yycheck[] = { 53,
446 41, 45, 14, 18, 7, 8, 10, 11, 18, 13,
447 10, 11, 65, 13, 19, 24, 99, 100, 12, 13,
448 19, 36, 34, 26, 28, 34, 36, 27, 81, 15,
449 16, 17, 18, 19, 28, 21, 22, 91, 92, 93,
450 26, 27, 35, 29, 98, 23, 32, 88, 19, 103,
451 94, 3, 4, 5, 6, 7, 8, 9, 112, 27,
452 27, 29, 24, 31, 24, 10, 11, 19, 13, 37,
453 37, 27, 34, 29, 34, 31, 27, 12, 18, 35,
454 134, 135, 136, 27, 23, 29, 140, 31, 34, 27,
455 34, 29, 25, 31, 28, 19, 34, 151, 27, 27,
456 29, 29, 31, 31, 27, 34, 29, 27, 31, 29,
457 33, 31, 27, 33, 29, 34, 31, 23, 33, 23,
458 32, 32, 32, 23, 19, 18, 18, 18, 25, 28,
459 19, 34, 30, 19, 24, 37, 24, 18, 34, 33,
460 20, 28, 25, 0, 0, 30, 88, 127, 150, 76,
461 2, 16, -1, -1, -1, -1, 38, -1, -1, -1,
462 -1, -1, 46, -1, -1, 44
Chris Lattner8d354e92005-09-30 04:11:27 +0000463};
464/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
465#line 3 "/usr/share/bison.simple"
466/* This file comes from bison-1.28. */
467
468/* Skeleton output parser for bison,
469 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
470
471 This program is free software; you can redistribute it and/or modify
472 it under the terms of the GNU General Public License as published by
473 the Free Software Foundation; either version 2, or (at your option)
474 any later version.
475
476 This program is distributed in the hope that it will be useful,
477 but WITHOUT ANY WARRANTY; without even the implied warranty of
478 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
479 GNU General Public License for more details.
480
481 You should have received a copy of the GNU General Public License
482 along with this program; if not, write to the Free Software
483 Foundation, Inc., 59 Temple Place - Suite 330,
484 Boston, MA 02111-1307, USA. */
485
486/* As a special exception, when this file is copied by Bison into a
487 Bison output file, you may use that output file without restriction.
488 This special exception was added by the Free Software Foundation
489 in version 1.24 of Bison. */
490
491/* This is the parser code that is written into each bison parser
492 when the %semantic_parser declaration is not specified in the grammar.
493 It was written by Richard Stallman by simplifying the hairy parser
494 used when %semantic_parser is specified. */
495
496#ifndef YYSTACK_USE_ALLOCA
497#ifdef alloca
498#define YYSTACK_USE_ALLOCA
499#else /* alloca not defined */
500#ifdef __GNUC__
501#define YYSTACK_USE_ALLOCA
502#define alloca __builtin_alloca
503#else /* not GNU C. */
504#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
505#define YYSTACK_USE_ALLOCA
506#include <alloca.h>
507#else /* not sparc */
508/* We think this test detects Watcom and Microsoft C. */
509/* This used to test MSDOS, but that is a bad idea
510 since that symbol is in the user namespace. */
511#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
512#if 0 /* No need for malloc.h, which pollutes the namespace;
513 instead, just don't use alloca. */
514#include <malloc.h>
515#endif
516#else /* not MSDOS, or __TURBOC__ */
517#if defined(_AIX)
518/* I don't know what this was needed for, but it pollutes the namespace.
519 So I turned it off. rms, 2 May 1997. */
520/* #include <malloc.h> */
521 #pragma alloca
522#define YYSTACK_USE_ALLOCA
523#else /* not MSDOS, or __TURBOC__, or _AIX */
524#if 0
525#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
526 and on HPUX 10. Eventually we can turn this on. */
527#define YYSTACK_USE_ALLOCA
528#define alloca __builtin_alloca
529#endif /* __hpux */
530#endif
531#endif /* not _AIX */
532#endif /* not MSDOS, or __TURBOC__ */
533#endif /* not sparc */
534#endif /* not GNU C */
535#endif /* alloca not defined */
536#endif /* YYSTACK_USE_ALLOCA not defined */
537
538#ifdef YYSTACK_USE_ALLOCA
539#define YYSTACK_ALLOC alloca
Reid Spencer68a24bd2005-08-27 18:50:39 +0000540#else
Chris Lattner8d354e92005-09-30 04:11:27 +0000541#define YYSTACK_ALLOC malloc
Reid Spencer68a24bd2005-08-27 18:50:39 +0000542#endif
543
Chris Lattner8d354e92005-09-30 04:11:27 +0000544/* Note: there must be only one dollar sign in this file.
545 It is replaced by the list of actions, each action
546 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000547
548#define yyerrok (yyerrstatus = 0)
549#define yyclearin (yychar = YYEMPTY)
Chris Lattner8d354e92005-09-30 04:11:27 +0000550#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +0000551#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +0000552#define YYACCEPT goto yyacceptlab
Chris Lattner8d354e92005-09-30 04:11:27 +0000553#define YYABORT goto yyabortlab
Chris Lattnerba4b1442005-09-08 18:22:57 +0000554#define YYERROR goto yyerrlab1
Chris Lattner8d354e92005-09-30 04:11:27 +0000555/* Like YYERROR except do call yyerror.
556 This remains here temporarily to ease the
557 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000558 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000559#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +0000560#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner8d354e92005-09-30 04:11:27 +0000561#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +0000562do \
563 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner8d354e92005-09-30 04:11:27 +0000564 { yychar = (token), yylval = (value); \
565 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer68a24bd2005-08-27 18:50:39 +0000566 YYPOPSTACK; \
567 goto yybackup; \
568 } \
569 else \
Chris Lattner8d354e92005-09-30 04:11:27 +0000570 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencer68a24bd2005-08-27 18:50:39 +0000571while (0)
572
573#define YYTERROR 1
574#define YYERRCODE 256
575
Chris Lattner8d354e92005-09-30 04:11:27 +0000576#ifndef YYPURE
577#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +0000578#endif
579
Chris Lattner8d354e92005-09-30 04:11:27 +0000580#ifdef YYPURE
581#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +0000582#ifdef YYLEX_PARAM
Chris Lattner8d354e92005-09-30 04:11:27 +0000583#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000584#else
Chris Lattner8d354e92005-09-30 04:11:27 +0000585#define YYLEX yylex(&yylval, &yylloc)
586#endif
587#else /* not YYLSP_NEEDED */
588#ifdef YYLEX_PARAM
589#define YYLEX yylex(&yylval, YYLEX_PARAM)
590#else
591#define YYLEX yylex(&yylval)
592#endif
593#endif /* not YYLSP_NEEDED */
Chris Lattnerba4b1442005-09-08 18:22:57 +0000594#endif
Chris Lattner2b931e82005-09-12 05:30:06 +0000595
Chris Lattner8d354e92005-09-30 04:11:27 +0000596/* If nonreentrant, generate the variables here */
Chris Lattner2b931e82005-09-12 05:30:06 +0000597
Chris Lattner8d354e92005-09-30 04:11:27 +0000598#ifndef YYPURE
Chris Lattner2b931e82005-09-12 05:30:06 +0000599
Chris Lattner8d354e92005-09-30 04:11:27 +0000600int yychar; /* the lookahead symbol */
601YYSTYPE yylval; /* the semantic value of the */
602 /* lookahead symbol */
Chris Lattner2b931e82005-09-12 05:30:06 +0000603
Chris Lattner8d354e92005-09-30 04:11:27 +0000604#ifdef YYLSP_NEEDED
605YYLTYPE yylloc; /* location data for the lookahead */
606 /* symbol */
Chris Lattnerba4b1442005-09-08 18:22:57 +0000607#endif
Chris Lattner2b931e82005-09-12 05:30:06 +0000608
Chris Lattner8d354e92005-09-30 04:11:27 +0000609int yynerrs; /* number of parse errors so far */
610#endif /* not YYPURE */
Chris Lattner2b931e82005-09-12 05:30:06 +0000611
Chris Lattner8d354e92005-09-30 04:11:27 +0000612#if YYDEBUG != 0
613int yydebug; /* nonzero means print parse trace */
614/* Since this is uninitialized, it does not stop multiple parsers
615 from coexisting. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000616#endif
617
Chris Lattner8d354e92005-09-30 04:11:27 +0000618/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000619
Reid Spencer68a24bd2005-08-27 18:50:39 +0000620#ifndef YYINITDEPTH
Chris Lattner8d354e92005-09-30 04:11:27 +0000621#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +0000622#endif
623
Chris Lattner8d354e92005-09-30 04:11:27 +0000624/* YYMAXDEPTH is the maximum size the stacks can grow to
625 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000626
Chris Lattnerba4b1442005-09-08 18:22:57 +0000627#if YYMAXDEPTH == 0
Chris Lattner8d354e92005-09-30 04:11:27 +0000628#undef YYMAXDEPTH
Reid Spencer68a24bd2005-08-27 18:50:39 +0000629#endif
630
631#ifndef YYMAXDEPTH
Chris Lattner8d354e92005-09-30 04:11:27 +0000632#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +0000633#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000634
Chris Lattner8d354e92005-09-30 04:11:27 +0000635/* Define __yy_memcpy. Note that the size argument
636 should be passed with type unsigned int, because that is what the non-GCC
637 definitions require. With GCC, __builtin_memcpy takes an arg
638 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000639
Chris Lattner8d354e92005-09-30 04:11:27 +0000640#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
641#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
642#else /* not GNU C or C++ */
643#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +0000644
Chris Lattner8d354e92005-09-30 04:11:27 +0000645/* This is the most reliable way to avoid incompatibilities
646 in available built-in functions on various systems. */
Chris Lattner2b931e82005-09-12 05:30:06 +0000647static void
Chris Lattner8d354e92005-09-30 04:11:27 +0000648__yy_memcpy (to, from, count)
649 char *to;
650 char *from;
651 unsigned int count;
652{
653 register char *f = from;
654 register char *t = to;
655 register int i = count;
656
657 while (i-- > 0)
658 *t++ = *f++;
659}
660
661#else /* __cplusplus */
662
663/* This is the most reliable way to avoid incompatibilities
664 in available built-in functions on various systems. */
Chris Lattner2b931e82005-09-12 05:30:06 +0000665static void
Chris Lattner8d354e92005-09-30 04:11:27 +0000666__yy_memcpy (char *to, char *from, unsigned int count)
667{
668 register char *t = to;
669 register char *f = from;
670 register int i = count;
671
672 while (i-- > 0)
673 *t++ = *f++;
674}
675
Reid Spencer68a24bd2005-08-27 18:50:39 +0000676#endif
Chris Lattner2b931e82005-09-12 05:30:06 +0000677#endif
Chris Lattner2b931e82005-09-12 05:30:06 +0000678
Chris Lattner8d354e92005-09-30 04:11:27 +0000679#line 217 "/usr/share/bison.simple"
Chris Lattner2b931e82005-09-12 05:30:06 +0000680
Chris Lattner8d354e92005-09-30 04:11:27 +0000681/* The user can define YYPARSE_PARAM as the name of an argument to be passed
682 into yyparse. The argument should have type void *.
683 It should actually point to an object.
684 Grammar actions can access the variable by casting it
685 to the proper pointer type. */
Chris Lattner2b931e82005-09-12 05:30:06 +0000686
687#ifdef YYPARSE_PARAM
Chris Lattner8d354e92005-09-30 04:11:27 +0000688#ifdef __cplusplus
689#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
690#define YYPARSE_PARAM_DECL
691#else /* not __cplusplus */
692#define YYPARSE_PARAM_ARG YYPARSE_PARAM
693#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
694#endif /* not __cplusplus */
695#else /* not YYPARSE_PARAM */
696#define YYPARSE_PARAM_ARG
697#define YYPARSE_PARAM_DECL
698#endif /* not YYPARSE_PARAM */
699
700/* Prevent warning if -Wstrict-prototypes. */
701#ifdef __GNUC__
702#ifdef YYPARSE_PARAM
703int yyparse (void *);
704#else
Chris Lattner2b931e82005-09-12 05:30:06 +0000705int yyparse (void);
Chris Lattner2b931e82005-09-12 05:30:06 +0000706#endif
Chris Lattner8d354e92005-09-30 04:11:27 +0000707#endif
Chris Lattner2b931e82005-09-12 05:30:06 +0000708
Chris Lattner2b931e82005-09-12 05:30:06 +0000709int
Chris Lattner8d354e92005-09-30 04:11:27 +0000710yyparse(YYPARSE_PARAM_ARG)
711 YYPARSE_PARAM_DECL
Chris Lattner2b931e82005-09-12 05:30:06 +0000712{
Reid Spencer68a24bd2005-08-27 18:50:39 +0000713 register int yystate;
714 register int yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000715 register short *yyssp;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000716 register YYSTYPE *yyvsp;
Chris Lattner8d354e92005-09-30 04:11:27 +0000717 int yyerrstatus; /* number of tokens to shift before error messages enabled */
718 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000719
Chris Lattner8d354e92005-09-30 04:11:27 +0000720 short yyssa[YYINITDEPTH]; /* the state stack */
721 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000722
Chris Lattner8d354e92005-09-30 04:11:27 +0000723 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
724 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000725
Chris Lattner8d354e92005-09-30 04:11:27 +0000726#ifdef YYLSP_NEEDED
727 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
728 YYLTYPE *yyls = yylsa;
729 YYLTYPE *yylsp;
730
731#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
732#else
Reid Spencer68a24bd2005-08-27 18:50:39 +0000733#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattner8d354e92005-09-30 04:11:27 +0000734#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000735
Chris Lattner8d354e92005-09-30 04:11:27 +0000736 int yystacksize = YYINITDEPTH;
737 int yyfree_stacks = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000738
Chris Lattner8d354e92005-09-30 04:11:27 +0000739#ifdef YYPURE
740 int yychar;
741 YYSTYPE yylval;
742 int yynerrs;
743#ifdef YYLSP_NEEDED
744 YYLTYPE yylloc;
745#endif
746#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000747
Chris Lattner8d354e92005-09-30 04:11:27 +0000748 YYSTYPE yyval; /* the variable used to return */
749 /* semantic values from the action */
750 /* routines */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000751
Reid Spencer68a24bd2005-08-27 18:50:39 +0000752 int yylen;
753
Chris Lattner8d354e92005-09-30 04:11:27 +0000754#if YYDEBUG != 0
755 if (yydebug)
756 fprintf(stderr, "Starting parse\n");
757#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000758
759 yystate = 0;
760 yyerrstatus = 0;
761 yynerrs = 0;
762 yychar = YYEMPTY; /* Cause a token to be read. */
763
764 /* Initialize stack pointers.
765 Waste one element of value and location stack
766 so that they stay on the same level as the state stack.
767 The wasted elements are never initialized. */
768
Chris Lattner8d354e92005-09-30 04:11:27 +0000769 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000770 yyvsp = yyvs;
Chris Lattner8d354e92005-09-30 04:11:27 +0000771#ifdef YYLSP_NEEDED
772 yylsp = yyls;
773#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000774
Chris Lattner8d354e92005-09-30 04:11:27 +0000775/* Push a new state, which is found in yystate . */
776/* In all cases, when you get here, the value and location stacks
777 have just been pushed. so pushing a state here evens the stacks. */
778yynewstate:
Reid Spencer68a24bd2005-08-27 18:50:39 +0000779
Chris Lattner8d354e92005-09-30 04:11:27 +0000780 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000781
Chris Lattner8d354e92005-09-30 04:11:27 +0000782 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000783 {
Chris Lattner8d354e92005-09-30 04:11:27 +0000784 /* Give user a chance to reallocate the stack */
785 /* Use copies of these so that the &'s don't force the real ones into memory. */
786 YYSTYPE *yyvs1 = yyvs;
787 short *yyss1 = yyss;
788#ifdef YYLSP_NEEDED
789 YYLTYPE *yyls1 = yyls;
790#endif
791
Reid Spencer68a24bd2005-08-27 18:50:39 +0000792 /* Get the current used size of the three stacks, in elements. */
Chris Lattner8d354e92005-09-30 04:11:27 +0000793 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000794
795#ifdef yyoverflow
Chris Lattner8d354e92005-09-30 04:11:27 +0000796 /* Each stack pointer address is followed by the size of
797 the data in use in that stack, in bytes. */
798#ifdef YYLSP_NEEDED
799 /* This used to be a conditional around just the two extra args,
800 but that might be undefined if yyoverflow is a macro. */
801 yyoverflow("parser stack overflow",
802 &yyss1, size * sizeof (*yyssp),
803 &yyvs1, size * sizeof (*yyvsp),
804 &yyls1, size * sizeof (*yylsp),
805 &yystacksize);
806#else
807 yyoverflow("parser stack overflow",
808 &yyss1, size * sizeof (*yyssp),
809 &yyvs1, size * sizeof (*yyvsp),
810 &yystacksize);
811#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000812
Chris Lattner8d354e92005-09-30 04:11:27 +0000813 yyss = yyss1; yyvs = yyvs1;
814#ifdef YYLSP_NEEDED
815 yyls = yyls1;
816#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000817#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000818 /* Extend the stack our own way. */
Chris Lattner8d354e92005-09-30 04:11:27 +0000819 if (yystacksize >= YYMAXDEPTH)
820 {
821 yyerror("parser stack overflow");
822 if (yyfree_stacks)
823 {
824 free (yyss);
825 free (yyvs);
826#ifdef YYLSP_NEEDED
827 free (yyls);
828#endif
829 }
830 return 2;
831 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000832 yystacksize *= 2;
Chris Lattner8d354e92005-09-30 04:11:27 +0000833 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000834 yystacksize = YYMAXDEPTH;
Chris Lattner8d354e92005-09-30 04:11:27 +0000835#ifndef YYSTACK_USE_ALLOCA
836 yyfree_stacks = 1;
837#endif
838 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
839 __yy_memcpy ((char *)yyss, (char *)yyss1,
840 size * (unsigned int) sizeof (*yyssp));
841 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
842 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
843 size * (unsigned int) sizeof (*yyvsp));
844#ifdef YYLSP_NEEDED
845 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
846 __yy_memcpy ((char *)yyls, (char *)yyls1,
847 size * (unsigned int) sizeof (*yylsp));
848#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000849#endif /* no yyoverflow */
850
Chris Lattner8d354e92005-09-30 04:11:27 +0000851 yyssp = yyss + size - 1;
852 yyvsp = yyvs + size - 1;
853#ifdef YYLSP_NEEDED
854 yylsp = yyls + size - 1;
855#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000856
Chris Lattner8d354e92005-09-30 04:11:27 +0000857#if YYDEBUG != 0
858 if (yydebug)
859 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
860#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000861
Chris Lattner8d354e92005-09-30 04:11:27 +0000862 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000863 YYABORT;
864 }
865
Chris Lattner8d354e92005-09-30 04:11:27 +0000866#if YYDEBUG != 0
867 if (yydebug)
868 fprintf(stderr, "Entering state %d\n", yystate);
869#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000870
871 goto yybackup;
Chris Lattner8d354e92005-09-30 04:11:27 +0000872 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +0000873
874/* Do appropriate processing given the current state. */
875/* Read a lookahead token if we need one and don't already have one. */
876/* yyresume: */
877
878 /* First try to decide what to do without reference to lookahead token. */
879
880 yyn = yypact[yystate];
Chris Lattner8d354e92005-09-30 04:11:27 +0000881 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000882 goto yydefault;
883
884 /* Not known => get a lookahead token if don't already have one. */
885
Chris Lattner8d354e92005-09-30 04:11:27 +0000886 /* yychar is either YYEMPTY or YYEOF
887 or a valid token in external form. */
888
Reid Spencer68a24bd2005-08-27 18:50:39 +0000889 if (yychar == YYEMPTY)
890 {
Chris Lattner8d354e92005-09-30 04:11:27 +0000891#if YYDEBUG != 0
892 if (yydebug)
893 fprintf(stderr, "Reading a token: ");
894#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000895 yychar = YYLEX;
896 }
897
Chris Lattner8d354e92005-09-30 04:11:27 +0000898 /* Convert token to internal form (in yychar1) for indexing tables with */
899
900 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000901 {
Chris Lattner8d354e92005-09-30 04:11:27 +0000902 yychar1 = 0;
903 yychar = YYEOF; /* Don't call YYLEX any more */
904
905#if YYDEBUG != 0
906 if (yydebug)
907 fprintf(stderr, "Now at end of input.\n");
908#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000909 }
910 else
911 {
Chris Lattner8d354e92005-09-30 04:11:27 +0000912 yychar1 = YYTRANSLATE(yychar);
913
914#if YYDEBUG != 0
915 if (yydebug)
916 {
917 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
918 /* Give the individual parser a way to print the precise meaning
919 of a token, for further debugging info. */
920#ifdef YYPRINT
921 YYPRINT (stderr, yychar, yylval);
922#endif
923 fprintf (stderr, ")\n");
924 }
925#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000926 }
927
Chris Lattner8d354e92005-09-30 04:11:27 +0000928 yyn += yychar1;
929 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000930 goto yydefault;
Chris Lattner8d354e92005-09-30 04:11:27 +0000931
Reid Spencer68a24bd2005-08-27 18:50:39 +0000932 yyn = yytable[yyn];
Chris Lattner8d354e92005-09-30 04:11:27 +0000933
934 /* yyn is what to do for this token type in this state.
935 Negative => reduce, -yyn is rule number.
936 Positive => shift, yyn is new state.
937 New state is final state => don't bother to shift,
938 just return success.
939 0, or most negative number => error. */
940
941 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000942 {
Chris Lattner8d354e92005-09-30 04:11:27 +0000943 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000944 goto yyerrlab;
945 yyn = -yyn;
946 goto yyreduce;
947 }
Chris Lattner8d354e92005-09-30 04:11:27 +0000948 else if (yyn == 0)
949 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000950
951 if (yyn == YYFINAL)
952 YYACCEPT;
953
954 /* Shift the lookahead token. */
Chris Lattner8d354e92005-09-30 04:11:27 +0000955
956#if YYDEBUG != 0
957 if (yydebug)
958 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
959#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000960
961 /* Discard the token being shifted unless it is eof. */
962 if (yychar != YYEOF)
963 yychar = YYEMPTY;
964
965 *++yyvsp = yylval;
Chris Lattner8d354e92005-09-30 04:11:27 +0000966#ifdef YYLSP_NEEDED
967 *++yylsp = yylloc;
968#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000969
Chris Lattner8d354e92005-09-30 04:11:27 +0000970 /* count tokens shifted since error; after three, turn off error status. */
971 if (yyerrstatus) yyerrstatus--;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000972
973 yystate = yyn;
974 goto yynewstate;
975
Chris Lattner8d354e92005-09-30 04:11:27 +0000976/* Do the default action for the current state. */
Chris Lattner2b931e82005-09-12 05:30:06 +0000977yydefault:
Chris Lattner8d354e92005-09-30 04:11:27 +0000978
Reid Spencer68a24bd2005-08-27 18:50:39 +0000979 yyn = yydefact[yystate];
980 if (yyn == 0)
981 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000982
Chris Lattner8d354e92005-09-30 04:11:27 +0000983/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000984yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +0000985 yylen = yyr2[yyn];
Chris Lattner8d354e92005-09-30 04:11:27 +0000986 if (yylen > 0)
987 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000988
Chris Lattner8d354e92005-09-30 04:11:27 +0000989#if YYDEBUG != 0
990 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000991 {
Chris Lattner8d354e92005-09-30 04:11:27 +0000992 int i;
993
994 fprintf (stderr, "Reducing via rule %d (line %d), ",
995 yyn, yyrline[yyn]);
996
997 /* Print the symbols being reduced, and their result. */
998 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
999 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1000 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1001 }
1002#endif
1003
1004
1005 switch (yyn) {
1006
1007case 1:
1008#line 223 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1009{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001010 yyval.Rec = Records.getClass(*yyvsp[0].StrVal);
1011 if (yyval.Rec == 0) {
1012 err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1013 exit(1);
1014 }
1015 delete yyvsp[0].StrVal;
Chris Lattner8d354e92005-09-30 04:11:27 +00001016 ;
1017 break;}
1018case 2:
1019#line 234 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1020{ // string type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001021 yyval.Ty = new StringRecTy();
Chris Lattner8d354e92005-09-30 04:11:27 +00001022 ;
1023 break;}
1024case 3:
1025#line 236 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1026{ // bit type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001027 yyval.Ty = new BitRecTy();
Chris Lattner8d354e92005-09-30 04:11:27 +00001028 ;
1029 break;}
1030case 4:
1031#line 238 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1032{ // bits<x> type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001033 yyval.Ty = new BitsRecTy(yyvsp[-1].IntVal);
Chris Lattner8d354e92005-09-30 04:11:27 +00001034 ;
1035 break;}
1036case 5:
1037#line 240 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1038{ // int type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001039 yyval.Ty = new IntRecTy();
Chris Lattner8d354e92005-09-30 04:11:27 +00001040 ;
1041 break;}
1042case 6:
1043#line 242 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1044{ // list<x> type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001045 yyval.Ty = new ListRecTy(yyvsp[-1].Ty);
Chris Lattner8d354e92005-09-30 04:11:27 +00001046 ;
1047 break;}
1048case 7:
1049#line 244 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1050{ // code type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001051 yyval.Ty = new CodeRecTy();
Chris Lattner8d354e92005-09-30 04:11:27 +00001052 ;
1053 break;}
1054case 8:
1055#line 246 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1056{ // dag type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001057 yyval.Ty = new DagRecTy();
Chris Lattner8d354e92005-09-30 04:11:27 +00001058 ;
1059 break;}
1060case 9:
1061#line 248 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1062{ // Record Type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001063 yyval.Ty = new RecordRecTy(yyvsp[0].Rec);
Chris Lattner8d354e92005-09-30 04:11:27 +00001064 ;
1065 break;}
1066case 10:
1067#line 252 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1068{ yyval.IntVal = 0; ;
1069 break;}
1070case 11:
1071#line 252 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1072{ yyval.IntVal = 1; ;
1073 break;}
1074case 12:
1075#line 254 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1076{ yyval.Initializer = 0; ;
1077 break;}
1078case 13:
1079#line 254 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1080{ yyval.Initializer = yyvsp[0].Initializer; ;
1081 break;}
1082case 14:
1083#line 256 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1084{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001085 yyval.Initializer = new IntInit(yyvsp[0].IntVal);
Chris Lattner8d354e92005-09-30 04:11:27 +00001086 ;
1087 break;}
1088case 15:
1089#line 258 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1090{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001091 yyval.Initializer = new StringInit(*yyvsp[0].StrVal);
1092 delete yyvsp[0].StrVal;
Chris Lattner8d354e92005-09-30 04:11:27 +00001093 ;
1094 break;}
1095case 16:
1096#line 261 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1097{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001098 yyval.Initializer = new CodeInit(*yyvsp[0].StrVal);
1099 delete yyvsp[0].StrVal;
Chris Lattner8d354e92005-09-30 04:11:27 +00001100 ;
1101 break;}
1102case 17:
1103#line 264 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1104{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001105 yyval.Initializer = new UnsetInit();
Chris Lattner8d354e92005-09-30 04:11:27 +00001106 ;
1107 break;}
1108case 18:
1109#line 266 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1110{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001111 BitsInit *Init = new BitsInit(yyvsp[-1].FieldList->size());
1112 for (unsigned i = 0, e = yyvsp[-1].FieldList->size(); i != e; ++i) {
1113 struct Init *Bit = (*yyvsp[-1].FieldList)[i]->convertInitializerTo(new BitRecTy());
1114 if (Bit == 0) {
Chris Lattnerba4b1442005-09-08 18:22:57 +00001115 err() << "Element #" << i << " (" << *(*yyvsp[-1].FieldList)[i]
1116 << ") is not convertable to a bit!\n";
1117 exit(1);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001118 }
1119 Init->setBit(yyvsp[-1].FieldList->size()-i-1, Bit);
1120 }
1121 yyval.Initializer = Init;
1122 delete yyvsp[-1].FieldList;
Chris Lattner8d354e92005-09-30 04:11:27 +00001123 ;
1124 break;}
1125case 19:
1126#line 279 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1127{
Chris Lattnerca572be2005-09-08 18:48:47 +00001128 // This is a CLASS<initvalslist> expression. This is supposed to synthesize
1129 // a new anonymous definition, deriving from CLASS<initvalslist> with no
1130 // body.
1131 Record *Class = Records.getClass(*yyvsp[-3].StrVal);
1132 if (!Class) {
1133 err() << "Expected a class, got '" << *yyvsp[-3].StrVal << "'!\n";
1134 exit(1);
1135 }
1136 delete yyvsp[-3].StrVal;
1137
1138 static unsigned AnonCounter = 0;
1139 Record *OldRec = CurRec; // Save CurRec.
1140
1141 // Create the new record, set it as CurRec temporarily.
1142 CurRec = new Record("anonymous.val."+utostr(AnonCounter++));
1143 addSubClass(Class, *yyvsp[-1].FieldList); // Add info about the subclass to CurRec.
1144 delete yyvsp[-1].FieldList; // Free up the template args.
1145
Chris Lattner751eabf2005-09-08 19:47:28 +00001146 CurRec->resolveReferences();
Chris Lattnerca572be2005-09-08 18:48:47 +00001147
1148 Records.addDef(CurRec);
1149
1150 // The result of the expression is a reference to the new record.
1151 yyval.Initializer = new DefInit(CurRec);
1152
1153 // Restore the old CurRec
1154 CurRec = OldRec;
Chris Lattner8d354e92005-09-30 04:11:27 +00001155 ;
1156 break;}
1157case 20:
1158#line 307 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1159{
Chris Lattner2b931e82005-09-12 05:30:06 +00001160 if (const RecordVal *RV = (CurRec ? CurRec->getValue(*yyvsp[0].StrVal) : 0)) {
1161 yyval.Initializer = new VarInit(*yyvsp[0].StrVal, RV->getType());
1162 } else if (CurRec && CurRec->isTemplateArg(CurRec->getName()+":"+*yyvsp[0].StrVal)) {
1163 const RecordVal *RV = CurRec->getValue(CurRec->getName()+":"+*yyvsp[0].StrVal);
1164 assert(RV && "Template arg doesn't exist??");
1165 yyval.Initializer = new VarInit(CurRec->getName()+":"+*yyvsp[0].StrVal, RV->getType());
1166 } else if (Record *D = Records.getDef(*yyvsp[0].StrVal)) {
1167 yyval.Initializer = new DefInit(D);
1168 } else {
1169 err() << "Variable not defined: '" << *yyvsp[0].StrVal << "'!\n";
1170 exit(1);
1171 }
1172
1173 delete yyvsp[0].StrVal;
Chris Lattner8d354e92005-09-30 04:11:27 +00001174 ;
1175 break;}
1176case 21:
1177#line 322 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1178{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001179 yyval.Initializer = yyvsp[-3].Initializer->convertInitializerBitRange(*yyvsp[-1].BitList);
1180 if (yyval.Initializer == 0) {
1181 err() << "Invalid bit range for value '" << *yyvsp[-3].Initializer << "'!\n";
1182 exit(1);
1183 }
1184 delete yyvsp[-1].BitList;
Chris Lattner8d354e92005-09-30 04:11:27 +00001185 ;
1186 break;}
1187case 22:
1188#line 329 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1189{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001190 yyval.Initializer = new ListInit(*yyvsp[-1].FieldList);
1191 delete yyvsp[-1].FieldList;
Chris Lattner8d354e92005-09-30 04:11:27 +00001192 ;
1193 break;}
1194case 23:
1195#line 332 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1196{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001197 if (!yyvsp[-2].Initializer->getFieldType(*yyvsp[0].StrVal)) {
1198 err() << "Cannot access field '" << *yyvsp[0].StrVal << "' of value '" << *yyvsp[-2].Initializer << "!\n";
1199 exit(1);
1200 }
1201 yyval.Initializer = new FieldInit(yyvsp[-2].Initializer, *yyvsp[0].StrVal);
1202 delete yyvsp[0].StrVal;
Chris Lattner8d354e92005-09-30 04:11:27 +00001203 ;
1204 break;}
1205case 24:
1206#line 339 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1207{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001208 Record *D = Records.getDef(*yyvsp[-2].StrVal);
1209 if (D == 0) {
1210 err() << "Invalid def '" << *yyvsp[-2].StrVal << "'!\n";
1211 exit(1);
1212 }
1213 yyval.Initializer = new DagInit(D, *yyvsp[-1].DagValueList);
1214 delete yyvsp[-2].StrVal; delete yyvsp[-1].DagValueList;
Chris Lattner8d354e92005-09-30 04:11:27 +00001215 ;
1216 break;}
1217case 25:
1218#line 347 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1219{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001220 std::reverse(yyvsp[-1].BitList->begin(), yyvsp[-1].BitList->end());
1221 yyval.Initializer = yyvsp[-3].Initializer->convertInitListSlice(*yyvsp[-1].BitList);
1222 if (yyval.Initializer == 0) {
1223 err() << "Invalid list slice for value '" << *yyvsp[-3].Initializer << "'!\n";
1224 exit(1);
1225 }
1226 delete yyvsp[-1].BitList;
Chris Lattner8d354e92005-09-30 04:11:27 +00001227 ;
1228 break;}
1229case 26:
1230#line 355 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1231{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001232 yyval.Initializer = yyvsp[-3].Initializer->getBinaryOp(Init::SHL, yyvsp[-1].Initializer);
1233 if (yyval.Initializer == 0) {
1234 err() << "Cannot shift values '" << *yyvsp[-3].Initializer << "' and '" << *yyvsp[-1].Initializer << "'!\n";
1235 exit(1);
1236 }
Chris Lattner8d354e92005-09-30 04:11:27 +00001237 ;
1238 break;}
1239case 27:
1240#line 361 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1241{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001242 yyval.Initializer = yyvsp[-3].Initializer->getBinaryOp(Init::SRA, yyvsp[-1].Initializer);
1243 if (yyval.Initializer == 0) {
1244 err() << "Cannot shift values '" << *yyvsp[-3].Initializer << "' and '" << *yyvsp[-1].Initializer << "'!\n";
1245 exit(1);
1246 }
Chris Lattner8d354e92005-09-30 04:11:27 +00001247 ;
1248 break;}
1249case 28:
1250#line 367 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1251{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001252 yyval.Initializer = yyvsp[-3].Initializer->getBinaryOp(Init::SRL, yyvsp[-1].Initializer);
1253 if (yyval.Initializer == 0) {
1254 err() << "Cannot shift values '" << *yyvsp[-3].Initializer << "' and '" << *yyvsp[-1].Initializer << "'!\n";
1255 exit(1);
1256 }
Chris Lattner8d354e92005-09-30 04:11:27 +00001257 ;
1258 break;}
1259case 29:
1260#line 375 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1261{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001262 yyval.StrVal = new std::string();
Chris Lattner8d354e92005-09-30 04:11:27 +00001263 ;
1264 break;}
1265case 30:
1266#line 378 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1267{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001268 yyval.StrVal = yyvsp[0].StrVal;
Chris Lattner8d354e92005-09-30 04:11:27 +00001269 ;
1270 break;}
1271case 31:
1272#line 382 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1273{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001274 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1275 yyval.DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1276 delete yyvsp[0].StrVal;
Chris Lattner8d354e92005-09-30 04:11:27 +00001277 ;
1278 break;}
1279case 32:
1280#line 387 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1281{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001282 yyvsp[-3].DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1283 delete yyvsp[0].StrVal;
1284 yyval.DagValueList = yyvsp[-3].DagValueList;
Chris Lattner8d354e92005-09-30 04:11:27 +00001285 ;
1286 break;}
1287case 33:
1288#line 393 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1289{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001290 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
Chris Lattner8d354e92005-09-30 04:11:27 +00001291 ;
1292 break;}
1293case 34:
1294#line 396 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1295{ yyval.DagValueList = yyvsp[0].DagValueList; ;
1296 break;}
1297case 35:
1298#line 399 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1299{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001300 yyval.BitList = new std::vector<unsigned>();
1301 yyval.BitList->push_back(yyvsp[0].IntVal);
Chris Lattner8d354e92005-09-30 04:11:27 +00001302 ;
1303 break;}
1304case 36:
1305#line 402 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1306{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001307 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1308 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1309 exit(1);
1310 }
1311 yyval.BitList = new std::vector<unsigned>();
1312 if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1313 for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1314 yyval.BitList->push_back(i);
1315 } else {
1316 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1317 yyval.BitList->push_back(i);
1318 }
Chris Lattner8d354e92005-09-30 04:11:27 +00001319 ;
1320 break;}
1321case 37:
1322#line 415 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1323{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001324 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1325 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1326 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1327 exit(1);
1328 }
1329 yyval.BitList = new std::vector<unsigned>();
1330 if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1331 for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1332 yyval.BitList->push_back(i);
1333 } else {
1334 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1335 yyval.BitList->push_back(i);
1336 }
Chris Lattner8d354e92005-09-30 04:11:27 +00001337 ;
1338 break;}
1339case 38:
1340#line 429 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1341{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001342 (yyval.BitList=yyvsp[-2].BitList)->push_back(yyvsp[0].IntVal);
Chris Lattner8d354e92005-09-30 04:11:27 +00001343 ;
1344 break;}
1345case 39:
1346#line 431 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1347{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001348 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1349 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1350 exit(1);
1351 }
1352 yyval.BitList = yyvsp[-4].BitList;
1353 if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1354 for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1355 yyval.BitList->push_back(i);
1356 } else {
1357 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1358 yyval.BitList->push_back(i);
1359 }
Chris Lattner8d354e92005-09-30 04:11:27 +00001360 ;
1361 break;}
1362case 40:
1363#line 444 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1364{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001365 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1366 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1367 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1368 exit(1);
1369 }
1370 yyval.BitList = yyvsp[-3].BitList;
1371 if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1372 for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1373 yyval.BitList->push_back(i);
1374 } else {
1375 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1376 yyval.BitList->push_back(i);
1377 }
Chris Lattner8d354e92005-09-30 04:11:27 +00001378 ;
1379 break;}
1380case 41:
1381#line 460 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1382{ yyval.BitList = yyvsp[0].BitList; std::reverse(yyvsp[0].BitList->begin(), yyvsp[0].BitList->end()); ;
1383 break;}
1384case 42:
1385#line 462 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1386{ yyval.BitList = 0; ;
1387 break;}
1388case 43:
1389#line 462 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1390{ yyval.BitList = yyvsp[-1].BitList; ;
1391 break;}
1392case 44:
1393#line 466 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1394{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001395 yyval.FieldList = new std::vector<Init*>();
Chris Lattner8d354e92005-09-30 04:11:27 +00001396 ;
1397 break;}
1398case 45:
1399#line 468 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1400{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001401 yyval.FieldList = yyvsp[0].FieldList;
Chris Lattner8d354e92005-09-30 04:11:27 +00001402 ;
1403 break;}
1404case 46:
1405#line 472 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1406{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001407 yyval.FieldList = new std::vector<Init*>();
1408 yyval.FieldList->push_back(yyvsp[0].Initializer);
Chris Lattner8d354e92005-09-30 04:11:27 +00001409 ;
1410 break;}
1411case 47:
1412#line 475 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1413{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001414 (yyval.FieldList = yyvsp[-2].FieldList)->push_back(yyvsp[0].Initializer);
Chris Lattner8d354e92005-09-30 04:11:27 +00001415 ;
1416 break;}
1417case 48:
1418#line 479 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1419{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001420 std::string DecName = *yyvsp[-1].StrVal;
1421 if (ParsingTemplateArgs)
1422 DecName = CurRec->getName() + ":" + DecName;
1423
1424 addValue(RecordVal(DecName, yyvsp[-2].Ty, yyvsp[-3].IntVal));
1425 setValue(DecName, 0, yyvsp[0].Initializer);
1426 yyval.StrVal = new std::string(DecName);
Chris Lattner8d354e92005-09-30 04:11:27 +00001427;
1428 break;}
1429case 49:
1430#line 489 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1431{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001432 delete yyvsp[-1].StrVal;
Chris Lattner8d354e92005-09-30 04:11:27 +00001433;
1434 break;}
1435case 50:
1436#line 491 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1437{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001438 setValue(*yyvsp[-4].StrVal, yyvsp[-3].BitList, yyvsp[-1].Initializer);
1439 delete yyvsp[-4].StrVal;
1440 delete yyvsp[-3].BitList;
Chris Lattner8d354e92005-09-30 04:11:27 +00001441;
1442 break;}
1443case 55:
1444#line 500 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1445{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001446 yyval.SubClassRef = new SubClassRefTy(yyvsp[0].Rec, new std::vector<Init*>());
Chris Lattner8d354e92005-09-30 04:11:27 +00001447 ;
1448 break;}
1449case 56:
1450#line 502 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1451{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001452 yyval.SubClassRef = new SubClassRefTy(yyvsp[-3].Rec, yyvsp[-1].FieldList);
Chris Lattner8d354e92005-09-30 04:11:27 +00001453 ;
1454 break;}
1455case 57:
1456#line 506 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1457{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001458 yyval.SubClassList = new std::vector<SubClassRefTy>();
1459 yyval.SubClassList->push_back(*yyvsp[0].SubClassRef);
1460 delete yyvsp[0].SubClassRef;
Chris Lattner8d354e92005-09-30 04:11:27 +00001461 ;
1462 break;}
1463case 58:
1464#line 511 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1465{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001466 (yyval.SubClassList=yyvsp[-2].SubClassList)->push_back(*yyvsp[0].SubClassRef);
1467 delete yyvsp[0].SubClassRef;
Chris Lattner8d354e92005-09-30 04:11:27 +00001468 ;
1469 break;}
1470case 59:
1471#line 516 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1472{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001473 yyval.SubClassList = new std::vector<SubClassRefTy>();
Chris Lattner8d354e92005-09-30 04:11:27 +00001474 ;
1475 break;}
1476case 60:
1477#line 519 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1478{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001479 yyval.SubClassList = yyvsp[0].SubClassList;
Chris Lattner8d354e92005-09-30 04:11:27 +00001480 ;
1481 break;}
1482case 61:
1483#line 523 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1484{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001485 CurRec->addTemplateArg(*yyvsp[0].StrVal);
1486 delete yyvsp[0].StrVal;
Chris Lattner8d354e92005-09-30 04:11:27 +00001487;
1488 break;}
1489case 62:
1490#line 526 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1491{
Chris Lattnerca572be2005-09-08 18:48:47 +00001492 CurRec->addTemplateArg(*yyvsp[0].StrVal);
1493 delete yyvsp[0].StrVal;
Chris Lattner8d354e92005-09-30 04:11:27 +00001494;
1495 break;}
1496case 63:
1497#line 531 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1498{;
1499 break;}
1500case 66:
1501#line 534 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1502{ yyval.StrVal = yyvsp[0].StrVal; ;
1503 break;}
1504case 67:
1505#line 534 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1506{ yyval.StrVal = new std::string(); ;
1507 break;}
1508case 68:
1509#line 536 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1510{
1511 static unsigned AnonCounter = 0;
1512 if (yyvsp[0].StrVal->empty())
1513 *yyvsp[0].StrVal = "anonymous."+utostr(AnonCounter++);
Chris Lattner946ac932005-09-30 04:53:25 +00001514 yyval.StrVal = yyvsp[0].StrVal;
Chris Lattner8d354e92005-09-30 04:11:27 +00001515;
1516 break;}
1517case 69:
Chris Lattner946ac932005-09-30 04:53:25 +00001518#line 543 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
Chris Lattner8d354e92005-09-30 04:11:27 +00001519{
Chris Lattner946ac932005-09-30 04:53:25 +00001520 // If a class of this name already exists, it must be a forward ref.
Chris Lattner88b7e6e2005-09-30 06:09:50 +00001521 if ((CurRec = Records.getClass(*yyvsp[0].StrVal))) {
Chris Lattner946ac932005-09-30 04:53:25 +00001522 // If the body was previously defined, this is an error.
1523 if (!CurRec->getValues().empty() ||
1524 !CurRec->getSuperClasses().empty() ||
1525 !CurRec->getTemplateArgs().empty()) {
1526 err() << "Class '" << CurRec->getName() << "' already defined!\n";
1527 exit(1);
1528 }
1529 } else {
1530 // If this is the first reference to this class, create and add it.
1531 CurRec = new Record(*yyvsp[0].StrVal);
1532 Records.addClass(CurRec);
Chris Lattner8d354e92005-09-30 04:11:27 +00001533 }
Chris Lattner946ac932005-09-30 04:53:25 +00001534 delete yyvsp[0].StrVal;
Chris Lattner8d354e92005-09-30 04:11:27 +00001535;
1536 break;}
1537case 70:
Chris Lattner946ac932005-09-30 04:53:25 +00001538#line 561 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
Chris Lattner8d354e92005-09-30 04:11:27 +00001539{
Chris Lattner946ac932005-09-30 04:53:25 +00001540 CurRec = new Record(*yyvsp[0].StrVal);
1541 delete yyvsp[0].StrVal;
1542
Chris Lattner8d354e92005-09-30 04:11:27 +00001543 // Ensure redefinition doesn't happen.
1544 if (Records.getDef(CurRec->getName())) {
1545 err() << "Def '" << CurRec->getName() << "' already defined!\n";
1546 exit(1);
1547 }
1548 Records.addDef(CurRec);
1549;
1550 break;}
1551case 71:
Chris Lattner946ac932005-09-30 04:53:25 +00001552#line 573 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
Chris Lattner8d354e92005-09-30 04:11:27 +00001553{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001554 for (unsigned i = 0, e = yyvsp[0].SubClassList->size(); i != e; ++i) {
Chris Lattnerba4b1442005-09-08 18:22:57 +00001555 addSubClass((*yyvsp[0].SubClassList)[i].first, *(*yyvsp[0].SubClassList)[i].second);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001556 // Delete the template arg values for the class
1557 delete (*yyvsp[0].SubClassList)[i].second;
1558 }
1559 delete yyvsp[0].SubClassList; // Delete the class list...
Chris Lattner0a284052005-09-30 04:42:56 +00001560
Chris Lattnerba4b1442005-09-08 18:22:57 +00001561 // Process any variables on the set stack...
1562 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001563 for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
1564 setValue(LetStack[i][j].Name,
1565 LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
1566 LetStack[i][j].Value);
Chris Lattner8d354e92005-09-30 04:11:27 +00001567 ;
1568 break;}
1569case 72:
Chris Lattner946ac932005-09-30 04:53:25 +00001570#line 587 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
Chris Lattner8d354e92005-09-30 04:11:27 +00001571{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001572 yyval.Rec = CurRec;
1573 CurRec = 0;
Chris Lattner8d354e92005-09-30 04:11:27 +00001574 ;
1575 break;}
1576case 73:
Chris Lattner946ac932005-09-30 04:53:25 +00001577#line 592 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1578{
1579 ParsingTemplateArgs = true;
1580 ;
1581 break;}
1582case 74:
1583#line 594 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1584{
1585 ParsingTemplateArgs = false;
1586 ;
1587 break;}
1588case 75:
1589#line 596 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
Chris Lattner8d354e92005-09-30 04:11:27 +00001590{
Chris Lattner0a284052005-09-30 04:42:56 +00001591 yyval.Rec = yyvsp[0].Rec;
1592 ;
Chris Lattner8d354e92005-09-30 04:11:27 +00001593 break;}
Chris Lattner946ac932005-09-30 04:53:25 +00001594case 76:
1595#line 600 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
Chris Lattner8d354e92005-09-30 04:11:27 +00001596{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001597 yyvsp[0].Rec->resolveReferences();
1598
Chris Lattnerca572be2005-09-08 18:48:47 +00001599 // If ObjectBody has template arguments, it's an error.
Chris Lattner0a284052005-09-30 04:42:56 +00001600 assert(yyvsp[0].Rec->getTemplateArgs().empty() && "How'd this get template args?");
Chris Lattner8d354e92005-09-30 04:11:27 +00001601 yyval.Rec = yyvsp[0].Rec;
1602;
1603 break;}
Chris Lattner946ac932005-09-30 04:53:25 +00001604case 79:
1605#line 611 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
Chris Lattner8d354e92005-09-30 04:11:27 +00001606{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001607 LetStack.back().push_back(LetRecord(*yyvsp[-3].StrVal, yyvsp[-2].BitList, yyvsp[0].Initializer));
1608 delete yyvsp[-3].StrVal; delete yyvsp[-2].BitList;
Chris Lattner8d354e92005-09-30 04:11:27 +00001609;
1610 break;}
Chris Lattner946ac932005-09-30 04:53:25 +00001611case 82:
1612#line 619 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
Chris Lattner8d354e92005-09-30 04:11:27 +00001613{ LetStack.push_back(std::vector<LetRecord>()); ;
1614 break;}
Chris Lattner8d354e92005-09-30 04:11:27 +00001615case 84:
Chris Lattner946ac932005-09-30 04:53:25 +00001616#line 622 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1617{
1618 LetStack.pop_back();
1619 ;
Chris Lattner8d354e92005-09-30 04:11:27 +00001620 break;}
1621case 85:
Chris Lattner946ac932005-09-30 04:53:25 +00001622#line 625 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1623{
1624 LetStack.pop_back();
1625 ;
Chris Lattner8d354e92005-09-30 04:11:27 +00001626 break;}
1627case 86:
Chris Lattner946ac932005-09-30 04:53:25 +00001628#line 629 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1629{;
1630 break;}
1631case 87:
1632#line 629 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1633{;
1634 break;}
1635case 88:
1636#line 631 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
Chris Lattner8d354e92005-09-30 04:11:27 +00001637{;
1638 break;}
1639}
1640 /* the action file gets copied in in place of this dollarsign */
1641#line 543 "/usr/share/bison.simple"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001642
1643 yyvsp -= yylen;
1644 yyssp -= yylen;
Chris Lattner8d354e92005-09-30 04:11:27 +00001645#ifdef YYLSP_NEEDED
1646 yylsp -= yylen;
1647#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001648
Chris Lattner8d354e92005-09-30 04:11:27 +00001649#if YYDEBUG != 0
1650 if (yydebug)
1651 {
1652 short *ssp1 = yyss - 1;
1653 fprintf (stderr, "state stack now");
1654 while (ssp1 != yyssp)
1655 fprintf (stderr, " %d", *++ssp1);
1656 fprintf (stderr, "\n");
1657 }
1658#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001659
1660 *++yyvsp = yyval;
1661
Chris Lattner8d354e92005-09-30 04:11:27 +00001662#ifdef YYLSP_NEEDED
1663 yylsp++;
1664 if (yylen == 0)
1665 {
1666 yylsp->first_line = yylloc.first_line;
1667 yylsp->first_column = yylloc.first_column;
1668 yylsp->last_line = (yylsp-1)->last_line;
1669 yylsp->last_column = (yylsp-1)->last_column;
1670 yylsp->text = 0;
1671 }
1672 else
1673 {
1674 yylsp->last_line = (yylsp+yylen-1)->last_line;
1675 yylsp->last_column = (yylsp+yylen-1)->last_column;
1676 }
1677#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001678
Chris Lattner8d354e92005-09-30 04:11:27 +00001679 /* Now "shift" the result of the reduction.
1680 Determine what state that goes to,
1681 based on the state we popped back to
1682 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001683
1684 yyn = yyr1[yyn];
1685
Chris Lattner8d354e92005-09-30 04:11:27 +00001686 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1687 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001688 yystate = yytable[yystate];
1689 else
Chris Lattner8d354e92005-09-30 04:11:27 +00001690 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00001691
1692 goto yynewstate;
1693
Chris Lattner8d354e92005-09-30 04:11:27 +00001694yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001695
Chris Lattner8d354e92005-09-30 04:11:27 +00001696 if (! yyerrstatus)
1697 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001698 {
1699 ++yynerrs;
Chris Lattner8d354e92005-09-30 04:11:27 +00001700
1701#ifdef YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00001702 yyn = yypact[yystate];
1703
Chris Lattner8d354e92005-09-30 04:11:27 +00001704 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001705 {
Chris Lattner8d354e92005-09-30 04:11:27 +00001706 int size = 0;
1707 char *msg;
1708 int x, count;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001709
Chris Lattner8d354e92005-09-30 04:11:27 +00001710 count = 0;
1711 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1712 for (x = (yyn < 0 ? -yyn : 0);
1713 x < (sizeof(yytname) / sizeof(char *)); x++)
1714 if (yycheck[x + yyn] == x)
1715 size += strlen(yytname[x]) + 15, count++;
1716 msg = (char *) malloc(size + 15);
1717 if (msg != 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001718 {
Chris Lattner8d354e92005-09-30 04:11:27 +00001719 strcpy(msg, "parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001720
Chris Lattner8d354e92005-09-30 04:11:27 +00001721 if (count < 5)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001722 {
Chris Lattner8d354e92005-09-30 04:11:27 +00001723 count = 0;
1724 for (x = (yyn < 0 ? -yyn : 0);
1725 x < (sizeof(yytname) / sizeof(char *)); x++)
1726 if (yycheck[x + yyn] == x)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001727 {
Chris Lattner8d354e92005-09-30 04:11:27 +00001728 strcat(msg, count == 0 ? ", expecting `" : " or `");
1729 strcat(msg, yytname[x]);
1730 strcat(msg, "'");
1731 count++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001732 }
1733 }
Chris Lattner8d354e92005-09-30 04:11:27 +00001734 yyerror(msg);
1735 free(msg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001736 }
1737 else
Chris Lattner8d354e92005-09-30 04:11:27 +00001738 yyerror ("parse error; also virtual memory exceeded");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001739 }
1740 else
1741#endif /* YYERROR_VERBOSE */
Chris Lattner8d354e92005-09-30 04:11:27 +00001742 yyerror("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001743 }
1744
Chris Lattner8d354e92005-09-30 04:11:27 +00001745 goto yyerrlab1;
1746yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001747
1748 if (yyerrstatus == 3)
1749 {
Chris Lattner8d354e92005-09-30 04:11:27 +00001750 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001751
Chris Lattner8d354e92005-09-30 04:11:27 +00001752 /* return failure if at end of input */
Chris Lattnerba4b1442005-09-08 18:22:57 +00001753 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001754 YYABORT;
1755
Chris Lattner8d354e92005-09-30 04:11:27 +00001756#if YYDEBUG != 0
1757 if (yydebug)
1758 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1759#endif
Chris Lattnerba4b1442005-09-08 18:22:57 +00001760
Chris Lattner8d354e92005-09-30 04:11:27 +00001761 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001762 }
1763
Chris Lattner8d354e92005-09-30 04:11:27 +00001764 /* Else will try to reuse lookahead token
1765 after shifting the error token. */
1766
1767 yyerrstatus = 3; /* Each real token shifted decrements this */
1768
1769 goto yyerrhandle;
1770
1771yyerrdefault: /* current state does not do anything special for the error token. */
1772
1773#if 0
1774 /* This is wrong; only states that explicitly want error tokens
1775 should shift them. */
1776 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1777 if (yyn) goto yydefault;
1778#endif
1779
1780yyerrpop: /* pop the current state because it cannot handle the error token */
1781
1782 if (yyssp == yyss) YYABORT;
1783 yyvsp--;
1784 yystate = *--yyssp;
1785#ifdef YYLSP_NEEDED
1786 yylsp--;
1787#endif
1788
1789#if YYDEBUG != 0
1790 if (yydebug)
1791 {
1792 short *ssp1 = yyss - 1;
1793 fprintf (stderr, "Error: state stack now");
1794 while (ssp1 != yyssp)
1795 fprintf (stderr, " %d", *++ssp1);
1796 fprintf (stderr, "\n");
1797 }
1798#endif
1799
1800yyerrhandle:
1801
1802 yyn = yypact[yystate];
1803 if (yyn == YYFLAG)
1804 goto yyerrdefault;
1805
1806 yyn += YYTERROR;
1807 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1808 goto yyerrdefault;
1809
1810 yyn = yytable[yyn];
1811 if (yyn < 0)
1812 {
1813 if (yyn == YYFLAG)
1814 goto yyerrpop;
1815 yyn = -yyn;
1816 goto yyreduce;
1817 }
1818 else if (yyn == 0)
1819 goto yyerrpop;
1820
Reid Spencer68a24bd2005-08-27 18:50:39 +00001821 if (yyn == YYFINAL)
1822 YYACCEPT;
1823
Chris Lattner8d354e92005-09-30 04:11:27 +00001824#if YYDEBUG != 0
1825 if (yydebug)
1826 fprintf(stderr, "Shifting error token, ");
1827#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001828
1829 *++yyvsp = yylval;
Chris Lattner8d354e92005-09-30 04:11:27 +00001830#ifdef YYLSP_NEEDED
1831 *++yylsp = yylloc;
1832#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001833
1834 yystate = yyn;
1835 goto yynewstate;
1836
Chris Lattner8d354e92005-09-30 04:11:27 +00001837 yyacceptlab:
1838 /* YYACCEPT comes here. */
1839 if (yyfree_stacks)
1840 {
1841 free (yyss);
1842 free (yyvs);
1843#ifdef YYLSP_NEEDED
1844 free (yyls);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001845#endif
Chris Lattner8d354e92005-09-30 04:11:27 +00001846 }
1847 return 0;
Chris Lattner2b931e82005-09-12 05:30:06 +00001848
Chris Lattner8d354e92005-09-30 04:11:27 +00001849 yyabortlab:
1850 /* YYABORT comes here. */
1851 if (yyfree_stacks)
1852 {
1853 free (yyss);
1854 free (yyvs);
1855#ifdef YYLSP_NEEDED
1856 free (yyls);
Chris Lattner2b931e82005-09-12 05:30:06 +00001857#endif
Chris Lattner8d354e92005-09-30 04:11:27 +00001858 }
1859 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001860}
Chris Lattner946ac932005-09-30 04:53:25 +00001861#line 633 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001862
1863
1864int yyerror(const char *ErrorMsg) {
1865 err() << "Error parsing: " << ErrorMsg << "\n";
1866 exit(1);
1867}