2 /* A Bison parser, made from llvmAsmParser.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define yyparse llvmAsmparse
8 #define yylex llvmAsmlex
9 #define yyerror llvmAsmerror
10 #define yylval llvmAsmlval
11 #define yychar llvmAsmchar
12 #define yydebug llvmAsmdebug
13 #define yynerrs llvmAsmnerrs
14 #define ESINT64VAL 257
15 #define EUINT64VAL 258
36 #define STRINGCONSTANT 279
37 #define IMPLEMENTATION 280
64 #define GETELEMENTPTR 307
71 #line 13 "llvmAsmParser.y"
73 #include "ParserInternals.h"
74 #include "llvm/BasicBlock.h"
75 #include "llvm/Method.h"
76 #include "llvm/SymbolTable.h"
77 #include "llvm/Module.h"
78 #include "llvm/Type.h"
79 #include "llvm/DerivedTypes.h"
80 #include "llvm/Assembly/Parser.h"
81 #include "llvm/ConstantPool.h"
82 #include "llvm/iTerminators.h"
83 #include "llvm/iMemory.h"
85 #include <utility> // Get definition of pair class
86 #include <algorithm> // Get definition of find_if
87 #include <stdio.h> // This embarasment is due to our flex lexer...
89 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
90 int yylex(); // declaration" of xxx warnings.
93 static Module *ParserResult;
94 const ToolCommandLine *CurOptions = 0;
96 // This contains info used when building the body of a method. It is destroyed
97 // when the method is completed.
99 typedef vector<Value *> ValueList; // Numbered defs
100 static void ResolveDefinitions(vector<ValueList> &LateResolvers);
102 static struct PerModuleInfo {
103 Module *CurrentModule;
104 vector<ValueList> Values; // Module level numbered definitions
105 vector<ValueList> LateResolveValues;
108 // If we could not resolve some blocks at parsing time (forward branches)
109 // resolve the branches now...
110 ResolveDefinitions(LateResolveValues);
112 Values.clear(); // Clear out method local definitions
117 static struct PerMethodInfo {
118 Method *CurrentMethod; // Pointer to current method being created
120 vector<ValueList> Values; // Keep track of numbered definitions
121 vector<ValueList> LateResolveValues;
122 bool isDeclare; // Is this method a forward declararation?
124 inline PerMethodInfo() {
129 inline ~PerMethodInfo() {}
131 inline void MethodStart(Method *M) {
136 // If we could not resolve some blocks at parsing time (forward branches)
137 // resolve the branches now...
138 ResolveDefinitions(LateResolveValues);
140 Values.clear(); // Clear out method local definitions
144 } CurMeth; // Info for the current method...
147 //===----------------------------------------------------------------------===//
148 // Code to handle definitions of all the types
149 //===----------------------------------------------------------------------===//
151 static void InsertValue(Value *D, vector<ValueList> &ValueTab = CurMeth.Values) {
152 if (!D->hasName()) { // Is this a numbered definition?
153 unsigned type = D->getType()->getUniqueID();
154 if (ValueTab.size() <= type)
155 ValueTab.resize(type+1, ValueList());
156 //printf("Values[%d][%d] = %d\n", type, ValueTab[type].size(), D);
157 ValueTab[type].push_back(D);
161 static Value *getVal(const Type *Type, ValID &D,
162 bool DoNotImprovise = false) {
164 case 0: { // Is it a numbered definition?
165 unsigned type = Type->getUniqueID();
166 unsigned Num = (unsigned)D.Num;
168 // Module constants occupy the lowest numbered slots...
169 if (type < CurModule.Values.size()) {
170 if (Num < CurModule.Values[type].size())
171 return CurModule.Values[type][Num];
173 Num -= CurModule.Values[type].size();
176 // Make sure that our type is within bounds
177 if (CurMeth.Values.size() <= type)
180 // Check that the number is within bounds...
181 if (CurMeth.Values[type].size() <= Num)
184 return CurMeth.Values[type][Num];
186 case 1: { // Is it a named definition?
188 SymbolTable *SymTab = 0;
189 if (CurMeth.CurrentMethod)
190 SymTab = CurMeth.CurrentMethod->getSymbolTable();
191 Value *N = SymTab ? SymTab->lookup(Type, Name) : 0;
194 SymTab = CurModule.CurrentModule->getSymbolTable();
196 N = SymTab->lookup(Type, Name);
200 D.destroy(); // Free old strdup'd memory...
204 case 2: // Is it a constant pool reference??
205 case 3: // Is it an unsigned const pool reference?
206 case 4: // Is it a string const pool reference?
207 case 5:{ // Is it a floating point const pool reference?
208 ConstPoolVal *CPV = 0;
210 // Check to make sure that "Type" is an integral type, and that our
211 // value will fit into the specified type...
214 if (Type == Type::BoolTy) { // Special handling for boolean data
215 CPV = new ConstPoolBool(D.ConstPool64 != 0);
217 if (!ConstPoolSInt::isValueValidForType(Type, D.ConstPool64))
218 ThrowException("Symbolic constant pool value '" +
219 itostr(D.ConstPool64) + "' is invalid for type '" +
220 Type->getName() + "'!");
221 CPV = new ConstPoolSInt(Type, D.ConstPool64);
225 if (!ConstPoolUInt::isValueValidForType(Type, D.UConstPool64)) {
226 if (!ConstPoolSInt::isValueValidForType(Type, D.ConstPool64)) {
227 ThrowException("Integral constant pool reference is invalid!");
228 } else { // This is really a signed reference. Transmogrify.
229 CPV = new ConstPoolSInt(Type, D.ConstPool64);
232 CPV = new ConstPoolUInt(Type, D.UConstPool64);
236 cerr << "FIXME: TODO: String constants [sbyte] not implemented yet!\n";
238 //CPV = new ConstPoolString(D.Name);
239 D.destroy(); // Free the string memory
242 if (!ConstPoolFP::isValueValidForType(Type, D.ConstPoolFP))
243 ThrowException("FP constant invalid for type!!");
245 CPV = new ConstPoolFP(Type, D.ConstPoolFP);
248 assert(CPV && "How did we escape creating a constant??");
250 // Scan through the constant table and see if we already have loaded this
253 ConstantPool &CP = CurMeth.CurrentMethod ?
254 CurMeth.CurrentMethod->getConstantPool() :
255 CurModule.CurrentModule->getConstantPool();
256 ConstPoolVal *C = CP.find(CPV); // Already have this constant?
258 delete CPV; // Didn't need this after all, oh well.
259 return C; // Yup, we already have one, recycle it!
263 // Success, everything is kosher. Lets go!
265 } // End of case 2,3,4
269 // If we reached here, we referenced either a symbol that we don't know about
270 // or an id number that hasn't been read yet. We may be referencing something
271 // forward, so just create an entry to be resolved later and get to it...
273 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
275 // TODO: Attempt to coallecse nodes that are the same with previous ones.
277 switch (Type->getPrimitiveID()) {
278 case Type::LabelTyID: d = new BBPlaceHolder(Type, D); break;
279 case Type::MethodTyID:
280 d = new MethPlaceHolder(Type, D);
281 InsertValue(d, CurModule.LateResolveValues);
283 //case Type::ClassTyID: d = new ClassPlaceHolder(Type, D); break;
284 default: d = new DefPlaceHolder(Type, D); break;
287 assert(d != 0 && "How did we not make something?");
288 InsertValue(d, CurMeth.LateResolveValues);
293 //===----------------------------------------------------------------------===//
294 // Code to handle forward references in instructions
295 //===----------------------------------------------------------------------===//
297 // This code handles the late binding needed with statements that reference
298 // values not defined yet... for example, a forward branch, or the PHI node for
301 // This keeps a table (CurMeth.LateResolveValues) of all such forward references
302 // and back patchs after we are done.
305 // ResolveDefinitions - If we could not resolve some defs at parsing
306 // time (forward branches, phi functions for loops, etc...) resolve the
309 static void ResolveDefinitions(vector<ValueList> &LateResolvers) {
310 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
311 for (unsigned ty = 0; ty < LateResolvers.size(); ty++) {
312 while (!LateResolvers[ty].empty()) {
313 Value *V = LateResolvers[ty].back();
314 LateResolvers[ty].pop_back();
315 ValID &DID = getValIDFromPlaceHolder(V);
317 Value *TheRealValue = getVal(Type::getUniqueIDType(ty), DID, true);
319 if (TheRealValue == 0 && DID.Type == 1)
320 ThrowException("Reference to an invalid definition: '" +DID.getName() +
321 "' of type '" + V->getType()->getName() + "'");
322 else if (TheRealValue == 0)
323 ThrowException("Reference to an invalid definition: #" +itostr(DID.Num)+
324 " of type '" + V->getType()->getName() + "'");
326 V->replaceAllUsesWith(TheRealValue);
327 assert(V->use_empty());
332 LateResolvers.clear();
335 // addConstValToConstantPool - This code is used to insert a constant into the
336 // current constant pool. This is designed to make maximal (but not more than
337 // possible) reuse (merging) of constants in the constant pool. This means that
338 // multiple references to %4, for example will all get merged.
340 static ConstPoolVal *addConstValToConstantPool(ConstPoolVal *C) {
341 vector<ValueList> &ValTab = CurMeth.CurrentMethod ?
342 CurMeth.Values : CurModule.Values;
343 ConstantPool &CP = CurMeth.CurrentMethod ?
344 CurMeth.CurrentMethod->getConstantPool() :
345 CurModule.CurrentModule->getConstantPool();
347 if (ConstPoolVal *CPV = CP.find(C)) {
348 // Constant already in constant pool. Try to merge the two constants
349 if (CPV->hasName() && !C->hasName()) {
350 // Merge the two values, we inherit the existing CPV's name.
351 // InsertValue requires that the value have no name to insert correctly
352 // (because we want to fill the slot this constant would have filled)
354 string Name = CPV->getName();
356 InsertValue(CPV, ValTab);
360 } else if (!CPV->hasName() && C->hasName()) {
361 // If we have a name on this value and there isn't one in the const
362 // pool val already, propogate it.
364 CPV->setName(C->getName());
365 delete C; // Sorry, you're toast
367 } else if (CPV->hasName() && C->hasName()) {
368 // Both values have distinct names. We cannot merge them.
370 InsertValue(C, ValTab);
372 } else if (!CPV->hasName() && !C->hasName()) {
373 // Neither value has a name, trivially merge them.
374 InsertValue(CPV, ValTab);
379 assert(0 && "Not reached!");
381 } else { // No duplication of value.
383 InsertValue(C, ValTab);
391 inline EqualsType(const Type *t) { T = t; }
392 inline bool operator()(const ConstPoolVal *CPV) const {
393 return static_cast<const ConstPoolType*>(CPV)->getValue() == T;
398 // checkNewType - We have to be careful to add all types referenced by the
399 // program to the constant pool of the method or module. Because of this, we
400 // often want to check to make sure that types used are in the constant pool,
401 // and add them if they aren't. That's what this function does.
403 static const Type *checkNewType(const Type *Ty) {
404 ConstantPool &CP = CurMeth.CurrentMethod ?
405 CurMeth.CurrentMethod->getConstantPool() :
406 CurModule.CurrentModule->getConstantPool();
408 // TODO: This should use ConstantPool::ensureTypeAvailable
410 // Get the type type plane...
411 ConstantPool::PlaneType &P = CP.getPlane(Type::TypeTy);
412 ConstantPool::PlaneType::const_iterator PI = find_if(P.begin(), P.end(),
415 vector<ValueList> &ValTab = CurMeth.CurrentMethod ?
416 CurMeth.Values : CurModule.Values;
417 ConstPoolVal *CPT = new ConstPoolType(Ty);
419 InsertValue(CPT, ValTab);
425 //===----------------------------------------------------------------------===//
426 // RunVMAsmParser - Define an interface to this parser
427 //===----------------------------------------------------------------------===//
429 Module *RunVMAsmParser(const ToolCommandLine &Opts, FILE *F) {
432 llvmAsmlineno = 1; // Reset the current line number...
434 CurModule.CurrentModule = new Module(); // Allocate a new module to read
435 yyparse(); // Parse the file.
436 Module *Result = ParserResult;
438 llvmAsmin = stdin; // F is about to go away, don't use it anymore...
445 #line 387 "llvmAsmParser.y"
449 MethodArgument *MethArgVal;
450 BasicBlock *BasicBlockVal;
451 TerminatorInst *TermInstVal;
452 Instruction *InstVal;
453 ConstPoolVal *ConstVal;
456 list<MethodArgument*> *MethodArgList;
457 list<Value*> *ValueList;
458 list<const Type*> *TypeList;
459 list<pair<Value*, BasicBlock*> > *PHIList; // Represent the RHS of PHI node
460 list<pair<ConstPoolVal*, BasicBlock*> > *JumpTable;
461 vector<ConstPoolVal*> *ConstVector;
469 char *StrVal; // This memory is allocated by strdup!
470 ValID ValIDVal; // May contain memory allocated by strdup
472 Instruction::UnaryOps UnaryOpVal;
473 Instruction::BinaryOps BinaryOpVal;
474 Instruction::TermOps TermOpVal;
475 Instruction::MemoryOps MemOpVal;
476 Instruction::OtherOps OtherOpVal;
489 #define YYFLAG -32768
492 #define YYTRANSLATE(x) ((unsigned)(x) <= 312 ? yytranslate[x] : 110)
494 static const char yytranslate[] = { 0,
495 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
496 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
497 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
498 2, 2, 2, 2, 2, 2, 2, 2, 2, 66,
499 67, 68, 2, 65, 2, 2, 2, 2, 2, 2,
500 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
501 59, 2, 2, 2, 2, 2, 2, 2, 2, 2,
502 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504 60, 2, 61, 2, 2, 2, 2, 2, 2, 2,
505 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
506 2, 2, 2, 2, 2, 2, 2, 2, 2, 62,
507 2, 2, 63, 2, 64, 2, 2, 2, 2, 2,
508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
512 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
514 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
516 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
520 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
521 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
522 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
523 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
524 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
525 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
530 static const short yyprhs[] = { 0,
531 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
532 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
533 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
534 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
535 80, 82, 84, 86, 88, 90, 92, 95, 96, 99,
536 102, 105, 108, 111, 114, 117, 124, 130, 139, 147,
537 154, 159, 163, 165, 169, 170, 172, 175, 178, 181,
538 183, 184, 187, 191, 193, 195, 196, 202, 206, 209,
539 210, 214, 216, 218, 220, 222, 224, 226, 228, 230,
540 232, 234, 239, 243, 247, 253, 257, 260, 263, 265,
541 269, 272, 275, 278, 282, 285, 286, 290, 293, 297,
542 307, 317, 324, 330, 333, 340, 348, 351, 356, 358,
543 359, 365, 369, 376, 382, 385, 392, 394, 397, 398,
544 401, 407, 410, 416, 420, 425, 433
547 static const short yyrhs[] = { 5,
548 0, 6, 0, 3, 0, 4, 0, 9, 0, 10,
549 0, 11, 0, 12, 0, 13, 0, 14, 0, 15,
550 0, 16, 0, 17, 0, 18, 0, 19, 0, 20,
551 0, 21, 0, 22, 0, 71, 0, 8, 0, 36,
552 0, 37, 0, 38, 0, 39, 0, 40, 0, 41,
553 0, 42, 0, 43, 0, 44, 0, 45, 0, 46,
554 0, 47, 0, 57, 0, 58, 0, 16, 0, 14,
555 0, 12, 0, 10, 0, 17, 0, 15, 0, 13,
556 0, 11, 0, 76, 0, 77, 0, 18, 0, 19,
557 0, 23, 59, 0, 0, 76, 70, 0, 77, 4,
558 0, 9, 27, 0, 9, 28, 0, 79, 7, 0,
559 20, 25, 0, 21, 71, 0, 60, 71, 61, 60,
560 82, 61, 0, 60, 71, 61, 60, 61, 0, 60,
561 4, 62, 71, 61, 60, 82, 61, 0, 60, 4,
562 62, 71, 61, 60, 61, 0, 63, 97, 64, 63,
563 82, 64, 0, 63, 64, 63, 64, 0, 82, 65,
564 81, 0, 81, 0, 83, 80, 81, 0, 0, 85,
565 0, 85, 92, 0, 85, 93, 0, 83, 26, 0,
566 23, 0, 0, 71, 86, 0, 87, 65, 88, 0,
567 87, 0, 88, 0, 0, 72, 25, 66, 89, 67,
568 0, 90, 83, 29, 0, 98, 30, 0, 0, 31,
569 94, 90, 0, 3, 0, 4, 0, 7, 0, 27,
570 0, 28, 0, 25, 0, 69, 0, 23, 0, 95,
571 0, 96, 0, 72, 66, 97, 67, 0, 72, 66,
572 67, 0, 60, 71, 61, 0, 60, 4, 62, 71,
573 61, 0, 63, 97, 64, 0, 63, 64, 0, 71,
574 68, 0, 71, 0, 97, 65, 71, 0, 98, 99,
575 0, 91, 99, 0, 100, 101, 0, 24, 100, 101,
576 0, 100, 103, 0, 0, 33, 71, 96, 0, 33,
577 8, 0, 34, 22, 96, 0, 34, 9, 96, 65,
578 22, 96, 65, 22, 96, 0, 35, 78, 96, 65,
579 22, 96, 60, 102, 61, 0, 102, 78, 95, 65,
580 22, 96, 0, 78, 95, 65, 22, 96, 0, 80,
581 107, 0, 71, 60, 96, 65, 96, 61, 0, 104,
582 65, 60, 96, 65, 96, 61, 0, 71, 96, 0,
583 105, 65, 71, 96, 0, 105, 0, 0, 74, 71,
584 96, 65, 96, 0, 73, 71, 96, 0, 75, 71,
585 96, 65, 71, 96, 0, 56, 71, 96, 32, 71,
586 0, 54, 104, 0, 55, 71, 96, 66, 106, 67,
587 0, 109, 0, 65, 82, 0, 0, 48, 71, 0,
588 48, 71, 65, 15, 96, 0, 49, 71, 0, 49,
589 71, 65, 15, 96, 0, 50, 71, 96, 0, 51,
590 71, 96, 108, 0, 52, 71, 96, 65, 71, 96,
591 108, 0, 53, 71, 96, 108, 0
597 static const short yyrline[] = { 0,
598 486, 487, 494, 495, 506, 506, 506, 506, 506, 506,
599 506, 507, 507, 507, 507, 507, 507, 507, 510, 510,
600 515, 516, 516, 516, 516, 516, 517, 517, 517, 517,
601 517, 517, 518, 518, 522, 522, 522, 522, 523, 523,
602 523, 523, 524, 524, 525, 525, 528, 531, 538, 543,
603 548, 551, 554, 557, 563, 566, 579, 583, 601, 608,
604 616, 630, 633, 643, 660, 671, 678, 684, 690, 699,
605 699, 701, 709, 713, 718, 721, 725, 766, 770, 774,
606 774, 782, 785, 788, 791, 794, 797, 802, 805, 808,
607 815, 823, 828, 832, 835, 838, 843, 846, 851, 855,
608 860, 864, 873, 878, 887, 891, 895, 898, 901, 904,
609 909, 920, 928, 938, 946, 951, 958, 962, 968, 968,
610 970, 975, 980, 984, 987, 998, 1035, 1040, 1042, 1046,
611 1049, 1056, 1059, 1067, 1073, 1082, 1094
616 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
618 static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
619 "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
620 "USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","STRING","TYPE","LABEL",
621 "VAR_ID","LABELSTR","STRINGCONSTANT","IMPLEMENTATION","TRUE","FALSE","BEGINTOK",
622 "END","DECLARE","TO","RET","BR","SWITCH","NOT","ADD","SUB","MUL","DIV","REM",
623 "SETLE","SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD",
624 "STORE","GETELEMENTPTR","PHI","CALL","CAST","SHL","SHR","'='","'['","']'","'x'",
625 "'{'","'}'","','","'('","')'","'*'","INTVAL","EINT64VAL","Types","TypesV","UnaryOps",
626 "BinaryOps","ShiftOps","SIntType","UIntType","IntType","FPType","OptAssign",
627 "ConstVal","ConstVector","ConstPool","Module","MethodList","OptVAR_ID","ArgVal",
628 "ArgListH","ArgList","MethodHeaderH","MethodHeader","Method","MethodProto","@1",
629 "ConstValueRef","ValueRef","TypeList","BasicBlockList","BasicBlock","InstructionList",
630 "BBTerminatorInst","JumpTable","Inst","PHIList","ValueRefList","ValueRefListE",
631 "InstVal","UByteList","MemoryInst", NULL
635 static const short yyr1[] = { 0,
636 69, 69, 70, 70, 71, 71, 71, 71, 71, 71,
637 71, 71, 71, 71, 71, 71, 71, 71, 72, 72,
638 73, 74, 74, 74, 74, 74, 74, 74, 74, 74,
639 74, 74, 75, 75, 76, 76, 76, 76, 77, 77,
640 77, 77, 78, 78, 79, 79, 80, 80, 81, 81,
641 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
642 81, 82, 82, 83, 83, 84, 85, 85, 85, 86,
643 86, 87, 88, 88, 89, 89, 90, 91, 92, 94,
644 93, 95, 95, 95, 95, 95, 95, 96, 96, 96,
645 71, 71, 71, 71, 71, 71, 71, 71, 97, 97,
646 98, 98, 99, 99, 100, 100, 101, 101, 101, 101,
647 101, 102, 102, 103, 104, 104, 105, 105, 106, 106,
648 107, 107, 107, 107, 107, 107, 107, 108, 108, 109,
649 109, 109, 109, 109, 109, 109, 109
652 static const short yyr2[] = { 0,
653 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
654 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
655 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
656 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
657 1, 1, 1, 1, 1, 1, 2, 0, 2, 2,
658 2, 2, 2, 2, 2, 6, 5, 8, 7, 6,
659 4, 3, 1, 3, 0, 1, 2, 2, 2, 1,
660 0, 2, 3, 1, 1, 0, 5, 3, 2, 0,
661 3, 1, 1, 1, 1, 1, 1, 1, 1, 1,
662 1, 4, 3, 3, 5, 3, 2, 2, 1, 3,
663 2, 2, 2, 3, 2, 0, 3, 2, 3, 9,
664 9, 6, 5, 2, 6, 7, 2, 4, 1, 0,
665 5, 3, 6, 5, 2, 6, 1, 2, 0, 2,
669 static const short yydefact[] = { 65,
670 48, 66, 0, 69, 0, 82, 83, 1, 2, 84,
671 20, 5, 6, 7, 8, 9, 10, 11, 12, 13,
672 14, 15, 16, 17, 18, 89, 87, 85, 86, 80,
673 0, 0, 88, 19, 0, 65, 106, 67, 68, 90,
674 91, 106, 47, 0, 38, 42, 37, 41, 36, 40,
675 35, 39, 45, 46, 0, 0, 0, 0, 0, 0,
676 0, 64, 0, 83, 19, 0, 97, 99, 0, 98,
677 0, 0, 48, 106, 102, 48, 79, 101, 51, 52,
678 54, 55, 83, 19, 0, 0, 3, 4, 49, 50,
679 53, 81, 0, 94, 96, 0, 76, 93, 0, 78,
680 48, 0, 0, 0, 0, 103, 105, 0, 0, 0,
681 0, 19, 100, 71, 74, 75, 0, 92, 104, 108,
682 19, 0, 0, 43, 44, 0, 21, 22, 23, 24,
683 25, 26, 27, 28, 29, 30, 31, 32, 0, 0,
684 0, 0, 0, 0, 0, 0, 0, 33, 34, 0,
685 0, 0, 114, 127, 19, 0, 61, 0, 95, 70,
686 72, 0, 77, 107, 0, 109, 0, 130, 132, 19,
687 19, 19, 19, 19, 125, 19, 19, 19, 19, 19,
688 0, 57, 63, 0, 0, 73, 0, 0, 0, 0,
689 134, 129, 0, 129, 0, 0, 0, 0, 122, 0,
690 0, 0, 56, 0, 60, 0, 0, 0, 0, 0,
691 135, 0, 137, 0, 0, 120, 0, 0, 0, 59,
692 0, 62, 0, 0, 131, 133, 128, 19, 0, 0,
693 19, 119, 0, 124, 121, 19, 58, 0, 0, 129,
694 0, 0, 117, 0, 126, 123, 0, 0, 0, 136,
695 115, 0, 19, 110, 0, 111, 0, 116, 118, 0,
696 0, 0, 0, 113, 0, 112, 0, 0, 0
699 static const short yydefgoto[] = { 33,
700 89, 68, 66, 150, 151, 152, 59, 60, 126, 61,
701 5, 183, 184, 1, 267, 2, 161, 115, 116, 117,
702 36, 37, 38, 39, 63, 40, 41, 69, 42, 75,
703 76, 106, 249, 107, 175, 232, 233, 153, 211, 154
706 static const short yypact[] = {-32768,
707 2, 354, -36,-32768, 557,-32768,-32768,-32768,-32768,-32768,
708 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
709 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
710 415, 266,-32768, -9, -16,-32768, 66,-32768,-32768,-32768,
711 -32768, 46,-32768, 145,-32768,-32768,-32768,-32768,-32768,-32768,
712 -32768,-32768,-32768,-32768, 68, 441, 502, 328, 191, 119,
713 124,-32768, 441, 92, -3, 117,-32768, 37, 132,-32768,
714 133, 240, 101,-32768,-32768, 64,-32768,-32768,-32768,-32768,
715 -32768, 37, 144, 13, 148, 137,-32768,-32768,-32768,-32768,
716 -32768,-32768, 441,-32768,-32768, 441, 441,-32768, 55,-32768,
717 64, 528, 40, 165, 556,-32768,-32768, 441, 147, 149,
718 153, 24, 37, 7, 143,-32768, 152,-32768,-32768, 146,
719 -1, 163, 163,-32768,-32768, 163,-32768,-32768,-32768,-32768,
720 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 441, 441,
721 441, 441, 441, 441, 441, 441, 441,-32768,-32768, 441,
722 441, 441,-32768,-32768, 28, 23,-32768, 557,-32768,-32768,
723 -32768, 441,-32768,-32768, 155,-32768, 157, 36, 87, -1,
724 -1, -1, -1, 20, 158, -1, -1, -1, -1, -1,
725 164,-32768,-32768, 60, 140,-32768, 203, 204, 212, 213,
726 -32768, 166, 167, 166, 163, 169, 168, 198,-32768, 170,
727 171, 98,-32768, 557,-32768, 163, 163, 163, 163, 557,
728 -32768, 441,-32768, 172, 163, 441, 441, 163, 441,-32768,
729 128,-32768, 173, 179,-32768,-32768, 175, -1, 163, 176,
730 -1, 199, 223, 37,-32768, -1,-32768, 211, 165, 166,
731 205, 163,-32768, 441,-32768,-32768, 163, 44, 3,-32768,
732 -32768, 231, -1,-32768, 230,-32768, 44,-32768,-32768, 274,
733 232, 163, 276,-32768, 163,-32768, 299, 301,-32768
736 static const short yypgoto[] = {-32768,
737 -32768, -2, 5,-32768,-32768,-32768, -93, -92, -186,-32768,
738 -55, -4, -150, 268,-32768,-32768,-32768,-32768, 150,-32768,
739 239,-32768,-32768,-32768,-32768, -191, -44, -27,-32768, 263,
740 234, 208,-32768,-32768,-32768,-32768,-32768,-32768, -184,-32768
747 static const short yytable[] = { 34,
748 62, 6, 7, 8, 9, 10, 35, 185, 71, 213,
749 124, 125, 45, 46, 47, 48, 49, 50, 51, 52,
750 105, 26, 43, 27, 3, 28, 29, 4, 65, 160,
751 86, 44, 45, 46, 47, 48, 49, 50, 51, 52,
752 53, 54, 55, 56, 99, 105, 6, 7, 122, 72,
753 10, 221, 248, 82, 84, 250, 255, 94, 70, 227,
754 34, 123, 257, 256, 70, 261, 70, 35, 27, 74,
755 28, 29, -19, 109, 70, 77, 164, 165, 166, 195,
756 70, 167, 57, 182, 159, 58, 3, 70, 181, 74,
757 112, 70, 81, 113, 114, 70, 102, 103, 104, 121,
758 189, -19, -19, 70, 70, 155, 44, 45, 46, 47,
759 48, 49, 50, 51, 52, 53, 54, 55, 56, 96,
760 203, 118, 90, 3, 204, 191, 192, 193, 194, 100,
761 91, 197, 198, 199, 200, 201, 168, 169, 170, 171,
762 172, 173, 174, 176, 177, 124, 125, 178, 179, 180,
763 214, 190, -19, 93, 70, 124, 125, 57, 220, 114,
764 58, 223, 224, 225, 226, 6, 7, 8, 9, 10,
765 230, 79, 80, 235, 45, 46, 47, 48, 49, 50,
766 51, 52, 72, 240, 241, 26, 243, 27, 237, 28,
767 29, 246, 204, 87, 88, 95, 96, 252, 97, 222,
768 111, 96, 254, 205, 204, 108, 156, 162, 259, 228,
769 110, -20, 157, 231, 234, 158, 236, 264, 163, 187,
770 266, 188, 196, 202, 206, 207, 208, 209, 215, 217,
771 210, 212, 247, 216, 218, 219, 229, 238, 239, 204,
772 242, 253, 6, 7, 8, 9, 10, 11, 12, 13,
773 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
774 24, 25, 26, 244, 27, 251, 28, 29, 6, 7,
775 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
776 18, 19, 20, 21, 22, 23, 24, 25, 26, 245,
777 27, 258, 28, 29, 260, 262, 263, 265, 268, 31,
778 269, 92, 32, 73, 78, 0, 98, 101, 119, 0,
779 0, 186, 0, 0, 0, 0, 0, 0, 0, 0,
780 0, 0, 0, 0, 0, 31, 0, 0, 32, 67,
781 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
782 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
783 26, 0, 27, 0, 28, 29, 6, 7, 8, 9,
784 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
785 20, 21, 22, 23, 24, 25, 26, 0, 27, 0,
786 28, 29, 0, 0, 30, 0, 0, 31, 0, 0,
787 32, 85, 0, 0, 0, 0, 0, 0, 0, 0,
788 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
789 0, 0, 0, 31, 0, 0, 32, 6, 64, 8,
790 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
791 19, 20, 21, 22, 23, 24, 25, 26, 0, 27,
792 0, 28, 29, 6, 7, 8, 9, 10, 11, 12,
793 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
794 23, 24, 25, 26, 0, 27, 0, 28, 29, 0,
795 0, 0, 0, 0, 31, 0, 0, 32, 0, 0,
796 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
797 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
798 31, 0, 0, 32, 6, 83, 8, 9, 10, 11,
799 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
800 22, 23, 24, 25, 26, 0, 27, 0, 28, 29,
801 6, 7, 8, 9, 10, 120, 12, 13, 14, 15,
802 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
803 26, 0, 27, 0, 28, 29, 0, 0, 0, 0,
804 0, 31, 0, 0, 32, 44, 45, 46, 47, 48,
805 49, 50, 51, 52, 53, 54, 55, 56, 0, 0,
806 0, 0, 0, 0, 0, 0, 0, 31, 0, 0,
807 32, 127, 128, 129, 130, 131, 132, 133, 134, 135,
808 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
809 146, 147, 148, 149, 0, 0, 57, 0, 0, 58
812 static const short yycheck[] = { 2,
813 5, 3, 4, 5, 6, 7, 2, 158, 25, 194,
814 104, 104, 10, 11, 12, 13, 14, 15, 16, 17,
815 76, 23, 59, 25, 23, 27, 28, 26, 31, 23,
816 58, 9, 10, 11, 12, 13, 14, 15, 16, 17,
817 18, 19, 20, 21, 72, 101, 3, 4, 9, 66,
818 7, 202, 239, 56, 57, 240, 248, 61, 68, 210,
819 63, 22, 249, 61, 68, 257, 68, 63, 25, 24,
820 27, 28, 66, 61, 68, 30, 121, 122, 123, 60,
821 68, 126, 60, 61, 61, 63, 23, 68, 61, 24,
822 93, 68, 25, 96, 97, 68, 33, 34, 35, 102,
823 65, 66, 66, 68, 68, 108, 9, 10, 11, 12,
824 13, 14, 15, 16, 17, 18, 19, 20, 21, 65,
825 61, 67, 4, 23, 65, 170, 171, 172, 173, 29,
826 7, 176, 177, 178, 179, 180, 139, 140, 141, 142,
827 143, 144, 145, 146, 147, 239, 239, 150, 151, 152,
828 195, 65, 66, 62, 68, 249, 249, 60, 61, 162,
829 63, 206, 207, 208, 209, 3, 4, 5, 6, 7,
830 215, 27, 28, 218, 10, 11, 12, 13, 14, 15,
831 16, 17, 66, 228, 229, 23, 231, 25, 61, 27,
832 28, 236, 65, 3, 4, 64, 65, 242, 66, 204,
833 64, 65, 247, 64, 65, 62, 60, 65, 253, 212,
834 63, 66, 64, 216, 217, 63, 219, 262, 67, 65,
835 265, 65, 65, 60, 22, 22, 15, 15, 60, 32,
836 65, 65, 22, 66, 65, 65, 65, 65, 60, 65,
837 65, 244, 3, 4, 5, 6, 7, 8, 9, 10,
838 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
839 21, 22, 23, 65, 25, 61, 27, 28, 3, 4,
840 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
841 15, 16, 17, 18, 19, 20, 21, 22, 23, 67,
842 25, 61, 27, 28, 65, 22, 65, 22, 0, 60,
843 0, 63, 63, 36, 42, -1, 67, 74, 101, -1,
844 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
845 -1, -1, -1, -1, -1, 60, -1, -1, 63, 64,
846 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
847 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
848 23, -1, 25, -1, 27, 28, 3, 4, 5, 6,
849 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
850 17, 18, 19, 20, 21, 22, 23, -1, 25, -1,
851 27, 28, -1, -1, 31, -1, -1, 60, -1, -1,
852 63, 64, -1, -1, -1, -1, -1, -1, -1, -1,
853 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
854 -1, -1, -1, 60, -1, -1, 63, 3, 4, 5,
855 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
856 16, 17, 18, 19, 20, 21, 22, 23, -1, 25,
857 -1, 27, 28, 3, 4, 5, 6, 7, 8, 9,
858 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
859 20, 21, 22, 23, -1, 25, -1, 27, 28, -1,
860 -1, -1, -1, -1, 60, -1, -1, 63, -1, -1,
861 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
862 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
863 60, -1, -1, 63, 3, 4, 5, 6, 7, 8,
864 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
865 19, 20, 21, 22, 23, -1, 25, -1, 27, 28,
866 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
867 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
868 23, -1, 25, -1, 27, 28, -1, -1, -1, -1,
869 -1, 60, -1, -1, 63, 9, 10, 11, 12, 13,
870 14, 15, 16, 17, 18, 19, 20, 21, -1, -1,
871 -1, -1, -1, -1, -1, -1, -1, 60, -1, -1,
872 63, 36, 37, 38, 39, 40, 41, 42, 43, 44,
873 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
874 55, 56, 57, 58, -1, -1, 60, -1, -1, 63
876 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
877 #line 3 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
878 /* This file comes from bison-1.28. */
880 /* Skeleton output parser for bison,
881 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
883 This program is free software; you can redistribute it and/or modify
884 it under the terms of the GNU General Public License as published by
885 the Free Software Foundation; either version 2, or (at your option)
888 This program is distributed in the hope that it will be useful,
889 but WITHOUT ANY WARRANTY; without even the implied warranty of
890 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
891 GNU General Public License for more details.
893 You should have received a copy of the GNU General Public License
894 along with this program; if not, write to the Free Software
895 Foundation, Inc., 59 Temple Place - Suite 330,
896 Boston, MA 02111-1307, USA. */
898 /* As a special exception, when this file is copied by Bison into a
899 Bison output file, you may use that output file without restriction.
900 This special exception was added by the Free Software Foundation
901 in version 1.24 of Bison. */
903 /* This is the parser code that is written into each bison parser
904 when the %semantic_parser declaration is not specified in the grammar.
905 It was written by Richard Stallman by simplifying the hairy parser
906 used when %semantic_parser is specified. */
908 #ifndef YYSTACK_USE_ALLOCA
910 #define YYSTACK_USE_ALLOCA
911 #else /* alloca not defined */
913 #define YYSTACK_USE_ALLOCA
914 #define alloca __builtin_alloca
915 #else /* not GNU C. */
916 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
917 #define YYSTACK_USE_ALLOCA
919 #else /* not sparc */
920 /* We think this test detects Watcom and Microsoft C. */
921 /* This used to test MSDOS, but that is a bad idea
922 since that symbol is in the user namespace. */
923 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
924 #if 0 /* No need for malloc.h, which pollutes the namespace;
925 instead, just don't use alloca. */
928 #else /* not MSDOS, or __TURBOC__ */
930 /* I don't know what this was needed for, but it pollutes the namespace.
931 So I turned it off. rms, 2 May 1997. */
932 /* #include <malloc.h> */
934 #define YYSTACK_USE_ALLOCA
935 #else /* not MSDOS, or __TURBOC__, or _AIX */
937 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
938 and on HPUX 10. Eventually we can turn this on. */
939 #define YYSTACK_USE_ALLOCA
940 #define alloca __builtin_alloca
943 #endif /* not _AIX */
944 #endif /* not MSDOS, or __TURBOC__ */
945 #endif /* not sparc */
946 #endif /* not GNU C */
947 #endif /* alloca not defined */
948 #endif /* YYSTACK_USE_ALLOCA not defined */
950 #ifdef YYSTACK_USE_ALLOCA
951 #define YYSTACK_ALLOC alloca
953 #define YYSTACK_ALLOC malloc
956 /* Note: there must be only one dollar sign in this file.
957 It is replaced by the list of actions, each action
958 as one case of the switch. */
960 #define yyerrok (yyerrstatus = 0)
961 #define yyclearin (yychar = YYEMPTY)
964 #define YYACCEPT goto yyacceptlab
965 #define YYABORT goto yyabortlab
966 #define YYERROR goto yyerrlab1
967 /* Like YYERROR except do call yyerror.
968 This remains here temporarily to ease the
969 transition to the new meaning of YYERROR, for GCC.
970 Once GCC version 2 has supplanted version 1, this can go. */
971 #define YYFAIL goto yyerrlab
972 #define YYRECOVERING() (!!yyerrstatus)
973 #define YYBACKUP(token, value) \
975 if (yychar == YYEMPTY && yylen == 1) \
976 { yychar = (token), yylval = (value); \
977 yychar1 = YYTRANSLATE (yychar); \
982 { yyerror ("syntax error: cannot back up"); YYERROR; } \
986 #define YYERRCODE 256
989 #define YYLEX yylex()
995 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
997 #define YYLEX yylex(&yylval, &yylloc)
999 #else /* not YYLSP_NEEDED */
1001 #define YYLEX yylex(&yylval, YYLEX_PARAM)
1003 #define YYLEX yylex(&yylval)
1005 #endif /* not YYLSP_NEEDED */
1008 /* If nonreentrant, generate the variables here */
1012 int yychar; /* the lookahead symbol */
1013 YYSTYPE yylval; /* the semantic value of the */
1014 /* lookahead symbol */
1017 YYLTYPE yylloc; /* location data for the lookahead */
1021 int yynerrs; /* number of parse errors so far */
1022 #endif /* not YYPURE */
1025 int yydebug; /* nonzero means print parse trace */
1026 /* Since this is uninitialized, it does not stop multiple parsers
1030 /* YYINITDEPTH indicates the initial size of the parser's stacks */
1033 #define YYINITDEPTH 200
1036 /* YYMAXDEPTH is the maximum size the stacks can grow to
1037 (effective only if the built-in stack extension method is used). */
1044 #define YYMAXDEPTH 10000
1047 /* Define __yy_memcpy. Note that the size argument
1048 should be passed with type unsigned int, because that is what the non-GCC
1049 definitions require. With GCC, __builtin_memcpy takes an arg
1050 of type size_t, but it can handle unsigned int. */
1052 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1053 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1054 #else /* not GNU C or C++ */
1057 /* This is the most reliable way to avoid incompatibilities
1058 in available built-in functions on various systems. */
1060 __yy_memcpy (to, from, count)
1065 register char *f = from;
1066 register char *t = to;
1067 register int i = count;
1073 #else /* __cplusplus */
1075 /* This is the most reliable way to avoid incompatibilities
1076 in available built-in functions on various systems. */
1078 __yy_memcpy (char *to, char *from, unsigned int count)
1080 register char *t = to;
1081 register char *f = from;
1082 register int i = count;
1091 #line 217 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
1093 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
1094 into yyparse. The argument should have type void *.
1095 It should actually point to an object.
1096 Grammar actions can access the variable by casting it
1097 to the proper pointer type. */
1099 #ifdef YYPARSE_PARAM
1101 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1102 #define YYPARSE_PARAM_DECL
1103 #else /* not __cplusplus */
1104 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1105 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1106 #endif /* not __cplusplus */
1107 #else /* not YYPARSE_PARAM */
1108 #define YYPARSE_PARAM_ARG
1109 #define YYPARSE_PARAM_DECL
1110 #endif /* not YYPARSE_PARAM */
1112 /* Prevent warning if -Wstrict-prototypes. */
1114 #ifdef YYPARSE_PARAM
1115 int yyparse (void *);
1122 yyparse(YYPARSE_PARAM_ARG)
1125 register int yystate;
1127 register short *yyssp;
1128 register YYSTYPE *yyvsp;
1129 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1130 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
1132 short yyssa[YYINITDEPTH]; /* the state stack */
1133 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
1135 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1136 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
1139 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1140 YYLTYPE *yyls = yylsa;
1143 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1145 #define YYPOPSTACK (yyvsp--, yyssp--)
1148 int yystacksize = YYINITDEPTH;
1149 int yyfree_stacks = 0;
1160 YYSTYPE yyval; /* the variable used to return */
1161 /* semantic values from the action */
1168 fprintf(stderr, "Starting parse\n");
1174 yychar = YYEMPTY; /* Cause a token to be read. */
1176 /* Initialize stack pointers.
1177 Waste one element of value and location stack
1178 so that they stay on the same level as the state stack.
1179 The wasted elements are never initialized. */
1187 /* Push a new state, which is found in yystate . */
1188 /* In all cases, when you get here, the value and location stacks
1189 have just been pushed. so pushing a state here evens the stacks. */
1194 if (yyssp >= yyss + yystacksize - 1)
1196 /* Give user a chance to reallocate the stack */
1197 /* Use copies of these so that the &'s don't force the real ones into memory. */
1198 YYSTYPE *yyvs1 = yyvs;
1199 short *yyss1 = yyss;
1201 YYLTYPE *yyls1 = yyls;
1204 /* Get the current used size of the three stacks, in elements. */
1205 int size = yyssp - yyss + 1;
1208 /* Each stack pointer address is followed by the size of
1209 the data in use in that stack, in bytes. */
1211 /* This used to be a conditional around just the two extra args,
1212 but that might be undefined if yyoverflow is a macro. */
1213 yyoverflow("parser stack overflow",
1214 &yyss1, size * sizeof (*yyssp),
1215 &yyvs1, size * sizeof (*yyvsp),
1216 &yyls1, size * sizeof (*yylsp),
1219 yyoverflow("parser stack overflow",
1220 &yyss1, size * sizeof (*yyssp),
1221 &yyvs1, size * sizeof (*yyvsp),
1225 yyss = yyss1; yyvs = yyvs1;
1229 #else /* no yyoverflow */
1230 /* Extend the stack our own way. */
1231 if (yystacksize >= YYMAXDEPTH)
1233 yyerror("parser stack overflow");
1245 if (yystacksize > YYMAXDEPTH)
1246 yystacksize = YYMAXDEPTH;
1247 #ifndef YYSTACK_USE_ALLOCA
1250 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
1251 __yy_memcpy ((char *)yyss, (char *)yyss1,
1252 size * (unsigned int) sizeof (*yyssp));
1253 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
1254 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
1255 size * (unsigned int) sizeof (*yyvsp));
1257 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
1258 __yy_memcpy ((char *)yyls, (char *)yyls1,
1259 size * (unsigned int) sizeof (*yylsp));
1261 #endif /* no yyoverflow */
1263 yyssp = yyss + size - 1;
1264 yyvsp = yyvs + size - 1;
1266 yylsp = yyls + size - 1;
1271 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
1274 if (yyssp >= yyss + yystacksize - 1)
1280 fprintf(stderr, "Entering state %d\n", yystate);
1286 /* Do appropriate processing given the current state. */
1287 /* Read a lookahead token if we need one and don't already have one. */
1290 /* First try to decide what to do without reference to lookahead token. */
1292 yyn = yypact[yystate];
1296 /* Not known => get a lookahead token if don't already have one. */
1298 /* yychar is either YYEMPTY or YYEOF
1299 or a valid token in external form. */
1301 if (yychar == YYEMPTY)
1305 fprintf(stderr, "Reading a token: ");
1310 /* Convert token to internal form (in yychar1) for indexing tables with */
1312 if (yychar <= 0) /* This means end of input. */
1315 yychar = YYEOF; /* Don't call YYLEX any more */
1319 fprintf(stderr, "Now at end of input.\n");
1324 yychar1 = YYTRANSLATE(yychar);
1329 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
1330 /* Give the individual parser a way to print the precise meaning
1331 of a token, for further debugging info. */
1333 YYPRINT (stderr, yychar, yylval);
1335 fprintf (stderr, ")\n");
1341 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
1346 /* yyn is what to do for this token type in this state.
1347 Negative => reduce, -yyn is rule number.
1348 Positive => shift, yyn is new state.
1349 New state is final state => don't bother to shift,
1350 just return success.
1351 0, or most negative number => error. */
1366 /* Shift the lookahead token. */
1370 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1373 /* Discard the token being shifted unless it is eof. */
1374 if (yychar != YYEOF)
1382 /* count tokens shifted since error; after three, turn off error status. */
1383 if (yyerrstatus) yyerrstatus--;
1388 /* Do the default action for the current state. */
1391 yyn = yydefact[yystate];
1395 /* Do a reduction. yyn is the number of a rule to reduce with. */
1399 yyval = yyvsp[1-yylen]; /* implement default value of the action */
1406 fprintf (stderr, "Reducing via rule %d (line %d), ",
1409 /* Print the symbols being reduced, and their result. */
1410 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1411 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1412 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1420 #line 487 "llvmAsmParser.y"
1422 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
1423 ThrowException("Value too large for type!");
1424 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
1428 #line 495 "llvmAsmParser.y"
1430 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
1431 ThrowException("Value too large for type!");
1432 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
1436 #line 528 "llvmAsmParser.y"
1438 yyval.StrVal = yyvsp[-1].StrVal;
1442 #line 531 "llvmAsmParser.y"
1448 #line 538 "llvmAsmParser.y"
1449 { // integral constants
1450 if (!ConstPoolSInt::isValueValidForType(yyvsp[-1].TypeVal, yyvsp[0].SInt64Val))
1451 ThrowException("Constant value doesn't fit in type!");
1452 yyval.ConstVal = new ConstPoolSInt(yyvsp[-1].TypeVal, yyvsp[0].SInt64Val);
1456 #line 543 "llvmAsmParser.y"
1457 { // integral constants
1458 if (!ConstPoolUInt::isValueValidForType(yyvsp[-1].TypeVal, yyvsp[0].UInt64Val))
1459 ThrowException("Constant value doesn't fit in type!");
1460 yyval.ConstVal = new ConstPoolUInt(yyvsp[-1].TypeVal, yyvsp[0].UInt64Val);
1464 #line 548 "llvmAsmParser.y"
1465 { // Boolean constants
1466 yyval.ConstVal = new ConstPoolBool(true);
1470 #line 551 "llvmAsmParser.y"
1471 { // Boolean constants
1472 yyval.ConstVal = new ConstPoolBool(false);
1476 #line 554 "llvmAsmParser.y"
1477 { // Float & Double constants
1478 yyval.ConstVal = new ConstPoolFP(yyvsp[-1].TypeVal, yyvsp[0].FPVal);
1482 #line 557 "llvmAsmParser.y"
1483 { // String constants
1484 cerr << "FIXME: TODO: String constants [sbyte] not implemented yet!\n";
1486 //$$ = new ConstPoolString($2);
1487 free(yyvsp[0].StrVal);
1491 #line 563 "llvmAsmParser.y"
1493 yyval.ConstVal = new ConstPoolType(yyvsp[0].TypeVal);
1497 #line 566 "llvmAsmParser.y"
1498 { // Nonempty array constant
1499 // Verify all elements are correct type!
1500 const ArrayType *AT = ArrayType::getArrayType(yyvsp[-4].TypeVal);
1501 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
1502 if (yyvsp[-4].TypeVal != (*yyvsp[-1].ConstVector)[i]->getType())
1503 ThrowException("Element #" + utostr(i) + " is not of type '" +
1504 yyvsp[-4].TypeVal->getName() + "' as required!\nIt is of type '" +
1505 (*yyvsp[-1].ConstVector)[i]->getType()->getName() + "'.");
1508 yyval.ConstVal = new ConstPoolArray(AT, *yyvsp[-1].ConstVector);
1509 delete yyvsp[-1].ConstVector;
1513 #line 579 "llvmAsmParser.y"
1514 { // Empty array constant
1515 vector<ConstPoolVal*> Empty;
1516 yyval.ConstVal = new ConstPoolArray(ArrayType::getArrayType(yyvsp[-3].TypeVal), Empty);
1520 #line 583 "llvmAsmParser.y"
1522 // Verify all elements are correct type!
1523 const ArrayType *AT = ArrayType::getArrayType(yyvsp[-4].TypeVal, (int)yyvsp[-6].UInt64Val);
1524 if (yyvsp[-6].UInt64Val != yyvsp[-1].ConstVector->size())
1525 ThrowException("Type mismatch: constant sized array initialized with " +
1526 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
1527 itostr((int)yyvsp[-6].UInt64Val) + "!");
1529 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
1530 if (yyvsp[-4].TypeVal != (*yyvsp[-1].ConstVector)[i]->getType())
1531 ThrowException("Element #" + utostr(i) + " is not of type '" +
1532 yyvsp[-4].TypeVal->getName() + "' as required!\nIt is of type '" +
1533 (*yyvsp[-1].ConstVector)[i]->getType()->getName() + "'.");
1536 yyval.ConstVal = new ConstPoolArray(AT, *yyvsp[-1].ConstVector);
1537 delete yyvsp[-1].ConstVector;
1541 #line 601 "llvmAsmParser.y"
1543 if (yyvsp[-5].UInt64Val != 0)
1544 ThrowException("Type mismatch: constant sized array initialized with 0"
1545 " arguments, but has size of " + itostr((int)yyvsp[-5].UInt64Val) + "!");
1546 vector<ConstPoolVal*> Empty;
1547 yyval.ConstVal = new ConstPoolArray(ArrayType::getArrayType(yyvsp[-3].TypeVal, 0), Empty);
1551 #line 608 "llvmAsmParser.y"
1553 StructType::ElementTypes Types(yyvsp[-4].TypeList->begin(), yyvsp[-4].TypeList->end());
1554 delete yyvsp[-4].TypeList;
1556 const StructType *St = StructType::getStructType(Types);
1557 yyval.ConstVal = new ConstPoolStruct(St, *yyvsp[-1].ConstVector);
1558 delete yyvsp[-1].ConstVector;
1562 #line 616 "llvmAsmParser.y"
1564 const StructType *St =
1565 StructType::getStructType(StructType::ElementTypes());
1566 vector<ConstPoolVal*> Empty;
1567 yyval.ConstVal = new ConstPoolStruct(St, Empty);
1571 #line 630 "llvmAsmParser.y"
1573 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(addConstValToConstantPool(yyvsp[0].ConstVal));
1577 #line 633 "llvmAsmParser.y"
1579 yyval.ConstVector = new vector<ConstPoolVal*>();
1580 yyval.ConstVector->push_back(addConstValToConstantPool(yyvsp[0].ConstVal));
1584 #line 643 "llvmAsmParser.y"
1586 if (yyvsp[-1].StrVal) {
1587 yyvsp[0].ConstVal->setName(yyvsp[-1].StrVal);
1588 free(yyvsp[-1].StrVal);
1591 addConstValToConstantPool(yyvsp[0].ConstVal);
1595 #line 660 "llvmAsmParser.y"
1600 #line 671 "llvmAsmParser.y"
1602 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
1603 CurModule.ModuleDone();
1607 #line 678 "llvmAsmParser.y"
1609 yyval.ModuleVal = yyvsp[-1].ModuleVal;
1610 if (!yyvsp[0].MethodVal->getParent())
1611 yyvsp[-1].ModuleVal->getMethodList().push_back(yyvsp[0].MethodVal);
1612 CurMeth.MethodDone();
1616 #line 684 "llvmAsmParser.y"
1618 yyval.ModuleVal = yyvsp[-1].ModuleVal;
1619 if (!yyvsp[0].MethodVal->getParent())
1620 yyvsp[-1].ModuleVal->getMethodList().push_back(yyvsp[0].MethodVal);
1621 CurMeth.MethodDone();
1625 #line 690 "llvmAsmParser.y"
1627 yyval.ModuleVal = CurModule.CurrentModule;
1631 #line 699 "llvmAsmParser.y"
1632 { yyval.StrVal = 0; ;
1635 #line 701 "llvmAsmParser.y"
1637 yyval.MethArgVal = new MethodArgument(yyvsp[-1].TypeVal);
1638 if (yyvsp[0].StrVal) { // Was the argument named?
1639 yyval.MethArgVal->setName(yyvsp[0].StrVal);
1640 free(yyvsp[0].StrVal); // The string was strdup'd, so free it now.
1645 #line 709 "llvmAsmParser.y"
1647 yyval.MethodArgList = yyvsp[0].MethodArgList;
1648 yyvsp[0].MethodArgList->push_front(yyvsp[-2].MethArgVal);
1652 #line 713 "llvmAsmParser.y"
1654 yyval.MethodArgList = new list<MethodArgument*>();
1655 yyval.MethodArgList->push_front(yyvsp[0].MethArgVal);
1659 #line 718 "llvmAsmParser.y"
1661 yyval.MethodArgList = yyvsp[0].MethodArgList;
1665 #line 721 "llvmAsmParser.y"
1667 yyval.MethodArgList = 0;
1671 #line 725 "llvmAsmParser.y"
1673 MethodType::ParamTypes ParamTypeList;
1674 if (yyvsp[-1].MethodArgList)
1675 for (list<MethodArgument*>::iterator I = yyvsp[-1].MethodArgList->begin(); I != yyvsp[-1].MethodArgList->end(); ++I)
1676 ParamTypeList.push_back((*I)->getType());
1678 const MethodType *MT = MethodType::getMethodType(yyvsp[-4].TypeVal, ParamTypeList);
1681 if (SymbolTable *ST = CurModule.CurrentModule->getSymbolTable()) {
1682 if (Value *V = ST->lookup(MT, yyvsp[-3].StrVal)) { // Method already in symtab?
1683 M = V->castMethodAsserting();
1685 // Yes it is. If this is the case, either we need to be a forward decl,
1686 // or it needs to be.
1687 if (!CurMeth.isDeclare && !M->isExternal())
1688 ThrowException("Redefinition of method '" + string(yyvsp[-3].StrVal) + "'!");
1692 if (M == 0) { // Not already defined?
1693 M = new Method(MT, yyvsp[-3].StrVal);
1694 InsertValue(M, CurModule.Values);
1697 free(yyvsp[-3].StrVal); // Free strdup'd memory!
1699 CurMeth.MethodStart(M);
1701 // Add all of the arguments we parsed to the method...
1702 if (yyvsp[-1].MethodArgList && !CurMeth.isDeclare) { // Is null if empty...
1703 Method::ArgumentListType &ArgList = M->getArgumentList();
1705 for (list<MethodArgument*>::iterator I = yyvsp[-1].MethodArgList->begin(); I != yyvsp[-1].MethodArgList->end(); ++I) {
1707 ArgList.push_back(*I);
1709 delete yyvsp[-1].MethodArgList; // We're now done with the argument list
1714 #line 766 "llvmAsmParser.y"
1716 yyval.MethodVal = CurMeth.CurrentMethod;
1720 #line 770 "llvmAsmParser.y"
1722 yyval.MethodVal = yyvsp[-1].MethodVal;
1726 #line 774 "llvmAsmParser.y"
1727 { CurMeth.isDeclare = true; ;
1730 #line 774 "llvmAsmParser.y"
1732 yyval.MethodVal = CurMeth.CurrentMethod;
1736 #line 782 "llvmAsmParser.y"
1737 { // A reference to a direct constant
1738 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
1742 #line 785 "llvmAsmParser.y"
1744 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
1748 #line 788 "llvmAsmParser.y"
1749 { // Perhaps it's an FP constant?
1750 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
1754 #line 791 "llvmAsmParser.y"
1756 yyval.ValIDVal = ValID::create((int64_t)1);
1760 #line 794 "llvmAsmParser.y"
1762 yyval.ValIDVal = ValID::create((int64_t)0);
1766 #line 797 "llvmAsmParser.y"
1767 { // Quoted strings work too... especially for methods
1768 yyval.ValIDVal = ValID::create_conststr(yyvsp[0].StrVal);
1772 #line 802 "llvmAsmParser.y"
1773 { // Is it an integer reference...?
1774 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
1778 #line 805 "llvmAsmParser.y"
1779 { // Is it a named reference...?
1780 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
1784 #line 808 "llvmAsmParser.y"
1786 yyval.ValIDVal = yyvsp[0].ValIDVal;
1790 #line 815 "llvmAsmParser.y"
1792 Value *D = getVal(Type::TypeTy, yyvsp[0].ValIDVal, true);
1793 if (D == 0) ThrowException("Invalid user defined type: " + yyvsp[0].ValIDVal.getName());
1795 // User defined type not in const pool!
1796 ConstPoolType *CPT = (ConstPoolType*)D->castConstantAsserting();
1797 yyval.TypeVal = CPT->getValue();
1801 #line 823 "llvmAsmParser.y"
1802 { // Method derived type?
1803 MethodType::ParamTypes Params(yyvsp[-1].TypeList->begin(), yyvsp[-1].TypeList->end());
1804 delete yyvsp[-1].TypeList;
1805 yyval.TypeVal = checkNewType(MethodType::getMethodType(yyvsp[-3].TypeVal, Params));
1809 #line 828 "llvmAsmParser.y"
1810 { // Method derived type?
1811 MethodType::ParamTypes Params; // Empty list
1812 yyval.TypeVal = checkNewType(MethodType::getMethodType(yyvsp[-2].TypeVal, Params));
1816 #line 832 "llvmAsmParser.y"
1818 yyval.TypeVal = checkNewType(ArrayType::getArrayType(yyvsp[-1].TypeVal));
1822 #line 835 "llvmAsmParser.y"
1824 yyval.TypeVal = checkNewType(ArrayType::getArrayType(yyvsp[-1].TypeVal, (int)yyvsp[-3].UInt64Val));
1828 #line 838 "llvmAsmParser.y"
1830 StructType::ElementTypes Elements(yyvsp[-1].TypeList->begin(), yyvsp[-1].TypeList->end());
1831 delete yyvsp[-1].TypeList;
1832 yyval.TypeVal = checkNewType(StructType::getStructType(Elements));
1836 #line 843 "llvmAsmParser.y"
1838 yyval.TypeVal = checkNewType(StructType::getStructType(StructType::ElementTypes()));
1842 #line 846 "llvmAsmParser.y"
1844 yyval.TypeVal = checkNewType(PointerType::getPointerType(yyvsp[-1].TypeVal));
1848 #line 851 "llvmAsmParser.y"
1850 yyval.TypeList = new list<const Type*>();
1851 yyval.TypeList->push_back(yyvsp[0].TypeVal);
1855 #line 855 "llvmAsmParser.y"
1857 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(yyvsp[0].TypeVal);
1861 #line 860 "llvmAsmParser.y"
1863 yyvsp[-1].MethodVal->getBasicBlocks().push_back(yyvsp[0].BasicBlockVal);
1864 yyval.MethodVal = yyvsp[-1].MethodVal;
1868 #line 864 "llvmAsmParser.y"
1869 { // Do not allow methods with 0 basic blocks
1870 yyval.MethodVal = yyvsp[-1].MethodVal; // in them...
1871 yyvsp[-1].MethodVal->getBasicBlocks().push_back(yyvsp[0].BasicBlockVal);
1875 #line 873 "llvmAsmParser.y"
1877 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
1878 InsertValue(yyvsp[-1].BasicBlockVal);
1879 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1883 #line 878 "llvmAsmParser.y"
1885 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
1886 yyvsp[-1].BasicBlockVal->setName(yyvsp[-2].StrVal);
1887 free(yyvsp[-2].StrVal); // Free the strdup'd memory...
1889 InsertValue(yyvsp[-1].BasicBlockVal);
1890 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1894 #line 887 "llvmAsmParser.y"
1896 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
1897 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1901 #line 891 "llvmAsmParser.y"
1903 yyval.BasicBlockVal = new BasicBlock();
1907 #line 895 "llvmAsmParser.y"
1908 { // Return with a result...
1909 yyval.TermInstVal = new ReturnInst(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1913 #line 898 "llvmAsmParser.y"
1914 { // Return with no result...
1915 yyval.TermInstVal = new ReturnInst();
1919 #line 901 "llvmAsmParser.y"
1920 { // Unconditional Branch...
1921 yyval.TermInstVal = new BranchInst((BasicBlock*)getVal(Type::LabelTy, yyvsp[0].ValIDVal));
1925 #line 904 "llvmAsmParser.y"
1927 yyval.TermInstVal = new BranchInst((BasicBlock*)getVal(Type::LabelTy, yyvsp[-3].ValIDVal),
1928 (BasicBlock*)getVal(Type::LabelTy, yyvsp[0].ValIDVal),
1929 getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
1933 #line 909 "llvmAsmParser.y"
1935 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].TypeVal, yyvsp[-6].ValIDVal),
1936 (BasicBlock*)getVal(Type::LabelTy, yyvsp[-3].ValIDVal));
1937 yyval.TermInstVal = S;
1939 list<pair<ConstPoolVal*, BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
1940 end = yyvsp[-1].JumpTable->end();
1941 for (; I != end; ++I)
1942 S->dest_push_back(I->first, I->second);
1946 #line 920 "llvmAsmParser.y"
1948 yyval.JumpTable = yyvsp[-5].JumpTable;
1949 ConstPoolVal *V = (ConstPoolVal*)getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal, true);
1951 ThrowException("May only switch on a constant pool value!");
1953 yyval.JumpTable->push_back(make_pair(V, (BasicBlock*)getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal)));
1957 #line 928 "llvmAsmParser.y"
1959 yyval.JumpTable = new list<pair<ConstPoolVal*, BasicBlock*> >();
1960 ConstPoolVal *V = (ConstPoolVal*)getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal, true);
1963 ThrowException("May only switch on a constant pool value!");
1965 yyval.JumpTable->push_back(make_pair(V, (BasicBlock*)getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal)));
1969 #line 938 "llvmAsmParser.y"
1971 if (yyvsp[-1].StrVal) // Is this definition named??
1972 yyvsp[0].InstVal->setName(yyvsp[-1].StrVal); // if so, assign the name...
1974 InsertValue(yyvsp[0].InstVal);
1975 yyval.InstVal = yyvsp[0].InstVal;
1979 #line 946 "llvmAsmParser.y"
1980 { // Used for PHI nodes
1981 yyval.PHIList = new list<pair<Value*, BasicBlock*> >();
1982 yyval.PHIList->push_back(make_pair(getVal(yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal),
1983 (BasicBlock*)getVal(Type::LabelTy, yyvsp[-1].ValIDVal)));
1987 #line 951 "llvmAsmParser.y"
1989 yyval.PHIList = yyvsp[-6].PHIList;
1990 yyvsp[-6].PHIList->push_back(make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
1991 (BasicBlock*)getVal(Type::LabelTy, yyvsp[-1].ValIDVal)));
1995 #line 958 "llvmAsmParser.y"
1996 { // Used for call statements...
1997 yyval.ValueList = new list<Value*>();
1998 yyval.ValueList->push_back(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
2002 #line 962 "llvmAsmParser.y"
2004 yyval.ValueList = yyvsp[-3].ValueList;
2005 yyvsp[-3].ValueList->push_back(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
2009 #line 968 "llvmAsmParser.y"
2010 { yyval.ValueList = 0; ;
2013 #line 970 "llvmAsmParser.y"
2015 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
2016 if (yyval.InstVal == 0)
2017 ThrowException("binary operator returned null!");
2021 #line 975 "llvmAsmParser.y"
2023 yyval.InstVal = UnaryOperator::create(yyvsp[-2].UnaryOpVal, getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
2024 if (yyval.InstVal == 0)
2025 ThrowException("unary operator returned null!");
2029 #line 980 "llvmAsmParser.y"
2031 if (yyvsp[-1].TypeVal != Type::UByteTy) ThrowException("Shift amount must be ubyte!");
2032 yyval.InstVal = new ShiftInst(yyvsp[-5].OtherOpVal, getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal), getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
2036 #line 984 "llvmAsmParser.y"
2038 yyval.InstVal = new CastInst(getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), yyvsp[0].TypeVal);
2042 #line 987 "llvmAsmParser.y"
2044 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
2045 yyval.InstVal = new PHINode(Ty);
2046 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
2047 if (yyvsp[0].PHIList->front().first->getType() != Ty)
2048 ThrowException("All elements of a PHI node must be of the same type!");
2049 ((PHINode*)yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
2050 yyvsp[0].PHIList->pop_front();
2052 delete yyvsp[0].PHIList; // Free the list...
2056 #line 998 "llvmAsmParser.y"
2058 if (!yyvsp[-4].TypeVal->isMethodType())
2059 ThrowException("Can only call methods: invalid type '" +
2060 yyvsp[-4].TypeVal->getName() + "'!");
2062 const MethodType *Ty = (const MethodType*)yyvsp[-4].TypeVal;
2064 Value *V = getVal(Ty, yyvsp[-3].ValIDVal);
2065 if (!V->isMethod() || V->getType() != Ty)
2066 ThrowException("Cannot call: " + yyvsp[-3].ValIDVal.getName() + "!");
2068 // Create or access a new type that corresponds to the function call...
2069 vector<Value *> Params;
2071 if (yyvsp[-1].ValueList) {
2072 // Pull out just the arguments...
2073 Params.insert(Params.begin(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2074 delete yyvsp[-1].ValueList;
2076 // Loop through MethodType's arguments and ensure they are specified
2079 MethodType::ParamTypes::const_iterator I = Ty->getParamTypes().begin();
2081 for (i = 0; i < Params.size() && I != Ty->getParamTypes().end(); ++i,++I){
2082 if (Params[i]->getType() != *I)
2083 ThrowException("Parameter " + utostr(i) + " is not of type '" +
2084 (*I)->getName() + "'!");
2087 if (i != Params.size() || I != Ty->getParamTypes().end())
2088 ThrowException("Invalid number of parameters detected!");
2091 // Create the call node...
2092 yyval.InstVal = new CallInst((Method*)V, Params);
2096 #line 1035 "llvmAsmParser.y"
2098 yyval.InstVal = yyvsp[0].InstVal;
2102 #line 1040 "llvmAsmParser.y"
2104 yyval.ConstVector = yyvsp[0].ConstVector;
2108 #line 1042 "llvmAsmParser.y"
2110 yyval.ConstVector = new vector<ConstPoolVal*>();
2114 #line 1046 "llvmAsmParser.y"
2116 yyval.InstVal = new MallocInst(checkNewType(PointerType::getPointerType(yyvsp[0].TypeVal)));
2120 #line 1049 "llvmAsmParser.y"
2122 if (!yyvsp[-3].TypeVal->isArrayType() || ((const ArrayType*)yyvsp[-3].TypeVal)->isSized())
2123 ThrowException("Trying to allocate " + yyvsp[-3].TypeVal->getName() +
2124 " as unsized array!");
2125 const Type *Ty = checkNewType(PointerType::getPointerType(yyvsp[-3].TypeVal));
2126 yyval.InstVal = new MallocInst(Ty, getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
2130 #line 1056 "llvmAsmParser.y"
2132 yyval.InstVal = new AllocaInst(checkNewType(PointerType::getPointerType(yyvsp[0].TypeVal)));
2136 #line 1059 "llvmAsmParser.y"
2138 if (!yyvsp[-3].TypeVal->isArrayType() || ((const ArrayType*)yyvsp[-3].TypeVal)->isSized())
2139 ThrowException("Trying to allocate " + yyvsp[-3].TypeVal->getName() +
2140 " as unsized array!");
2141 const Type *Ty = checkNewType(PointerType::getPointerType(yyvsp[-3].TypeVal));
2142 Value *ArrSize = getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
2143 yyval.InstVal = new AllocaInst(Ty, ArrSize);
2147 #line 1067 "llvmAsmParser.y"
2149 if (!yyvsp[-1].TypeVal->isPointerType())
2150 ThrowException("Trying to free nonpointer type " + yyvsp[-1].TypeVal->getName() + "!");
2151 yyval.InstVal = new FreeInst(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
2155 #line 1073 "llvmAsmParser.y"
2157 if (!yyvsp[-2].TypeVal->isPointerType())
2158 ThrowException("Can't load from nonpointer type: " + yyvsp[-2].TypeVal->getName());
2159 if (LoadInst::getIndexedType(yyvsp[-2].TypeVal, *yyvsp[0].ConstVector) == 0)
2160 ThrowException("Invalid indices for load instruction!");
2162 yyval.InstVal = new LoadInst(getVal(yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ConstVector);
2163 delete yyvsp[0].ConstVector; // Free the vector...
2167 #line 1082 "llvmAsmParser.y"
2169 if (!yyvsp[-2].TypeVal->isPointerType())
2170 ThrowException("Can't store to a nonpointer type: " + yyvsp[-2].TypeVal->getName());
2171 const Type *ElTy = StoreInst::getIndexedType(yyvsp[-2].TypeVal, *yyvsp[0].ConstVector);
2173 ThrowException("Can't store into that field list!");
2174 if (ElTy != yyvsp[-5].TypeVal)
2175 ThrowException("Can't store '" + yyvsp[-5].TypeVal->getName() + "' into space of type '"+
2176 ElTy->getName() + "'!");
2177 yyval.InstVal = new StoreInst(getVal(yyvsp[-5].TypeVal, yyvsp[-4].ValIDVal), getVal(yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ConstVector);
2178 delete yyvsp[0].ConstVector;
2182 #line 1094 "llvmAsmParser.y"
2184 if (!yyvsp[-2].TypeVal->isPointerType())
2185 ThrowException("getelementptr insn requires pointer operand!");
2186 if (!GetElementPtrInst::getIndexedType(yyvsp[-2].TypeVal, *yyvsp[0].ConstVector, true))
2187 ThrowException("Can't get element ptr '" + yyvsp[-2].TypeVal->getName() + "'!");
2188 yyval.InstVal = new GetElementPtrInst(getVal(yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ConstVector);
2189 delete yyvsp[0].ConstVector;
2190 checkNewType(yyval.InstVal->getType());
2194 /* the action file gets copied in in place of this dollarsign */
2195 #line 543 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
2206 short *ssp1 = yyss - 1;
2207 fprintf (stderr, "state stack now");
2208 while (ssp1 != yyssp)
2209 fprintf (stderr, " %d", *++ssp1);
2210 fprintf (stderr, "\n");
2220 yylsp->first_line = yylloc.first_line;
2221 yylsp->first_column = yylloc.first_column;
2222 yylsp->last_line = (yylsp-1)->last_line;
2223 yylsp->last_column = (yylsp-1)->last_column;
2228 yylsp->last_line = (yylsp+yylen-1)->last_line;
2229 yylsp->last_column = (yylsp+yylen-1)->last_column;
2233 /* Now "shift" the result of the reduction.
2234 Determine what state that goes to,
2235 based on the state we popped back to
2236 and the rule number reduced by. */
2240 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
2241 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2242 yystate = yytable[yystate];
2244 yystate = yydefgoto[yyn - YYNTBASE];
2248 yyerrlab: /* here on detecting error */
2251 /* If not already recovering from an error, report this error. */
2255 #ifdef YYERROR_VERBOSE
2256 yyn = yypact[yystate];
2258 if (yyn > YYFLAG && yyn < YYLAST)
2265 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
2266 for (x = (yyn < 0 ? -yyn : 0);
2267 x < (sizeof(yytname) / sizeof(char *)); x++)
2268 if (yycheck[x + yyn] == x)
2269 size += strlen(yytname[x]) + 15, count++;
2270 msg = (char *) malloc(size + 15);
2273 strcpy(msg, "parse error");
2278 for (x = (yyn < 0 ? -yyn : 0);
2279 x < (sizeof(yytname) / sizeof(char *)); x++)
2280 if (yycheck[x + yyn] == x)
2282 strcat(msg, count == 0 ? ", expecting `" : " or `");
2283 strcat(msg, yytname[x]);
2292 yyerror ("parse error; also virtual memory exceeded");
2295 #endif /* YYERROR_VERBOSE */
2296 yyerror("parse error");
2300 yyerrlab1: /* here on error raised explicitly by an action */
2302 if (yyerrstatus == 3)
2304 /* if just tried and failed to reuse lookahead token after an error, discard it. */
2306 /* return failure if at end of input */
2307 if (yychar == YYEOF)
2312 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
2318 /* Else will try to reuse lookahead token
2319 after shifting the error token. */
2321 yyerrstatus = 3; /* Each real token shifted decrements this */
2325 yyerrdefault: /* current state does not do anything special for the error token. */
2328 /* This is wrong; only states that explicitly want error tokens
2329 should shift them. */
2330 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
2331 if (yyn) goto yydefault;
2334 yyerrpop: /* pop the current state because it cannot handle the error token */
2336 if (yyssp == yyss) YYABORT;
2346 short *ssp1 = yyss - 1;
2347 fprintf (stderr, "Error: state stack now");
2348 while (ssp1 != yyssp)
2349 fprintf (stderr, " %d", *++ssp1);
2350 fprintf (stderr, "\n");
2356 yyn = yypact[yystate];
2361 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
2380 fprintf(stderr, "Shifting error token, ");
2392 /* YYACCEPT comes here. */
2404 /* YYABORT comes here. */
2415 #line 1104 "llvmAsmParser.y"
2417 int yyerror(const char *ErrorMsg) {
2418 ThrowException(string("Parse error: ") + ErrorMsg);