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