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
71 #line 13 "llvmAsmParser.y"
73 #include "ParserInternals.h"
74 #include "llvm/BasicBlock.h"
75 #include "llvm/Method.h"
76 #include "llvm/SymbolTable.h"
77 #include "llvm/Module.h"
78 #include "llvm/Type.h"
79 #include "llvm/DerivedTypes.h"
80 #include "llvm/Assembly/Parser.h"
81 #include "llvm/ConstantPool.h"
82 #include "llvm/iTerminators.h"
83 #include "llvm/iMemory.h"
85 #include <utility> // Get definition of pair class
86 #include <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);
375 //===----------------------------------------------------------------------===//
376 // RunVMAsmParser - Define an interface to this parser
377 //===----------------------------------------------------------------------===//
379 Module *RunVMAsmParser(const ToolCommandLine &Opts, FILE *F) {
382 llvmAsmlineno = 1; // Reset the current line number...
384 CurModule.CurrentModule = new Module(); // Allocate a new module to read
385 yyparse(); // Parse the file.
386 Module *Result = ParserResult;
388 llvmAsmin = stdin; // F is about to go away, don't use it anymore...
395 #line 337 "llvmAsmParser.y"
399 MethodArgument *MethArgVal;
400 BasicBlock *BasicBlockVal;
401 TerminatorInst *TermInstVal;
402 Instruction *InstVal;
403 ConstPoolVal *ConstVal;
406 list<MethodArgument*> *MethodArgList;
407 list<Value*> *ValueList;
408 list<const Type*> *TypeList;
409 list<pair<Value*, BasicBlock*> > *PHIList; // Represent the RHS of PHI node
410 list<pair<ConstPoolVal*, BasicBlock*> > *JumpTable;
411 vector<ConstPoolVal*> *ConstVector;
418 char *StrVal; // This memory is allocated by strdup!
419 ValID ValIDVal; // May contain memory allocated by strdup
421 Instruction::UnaryOps UnaryOpVal;
422 Instruction::BinaryOps BinaryOpVal;
423 Instruction::TermOps TermOpVal;
424 Instruction::MemoryOps MemOpVal;
425 Instruction::OtherOps OtherOpVal;
438 #define YYFLAG -32768
441 #define YYTRANSLATE(x) ((unsigned)(x) <= 312 ? yytranslate[x] : 107)
443 static const char yytranslate[] = { 0,
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, 2,
447 2, 2, 2, 2, 2, 2, 2, 2, 2, 66,
448 67, 68, 2, 65, 2, 2, 2, 2, 2, 2,
449 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
450 59, 2, 2, 2, 2, 2, 2, 2, 2, 2,
451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
453 60, 2, 61, 2, 2, 2, 2, 2, 2, 2,
454 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
455 2, 2, 2, 2, 2, 2, 2, 2, 2, 62,
456 2, 2, 63, 2, 64, 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, 2, 2, 2, 2, 2,
469 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
470 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
471 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
472 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
473 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
474 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
479 static const short yyprhs[] = { 0,
480 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
481 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
482 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
483 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
484 80, 82, 84, 86, 88, 91, 92, 95, 98, 101,
485 104, 107, 110, 117, 123, 132, 140, 147, 152, 156,
486 158, 162, 163, 165, 168, 171, 173, 174, 177, 181,
487 183, 185, 186, 192, 196, 199, 201, 203, 205, 207,
488 209, 211, 213, 215, 217, 222, 226, 230, 236, 240,
489 243, 246, 248, 252, 255, 258, 261, 265, 268, 269,
490 273, 276, 280, 290, 300, 307, 313, 316, 323, 331,
491 334, 338, 340, 341, 347, 351, 358, 364, 367, 374,
492 376, 379, 380, 383, 389, 392, 398, 402
495 static const short yyrhs[] = { 5,
496 0, 6, 0, 3, 0, 4, 0, 8, 0, 9,
497 0, 10, 0, 11, 0, 12, 0, 13, 0, 14,
498 0, 15, 0, 16, 0, 17, 0, 18, 0, 19,
499 0, 20, 0, 21, 0, 71, 0, 7, 0, 35,
500 0, 36, 0, 37, 0, 38, 0, 39, 0, 40,
501 0, 41, 0, 42, 0, 43, 0, 44, 0, 45,
502 0, 46, 0, 57, 0, 58, 0, 15, 0, 13,
503 0, 11, 0, 9, 0, 16, 0, 14, 0, 12,
504 0, 10, 0, 76, 0, 77, 0, 22, 59, 0,
505 0, 76, 70, 0, 77, 4, 0, 8, 26, 0,
506 8, 27, 0, 19, 24, 0, 20, 71, 0, 60,
507 71, 61, 60, 81, 61, 0, 60, 71, 61, 60,
508 61, 0, 60, 4, 62, 71, 61, 60, 81, 61,
509 0, 60, 4, 62, 71, 61, 60, 61, 0, 63,
510 94, 64, 63, 81, 64, 0, 63, 64, 63, 64,
511 0, 81, 65, 80, 0, 80, 0, 82, 79, 80,
512 0, 0, 84, 0, 84, 91, 0, 82, 25, 0,
513 22, 0, 0, 71, 85, 0, 86, 65, 87, 0,
514 86, 0, 87, 0, 0, 72, 24, 66, 88, 67,
515 0, 89, 82, 28, 0, 95, 29, 0, 3, 0,
516 4, 0, 26, 0, 27, 0, 24, 0, 69, 0,
517 22, 0, 92, 0, 93, 0, 72, 66, 94, 67,
518 0, 72, 66, 67, 0, 60, 71, 61, 0, 60,
519 4, 62, 71, 61, 0, 63, 94, 64, 0, 63,
520 64, 0, 71, 68, 0, 71, 0, 94, 65, 71,
521 0, 95, 96, 0, 90, 96, 0, 97, 98, 0,
522 23, 97, 98, 0, 97, 100, 0, 0, 32, 71,
523 93, 0, 32, 7, 0, 33, 21, 93, 0, 33,
524 8, 93, 65, 21, 93, 65, 21, 93, 0, 34,
525 78, 93, 65, 21, 93, 60, 99, 61, 0, 99,
526 78, 92, 65, 21, 93, 0, 78, 92, 65, 21,
527 93, 0, 79, 104, 0, 71, 60, 93, 65, 93,
528 61, 0, 101, 65, 60, 93, 65, 93, 61, 0,
529 71, 93, 0, 102, 65, 93, 0, 102, 0, 0,
530 74, 71, 93, 65, 93, 0, 73, 71, 93, 0,
531 75, 71, 93, 65, 71, 93, 0, 56, 71, 93,
532 31, 71, 0, 54, 101, 0, 55, 71, 93, 66,
533 103, 67, 0, 106, 0, 65, 81, 0, 0, 47,
534 71, 0, 47, 71, 65, 14, 93, 0, 48, 71,
535 0, 48, 71, 65, 14, 93, 0, 49, 71, 93,
536 0, 50, 71, 93, 105, 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
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 "GETFIELD","PUTFIELD","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 69, 69, 70, 70, 71, 71, 71, 71, 71, 71,
581 71, 71, 71, 71, 71, 71, 71, 71, 72, 72,
582 73, 74, 74, 74, 74, 74, 74, 74, 74, 74,
583 74, 74, 75, 75, 76, 76, 76, 76, 77, 77,
584 77, 77, 78, 78, 79, 79, 80, 80, 80, 80,
585 80, 80, 80, 80, 80, 80, 80, 80, 81, 81,
586 82, 82, 83, 84, 84, 85, 85, 86, 87, 87,
587 88, 88, 89, 90, 91, 92, 92, 92, 92, 92,
588 93, 93, 93, 71, 71, 71, 71, 71, 71, 71,
589 71, 94, 94, 95, 95, 96, 96, 97, 97, 98,
590 98, 98, 98, 98, 99, 99, 100, 101, 101, 102,
591 102, 103, 103, 104, 104, 104, 104, 104, 104, 104,
592 105, 105, 106, 106, 106, 106, 106, 106
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 3, 1, 0, 5, 3, 6, 5, 2, 6, 1,
608 2, 0, 2, 5, 2, 5, 3, 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, 33, 34, 0, 0,
626 0, 107, 120, 19, 0, 58, 0, 88, 66, 68,
627 0, 73, 100, 0, 102, 0, 123, 125, 19, 19,
628 19, 118, 19, 19, 19, 19, 19, 0, 54, 60,
629 0, 0, 69, 0, 0, 0, 0, 127, 122, 0,
630 0, 0, 0, 115, 0, 0, 0, 53, 0, 57,
631 0, 0, 0, 0, 0, 128, 0, 0, 113, 0,
632 0, 0, 56, 0, 59, 0, 0, 124, 126, 121,
633 0, 0, 19, 112, 0, 117, 114, 19, 55, 0,
634 0, 0, 0, 110, 0, 119, 116, 0, 0, 0,
635 108, 0, 111, 103, 0, 104, 0, 109, 0, 0,
636 0, 0, 106, 0, 105, 0, 0, 0
639 static const short yydefgoto[] = { 31,
640 82, 61, 59, 139, 140, 141, 54, 55, 117, 5,
641 170, 171, 1, 246, 2, 150, 106, 107, 108, 34,
642 35, 36, 37, 38, 62, 39, 68, 69, 97, 230,
643 98, 162, 214, 215, 142, 196, 143
646 static const short yypact[] = {-32768,
647 19, 342, -51,-32768, 99,-32768,-32768,-32768,-32768,-32768,
648 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
649 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 403, 255,
650 -32768, -3, -18,-32768, 142,-32768,-32768,-32768, 55,-32768,
651 68,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 117,
652 342, 428, 317, 118, 163,-32768, 131, 59, 112,-32768,
653 11, 61,-32768, 129, 230, 95,-32768,-32768, 124,-32768,
654 -32768,-32768,-32768,-32768, 11, 134, 82, 139, 96,-32768,
655 -32768,-32768,-32768, 342,-32768,-32768, 342, 342,-32768, 75,
656 -32768, 124, 489, 16, 160, 482,-32768,-32768, 342, 143,
657 140, 144, 116, 11, 21, 145,-32768, 138,-32768,-32768,
658 146, -1, 66, 66,-32768,-32768, 66,-32768,-32768,-32768,
659 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 342,
660 342, 342, 342, 342, 342, 342,-32768,-32768, 342, 342,
661 342,-32768,-32768, 122, 20,-32768, 99,-32768,-32768,-32768,
662 342,-32768,-32768, 149,-32768, 150, 98, 126, -1, -1,
663 6, 152, -1, -1, -1, -1, -1, 148,-32768,-32768,
664 -54, 123,-32768, 188, 197, 205, 206,-32768, 156, 66,
665 162, 157, 193,-32768, 161, 165, 43,-32768, 99,-32768,
666 66, 66, 66, 66, 99,-32768, 166, 66, 342, 342,
667 66, 342,-32768, -19,-32768, 190, 167,-32768,-32768, 213,
668 66, 215, -1, 218, 158, 11,-32768, -1,-32768, 207,
669 160, 192, 66,-32768, 66,-32768,-32768, 66, 72, 3,
670 -32768, 223,-32768,-32768, 220,-32768, 72,-32768, 265, 222,
671 66, 267,-32768, 66,-32768, 289, 291,-32768
674 static const short yypgoto[] = {-32768,
675 -32768, -2, 290,-32768,-32768,-32768, -86, -85, -183, -47,
676 -4, -127, 260,-32768,-32768,-32768,-32768, 147,-32768,-32768,
677 -32768,-32768, -113, -12, 8,-32768, 256, 229, 208,-32768,
678 -32768,-32768,-32768,-32768,-32768,-32768,-32768
685 static const short yytable[] = { 32,
686 56, 6, 7, 8, 9, 64, 188, 40, 115, 116,
687 189, 42, 43, 44, 45, 46, 47, 48, 49, 172,
688 25, 96, 26, 113, 27, 28, 58, 41, 42, 43,
689 44, 45, 46, 47, 48, 49, 114, 229, 50, 51,
690 3, 219, 149, 4, 96, 189, 237, 65, 75, 77,
691 41, 42, 43, 44, 45, 46, 47, 48, 49, 204,
692 79, 50, 51, 236, 63, 180, 63, 210, 6, 7,
693 8, 9, 90, 63, 6, 7, -19, 67, 63, 52,
694 169, 103, 53, 70, 104, 105, -19, 25, 63, 26,
695 112, 27, 28, 72, 73, 26, 144, 27, 28, 153,
696 154, 155, 52, 203, 156, 53, 41, 42, 43, 44,
697 45, 46, 47, 48, 49, 235, 3, 50, 51, 85,
698 80, 81, 91, 240, 86, 87, 63, 157, 158, 159,
699 160, 161, 163, 164, 115, 116, 165, 166, 167, 87,
700 74, 109, 100, 115, 116, 3, 178, 179, 105, 63,
701 182, 183, 184, 185, 186, 93, 94, 95, 52, 102,
702 87, 53, 176, -19, 67, 63, 83, 197, 42, 43,
703 44, 45, 46, 47, 48, 49, 148, 65, 206, 207,
704 208, 209, 168, 63, 205, 212, 190, 189, 217, 63,
705 177, -19, 84, 63, 88, 99, 213, 216, 222, 218,
706 224, 101, 145, 146, 152, 227, 147, 187, 191, 151,
707 232, -20, 233, 174, 175, 234, 181, 192, 193, 194,
708 195, 198, 199, 200, 226, 201, 221, 228, 243, 202,
709 211, 245, 6, 7, 8, 9, 10, 11, 12, 13,
710 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
711 24, 25, 231, 26, 220, 27, 28, 6, 7, 8,
712 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
713 19, 20, 21, 22, 23, 24, 25, 189, 26, 223,
714 27, 28, 225, 238, 239, 241, 242, 244, 247, 29,
715 248, 33, 30, 66, 71, 92, 89, 173, 0, 110,
716 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
717 0, 0, 0, 0, 29, 0, 0, 30, 60, 6,
718 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
719 17, 18, 19, 20, 21, 22, 23, 24, 25, 0,
720 26, 0, 27, 28, 6, 7, 8, 9, 10, 11,
721 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
722 22, 23, 24, 25, 0, 26, 0, 27, 28, 0,
723 0, 0, 0, 0, 0, 0, 29, 0, 0, 30,
724 78, 0, 0, 0, 0, 0, 0, 0, 0, 0,
725 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
726 0, 29, 0, 0, 30, 6, 57, 8, 9, 10,
727 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
728 21, 22, 23, 24, 25, 0, 26, 0, 27, 28,
729 6, 76, 8, 9, 10, 11, 12, 13, 14, 15,
730 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
731 0, 26, 0, 27, 28, 0, 0, 0, 0, 0,
732 0, 0, 29, 0, 0, 30, 0, 0, 0, 0,
733 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
734 0, 0, 0, 0, 0, 0, 0, 29, 0, 0,
735 30, 6, 7, 8, 9, 111, 11, 12, 13, 14,
736 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
737 25, 0, 26, 0, 27, 28, 118, 119, 120, 121,
738 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
739 132, 133, 0, 0, 0, 134, 135, 136, 137, 138,
740 0, 0, 0, 0, 0, 0, 0, 0, 29, 0,
744 static const short yycheck[] = { 2,
745 5, 3, 4, 5, 6, 24, 61, 59, 95, 95,
746 65, 9, 10, 11, 12, 13, 14, 15, 16, 147,
747 22, 69, 24, 8, 26, 27, 29, 8, 9, 10,
748 11, 12, 13, 14, 15, 16, 21, 221, 19, 20,
749 22, 61, 22, 25, 92, 65, 230, 66, 51, 52,
750 8, 9, 10, 11, 12, 13, 14, 15, 16, 187,
751 53, 19, 20, 61, 68, 60, 68, 195, 3, 4,
752 5, 6, 65, 68, 3, 4, 66, 23, 68, 60,
753 61, 84, 63, 29, 87, 88, 66, 22, 68, 24,
754 93, 26, 27, 26, 27, 24, 99, 26, 27, 112,
755 113, 114, 60, 61, 117, 63, 8, 9, 10, 11,
756 12, 13, 14, 15, 16, 229, 22, 19, 20, 61,
757 3, 4, 28, 237, 64, 65, 68, 130, 131, 132,
758 133, 134, 135, 136, 221, 221, 139, 140, 141, 65,
759 24, 67, 61, 230, 230, 22, 159, 160, 151, 68,
760 163, 164, 165, 166, 167, 32, 33, 34, 60, 64,
761 65, 63, 65, 66, 23, 68, 4, 180, 9, 10,
762 11, 12, 13, 14, 15, 16, 61, 66, 191, 192,
763 193, 194, 61, 68, 189, 198, 64, 65, 201, 68,
764 65, 66, 62, 68, 66, 62, 199, 200, 211, 202,
765 213, 63, 60, 64, 67, 218, 63, 60, 21, 65,
766 223, 66, 225, 65, 65, 228, 65, 21, 14, 14,
767 65, 60, 66, 31, 67, 65, 60, 21, 241, 65,
768 65, 244, 3, 4, 5, 6, 7, 8, 9, 10,
769 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
770 21, 22, 61, 24, 65, 26, 27, 3, 4, 5,
771 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
772 16, 17, 18, 19, 20, 21, 22, 65, 24, 65,
773 26, 27, 65, 61, 65, 21, 65, 21, 0, 60,
774 0, 2, 63, 34, 39, 67, 67, 151, -1, 92,
775 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
776 -1, -1, -1, -1, 60, -1, -1, 63, 64, 3,
777 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
778 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
779 24, -1, 26, 27, 3, 4, 5, 6, 7, 8,
780 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
781 19, 20, 21, 22, -1, 24, -1, 26, 27, -1,
782 -1, -1, -1, -1, -1, -1, 60, -1, -1, 63,
783 64, -1, -1, -1, -1, -1, -1, -1, -1, -1,
784 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
785 -1, 60, -1, -1, 63, 3, 4, 5, 6, 7,
786 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
787 18, 19, 20, 21, 22, -1, 24, -1, 26, 27,
788 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
789 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
790 -1, 24, -1, 26, 27, -1, -1, -1, -1, -1,
791 -1, -1, 60, -1, -1, 63, -1, -1, -1, -1,
792 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
793 -1, -1, -1, -1, -1, -1, -1, 60, -1, -1,
794 63, 3, 4, 5, 6, 7, 8, 9, 10, 11,
795 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
796 22, -1, 24, -1, 26, 27, 35, 36, 37, 38,
797 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
798 49, 50, -1, -1, -1, 54, 55, 56, 57, 58,
799 -1, -1, -1, -1, -1, -1, -1, -1, 60, -1,
802 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
803 #line 3 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
804 /* This file comes from bison-1.28. */
806 /* Skeleton output parser for bison,
807 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
809 This program is free software; you can redistribute it and/or modify
810 it under the terms of the GNU General Public License as published by
811 the Free Software Foundation; either version 2, or (at your option)
814 This program is distributed in the hope that it will be useful,
815 but WITHOUT ANY WARRANTY; without even the implied warranty of
816 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
817 GNU General Public License for more details.
819 You should have received a copy of the GNU General Public License
820 along with this program; if not, write to the Free Software
821 Foundation, Inc., 59 Temple Place - Suite 330,
822 Boston, MA 02111-1307, USA. */
824 /* As a special exception, when this file is copied by Bison into a
825 Bison output file, you may use that output file without restriction.
826 This special exception was added by the Free Software Foundation
827 in version 1.24 of Bison. */
829 /* This is the parser code that is written into each bison parser
830 when the %semantic_parser declaration is not specified in the grammar.
831 It was written by Richard Stallman by simplifying the hairy parser
832 used when %semantic_parser is specified. */
834 #ifndef YYSTACK_USE_ALLOCA
836 #define YYSTACK_USE_ALLOCA
837 #else /* alloca not defined */
839 #define YYSTACK_USE_ALLOCA
840 #define alloca __builtin_alloca
841 #else /* not GNU C. */
842 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
843 #define YYSTACK_USE_ALLOCA
845 #else /* not sparc */
846 /* We think this test detects Watcom and Microsoft C. */
847 /* This used to test MSDOS, but that is a bad idea
848 since that symbol is in the user namespace. */
849 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
850 #if 0 /* No need for malloc.h, which pollutes the namespace;
851 instead, just don't use alloca. */
854 #else /* not MSDOS, or __TURBOC__ */
856 /* I don't know what this was needed for, but it pollutes the namespace.
857 So I turned it off. rms, 2 May 1997. */
858 /* #include <malloc.h> */
860 #define YYSTACK_USE_ALLOCA
861 #else /* not MSDOS, or __TURBOC__, or _AIX */
863 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
864 and on HPUX 10. Eventually we can turn this on. */
865 #define YYSTACK_USE_ALLOCA
866 #define alloca __builtin_alloca
869 #endif /* not _AIX */
870 #endif /* not MSDOS, or __TURBOC__ */
871 #endif /* not sparc */
872 #endif /* not GNU C */
873 #endif /* alloca not defined */
874 #endif /* YYSTACK_USE_ALLOCA not defined */
876 #ifdef YYSTACK_USE_ALLOCA
877 #define YYSTACK_ALLOC alloca
879 #define YYSTACK_ALLOC malloc
882 /* Note: there must be only one dollar sign in this file.
883 It is replaced by the list of actions, each action
884 as one case of the switch. */
886 #define yyerrok (yyerrstatus = 0)
887 #define yyclearin (yychar = YYEMPTY)
890 #define YYACCEPT goto yyacceptlab
891 #define YYABORT goto yyabortlab
892 #define YYERROR goto yyerrlab1
893 /* Like YYERROR except do call yyerror.
894 This remains here temporarily to ease the
895 transition to the new meaning of YYERROR, for GCC.
896 Once GCC version 2 has supplanted version 1, this can go. */
897 #define YYFAIL goto yyerrlab
898 #define YYRECOVERING() (!!yyerrstatus)
899 #define YYBACKUP(token, value) \
901 if (yychar == YYEMPTY && yylen == 1) \
902 { yychar = (token), yylval = (value); \
903 yychar1 = YYTRANSLATE (yychar); \
908 { yyerror ("syntax error: cannot back up"); YYERROR; } \
912 #define YYERRCODE 256
915 #define YYLEX yylex()
921 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
923 #define YYLEX yylex(&yylval, &yylloc)
925 #else /* not YYLSP_NEEDED */
927 #define YYLEX yylex(&yylval, YYLEX_PARAM)
929 #define YYLEX yylex(&yylval)
931 #endif /* not YYLSP_NEEDED */
934 /* If nonreentrant, generate the variables here */
938 int yychar; /* the lookahead symbol */
939 YYSTYPE yylval; /* the semantic value of the */
940 /* lookahead symbol */
943 YYLTYPE yylloc; /* location data for the lookahead */
947 int yynerrs; /* number of parse errors so far */
948 #endif /* not YYPURE */
951 int yydebug; /* nonzero means print parse trace */
952 /* Since this is uninitialized, it does not stop multiple parsers
956 /* YYINITDEPTH indicates the initial size of the parser's stacks */
959 #define YYINITDEPTH 200
962 /* YYMAXDEPTH is the maximum size the stacks can grow to
963 (effective only if the built-in stack extension method is used). */
970 #define YYMAXDEPTH 10000
973 /* Define __yy_memcpy. Note that the size argument
974 should be passed with type unsigned int, because that is what the non-GCC
975 definitions require. With GCC, __builtin_memcpy takes an arg
976 of type size_t, but it can handle unsigned int. */
978 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
979 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
980 #else /* not GNU C or C++ */
983 /* This is the most reliable way to avoid incompatibilities
984 in available built-in functions on various systems. */
986 __yy_memcpy (to, from, count)
991 register char *f = from;
992 register char *t = to;
993 register int i = count;
999 #else /* __cplusplus */
1001 /* This is the most reliable way to avoid incompatibilities
1002 in available built-in functions on various systems. */
1004 __yy_memcpy (char *to, char *from, unsigned int count)
1006 register char *t = to;
1007 register char *f = from;
1008 register int i = count;
1017 #line 217 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
1019 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
1020 into yyparse. The argument should have type void *.
1021 It should actually point to an object.
1022 Grammar actions can access the variable by casting it
1023 to the proper pointer type. */
1025 #ifdef YYPARSE_PARAM
1027 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1028 #define YYPARSE_PARAM_DECL
1029 #else /* not __cplusplus */
1030 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1031 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1032 #endif /* not __cplusplus */
1033 #else /* not YYPARSE_PARAM */
1034 #define YYPARSE_PARAM_ARG
1035 #define YYPARSE_PARAM_DECL
1036 #endif /* not YYPARSE_PARAM */
1038 /* Prevent warning if -Wstrict-prototypes. */
1040 #ifdef YYPARSE_PARAM
1041 int yyparse (void *);
1048 yyparse(YYPARSE_PARAM_ARG)
1051 register int yystate;
1053 register short *yyssp;
1054 register YYSTYPE *yyvsp;
1055 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1056 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
1058 short yyssa[YYINITDEPTH]; /* the state stack */
1059 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
1061 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1062 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
1065 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1066 YYLTYPE *yyls = yylsa;
1069 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1071 #define YYPOPSTACK (yyvsp--, yyssp--)
1074 int yystacksize = YYINITDEPTH;
1075 int yyfree_stacks = 0;
1086 YYSTYPE yyval; /* the variable used to return */
1087 /* semantic values from the action */
1094 fprintf(stderr, "Starting parse\n");
1100 yychar = YYEMPTY; /* Cause a token to be read. */
1102 /* Initialize stack pointers.
1103 Waste one element of value and location stack
1104 so that they stay on the same level as the state stack.
1105 The wasted elements are never initialized. */
1113 /* Push a new state, which is found in yystate . */
1114 /* In all cases, when you get here, the value and location stacks
1115 have just been pushed. so pushing a state here evens the stacks. */
1120 if (yyssp >= yyss + yystacksize - 1)
1122 /* Give user a chance to reallocate the stack */
1123 /* Use copies of these so that the &'s don't force the real ones into memory. */
1124 YYSTYPE *yyvs1 = yyvs;
1125 short *yyss1 = yyss;
1127 YYLTYPE *yyls1 = yyls;
1130 /* Get the current used size of the three stacks, in elements. */
1131 int size = yyssp - yyss + 1;
1134 /* Each stack pointer address is followed by the size of
1135 the data in use in that stack, in bytes. */
1137 /* This used to be a conditional around just the two extra args,
1138 but that might be undefined if yyoverflow is a macro. */
1139 yyoverflow("parser stack overflow",
1140 &yyss1, size * sizeof (*yyssp),
1141 &yyvs1, size * sizeof (*yyvsp),
1142 &yyls1, size * sizeof (*yylsp),
1145 yyoverflow("parser stack overflow",
1146 &yyss1, size * sizeof (*yyssp),
1147 &yyvs1, size * sizeof (*yyvsp),
1151 yyss = yyss1; yyvs = yyvs1;
1155 #else /* no yyoverflow */
1156 /* Extend the stack our own way. */
1157 if (yystacksize >= YYMAXDEPTH)
1159 yyerror("parser stack overflow");
1171 if (yystacksize > YYMAXDEPTH)
1172 yystacksize = YYMAXDEPTH;
1173 #ifndef YYSTACK_USE_ALLOCA
1176 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
1177 __yy_memcpy ((char *)yyss, (char *)yyss1,
1178 size * (unsigned int) sizeof (*yyssp));
1179 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
1180 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
1181 size * (unsigned int) sizeof (*yyvsp));
1183 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
1184 __yy_memcpy ((char *)yyls, (char *)yyls1,
1185 size * (unsigned int) sizeof (*yylsp));
1187 #endif /* no yyoverflow */
1189 yyssp = yyss + size - 1;
1190 yyvsp = yyvs + size - 1;
1192 yylsp = yyls + size - 1;
1197 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
1200 if (yyssp >= yyss + yystacksize - 1)
1206 fprintf(stderr, "Entering state %d\n", yystate);
1212 /* Do appropriate processing given the current state. */
1213 /* Read a lookahead token if we need one and don't already have one. */
1216 /* First try to decide what to do without reference to lookahead token. */
1218 yyn = yypact[yystate];
1222 /* Not known => get a lookahead token if don't already have one. */
1224 /* yychar is either YYEMPTY or YYEOF
1225 or a valid token in external form. */
1227 if (yychar == YYEMPTY)
1231 fprintf(stderr, "Reading a token: ");
1236 /* Convert token to internal form (in yychar1) for indexing tables with */
1238 if (yychar <= 0) /* This means end of input. */
1241 yychar = YYEOF; /* Don't call YYLEX any more */
1245 fprintf(stderr, "Now at end of input.\n");
1250 yychar1 = YYTRANSLATE(yychar);
1255 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
1256 /* Give the individual parser a way to print the precise meaning
1257 of a token, for further debugging info. */
1259 YYPRINT (stderr, yychar, yylval);
1261 fprintf (stderr, ")\n");
1267 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
1272 /* yyn is what to do for this token type in this state.
1273 Negative => reduce, -yyn is rule number.
1274 Positive => shift, yyn is new state.
1275 New state is final state => don't bother to shift,
1276 just return success.
1277 0, or most negative number => error. */
1292 /* Shift the lookahead token. */
1296 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1299 /* Discard the token being shifted unless it is eof. */
1300 if (yychar != YYEOF)
1308 /* count tokens shifted since error; after three, turn off error status. */
1309 if (yyerrstatus) yyerrstatus--;
1314 /* Do the default action for the current state. */
1317 yyn = yydefact[yystate];
1321 /* Do a reduction. yyn is the number of a rule to reduce with. */
1325 yyval = yyvsp[1-yylen]; /* implement default value of the action */
1332 fprintf (stderr, "Reducing via rule %d (line %d), ",
1335 /* Print the symbols being reduced, and their result. */
1336 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1337 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1338 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1346 #line 435 "llvmAsmParser.y"
1348 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
1349 ThrowException("Value too large for type!");
1350 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
1354 #line 443 "llvmAsmParser.y"
1356 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
1357 ThrowException("Value too large for type!");
1358 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
1362 #line 474 "llvmAsmParser.y"
1364 yyval.StrVal = yyvsp[-1].StrVal;
1368 #line 477 "llvmAsmParser.y"
1374 #line 481 "llvmAsmParser.y"
1375 { // integral constants
1376 if (!ConstPoolSInt::isValueValidForType(yyvsp[-1].TypeVal, yyvsp[0].SInt64Val))
1377 ThrowException("Constant value doesn't fit in type!");
1378 yyval.ConstVal = new ConstPoolSInt(yyvsp[-1].TypeVal, yyvsp[0].SInt64Val);
1382 #line 486 "llvmAsmParser.y"
1383 { // integral constants
1384 if (!ConstPoolUInt::isValueValidForType(yyvsp[-1].TypeVal, yyvsp[0].UInt64Val))
1385 ThrowException("Constant value doesn't fit in type!");
1386 yyval.ConstVal = new ConstPoolUInt(yyvsp[-1].TypeVal, yyvsp[0].UInt64Val);
1390 #line 491 "llvmAsmParser.y"
1391 { // Boolean constants
1392 yyval.ConstVal = new ConstPoolBool(true);
1396 #line 494 "llvmAsmParser.y"
1397 { // Boolean constants
1398 yyval.ConstVal = new ConstPoolBool(false);
1402 #line 497 "llvmAsmParser.y"
1403 { // String constants
1404 cerr << "FIXME: TODO: String constants [sbyte] not implemented yet!\n";
1406 //$$ = new ConstPoolString($2);
1407 free(yyvsp[0].StrVal);
1411 #line 503 "llvmAsmParser.y"
1413 yyval.ConstVal = new ConstPoolType(yyvsp[0].TypeVal);
1417 #line 506 "llvmAsmParser.y"
1418 { // Nonempty array constant
1419 // Verify all elements are correct type!
1420 const ArrayType *AT = ArrayType::getArrayType(yyvsp[-4].TypeVal);
1421 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
1422 if (yyvsp[-4].TypeVal != (*yyvsp[-1].ConstVector)[i]->getType())
1423 ThrowException("Element #" + utostr(i) + " is not of type '" +
1424 yyvsp[-4].TypeVal->getName() + "' as required!\nIt is of type '" +
1425 (*yyvsp[-1].ConstVector)[i]->getType()->getName() + "'.");
1428 yyval.ConstVal = new ConstPoolArray(AT, *yyvsp[-1].ConstVector);
1429 delete yyvsp[-1].ConstVector;
1433 #line 519 "llvmAsmParser.y"
1434 { // Empty array constant
1435 vector<ConstPoolVal*> Empty;
1436 yyval.ConstVal = new ConstPoolArray(ArrayType::getArrayType(yyvsp[-3].TypeVal), Empty);
1440 #line 523 "llvmAsmParser.y"
1442 // Verify all elements are correct type!
1443 const ArrayType *AT = ArrayType::getArrayType(yyvsp[-4].TypeVal, (int)yyvsp[-6].UInt64Val);
1444 if (yyvsp[-6].UInt64Val != yyvsp[-1].ConstVector->size())
1445 ThrowException("Type mismatch: constant sized array initialized with " +
1446 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
1447 itostr((int)yyvsp[-6].UInt64Val) + "!");
1449 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
1450 if (yyvsp[-4].TypeVal != (*yyvsp[-1].ConstVector)[i]->getType())
1451 ThrowException("Element #" + utostr(i) + " is not of type '" +
1452 yyvsp[-4].TypeVal->getName() + "' as required!\nIt is of type '" +
1453 (*yyvsp[-1].ConstVector)[i]->getType()->getName() + "'.");
1456 yyval.ConstVal = new ConstPoolArray(AT, *yyvsp[-1].ConstVector);
1457 delete yyvsp[-1].ConstVector;
1461 #line 541 "llvmAsmParser.y"
1463 if (yyvsp[-5].UInt64Val != 0)
1464 ThrowException("Type mismatch: constant sized array initialized with 0"
1465 " arguments, but has size of " + itostr((int)yyvsp[-5].UInt64Val) + "!");
1466 vector<ConstPoolVal*> Empty;
1467 yyval.ConstVal = new ConstPoolArray(ArrayType::getArrayType(yyvsp[-3].TypeVal, 0), Empty);
1471 #line 548 "llvmAsmParser.y"
1473 StructType::ElementTypes Types(yyvsp[-4].TypeList->begin(), yyvsp[-4].TypeList->end());
1474 delete yyvsp[-4].TypeList;
1476 const StructType *St = StructType::getStructType(Types);
1477 yyval.ConstVal = new ConstPoolStruct(St, *yyvsp[-1].ConstVector);
1478 delete yyvsp[-1].ConstVector;
1482 #line 556 "llvmAsmParser.y"
1484 const StructType *St =
1485 StructType::getStructType(StructType::ElementTypes());
1486 vector<ConstPoolVal*> Empty;
1487 yyval.ConstVal = new ConstPoolStruct(St, Empty);
1491 #line 570 "llvmAsmParser.y"
1493 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(addConstValToConstantPool(yyvsp[0].ConstVal));
1497 #line 573 "llvmAsmParser.y"
1499 yyval.ConstVector = new vector<ConstPoolVal*>();
1500 yyval.ConstVector->push_back(addConstValToConstantPool(yyvsp[0].ConstVal));
1504 #line 579 "llvmAsmParser.y"
1506 if (yyvsp[-1].StrVal) {
1507 yyvsp[0].ConstVal->setName(yyvsp[-1].StrVal);
1508 free(yyvsp[-1].StrVal);
1511 addConstValToConstantPool(yyvsp[0].ConstVal);
1515 #line 587 "llvmAsmParser.y"
1520 #line 598 "llvmAsmParser.y"
1522 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
1523 CurModule.ModuleDone();
1527 #line 603 "llvmAsmParser.y"
1529 yyvsp[-1].ModuleVal->getMethodList().push_back(yyvsp[0].MethodVal);
1530 CurMeth.MethodDone();
1531 yyval.ModuleVal = yyvsp[-1].ModuleVal;
1535 #line 608 "llvmAsmParser.y"
1537 yyval.ModuleVal = CurModule.CurrentModule;
1541 #line 617 "llvmAsmParser.y"
1542 { yyval.StrVal = 0; ;
1545 #line 619 "llvmAsmParser.y"
1547 yyval.MethArgVal = new MethodArgument(yyvsp[-1].TypeVal);
1548 if (yyvsp[0].StrVal) { // Was the argument named?
1549 yyval.MethArgVal->setName(yyvsp[0].StrVal);
1550 free(yyvsp[0].StrVal); // The string was strdup'd, so free it now.
1555 #line 627 "llvmAsmParser.y"
1557 yyval.MethodArgList = yyvsp[0].MethodArgList;
1558 yyvsp[0].MethodArgList->push_front(yyvsp[-2].MethArgVal);
1562 #line 631 "llvmAsmParser.y"
1564 yyval.MethodArgList = new list<MethodArgument*>();
1565 yyval.MethodArgList->push_front(yyvsp[0].MethArgVal);
1569 #line 636 "llvmAsmParser.y"
1571 yyval.MethodArgList = yyvsp[0].MethodArgList;
1575 #line 639 "llvmAsmParser.y"
1577 yyval.MethodArgList = 0;
1581 #line 643 "llvmAsmParser.y"
1583 MethodType::ParamTypes ParamTypeList;
1584 if (yyvsp[-1].MethodArgList)
1585 for (list<MethodArgument*>::iterator I = yyvsp[-1].MethodArgList->begin(); I != yyvsp[-1].MethodArgList->end(); ++I)
1586 ParamTypeList.push_back((*I)->getType());
1588 const MethodType *MT = MethodType::getMethodType(yyvsp[-4].TypeVal, ParamTypeList);
1590 Method *M = new Method(MT, yyvsp[-3].StrVal);
1591 free(yyvsp[-3].StrVal); // Free strdup'd memory!
1593 InsertValue(M, CurModule.Values);
1595 CurMeth.MethodStart(M);
1597 // Add all of the arguments we parsed to the method...
1598 if (yyvsp[-1].MethodArgList) { // Is null if empty...
1599 Method::ArgumentListType &ArgList = M->getArgumentList();
1601 for (list<MethodArgument*>::iterator I = yyvsp[-1].MethodArgList->begin(); I != yyvsp[-1].MethodArgList->end(); ++I) {
1603 ArgList.push_back(*I);
1605 delete yyvsp[-1].MethodArgList; // We're now done with the argument list
1610 #line 670 "llvmAsmParser.y"
1612 yyval.MethodVal = CurMeth.CurrentMethod;
1616 #line 674 "llvmAsmParser.y"
1618 yyval.MethodVal = yyvsp[-1].MethodVal;
1622 #line 683 "llvmAsmParser.y"
1623 { // A reference to a direct constant
1624 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
1628 #line 686 "llvmAsmParser.y"
1630 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
1634 #line 689 "llvmAsmParser.y"
1636 yyval.ValIDVal = ValID::create((int64_t)1);
1640 #line 692 "llvmAsmParser.y"
1642 yyval.ValIDVal = ValID::create((int64_t)0);
1646 #line 695 "llvmAsmParser.y"
1647 { // Quoted strings work too... especially for methods
1648 yyval.ValIDVal = ValID::create_conststr(yyvsp[0].StrVal);
1652 #line 700 "llvmAsmParser.y"
1653 { // Is it an integer reference...?
1654 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
1658 #line 703 "llvmAsmParser.y"
1659 { // It must be a named reference then...
1660 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
1664 #line 706 "llvmAsmParser.y"
1666 yyval.ValIDVal = yyvsp[0].ValIDVal;
1670 #line 713 "llvmAsmParser.y"
1672 Value *D = getVal(Type::TypeTy, yyvsp[0].ValIDVal, true);
1673 if (D == 0) ThrowException("Invalid user defined type: " + yyvsp[0].ValIDVal.getName());
1675 // User defined type not in const pool!
1676 ConstPoolType *CPT = (ConstPoolType*)D->castConstantAsserting();
1677 yyval.TypeVal = CPT->getValue();
1681 #line 721 "llvmAsmParser.y"
1682 { // Method derived type?
1683 MethodType::ParamTypes Params(yyvsp[-1].TypeList->begin(), yyvsp[-1].TypeList->end());
1684 delete yyvsp[-1].TypeList;
1685 yyval.TypeVal = MethodType::getMethodType(yyvsp[-3].TypeVal, Params);
1689 #line 726 "llvmAsmParser.y"
1690 { // Method derived type?
1691 MethodType::ParamTypes Params; // Empty list
1692 yyval.TypeVal = MethodType::getMethodType(yyvsp[-2].TypeVal, Params);
1696 #line 730 "llvmAsmParser.y"
1698 yyval.TypeVal = ArrayType::getArrayType(yyvsp[-1].TypeVal);
1702 #line 733 "llvmAsmParser.y"
1704 yyval.TypeVal = ArrayType::getArrayType(yyvsp[-1].TypeVal, (int)yyvsp[-3].UInt64Val);
1708 #line 736 "llvmAsmParser.y"
1710 StructType::ElementTypes Elements(yyvsp[-1].TypeList->begin(), yyvsp[-1].TypeList->end());
1711 delete yyvsp[-1].TypeList;
1712 yyval.TypeVal = StructType::getStructType(Elements);
1716 #line 741 "llvmAsmParser.y"
1718 yyval.TypeVal = StructType::getStructType(StructType::ElementTypes());
1722 #line 744 "llvmAsmParser.y"
1724 yyval.TypeVal = PointerType::getPointerType(yyvsp[-1].TypeVal);
1728 #line 749 "llvmAsmParser.y"
1730 yyval.TypeList = new list<const Type*>();
1731 yyval.TypeList->push_back(yyvsp[0].TypeVal);
1735 #line 753 "llvmAsmParser.y"
1737 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(yyvsp[0].TypeVal);
1741 #line 758 "llvmAsmParser.y"
1743 yyvsp[-1].MethodVal->getBasicBlocks().push_back(yyvsp[0].BasicBlockVal);
1744 yyval.MethodVal = yyvsp[-1].MethodVal;
1748 #line 762 "llvmAsmParser.y"
1749 { // Do not allow methods with 0 basic blocks
1750 yyval.MethodVal = yyvsp[-1].MethodVal; // in them...
1751 yyvsp[-1].MethodVal->getBasicBlocks().push_back(yyvsp[0].BasicBlockVal);
1755 #line 771 "llvmAsmParser.y"
1757 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
1758 InsertValue(yyvsp[-1].BasicBlockVal);
1759 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1763 #line 776 "llvmAsmParser.y"
1765 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
1766 yyvsp[-1].BasicBlockVal->setName(yyvsp[-2].StrVal);
1767 free(yyvsp[-2].StrVal); // Free the strdup'd memory...
1769 InsertValue(yyvsp[-1].BasicBlockVal);
1770 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1774 #line 785 "llvmAsmParser.y"
1776 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
1777 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1781 #line 789 "llvmAsmParser.y"
1783 yyval.BasicBlockVal = new BasicBlock();
1787 #line 793 "llvmAsmParser.y"
1788 { // Return with a result...
1789 yyval.TermInstVal = new ReturnInst(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1793 #line 796 "llvmAsmParser.y"
1794 { // Return with no result...
1795 yyval.TermInstVal = new ReturnInst();
1799 #line 799 "llvmAsmParser.y"
1800 { // Unconditional Branch...
1801 yyval.TermInstVal = new BranchInst((BasicBlock*)getVal(Type::LabelTy, yyvsp[0].ValIDVal));
1805 #line 802 "llvmAsmParser.y"
1807 yyval.TermInstVal = new BranchInst((BasicBlock*)getVal(Type::LabelTy, yyvsp[-3].ValIDVal),
1808 (BasicBlock*)getVal(Type::LabelTy, yyvsp[0].ValIDVal),
1809 getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
1813 #line 807 "llvmAsmParser.y"
1815 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].TypeVal, yyvsp[-6].ValIDVal),
1816 (BasicBlock*)getVal(Type::LabelTy, yyvsp[-3].ValIDVal));
1817 yyval.TermInstVal = S;
1819 list<pair<ConstPoolVal*, BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
1820 end = yyvsp[-1].JumpTable->end();
1821 for (; I != end; ++I)
1822 S->dest_push_back(I->first, I->second);
1826 #line 818 "llvmAsmParser.y"
1828 yyval.JumpTable = yyvsp[-5].JumpTable;
1829 ConstPoolVal *V = (ConstPoolVal*)getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal, true);
1831 ThrowException("May only switch on a constant pool value!");
1833 yyval.JumpTable->push_back(make_pair(V, (BasicBlock*)getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal)));
1837 #line 826 "llvmAsmParser.y"
1839 yyval.JumpTable = new list<pair<ConstPoolVal*, BasicBlock*> >();
1840 ConstPoolVal *V = (ConstPoolVal*)getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal, true);
1843 ThrowException("May only switch on a constant pool value!");
1845 yyval.JumpTable->push_back(make_pair(V, (BasicBlock*)getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal)));
1849 #line 836 "llvmAsmParser.y"
1851 if (yyvsp[-1].StrVal) // Is this definition named??
1852 yyvsp[0].InstVal->setName(yyvsp[-1].StrVal); // if so, assign the name...
1854 InsertValue(yyvsp[0].InstVal);
1855 yyval.InstVal = yyvsp[0].InstVal;
1859 #line 844 "llvmAsmParser.y"
1860 { // Used for PHI nodes
1861 yyval.PHIList = new list<pair<Value*, BasicBlock*> >();
1862 yyval.PHIList->push_back(make_pair(getVal(yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal),
1863 (BasicBlock*)getVal(Type::LabelTy, yyvsp[-1].ValIDVal)));
1867 #line 849 "llvmAsmParser.y"
1869 yyval.PHIList = yyvsp[-6].PHIList;
1870 yyvsp[-6].PHIList->push_back(make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
1871 (BasicBlock*)getVal(Type::LabelTy, yyvsp[-1].ValIDVal)));
1875 #line 856 "llvmAsmParser.y"
1876 { // Used for call statements...
1877 yyval.ValueList = new list<Value*>();
1878 yyval.ValueList->push_back(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1882 #line 860 "llvmAsmParser.y"
1884 yyval.ValueList = yyvsp[-2].ValueList;
1885 yyvsp[-2].ValueList->push_back(getVal(yyvsp[-2].ValueList->front()->getType(), yyvsp[0].ValIDVal));
1889 #line 866 "llvmAsmParser.y"
1890 { yyval.ValueList = 0; ;
1893 #line 868 "llvmAsmParser.y"
1895 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
1896 if (yyval.InstVal == 0)
1897 ThrowException("binary operator returned null!");
1901 #line 873 "llvmAsmParser.y"
1903 yyval.InstVal = UnaryOperator::create(yyvsp[-2].UnaryOpVal, getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1904 if (yyval.InstVal == 0)
1905 ThrowException("unary operator returned null!");
1909 #line 878 "llvmAsmParser.y"
1911 if (yyvsp[-1].TypeVal != Type::UByteTy) ThrowException("Shift amount must be ubyte!");
1912 yyval.InstVal = new ShiftInst(yyvsp[-5].OtherOpVal, getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal), getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1916 #line 882 "llvmAsmParser.y"
1918 yyval.InstVal = new CastInst(getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), yyvsp[0].TypeVal);
1922 #line 885 "llvmAsmParser.y"
1924 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
1925 yyval.InstVal = new PHINode(Ty);
1926 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
1927 if (yyvsp[0].PHIList->front().first->getType() != Ty)
1928 ThrowException("All elements of a PHI node must be of the same type!");
1929 ((PHINode*)yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
1930 yyvsp[0].PHIList->pop_front();
1932 delete yyvsp[0].PHIList; // Free the list...
1936 #line 896 "llvmAsmParser.y"
1938 if (!yyvsp[-4].TypeVal->isMethodType())
1939 ThrowException("Can only call methods: invalid type '" +
1940 yyvsp[-4].TypeVal->getName() + "'!");
1942 const MethodType *Ty = (const MethodType*)yyvsp[-4].TypeVal;
1944 Value *V = getVal(Ty, yyvsp[-3].ValIDVal);
1945 if (!V->isMethod() || V->getType() != Ty)
1946 ThrowException("Cannot call: " + yyvsp[-3].ValIDVal.getName() + "!");
1948 // Create or access a new type that corresponds to the function call...
1949 vector<Value *> Params;
1951 if (yyvsp[-1].ValueList) {
1952 // Pull out just the arguments...
1953 Params.insert(Params.begin(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
1954 delete yyvsp[-1].ValueList;
1956 // Loop through MethodType's arguments and ensure they are specified
1959 MethodType::ParamTypes::const_iterator I = Ty->getParamTypes().begin();
1961 for (i = 0; i < Params.size() && I != Ty->getParamTypes().end(); ++i,++I){
1962 if (Params[i]->getType() != *I)
1963 ThrowException("Parameter " + utostr(i) + " is not of type '" +
1964 (*I)->getName() + "'!");
1967 if (i != Params.size() || I != Ty->getParamTypes().end())
1968 ThrowException("Invalid number of parameters detected!");
1971 // Create the call node...
1972 yyval.InstVal = new CallInst((Method*)V, Params);
1976 #line 933 "llvmAsmParser.y"
1978 yyval.InstVal = yyvsp[0].InstVal;
1982 #line 938 "llvmAsmParser.y"
1984 yyval.ConstVector = yyvsp[0].ConstVector;
1988 #line 940 "llvmAsmParser.y"
1990 yyval.ConstVector = new vector<ConstPoolVal*>();
1994 #line 944 "llvmAsmParser.y"
1996 const Type *Ty = PointerType::getPointerType(yyvsp[0].TypeVal);
1997 addConstValToConstantPool(new ConstPoolType(Ty));
1998 yyval.InstVal = new MallocInst(Ty);
2002 #line 949 "llvmAsmParser.y"
2004 if (!yyvsp[-3].TypeVal->isArrayType() || ((const ArrayType*)yyvsp[-3].TypeVal)->isSized())
2005 ThrowException("Trying to allocate " + yyvsp[-3].TypeVal->getName() +
2006 " as unsized array!");
2007 const Type *Ty = PointerType::getPointerType(yyvsp[-3].TypeVal);
2008 addConstValToConstantPool(new ConstPoolType(Ty));
2009 Value *ArrSize = getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
2010 yyval.InstVal = new MallocInst(Ty, ArrSize);
2014 #line 958 "llvmAsmParser.y"
2016 const Type *Ty = PointerType::getPointerType(yyvsp[0].TypeVal);
2017 addConstValToConstantPool(new ConstPoolType(Ty));
2018 yyval.InstVal = new AllocaInst(Ty);
2022 #line 963 "llvmAsmParser.y"
2024 if (!yyvsp[-3].TypeVal->isArrayType() || ((const ArrayType*)yyvsp[-3].TypeVal)->isSized())
2025 ThrowException("Trying to allocate " + yyvsp[-3].TypeVal->getName() +
2026 " as unsized array!");
2027 const Type *Ty = PointerType::getPointerType(yyvsp[-3].TypeVal);
2028 addConstValToConstantPool(new ConstPoolType(Ty));
2029 Value *ArrSize = getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
2030 yyval.InstVal = new AllocaInst(Ty, ArrSize);
2034 #line 972 "llvmAsmParser.y"
2036 if (!yyvsp[-1].TypeVal->isPointerType())
2037 ThrowException("Trying to free nonpointer type " + yyvsp[-1].TypeVal->getName() + "!");
2038 yyval.InstVal = new FreeInst(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
2042 #line 978 "llvmAsmParser.y"
2044 if (!yyvsp[-2].TypeVal->isPointerType())
2045 ThrowException("Can't load from nonpointer type: " + yyvsp[-2].TypeVal->getName());
2046 if (LoadInst::getIndexedType(yyvsp[-2].TypeVal, *yyvsp[0].ConstVector) == 0)
2047 ThrowException("Invalid indices for load instruction!");
2049 yyval.InstVal = new LoadInst(getVal(yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ConstVector);
2050 delete yyvsp[0].ConstVector; // Free the vector...
2054 /* the action file gets copied in in place of this dollarsign */
2055 #line 543 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
2066 short *ssp1 = yyss - 1;
2067 fprintf (stderr, "state stack now");
2068 while (ssp1 != yyssp)
2069 fprintf (stderr, " %d", *++ssp1);
2070 fprintf (stderr, "\n");
2080 yylsp->first_line = yylloc.first_line;
2081 yylsp->first_column = yylloc.first_column;
2082 yylsp->last_line = (yylsp-1)->last_line;
2083 yylsp->last_column = (yylsp-1)->last_column;
2088 yylsp->last_line = (yylsp+yylen-1)->last_line;
2089 yylsp->last_column = (yylsp+yylen-1)->last_column;
2093 /* Now "shift" the result of the reduction.
2094 Determine what state that goes to,
2095 based on the state we popped back to
2096 and the rule number reduced by. */
2100 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
2101 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2102 yystate = yytable[yystate];
2104 yystate = yydefgoto[yyn - YYNTBASE];
2108 yyerrlab: /* here on detecting error */
2111 /* If not already recovering from an error, report this error. */
2115 #ifdef YYERROR_VERBOSE
2116 yyn = yypact[yystate];
2118 if (yyn > YYFLAG && yyn < YYLAST)
2125 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
2126 for (x = (yyn < 0 ? -yyn : 0);
2127 x < (sizeof(yytname) / sizeof(char *)); x++)
2128 if (yycheck[x + yyn] == x)
2129 size += strlen(yytname[x]) + 15, count++;
2130 msg = (char *) malloc(size + 15);
2133 strcpy(msg, "parse error");
2138 for (x = (yyn < 0 ? -yyn : 0);
2139 x < (sizeof(yytname) / sizeof(char *)); x++)
2140 if (yycheck[x + yyn] == x)
2142 strcat(msg, count == 0 ? ", expecting `" : " or `");
2143 strcat(msg, yytname[x]);
2152 yyerror ("parse error; also virtual memory exceeded");
2155 #endif /* YYERROR_VERBOSE */
2156 yyerror("parse error");
2160 yyerrlab1: /* here on error raised explicitly by an action */
2162 if (yyerrstatus == 3)
2164 /* if just tried and failed to reuse lookahead token after an error, discard it. */
2166 /* return failure if at end of input */
2167 if (yychar == YYEOF)
2172 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
2178 /* Else will try to reuse lookahead token
2179 after shifting the error token. */
2181 yyerrstatus = 3; /* Each real token shifted decrements this */
2185 yyerrdefault: /* current state does not do anything special for the error token. */
2188 /* This is wrong; only states that explicitly want error tokens
2189 should shift them. */
2190 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
2191 if (yyn) goto yydefault;
2194 yyerrpop: /* pop the current state because it cannot handle the error token */
2196 if (yyssp == yyss) YYABORT;
2206 short *ssp1 = yyss - 1;
2207 fprintf (stderr, "Error: state stack now");
2208 while (ssp1 != yyssp)
2209 fprintf (stderr, " %d", *++ssp1);
2210 fprintf (stderr, "\n");
2216 yyn = yypact[yystate];
2221 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
2240 fprintf(stderr, "Shifting error token, ");
2252 /* YYACCEPT comes here. */
2264 /* YYABORT comes here. */
2275 #line 988 "llvmAsmParser.y"
2277 int yyerror(const char *ErrorMsg) {
2278 ThrowException(string("Parse error: ") + ErrorMsg);