Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 2 | /* A Bison parser, made from /Users/sabre/llvm/utils/TableGen/FileParser.y |
| 3 | by GNU Bison version 1.28 */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 5 | #define YYBISON 1 /* Identify Bison output. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 7 | #define yyparse Fileparse |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 8 | #define yylex Filelex |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 9 | #define yyerror Fileerror |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 10 | #define yylval Filelval |
| 11 | #define yychar Filechar |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 12 | #define yydebug Filedebug |
| 13 | #define yynerrs Filenerrs |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 14 | #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 Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 34 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 35 | #line 14 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 36 | |
| 37 | #include "Record.h" |
| 38 | #include "llvm/ADT/StringExtras.h" |
| 39 | #include <algorithm> |
| 40 | #include <cstdio> |
| 41 | #define YYERROR_VERBOSE 1 |
| 42 | |
| 43 | int yyerror(const char *ErrorMsg); |
| 44 | int yylex(); |
| 45 | |
| 46 | namespace llvm { |
| 47 | |
| 48 | extern int Filelineno; |
| 49 | static Record *CurRec = 0; |
| 50 | static bool ParsingTemplateArgs = false; |
| 51 | |
| 52 | typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy; |
| 53 | |
| 54 | struct 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 | |
| 65 | static std::vector<std::vector<LetRecord> > LetStack; |
| 66 | |
| 67 | |
| 68 | extern std::ostream &err(); |
| 69 | |
| 70 | static 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 | |
| 84 | static 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 | |
| 92 | static 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. |
| 161 | static 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 Lattner | ba4b144 | 2005-09-08 18:22:57 +0000 | [diff] [blame] | 178 | // Set it now. |
| 179 | setValue(TArgs[i], 0, TemplateArgs[i]); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 180 | |
| 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 Lattner | ba4b144 | 2005-09-08 18:22:57 +0000 | [diff] [blame] | 189 | err() << "ERROR: Value not specified for template argument #" |
| 190 | << i << " (" << TArgs[i] << ") of subclass '" << SC->getName() |
| 191 | << "'!\n"; |
| 192 | exit(1); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 193 | } |
| 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 | |
| 207 | using namespace llvm; |
| 208 | |
| 209 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 210 | #line 189 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 211 | typedef union { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 212 | 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 Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 223 | #include <stdio.h> |
| 224 | |
| 225 | #ifndef __cplusplus |
| 226 | #ifndef __STDC__ |
| 227 | #define const |
| 228 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 229 | #endif |
| 230 | |
| 231 | |
| 232 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 233 | #define YYFINAL 158 |
| 234 | #define YYFLAG -32768 |
| 235 | #define YYNTBASE 38 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 236 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 237 | #define YYTRANSLATE(x) ((unsigned)(x) <= 276 ? yytranslate[x] : 76) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 238 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 239 | static 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 Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 269 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 270 | #if YYDEBUG != 0 |
| 271 | static 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, |
| 279 | 213, 214, 219, 223, 227, 229, 231, 236, 238, 242, |
| 280 | 243, 248, 253, 256, 258, 261 |
| 281 | }; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 282 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 283 | static 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, |
| 305 | 62, 0, 0, 60, 57, 66, 54, 0, 10, 63, |
| 306 | 65, 0, 11, 64, 65, 0, 67, 0, 68, 0, |
| 307 | 19, 48, 25, 42, 0, 70, 0, 71, 34, 70, |
| 308 | 0, 0, 13, 73, 71, 14, 0, 72, 27, 74, |
| 309 | 28, 0, 72, 69, 0, 69, 0, 74, 69, 0, |
| 310 | 74, 0 |
| 311 | }; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 312 | |
| 313 | #endif |
| 314 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 315 | #if YYDEBUG != 0 |
| 316 | static 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, |
| 323 | 523, 526, 531, 532, 532, 534, 534, 536, 545, 553, |
| 324 | 562, 577, 582, 586, 599, 599, 601, 606, 606, 609, |
| 325 | 609, 612, 615, 619, 619, 621 |
| 326 | }; |
| 327 | #endif |
| 328 | |
| 329 | |
| 330 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) |
| 331 | |
| 332 | static 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", |
| 340 | "ObjectBody","@1","ClassInst","DefInst","Object","LETItem","LETList","LETCommand", |
| 341 | "@2","ObjectList","File", NULL |
| 342 | }; |
| 343 | #endif |
| 344 | |
| 345 | static 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, |
| 353 | 66, 65, 67, 68, 69, 69, 70, 71, 71, 73, |
| 354 | 72, 69, 69, 74, 74, 75 |
| 355 | }; |
| 356 | |
| 357 | static 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, |
| 365 | 0, 4, 3, 3, 1, 1, 4, 1, 3, 0, |
| 366 | 4, 4, 2, 1, 2, 1 |
| 367 | }; |
| 368 | |
| 369 | static const short yydefact[] = { 0, |
| 370 | 67, 67, 80, 75, 76, 84, 0, 86, 66, 68, |
| 371 | 69, 64, 70, 64, 0, 0, 83, 85, 10, 65, |
| 372 | 59, 73, 74, 42, 78, 0, 0, 11, 0, 61, |
| 373 | 0, 0, 71, 0, 0, 81, 0, 82, 5, 3, |
| 374 | 2, 0, 0, 7, 8, 1, 9, 0, 63, 10, |
| 375 | 55, 57, 60, 0, 35, 41, 0, 0, 79, 0, |
| 376 | 0, 12, 62, 0, 0, 51, 53, 72, 37, 0, |
| 377 | 0, 43, 0, 0, 0, 14, 20, 15, 16, 17, |
| 378 | 44, 44, 0, 77, 0, 0, 0, 48, 46, 0, |
| 379 | 58, 10, 36, 38, 0, 0, 0, 0, 0, 45, |
| 380 | 0, 33, 0, 0, 0, 4, 6, 13, 56, 0, |
| 381 | 0, 54, 0, 52, 40, 0, 0, 0, 0, 0, |
| 382 | 18, 22, 29, 34, 0, 0, 0, 23, 47, 42, |
| 383 | 49, 39, 0, 0, 0, 19, 0, 31, 0, 24, |
| 384 | 21, 25, 0, 0, 0, 0, 30, 29, 0, 26, |
| 385 | 27, 28, 32, 0, 50, 0, 0, 0 |
| 386 | }; |
| 387 | |
| 388 | static const short yydefgoto[] = { 47, |
| 389 | 48, 29, 88, 89, 138, 124, 125, 56, 57, 35, |
| 390 | 99, 100, 30, 114, 92, 68, 52, 53, 33, 31, |
| 391 | 20, 21, 10, 11, 12, 14, 22, 54, 4, 5, |
| 392 | 6, 25, 26, 7, 15, 8, 156 |
| 393 | }; |
| 394 | |
| 395 | static const short yypact[] = { 52, |
| 396 | 15, 15,-32768,-32768,-32768,-32768, 3, 52,-32768,-32768, |
| 397 | -32768, 4,-32768, 4, 22, 52,-32768,-32768, 34,-32768, |
| 398 | -20,-32768,-32768, 28,-32768, -9, -2,-32768, 63,-32768, |
| 399 | -3, 37,-32768, 39, 35,-32768, 22,-32768,-32768,-32768, |
| 400 | -32768, 50, 51,-32768,-32768,-32768,-32768, 59,-32768, 34, |
| 401 | 66,-32768, 45, -15, -12, 46, 62, 32,-32768, 102, |
| 402 | 63, 75,-32768, 32, 37,-32768,-32768,-32768,-32768, 104, |
| 403 | 106,-32768, 93, 94, 95,-32768, 105,-32768,-32768,-32768, |
| 404 | 32, 32, 110, 77, 107, 108, 32,-32768, 77, 8, |
| 405 | -32768, 5,-32768, -8, 32, 32, 32, 32, 109, 96, |
| 406 | 103, 32, 39, 39, 115,-32768,-32768, 77,-32768, 32, |
| 407 | 116,-32768, 99,-32768,-32768, 120, 67, 68, 76, 11, |
| 408 | -32768,-32768, 57, 111, 113, 112, 114,-32768, 77, 28, |
| 409 | -32768,-32768, 32, 32, 32,-32768, 119,-32768, 32,-32768, |
| 410 | -32768,-32768, 117, 82, 85, 90,-32768, 57, 32,-32768, |
| 411 | -32768,-32768,-32768, 56,-32768, 141, 143,-32768 |
| 412 | }; |
| 413 | |
| 414 | static const short yypgoto[] = { -25, |
| 415 | 86,-32768,-32768, -58, 0,-32768,-32768,-32768, -84, 19, |
| 416 | 69, -62, -49,-32768,-32768,-32768, 87,-32768,-32768,-32768, |
| 417 | -32768,-32768,-32768, 148,-32768,-32768, 139,-32768,-32768,-32768, |
| 418 | -4, 118,-32768,-32768,-32768, 138,-32768 |
| 419 | }; |
| 420 | |
| 421 | |
| 422 | #define YYLAST 155 |
| 423 | |
| 424 | |
| 425 | static const short yytable[] = { 84, |
| 426 | 63, 90, 17, 18, 36, 69, 51, 1, 2, 115, |
| 427 | 3, 66, 1, 2, 32, 3, 28, 111, 126, 127, |
| 428 | 49, 67, 18, 70, 37, 38, 19, 116, 108, 16, |
| 429 | 50, 109, 112, 9, 136, 120, 117, 118, 119, 51, |
| 430 | 24, 110, 113, 123, 110, 28, 73, 74, 75, 76, |
| 431 | 77, 129, 78, 79, 34, 46, 55, 80, 81, 58, |
| 432 | 82, 1, 2, 83, 3, 39, 40, 41, 42, 43, |
| 433 | 44, 45, 60, 61, 144, 145, 146, 62, 65, 71, |
| 434 | 148, 46, 103, 103, 104, 104, 105, 105, 64, 72, |
| 435 | 154, 137, 155, 103, 103, 104, 104, 105, 105, 87, |
| 436 | 133, 134, 103, 103, 104, 104, 105, 105, 103, 135, |
| 437 | 104, 103, 105, 104, 150, 105, 103, 151, 104, 85, |
| 438 | 105, 93, 152, 94, 95, 96, 97, 98, 102, 110, |
| 439 | 106, 107, 122, 128, 130, 131, 121, 132, 147, 141, |
| 440 | 157, 149, 158, 142, 139, 140, 86, 153, 143, 13, |
| 441 | 101, 91, 23, 27, 59 |
| 442 | }; |
| 443 | |
| 444 | static const short yycheck[] = { 58, |
| 445 | 50, 64, 7, 8, 14, 18, 32, 10, 11, 18, |
| 446 | 13, 27, 10, 11, 35, 13, 12, 13, 103, 104, |
| 447 | 24, 37, 27, 36, 34, 28, 23, 36, 87, 27, |
| 448 | 34, 24, 28, 19, 24, 98, 95, 96, 97, 65, |
| 449 | 19, 34, 92, 102, 34, 12, 15, 16, 17, 18, |
| 450 | 19, 110, 21, 22, 27, 19, 18, 26, 27, 25, |
| 451 | 29, 10, 11, 32, 13, 3, 4, 5, 6, 7, |
| 452 | 8, 9, 23, 23, 133, 134, 135, 19, 34, 34, |
| 453 | 139, 19, 27, 27, 29, 29, 31, 31, 23, 28, |
| 454 | 149, 35, 37, 27, 27, 29, 29, 31, 31, 25, |
| 455 | 34, 34, 27, 27, 29, 29, 31, 31, 27, 34, |
| 456 | 29, 27, 31, 29, 33, 31, 27, 33, 29, 18, |
| 457 | 31, 18, 33, 18, 32, 32, 32, 23, 19, 34, |
| 458 | 24, 24, 30, 19, 19, 37, 28, 18, 20, 28, |
| 459 | 0, 25, 0, 30, 34, 33, 61, 148, 130, 2, |
| 460 | 82, 65, 14, 16, 37 |
| 461 | }; |
| 462 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ |
| 463 | #line 3 "/usr/share/bison.simple" |
| 464 | /* This file comes from bison-1.28. */ |
| 465 | |
| 466 | /* Skeleton output parser for bison, |
| 467 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. |
| 468 | |
| 469 | This program is free software; you can redistribute it and/or modify |
| 470 | it under the terms of the GNU General Public License as published by |
| 471 | the Free Software Foundation; either version 2, or (at your option) |
| 472 | any later version. |
| 473 | |
| 474 | This program is distributed in the hope that it will be useful, |
| 475 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 476 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 477 | GNU General Public License for more details. |
| 478 | |
| 479 | You should have received a copy of the GNU General Public License |
| 480 | along with this program; if not, write to the Free Software |
| 481 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 482 | Boston, MA 02111-1307, USA. */ |
| 483 | |
| 484 | /* As a special exception, when this file is copied by Bison into a |
| 485 | Bison output file, you may use that output file without restriction. |
| 486 | This special exception was added by the Free Software Foundation |
| 487 | in version 1.24 of Bison. */ |
| 488 | |
| 489 | /* This is the parser code that is written into each bison parser |
| 490 | when the %semantic_parser declaration is not specified in the grammar. |
| 491 | It was written by Richard Stallman by simplifying the hairy parser |
| 492 | used when %semantic_parser is specified. */ |
| 493 | |
| 494 | #ifndef YYSTACK_USE_ALLOCA |
| 495 | #ifdef alloca |
| 496 | #define YYSTACK_USE_ALLOCA |
| 497 | #else /* alloca not defined */ |
| 498 | #ifdef __GNUC__ |
| 499 | #define YYSTACK_USE_ALLOCA |
| 500 | #define alloca __builtin_alloca |
| 501 | #else /* not GNU C. */ |
| 502 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) |
| 503 | #define YYSTACK_USE_ALLOCA |
| 504 | #include <alloca.h> |
| 505 | #else /* not sparc */ |
| 506 | /* We think this test detects Watcom and Microsoft C. */ |
| 507 | /* This used to test MSDOS, but that is a bad idea |
| 508 | since that symbol is in the user namespace. */ |
| 509 | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) |
| 510 | #if 0 /* No need for malloc.h, which pollutes the namespace; |
| 511 | instead, just don't use alloca. */ |
| 512 | #include <malloc.h> |
| 513 | #endif |
| 514 | #else /* not MSDOS, or __TURBOC__ */ |
| 515 | #if defined(_AIX) |
| 516 | /* I don't know what this was needed for, but it pollutes the namespace. |
| 517 | So I turned it off. rms, 2 May 1997. */ |
| 518 | /* #include <malloc.h> */ |
| 519 | #pragma alloca |
| 520 | #define YYSTACK_USE_ALLOCA |
| 521 | #else /* not MSDOS, or __TURBOC__, or _AIX */ |
| 522 | #if 0 |
| 523 | #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, |
| 524 | and on HPUX 10. Eventually we can turn this on. */ |
| 525 | #define YYSTACK_USE_ALLOCA |
| 526 | #define alloca __builtin_alloca |
| 527 | #endif /* __hpux */ |
| 528 | #endif |
| 529 | #endif /* not _AIX */ |
| 530 | #endif /* not MSDOS, or __TURBOC__ */ |
| 531 | #endif /* not sparc */ |
| 532 | #endif /* not GNU C */ |
| 533 | #endif /* alloca not defined */ |
| 534 | #endif /* YYSTACK_USE_ALLOCA not defined */ |
| 535 | |
| 536 | #ifdef YYSTACK_USE_ALLOCA |
| 537 | #define YYSTACK_ALLOC alloca |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 538 | #else |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 539 | #define YYSTACK_ALLOC malloc |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 540 | #endif |
| 541 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 542 | /* Note: there must be only one dollar sign in this file. |
| 543 | It is replaced by the list of actions, each action |
| 544 | as one case of the switch. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 545 | |
| 546 | #define yyerrok (yyerrstatus = 0) |
| 547 | #define yyclearin (yychar = YYEMPTY) |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 548 | #define YYEMPTY -2 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 549 | #define YYEOF 0 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 550 | #define YYACCEPT goto yyacceptlab |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 551 | #define YYABORT goto yyabortlab |
Chris Lattner | ba4b144 | 2005-09-08 18:22:57 +0000 | [diff] [blame] | 552 | #define YYERROR goto yyerrlab1 |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 553 | /* Like YYERROR except do call yyerror. |
| 554 | This remains here temporarily to ease the |
| 555 | transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 556 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 557 | #define YYFAIL goto yyerrlab |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 558 | #define YYRECOVERING() (!!yyerrstatus) |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 559 | #define YYBACKUP(token, value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 560 | do \ |
| 561 | if (yychar == YYEMPTY && yylen == 1) \ |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 562 | { yychar = (token), yylval = (value); \ |
| 563 | yychar1 = YYTRANSLATE (yychar); \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 564 | YYPOPSTACK; \ |
| 565 | goto yybackup; \ |
| 566 | } \ |
| 567 | else \ |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 568 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 569 | while (0) |
| 570 | |
| 571 | #define YYTERROR 1 |
| 572 | #define YYERRCODE 256 |
| 573 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 574 | #ifndef YYPURE |
| 575 | #define YYLEX yylex() |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 576 | #endif |
| 577 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 578 | #ifdef YYPURE |
| 579 | #ifdef YYLSP_NEEDED |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 580 | #ifdef YYLEX_PARAM |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 581 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 582 | #else |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 583 | #define YYLEX yylex(&yylval, &yylloc) |
| 584 | #endif |
| 585 | #else /* not YYLSP_NEEDED */ |
| 586 | #ifdef YYLEX_PARAM |
| 587 | #define YYLEX yylex(&yylval, YYLEX_PARAM) |
| 588 | #else |
| 589 | #define YYLEX yylex(&yylval) |
| 590 | #endif |
| 591 | #endif /* not YYLSP_NEEDED */ |
Chris Lattner | ba4b144 | 2005-09-08 18:22:57 +0000 | [diff] [blame] | 592 | #endif |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 593 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 594 | /* If nonreentrant, generate the variables here */ |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 595 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 596 | #ifndef YYPURE |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 597 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 598 | int yychar; /* the lookahead symbol */ |
| 599 | YYSTYPE yylval; /* the semantic value of the */ |
| 600 | /* lookahead symbol */ |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 601 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 602 | #ifdef YYLSP_NEEDED |
| 603 | YYLTYPE yylloc; /* location data for the lookahead */ |
| 604 | /* symbol */ |
Chris Lattner | ba4b144 | 2005-09-08 18:22:57 +0000 | [diff] [blame] | 605 | #endif |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 606 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 607 | int yynerrs; /* number of parse errors so far */ |
| 608 | #endif /* not YYPURE */ |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 609 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 610 | #if YYDEBUG != 0 |
| 611 | int yydebug; /* nonzero means print parse trace */ |
| 612 | /* Since this is uninitialized, it does not stop multiple parsers |
| 613 | from coexisting. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 614 | #endif |
| 615 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 616 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 617 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 618 | #ifndef YYINITDEPTH |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 619 | #define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 620 | #endif |
| 621 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 622 | /* YYMAXDEPTH is the maximum size the stacks can grow to |
| 623 | (effective only if the built-in stack extension method is used). */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 624 | |
Chris Lattner | ba4b144 | 2005-09-08 18:22:57 +0000 | [diff] [blame] | 625 | #if YYMAXDEPTH == 0 |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 626 | #undef YYMAXDEPTH |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 627 | #endif |
| 628 | |
| 629 | #ifndef YYMAXDEPTH |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 630 | #define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 631 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 632 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 633 | /* Define __yy_memcpy. Note that the size argument |
| 634 | should be passed with type unsigned int, because that is what the non-GCC |
| 635 | definitions require. With GCC, __builtin_memcpy takes an arg |
| 636 | of type size_t, but it can handle unsigned int. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 637 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 638 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ |
| 639 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) |
| 640 | #else /* not GNU C or C++ */ |
| 641 | #ifndef __cplusplus |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 642 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 643 | /* This is the most reliable way to avoid incompatibilities |
| 644 | in available built-in functions on various systems. */ |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 645 | static void |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 646 | __yy_memcpy (to, from, count) |
| 647 | char *to; |
| 648 | char *from; |
| 649 | unsigned int count; |
| 650 | { |
| 651 | register char *f = from; |
| 652 | register char *t = to; |
| 653 | register int i = count; |
| 654 | |
| 655 | while (i-- > 0) |
| 656 | *t++ = *f++; |
| 657 | } |
| 658 | |
| 659 | #else /* __cplusplus */ |
| 660 | |
| 661 | /* This is the most reliable way to avoid incompatibilities |
| 662 | in available built-in functions on various systems. */ |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 663 | static void |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 664 | __yy_memcpy (char *to, char *from, unsigned int count) |
| 665 | { |
| 666 | register char *t = to; |
| 667 | register char *f = from; |
| 668 | register int i = count; |
| 669 | |
| 670 | while (i-- > 0) |
| 671 | *t++ = *f++; |
| 672 | } |
| 673 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 674 | #endif |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 675 | #endif |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 676 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 677 | #line 217 "/usr/share/bison.simple" |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 678 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 679 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed |
| 680 | into yyparse. The argument should have type void *. |
| 681 | It should actually point to an object. |
| 682 | Grammar actions can access the variable by casting it |
| 683 | to the proper pointer type. */ |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 684 | |
| 685 | #ifdef YYPARSE_PARAM |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 686 | #ifdef __cplusplus |
| 687 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM |
| 688 | #define YYPARSE_PARAM_DECL |
| 689 | #else /* not __cplusplus */ |
| 690 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM |
| 691 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; |
| 692 | #endif /* not __cplusplus */ |
| 693 | #else /* not YYPARSE_PARAM */ |
| 694 | #define YYPARSE_PARAM_ARG |
| 695 | #define YYPARSE_PARAM_DECL |
| 696 | #endif /* not YYPARSE_PARAM */ |
| 697 | |
| 698 | /* Prevent warning if -Wstrict-prototypes. */ |
| 699 | #ifdef __GNUC__ |
| 700 | #ifdef YYPARSE_PARAM |
| 701 | int yyparse (void *); |
| 702 | #else |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 703 | int yyparse (void); |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 704 | #endif |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 705 | #endif |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 706 | |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 707 | int |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 708 | yyparse(YYPARSE_PARAM_ARG) |
| 709 | YYPARSE_PARAM_DECL |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 710 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 711 | register int yystate; |
| 712 | register int yyn; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 713 | register short *yyssp; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 714 | register YYSTYPE *yyvsp; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 715 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ |
| 716 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 717 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 718 | short yyssa[YYINITDEPTH]; /* the state stack */ |
| 719 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 720 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 721 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ |
| 722 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 723 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 724 | #ifdef YYLSP_NEEDED |
| 725 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ |
| 726 | YYLTYPE *yyls = yylsa; |
| 727 | YYLTYPE *yylsp; |
| 728 | |
| 729 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) |
| 730 | #else |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 731 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 732 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 733 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 734 | int yystacksize = YYINITDEPTH; |
| 735 | int yyfree_stacks = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 736 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 737 | #ifdef YYPURE |
| 738 | int yychar; |
| 739 | YYSTYPE yylval; |
| 740 | int yynerrs; |
| 741 | #ifdef YYLSP_NEEDED |
| 742 | YYLTYPE yylloc; |
| 743 | #endif |
| 744 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 745 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 746 | YYSTYPE yyval; /* the variable used to return */ |
| 747 | /* semantic values from the action */ |
| 748 | /* routines */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 749 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 750 | int yylen; |
| 751 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 752 | #if YYDEBUG != 0 |
| 753 | if (yydebug) |
| 754 | fprintf(stderr, "Starting parse\n"); |
| 755 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 756 | |
| 757 | yystate = 0; |
| 758 | yyerrstatus = 0; |
| 759 | yynerrs = 0; |
| 760 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 761 | |
| 762 | /* Initialize stack pointers. |
| 763 | Waste one element of value and location stack |
| 764 | so that they stay on the same level as the state stack. |
| 765 | The wasted elements are never initialized. */ |
| 766 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 767 | yyssp = yyss - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 768 | yyvsp = yyvs; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 769 | #ifdef YYLSP_NEEDED |
| 770 | yylsp = yyls; |
| 771 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 772 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 773 | /* Push a new state, which is found in yystate . */ |
| 774 | /* In all cases, when you get here, the value and location stacks |
| 775 | have just been pushed. so pushing a state here evens the stacks. */ |
| 776 | yynewstate: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 777 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 778 | *++yyssp = yystate; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 779 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 780 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 781 | { |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 782 | /* Give user a chance to reallocate the stack */ |
| 783 | /* Use copies of these so that the &'s don't force the real ones into memory. */ |
| 784 | YYSTYPE *yyvs1 = yyvs; |
| 785 | short *yyss1 = yyss; |
| 786 | #ifdef YYLSP_NEEDED |
| 787 | YYLTYPE *yyls1 = yyls; |
| 788 | #endif |
| 789 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 790 | /* Get the current used size of the three stacks, in elements. */ |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 791 | int size = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 792 | |
| 793 | #ifdef yyoverflow |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 794 | /* Each stack pointer address is followed by the size of |
| 795 | the data in use in that stack, in bytes. */ |
| 796 | #ifdef YYLSP_NEEDED |
| 797 | /* This used to be a conditional around just the two extra args, |
| 798 | but that might be undefined if yyoverflow is a macro. */ |
| 799 | yyoverflow("parser stack overflow", |
| 800 | &yyss1, size * sizeof (*yyssp), |
| 801 | &yyvs1, size * sizeof (*yyvsp), |
| 802 | &yyls1, size * sizeof (*yylsp), |
| 803 | &yystacksize); |
| 804 | #else |
| 805 | yyoverflow("parser stack overflow", |
| 806 | &yyss1, size * sizeof (*yyssp), |
| 807 | &yyvs1, size * sizeof (*yyvsp), |
| 808 | &yystacksize); |
| 809 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 810 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 811 | yyss = yyss1; yyvs = yyvs1; |
| 812 | #ifdef YYLSP_NEEDED |
| 813 | yyls = yyls1; |
| 814 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 815 | #else /* no yyoverflow */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 816 | /* Extend the stack our own way. */ |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 817 | if (yystacksize >= YYMAXDEPTH) |
| 818 | { |
| 819 | yyerror("parser stack overflow"); |
| 820 | if (yyfree_stacks) |
| 821 | { |
| 822 | free (yyss); |
| 823 | free (yyvs); |
| 824 | #ifdef YYLSP_NEEDED |
| 825 | free (yyls); |
| 826 | #endif |
| 827 | } |
| 828 | return 2; |
| 829 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 830 | yystacksize *= 2; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 831 | if (yystacksize > YYMAXDEPTH) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 832 | yystacksize = YYMAXDEPTH; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 833 | #ifndef YYSTACK_USE_ALLOCA |
| 834 | yyfree_stacks = 1; |
| 835 | #endif |
| 836 | yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); |
| 837 | __yy_memcpy ((char *)yyss, (char *)yyss1, |
| 838 | size * (unsigned int) sizeof (*yyssp)); |
| 839 | yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); |
| 840 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, |
| 841 | size * (unsigned int) sizeof (*yyvsp)); |
| 842 | #ifdef YYLSP_NEEDED |
| 843 | yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); |
| 844 | __yy_memcpy ((char *)yyls, (char *)yyls1, |
| 845 | size * (unsigned int) sizeof (*yylsp)); |
| 846 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 847 | #endif /* no yyoverflow */ |
| 848 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 849 | yyssp = yyss + size - 1; |
| 850 | yyvsp = yyvs + size - 1; |
| 851 | #ifdef YYLSP_NEEDED |
| 852 | yylsp = yyls + size - 1; |
| 853 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 854 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 855 | #if YYDEBUG != 0 |
| 856 | if (yydebug) |
| 857 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); |
| 858 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 859 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 860 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 861 | YYABORT; |
| 862 | } |
| 863 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 864 | #if YYDEBUG != 0 |
| 865 | if (yydebug) |
| 866 | fprintf(stderr, "Entering state %d\n", yystate); |
| 867 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 868 | |
| 869 | goto yybackup; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 870 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 871 | |
| 872 | /* Do appropriate processing given the current state. */ |
| 873 | /* Read a lookahead token if we need one and don't already have one. */ |
| 874 | /* yyresume: */ |
| 875 | |
| 876 | /* First try to decide what to do without reference to lookahead token. */ |
| 877 | |
| 878 | yyn = yypact[yystate]; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 879 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 880 | goto yydefault; |
| 881 | |
| 882 | /* Not known => get a lookahead token if don't already have one. */ |
| 883 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 884 | /* yychar is either YYEMPTY or YYEOF |
| 885 | or a valid token in external form. */ |
| 886 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 887 | if (yychar == YYEMPTY) |
| 888 | { |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 889 | #if YYDEBUG != 0 |
| 890 | if (yydebug) |
| 891 | fprintf(stderr, "Reading a token: "); |
| 892 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 893 | yychar = YYLEX; |
| 894 | } |
| 895 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 896 | /* Convert token to internal form (in yychar1) for indexing tables with */ |
| 897 | |
| 898 | if (yychar <= 0) /* This means end of input. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 899 | { |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 900 | yychar1 = 0; |
| 901 | yychar = YYEOF; /* Don't call YYLEX any more */ |
| 902 | |
| 903 | #if YYDEBUG != 0 |
| 904 | if (yydebug) |
| 905 | fprintf(stderr, "Now at end of input.\n"); |
| 906 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 907 | } |
| 908 | else |
| 909 | { |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 910 | yychar1 = YYTRANSLATE(yychar); |
| 911 | |
| 912 | #if YYDEBUG != 0 |
| 913 | if (yydebug) |
| 914 | { |
| 915 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); |
| 916 | /* Give the individual parser a way to print the precise meaning |
| 917 | of a token, for further debugging info. */ |
| 918 | #ifdef YYPRINT |
| 919 | YYPRINT (stderr, yychar, yylval); |
| 920 | #endif |
| 921 | fprintf (stderr, ")\n"); |
| 922 | } |
| 923 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 924 | } |
| 925 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 926 | yyn += yychar1; |
| 927 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 928 | goto yydefault; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 929 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 930 | yyn = yytable[yyn]; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 931 | |
| 932 | /* yyn is what to do for this token type in this state. |
| 933 | Negative => reduce, -yyn is rule number. |
| 934 | Positive => shift, yyn is new state. |
| 935 | New state is final state => don't bother to shift, |
| 936 | just return success. |
| 937 | 0, or most negative number => error. */ |
| 938 | |
| 939 | if (yyn < 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 940 | { |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 941 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 942 | goto yyerrlab; |
| 943 | yyn = -yyn; |
| 944 | goto yyreduce; |
| 945 | } |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 946 | else if (yyn == 0) |
| 947 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 948 | |
| 949 | if (yyn == YYFINAL) |
| 950 | YYACCEPT; |
| 951 | |
| 952 | /* Shift the lookahead token. */ |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 953 | |
| 954 | #if YYDEBUG != 0 |
| 955 | if (yydebug) |
| 956 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); |
| 957 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 958 | |
| 959 | /* Discard the token being shifted unless it is eof. */ |
| 960 | if (yychar != YYEOF) |
| 961 | yychar = YYEMPTY; |
| 962 | |
| 963 | *++yyvsp = yylval; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 964 | #ifdef YYLSP_NEEDED |
| 965 | *++yylsp = yylloc; |
| 966 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 967 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 968 | /* count tokens shifted since error; after three, turn off error status. */ |
| 969 | if (yyerrstatus) yyerrstatus--; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 970 | |
| 971 | yystate = yyn; |
| 972 | goto yynewstate; |
| 973 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 974 | /* Do the default action for the current state. */ |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 975 | yydefault: |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 976 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 977 | yyn = yydefact[yystate]; |
| 978 | if (yyn == 0) |
| 979 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 980 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 981 | /* Do a reduction. yyn is the number of a rule to reduce with. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 982 | yyreduce: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 983 | yylen = yyr2[yyn]; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 984 | if (yylen > 0) |
| 985 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 986 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 987 | #if YYDEBUG != 0 |
| 988 | if (yydebug) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 989 | { |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 990 | int i; |
| 991 | |
| 992 | fprintf (stderr, "Reducing via rule %d (line %d), ", |
| 993 | yyn, yyrline[yyn]); |
| 994 | |
| 995 | /* Print the symbols being reduced, and their result. */ |
| 996 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) |
| 997 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); |
| 998 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); |
| 999 | } |
| 1000 | #endif |
| 1001 | |
| 1002 | |
| 1003 | switch (yyn) { |
| 1004 | |
| 1005 | case 1: |
| 1006 | #line 223 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1007 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1008 | yyval.Rec = Records.getClass(*yyvsp[0].StrVal); |
| 1009 | if (yyval.Rec == 0) { |
| 1010 | err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n"; |
| 1011 | exit(1); |
| 1012 | } |
| 1013 | delete yyvsp[0].StrVal; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1014 | ; |
| 1015 | break;} |
| 1016 | case 2: |
| 1017 | #line 234 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1018 | { // string type |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1019 | yyval.Ty = new StringRecTy(); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1020 | ; |
| 1021 | break;} |
| 1022 | case 3: |
| 1023 | #line 236 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1024 | { // bit type |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1025 | yyval.Ty = new BitRecTy(); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1026 | ; |
| 1027 | break;} |
| 1028 | case 4: |
| 1029 | #line 238 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1030 | { // bits<x> type |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1031 | yyval.Ty = new BitsRecTy(yyvsp[-1].IntVal); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1032 | ; |
| 1033 | break;} |
| 1034 | case 5: |
| 1035 | #line 240 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1036 | { // int type |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1037 | yyval.Ty = new IntRecTy(); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1038 | ; |
| 1039 | break;} |
| 1040 | case 6: |
| 1041 | #line 242 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1042 | { // list<x> type |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1043 | yyval.Ty = new ListRecTy(yyvsp[-1].Ty); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1044 | ; |
| 1045 | break;} |
| 1046 | case 7: |
| 1047 | #line 244 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1048 | { // code type |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1049 | yyval.Ty = new CodeRecTy(); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1050 | ; |
| 1051 | break;} |
| 1052 | case 8: |
| 1053 | #line 246 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1054 | { // dag type |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1055 | yyval.Ty = new DagRecTy(); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1056 | ; |
| 1057 | break;} |
| 1058 | case 9: |
| 1059 | #line 248 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1060 | { // Record Type |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1061 | yyval.Ty = new RecordRecTy(yyvsp[0].Rec); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1062 | ; |
| 1063 | break;} |
| 1064 | case 10: |
| 1065 | #line 252 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1066 | { yyval.IntVal = 0; ; |
| 1067 | break;} |
| 1068 | case 11: |
| 1069 | #line 252 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1070 | { yyval.IntVal = 1; ; |
| 1071 | break;} |
| 1072 | case 12: |
| 1073 | #line 254 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1074 | { yyval.Initializer = 0; ; |
| 1075 | break;} |
| 1076 | case 13: |
| 1077 | #line 254 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1078 | { yyval.Initializer = yyvsp[0].Initializer; ; |
| 1079 | break;} |
| 1080 | case 14: |
| 1081 | #line 256 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1082 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1083 | yyval.Initializer = new IntInit(yyvsp[0].IntVal); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1084 | ; |
| 1085 | break;} |
| 1086 | case 15: |
| 1087 | #line 258 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1088 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1089 | yyval.Initializer = new StringInit(*yyvsp[0].StrVal); |
| 1090 | delete yyvsp[0].StrVal; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1091 | ; |
| 1092 | break;} |
| 1093 | case 16: |
| 1094 | #line 261 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1095 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1096 | yyval.Initializer = new CodeInit(*yyvsp[0].StrVal); |
| 1097 | delete yyvsp[0].StrVal; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1098 | ; |
| 1099 | break;} |
| 1100 | case 17: |
| 1101 | #line 264 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1102 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1103 | yyval.Initializer = new UnsetInit(); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1104 | ; |
| 1105 | break;} |
| 1106 | case 18: |
| 1107 | #line 266 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1108 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1109 | BitsInit *Init = new BitsInit(yyvsp[-1].FieldList->size()); |
| 1110 | for (unsigned i = 0, e = yyvsp[-1].FieldList->size(); i != e; ++i) { |
| 1111 | struct Init *Bit = (*yyvsp[-1].FieldList)[i]->convertInitializerTo(new BitRecTy()); |
| 1112 | if (Bit == 0) { |
Chris Lattner | ba4b144 | 2005-09-08 18:22:57 +0000 | [diff] [blame] | 1113 | err() << "Element #" << i << " (" << *(*yyvsp[-1].FieldList)[i] |
| 1114 | << ") is not convertable to a bit!\n"; |
| 1115 | exit(1); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1116 | } |
| 1117 | Init->setBit(yyvsp[-1].FieldList->size()-i-1, Bit); |
| 1118 | } |
| 1119 | yyval.Initializer = Init; |
| 1120 | delete yyvsp[-1].FieldList; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1121 | ; |
| 1122 | break;} |
| 1123 | case 19: |
| 1124 | #line 279 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1125 | { |
Chris Lattner | ca572be | 2005-09-08 18:48:47 +0000 | [diff] [blame] | 1126 | // This is a CLASS<initvalslist> expression. This is supposed to synthesize |
| 1127 | // a new anonymous definition, deriving from CLASS<initvalslist> with no |
| 1128 | // body. |
| 1129 | Record *Class = Records.getClass(*yyvsp[-3].StrVal); |
| 1130 | if (!Class) { |
| 1131 | err() << "Expected a class, got '" << *yyvsp[-3].StrVal << "'!\n"; |
| 1132 | exit(1); |
| 1133 | } |
| 1134 | delete yyvsp[-3].StrVal; |
| 1135 | |
| 1136 | static unsigned AnonCounter = 0; |
| 1137 | Record *OldRec = CurRec; // Save CurRec. |
| 1138 | |
| 1139 | // Create the new record, set it as CurRec temporarily. |
| 1140 | CurRec = new Record("anonymous.val."+utostr(AnonCounter++)); |
| 1141 | addSubClass(Class, *yyvsp[-1].FieldList); // Add info about the subclass to CurRec. |
| 1142 | delete yyvsp[-1].FieldList; // Free up the template args. |
| 1143 | |
Chris Lattner | 751eabf | 2005-09-08 19:47:28 +0000 | [diff] [blame] | 1144 | CurRec->resolveReferences(); |
Chris Lattner | ca572be | 2005-09-08 18:48:47 +0000 | [diff] [blame] | 1145 | |
| 1146 | Records.addDef(CurRec); |
| 1147 | |
| 1148 | // The result of the expression is a reference to the new record. |
| 1149 | yyval.Initializer = new DefInit(CurRec); |
| 1150 | |
| 1151 | // Restore the old CurRec |
| 1152 | CurRec = OldRec; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1153 | ; |
| 1154 | break;} |
| 1155 | case 20: |
| 1156 | #line 307 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1157 | { |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 1158 | if (const RecordVal *RV = (CurRec ? CurRec->getValue(*yyvsp[0].StrVal) : 0)) { |
| 1159 | yyval.Initializer = new VarInit(*yyvsp[0].StrVal, RV->getType()); |
| 1160 | } else if (CurRec && CurRec->isTemplateArg(CurRec->getName()+":"+*yyvsp[0].StrVal)) { |
| 1161 | const RecordVal *RV = CurRec->getValue(CurRec->getName()+":"+*yyvsp[0].StrVal); |
| 1162 | assert(RV && "Template arg doesn't exist??"); |
| 1163 | yyval.Initializer = new VarInit(CurRec->getName()+":"+*yyvsp[0].StrVal, RV->getType()); |
| 1164 | } else if (Record *D = Records.getDef(*yyvsp[0].StrVal)) { |
| 1165 | yyval.Initializer = new DefInit(D); |
| 1166 | } else { |
| 1167 | err() << "Variable not defined: '" << *yyvsp[0].StrVal << "'!\n"; |
| 1168 | exit(1); |
| 1169 | } |
| 1170 | |
| 1171 | delete yyvsp[0].StrVal; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1172 | ; |
| 1173 | break;} |
| 1174 | case 21: |
| 1175 | #line 322 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1176 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1177 | yyval.Initializer = yyvsp[-3].Initializer->convertInitializerBitRange(*yyvsp[-1].BitList); |
| 1178 | if (yyval.Initializer == 0) { |
| 1179 | err() << "Invalid bit range for value '" << *yyvsp[-3].Initializer << "'!\n"; |
| 1180 | exit(1); |
| 1181 | } |
| 1182 | delete yyvsp[-1].BitList; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1183 | ; |
| 1184 | break;} |
| 1185 | case 22: |
| 1186 | #line 329 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1187 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1188 | yyval.Initializer = new ListInit(*yyvsp[-1].FieldList); |
| 1189 | delete yyvsp[-1].FieldList; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1190 | ; |
| 1191 | break;} |
| 1192 | case 23: |
| 1193 | #line 332 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1194 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1195 | if (!yyvsp[-2].Initializer->getFieldType(*yyvsp[0].StrVal)) { |
| 1196 | err() << "Cannot access field '" << *yyvsp[0].StrVal << "' of value '" << *yyvsp[-2].Initializer << "!\n"; |
| 1197 | exit(1); |
| 1198 | } |
| 1199 | yyval.Initializer = new FieldInit(yyvsp[-2].Initializer, *yyvsp[0].StrVal); |
| 1200 | delete yyvsp[0].StrVal; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1201 | ; |
| 1202 | break;} |
| 1203 | case 24: |
| 1204 | #line 339 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1205 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1206 | Record *D = Records.getDef(*yyvsp[-2].StrVal); |
| 1207 | if (D == 0) { |
| 1208 | err() << "Invalid def '" << *yyvsp[-2].StrVal << "'!\n"; |
| 1209 | exit(1); |
| 1210 | } |
| 1211 | yyval.Initializer = new DagInit(D, *yyvsp[-1].DagValueList); |
| 1212 | delete yyvsp[-2].StrVal; delete yyvsp[-1].DagValueList; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1213 | ; |
| 1214 | break;} |
| 1215 | case 25: |
| 1216 | #line 347 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1217 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1218 | std::reverse(yyvsp[-1].BitList->begin(), yyvsp[-1].BitList->end()); |
| 1219 | yyval.Initializer = yyvsp[-3].Initializer->convertInitListSlice(*yyvsp[-1].BitList); |
| 1220 | if (yyval.Initializer == 0) { |
| 1221 | err() << "Invalid list slice for value '" << *yyvsp[-3].Initializer << "'!\n"; |
| 1222 | exit(1); |
| 1223 | } |
| 1224 | delete yyvsp[-1].BitList; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1225 | ; |
| 1226 | break;} |
| 1227 | case 26: |
| 1228 | #line 355 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1229 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1230 | yyval.Initializer = yyvsp[-3].Initializer->getBinaryOp(Init::SHL, yyvsp[-1].Initializer); |
| 1231 | if (yyval.Initializer == 0) { |
| 1232 | err() << "Cannot shift values '" << *yyvsp[-3].Initializer << "' and '" << *yyvsp[-1].Initializer << "'!\n"; |
| 1233 | exit(1); |
| 1234 | } |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1235 | ; |
| 1236 | break;} |
| 1237 | case 27: |
| 1238 | #line 361 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1239 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1240 | yyval.Initializer = yyvsp[-3].Initializer->getBinaryOp(Init::SRA, yyvsp[-1].Initializer); |
| 1241 | if (yyval.Initializer == 0) { |
| 1242 | err() << "Cannot shift values '" << *yyvsp[-3].Initializer << "' and '" << *yyvsp[-1].Initializer << "'!\n"; |
| 1243 | exit(1); |
| 1244 | } |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1245 | ; |
| 1246 | break;} |
| 1247 | case 28: |
| 1248 | #line 367 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1249 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1250 | yyval.Initializer = yyvsp[-3].Initializer->getBinaryOp(Init::SRL, yyvsp[-1].Initializer); |
| 1251 | if (yyval.Initializer == 0) { |
| 1252 | err() << "Cannot shift values '" << *yyvsp[-3].Initializer << "' and '" << *yyvsp[-1].Initializer << "'!\n"; |
| 1253 | exit(1); |
| 1254 | } |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1255 | ; |
| 1256 | break;} |
| 1257 | case 29: |
| 1258 | #line 375 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1259 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1260 | yyval.StrVal = new std::string(); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1261 | ; |
| 1262 | break;} |
| 1263 | case 30: |
| 1264 | #line 378 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1265 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1266 | yyval.StrVal = yyvsp[0].StrVal; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1267 | ; |
| 1268 | break;} |
| 1269 | case 31: |
| 1270 | #line 382 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1271 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1272 | yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >(); |
| 1273 | yyval.DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal)); |
| 1274 | delete yyvsp[0].StrVal; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1275 | ; |
| 1276 | break;} |
| 1277 | case 32: |
| 1278 | #line 387 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1279 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1280 | yyvsp[-3].DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal)); |
| 1281 | delete yyvsp[0].StrVal; |
| 1282 | yyval.DagValueList = yyvsp[-3].DagValueList; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1283 | ; |
| 1284 | break;} |
| 1285 | case 33: |
| 1286 | #line 393 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1287 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1288 | yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >(); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1289 | ; |
| 1290 | break;} |
| 1291 | case 34: |
| 1292 | #line 396 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1293 | { yyval.DagValueList = yyvsp[0].DagValueList; ; |
| 1294 | break;} |
| 1295 | case 35: |
| 1296 | #line 399 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1297 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1298 | yyval.BitList = new std::vector<unsigned>(); |
| 1299 | yyval.BitList->push_back(yyvsp[0].IntVal); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1300 | ; |
| 1301 | break;} |
| 1302 | case 36: |
| 1303 | #line 402 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1304 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1305 | if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) { |
| 1306 | err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n"; |
| 1307 | exit(1); |
| 1308 | } |
| 1309 | yyval.BitList = new std::vector<unsigned>(); |
| 1310 | if (yyvsp[-2].IntVal < yyvsp[0].IntVal) { |
| 1311 | for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i) |
| 1312 | yyval.BitList->push_back(i); |
| 1313 | } else { |
| 1314 | for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i) |
| 1315 | yyval.BitList->push_back(i); |
| 1316 | } |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1317 | ; |
| 1318 | break;} |
| 1319 | case 37: |
| 1320 | #line 415 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1321 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1322 | yyvsp[0].IntVal = -yyvsp[0].IntVal; |
| 1323 | if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) { |
| 1324 | err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n"; |
| 1325 | exit(1); |
| 1326 | } |
| 1327 | yyval.BitList = new std::vector<unsigned>(); |
| 1328 | if (yyvsp[-1].IntVal < yyvsp[0].IntVal) { |
| 1329 | for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i) |
| 1330 | yyval.BitList->push_back(i); |
| 1331 | } else { |
| 1332 | for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i) |
| 1333 | yyval.BitList->push_back(i); |
| 1334 | } |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1335 | ; |
| 1336 | break;} |
| 1337 | case 38: |
| 1338 | #line 429 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1339 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1340 | (yyval.BitList=yyvsp[-2].BitList)->push_back(yyvsp[0].IntVal); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1341 | ; |
| 1342 | break;} |
| 1343 | case 39: |
| 1344 | #line 431 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1345 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1346 | if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) { |
| 1347 | err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n"; |
| 1348 | exit(1); |
| 1349 | } |
| 1350 | yyval.BitList = yyvsp[-4].BitList; |
| 1351 | if (yyvsp[-2].IntVal < yyvsp[0].IntVal) { |
| 1352 | for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i) |
| 1353 | yyval.BitList->push_back(i); |
| 1354 | } else { |
| 1355 | for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i) |
| 1356 | yyval.BitList->push_back(i); |
| 1357 | } |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1358 | ; |
| 1359 | break;} |
| 1360 | case 40: |
| 1361 | #line 444 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1362 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1363 | yyvsp[0].IntVal = -yyvsp[0].IntVal; |
| 1364 | if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) { |
| 1365 | err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n"; |
| 1366 | exit(1); |
| 1367 | } |
| 1368 | yyval.BitList = yyvsp[-3].BitList; |
| 1369 | if (yyvsp[-1].IntVal < yyvsp[0].IntVal) { |
| 1370 | for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i) |
| 1371 | yyval.BitList->push_back(i); |
| 1372 | } else { |
| 1373 | for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i) |
| 1374 | yyval.BitList->push_back(i); |
| 1375 | } |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1376 | ; |
| 1377 | break;} |
| 1378 | case 41: |
| 1379 | #line 460 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1380 | { yyval.BitList = yyvsp[0].BitList; std::reverse(yyvsp[0].BitList->begin(), yyvsp[0].BitList->end()); ; |
| 1381 | break;} |
| 1382 | case 42: |
| 1383 | #line 462 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1384 | { yyval.BitList = 0; ; |
| 1385 | break;} |
| 1386 | case 43: |
| 1387 | #line 462 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1388 | { yyval.BitList = yyvsp[-1].BitList; ; |
| 1389 | break;} |
| 1390 | case 44: |
| 1391 | #line 466 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1392 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1393 | yyval.FieldList = new std::vector<Init*>(); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1394 | ; |
| 1395 | break;} |
| 1396 | case 45: |
| 1397 | #line 468 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1398 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1399 | yyval.FieldList = yyvsp[0].FieldList; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1400 | ; |
| 1401 | break;} |
| 1402 | case 46: |
| 1403 | #line 472 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1404 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1405 | yyval.FieldList = new std::vector<Init*>(); |
| 1406 | yyval.FieldList->push_back(yyvsp[0].Initializer); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1407 | ; |
| 1408 | break;} |
| 1409 | case 47: |
| 1410 | #line 475 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1411 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1412 | (yyval.FieldList = yyvsp[-2].FieldList)->push_back(yyvsp[0].Initializer); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1413 | ; |
| 1414 | break;} |
| 1415 | case 48: |
| 1416 | #line 479 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1417 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1418 | std::string DecName = *yyvsp[-1].StrVal; |
| 1419 | if (ParsingTemplateArgs) |
| 1420 | DecName = CurRec->getName() + ":" + DecName; |
| 1421 | |
| 1422 | addValue(RecordVal(DecName, yyvsp[-2].Ty, yyvsp[-3].IntVal)); |
| 1423 | setValue(DecName, 0, yyvsp[0].Initializer); |
| 1424 | yyval.StrVal = new std::string(DecName); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1425 | ; |
| 1426 | break;} |
| 1427 | case 49: |
| 1428 | #line 489 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1429 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1430 | delete yyvsp[-1].StrVal; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1431 | ; |
| 1432 | break;} |
| 1433 | case 50: |
| 1434 | #line 491 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1435 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1436 | setValue(*yyvsp[-4].StrVal, yyvsp[-3].BitList, yyvsp[-1].Initializer); |
| 1437 | delete yyvsp[-4].StrVal; |
| 1438 | delete yyvsp[-3].BitList; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1439 | ; |
| 1440 | break;} |
| 1441 | case 55: |
| 1442 | #line 500 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1443 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1444 | yyval.SubClassRef = new SubClassRefTy(yyvsp[0].Rec, new std::vector<Init*>()); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1445 | ; |
| 1446 | break;} |
| 1447 | case 56: |
| 1448 | #line 502 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1449 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1450 | yyval.SubClassRef = new SubClassRefTy(yyvsp[-3].Rec, yyvsp[-1].FieldList); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1451 | ; |
| 1452 | break;} |
| 1453 | case 57: |
| 1454 | #line 506 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1455 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1456 | yyval.SubClassList = new std::vector<SubClassRefTy>(); |
| 1457 | yyval.SubClassList->push_back(*yyvsp[0].SubClassRef); |
| 1458 | delete yyvsp[0].SubClassRef; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1459 | ; |
| 1460 | break;} |
| 1461 | case 58: |
| 1462 | #line 511 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1463 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1464 | (yyval.SubClassList=yyvsp[-2].SubClassList)->push_back(*yyvsp[0].SubClassRef); |
| 1465 | delete yyvsp[0].SubClassRef; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1466 | ; |
| 1467 | break;} |
| 1468 | case 59: |
| 1469 | #line 516 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1470 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1471 | yyval.SubClassList = new std::vector<SubClassRefTy>(); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1472 | ; |
| 1473 | break;} |
| 1474 | case 60: |
| 1475 | #line 519 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1476 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1477 | yyval.SubClassList = yyvsp[0].SubClassList; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1478 | ; |
| 1479 | break;} |
| 1480 | case 61: |
| 1481 | #line 523 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1482 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1483 | CurRec->addTemplateArg(*yyvsp[0].StrVal); |
| 1484 | delete yyvsp[0].StrVal; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1485 | ; |
| 1486 | break;} |
| 1487 | case 62: |
| 1488 | #line 526 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1489 | { |
Chris Lattner | ca572be | 2005-09-08 18:48:47 +0000 | [diff] [blame] | 1490 | CurRec->addTemplateArg(*yyvsp[0].StrVal); |
| 1491 | delete yyvsp[0].StrVal; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1492 | ; |
| 1493 | break;} |
| 1494 | case 63: |
| 1495 | #line 531 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1496 | {; |
| 1497 | break;} |
| 1498 | case 66: |
| 1499 | #line 534 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1500 | { yyval.StrVal = yyvsp[0].StrVal; ; |
| 1501 | break;} |
| 1502 | case 67: |
| 1503 | #line 534 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1504 | { yyval.StrVal = new std::string(); ; |
| 1505 | break;} |
| 1506 | case 68: |
| 1507 | #line 536 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1508 | { |
| 1509 | static unsigned AnonCounter = 0; |
| 1510 | if (yyvsp[0].StrVal->empty()) |
| 1511 | *yyvsp[0].StrVal = "anonymous."+utostr(AnonCounter++); |
| 1512 | CurRec = new Record(*yyvsp[0].StrVal); |
| 1513 | delete yyvsp[0].StrVal; |
| 1514 | ParsingTemplateArgs = true; |
| 1515 | ; |
| 1516 | break;} |
| 1517 | case 69: |
| 1518 | #line 545 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1519 | { |
| 1520 | if (Records.getClass(CurRec->getName())) { |
| 1521 | err() << "Class '" << CurRec->getName() << "' already defined!\n"; |
| 1522 | exit(1); |
| 1523 | } |
| 1524 | Records.addClass(CurRec); |
| 1525 | ; |
| 1526 | break;} |
| 1527 | case 70: |
| 1528 | #line 553 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1529 | { |
| 1530 | // Ensure redefinition doesn't happen. |
| 1531 | if (Records.getDef(CurRec->getName())) { |
| 1532 | err() << "Def '" << CurRec->getName() << "' already defined!\n"; |
| 1533 | exit(1); |
| 1534 | } |
| 1535 | Records.addDef(CurRec); |
| 1536 | ; |
| 1537 | break;} |
| 1538 | case 71: |
| 1539 | #line 562 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1540 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1541 | ParsingTemplateArgs = false; |
| 1542 | for (unsigned i = 0, e = yyvsp[0].SubClassList->size(); i != e; ++i) { |
Chris Lattner | ba4b144 | 2005-09-08 18:22:57 +0000 | [diff] [blame] | 1543 | addSubClass((*yyvsp[0].SubClassList)[i].first, *(*yyvsp[0].SubClassList)[i].second); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1544 | // Delete the template arg values for the class |
| 1545 | delete (*yyvsp[0].SubClassList)[i].second; |
| 1546 | } |
| 1547 | delete yyvsp[0].SubClassList; // Delete the class list... |
| 1548 | |
Chris Lattner | ba4b144 | 2005-09-08 18:22:57 +0000 | [diff] [blame] | 1549 | // Process any variables on the set stack... |
| 1550 | for (unsigned i = 0, e = LetStack.size(); i != e; ++i) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1551 | for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j) |
| 1552 | setValue(LetStack[i][j].Name, |
| 1553 | LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0, |
| 1554 | LetStack[i][j].Value); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1555 | ; |
| 1556 | break;} |
| 1557 | case 72: |
| 1558 | #line 577 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1559 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1560 | yyval.Rec = CurRec; |
| 1561 | CurRec = 0; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1562 | ; |
| 1563 | break;} |
| 1564 | case 73: |
| 1565 | #line 582 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1566 | { |
| 1567 | yyval.Rec = yyvsp[0].Rec; |
| 1568 | ; |
| 1569 | break;} |
| 1570 | case 74: |
| 1571 | #line 586 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1572 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1573 | yyvsp[0].Rec->resolveReferences(); |
| 1574 | |
Chris Lattner | ca572be | 2005-09-08 18:48:47 +0000 | [diff] [blame] | 1575 | // If ObjectBody has template arguments, it's an error. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1576 | if (!yyvsp[0].Rec->getTemplateArgs().empty()) { |
| 1577 | err() << "Def '" << yyvsp[0].Rec->getName() |
| 1578 | << "' is not permitted to have template arguments!\n"; |
| 1579 | exit(1); |
| 1580 | } |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1581 | yyval.Rec = yyvsp[0].Rec; |
| 1582 | ; |
| 1583 | break;} |
| 1584 | case 77: |
| 1585 | #line 601 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1586 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1587 | LetStack.back().push_back(LetRecord(*yyvsp[-3].StrVal, yyvsp[-2].BitList, yyvsp[0].Initializer)); |
| 1588 | delete yyvsp[-3].StrVal; delete yyvsp[-2].BitList; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1589 | ; |
| 1590 | break;} |
| 1591 | case 80: |
| 1592 | #line 609 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1593 | { LetStack.push_back(std::vector<LetRecord>()); ; |
| 1594 | break;} |
| 1595 | case 82: |
| 1596 | #line 612 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1597 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1598 | LetStack.pop_back(); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1599 | ; |
| 1600 | break;} |
| 1601 | case 83: |
| 1602 | #line 615 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1603 | { |
Chris Lattner | ca572be | 2005-09-08 18:48:47 +0000 | [diff] [blame] | 1604 | LetStack.pop_back(); |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1605 | ; |
| 1606 | break;} |
| 1607 | case 84: |
| 1608 | #line 619 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1609 | {; |
| 1610 | break;} |
| 1611 | case 85: |
| 1612 | #line 619 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1613 | {; |
| 1614 | break;} |
| 1615 | case 86: |
| 1616 | #line 621 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
| 1617 | {; |
| 1618 | break;} |
| 1619 | } |
| 1620 | /* the action file gets copied in in place of this dollarsign */ |
| 1621 | #line 543 "/usr/share/bison.simple" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1622 | |
| 1623 | yyvsp -= yylen; |
| 1624 | yyssp -= yylen; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1625 | #ifdef YYLSP_NEEDED |
| 1626 | yylsp -= yylen; |
| 1627 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1628 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1629 | #if YYDEBUG != 0 |
| 1630 | if (yydebug) |
| 1631 | { |
| 1632 | short *ssp1 = yyss - 1; |
| 1633 | fprintf (stderr, "state stack now"); |
| 1634 | while (ssp1 != yyssp) |
| 1635 | fprintf (stderr, " %d", *++ssp1); |
| 1636 | fprintf (stderr, "\n"); |
| 1637 | } |
| 1638 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1639 | |
| 1640 | *++yyvsp = yyval; |
| 1641 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1642 | #ifdef YYLSP_NEEDED |
| 1643 | yylsp++; |
| 1644 | if (yylen == 0) |
| 1645 | { |
| 1646 | yylsp->first_line = yylloc.first_line; |
| 1647 | yylsp->first_column = yylloc.first_column; |
| 1648 | yylsp->last_line = (yylsp-1)->last_line; |
| 1649 | yylsp->last_column = (yylsp-1)->last_column; |
| 1650 | yylsp->text = 0; |
| 1651 | } |
| 1652 | else |
| 1653 | { |
| 1654 | yylsp->last_line = (yylsp+yylen-1)->last_line; |
| 1655 | yylsp->last_column = (yylsp+yylen-1)->last_column; |
| 1656 | } |
| 1657 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1658 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1659 | /* Now "shift" the result of the reduction. |
| 1660 | Determine what state that goes to, |
| 1661 | based on the state we popped back to |
| 1662 | and the rule number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1663 | |
| 1664 | yyn = yyr1[yyn]; |
| 1665 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1666 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; |
| 1667 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1668 | yystate = yytable[yystate]; |
| 1669 | else |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1670 | yystate = yydefgoto[yyn - YYNTBASE]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1671 | |
| 1672 | goto yynewstate; |
| 1673 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1674 | yyerrlab: /* here on detecting error */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1675 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1676 | if (! yyerrstatus) |
| 1677 | /* If not already recovering from an error, report this error. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1678 | { |
| 1679 | ++yynerrs; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1680 | |
| 1681 | #ifdef YYERROR_VERBOSE |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1682 | yyn = yypact[yystate]; |
| 1683 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1684 | if (yyn > YYFLAG && yyn < YYLAST) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1685 | { |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1686 | int size = 0; |
| 1687 | char *msg; |
| 1688 | int x, count; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1689 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1690 | count = 0; |
| 1691 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ |
| 1692 | for (x = (yyn < 0 ? -yyn : 0); |
| 1693 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 1694 | if (yycheck[x + yyn] == x) |
| 1695 | size += strlen(yytname[x]) + 15, count++; |
| 1696 | msg = (char *) malloc(size + 15); |
| 1697 | if (msg != 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1698 | { |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1699 | strcpy(msg, "parse error"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1700 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1701 | if (count < 5) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1702 | { |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1703 | count = 0; |
| 1704 | for (x = (yyn < 0 ? -yyn : 0); |
| 1705 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 1706 | if (yycheck[x + yyn] == x) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1707 | { |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1708 | strcat(msg, count == 0 ? ", expecting `" : " or `"); |
| 1709 | strcat(msg, yytname[x]); |
| 1710 | strcat(msg, "'"); |
| 1711 | count++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1712 | } |
| 1713 | } |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1714 | yyerror(msg); |
| 1715 | free(msg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1716 | } |
| 1717 | else |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1718 | yyerror ("parse error; also virtual memory exceeded"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1719 | } |
| 1720 | else |
| 1721 | #endif /* YYERROR_VERBOSE */ |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1722 | yyerror("parse error"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1723 | } |
| 1724 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1725 | goto yyerrlab1; |
| 1726 | yyerrlab1: /* here on error raised explicitly by an action */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1727 | |
| 1728 | if (yyerrstatus == 3) |
| 1729 | { |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1730 | /* if just tried and failed to reuse lookahead token after an error, discard it. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1731 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1732 | /* return failure if at end of input */ |
Chris Lattner | ba4b144 | 2005-09-08 18:22:57 +0000 | [diff] [blame] | 1733 | if (yychar == YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1734 | YYABORT; |
| 1735 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1736 | #if YYDEBUG != 0 |
| 1737 | if (yydebug) |
| 1738 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); |
| 1739 | #endif |
Chris Lattner | ba4b144 | 2005-09-08 18:22:57 +0000 | [diff] [blame] | 1740 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1741 | yychar = YYEMPTY; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1742 | } |
| 1743 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1744 | /* Else will try to reuse lookahead token |
| 1745 | after shifting the error token. */ |
| 1746 | |
| 1747 | yyerrstatus = 3; /* Each real token shifted decrements this */ |
| 1748 | |
| 1749 | goto yyerrhandle; |
| 1750 | |
| 1751 | yyerrdefault: /* current state does not do anything special for the error token. */ |
| 1752 | |
| 1753 | #if 0 |
| 1754 | /* This is wrong; only states that explicitly want error tokens |
| 1755 | should shift them. */ |
| 1756 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ |
| 1757 | if (yyn) goto yydefault; |
| 1758 | #endif |
| 1759 | |
| 1760 | yyerrpop: /* pop the current state because it cannot handle the error token */ |
| 1761 | |
| 1762 | if (yyssp == yyss) YYABORT; |
| 1763 | yyvsp--; |
| 1764 | yystate = *--yyssp; |
| 1765 | #ifdef YYLSP_NEEDED |
| 1766 | yylsp--; |
| 1767 | #endif |
| 1768 | |
| 1769 | #if YYDEBUG != 0 |
| 1770 | if (yydebug) |
| 1771 | { |
| 1772 | short *ssp1 = yyss - 1; |
| 1773 | fprintf (stderr, "Error: state stack now"); |
| 1774 | while (ssp1 != yyssp) |
| 1775 | fprintf (stderr, " %d", *++ssp1); |
| 1776 | fprintf (stderr, "\n"); |
| 1777 | } |
| 1778 | #endif |
| 1779 | |
| 1780 | yyerrhandle: |
| 1781 | |
| 1782 | yyn = yypact[yystate]; |
| 1783 | if (yyn == YYFLAG) |
| 1784 | goto yyerrdefault; |
| 1785 | |
| 1786 | yyn += YYTERROR; |
| 1787 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) |
| 1788 | goto yyerrdefault; |
| 1789 | |
| 1790 | yyn = yytable[yyn]; |
| 1791 | if (yyn < 0) |
| 1792 | { |
| 1793 | if (yyn == YYFLAG) |
| 1794 | goto yyerrpop; |
| 1795 | yyn = -yyn; |
| 1796 | goto yyreduce; |
| 1797 | } |
| 1798 | else if (yyn == 0) |
| 1799 | goto yyerrpop; |
| 1800 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1801 | if (yyn == YYFINAL) |
| 1802 | YYACCEPT; |
| 1803 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1804 | #if YYDEBUG != 0 |
| 1805 | if (yydebug) |
| 1806 | fprintf(stderr, "Shifting error token, "); |
| 1807 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1808 | |
| 1809 | *++yyvsp = yylval; |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1810 | #ifdef YYLSP_NEEDED |
| 1811 | *++yylsp = yylloc; |
| 1812 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1813 | |
| 1814 | yystate = yyn; |
| 1815 | goto yynewstate; |
| 1816 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1817 | yyacceptlab: |
| 1818 | /* YYACCEPT comes here. */ |
| 1819 | if (yyfree_stacks) |
| 1820 | { |
| 1821 | free (yyss); |
| 1822 | free (yyvs); |
| 1823 | #ifdef YYLSP_NEEDED |
| 1824 | free (yyls); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1825 | #endif |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1826 | } |
| 1827 | return 0; |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 1828 | |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1829 | yyabortlab: |
| 1830 | /* YYABORT comes here. */ |
| 1831 | if (yyfree_stacks) |
| 1832 | { |
| 1833 | free (yyss); |
| 1834 | free (yyvs); |
| 1835 | #ifdef YYLSP_NEEDED |
| 1836 | free (yyls); |
Chris Lattner | 2b931e8 | 2005-09-12 05:30:06 +0000 | [diff] [blame] | 1837 | #endif |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1838 | } |
| 1839 | return 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1840 | } |
Chris Lattner | 8d354e9 | 2005-09-30 04:11:27 +0000 | [diff] [blame^] | 1841 | #line 623 "/Users/sabre/llvm/utils/TableGen/FileParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1842 | |
| 1843 | |
| 1844 | int yyerror(const char *ErrorMsg) { |
| 1845 | err() << "Error parsing: " << ErrorMsg << "\n"; |
| 1846 | exit(1); |
| 1847 | } |