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 <stdio.h> // This embarasment is due to our flex lexer...
87 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
88 int yylex(); // declaration" of xxx warnings.
91 static Module *ParserResult;
92 const ToolCommandLine *CurOptions = 0;
94 // This contains info used when building the body of a method. It is destroyed
95 // when the method is completed.
97 typedef vector<Value *> ValueList; // Numbered defs
98 static void ResolveDefinitions(vector<ValueList> &LateResolvers);
100 static struct PerModuleInfo {
101 Module *CurrentModule;
102 vector<ValueList> Values; // Module level numbered definitions
103 vector<ValueList> LateResolveValues;
106 // If we could not resolve some blocks at parsing time (forward branches)
107 // resolve the branches now...
108 ResolveDefinitions(LateResolveValues);
110 Values.clear(); // Clear out method local definitions
115 static struct PerMethodInfo {
116 Method *CurrentMethod; // Pointer to current method being created
118 vector<ValueList> Values; // Keep track of numbered definitions
119 vector<ValueList> LateResolveValues;
121 inline PerMethodInfo() {
125 inline ~PerMethodInfo() {}
127 inline void MethodStart(Method *M) {
132 // If we could not resolve some blocks at parsing time (forward branches)
133 // resolve the branches now...
134 ResolveDefinitions(LateResolveValues);
136 Values.clear(); // Clear out method local definitions
139 } CurMeth; // Info for the current method...
142 //===----------------------------------------------------------------------===//
143 // Code to handle definitions of all the types
144 //===----------------------------------------------------------------------===//
146 static void InsertValue(Value *D, vector<ValueList> &ValueTab = CurMeth.Values) {
147 if (!D->hasName()) { // Is this a numbered definition?
148 unsigned type = D->getType()->getUniqueID();
149 if (ValueTab.size() <= type)
150 ValueTab.resize(type+1, ValueList());
151 //printf("Values[%d][%d] = %d\n", type, ValueTab[type].size(), D);
152 ValueTab[type].push_back(D);
156 static Value *getVal(const Type *Type, ValID &D,
157 bool DoNotImprovise = false) {
159 case 0: { // Is it a numbered definition?
160 unsigned type = Type->getUniqueID();
161 unsigned Num = (unsigned)D.Num;
163 // Module constants occupy the lowest numbered slots...
164 if (type < CurModule.Values.size()) {
165 if (Num < CurModule.Values[type].size())
166 return CurModule.Values[type][Num];
168 Num -= CurModule.Values[type].size();
171 // Make sure that our type is within bounds
172 if (CurMeth.Values.size() <= type)
175 // Check that the number is within bounds...
176 if (CurMeth.Values[type].size() <= Num)
179 return CurMeth.Values[type][Num];
181 case 1: { // Is it a named definition?
183 SymbolTable *SymTab = 0;
184 if (CurMeth.CurrentMethod)
185 SymTab = CurMeth.CurrentMethod->getSymbolTable();
186 Value *N = SymTab ? SymTab->lookup(Type, Name) : 0;
189 SymTab = CurModule.CurrentModule->getSymbolTable();
191 N = SymTab->lookup(Type, Name);
195 D.destroy(); // Free old strdup'd memory...
199 case 2: // Is it a constant pool reference??
200 case 3: // Is it an unsigned const pool reference?
201 case 4:{ // Is it a string const pool reference?
202 ConstPoolVal *CPV = 0;
204 // Check to make sure that "Type" is an integral type, and that our
205 // value will fit into the specified type...
208 if (Type == Type::BoolTy) { // Special handling for boolean data
209 CPV = new ConstPoolBool(D.ConstPool64 != 0);
211 if (!ConstPoolSInt::isValueValidForType(Type, D.ConstPool64))
212 ThrowException("Symbolic constant pool reference is invalid!");
213 CPV = new ConstPoolSInt(Type, D.ConstPool64);
217 if (!ConstPoolUInt::isValueValidForType(Type, D.UConstPool64)) {
218 if (!ConstPoolSInt::isValueValidForType(Type, D.ConstPool64)) {
219 ThrowException("Symbolic constant pool reference is invalid!");
220 } else { // This is really a signed reference. Transmogrify.
221 CPV = new ConstPoolSInt(Type, D.ConstPool64);
224 CPV = new ConstPoolUInt(Type, D.UConstPool64);
228 cerr << "FIXME: TODO: String constants [sbyte] not implemented yet!\n";
230 //CPV = new ConstPoolString(D.Name);
231 D.destroy(); // Free the string memory
234 assert(CPV && "How did we escape creating a constant??");
236 // Scan through the constant table and see if we already have loaded this
239 ConstantPool &CP = CurMeth.CurrentMethod ?
240 CurMeth.CurrentMethod->getConstantPool() :
241 CurModule.CurrentModule->getConstantPool();
242 ConstPoolVal *C = CP.find(CPV); // Already have this constant?
244 delete CPV; // Didn't need this after all, oh well.
245 return C; // Yup, we already have one, recycle it!
249 // Success, everything is kosher. Lets go!
251 } // End of case 2,3,4
255 // If we reached here, we referenced either a symbol that we don't know about
256 // or an id number that hasn't been read yet. We may be referencing something
257 // forward, so just create an entry to be resolved later and get to it...
259 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
261 // TODO: Attempt to coallecse nodes that are the same with previous ones.
263 switch (Type->getPrimitiveID()) {
264 case Type::LabelTyID: d = new BBPlaceHolder(Type, D); break;
265 case Type::MethodTyID:
266 d = new MethPlaceHolder(Type, D);
267 InsertValue(d, CurModule.LateResolveValues);
269 //case Type::ClassTyID: d = new ClassPlaceHolder(Type, D); break;
270 default: d = new DefPlaceHolder(Type, D); break;
273 assert(d != 0 && "How did we not make something?");
274 InsertValue(d, CurMeth.LateResolveValues);
279 //===----------------------------------------------------------------------===//
280 // Code to handle forward references in instructions
281 //===----------------------------------------------------------------------===//
283 // This code handles the late binding needed with statements that reference
284 // values not defined yet... for example, a forward branch, or the PHI node for
287 // This keeps a table (CurMeth.LateResolveValues) of all such forward references
288 // and back patchs after we are done.
291 // ResolveDefinitions - If we could not resolve some defs at parsing
292 // time (forward branches, phi functions for loops, etc...) resolve the
295 static void ResolveDefinitions(vector<ValueList> &LateResolvers) {
296 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
297 for (unsigned ty = 0; ty < LateResolvers.size(); ty++) {
298 while (!LateResolvers[ty].empty()) {
299 Value *V = LateResolvers[ty].back();
300 LateResolvers[ty].pop_back();
301 ValID &DID = getValIDFromPlaceHolder(V);
303 Value *TheRealValue = getVal(Type::getUniqueIDType(ty), DID, true);
305 if (TheRealValue == 0 && DID.Type == 1)
306 ThrowException("Reference to an invalid definition: '" +DID.getName() +
307 "' of type '" + V->getType()->getName() + "'");
308 else if (TheRealValue == 0)
309 ThrowException("Reference to an invalid definition: #" +itostr(DID.Num)+
310 " of type '" + V->getType()->getName() + "'");
312 V->replaceAllUsesWith(TheRealValue);
313 assert(V->use_empty());
318 LateResolvers.clear();
321 // addConstValToConstantPool - This code is used to insert a constant into the
322 // current constant pool. This is designed to make maximal (but not more than
323 // possible) reuse (merging) of constants in the constant pool. This means that
324 // multiple references to %4, for example will all get merged.
326 static ConstPoolVal *addConstValToConstantPool(ConstPoolVal *C) {
327 vector<ValueList> &ValTab = CurMeth.CurrentMethod ?
328 CurMeth.Values : CurModule.Values;
329 ConstantPool &CP = CurMeth.CurrentMethod ?
330 CurMeth.CurrentMethod->getConstantPool() :
331 CurModule.CurrentModule->getConstantPool();
333 if (ConstPoolVal *CPV = CP.find(C)) {
334 // Constant already in constant pool. Try to merge the two constants
335 if (CPV->hasName() && !C->hasName()) {
336 // Merge the two values, we inherit the existing CPV's name.
337 // InsertValue requires that the value have no name to insert correctly
338 // (because we want to fill the slot this constant would have filled)
340 string Name = CPV->getName();
342 InsertValue(CPV, ValTab);
346 } else if (!CPV->hasName() && C->hasName()) {
347 // If we have a name on this value and there isn't one in the const
348 // pool val already, propogate it.
350 CPV->setName(C->getName());
351 delete C; // Sorry, you're toast
353 } else if (CPV->hasName() && C->hasName()) {
354 // Both values have distinct names. We cannot merge them.
356 InsertValue(C, ValTab);
358 } else if (!CPV->hasName() && !C->hasName()) {
359 // Neither value has a name, trivially merge them.
360 InsertValue(CPV, ValTab);
365 assert(0 && "Not reached!");
367 } else { // No duplication of value.
369 InsertValue(C, ValTab);
374 //===----------------------------------------------------------------------===//
375 // RunVMAsmParser - Define an interface to this parser
376 //===----------------------------------------------------------------------===//
378 Module *RunVMAsmParser(const ToolCommandLine &Opts, FILE *F) {
381 llvmAsmlineno = 1; // Reset the current line number...
383 CurModule.CurrentModule = new Module(); // Allocate a new module to read
384 yyparse(); // Parse the file.
385 Module *Result = ParserResult;
387 llvmAsmin = stdin; // F is about to go away, don't use it anymore...
394 #line 337 "llvmAsmParser.y"
398 MethodArgument *MethArgVal;
399 BasicBlock *BasicBlockVal;
400 TerminatorInst *TermInstVal;
401 Instruction *InstVal;
402 ConstPoolVal *ConstVal;
405 list<MethodArgument*> *MethodArgList;
406 list<Value*> *ValueList;
407 list<const Type*> *TypeList;
408 list<pair<Value*, BasicBlock*> > *PHIList; // Represent the RHS of PHI node
409 list<pair<ConstPoolVal*, BasicBlock*> > *JumpTable;
410 vector<ConstPoolVal*> *ConstVector;
417 char *StrVal; // This memory is allocated by strdup!
418 ValID ValIDVal; // May contain memory allocated by strdup
420 Instruction::UnaryOps UnaryOpVal;
421 Instruction::BinaryOps BinaryOpVal;
422 Instruction::TermOps TermOpVal;
423 Instruction::MemoryOps MemOpVal;
424 Instruction::OtherOps OtherOpVal;
437 #define YYFLAG -32768
440 #define YYTRANSLATE(x) ((unsigned)(x) <= 311 ? yytranslate[x] : 106)
442 static const char yytranslate[] = { 0,
443 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
444 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
446 2, 2, 2, 2, 2, 2, 2, 2, 2, 65,
447 66, 67, 2, 64, 2, 2, 2, 2, 2, 2,
448 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
449 58, 2, 2, 2, 2, 2, 2, 2, 2, 2,
450 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
452 59, 2, 60, 2, 2, 2, 2, 2, 2, 2,
453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
454 2, 2, 2, 2, 2, 2, 2, 2, 2, 61,
455 2, 2, 62, 2, 63, 2, 2, 2, 2, 2,
456 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
457 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
458 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
459 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
460 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
461 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
462 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
463 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
464 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
465 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
466 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
467 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
468 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
469 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
470 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
471 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
472 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
473 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
478 static const short yyprhs[] = { 0,
479 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
480 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
481 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
482 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
483 80, 82, 84, 86, 88, 91, 92, 95, 98, 101,
484 104, 107, 110, 117, 123, 132, 140, 147, 152, 156,
485 158, 162, 163, 165, 168, 171, 173, 174, 177, 181,
486 183, 185, 186, 192, 196, 199, 201, 203, 205, 207,
487 209, 211, 213, 215, 217, 222, 226, 230, 236, 240,
488 243, 246, 248, 252, 255, 258, 261, 265, 268, 269,
489 273, 276, 280, 290, 300, 307, 313, 316, 323, 331,
490 334, 339, 341, 342, 348, 352, 359, 365, 368, 375,
491 377, 380, 381, 384, 390, 393, 399, 403, 408, 416
494 static const short yyrhs[] = { 5,
495 0, 6, 0, 3, 0, 4, 0, 8, 0, 9,
496 0, 10, 0, 11, 0, 12, 0, 13, 0, 14,
497 0, 15, 0, 16, 0, 17, 0, 18, 0, 19,
498 0, 20, 0, 21, 0, 70, 0, 7, 0, 35,
499 0, 36, 0, 37, 0, 38, 0, 39, 0, 40,
500 0, 41, 0, 42, 0, 43, 0, 44, 0, 45,
501 0, 46, 0, 56, 0, 57, 0, 15, 0, 13,
502 0, 11, 0, 9, 0, 16, 0, 14, 0, 12,
503 0, 10, 0, 75, 0, 76, 0, 22, 58, 0,
504 0, 75, 69, 0, 76, 4, 0, 8, 26, 0,
505 8, 27, 0, 19, 24, 0, 20, 70, 0, 59,
506 70, 60, 59, 80, 60, 0, 59, 70, 60, 59,
507 60, 0, 59, 4, 61, 70, 60, 59, 80, 60,
508 0, 59, 4, 61, 70, 60, 59, 60, 0, 62,
509 93, 63, 62, 80, 63, 0, 62, 63, 62, 63,
510 0, 80, 64, 79, 0, 79, 0, 81, 78, 79,
511 0, 0, 83, 0, 83, 90, 0, 81, 25, 0,
512 22, 0, 0, 70, 84, 0, 85, 64, 86, 0,
513 85, 0, 86, 0, 0, 71, 24, 65, 87, 66,
514 0, 88, 81, 28, 0, 94, 29, 0, 3, 0,
515 4, 0, 26, 0, 27, 0, 24, 0, 68, 0,
516 22, 0, 91, 0, 92, 0, 71, 65, 93, 66,
517 0, 71, 65, 66, 0, 59, 70, 60, 0, 59,
518 4, 61, 70, 60, 0, 62, 93, 63, 0, 62,
519 63, 0, 70, 67, 0, 70, 0, 93, 64, 70,
520 0, 94, 95, 0, 89, 95, 0, 96, 97, 0,
521 23, 96, 97, 0, 96, 99, 0, 0, 32, 70,
522 92, 0, 32, 7, 0, 33, 21, 92, 0, 33,
523 8, 92, 64, 21, 92, 64, 21, 92, 0, 34,
524 77, 92, 64, 21, 92, 59, 98, 60, 0, 98,
525 77, 91, 64, 21, 92, 0, 77, 91, 64, 21,
526 92, 0, 78, 103, 0, 70, 59, 92, 64, 92,
527 60, 0, 100, 64, 59, 92, 64, 92, 60, 0,
528 70, 92, 0, 101, 64, 70, 92, 0, 101, 0,
529 0, 73, 70, 92, 64, 92, 0, 72, 70, 92,
530 0, 74, 70, 92, 64, 70, 92, 0, 55, 70,
531 92, 31, 70, 0, 53, 100, 0, 54, 70, 92,
532 65, 102, 66, 0, 105, 0, 64, 80, 0, 0,
533 47, 70, 0, 47, 70, 64, 14, 92, 0, 48,
534 70, 0, 48, 70, 64, 14, 92, 0, 49, 70,
535 92, 0, 50, 70, 92, 104, 0, 51, 70, 92,
536 64, 70, 92, 104, 0, 52, 70, 92, 104, 0
542 static const short yyrline[] = { 0,
543 434, 435, 442, 443, 454, 454, 454, 454, 454, 454,
544 454, 455, 455, 455, 455, 455, 455, 455, 458, 458,
545 463, 464, 464, 464, 464, 464, 465, 465, 465, 465,
546 465, 465, 466, 466, 470, 470, 470, 470, 471, 471,
547 471, 471, 472, 472, 474, 477, 481, 486, 491, 494,
548 497, 503, 506, 519, 523, 541, 548, 556, 570, 573,
549 579, 587, 598, 603, 608, 617, 617, 619, 627, 631,
550 636, 639, 643, 670, 674, 683, 686, 689, 692, 695,
551 700, 703, 706, 713, 721, 726, 730, 733, 736, 741,
552 744, 749, 753, 758, 762, 771, 776, 785, 789, 793,
553 796, 799, 802, 807, 818, 826, 836, 844, 849, 856,
554 860, 866, 866, 868, 873, 878, 882, 885, 896, 933,
555 938, 940, 944, 949, 958, 963, 972, 978, 987, 999
560 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
562 static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
563 "EUINT64VAL","SINTVAL","UINTVAL","VOID","BOOL","SBYTE","UBYTE","SHORT","USHORT",
564 "INT","UINT","LONG","ULONG","FLOAT","DOUBLE","STRING","TYPE","LABEL","VAR_ID",
565 "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","TRUE","FALSE","BEGINTOK","END",
566 "DECLARE","TO","RET","BR","SWITCH","NOT","ADD","SUB","MUL","DIV","REM","SETLE",
567 "SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE",
568 "GETELEMENTPTR","PHI","CALL","CAST","SHL","SHR","'='","'['","']'","'x'","'{'",
569 "'}'","','","'('","')'","'*'","INTVAL","EINT64VAL","Types","TypesV","UnaryOps",
570 "BinaryOps","ShiftOps","SIntType","UIntType","IntType","OptAssign","ConstVal",
571 "ConstVector","ConstPool","Module","MethodList","OptVAR_ID","ArgVal","ArgListH",
572 "ArgList","MethodHeaderH","MethodHeader","Method","ConstValueRef","ValueRef",
573 "TypeList","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
574 "JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","InstVal","UByteList",
579 static const short yyr1[] = { 0,
580 68, 68, 69, 69, 70, 70, 70, 70, 70, 70,
581 70, 70, 70, 70, 70, 70, 70, 70, 71, 71,
582 72, 73, 73, 73, 73, 73, 73, 73, 73, 73,
583 73, 73, 74, 74, 75, 75, 75, 75, 76, 76,
584 76, 76, 77, 77, 78, 78, 79, 79, 79, 79,
585 79, 79, 79, 79, 79, 79, 79, 79, 80, 80,
586 81, 81, 82, 83, 83, 84, 84, 85, 86, 86,
587 87, 87, 88, 89, 90, 91, 91, 91, 91, 91,
588 92, 92, 92, 70, 70, 70, 70, 70, 70, 70,
589 70, 93, 93, 94, 94, 95, 95, 96, 96, 97,
590 97, 97, 97, 97, 98, 98, 99, 100, 100, 101,
591 101, 102, 102, 103, 103, 103, 103, 103, 103, 103,
592 104, 104, 105, 105, 105, 105, 105, 105, 105, 105
595 static const short yyr2[] = { 0,
596 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
597 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
598 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
599 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
600 1, 1, 1, 1, 2, 0, 2, 2, 2, 2,
601 2, 2, 6, 5, 8, 7, 6, 4, 3, 1,
602 3, 0, 1, 2, 2, 1, 0, 2, 3, 1,
603 1, 0, 5, 3, 2, 1, 1, 1, 1, 1,
604 1, 1, 1, 1, 4, 3, 3, 5, 3, 2,
605 2, 1, 3, 2, 2, 2, 3, 2, 0, 3,
606 2, 3, 9, 9, 6, 5, 2, 6, 7, 2,
607 4, 1, 0, 5, 3, 6, 5, 2, 6, 1,
608 2, 0, 2, 5, 2, 5, 3, 4, 7, 4
611 static const short yydefact[] = { 62,
612 46, 63, 0, 65, 0, 76, 77, 1, 2, 20,
613 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
614 15, 16, 17, 18, 82, 80, 78, 79, 0, 0,
615 81, 19, 0, 62, 99, 64, 83, 84, 99, 45,
616 0, 38, 42, 37, 41, 36, 40, 35, 39, 0,
617 0, 0, 0, 0, 0, 61, 77, 19, 0, 90,
618 92, 0, 91, 0, 0, 46, 99, 95, 46, 75,
619 94, 49, 50, 51, 52, 77, 19, 0, 0, 3,
620 4, 47, 48, 0, 87, 89, 0, 72, 86, 0,
621 74, 46, 0, 0, 0, 0, 96, 98, 0, 0,
622 0, 0, 19, 93, 67, 70, 71, 0, 85, 97,
623 101, 19, 0, 0, 43, 44, 0, 21, 22, 23,
624 24, 25, 26, 27, 28, 29, 30, 31, 32, 0,
625 0, 0, 0, 0, 0, 0, 0, 0, 33, 34,
626 0, 0, 0, 107, 120, 19, 0, 58, 0, 88,
627 66, 68, 0, 73, 100, 0, 102, 0, 123, 125,
628 19, 19, 19, 19, 19, 118, 19, 19, 19, 19,
629 19, 0, 54, 60, 0, 0, 69, 0, 0, 0,
630 0, 127, 122, 0, 122, 0, 0, 0, 0, 115,
631 0, 0, 0, 53, 0, 57, 0, 0, 0, 0,
632 0, 128, 0, 130, 0, 0, 113, 0, 0, 0,
633 56, 0, 59, 0, 0, 124, 126, 121, 19, 0,
634 0, 19, 112, 0, 117, 114, 19, 55, 0, 0,
635 122, 0, 0, 110, 0, 119, 116, 0, 0, 0,
636 129, 108, 0, 19, 103, 0, 104, 0, 109, 111,
637 0, 0, 0, 0, 106, 0, 105, 0, 0, 0
640 static const short yydefgoto[] = { 31,
641 82, 61, 59, 141, 142, 143, 54, 55, 117, 5,
642 174, 175, 1, 258, 2, 152, 106, 107, 108, 34,
643 35, 36, 37, 38, 62, 39, 68, 69, 97, 240,
644 98, 166, 223, 224, 144, 202, 145
647 static const short yypact[] = {-32768,
648 70, 321, -6,-32768, 90,-32768,-32768,-32768,-32768,-32768,
649 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
650 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 381, 235,
651 -32768, 45, -20,-32768, 98,-32768,-32768,-32768, 93,-32768,
652 67,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 56,
653 321, 406, 296, 181, 142,-32768, 97, -14, 96,-32768,
654 46, 123,-32768, 101, 210, 122,-32768,-32768, 135,-32768,
655 -32768,-32768,-32768,-32768, 46, 111, 29, 112, 129,-32768,
656 -32768,-32768,-32768, 321,-32768,-32768, 321, 321,-32768, 79,
657 -32768, 135, 466, 13, 268, 461,-32768,-32768, 321, 118,
658 125, 119, 47, 46, 10, 126,-32768, 131,-32768,-32768,
659 133, 4, 52, 52,-32768,-32768, 52,-32768,-32768,-32768,
660 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 321,
661 321, 321, 321, 321, 321, 321, 321, 321,-32768,-32768,
662 321, 321, 321,-32768,-32768, 48, 3,-32768, 90,-32768,
663 -32768,-32768, 321,-32768,-32768, 138,-32768, 139, 106, 115,
664 4, 4, 4, 4, 0, 140, 4, 4, 4, 4,
665 4, 148,-32768,-32768, 99, 132,-32768, 178, 189, 197,
666 221,-32768, 194, 196, 194, 52, 204, 199, 234,-32768,
667 202, 203, 28,-32768, 90,-32768, 52, 52, 52, 52,
668 90,-32768, 321,-32768, 206, 52, 321, 321, 52, 321,
669 -32768, 100,-32768, 207, 209,-32768,-32768, 211, 4, 52,
670 222, 4, 223, 208, 46,-32768, 4,-32768, 252, 268,
671 194, 225, 52,-32768, 321,-32768,-32768, 52, 57, 435,
672 -32768,-32768, 228, 4,-32768, 226,-32768, 57,-32768,-32768,
673 270, 229, 52, 271,-32768, 52,-32768, 289, 295,-32768
676 static const short yypgoto[] = {-32768,
677 -32768, -2, 294,-32768,-32768,-32768, -93, -92, -205, -63,
678 -4, -129, 285,-32768,-32768,-32768,-32768, 168,-32768,-32768,
679 -32768,-32768, -215, -44, 1,-32768, 305, 279, 257,-32768,
680 -32768,-32768,-32768,-32768,-32768, -180,-32768
687 static const short yytable[] = { 32,
688 56, 115, 116, 64, 204, 96, 6, 7, 8, 9,
689 41, 42, 43, 44, 45, 46, 47, 48, 49, 176,
690 113, 50, 51, 246, 239, 25, 58, 26, 96, 27,
691 28, 151, 252, 114, 248, 41, 42, 43, 44, 45,
692 46, 47, 48, 49, 65, 85, 50, 51, 75, 77,
693 241, 40, 63, 79, 6, 7, 8, 9, 186, 6,
694 7, 52, 173, 212, 53, 90, 63, 155, 156, 157,
695 63, 218, 158, 25, -19, 26, 63, 27, 28, 74,
696 26, 103, 27, 28, 104, 105, 52, 211, 100, 53,
697 112, 3, 72, 73, 4, 63, 146, 41, 42, 43,
698 44, 45, 46, 47, 48, 49, 150, 172, 50, 51,
699 -19, 63, 63, 63, 63, 67, 182, 183, 184, 185,
700 67, 70, 188, 189, 190, 191, 192, 159, 160, 161,
701 162, 163, 164, 165, 167, 168, 115, 116, 169, 170,
702 171, 205, 87, 3, 109, 83, 115, 116, 52, 91,
703 105, 53, 214, 215, 216, 217, 3, 84, 194, 228,
704 65, 221, 195, 195, 226, 88, 93, 94, 95, 180,
705 -19, 99, 63, 101, 231, 232, 147, 234, 181, -19,
706 149, 63, 237, 80, 81, 86, 87, 148, 243, 153,
707 213, 102, 87, 245, 196, 195, 154, -20, 197, 250,
708 219, 178, 179, 187, 222, 225, 193, 227, 255, 198,
709 199, 257, 6, 7, 8, 9, 10, 11, 12, 13,
710 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
711 24, 25, 244, 26, 200, 27, 28, 6, 7, 8,
712 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
713 19, 20, 21, 22, 23, 24, 25, 201, 26, 203,
714 27, 28, 206, 207, 208, 209, 210, 230, 29, 220,
715 229, 30, 238, 236, 195, 89, 42, 43, 44, 45,
716 46, 47, 48, 49, 242, 233, 235, 249, 259, 251,
717 253, 256, 254, 29, 260, 33, 30, 60, 6, 7,
718 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
719 18, 19, 20, 21, 22, 23, 24, 25, 66, 26,
720 177, 27, 28, 6, 7, 8, 9, 10, 11, 12,
721 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
722 23, 24, 25, 71, 26, 92, 27, 28, 110, 0,
723 0, 0, 0, 0, 29, 0, 0, 30, 78, 0,
724 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
725 0, 0, 0, 0, 0, 0, 0, 0, 0, 29,
726 0, 0, 30, 6, 57, 8, 9, 10, 11, 12,
727 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
728 23, 24, 25, 0, 26, 0, 27, 28, 6, 76,
729 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
730 18, 19, 20, 21, 22, 23, 24, 25, 0, 26,
731 0, 27, 28, 0, 0, 0, 0, 0, 0, 29,
732 0, 0, 30, 42, 43, 44, 45, 46, 47, 48,
733 49, 0, 0, 0, 0, 0, 0, 0, 0, 0,
734 0, 0, 0, 0, 29, 0, 0, 30, 6, 7,
735 8, 9, 111, 11, 12, 13, 14, 15, 16, 17,
736 18, 19, 20, 21, 22, 23, 24, 25, 0, 26,
737 0, 27, 28, 0, 247, 118, 119, 120, 121, 122,
738 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
739 133, 134, 135, 136, 137, 138, 139, 140, 0, 0,
740 0, 0, 0, 0, 29, 0, 0, 30
743 static const short yycheck[] = { 2,
744 5, 95, 95, 24, 185, 69, 3, 4, 5, 6,
745 8, 9, 10, 11, 12, 13, 14, 15, 16, 149,
746 8, 19, 20, 239, 230, 22, 29, 24, 92, 26,
747 27, 22, 248, 21, 240, 8, 9, 10, 11, 12,
748 13, 14, 15, 16, 65, 60, 19, 20, 51, 52,
749 231, 58, 67, 53, 3, 4, 5, 6, 59, 3,
750 4, 59, 60, 193, 62, 65, 67, 112, 113, 114,
751 67, 201, 117, 22, 65, 24, 67, 26, 27, 24,
752 24, 84, 26, 27, 87, 88, 59, 60, 60, 62,
753 93, 22, 26, 27, 25, 67, 99, 8, 9, 10,
754 11, 12, 13, 14, 15, 16, 60, 60, 19, 20,
755 65, 67, 67, 67, 67, 23, 161, 162, 163, 164,
756 23, 29, 167, 168, 169, 170, 171, 130, 131, 132,
757 133, 134, 135, 136, 137, 138, 230, 230, 141, 142,
758 143, 186, 64, 22, 66, 4, 240, 240, 59, 28,
759 153, 62, 197, 198, 199, 200, 22, 61, 60, 60,
760 65, 206, 64, 64, 209, 65, 32, 33, 34, 64,
761 65, 61, 67, 62, 219, 220, 59, 222, 64, 65,
762 62, 67, 227, 3, 4, 63, 64, 63, 233, 64,
763 195, 63, 64, 238, 63, 64, 66, 65, 21, 244,
764 203, 64, 64, 64, 207, 208, 59, 210, 253, 21,
765 14, 256, 3, 4, 5, 6, 7, 8, 9, 10,
766 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
767 21, 22, 235, 24, 14, 26, 27, 3, 4, 5,
768 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
769 16, 17, 18, 19, 20, 21, 22, 64, 24, 64,
770 26, 27, 59, 65, 31, 64, 64, 59, 59, 64,
771 64, 62, 21, 66, 64, 66, 9, 10, 11, 12,
772 13, 14, 15, 16, 60, 64, 64, 60, 0, 64,
773 21, 21, 64, 59, 0, 2, 62, 63, 3, 4,
774 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
775 15, 16, 17, 18, 19, 20, 21, 22, 34, 24,
776 153, 26, 27, 3, 4, 5, 6, 7, 8, 9,
777 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
778 20, 21, 22, 39, 24, 67, 26, 27, 92, -1,
779 -1, -1, -1, -1, 59, -1, -1, 62, 63, -1,
780 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
781 -1, -1, -1, -1, -1, -1, -1, -1, -1, 59,
782 -1, -1, 62, 3, 4, 5, 6, 7, 8, 9,
783 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
784 20, 21, 22, -1, 24, -1, 26, 27, 3, 4,
785 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
786 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
787 -1, 26, 27, -1, -1, -1, -1, -1, -1, 59,
788 -1, -1, 62, 9, 10, 11, 12, 13, 14, 15,
789 16, -1, -1, -1, -1, -1, -1, -1, -1, -1,
790 -1, -1, -1, -1, 59, -1, -1, 62, 3, 4,
791 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
792 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
793 -1, 26, 27, -1, 60, 35, 36, 37, 38, 39,
794 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
795 50, 51, 52, 53, 54, 55, 56, 57, -1, -1,
796 -1, -1, -1, -1, 59, -1, -1, 62
798 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
799 #line 3 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
800 /* This file comes from bison-1.28. */
802 /* Skeleton output parser for bison,
803 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
805 This program is free software; you can redistribute it and/or modify
806 it under the terms of the GNU General Public License as published by
807 the Free Software Foundation; either version 2, or (at your option)
810 This program is distributed in the hope that it will be useful,
811 but WITHOUT ANY WARRANTY; without even the implied warranty of
812 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
813 GNU General Public License for more details.
815 You should have received a copy of the GNU General Public License
816 along with this program; if not, write to the Free Software
817 Foundation, Inc., 59 Temple Place - Suite 330,
818 Boston, MA 02111-1307, USA. */
820 /* As a special exception, when this file is copied by Bison into a
821 Bison output file, you may use that output file without restriction.
822 This special exception was added by the Free Software Foundation
823 in version 1.24 of Bison. */
825 /* This is the parser code that is written into each bison parser
826 when the %semantic_parser declaration is not specified in the grammar.
827 It was written by Richard Stallman by simplifying the hairy parser
828 used when %semantic_parser is specified. */
830 #ifndef YYSTACK_USE_ALLOCA
832 #define YYSTACK_USE_ALLOCA
833 #else /* alloca not defined */
835 #define YYSTACK_USE_ALLOCA
836 #define alloca __builtin_alloca
837 #else /* not GNU C. */
838 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
839 #define YYSTACK_USE_ALLOCA
841 #else /* not sparc */
842 /* We think this test detects Watcom and Microsoft C. */
843 /* This used to test MSDOS, but that is a bad idea
844 since that symbol is in the user namespace. */
845 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
846 #if 0 /* No need for malloc.h, which pollutes the namespace;
847 instead, just don't use alloca. */
850 #else /* not MSDOS, or __TURBOC__ */
852 /* I don't know what this was needed for, but it pollutes the namespace.
853 So I turned it off. rms, 2 May 1997. */
854 /* #include <malloc.h> */
856 #define YYSTACK_USE_ALLOCA
857 #else /* not MSDOS, or __TURBOC__, or _AIX */
859 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
860 and on HPUX 10. Eventually we can turn this on. */
861 #define YYSTACK_USE_ALLOCA
862 #define alloca __builtin_alloca
865 #endif /* not _AIX */
866 #endif /* not MSDOS, or __TURBOC__ */
867 #endif /* not sparc */
868 #endif /* not GNU C */
869 #endif /* alloca not defined */
870 #endif /* YYSTACK_USE_ALLOCA not defined */
872 #ifdef YYSTACK_USE_ALLOCA
873 #define YYSTACK_ALLOC alloca
875 #define YYSTACK_ALLOC malloc
878 /* Note: there must be only one dollar sign in this file.
879 It is replaced by the list of actions, each action
880 as one case of the switch. */
882 #define yyerrok (yyerrstatus = 0)
883 #define yyclearin (yychar = YYEMPTY)
886 #define YYACCEPT goto yyacceptlab
887 #define YYABORT goto yyabortlab
888 #define YYERROR goto yyerrlab1
889 /* Like YYERROR except do call yyerror.
890 This remains here temporarily to ease the
891 transition to the new meaning of YYERROR, for GCC.
892 Once GCC version 2 has supplanted version 1, this can go. */
893 #define YYFAIL goto yyerrlab
894 #define YYRECOVERING() (!!yyerrstatus)
895 #define YYBACKUP(token, value) \
897 if (yychar == YYEMPTY && yylen == 1) \
898 { yychar = (token), yylval = (value); \
899 yychar1 = YYTRANSLATE (yychar); \
904 { yyerror ("syntax error: cannot back up"); YYERROR; } \
908 #define YYERRCODE 256
911 #define YYLEX yylex()
917 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
919 #define YYLEX yylex(&yylval, &yylloc)
921 #else /* not YYLSP_NEEDED */
923 #define YYLEX yylex(&yylval, YYLEX_PARAM)
925 #define YYLEX yylex(&yylval)
927 #endif /* not YYLSP_NEEDED */
930 /* If nonreentrant, generate the variables here */
934 int yychar; /* the lookahead symbol */
935 YYSTYPE yylval; /* the semantic value of the */
936 /* lookahead symbol */
939 YYLTYPE yylloc; /* location data for the lookahead */
943 int yynerrs; /* number of parse errors so far */
944 #endif /* not YYPURE */
947 int yydebug; /* nonzero means print parse trace */
948 /* Since this is uninitialized, it does not stop multiple parsers
952 /* YYINITDEPTH indicates the initial size of the parser's stacks */
955 #define YYINITDEPTH 200
958 /* YYMAXDEPTH is the maximum size the stacks can grow to
959 (effective only if the built-in stack extension method is used). */
966 #define YYMAXDEPTH 10000
969 /* Define __yy_memcpy. Note that the size argument
970 should be passed with type unsigned int, because that is what the non-GCC
971 definitions require. With GCC, __builtin_memcpy takes an arg
972 of type size_t, but it can handle unsigned int. */
974 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
975 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
976 #else /* not GNU C or C++ */
979 /* This is the most reliable way to avoid incompatibilities
980 in available built-in functions on various systems. */
982 __yy_memcpy (to, from, count)
987 register char *f = from;
988 register char *t = to;
989 register int i = count;
995 #else /* __cplusplus */
997 /* This is the most reliable way to avoid incompatibilities
998 in available built-in functions on various systems. */
1000 __yy_memcpy (char *to, char *from, unsigned int count)
1002 register char *t = to;
1003 register char *f = from;
1004 register int i = count;
1013 #line 217 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
1015 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
1016 into yyparse. The argument should have type void *.
1017 It should actually point to an object.
1018 Grammar actions can access the variable by casting it
1019 to the proper pointer type. */
1021 #ifdef YYPARSE_PARAM
1023 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1024 #define YYPARSE_PARAM_DECL
1025 #else /* not __cplusplus */
1026 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1027 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1028 #endif /* not __cplusplus */
1029 #else /* not YYPARSE_PARAM */
1030 #define YYPARSE_PARAM_ARG
1031 #define YYPARSE_PARAM_DECL
1032 #endif /* not YYPARSE_PARAM */
1034 /* Prevent warning if -Wstrict-prototypes. */
1036 #ifdef YYPARSE_PARAM
1037 int yyparse (void *);
1044 yyparse(YYPARSE_PARAM_ARG)
1047 register int yystate;
1049 register short *yyssp;
1050 register YYSTYPE *yyvsp;
1051 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1052 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
1054 short yyssa[YYINITDEPTH]; /* the state stack */
1055 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
1057 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1058 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
1061 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1062 YYLTYPE *yyls = yylsa;
1065 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1067 #define YYPOPSTACK (yyvsp--, yyssp--)
1070 int yystacksize = YYINITDEPTH;
1071 int yyfree_stacks = 0;
1082 YYSTYPE yyval; /* the variable used to return */
1083 /* semantic values from the action */
1090 fprintf(stderr, "Starting parse\n");
1096 yychar = YYEMPTY; /* Cause a token to be read. */
1098 /* Initialize stack pointers.
1099 Waste one element of value and location stack
1100 so that they stay on the same level as the state stack.
1101 The wasted elements are never initialized. */
1109 /* Push a new state, which is found in yystate . */
1110 /* In all cases, when you get here, the value and location stacks
1111 have just been pushed. so pushing a state here evens the stacks. */
1116 if (yyssp >= yyss + yystacksize - 1)
1118 /* Give user a chance to reallocate the stack */
1119 /* Use copies of these so that the &'s don't force the real ones into memory. */
1120 YYSTYPE *yyvs1 = yyvs;
1121 short *yyss1 = yyss;
1123 YYLTYPE *yyls1 = yyls;
1126 /* Get the current used size of the three stacks, in elements. */
1127 int size = yyssp - yyss + 1;
1130 /* Each stack pointer address is followed by the size of
1131 the data in use in that stack, in bytes. */
1133 /* This used to be a conditional around just the two extra args,
1134 but that might be undefined if yyoverflow is a macro. */
1135 yyoverflow("parser stack overflow",
1136 &yyss1, size * sizeof (*yyssp),
1137 &yyvs1, size * sizeof (*yyvsp),
1138 &yyls1, size * sizeof (*yylsp),
1141 yyoverflow("parser stack overflow",
1142 &yyss1, size * sizeof (*yyssp),
1143 &yyvs1, size * sizeof (*yyvsp),
1147 yyss = yyss1; yyvs = yyvs1;
1151 #else /* no yyoverflow */
1152 /* Extend the stack our own way. */
1153 if (yystacksize >= YYMAXDEPTH)
1155 yyerror("parser stack overflow");
1167 if (yystacksize > YYMAXDEPTH)
1168 yystacksize = YYMAXDEPTH;
1169 #ifndef YYSTACK_USE_ALLOCA
1172 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
1173 __yy_memcpy ((char *)yyss, (char *)yyss1,
1174 size * (unsigned int) sizeof (*yyssp));
1175 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
1176 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
1177 size * (unsigned int) sizeof (*yyvsp));
1179 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
1180 __yy_memcpy ((char *)yyls, (char *)yyls1,
1181 size * (unsigned int) sizeof (*yylsp));
1183 #endif /* no yyoverflow */
1185 yyssp = yyss + size - 1;
1186 yyvsp = yyvs + size - 1;
1188 yylsp = yyls + size - 1;
1193 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
1196 if (yyssp >= yyss + yystacksize - 1)
1202 fprintf(stderr, "Entering state %d\n", yystate);
1208 /* Do appropriate processing given the current state. */
1209 /* Read a lookahead token if we need one and don't already have one. */
1212 /* First try to decide what to do without reference to lookahead token. */
1214 yyn = yypact[yystate];
1218 /* Not known => get a lookahead token if don't already have one. */
1220 /* yychar is either YYEMPTY or YYEOF
1221 or a valid token in external form. */
1223 if (yychar == YYEMPTY)
1227 fprintf(stderr, "Reading a token: ");
1232 /* Convert token to internal form (in yychar1) for indexing tables with */
1234 if (yychar <= 0) /* This means end of input. */
1237 yychar = YYEOF; /* Don't call YYLEX any more */
1241 fprintf(stderr, "Now at end of input.\n");
1246 yychar1 = YYTRANSLATE(yychar);
1251 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
1252 /* Give the individual parser a way to print the precise meaning
1253 of a token, for further debugging info. */
1255 YYPRINT (stderr, yychar, yylval);
1257 fprintf (stderr, ")\n");
1263 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
1268 /* yyn is what to do for this token type in this state.
1269 Negative => reduce, -yyn is rule number.
1270 Positive => shift, yyn is new state.
1271 New state is final state => don't bother to shift,
1272 just return success.
1273 0, or most negative number => error. */
1288 /* Shift the lookahead token. */
1292 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1295 /* Discard the token being shifted unless it is eof. */
1296 if (yychar != YYEOF)
1304 /* count tokens shifted since error; after three, turn off error status. */
1305 if (yyerrstatus) yyerrstatus--;
1310 /* Do the default action for the current state. */
1313 yyn = yydefact[yystate];
1317 /* Do a reduction. yyn is the number of a rule to reduce with. */
1321 yyval = yyvsp[1-yylen]; /* implement default value of the action */
1328 fprintf (stderr, "Reducing via rule %d (line %d), ",
1331 /* Print the symbols being reduced, and their result. */
1332 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1333 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1334 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1342 #line 435 "llvmAsmParser.y"
1344 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
1345 ThrowException("Value too large for type!");
1346 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
1350 #line 443 "llvmAsmParser.y"
1352 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
1353 ThrowException("Value too large for type!");
1354 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
1358 #line 474 "llvmAsmParser.y"
1360 yyval.StrVal = yyvsp[-1].StrVal;
1364 #line 477 "llvmAsmParser.y"
1370 #line 481 "llvmAsmParser.y"
1371 { // integral constants
1372 if (!ConstPoolSInt::isValueValidForType(yyvsp[-1].TypeVal, yyvsp[0].SInt64Val))
1373 ThrowException("Constant value doesn't fit in type!");
1374 yyval.ConstVal = new ConstPoolSInt(yyvsp[-1].TypeVal, yyvsp[0].SInt64Val);
1378 #line 486 "llvmAsmParser.y"
1379 { // integral constants
1380 if (!ConstPoolUInt::isValueValidForType(yyvsp[-1].TypeVal, yyvsp[0].UInt64Val))
1381 ThrowException("Constant value doesn't fit in type!");
1382 yyval.ConstVal = new ConstPoolUInt(yyvsp[-1].TypeVal, yyvsp[0].UInt64Val);
1386 #line 491 "llvmAsmParser.y"
1387 { // Boolean constants
1388 yyval.ConstVal = new ConstPoolBool(true);
1392 #line 494 "llvmAsmParser.y"
1393 { // Boolean constants
1394 yyval.ConstVal = new ConstPoolBool(false);
1398 #line 497 "llvmAsmParser.y"
1399 { // String constants
1400 cerr << "FIXME: TODO: String constants [sbyte] not implemented yet!\n";
1402 //$$ = new ConstPoolString($2);
1403 free(yyvsp[0].StrVal);
1407 #line 503 "llvmAsmParser.y"
1409 yyval.ConstVal = new ConstPoolType(yyvsp[0].TypeVal);
1413 #line 506 "llvmAsmParser.y"
1414 { // Nonempty array constant
1415 // Verify all elements are correct type!
1416 const ArrayType *AT = ArrayType::getArrayType(yyvsp[-4].TypeVal);
1417 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
1418 if (yyvsp[-4].TypeVal != (*yyvsp[-1].ConstVector)[i]->getType())
1419 ThrowException("Element #" + utostr(i) + " is not of type '" +
1420 yyvsp[-4].TypeVal->getName() + "' as required!\nIt is of type '" +
1421 (*yyvsp[-1].ConstVector)[i]->getType()->getName() + "'.");
1424 yyval.ConstVal = new ConstPoolArray(AT, *yyvsp[-1].ConstVector);
1425 delete yyvsp[-1].ConstVector;
1429 #line 519 "llvmAsmParser.y"
1430 { // Empty array constant
1431 vector<ConstPoolVal*> Empty;
1432 yyval.ConstVal = new ConstPoolArray(ArrayType::getArrayType(yyvsp[-3].TypeVal), Empty);
1436 #line 523 "llvmAsmParser.y"
1438 // Verify all elements are correct type!
1439 const ArrayType *AT = ArrayType::getArrayType(yyvsp[-4].TypeVal, (int)yyvsp[-6].UInt64Val);
1440 if (yyvsp[-6].UInt64Val != yyvsp[-1].ConstVector->size())
1441 ThrowException("Type mismatch: constant sized array initialized with " +
1442 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
1443 itostr((int)yyvsp[-6].UInt64Val) + "!");
1445 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
1446 if (yyvsp[-4].TypeVal != (*yyvsp[-1].ConstVector)[i]->getType())
1447 ThrowException("Element #" + utostr(i) + " is not of type '" +
1448 yyvsp[-4].TypeVal->getName() + "' as required!\nIt is of type '" +
1449 (*yyvsp[-1].ConstVector)[i]->getType()->getName() + "'.");
1452 yyval.ConstVal = new ConstPoolArray(AT, *yyvsp[-1].ConstVector);
1453 delete yyvsp[-1].ConstVector;
1457 #line 541 "llvmAsmParser.y"
1459 if (yyvsp[-5].UInt64Val != 0)
1460 ThrowException("Type mismatch: constant sized array initialized with 0"
1461 " arguments, but has size of " + itostr((int)yyvsp[-5].UInt64Val) + "!");
1462 vector<ConstPoolVal*> Empty;
1463 yyval.ConstVal = new ConstPoolArray(ArrayType::getArrayType(yyvsp[-3].TypeVal, 0), Empty);
1467 #line 548 "llvmAsmParser.y"
1469 StructType::ElementTypes Types(yyvsp[-4].TypeList->begin(), yyvsp[-4].TypeList->end());
1470 delete yyvsp[-4].TypeList;
1472 const StructType *St = StructType::getStructType(Types);
1473 yyval.ConstVal = new ConstPoolStruct(St, *yyvsp[-1].ConstVector);
1474 delete yyvsp[-1].ConstVector;
1478 #line 556 "llvmAsmParser.y"
1480 const StructType *St =
1481 StructType::getStructType(StructType::ElementTypes());
1482 vector<ConstPoolVal*> Empty;
1483 yyval.ConstVal = new ConstPoolStruct(St, Empty);
1487 #line 570 "llvmAsmParser.y"
1489 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(addConstValToConstantPool(yyvsp[0].ConstVal));
1493 #line 573 "llvmAsmParser.y"
1495 yyval.ConstVector = new vector<ConstPoolVal*>();
1496 yyval.ConstVector->push_back(addConstValToConstantPool(yyvsp[0].ConstVal));
1500 #line 579 "llvmAsmParser.y"
1502 if (yyvsp[-1].StrVal) {
1503 yyvsp[0].ConstVal->setName(yyvsp[-1].StrVal);
1504 free(yyvsp[-1].StrVal);
1507 addConstValToConstantPool(yyvsp[0].ConstVal);
1511 #line 587 "llvmAsmParser.y"
1516 #line 598 "llvmAsmParser.y"
1518 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
1519 CurModule.ModuleDone();
1523 #line 603 "llvmAsmParser.y"
1525 yyvsp[-1].ModuleVal->getMethodList().push_back(yyvsp[0].MethodVal);
1526 CurMeth.MethodDone();
1527 yyval.ModuleVal = yyvsp[-1].ModuleVal;
1531 #line 608 "llvmAsmParser.y"
1533 yyval.ModuleVal = CurModule.CurrentModule;
1537 #line 617 "llvmAsmParser.y"
1538 { yyval.StrVal = 0; ;
1541 #line 619 "llvmAsmParser.y"
1543 yyval.MethArgVal = new MethodArgument(yyvsp[-1].TypeVal);
1544 if (yyvsp[0].StrVal) { // Was the argument named?
1545 yyval.MethArgVal->setName(yyvsp[0].StrVal);
1546 free(yyvsp[0].StrVal); // The string was strdup'd, so free it now.
1551 #line 627 "llvmAsmParser.y"
1553 yyval.MethodArgList = yyvsp[0].MethodArgList;
1554 yyvsp[0].MethodArgList->push_front(yyvsp[-2].MethArgVal);
1558 #line 631 "llvmAsmParser.y"
1560 yyval.MethodArgList = new list<MethodArgument*>();
1561 yyval.MethodArgList->push_front(yyvsp[0].MethArgVal);
1565 #line 636 "llvmAsmParser.y"
1567 yyval.MethodArgList = yyvsp[0].MethodArgList;
1571 #line 639 "llvmAsmParser.y"
1573 yyval.MethodArgList = 0;
1577 #line 643 "llvmAsmParser.y"
1579 MethodType::ParamTypes ParamTypeList;
1580 if (yyvsp[-1].MethodArgList)
1581 for (list<MethodArgument*>::iterator I = yyvsp[-1].MethodArgList->begin(); I != yyvsp[-1].MethodArgList->end(); ++I)
1582 ParamTypeList.push_back((*I)->getType());
1584 const MethodType *MT = MethodType::getMethodType(yyvsp[-4].TypeVal, ParamTypeList);
1586 Method *M = new Method(MT, yyvsp[-3].StrVal);
1587 free(yyvsp[-3].StrVal); // Free strdup'd memory!
1589 InsertValue(M, CurModule.Values);
1591 CurMeth.MethodStart(M);
1593 // Add all of the arguments we parsed to the method...
1594 if (yyvsp[-1].MethodArgList) { // Is null if empty...
1595 Method::ArgumentListType &ArgList = M->getArgumentList();
1597 for (list<MethodArgument*>::iterator I = yyvsp[-1].MethodArgList->begin(); I != yyvsp[-1].MethodArgList->end(); ++I) {
1599 ArgList.push_back(*I);
1601 delete yyvsp[-1].MethodArgList; // We're now done with the argument list
1606 #line 670 "llvmAsmParser.y"
1608 yyval.MethodVal = CurMeth.CurrentMethod;
1612 #line 674 "llvmAsmParser.y"
1614 yyval.MethodVal = yyvsp[-1].MethodVal;
1618 #line 683 "llvmAsmParser.y"
1619 { // A reference to a direct constant
1620 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
1624 #line 686 "llvmAsmParser.y"
1626 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
1630 #line 689 "llvmAsmParser.y"
1632 yyval.ValIDVal = ValID::create((int64_t)1);
1636 #line 692 "llvmAsmParser.y"
1638 yyval.ValIDVal = ValID::create((int64_t)0);
1642 #line 695 "llvmAsmParser.y"
1643 { // Quoted strings work too... especially for methods
1644 yyval.ValIDVal = ValID::create_conststr(yyvsp[0].StrVal);
1648 #line 700 "llvmAsmParser.y"
1649 { // Is it an integer reference...?
1650 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
1654 #line 703 "llvmAsmParser.y"
1655 { // It must be a named reference then...
1656 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
1660 #line 706 "llvmAsmParser.y"
1662 yyval.ValIDVal = yyvsp[0].ValIDVal;
1666 #line 713 "llvmAsmParser.y"
1668 Value *D = getVal(Type::TypeTy, yyvsp[0].ValIDVal, true);
1669 if (D == 0) ThrowException("Invalid user defined type: " + yyvsp[0].ValIDVal.getName());
1671 // User defined type not in const pool!
1672 ConstPoolType *CPT = (ConstPoolType*)D->castConstantAsserting();
1673 yyval.TypeVal = CPT->getValue();
1677 #line 721 "llvmAsmParser.y"
1678 { // Method derived type?
1679 MethodType::ParamTypes Params(yyvsp[-1].TypeList->begin(), yyvsp[-1].TypeList->end());
1680 delete yyvsp[-1].TypeList;
1681 yyval.TypeVal = MethodType::getMethodType(yyvsp[-3].TypeVal, Params);
1685 #line 726 "llvmAsmParser.y"
1686 { // Method derived type?
1687 MethodType::ParamTypes Params; // Empty list
1688 yyval.TypeVal = MethodType::getMethodType(yyvsp[-2].TypeVal, Params);
1692 #line 730 "llvmAsmParser.y"
1694 yyval.TypeVal = ArrayType::getArrayType(yyvsp[-1].TypeVal);
1698 #line 733 "llvmAsmParser.y"
1700 yyval.TypeVal = ArrayType::getArrayType(yyvsp[-1].TypeVal, (int)yyvsp[-3].UInt64Val);
1704 #line 736 "llvmAsmParser.y"
1706 StructType::ElementTypes Elements(yyvsp[-1].TypeList->begin(), yyvsp[-1].TypeList->end());
1707 delete yyvsp[-1].TypeList;
1708 yyval.TypeVal = StructType::getStructType(Elements);
1712 #line 741 "llvmAsmParser.y"
1714 yyval.TypeVal = StructType::getStructType(StructType::ElementTypes());
1718 #line 744 "llvmAsmParser.y"
1720 yyval.TypeVal = PointerType::getPointerType(yyvsp[-1].TypeVal);
1724 #line 749 "llvmAsmParser.y"
1726 yyval.TypeList = new list<const Type*>();
1727 yyval.TypeList->push_back(yyvsp[0].TypeVal);
1731 #line 753 "llvmAsmParser.y"
1733 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(yyvsp[0].TypeVal);
1737 #line 758 "llvmAsmParser.y"
1739 yyvsp[-1].MethodVal->getBasicBlocks().push_back(yyvsp[0].BasicBlockVal);
1740 yyval.MethodVal = yyvsp[-1].MethodVal;
1744 #line 762 "llvmAsmParser.y"
1745 { // Do not allow methods with 0 basic blocks
1746 yyval.MethodVal = yyvsp[-1].MethodVal; // in them...
1747 yyvsp[-1].MethodVal->getBasicBlocks().push_back(yyvsp[0].BasicBlockVal);
1751 #line 771 "llvmAsmParser.y"
1753 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
1754 InsertValue(yyvsp[-1].BasicBlockVal);
1755 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1759 #line 776 "llvmAsmParser.y"
1761 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
1762 yyvsp[-1].BasicBlockVal->setName(yyvsp[-2].StrVal);
1763 free(yyvsp[-2].StrVal); // Free the strdup'd memory...
1765 InsertValue(yyvsp[-1].BasicBlockVal);
1766 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1770 #line 785 "llvmAsmParser.y"
1772 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
1773 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1777 #line 789 "llvmAsmParser.y"
1779 yyval.BasicBlockVal = new BasicBlock();
1783 #line 793 "llvmAsmParser.y"
1784 { // Return with a result...
1785 yyval.TermInstVal = new ReturnInst(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1789 #line 796 "llvmAsmParser.y"
1790 { // Return with no result...
1791 yyval.TermInstVal = new ReturnInst();
1795 #line 799 "llvmAsmParser.y"
1796 { // Unconditional Branch...
1797 yyval.TermInstVal = new BranchInst((BasicBlock*)getVal(Type::LabelTy, yyvsp[0].ValIDVal));
1801 #line 802 "llvmAsmParser.y"
1803 yyval.TermInstVal = new BranchInst((BasicBlock*)getVal(Type::LabelTy, yyvsp[-3].ValIDVal),
1804 (BasicBlock*)getVal(Type::LabelTy, yyvsp[0].ValIDVal),
1805 getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
1809 #line 807 "llvmAsmParser.y"
1811 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].TypeVal, yyvsp[-6].ValIDVal),
1812 (BasicBlock*)getVal(Type::LabelTy, yyvsp[-3].ValIDVal));
1813 yyval.TermInstVal = S;
1815 list<pair<ConstPoolVal*, BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
1816 end = yyvsp[-1].JumpTable->end();
1817 for (; I != end; ++I)
1818 S->dest_push_back(I->first, I->second);
1822 #line 818 "llvmAsmParser.y"
1824 yyval.JumpTable = yyvsp[-5].JumpTable;
1825 ConstPoolVal *V = (ConstPoolVal*)getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal, true);
1827 ThrowException("May only switch on a constant pool value!");
1829 yyval.JumpTable->push_back(make_pair(V, (BasicBlock*)getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal)));
1833 #line 826 "llvmAsmParser.y"
1835 yyval.JumpTable = new list<pair<ConstPoolVal*, BasicBlock*> >();
1836 ConstPoolVal *V = (ConstPoolVal*)getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal, true);
1839 ThrowException("May only switch on a constant pool value!");
1841 yyval.JumpTable->push_back(make_pair(V, (BasicBlock*)getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal)));
1845 #line 836 "llvmAsmParser.y"
1847 if (yyvsp[-1].StrVal) // Is this definition named??
1848 yyvsp[0].InstVal->setName(yyvsp[-1].StrVal); // if so, assign the name...
1850 InsertValue(yyvsp[0].InstVal);
1851 yyval.InstVal = yyvsp[0].InstVal;
1855 #line 844 "llvmAsmParser.y"
1856 { // Used for PHI nodes
1857 yyval.PHIList = new list<pair<Value*, BasicBlock*> >();
1858 yyval.PHIList->push_back(make_pair(getVal(yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal),
1859 (BasicBlock*)getVal(Type::LabelTy, yyvsp[-1].ValIDVal)));
1863 #line 849 "llvmAsmParser.y"
1865 yyval.PHIList = yyvsp[-6].PHIList;
1866 yyvsp[-6].PHIList->push_back(make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
1867 (BasicBlock*)getVal(Type::LabelTy, yyvsp[-1].ValIDVal)));
1871 #line 856 "llvmAsmParser.y"
1872 { // Used for call statements...
1873 yyval.ValueList = new list<Value*>();
1874 yyval.ValueList->push_back(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1878 #line 860 "llvmAsmParser.y"
1880 yyval.ValueList = yyvsp[-3].ValueList;
1881 yyvsp[-3].ValueList->push_back(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1885 #line 866 "llvmAsmParser.y"
1886 { yyval.ValueList = 0; ;
1889 #line 868 "llvmAsmParser.y"
1891 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
1892 if (yyval.InstVal == 0)
1893 ThrowException("binary operator returned null!");
1897 #line 873 "llvmAsmParser.y"
1899 yyval.InstVal = UnaryOperator::create(yyvsp[-2].UnaryOpVal, getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1900 if (yyval.InstVal == 0)
1901 ThrowException("unary operator returned null!");
1905 #line 878 "llvmAsmParser.y"
1907 if (yyvsp[-1].TypeVal != Type::UByteTy) ThrowException("Shift amount must be ubyte!");
1908 yyval.InstVal = new ShiftInst(yyvsp[-5].OtherOpVal, getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal), getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1912 #line 882 "llvmAsmParser.y"
1914 yyval.InstVal = new CastInst(getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), yyvsp[0].TypeVal);
1918 #line 885 "llvmAsmParser.y"
1920 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
1921 yyval.InstVal = new PHINode(Ty);
1922 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
1923 if (yyvsp[0].PHIList->front().first->getType() != Ty)
1924 ThrowException("All elements of a PHI node must be of the same type!");
1925 ((PHINode*)yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
1926 yyvsp[0].PHIList->pop_front();
1928 delete yyvsp[0].PHIList; // Free the list...
1932 #line 896 "llvmAsmParser.y"
1934 if (!yyvsp[-4].TypeVal->isMethodType())
1935 ThrowException("Can only call methods: invalid type '" +
1936 yyvsp[-4].TypeVal->getName() + "'!");
1938 const MethodType *Ty = (const MethodType*)yyvsp[-4].TypeVal;
1940 Value *V = getVal(Ty, yyvsp[-3].ValIDVal);
1941 if (!V->isMethod() || V->getType() != Ty)
1942 ThrowException("Cannot call: " + yyvsp[-3].ValIDVal.getName() + "!");
1944 // Create or access a new type that corresponds to the function call...
1945 vector<Value *> Params;
1947 if (yyvsp[-1].ValueList) {
1948 // Pull out just the arguments...
1949 Params.insert(Params.begin(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
1950 delete yyvsp[-1].ValueList;
1952 // Loop through MethodType's arguments and ensure they are specified
1955 MethodType::ParamTypes::const_iterator I = Ty->getParamTypes().begin();
1957 for (i = 0; i < Params.size() && I != Ty->getParamTypes().end(); ++i,++I){
1958 if (Params[i]->getType() != *I)
1959 ThrowException("Parameter " + utostr(i) + " is not of type '" +
1960 (*I)->getName() + "'!");
1963 if (i != Params.size() || I != Ty->getParamTypes().end())
1964 ThrowException("Invalid number of parameters detected!");
1967 // Create the call node...
1968 yyval.InstVal = new CallInst((Method*)V, Params);
1972 #line 933 "llvmAsmParser.y"
1974 yyval.InstVal = yyvsp[0].InstVal;
1978 #line 938 "llvmAsmParser.y"
1980 yyval.ConstVector = yyvsp[0].ConstVector;
1984 #line 940 "llvmAsmParser.y"
1986 yyval.ConstVector = new vector<ConstPoolVal*>();
1990 #line 944 "llvmAsmParser.y"
1992 const Type *Ty = PointerType::getPointerType(yyvsp[0].TypeVal);
1993 addConstValToConstantPool(new ConstPoolType(Ty));
1994 yyval.InstVal = new MallocInst(Ty);
1998 #line 949 "llvmAsmParser.y"
2000 if (!yyvsp[-3].TypeVal->isArrayType() || ((const ArrayType*)yyvsp[-3].TypeVal)->isSized())
2001 ThrowException("Trying to allocate " + yyvsp[-3].TypeVal->getName() +
2002 " as unsized array!");
2003 const Type *Ty = PointerType::getPointerType(yyvsp[-3].TypeVal);
2004 addConstValToConstantPool(new ConstPoolType(Ty));
2005 Value *ArrSize = getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
2006 yyval.InstVal = new MallocInst(Ty, ArrSize);
2010 #line 958 "llvmAsmParser.y"
2012 const Type *Ty = PointerType::getPointerType(yyvsp[0].TypeVal);
2013 addConstValToConstantPool(new ConstPoolType(Ty));
2014 yyval.InstVal = new AllocaInst(Ty);
2018 #line 963 "llvmAsmParser.y"
2020 if (!yyvsp[-3].TypeVal->isArrayType() || ((const ArrayType*)yyvsp[-3].TypeVal)->isSized())
2021 ThrowException("Trying to allocate " + yyvsp[-3].TypeVal->getName() +
2022 " as unsized array!");
2023 const Type *Ty = PointerType::getPointerType(yyvsp[-3].TypeVal);
2024 addConstValToConstantPool(new ConstPoolType(Ty));
2025 Value *ArrSize = getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
2026 yyval.InstVal = new AllocaInst(Ty, ArrSize);
2030 #line 972 "llvmAsmParser.y"
2032 if (!yyvsp[-1].TypeVal->isPointerType())
2033 ThrowException("Trying to free nonpointer type " + yyvsp[-1].TypeVal->getName() + "!");
2034 yyval.InstVal = new FreeInst(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
2038 #line 978 "llvmAsmParser.y"
2040 if (!yyvsp[-2].TypeVal->isPointerType())
2041 ThrowException("Can't load from nonpointer type: " + yyvsp[-2].TypeVal->getName());
2042 if (LoadInst::getIndexedType(yyvsp[-2].TypeVal, *yyvsp[0].ConstVector) == 0)
2043 ThrowException("Invalid indices for load instruction!");
2045 yyval.InstVal = new LoadInst(getVal(yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ConstVector);
2046 delete yyvsp[0].ConstVector; // Free the vector...
2050 #line 987 "llvmAsmParser.y"
2052 if (!yyvsp[-2].TypeVal->isPointerType())
2053 ThrowException("Can't store to a nonpointer type: " + yyvsp[-2].TypeVal->getName());
2054 const Type *ElTy = StoreInst::getIndexedType(yyvsp[-2].TypeVal, *yyvsp[0].ConstVector);
2056 ThrowException("Can't store into that field list!");
2057 if (ElTy != yyvsp[-5].TypeVal)
2058 ThrowException("Can't store '" + yyvsp[-5].TypeVal->getName() + "' into space of type '"+
2059 ElTy->getName() + "'!");
2060 yyval.InstVal = new StoreInst(getVal(yyvsp[-5].TypeVal, yyvsp[-4].ValIDVal), getVal(yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ConstVector);
2061 delete yyvsp[0].ConstVector;
2065 #line 999 "llvmAsmParser.y"
2067 if (!yyvsp[-2].TypeVal->isPointerType())
2068 ThrowException("getelementptr insn requires pointer operand!");
2069 if (!GetElementPtrInst::getIndexedType(yyvsp[-2].TypeVal, *yyvsp[0].ConstVector, true))
2070 ThrowException("Can't get element ptr '" + yyvsp[-2].TypeVal->getName() + "'!");
2071 yyval.InstVal = new GetElementPtrInst(getVal(yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ConstVector);
2072 delete yyvsp[0].ConstVector;
2073 addConstValToConstantPool(new ConstPoolType(yyval.InstVal->getType()));
2077 /* the action file gets copied in in place of this dollarsign */
2078 #line 543 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
2089 short *ssp1 = yyss - 1;
2090 fprintf (stderr, "state stack now");
2091 while (ssp1 != yyssp)
2092 fprintf (stderr, " %d", *++ssp1);
2093 fprintf (stderr, "\n");
2103 yylsp->first_line = yylloc.first_line;
2104 yylsp->first_column = yylloc.first_column;
2105 yylsp->last_line = (yylsp-1)->last_line;
2106 yylsp->last_column = (yylsp-1)->last_column;
2111 yylsp->last_line = (yylsp+yylen-1)->last_line;
2112 yylsp->last_column = (yylsp+yylen-1)->last_column;
2116 /* Now "shift" the result of the reduction.
2117 Determine what state that goes to,
2118 based on the state we popped back to
2119 and the rule number reduced by. */
2123 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
2124 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2125 yystate = yytable[yystate];
2127 yystate = yydefgoto[yyn - YYNTBASE];
2131 yyerrlab: /* here on detecting error */
2134 /* If not already recovering from an error, report this error. */
2138 #ifdef YYERROR_VERBOSE
2139 yyn = yypact[yystate];
2141 if (yyn > YYFLAG && yyn < YYLAST)
2148 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
2149 for (x = (yyn < 0 ? -yyn : 0);
2150 x < (sizeof(yytname) / sizeof(char *)); x++)
2151 if (yycheck[x + yyn] == x)
2152 size += strlen(yytname[x]) + 15, count++;
2153 msg = (char *) malloc(size + 15);
2156 strcpy(msg, "parse error");
2161 for (x = (yyn < 0 ? -yyn : 0);
2162 x < (sizeof(yytname) / sizeof(char *)); x++)
2163 if (yycheck[x + yyn] == x)
2165 strcat(msg, count == 0 ? ", expecting `" : " or `");
2166 strcat(msg, yytname[x]);
2175 yyerror ("parse error; also virtual memory exceeded");
2178 #endif /* YYERROR_VERBOSE */
2179 yyerror("parse error");
2183 yyerrlab1: /* here on error raised explicitly by an action */
2185 if (yyerrstatus == 3)
2187 /* if just tried and failed to reuse lookahead token after an error, discard it. */
2189 /* return failure if at end of input */
2190 if (yychar == YYEOF)
2195 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
2201 /* Else will try to reuse lookahead token
2202 after shifting the error token. */
2204 yyerrstatus = 3; /* Each real token shifted decrements this */
2208 yyerrdefault: /* current state does not do anything special for the error token. */
2211 /* This is wrong; only states that explicitly want error tokens
2212 should shift them. */
2213 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
2214 if (yyn) goto yydefault;
2217 yyerrpop: /* pop the current state because it cannot handle the error token */
2219 if (yyssp == yyss) YYABORT;
2229 short *ssp1 = yyss - 1;
2230 fprintf (stderr, "Error: state stack now");
2231 while (ssp1 != yyssp)
2232 fprintf (stderr, " %d", *++ssp1);
2233 fprintf (stderr, "\n");
2239 yyn = yypact[yystate];
2244 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
2263 fprintf(stderr, "Shifting error token, ");
2275 /* YYACCEPT comes here. */
2287 /* YYABORT comes here. */
2298 #line 1009 "llvmAsmParser.y"
2300 int yyerror(const char *ErrorMsg) {
2301 ThrowException(string("Parse error: ") + ErrorMsg);