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
35 #define STRINGCONSTANT 278
36 #define IMPLEMENTATION 279
63 #define GETELEMENTPTR 306
70 #line 13 "llvmAsmParser.y"
72 #include "ParserInternals.h"
73 #include "llvm/BasicBlock.h"
74 #include "llvm/Method.h"
75 #include "llvm/SymbolTable.h"
76 #include "llvm/Module.h"
77 #include "llvm/Type.h"
78 #include "llvm/DerivedTypes.h"
79 #include "llvm/Assembly/Parser.h"
80 #include "llvm/ConstantPool.h"
81 #include "llvm/iTerminators.h"
82 #include "llvm/iMemory.h"
84 #include <utility> // Get definition of pair class
85 #include <algorithm> // Get definition of find_if
86 #include <stdio.h> // This embarasment is due to our flex lexer...
88 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
89 int yylex(); // declaration" of xxx warnings.
92 static Module *ParserResult;
93 const ToolCommandLine *CurOptions = 0;
95 // This contains info used when building the body of a method. It is destroyed
96 // when the method is completed.
98 typedef vector<Value *> ValueList; // Numbered defs
99 static void ResolveDefinitions(vector<ValueList> &LateResolvers);
101 static struct PerModuleInfo {
102 Module *CurrentModule;
103 vector<ValueList> Values; // Module level numbered definitions
104 vector<ValueList> LateResolveValues;
107 // If we could not resolve some blocks at parsing time (forward branches)
108 // resolve the branches now...
109 ResolveDefinitions(LateResolveValues);
111 Values.clear(); // Clear out method local definitions
116 static struct PerMethodInfo {
117 Method *CurrentMethod; // Pointer to current method being created
119 vector<ValueList> Values; // Keep track of numbered definitions
120 vector<ValueList> LateResolveValues;
122 inline PerMethodInfo() {
126 inline ~PerMethodInfo() {}
128 inline void MethodStart(Method *M) {
133 // If we could not resolve some blocks at parsing time (forward branches)
134 // resolve the branches now...
135 ResolveDefinitions(LateResolveValues);
137 Values.clear(); // Clear out method local definitions
140 } CurMeth; // Info for the current method...
143 //===----------------------------------------------------------------------===//
144 // Code to handle definitions of all the types
145 //===----------------------------------------------------------------------===//
147 static void InsertValue(Value *D, vector<ValueList> &ValueTab = CurMeth.Values) {
148 if (!D->hasName()) { // Is this a numbered definition?
149 unsigned type = D->getType()->getUniqueID();
150 if (ValueTab.size() <= type)
151 ValueTab.resize(type+1, ValueList());
152 //printf("Values[%d][%d] = %d\n", type, ValueTab[type].size(), D);
153 ValueTab[type].push_back(D);
157 static Value *getVal(const Type *Type, ValID &D,
158 bool DoNotImprovise = false) {
160 case 0: { // Is it a numbered definition?
161 unsigned type = Type->getUniqueID();
162 unsigned Num = (unsigned)D.Num;
164 // Module constants occupy the lowest numbered slots...
165 if (type < CurModule.Values.size()) {
166 if (Num < CurModule.Values[type].size())
167 return CurModule.Values[type][Num];
169 Num -= CurModule.Values[type].size();
172 // Make sure that our type is within bounds
173 if (CurMeth.Values.size() <= type)
176 // Check that the number is within bounds...
177 if (CurMeth.Values[type].size() <= Num)
180 return CurMeth.Values[type][Num];
182 case 1: { // Is it a named definition?
184 SymbolTable *SymTab = 0;
185 if (CurMeth.CurrentMethod)
186 SymTab = CurMeth.CurrentMethod->getSymbolTable();
187 Value *N = SymTab ? SymTab->lookup(Type, Name) : 0;
190 SymTab = CurModule.CurrentModule->getSymbolTable();
192 N = SymTab->lookup(Type, Name);
196 D.destroy(); // Free old strdup'd memory...
200 case 2: // Is it a constant pool reference??
201 case 3: // Is it an unsigned const pool reference?
202 case 4:{ // Is it a string const pool reference?
203 ConstPoolVal *CPV = 0;
205 // Check to make sure that "Type" is an integral type, and that our
206 // value will fit into the specified type...
209 if (Type == Type::BoolTy) { // Special handling for boolean data
210 CPV = new ConstPoolBool(D.ConstPool64 != 0);
212 if (!ConstPoolSInt::isValueValidForType(Type, D.ConstPool64))
213 ThrowException("Symbolic constant pool reference is invalid!");
214 CPV = new ConstPoolSInt(Type, D.ConstPool64);
218 if (!ConstPoolUInt::isValueValidForType(Type, D.UConstPool64)) {
219 if (!ConstPoolSInt::isValueValidForType(Type, D.ConstPool64)) {
220 ThrowException("Symbolic constant pool reference is invalid!");
221 } else { // This is really a signed reference. Transmogrify.
222 CPV = new ConstPoolSInt(Type, D.ConstPool64);
225 CPV = new ConstPoolUInt(Type, D.UConstPool64);
229 cerr << "FIXME: TODO: String constants [sbyte] not implemented yet!\n";
231 //CPV = new ConstPoolString(D.Name);
232 D.destroy(); // Free the string memory
235 assert(CPV && "How did we escape creating a constant??");
237 // Scan through the constant table and see if we already have loaded this
240 ConstantPool &CP = CurMeth.CurrentMethod ?
241 CurMeth.CurrentMethod->getConstantPool() :
242 CurModule.CurrentModule->getConstantPool();
243 ConstPoolVal *C = CP.find(CPV); // Already have this constant?
245 delete CPV; // Didn't need this after all, oh well.
246 return C; // Yup, we already have one, recycle it!
250 // Success, everything is kosher. Lets go!
252 } // End of case 2,3,4
256 // If we reached here, we referenced either a symbol that we don't know about
257 // or an id number that hasn't been read yet. We may be referencing something
258 // forward, so just create an entry to be resolved later and get to it...
260 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
262 // TODO: Attempt to coallecse nodes that are the same with previous ones.
264 switch (Type->getPrimitiveID()) {
265 case Type::LabelTyID: d = new BBPlaceHolder(Type, D); break;
266 case Type::MethodTyID:
267 d = new MethPlaceHolder(Type, D);
268 InsertValue(d, CurModule.LateResolveValues);
270 //case Type::ClassTyID: d = new ClassPlaceHolder(Type, D); break;
271 default: d = new DefPlaceHolder(Type, D); break;
274 assert(d != 0 && "How did we not make something?");
275 InsertValue(d, CurMeth.LateResolveValues);
280 //===----------------------------------------------------------------------===//
281 // Code to handle forward references in instructions
282 //===----------------------------------------------------------------------===//
284 // This code handles the late binding needed with statements that reference
285 // values not defined yet... for example, a forward branch, or the PHI node for
288 // This keeps a table (CurMeth.LateResolveValues) of all such forward references
289 // and back patchs after we are done.
292 // ResolveDefinitions - If we could not resolve some defs at parsing
293 // time (forward branches, phi functions for loops, etc...) resolve the
296 static void ResolveDefinitions(vector<ValueList> &LateResolvers) {
297 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
298 for (unsigned ty = 0; ty < LateResolvers.size(); ty++) {
299 while (!LateResolvers[ty].empty()) {
300 Value *V = LateResolvers[ty].back();
301 LateResolvers[ty].pop_back();
302 ValID &DID = getValIDFromPlaceHolder(V);
304 Value *TheRealValue = getVal(Type::getUniqueIDType(ty), DID, true);
306 if (TheRealValue == 0 && DID.Type == 1)
307 ThrowException("Reference to an invalid definition: '" +DID.getName() +
308 "' of type '" + V->getType()->getName() + "'");
309 else if (TheRealValue == 0)
310 ThrowException("Reference to an invalid definition: #" +itostr(DID.Num)+
311 " of type '" + V->getType()->getName() + "'");
313 V->replaceAllUsesWith(TheRealValue);
314 assert(V->use_empty());
319 LateResolvers.clear();
322 // addConstValToConstantPool - This code is used to insert a constant into the
323 // current constant pool. This is designed to make maximal (but not more than
324 // possible) reuse (merging) of constants in the constant pool. This means that
325 // multiple references to %4, for example will all get merged.
327 static ConstPoolVal *addConstValToConstantPool(ConstPoolVal *C) {
328 vector<ValueList> &ValTab = CurMeth.CurrentMethod ?
329 CurMeth.Values : CurModule.Values;
330 ConstantPool &CP = CurMeth.CurrentMethod ?
331 CurMeth.CurrentMethod->getConstantPool() :
332 CurModule.CurrentModule->getConstantPool();
334 if (ConstPoolVal *CPV = CP.find(C)) {
335 // Constant already in constant pool. Try to merge the two constants
336 if (CPV->hasName() && !C->hasName()) {
337 // Merge the two values, we inherit the existing CPV's name.
338 // InsertValue requires that the value have no name to insert correctly
339 // (because we want to fill the slot this constant would have filled)
341 string Name = CPV->getName();
343 InsertValue(CPV, ValTab);
347 } else if (!CPV->hasName() && C->hasName()) {
348 // If we have a name on this value and there isn't one in the const
349 // pool val already, propogate it.
351 CPV->setName(C->getName());
352 delete C; // Sorry, you're toast
354 } else if (CPV->hasName() && C->hasName()) {
355 // Both values have distinct names. We cannot merge them.
357 InsertValue(C, ValTab);
359 } else if (!CPV->hasName() && !C->hasName()) {
360 // Neither value has a name, trivially merge them.
361 InsertValue(CPV, ValTab);
366 assert(0 && "Not reached!");
368 } else { // No duplication of value.
370 InsertValue(C, ValTab);
378 inline EqualsType(const Type *t) { T = t; }
379 inline bool operator()(const ConstPoolVal *CPV) const {
380 return static_cast<const ConstPoolType*>(CPV)->getValue() == T;
385 // checkNewType - We have to be careful to add all types referenced by the
386 // program to the constant pool of the method or module. Because of this, we
387 // often want to check to make sure that types used are in the constant pool,
388 // and add them if they aren't. That's what this function does.
390 static const Type *checkNewType(const Type *Ty) {
391 ConstantPool &CP = CurMeth.CurrentMethod ?
392 CurMeth.CurrentMethod->getConstantPool() :
393 CurModule.CurrentModule->getConstantPool();
395 // Get the type type plane...
396 ConstantPool::PlaneType &P = CP.getPlane(Type::TypeTy);
397 ConstantPool::PlaneType::const_iterator PI = find_if(P.begin(), P.end(),
400 vector<ValueList> &ValTab = CurMeth.CurrentMethod ?
401 CurMeth.Values : CurModule.Values;
402 ConstPoolVal *CPT = new ConstPoolType(Ty);
404 InsertValue(CPT, ValTab);
410 //===----------------------------------------------------------------------===//
411 // RunVMAsmParser - Define an interface to this parser
412 //===----------------------------------------------------------------------===//
414 Module *RunVMAsmParser(const ToolCommandLine &Opts, FILE *F) {
417 llvmAsmlineno = 1; // Reset the current line number...
419 CurModule.CurrentModule = new Module(); // Allocate a new module to read
420 yyparse(); // Parse the file.
421 Module *Result = ParserResult;
423 llvmAsmin = stdin; // F is about to go away, don't use it anymore...
430 #line 373 "llvmAsmParser.y"
434 MethodArgument *MethArgVal;
435 BasicBlock *BasicBlockVal;
436 TerminatorInst *TermInstVal;
437 Instruction *InstVal;
438 ConstPoolVal *ConstVal;
441 list<MethodArgument*> *MethodArgList;
442 list<Value*> *ValueList;
443 list<const Type*> *TypeList;
444 list<pair<Value*, BasicBlock*> > *PHIList; // Represent the RHS of PHI node
445 list<pair<ConstPoolVal*, BasicBlock*> > *JumpTable;
446 vector<ConstPoolVal*> *ConstVector;
453 char *StrVal; // This memory is allocated by strdup!
454 ValID ValIDVal; // May contain memory allocated by strdup
456 Instruction::UnaryOps UnaryOpVal;
457 Instruction::BinaryOps BinaryOpVal;
458 Instruction::TermOps TermOpVal;
459 Instruction::MemoryOps MemOpVal;
460 Instruction::OtherOps OtherOpVal;
473 #define YYFLAG -32768
476 #define YYTRANSLATE(x) ((unsigned)(x) <= 311 ? yytranslate[x] : 106)
478 static const char yytranslate[] = { 0,
479 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
480 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
481 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
482 2, 2, 2, 2, 2, 2, 2, 2, 2, 65,
483 66, 67, 2, 64, 2, 2, 2, 2, 2, 2,
484 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
485 58, 2, 2, 2, 2, 2, 2, 2, 2, 2,
486 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
487 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
488 59, 2, 60, 2, 2, 2, 2, 2, 2, 2,
489 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
490 2, 2, 2, 2, 2, 2, 2, 2, 2, 61,
491 2, 2, 62, 2, 63, 2, 2, 2, 2, 2,
492 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
493 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
494 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
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, 2,
499 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
500 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
501 2, 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 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
505 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
506 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
507 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
508 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
509 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
514 static const short yyprhs[] = { 0,
515 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
516 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
517 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
518 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
519 80, 82, 84, 86, 88, 91, 92, 95, 98, 101,
520 104, 107, 110, 117, 123, 132, 140, 147, 152, 156,
521 158, 162, 163, 165, 168, 171, 173, 174, 177, 181,
522 183, 185, 186, 192, 196, 199, 201, 203, 205, 207,
523 209, 211, 213, 215, 217, 222, 226, 230, 236, 240,
524 243, 246, 248, 252, 255, 258, 261, 265, 268, 269,
525 273, 276, 280, 290, 300, 307, 313, 316, 323, 331,
526 334, 339, 341, 342, 348, 352, 359, 365, 368, 375,
527 377, 380, 381, 384, 390, 393, 399, 403, 408, 416
530 static const short yyrhs[] = { 5,
531 0, 6, 0, 3, 0, 4, 0, 8, 0, 9,
532 0, 10, 0, 11, 0, 12, 0, 13, 0, 14,
533 0, 15, 0, 16, 0, 17, 0, 18, 0, 19,
534 0, 20, 0, 21, 0, 70, 0, 7, 0, 35,
535 0, 36, 0, 37, 0, 38, 0, 39, 0, 40,
536 0, 41, 0, 42, 0, 43, 0, 44, 0, 45,
537 0, 46, 0, 56, 0, 57, 0, 15, 0, 13,
538 0, 11, 0, 9, 0, 16, 0, 14, 0, 12,
539 0, 10, 0, 75, 0, 76, 0, 22, 58, 0,
540 0, 75, 69, 0, 76, 4, 0, 8, 26, 0,
541 8, 27, 0, 19, 24, 0, 20, 70, 0, 59,
542 70, 60, 59, 80, 60, 0, 59, 70, 60, 59,
543 60, 0, 59, 4, 61, 70, 60, 59, 80, 60,
544 0, 59, 4, 61, 70, 60, 59, 60, 0, 62,
545 93, 63, 62, 80, 63, 0, 62, 63, 62, 63,
546 0, 80, 64, 79, 0, 79, 0, 81, 78, 79,
547 0, 0, 83, 0, 83, 90, 0, 81, 25, 0,
548 22, 0, 0, 70, 84, 0, 85, 64, 86, 0,
549 85, 0, 86, 0, 0, 71, 24, 65, 87, 66,
550 0, 88, 81, 28, 0, 94, 29, 0, 3, 0,
551 4, 0, 26, 0, 27, 0, 24, 0, 68, 0,
552 22, 0, 91, 0, 92, 0, 71, 65, 93, 66,
553 0, 71, 65, 66, 0, 59, 70, 60, 0, 59,
554 4, 61, 70, 60, 0, 62, 93, 63, 0, 62,
555 63, 0, 70, 67, 0, 70, 0, 93, 64, 70,
556 0, 94, 95, 0, 89, 95, 0, 96, 97, 0,
557 23, 96, 97, 0, 96, 99, 0, 0, 32, 70,
558 92, 0, 32, 7, 0, 33, 21, 92, 0, 33,
559 8, 92, 64, 21, 92, 64, 21, 92, 0, 34,
560 77, 92, 64, 21, 92, 59, 98, 60, 0, 98,
561 77, 91, 64, 21, 92, 0, 77, 91, 64, 21,
562 92, 0, 78, 103, 0, 70, 59, 92, 64, 92,
563 60, 0, 100, 64, 59, 92, 64, 92, 60, 0,
564 70, 92, 0, 101, 64, 70, 92, 0, 101, 0,
565 0, 73, 70, 92, 64, 92, 0, 72, 70, 92,
566 0, 74, 70, 92, 64, 70, 92, 0, 55, 70,
567 92, 31, 70, 0, 53, 100, 0, 54, 70, 92,
568 65, 102, 66, 0, 105, 0, 64, 80, 0, 0,
569 47, 70, 0, 47, 70, 64, 14, 92, 0, 48,
570 70, 0, 48, 70, 64, 14, 92, 0, 49, 70,
571 92, 0, 50, 70, 92, 104, 0, 51, 70, 92,
572 64, 70, 92, 104, 0, 52, 70, 92, 104, 0
578 static const short yyrline[] = { 0,
579 470, 471, 478, 479, 490, 490, 490, 490, 490, 490,
580 490, 491, 491, 491, 491, 491, 491, 491, 494, 494,
581 499, 500, 500, 500, 500, 500, 501, 501, 501, 501,
582 501, 501, 502, 502, 506, 506, 506, 506, 507, 507,
583 507, 507, 508, 508, 510, 513, 517, 522, 527, 530,
584 533, 539, 542, 555, 559, 577, 584, 592, 606, 609,
585 615, 623, 634, 639, 644, 653, 653, 655, 663, 667,
586 672, 675, 679, 706, 710, 719, 722, 725, 728, 731,
587 736, 739, 742, 749, 757, 762, 766, 769, 772, 777,
588 780, 785, 789, 794, 798, 807, 812, 821, 825, 829,
589 832, 835, 838, 843, 854, 862, 872, 880, 885, 892,
590 896, 902, 902, 904, 909, 914, 918, 921, 932, 969,
591 974, 976, 980, 983, 990, 993, 1001, 1007, 1016, 1028
596 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
598 static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
599 "EUINT64VAL","SINTVAL","UINTVAL","VOID","BOOL","SBYTE","UBYTE","SHORT","USHORT",
600 "INT","UINT","LONG","ULONG","FLOAT","DOUBLE","STRING","TYPE","LABEL","VAR_ID",
601 "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","TRUE","FALSE","BEGINTOK","END",
602 "DECLARE","TO","RET","BR","SWITCH","NOT","ADD","SUB","MUL","DIV","REM","SETLE",
603 "SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE",
604 "GETELEMENTPTR","PHI","CALL","CAST","SHL","SHR","'='","'['","']'","'x'","'{'",
605 "'}'","','","'('","')'","'*'","INTVAL","EINT64VAL","Types","TypesV","UnaryOps",
606 "BinaryOps","ShiftOps","SIntType","UIntType","IntType","OptAssign","ConstVal",
607 "ConstVector","ConstPool","Module","MethodList","OptVAR_ID","ArgVal","ArgListH",
608 "ArgList","MethodHeaderH","MethodHeader","Method","ConstValueRef","ValueRef",
609 "TypeList","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
610 "JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","InstVal","UByteList",
615 static const short yyr1[] = { 0,
616 68, 68, 69, 69, 70, 70, 70, 70, 70, 70,
617 70, 70, 70, 70, 70, 70, 70, 70, 71, 71,
618 72, 73, 73, 73, 73, 73, 73, 73, 73, 73,
619 73, 73, 74, 74, 75, 75, 75, 75, 76, 76,
620 76, 76, 77, 77, 78, 78, 79, 79, 79, 79,
621 79, 79, 79, 79, 79, 79, 79, 79, 80, 80,
622 81, 81, 82, 83, 83, 84, 84, 85, 86, 86,
623 87, 87, 88, 89, 90, 91, 91, 91, 91, 91,
624 92, 92, 92, 70, 70, 70, 70, 70, 70, 70,
625 70, 93, 93, 94, 94, 95, 95, 96, 96, 97,
626 97, 97, 97, 97, 98, 98, 99, 100, 100, 101,
627 101, 102, 102, 103, 103, 103, 103, 103, 103, 103,
628 104, 104, 105, 105, 105, 105, 105, 105, 105, 105
631 static const short yyr2[] = { 0,
632 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
633 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
634 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
635 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
636 1, 1, 1, 1, 2, 0, 2, 2, 2, 2,
637 2, 2, 6, 5, 8, 7, 6, 4, 3, 1,
638 3, 0, 1, 2, 2, 1, 0, 2, 3, 1,
639 1, 0, 5, 3, 2, 1, 1, 1, 1, 1,
640 1, 1, 1, 1, 4, 3, 3, 5, 3, 2,
641 2, 1, 3, 2, 2, 2, 3, 2, 0, 3,
642 2, 3, 9, 9, 6, 5, 2, 6, 7, 2,
643 4, 1, 0, 5, 3, 6, 5, 2, 6, 1,
644 2, 0, 2, 5, 2, 5, 3, 4, 7, 4
647 static const short yydefact[] = { 62,
648 46, 63, 0, 65, 0, 76, 77, 1, 2, 20,
649 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
650 15, 16, 17, 18, 82, 80, 78, 79, 0, 0,
651 81, 19, 0, 62, 99, 64, 83, 84, 99, 45,
652 0, 38, 42, 37, 41, 36, 40, 35, 39, 0,
653 0, 0, 0, 0, 0, 61, 77, 19, 0, 90,
654 92, 0, 91, 0, 0, 46, 99, 95, 46, 75,
655 94, 49, 50, 51, 52, 77, 19, 0, 0, 3,
656 4, 47, 48, 0, 87, 89, 0, 72, 86, 0,
657 74, 46, 0, 0, 0, 0, 96, 98, 0, 0,
658 0, 0, 19, 93, 67, 70, 71, 0, 85, 97,
659 101, 19, 0, 0, 43, 44, 0, 21, 22, 23,
660 24, 25, 26, 27, 28, 29, 30, 31, 32, 0,
661 0, 0, 0, 0, 0, 0, 0, 0, 33, 34,
662 0, 0, 0, 107, 120, 19, 0, 58, 0, 88,
663 66, 68, 0, 73, 100, 0, 102, 0, 123, 125,
664 19, 19, 19, 19, 19, 118, 19, 19, 19, 19,
665 19, 0, 54, 60, 0, 0, 69, 0, 0, 0,
666 0, 127, 122, 0, 122, 0, 0, 0, 0, 115,
667 0, 0, 0, 53, 0, 57, 0, 0, 0, 0,
668 0, 128, 0, 130, 0, 0, 113, 0, 0, 0,
669 56, 0, 59, 0, 0, 124, 126, 121, 19, 0,
670 0, 19, 112, 0, 117, 114, 19, 55, 0, 0,
671 122, 0, 0, 110, 0, 119, 116, 0, 0, 0,
672 129, 108, 0, 19, 103, 0, 104, 0, 109, 111,
673 0, 0, 0, 0, 106, 0, 105, 0, 0, 0
676 static const short yydefgoto[] = { 31,
677 82, 61, 59, 141, 142, 143, 54, 55, 117, 5,
678 174, 175, 1, 258, 2, 152, 106, 107, 108, 34,
679 35, 36, 37, 38, 62, 39, 68, 69, 97, 240,
680 98, 166, 223, 224, 144, 202, 145
683 static const short yypact[] = {-32768,
684 70, 321, -6,-32768, 90,-32768,-32768,-32768,-32768,-32768,
685 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
686 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 381, 235,
687 -32768, 45, -20,-32768, 98,-32768,-32768,-32768, 93,-32768,
688 67,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 56,
689 321, 406, 296, 181, 142,-32768, 97, -14, 96,-32768,
690 46, 123,-32768, 101, 210, 122,-32768,-32768, 135,-32768,
691 -32768,-32768,-32768,-32768, 46, 111, 29, 112, 129,-32768,
692 -32768,-32768,-32768, 321,-32768,-32768, 321, 321,-32768, 79,
693 -32768, 135, 466, 13, 268, 461,-32768,-32768, 321, 118,
694 125, 119, 47, 46, 10, 126,-32768, 131,-32768,-32768,
695 133, 4, 52, 52,-32768,-32768, 52,-32768,-32768,-32768,
696 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 321,
697 321, 321, 321, 321, 321, 321, 321, 321,-32768,-32768,
698 321, 321, 321,-32768,-32768, 48, 3,-32768, 90,-32768,
699 -32768,-32768, 321,-32768,-32768, 138,-32768, 139, 106, 115,
700 4, 4, 4, 4, 0, 140, 4, 4, 4, 4,
701 4, 148,-32768,-32768, 99, 132,-32768, 178, 189, 197,
702 221,-32768, 194, 196, 194, 52, 204, 199, 234,-32768,
703 202, 203, 28,-32768, 90,-32768, 52, 52, 52, 52,
704 90,-32768, 321,-32768, 206, 52, 321, 321, 52, 321,
705 -32768, 100,-32768, 207, 209,-32768,-32768, 211, 4, 52,
706 222, 4, 223, 208, 46,-32768, 4,-32768, 252, 268,
707 194, 225, 52,-32768, 321,-32768,-32768, 52, 57, 435,
708 -32768,-32768, 228, 4,-32768, 226,-32768, 57,-32768,-32768,
709 270, 229, 52, 271,-32768, 52,-32768, 289, 295,-32768
712 static const short yypgoto[] = {-32768,
713 -32768, -2, 294,-32768,-32768,-32768, -93, -92, -205, -63,
714 -4, -129, 285,-32768,-32768,-32768,-32768, 168,-32768,-32768,
715 -32768,-32768, -215, -44, 1,-32768, 305, 279, 257,-32768,
716 -32768,-32768,-32768,-32768,-32768, -180,-32768
723 static const short yytable[] = { 32,
724 56, 115, 116, 64, 204, 96, 6, 7, 8, 9,
725 41, 42, 43, 44, 45, 46, 47, 48, 49, 176,
726 113, 50, 51, 246, 239, 25, 58, 26, 96, 27,
727 28, 151, 252, 114, 248, 41, 42, 43, 44, 45,
728 46, 47, 48, 49, 65, 85, 50, 51, 75, 77,
729 241, 40, 63, 79, 6, 7, 8, 9, 186, 6,
730 7, 52, 173, 212, 53, 90, 63, 155, 156, 157,
731 63, 218, 158, 25, -19, 26, 63, 27, 28, 74,
732 26, 103, 27, 28, 104, 105, 52, 211, 100, 53,
733 112, 3, 72, 73, 4, 63, 146, 41, 42, 43,
734 44, 45, 46, 47, 48, 49, 150, 172, 50, 51,
735 -19, 63, 63, 63, 63, 67, 182, 183, 184, 185,
736 67, 70, 188, 189, 190, 191, 192, 159, 160, 161,
737 162, 163, 164, 165, 167, 168, 115, 116, 169, 170,
738 171, 205, 87, 3, 109, 83, 115, 116, 52, 91,
739 105, 53, 214, 215, 216, 217, 3, 84, 194, 228,
740 65, 221, 195, 195, 226, 88, 93, 94, 95, 180,
741 -19, 99, 63, 101, 231, 232, 147, 234, 181, -19,
742 149, 63, 237, 80, 81, 86, 87, 148, 243, 153,
743 213, 102, 87, 245, 196, 195, 154, -20, 197, 250,
744 219, 178, 179, 187, 222, 225, 193, 227, 255, 198,
745 199, 257, 6, 7, 8, 9, 10, 11, 12, 13,
746 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
747 24, 25, 244, 26, 200, 27, 28, 6, 7, 8,
748 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
749 19, 20, 21, 22, 23, 24, 25, 201, 26, 203,
750 27, 28, 206, 207, 208, 209, 210, 230, 29, 220,
751 229, 30, 238, 236, 195, 89, 42, 43, 44, 45,
752 46, 47, 48, 49, 242, 233, 235, 249, 259, 251,
753 253, 256, 254, 29, 260, 33, 30, 60, 6, 7,
754 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
755 18, 19, 20, 21, 22, 23, 24, 25, 66, 26,
756 177, 27, 28, 6, 7, 8, 9, 10, 11, 12,
757 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
758 23, 24, 25, 71, 26, 92, 27, 28, 110, 0,
759 0, 0, 0, 0, 29, 0, 0, 30, 78, 0,
760 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
761 0, 0, 0, 0, 0, 0, 0, 0, 0, 29,
762 0, 0, 30, 6, 57, 8, 9, 10, 11, 12,
763 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
764 23, 24, 25, 0, 26, 0, 27, 28, 6, 76,
765 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
766 18, 19, 20, 21, 22, 23, 24, 25, 0, 26,
767 0, 27, 28, 0, 0, 0, 0, 0, 0, 29,
768 0, 0, 30, 42, 43, 44, 45, 46, 47, 48,
769 49, 0, 0, 0, 0, 0, 0, 0, 0, 0,
770 0, 0, 0, 0, 29, 0, 0, 30, 6, 7,
771 8, 9, 111, 11, 12, 13, 14, 15, 16, 17,
772 18, 19, 20, 21, 22, 23, 24, 25, 0, 26,
773 0, 27, 28, 0, 247, 118, 119, 120, 121, 122,
774 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
775 133, 134, 135, 136, 137, 138, 139, 140, 0, 0,
776 0, 0, 0, 0, 29, 0, 0, 30
779 static const short yycheck[] = { 2,
780 5, 95, 95, 24, 185, 69, 3, 4, 5, 6,
781 8, 9, 10, 11, 12, 13, 14, 15, 16, 149,
782 8, 19, 20, 239, 230, 22, 29, 24, 92, 26,
783 27, 22, 248, 21, 240, 8, 9, 10, 11, 12,
784 13, 14, 15, 16, 65, 60, 19, 20, 51, 52,
785 231, 58, 67, 53, 3, 4, 5, 6, 59, 3,
786 4, 59, 60, 193, 62, 65, 67, 112, 113, 114,
787 67, 201, 117, 22, 65, 24, 67, 26, 27, 24,
788 24, 84, 26, 27, 87, 88, 59, 60, 60, 62,
789 93, 22, 26, 27, 25, 67, 99, 8, 9, 10,
790 11, 12, 13, 14, 15, 16, 60, 60, 19, 20,
791 65, 67, 67, 67, 67, 23, 161, 162, 163, 164,
792 23, 29, 167, 168, 169, 170, 171, 130, 131, 132,
793 133, 134, 135, 136, 137, 138, 230, 230, 141, 142,
794 143, 186, 64, 22, 66, 4, 240, 240, 59, 28,
795 153, 62, 197, 198, 199, 200, 22, 61, 60, 60,
796 65, 206, 64, 64, 209, 65, 32, 33, 34, 64,
797 65, 61, 67, 62, 219, 220, 59, 222, 64, 65,
798 62, 67, 227, 3, 4, 63, 64, 63, 233, 64,
799 195, 63, 64, 238, 63, 64, 66, 65, 21, 244,
800 203, 64, 64, 64, 207, 208, 59, 210, 253, 21,
801 14, 256, 3, 4, 5, 6, 7, 8, 9, 10,
802 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
803 21, 22, 235, 24, 14, 26, 27, 3, 4, 5,
804 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
805 16, 17, 18, 19, 20, 21, 22, 64, 24, 64,
806 26, 27, 59, 65, 31, 64, 64, 59, 59, 64,
807 64, 62, 21, 66, 64, 66, 9, 10, 11, 12,
808 13, 14, 15, 16, 60, 64, 64, 60, 0, 64,
809 21, 21, 64, 59, 0, 2, 62, 63, 3, 4,
810 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
811 15, 16, 17, 18, 19, 20, 21, 22, 34, 24,
812 153, 26, 27, 3, 4, 5, 6, 7, 8, 9,
813 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
814 20, 21, 22, 39, 24, 67, 26, 27, 92, -1,
815 -1, -1, -1, -1, 59, -1, -1, 62, 63, -1,
816 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
817 -1, -1, -1, -1, -1, -1, -1, -1, -1, 59,
818 -1, -1, 62, 3, 4, 5, 6, 7, 8, 9,
819 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
820 20, 21, 22, -1, 24, -1, 26, 27, 3, 4,
821 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
822 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
823 -1, 26, 27, -1, -1, -1, -1, -1, -1, 59,
824 -1, -1, 62, 9, 10, 11, 12, 13, 14, 15,
825 16, -1, -1, -1, -1, -1, -1, -1, -1, -1,
826 -1, -1, -1, -1, 59, -1, -1, 62, 3, 4,
827 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
828 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
829 -1, 26, 27, -1, 60, 35, 36, 37, 38, 39,
830 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
831 50, 51, 52, 53, 54, 55, 56, 57, -1, -1,
832 -1, -1, -1, -1, 59, -1, -1, 62
834 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
835 #line 3 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
836 /* This file comes from bison-1.28. */
838 /* Skeleton output parser for bison,
839 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
841 This program is free software; you can redistribute it and/or modify
842 it under the terms of the GNU General Public License as published by
843 the Free Software Foundation; either version 2, or (at your option)
846 This program is distributed in the hope that it will be useful,
847 but WITHOUT ANY WARRANTY; without even the implied warranty of
848 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
849 GNU General Public License for more details.
851 You should have received a copy of the GNU General Public License
852 along with this program; if not, write to the Free Software
853 Foundation, Inc., 59 Temple Place - Suite 330,
854 Boston, MA 02111-1307, USA. */
856 /* As a special exception, when this file is copied by Bison into a
857 Bison output file, you may use that output file without restriction.
858 This special exception was added by the Free Software Foundation
859 in version 1.24 of Bison. */
861 /* This is the parser code that is written into each bison parser
862 when the %semantic_parser declaration is not specified in the grammar.
863 It was written by Richard Stallman by simplifying the hairy parser
864 used when %semantic_parser is specified. */
866 #ifndef YYSTACK_USE_ALLOCA
868 #define YYSTACK_USE_ALLOCA
869 #else /* alloca not defined */
871 #define YYSTACK_USE_ALLOCA
872 #define alloca __builtin_alloca
873 #else /* not GNU C. */
874 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
875 #define YYSTACK_USE_ALLOCA
877 #else /* not sparc */
878 /* We think this test detects Watcom and Microsoft C. */
879 /* This used to test MSDOS, but that is a bad idea
880 since that symbol is in the user namespace. */
881 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
882 #if 0 /* No need for malloc.h, which pollutes the namespace;
883 instead, just don't use alloca. */
886 #else /* not MSDOS, or __TURBOC__ */
888 /* I don't know what this was needed for, but it pollutes the namespace.
889 So I turned it off. rms, 2 May 1997. */
890 /* #include <malloc.h> */
892 #define YYSTACK_USE_ALLOCA
893 #else /* not MSDOS, or __TURBOC__, or _AIX */
895 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
896 and on HPUX 10. Eventually we can turn this on. */
897 #define YYSTACK_USE_ALLOCA
898 #define alloca __builtin_alloca
901 #endif /* not _AIX */
902 #endif /* not MSDOS, or __TURBOC__ */
903 #endif /* not sparc */
904 #endif /* not GNU C */
905 #endif /* alloca not defined */
906 #endif /* YYSTACK_USE_ALLOCA not defined */
908 #ifdef YYSTACK_USE_ALLOCA
909 #define YYSTACK_ALLOC alloca
911 #define YYSTACK_ALLOC malloc
914 /* Note: there must be only one dollar sign in this file.
915 It is replaced by the list of actions, each action
916 as one case of the switch. */
918 #define yyerrok (yyerrstatus = 0)
919 #define yyclearin (yychar = YYEMPTY)
922 #define YYACCEPT goto yyacceptlab
923 #define YYABORT goto yyabortlab
924 #define YYERROR goto yyerrlab1
925 /* Like YYERROR except do call yyerror.
926 This remains here temporarily to ease the
927 transition to the new meaning of YYERROR, for GCC.
928 Once GCC version 2 has supplanted version 1, this can go. */
929 #define YYFAIL goto yyerrlab
930 #define YYRECOVERING() (!!yyerrstatus)
931 #define YYBACKUP(token, value) \
933 if (yychar == YYEMPTY && yylen == 1) \
934 { yychar = (token), yylval = (value); \
935 yychar1 = YYTRANSLATE (yychar); \
940 { yyerror ("syntax error: cannot back up"); YYERROR; } \
944 #define YYERRCODE 256
947 #define YYLEX yylex()
953 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
955 #define YYLEX yylex(&yylval, &yylloc)
957 #else /* not YYLSP_NEEDED */
959 #define YYLEX yylex(&yylval, YYLEX_PARAM)
961 #define YYLEX yylex(&yylval)
963 #endif /* not YYLSP_NEEDED */
966 /* If nonreentrant, generate the variables here */
970 int yychar; /* the lookahead symbol */
971 YYSTYPE yylval; /* the semantic value of the */
972 /* lookahead symbol */
975 YYLTYPE yylloc; /* location data for the lookahead */
979 int yynerrs; /* number of parse errors so far */
980 #endif /* not YYPURE */
983 int yydebug; /* nonzero means print parse trace */
984 /* Since this is uninitialized, it does not stop multiple parsers
988 /* YYINITDEPTH indicates the initial size of the parser's stacks */
991 #define YYINITDEPTH 200
994 /* YYMAXDEPTH is the maximum size the stacks can grow to
995 (effective only if the built-in stack extension method is used). */
1002 #define YYMAXDEPTH 10000
1005 /* Define __yy_memcpy. Note that the size argument
1006 should be passed with type unsigned int, because that is what the non-GCC
1007 definitions require. With GCC, __builtin_memcpy takes an arg
1008 of type size_t, but it can handle unsigned int. */
1010 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1011 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1012 #else /* not GNU C or C++ */
1015 /* This is the most reliable way to avoid incompatibilities
1016 in available built-in functions on various systems. */
1018 __yy_memcpy (to, from, count)
1023 register char *f = from;
1024 register char *t = to;
1025 register int i = count;
1031 #else /* __cplusplus */
1033 /* This is the most reliable way to avoid incompatibilities
1034 in available built-in functions on various systems. */
1036 __yy_memcpy (char *to, char *from, unsigned int count)
1038 register char *t = to;
1039 register char *f = from;
1040 register int i = count;
1049 #line 217 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
1051 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
1052 into yyparse. The argument should have type void *.
1053 It should actually point to an object.
1054 Grammar actions can access the variable by casting it
1055 to the proper pointer type. */
1057 #ifdef YYPARSE_PARAM
1059 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1060 #define YYPARSE_PARAM_DECL
1061 #else /* not __cplusplus */
1062 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1063 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1064 #endif /* not __cplusplus */
1065 #else /* not YYPARSE_PARAM */
1066 #define YYPARSE_PARAM_ARG
1067 #define YYPARSE_PARAM_DECL
1068 #endif /* not YYPARSE_PARAM */
1070 /* Prevent warning if -Wstrict-prototypes. */
1072 #ifdef YYPARSE_PARAM
1073 int yyparse (void *);
1080 yyparse(YYPARSE_PARAM_ARG)
1083 register int yystate;
1085 register short *yyssp;
1086 register YYSTYPE *yyvsp;
1087 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1088 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
1090 short yyssa[YYINITDEPTH]; /* the state stack */
1091 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
1093 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1094 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
1097 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1098 YYLTYPE *yyls = yylsa;
1101 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1103 #define YYPOPSTACK (yyvsp--, yyssp--)
1106 int yystacksize = YYINITDEPTH;
1107 int yyfree_stacks = 0;
1118 YYSTYPE yyval; /* the variable used to return */
1119 /* semantic values from the action */
1126 fprintf(stderr, "Starting parse\n");
1132 yychar = YYEMPTY; /* Cause a token to be read. */
1134 /* Initialize stack pointers.
1135 Waste one element of value and location stack
1136 so that they stay on the same level as the state stack.
1137 The wasted elements are never initialized. */
1145 /* Push a new state, which is found in yystate . */
1146 /* In all cases, when you get here, the value and location stacks
1147 have just been pushed. so pushing a state here evens the stacks. */
1152 if (yyssp >= yyss + yystacksize - 1)
1154 /* Give user a chance to reallocate the stack */
1155 /* Use copies of these so that the &'s don't force the real ones into memory. */
1156 YYSTYPE *yyvs1 = yyvs;
1157 short *yyss1 = yyss;
1159 YYLTYPE *yyls1 = yyls;
1162 /* Get the current used size of the three stacks, in elements. */
1163 int size = yyssp - yyss + 1;
1166 /* Each stack pointer address is followed by the size of
1167 the data in use in that stack, in bytes. */
1169 /* This used to be a conditional around just the two extra args,
1170 but that might be undefined if yyoverflow is a macro. */
1171 yyoverflow("parser stack overflow",
1172 &yyss1, size * sizeof (*yyssp),
1173 &yyvs1, size * sizeof (*yyvsp),
1174 &yyls1, size * sizeof (*yylsp),
1177 yyoverflow("parser stack overflow",
1178 &yyss1, size * sizeof (*yyssp),
1179 &yyvs1, size * sizeof (*yyvsp),
1183 yyss = yyss1; yyvs = yyvs1;
1187 #else /* no yyoverflow */
1188 /* Extend the stack our own way. */
1189 if (yystacksize >= YYMAXDEPTH)
1191 yyerror("parser stack overflow");
1203 if (yystacksize > YYMAXDEPTH)
1204 yystacksize = YYMAXDEPTH;
1205 #ifndef YYSTACK_USE_ALLOCA
1208 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
1209 __yy_memcpy ((char *)yyss, (char *)yyss1,
1210 size * (unsigned int) sizeof (*yyssp));
1211 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
1212 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
1213 size * (unsigned int) sizeof (*yyvsp));
1215 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
1216 __yy_memcpy ((char *)yyls, (char *)yyls1,
1217 size * (unsigned int) sizeof (*yylsp));
1219 #endif /* no yyoverflow */
1221 yyssp = yyss + size - 1;
1222 yyvsp = yyvs + size - 1;
1224 yylsp = yyls + size - 1;
1229 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
1232 if (yyssp >= yyss + yystacksize - 1)
1238 fprintf(stderr, "Entering state %d\n", yystate);
1244 /* Do appropriate processing given the current state. */
1245 /* Read a lookahead token if we need one and don't already have one. */
1248 /* First try to decide what to do without reference to lookahead token. */
1250 yyn = yypact[yystate];
1254 /* Not known => get a lookahead token if don't already have one. */
1256 /* yychar is either YYEMPTY or YYEOF
1257 or a valid token in external form. */
1259 if (yychar == YYEMPTY)
1263 fprintf(stderr, "Reading a token: ");
1268 /* Convert token to internal form (in yychar1) for indexing tables with */
1270 if (yychar <= 0) /* This means end of input. */
1273 yychar = YYEOF; /* Don't call YYLEX any more */
1277 fprintf(stderr, "Now at end of input.\n");
1282 yychar1 = YYTRANSLATE(yychar);
1287 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
1288 /* Give the individual parser a way to print the precise meaning
1289 of a token, for further debugging info. */
1291 YYPRINT (stderr, yychar, yylval);
1293 fprintf (stderr, ")\n");
1299 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
1304 /* yyn is what to do for this token type in this state.
1305 Negative => reduce, -yyn is rule number.
1306 Positive => shift, yyn is new state.
1307 New state is final state => don't bother to shift,
1308 just return success.
1309 0, or most negative number => error. */
1324 /* Shift the lookahead token. */
1328 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1331 /* Discard the token being shifted unless it is eof. */
1332 if (yychar != YYEOF)
1340 /* count tokens shifted since error; after three, turn off error status. */
1341 if (yyerrstatus) yyerrstatus--;
1346 /* Do the default action for the current state. */
1349 yyn = yydefact[yystate];
1353 /* Do a reduction. yyn is the number of a rule to reduce with. */
1357 yyval = yyvsp[1-yylen]; /* implement default value of the action */
1364 fprintf (stderr, "Reducing via rule %d (line %d), ",
1367 /* Print the symbols being reduced, and their result. */
1368 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1369 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1370 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1378 #line 471 "llvmAsmParser.y"
1380 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
1381 ThrowException("Value too large for type!");
1382 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
1386 #line 479 "llvmAsmParser.y"
1388 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
1389 ThrowException("Value too large for type!");
1390 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
1394 #line 510 "llvmAsmParser.y"
1396 yyval.StrVal = yyvsp[-1].StrVal;
1400 #line 513 "llvmAsmParser.y"
1406 #line 517 "llvmAsmParser.y"
1407 { // integral constants
1408 if (!ConstPoolSInt::isValueValidForType(yyvsp[-1].TypeVal, yyvsp[0].SInt64Val))
1409 ThrowException("Constant value doesn't fit in type!");
1410 yyval.ConstVal = new ConstPoolSInt(yyvsp[-1].TypeVal, yyvsp[0].SInt64Val);
1414 #line 522 "llvmAsmParser.y"
1415 { // integral constants
1416 if (!ConstPoolUInt::isValueValidForType(yyvsp[-1].TypeVal, yyvsp[0].UInt64Val))
1417 ThrowException("Constant value doesn't fit in type!");
1418 yyval.ConstVal = new ConstPoolUInt(yyvsp[-1].TypeVal, yyvsp[0].UInt64Val);
1422 #line 527 "llvmAsmParser.y"
1423 { // Boolean constants
1424 yyval.ConstVal = new ConstPoolBool(true);
1428 #line 530 "llvmAsmParser.y"
1429 { // Boolean constants
1430 yyval.ConstVal = new ConstPoolBool(false);
1434 #line 533 "llvmAsmParser.y"
1435 { // String constants
1436 cerr << "FIXME: TODO: String constants [sbyte] not implemented yet!\n";
1438 //$$ = new ConstPoolString($2);
1439 free(yyvsp[0].StrVal);
1443 #line 539 "llvmAsmParser.y"
1445 yyval.ConstVal = new ConstPoolType(yyvsp[0].TypeVal);
1449 #line 542 "llvmAsmParser.y"
1450 { // Nonempty array constant
1451 // Verify all elements are correct type!
1452 const ArrayType *AT = ArrayType::getArrayType(yyvsp[-4].TypeVal);
1453 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
1454 if (yyvsp[-4].TypeVal != (*yyvsp[-1].ConstVector)[i]->getType())
1455 ThrowException("Element #" + utostr(i) + " is not of type '" +
1456 yyvsp[-4].TypeVal->getName() + "' as required!\nIt is of type '" +
1457 (*yyvsp[-1].ConstVector)[i]->getType()->getName() + "'.");
1460 yyval.ConstVal = new ConstPoolArray(AT, *yyvsp[-1].ConstVector);
1461 delete yyvsp[-1].ConstVector;
1465 #line 555 "llvmAsmParser.y"
1466 { // Empty array constant
1467 vector<ConstPoolVal*> Empty;
1468 yyval.ConstVal = new ConstPoolArray(ArrayType::getArrayType(yyvsp[-3].TypeVal), Empty);
1472 #line 559 "llvmAsmParser.y"
1474 // Verify all elements are correct type!
1475 const ArrayType *AT = ArrayType::getArrayType(yyvsp[-4].TypeVal, (int)yyvsp[-6].UInt64Val);
1476 if (yyvsp[-6].UInt64Val != yyvsp[-1].ConstVector->size())
1477 ThrowException("Type mismatch: constant sized array initialized with " +
1478 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
1479 itostr((int)yyvsp[-6].UInt64Val) + "!");
1481 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
1482 if (yyvsp[-4].TypeVal != (*yyvsp[-1].ConstVector)[i]->getType())
1483 ThrowException("Element #" + utostr(i) + " is not of type '" +
1484 yyvsp[-4].TypeVal->getName() + "' as required!\nIt is of type '" +
1485 (*yyvsp[-1].ConstVector)[i]->getType()->getName() + "'.");
1488 yyval.ConstVal = new ConstPoolArray(AT, *yyvsp[-1].ConstVector);
1489 delete yyvsp[-1].ConstVector;
1493 #line 577 "llvmAsmParser.y"
1495 if (yyvsp[-5].UInt64Val != 0)
1496 ThrowException("Type mismatch: constant sized array initialized with 0"
1497 " arguments, but has size of " + itostr((int)yyvsp[-5].UInt64Val) + "!");
1498 vector<ConstPoolVal*> Empty;
1499 yyval.ConstVal = new ConstPoolArray(ArrayType::getArrayType(yyvsp[-3].TypeVal, 0), Empty);
1503 #line 584 "llvmAsmParser.y"
1505 StructType::ElementTypes Types(yyvsp[-4].TypeList->begin(), yyvsp[-4].TypeList->end());
1506 delete yyvsp[-4].TypeList;
1508 const StructType *St = StructType::getStructType(Types);
1509 yyval.ConstVal = new ConstPoolStruct(St, *yyvsp[-1].ConstVector);
1510 delete yyvsp[-1].ConstVector;
1514 #line 592 "llvmAsmParser.y"
1516 const StructType *St =
1517 StructType::getStructType(StructType::ElementTypes());
1518 vector<ConstPoolVal*> Empty;
1519 yyval.ConstVal = new ConstPoolStruct(St, Empty);
1523 #line 606 "llvmAsmParser.y"
1525 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(addConstValToConstantPool(yyvsp[0].ConstVal));
1529 #line 609 "llvmAsmParser.y"
1531 yyval.ConstVector = new vector<ConstPoolVal*>();
1532 yyval.ConstVector->push_back(addConstValToConstantPool(yyvsp[0].ConstVal));
1536 #line 615 "llvmAsmParser.y"
1538 if (yyvsp[-1].StrVal) {
1539 yyvsp[0].ConstVal->setName(yyvsp[-1].StrVal);
1540 free(yyvsp[-1].StrVal);
1543 addConstValToConstantPool(yyvsp[0].ConstVal);
1547 #line 623 "llvmAsmParser.y"
1552 #line 634 "llvmAsmParser.y"
1554 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
1555 CurModule.ModuleDone();
1559 #line 639 "llvmAsmParser.y"
1561 yyvsp[-1].ModuleVal->getMethodList().push_back(yyvsp[0].MethodVal);
1562 CurMeth.MethodDone();
1563 yyval.ModuleVal = yyvsp[-1].ModuleVal;
1567 #line 644 "llvmAsmParser.y"
1569 yyval.ModuleVal = CurModule.CurrentModule;
1573 #line 653 "llvmAsmParser.y"
1574 { yyval.StrVal = 0; ;
1577 #line 655 "llvmAsmParser.y"
1579 yyval.MethArgVal = new MethodArgument(yyvsp[-1].TypeVal);
1580 if (yyvsp[0].StrVal) { // Was the argument named?
1581 yyval.MethArgVal->setName(yyvsp[0].StrVal);
1582 free(yyvsp[0].StrVal); // The string was strdup'd, so free it now.
1587 #line 663 "llvmAsmParser.y"
1589 yyval.MethodArgList = yyvsp[0].MethodArgList;
1590 yyvsp[0].MethodArgList->push_front(yyvsp[-2].MethArgVal);
1594 #line 667 "llvmAsmParser.y"
1596 yyval.MethodArgList = new list<MethodArgument*>();
1597 yyval.MethodArgList->push_front(yyvsp[0].MethArgVal);
1601 #line 672 "llvmAsmParser.y"
1603 yyval.MethodArgList = yyvsp[0].MethodArgList;
1607 #line 675 "llvmAsmParser.y"
1609 yyval.MethodArgList = 0;
1613 #line 679 "llvmAsmParser.y"
1615 MethodType::ParamTypes ParamTypeList;
1616 if (yyvsp[-1].MethodArgList)
1617 for (list<MethodArgument*>::iterator I = yyvsp[-1].MethodArgList->begin(); I != yyvsp[-1].MethodArgList->end(); ++I)
1618 ParamTypeList.push_back((*I)->getType());
1620 const MethodType *MT = MethodType::getMethodType(yyvsp[-4].TypeVal, ParamTypeList);
1622 Method *M = new Method(MT, yyvsp[-3].StrVal);
1623 free(yyvsp[-3].StrVal); // Free strdup'd memory!
1625 InsertValue(M, CurModule.Values);
1627 CurMeth.MethodStart(M);
1629 // Add all of the arguments we parsed to the method...
1630 if (yyvsp[-1].MethodArgList) { // Is null if empty...
1631 Method::ArgumentListType &ArgList = M->getArgumentList();
1633 for (list<MethodArgument*>::iterator I = yyvsp[-1].MethodArgList->begin(); I != yyvsp[-1].MethodArgList->end(); ++I) {
1635 ArgList.push_back(*I);
1637 delete yyvsp[-1].MethodArgList; // We're now done with the argument list
1642 #line 706 "llvmAsmParser.y"
1644 yyval.MethodVal = CurMeth.CurrentMethod;
1648 #line 710 "llvmAsmParser.y"
1650 yyval.MethodVal = yyvsp[-1].MethodVal;
1654 #line 719 "llvmAsmParser.y"
1655 { // A reference to a direct constant
1656 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
1660 #line 722 "llvmAsmParser.y"
1662 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
1666 #line 725 "llvmAsmParser.y"
1668 yyval.ValIDVal = ValID::create((int64_t)1);
1672 #line 728 "llvmAsmParser.y"
1674 yyval.ValIDVal = ValID::create((int64_t)0);
1678 #line 731 "llvmAsmParser.y"
1679 { // Quoted strings work too... especially for methods
1680 yyval.ValIDVal = ValID::create_conststr(yyvsp[0].StrVal);
1684 #line 736 "llvmAsmParser.y"
1685 { // Is it an integer reference...?
1686 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
1690 #line 739 "llvmAsmParser.y"
1691 { // It must be a named reference then...
1692 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
1696 #line 742 "llvmAsmParser.y"
1698 yyval.ValIDVal = yyvsp[0].ValIDVal;
1702 #line 749 "llvmAsmParser.y"
1704 Value *D = getVal(Type::TypeTy, yyvsp[0].ValIDVal, true);
1705 if (D == 0) ThrowException("Invalid user defined type: " + yyvsp[0].ValIDVal.getName());
1707 // User defined type not in const pool!
1708 ConstPoolType *CPT = (ConstPoolType*)D->castConstantAsserting();
1709 yyval.TypeVal = CPT->getValue();
1713 #line 757 "llvmAsmParser.y"
1714 { // Method derived type?
1715 MethodType::ParamTypes Params(yyvsp[-1].TypeList->begin(), yyvsp[-1].TypeList->end());
1716 delete yyvsp[-1].TypeList;
1717 yyval.TypeVal = checkNewType(MethodType::getMethodType(yyvsp[-3].TypeVal, Params));
1721 #line 762 "llvmAsmParser.y"
1722 { // Method derived type?
1723 MethodType::ParamTypes Params; // Empty list
1724 yyval.TypeVal = checkNewType(MethodType::getMethodType(yyvsp[-2].TypeVal, Params));
1728 #line 766 "llvmAsmParser.y"
1730 yyval.TypeVal = checkNewType(ArrayType::getArrayType(yyvsp[-1].TypeVal));
1734 #line 769 "llvmAsmParser.y"
1736 yyval.TypeVal = checkNewType(ArrayType::getArrayType(yyvsp[-1].TypeVal, (int)yyvsp[-3].UInt64Val));
1740 #line 772 "llvmAsmParser.y"
1742 StructType::ElementTypes Elements(yyvsp[-1].TypeList->begin(), yyvsp[-1].TypeList->end());
1743 delete yyvsp[-1].TypeList;
1744 yyval.TypeVal = checkNewType(StructType::getStructType(Elements));
1748 #line 777 "llvmAsmParser.y"
1750 yyval.TypeVal = checkNewType(StructType::getStructType(StructType::ElementTypes()));
1754 #line 780 "llvmAsmParser.y"
1756 yyval.TypeVal = checkNewType(PointerType::getPointerType(yyvsp[-1].TypeVal));
1760 #line 785 "llvmAsmParser.y"
1762 yyval.TypeList = new list<const Type*>();
1763 yyval.TypeList->push_back(yyvsp[0].TypeVal);
1767 #line 789 "llvmAsmParser.y"
1769 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(yyvsp[0].TypeVal);
1773 #line 794 "llvmAsmParser.y"
1775 yyvsp[-1].MethodVal->getBasicBlocks().push_back(yyvsp[0].BasicBlockVal);
1776 yyval.MethodVal = yyvsp[-1].MethodVal;
1780 #line 798 "llvmAsmParser.y"
1781 { // Do not allow methods with 0 basic blocks
1782 yyval.MethodVal = yyvsp[-1].MethodVal; // in them...
1783 yyvsp[-1].MethodVal->getBasicBlocks().push_back(yyvsp[0].BasicBlockVal);
1787 #line 807 "llvmAsmParser.y"
1789 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
1790 InsertValue(yyvsp[-1].BasicBlockVal);
1791 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1795 #line 812 "llvmAsmParser.y"
1797 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
1798 yyvsp[-1].BasicBlockVal->setName(yyvsp[-2].StrVal);
1799 free(yyvsp[-2].StrVal); // Free the strdup'd memory...
1801 InsertValue(yyvsp[-1].BasicBlockVal);
1802 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1806 #line 821 "llvmAsmParser.y"
1808 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
1809 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1813 #line 825 "llvmAsmParser.y"
1815 yyval.BasicBlockVal = new BasicBlock();
1819 #line 829 "llvmAsmParser.y"
1820 { // Return with a result...
1821 yyval.TermInstVal = new ReturnInst(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1825 #line 832 "llvmAsmParser.y"
1826 { // Return with no result...
1827 yyval.TermInstVal = new ReturnInst();
1831 #line 835 "llvmAsmParser.y"
1832 { // Unconditional Branch...
1833 yyval.TermInstVal = new BranchInst((BasicBlock*)getVal(Type::LabelTy, yyvsp[0].ValIDVal));
1837 #line 838 "llvmAsmParser.y"
1839 yyval.TermInstVal = new BranchInst((BasicBlock*)getVal(Type::LabelTy, yyvsp[-3].ValIDVal),
1840 (BasicBlock*)getVal(Type::LabelTy, yyvsp[0].ValIDVal),
1841 getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
1845 #line 843 "llvmAsmParser.y"
1847 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].TypeVal, yyvsp[-6].ValIDVal),
1848 (BasicBlock*)getVal(Type::LabelTy, yyvsp[-3].ValIDVal));
1849 yyval.TermInstVal = S;
1851 list<pair<ConstPoolVal*, BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
1852 end = yyvsp[-1].JumpTable->end();
1853 for (; I != end; ++I)
1854 S->dest_push_back(I->first, I->second);
1858 #line 854 "llvmAsmParser.y"
1860 yyval.JumpTable = yyvsp[-5].JumpTable;
1861 ConstPoolVal *V = (ConstPoolVal*)getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal, true);
1863 ThrowException("May only switch on a constant pool value!");
1865 yyval.JumpTable->push_back(make_pair(V, (BasicBlock*)getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal)));
1869 #line 862 "llvmAsmParser.y"
1871 yyval.JumpTable = new list<pair<ConstPoolVal*, BasicBlock*> >();
1872 ConstPoolVal *V = (ConstPoolVal*)getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal, true);
1875 ThrowException("May only switch on a constant pool value!");
1877 yyval.JumpTable->push_back(make_pair(V, (BasicBlock*)getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal)));
1881 #line 872 "llvmAsmParser.y"
1883 if (yyvsp[-1].StrVal) // Is this definition named??
1884 yyvsp[0].InstVal->setName(yyvsp[-1].StrVal); // if so, assign the name...
1886 InsertValue(yyvsp[0].InstVal);
1887 yyval.InstVal = yyvsp[0].InstVal;
1891 #line 880 "llvmAsmParser.y"
1892 { // Used for PHI nodes
1893 yyval.PHIList = new list<pair<Value*, BasicBlock*> >();
1894 yyval.PHIList->push_back(make_pair(getVal(yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal),
1895 (BasicBlock*)getVal(Type::LabelTy, yyvsp[-1].ValIDVal)));
1899 #line 885 "llvmAsmParser.y"
1901 yyval.PHIList = yyvsp[-6].PHIList;
1902 yyvsp[-6].PHIList->push_back(make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
1903 (BasicBlock*)getVal(Type::LabelTy, yyvsp[-1].ValIDVal)));
1907 #line 892 "llvmAsmParser.y"
1908 { // Used for call statements...
1909 yyval.ValueList = new list<Value*>();
1910 yyval.ValueList->push_back(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1914 #line 896 "llvmAsmParser.y"
1916 yyval.ValueList = yyvsp[-3].ValueList;
1917 yyvsp[-3].ValueList->push_back(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1921 #line 902 "llvmAsmParser.y"
1922 { yyval.ValueList = 0; ;
1925 #line 904 "llvmAsmParser.y"
1927 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
1928 if (yyval.InstVal == 0)
1929 ThrowException("binary operator returned null!");
1933 #line 909 "llvmAsmParser.y"
1935 yyval.InstVal = UnaryOperator::create(yyvsp[-2].UnaryOpVal, getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1936 if (yyval.InstVal == 0)
1937 ThrowException("unary operator returned null!");
1941 #line 914 "llvmAsmParser.y"
1943 if (yyvsp[-1].TypeVal != Type::UByteTy) ThrowException("Shift amount must be ubyte!");
1944 yyval.InstVal = new ShiftInst(yyvsp[-5].OtherOpVal, getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal), getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1948 #line 918 "llvmAsmParser.y"
1950 yyval.InstVal = new CastInst(getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), yyvsp[0].TypeVal);
1954 #line 921 "llvmAsmParser.y"
1956 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
1957 yyval.InstVal = new PHINode(Ty);
1958 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
1959 if (yyvsp[0].PHIList->front().first->getType() != Ty)
1960 ThrowException("All elements of a PHI node must be of the same type!");
1961 ((PHINode*)yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
1962 yyvsp[0].PHIList->pop_front();
1964 delete yyvsp[0].PHIList; // Free the list...
1968 #line 932 "llvmAsmParser.y"
1970 if (!yyvsp[-4].TypeVal->isMethodType())
1971 ThrowException("Can only call methods: invalid type '" +
1972 yyvsp[-4].TypeVal->getName() + "'!");
1974 const MethodType *Ty = (const MethodType*)yyvsp[-4].TypeVal;
1976 Value *V = getVal(Ty, yyvsp[-3].ValIDVal);
1977 if (!V->isMethod() || V->getType() != Ty)
1978 ThrowException("Cannot call: " + yyvsp[-3].ValIDVal.getName() + "!");
1980 // Create or access a new type that corresponds to the function call...
1981 vector<Value *> Params;
1983 if (yyvsp[-1].ValueList) {
1984 // Pull out just the arguments...
1985 Params.insert(Params.begin(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
1986 delete yyvsp[-1].ValueList;
1988 // Loop through MethodType's arguments and ensure they are specified
1991 MethodType::ParamTypes::const_iterator I = Ty->getParamTypes().begin();
1993 for (i = 0; i < Params.size() && I != Ty->getParamTypes().end(); ++i,++I){
1994 if (Params[i]->getType() != *I)
1995 ThrowException("Parameter " + utostr(i) + " is not of type '" +
1996 (*I)->getName() + "'!");
1999 if (i != Params.size() || I != Ty->getParamTypes().end())
2000 ThrowException("Invalid number of parameters detected!");
2003 // Create the call node...
2004 yyval.InstVal = new CallInst((Method*)V, Params);
2008 #line 969 "llvmAsmParser.y"
2010 yyval.InstVal = yyvsp[0].InstVal;
2014 #line 974 "llvmAsmParser.y"
2016 yyval.ConstVector = yyvsp[0].ConstVector;
2020 #line 976 "llvmAsmParser.y"
2022 yyval.ConstVector = new vector<ConstPoolVal*>();
2026 #line 980 "llvmAsmParser.y"
2028 yyval.InstVal = new MallocInst(checkNewType(PointerType::getPointerType(yyvsp[0].TypeVal)));
2032 #line 983 "llvmAsmParser.y"
2034 if (!yyvsp[-3].TypeVal->isArrayType() || ((const ArrayType*)yyvsp[-3].TypeVal)->isSized())
2035 ThrowException("Trying to allocate " + yyvsp[-3].TypeVal->getName() +
2036 " as unsized array!");
2037 const Type *Ty = checkNewType(PointerType::getPointerType(yyvsp[-3].TypeVal));
2038 yyval.InstVal = new MallocInst(Ty, getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
2042 #line 990 "llvmAsmParser.y"
2044 yyval.InstVal = new AllocaInst(checkNewType(PointerType::getPointerType(yyvsp[0].TypeVal)));
2048 #line 993 "llvmAsmParser.y"
2050 if (!yyvsp[-3].TypeVal->isArrayType() || ((const ArrayType*)yyvsp[-3].TypeVal)->isSized())
2051 ThrowException("Trying to allocate " + yyvsp[-3].TypeVal->getName() +
2052 " as unsized array!");
2053 const Type *Ty = checkNewType(PointerType::getPointerType(yyvsp[-3].TypeVal));
2054 Value *ArrSize = getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
2055 yyval.InstVal = new AllocaInst(Ty, ArrSize);
2059 #line 1001 "llvmAsmParser.y"
2061 if (!yyvsp[-1].TypeVal->isPointerType())
2062 ThrowException("Trying to free nonpointer type " + yyvsp[-1].TypeVal->getName() + "!");
2063 yyval.InstVal = new FreeInst(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
2067 #line 1007 "llvmAsmParser.y"
2069 if (!yyvsp[-2].TypeVal->isPointerType())
2070 ThrowException("Can't load from nonpointer type: " + yyvsp[-2].TypeVal->getName());
2071 if (LoadInst::getIndexedType(yyvsp[-2].TypeVal, *yyvsp[0].ConstVector) == 0)
2072 ThrowException("Invalid indices for load instruction!");
2074 yyval.InstVal = new LoadInst(getVal(yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ConstVector);
2075 delete yyvsp[0].ConstVector; // Free the vector...
2079 #line 1016 "llvmAsmParser.y"
2081 if (!yyvsp[-2].TypeVal->isPointerType())
2082 ThrowException("Can't store to a nonpointer type: " + yyvsp[-2].TypeVal->getName());
2083 const Type *ElTy = StoreInst::getIndexedType(yyvsp[-2].TypeVal, *yyvsp[0].ConstVector);
2085 ThrowException("Can't store into that field list!");
2086 if (ElTy != yyvsp[-5].TypeVal)
2087 ThrowException("Can't store '" + yyvsp[-5].TypeVal->getName() + "' into space of type '"+
2088 ElTy->getName() + "'!");
2089 yyval.InstVal = new StoreInst(getVal(yyvsp[-5].TypeVal, yyvsp[-4].ValIDVal), getVal(yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ConstVector);
2090 delete yyvsp[0].ConstVector;
2094 #line 1028 "llvmAsmParser.y"
2096 if (!yyvsp[-2].TypeVal->isPointerType())
2097 ThrowException("getelementptr insn requires pointer operand!");
2098 if (!GetElementPtrInst::getIndexedType(yyvsp[-2].TypeVal, *yyvsp[0].ConstVector, true))
2099 ThrowException("Can't get element ptr '" + yyvsp[-2].TypeVal->getName() + "'!");
2100 yyval.InstVal = new GetElementPtrInst(getVal(yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ConstVector);
2101 delete yyvsp[0].ConstVector;
2102 checkNewType(yyval.InstVal->getType());
2106 /* the action file gets copied in in place of this dollarsign */
2107 #line 543 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
2118 short *ssp1 = yyss - 1;
2119 fprintf (stderr, "state stack now");
2120 while (ssp1 != yyssp)
2121 fprintf (stderr, " %d", *++ssp1);
2122 fprintf (stderr, "\n");
2132 yylsp->first_line = yylloc.first_line;
2133 yylsp->first_column = yylloc.first_column;
2134 yylsp->last_line = (yylsp-1)->last_line;
2135 yylsp->last_column = (yylsp-1)->last_column;
2140 yylsp->last_line = (yylsp+yylen-1)->last_line;
2141 yylsp->last_column = (yylsp+yylen-1)->last_column;
2145 /* Now "shift" the result of the reduction.
2146 Determine what state that goes to,
2147 based on the state we popped back to
2148 and the rule number reduced by. */
2152 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
2153 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2154 yystate = yytable[yystate];
2156 yystate = yydefgoto[yyn - YYNTBASE];
2160 yyerrlab: /* here on detecting error */
2163 /* If not already recovering from an error, report this error. */
2167 #ifdef YYERROR_VERBOSE
2168 yyn = yypact[yystate];
2170 if (yyn > YYFLAG && yyn < YYLAST)
2177 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
2178 for (x = (yyn < 0 ? -yyn : 0);
2179 x < (sizeof(yytname) / sizeof(char *)); x++)
2180 if (yycheck[x + yyn] == x)
2181 size += strlen(yytname[x]) + 15, count++;
2182 msg = (char *) malloc(size + 15);
2185 strcpy(msg, "parse error");
2190 for (x = (yyn < 0 ? -yyn : 0);
2191 x < (sizeof(yytname) / sizeof(char *)); x++)
2192 if (yycheck[x + yyn] == x)
2194 strcat(msg, count == 0 ? ", expecting `" : " or `");
2195 strcat(msg, yytname[x]);
2204 yyerror ("parse error; also virtual memory exceeded");
2207 #endif /* YYERROR_VERBOSE */
2208 yyerror("parse error");
2212 yyerrlab1: /* here on error raised explicitly by an action */
2214 if (yyerrstatus == 3)
2216 /* if just tried and failed to reuse lookahead token after an error, discard it. */
2218 /* return failure if at end of input */
2219 if (yychar == YYEOF)
2224 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
2230 /* Else will try to reuse lookahead token
2231 after shifting the error token. */
2233 yyerrstatus = 3; /* Each real token shifted decrements this */
2237 yyerrdefault: /* current state does not do anything special for the error token. */
2240 /* This is wrong; only states that explicitly want error tokens
2241 should shift them. */
2242 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
2243 if (yyn) goto yydefault;
2246 yyerrpop: /* pop the current state because it cannot handle the error token */
2248 if (yyssp == yyss) YYABORT;
2258 short *ssp1 = yyss - 1;
2259 fprintf (stderr, "Error: state stack now");
2260 while (ssp1 != yyssp)
2261 fprintf (stderr, " %d", *++ssp1);
2262 fprintf (stderr, "\n");
2268 yyn = yypact[yystate];
2273 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
2292 fprintf(stderr, "Shifting error token, ");
2304 /* YYACCEPT comes here. */
2316 /* YYABORT comes here. */
2327 #line 1038 "llvmAsmParser.y"
2329 int yyerror(const char *ErrorMsg) {
2330 ThrowException(string("Parse error: ") + ErrorMsg);