|
|
1.1 ! root 1: /* ! 2: * Mach Operating System ! 3: * Copyright (c) 1991,1990 Carnegie Mellon University ! 4: * All Rights Reserved. ! 5: * ! 6: * Permission to use, copy, modify and distribute this software and its ! 7: * documentation is hereby granted, provided that both the copyright ! 8: * notice and this permission notice appear in all copies of the ! 9: * software, derivative works or modified versions, and any portions ! 10: * thereof, and that both notices appear in supporting documentation. ! 11: * ! 12: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS ! 13: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR ! 14: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ! 15: * ! 16: * Carnegie Mellon requests users of this software to return to ! 17: * ! 18: * Software Distribution Coordinator or [email protected] ! 19: * School of Computer Science ! 20: * Carnegie Mellon University ! 21: * Pittsburgh PA 15213-3890 ! 22: * ! 23: * any improvements or extensions that they make and grant Carnegie the ! 24: * rights to redistribute these changes. ! 25: */ ! 26: ! 27: %token sySkip ! 28: %token syRoutine ! 29: %token sySimpleRoutine ! 30: %token sySimpleProcedure ! 31: %token syProcedure ! 32: %token syFunction ! 33: ! 34: %token sySubsystem ! 35: %token syKernelUser ! 36: %token syKernelServer ! 37: ! 38: %token syMsgOption ! 39: %token syMsgSeqno ! 40: %token syWaitTime ! 41: %token syNoWaitTime ! 42: %token syErrorProc ! 43: %token syServerPrefix ! 44: %token syUserPrefix ! 45: %token syServerDemux ! 46: %token syRCSId ! 47: ! 48: %token syImport ! 49: %token syUImport ! 50: %token sySImport ! 51: ! 52: %token syIn ! 53: %token syOut ! 54: %token syInOut ! 55: %token syRequestPort ! 56: %token syReplyPort ! 57: %token sySReplyPort ! 58: %token syUReplyPort ! 59: ! 60: %token syType ! 61: %token syArray ! 62: %token syStruct ! 63: %token syOf ! 64: ! 65: %token syInTran ! 66: %token syOutTran ! 67: %token syDestructor ! 68: %token syCType ! 69: %token syCUserType ! 70: %token syCServerType ! 71: ! 72: %token syCString ! 73: ! 74: %token syColon ! 75: %token sySemi ! 76: %token syComma ! 77: %token syPlus ! 78: %token syMinus ! 79: %token syStar ! 80: %token syDiv ! 81: %token syLParen ! 82: %token syRParen ! 83: %token syEqual ! 84: %token syCaret ! 85: %token syTilde ! 86: %token syLAngle ! 87: %token syRAngle ! 88: %token syLBrack ! 89: %token syRBrack ! 90: %token syBar ! 91: ! 92: %token syError /* lex error */ ! 93: ! 94: %token <number> syNumber ! 95: %token <symtype> sySymbolicType ! 96: %token <identifier> syIdentifier ! 97: %token <string> syString syQString ! 98: %token <string> syFileName ! 99: %token <flag> syIPCFlag ! 100: ! 101: %left syPlus,syMinus ! 102: %left syStar,syDiv ! 103: ! 104: ! 105: %type <statement_kind> ImportIndicant ! 106: %type <number> VarArrayHead ArrayHead StructHead IntExp ! 107: %type <type> NamedTypeSpec TransTypeSpec TypeSpec ! 108: %type <type> CStringSpec ! 109: %type <type> BasicTypeSpec PrevTypeSpec ArgumentType ! 110: %type <symtype> PrimIPCType IPCType ! 111: %type <routine> RoutineDecl Routine SimpleRoutine ! 112: %type <routine> Procedure SimpleProcedure Function ! 113: %type <direction> Direction ! 114: %type <argument> Argument Arguments ArgumentList ! 115: %type <flag> IPCFlags ! 116: ! 117: %{ ! 118: ! 119: #include <stdio.h> ! 120: ! 121: #include "error.h" ! 122: #include "lexxer.h" ! 123: #include "global.h" ! 124: #include "mig_string.h" ! 125: #include "type.h" ! 126: #include "routine.h" ! 127: #include "statement.h" ! 128: ! 129: static const char *import_name(statement_kind_t sk); ! 130: ! 131: void ! 132: yyerror(const char *s) ! 133: { ! 134: error(s); ! 135: } ! 136: %} ! 137: ! 138: %union ! 139: { ! 140: u_int number; ! 141: identifier_t identifier; ! 142: const_string_t string; ! 143: statement_kind_t statement_kind; ! 144: ipc_type_t *type; ! 145: struct ! 146: { ! 147: u_int innumber; /* msgt_name value, when sending */ ! 148: const_string_t instr; ! 149: u_int outnumber; /* msgt_name value, when receiving */ ! 150: const_string_t outstr; ! 151: u_int size; /* 0 means there is no default size */ ! 152: } symtype; ! 153: routine_t *routine; ! 154: arg_kind_t direction; ! 155: argument_t *argument; ! 156: ipc_flags_t flag; ! 157: } ! 158: ! 159: %% ! 160: ! 161: Statements : /* empty */ ! 162: | Statements Statement ! 163: ; ! 164: ! 165: Statement : Subsystem sySemi ! 166: | WaitTime sySemi ! 167: | MsgOption sySemi ! 168: | Error sySemi ! 169: | ServerPrefix sySemi ! 170: | UserPrefix sySemi ! 171: | ServerDemux sySemi ! 172: | TypeDecl sySemi ! 173: | RoutineDecl sySemi ! 174: { ! 175: register statement_t *st = stAlloc(); ! 176: ! 177: st->stKind = skRoutine; ! 178: st->stRoutine = $1; ! 179: rtCheckRoutine($1); ! 180: if (BeVerbose) ! 181: rtPrintRoutine($1); ! 182: } ! 183: | sySkip sySemi ! 184: { rtSkip(1); } ! 185: | sySkip syNumber sySemi ! 186: { rtSkip($2); } ! 187: | Import sySemi ! 188: | RCSDecl sySemi ! 189: | sySemi ! 190: | error sySemi ! 191: { yyerrok; } ! 192: ; ! 193: ! 194: Subsystem : SubsystemStart SubsystemMods ! 195: SubsystemName SubsystemBase ! 196: { ! 197: if (BeVerbose) ! 198: { ! 199: printf("Subsystem %s: base = %u%s%s\n\n", ! 200: SubsystemName, SubsystemBase, ! 201: IsKernelUser ? ", KernelUser" : "", ! 202: IsKernelServer ? ", KernelServer" : ""); ! 203: } ! 204: } ! 205: ; ! 206: ! 207: SubsystemStart : sySubsystem ! 208: { ! 209: if (SubsystemName != strNULL) ! 210: { ! 211: warn("previous Subsystem decl (of %s) will be ignored", SubsystemName); ! 212: IsKernelUser = FALSE; ! 213: IsKernelServer = FALSE; ! 214: strfree((string_t) SubsystemName); ! 215: } ! 216: } ! 217: ; ! 218: ! 219: SubsystemMods : /* empty */ ! 220: | SubsystemMods SubsystemMod ! 221: ; ! 222: ! 223: SubsystemMod : syKernelUser ! 224: { ! 225: if (IsKernelUser) ! 226: warn("duplicate KernelUser keyword"); ! 227: IsKernelUser = TRUE; ! 228: } ! 229: | syKernelServer ! 230: { ! 231: if (IsKernelServer) ! 232: warn("duplicate KernelServer keyword"); ! 233: IsKernelServer = TRUE; ! 234: } ! 235: ; ! 236: ! 237: SubsystemName : syIdentifier { SubsystemName = $1; } ! 238: ; ! 239: ! 240: SubsystemBase : syNumber { SubsystemBase = $1; } ! 241: ; ! 242: ! 243: MsgOption : LookString syMsgOption syString ! 244: { ! 245: if (streql($3, "MACH_MSG_OPTION_NONE")) ! 246: { ! 247: MsgOption = strNULL; ! 248: if (BeVerbose) ! 249: printf("MsgOption: canceled\n\n"); ! 250: } ! 251: else ! 252: { ! 253: MsgOption = $3; ! 254: if (BeVerbose) ! 255: printf("MsgOption %s\n\n",$3); ! 256: } ! 257: } ! 258: ; ! 259: ! 260: WaitTime : LookString syWaitTime syString ! 261: { ! 262: WaitTime = $3; ! 263: if (BeVerbose) ! 264: printf("WaitTime %s\n\n", WaitTime); ! 265: } ! 266: | syNoWaitTime ! 267: { ! 268: WaitTime = strNULL; ! 269: if (BeVerbose) ! 270: printf("NoWaitTime\n\n"); ! 271: } ! 272: ; ! 273: ! 274: Error : syErrorProc syIdentifier ! 275: { ! 276: ErrorProc = $2; ! 277: if (BeVerbose) ! 278: printf("ErrorProc %s\n\n", ErrorProc); ! 279: } ! 280: ; ! 281: ! 282: ServerPrefix : syServerPrefix syIdentifier ! 283: { ! 284: ServerPrefix = $2; ! 285: if (BeVerbose) ! 286: printf("ServerPrefix %s\n\n", ServerPrefix); ! 287: } ! 288: ; ! 289: ! 290: UserPrefix : syUserPrefix syIdentifier ! 291: { ! 292: UserPrefix = $2; ! 293: if (BeVerbose) ! 294: printf("UserPrefix %s\n\n", UserPrefix); ! 295: } ! 296: ; ! 297: ! 298: ServerDemux : syServerDemux syIdentifier ! 299: { ! 300: ServerDemux = $2; ! 301: if (BeVerbose) ! 302: printf("ServerDemux %s\n\n", ServerDemux); ! 303: } ! 304: ; ! 305: ! 306: Import : LookFileName ImportIndicant syFileName ! 307: { ! 308: register statement_t *st = stAlloc(); ! 309: st->stKind = $2; ! 310: st->stFileName = $3; ! 311: ! 312: if (BeVerbose) ! 313: printf("%s %s\n\n", import_name($2), $3); ! 314: } ! 315: ; ! 316: ! 317: ImportIndicant : syImport { $$ = skImport; } ! 318: | syUImport { $$ = skUImport; } ! 319: | sySImport { $$ = skSImport; } ! 320: ; ! 321: ! 322: RCSDecl : LookQString syRCSId syQString ! 323: { ! 324: if (RCSId != strNULL) ! 325: warn("previous RCS decl will be ignored"); ! 326: if (BeVerbose) ! 327: printf("RCSId %s\n\n", $3); ! 328: RCSId = $3; ! 329: } ! 330: ; ! 331: ! 332: TypeDecl : syType NamedTypeSpec ! 333: { ! 334: register identifier_t name = $2->itName; ! 335: ! 336: if (itLookUp(name) != itNULL) ! 337: warn("overriding previous definition of %s", name); ! 338: itInsert(name, $2); ! 339: } ! 340: ; ! 341: ! 342: NamedTypeSpec : syIdentifier syEqual TransTypeSpec ! 343: { itTypeDecl($1, $$ = $3); } ! 344: ; ! 345: ! 346: TransTypeSpec : TypeSpec ! 347: { $$ = itResetType($1); } ! 348: | TransTypeSpec syInTran syColon syIdentifier ! 349: syIdentifier syLParen syIdentifier syRParen ! 350: { ! 351: $$ = $1; ! 352: ! 353: if (($$->itTransType != strNULL) && !streql($$->itTransType, $4)) ! 354: warn("conflicting translation types (%s, %s)", ! 355: $$->itTransType, $4); ! 356: $$->itTransType = $4; ! 357: ! 358: if (($$->itInTrans != strNULL) && !streql($$->itInTrans, $5)) ! 359: warn("conflicting in-translation functions (%s, %s)", ! 360: $$->itInTrans, $5); ! 361: $$->itInTrans = $5; ! 362: ! 363: if (($$->itServerType != strNULL) && !streql($$->itServerType, $7)) ! 364: warn("conflicting server types (%s, %s)", ! 365: $$->itServerType, $7); ! 366: $$->itServerType = $7; ! 367: } ! 368: | TransTypeSpec syOutTran syColon syIdentifier ! 369: syIdentifier syLParen syIdentifier syRParen ! 370: { ! 371: $$ = $1; ! 372: ! 373: if (($$->itServerType != strNULL) && !streql($$->itServerType, $4)) ! 374: warn("conflicting server types (%s, %s)", ! 375: $$->itServerType, $4); ! 376: $$->itServerType = $4; ! 377: ! 378: if (($$->itOutTrans != strNULL) && !streql($$->itOutTrans, $5)) ! 379: warn("conflicting out-translation functions (%s, %s)", ! 380: $$->itOutTrans, $5); ! 381: $$->itOutTrans = $5; ! 382: ! 383: if (($$->itTransType != strNULL) && !streql($$->itTransType, $7)) ! 384: warn("conflicting translation types (%s, %s)", ! 385: $$->itTransType, $7); ! 386: $$->itTransType = $7; ! 387: } ! 388: | TransTypeSpec syDestructor syColon syIdentifier ! 389: syLParen syIdentifier syRParen ! 390: { ! 391: $$ = $1; ! 392: ! 393: if (($$->itDestructor != strNULL) && !streql($$->itDestructor, $4)) ! 394: warn("conflicting destructor functions (%s, %s)", ! 395: $$->itDestructor, $4); ! 396: $$->itDestructor = $4; ! 397: ! 398: if (($$->itTransType != strNULL) && !streql($$->itTransType, $6)) ! 399: warn("conflicting translation types (%s, %s)", ! 400: $$->itTransType, $6); ! 401: $$->itTransType = $6; ! 402: } ! 403: | TransTypeSpec syCType syColon syIdentifier ! 404: { ! 405: $$ = $1; ! 406: ! 407: if (($$->itUserType != strNULL) && !streql($$->itUserType, $4)) ! 408: warn("conflicting user types (%s, %s)", ! 409: $$->itUserType, $4); ! 410: $$->itUserType = $4; ! 411: ! 412: if (($$->itServerType != strNULL) && !streql($$->itServerType, $4)) ! 413: warn("conflicting server types (%s, %s)", ! 414: $$->itServerType, $4); ! 415: $$->itServerType = $4; ! 416: } ! 417: | TransTypeSpec syCUserType syColon syIdentifier ! 418: { ! 419: $$ = $1; ! 420: ! 421: if (($$->itUserType != strNULL) && !streql($$->itUserType, $4)) ! 422: warn("conflicting user types (%s, %s)", ! 423: $$->itUserType, $4); ! 424: $$->itUserType = $4; ! 425: } ! 426: | TransTypeSpec syCServerType ! 427: syColon syIdentifier ! 428: { ! 429: $$ = $1; ! 430: ! 431: if (($$->itServerType != strNULL) && !streql($$->itServerType, $4)) ! 432: warn("conflicting server types (%s, %s)", ! 433: $$->itServerType, $4); ! 434: $$->itServerType = $4; ! 435: } ! 436: ; ! 437: ! 438: TypeSpec : BasicTypeSpec ! 439: { $$ = $1; } ! 440: | PrevTypeSpec ! 441: { $$ = $1; } ! 442: | VarArrayHead TypeSpec ! 443: { $$ = itVarArrayDecl($1, $2); } ! 444: | ArrayHead TypeSpec ! 445: { $$ = itArrayDecl($1, $2); } ! 446: | syCaret TypeSpec ! 447: { $$ = itPtrDecl($2); } ! 448: | StructHead TypeSpec ! 449: { $$ = itStructDecl($1, $2); } ! 450: | CStringSpec ! 451: { $$ = $1; } ! 452: ; ! 453: ! 454: BasicTypeSpec : IPCType ! 455: { ! 456: $$ = itShortDecl($1.innumber, $1.instr, ! 457: $1.outnumber, $1.outstr, ! 458: $1.size); ! 459: } ! 460: | syLParen IPCType syComma IntExp ! 461: IPCFlags syRParen ! 462: { ! 463: $$ = itLongDecl($2.innumber, $2.instr, ! 464: $2.outnumber, $2.outstr, ! 465: $2.size, $4, $5); ! 466: } ! 467: ; ! 468: ! 469: IPCFlags : /* empty */ ! 470: { $$ = flNone; } ! 471: | IPCFlags syComma syIPCFlag ! 472: { ! 473: if ($1 & $3) ! 474: warn("redundant IPC flag ignored"); ! 475: else ! 476: $$ = $1 | $3; ! 477: } ! 478: | IPCFlags syComma syIPCFlag syLBrack syRBrack ! 479: { ! 480: if ($3 != flDealloc) ! 481: warn("only Dealloc is variable"); ! 482: else ! 483: $$ = $1 | flMaybeDealloc; ! 484: } ! 485: ; ! 486: ! 487: PrimIPCType : syNumber ! 488: { ! 489: $$.innumber = $$.outnumber = $1; ! 490: $$.instr = $$.outstr = strNULL; ! 491: $$.size = 0; ! 492: } ! 493: | sySymbolicType ! 494: { $$ = $1; } ! 495: ; ! 496: ! 497: IPCType : PrimIPCType ! 498: { $$ = $1; } ! 499: | PrimIPCType syBar PrimIPCType ! 500: { ! 501: if ($1.size != $3.size) ! 502: { ! 503: if ($1.size == 0) ! 504: $$.size = $3.size; ! 505: else if ($3.size == 0) ! 506: $$.size = $1.size; ! 507: else ! 508: { ! 509: error("sizes in IPCTypes (%d, %d) aren't equal", ! 510: $1.size, $3.size); ! 511: $$.size = 0; ! 512: } ! 513: } ! 514: else ! 515: $$.size = $1.size; ! 516: $$.innumber = $1.innumber; ! 517: $$.instr = $1.instr; ! 518: $$.outnumber = $3.outnumber; ! 519: $$.outstr = $3.outstr; ! 520: } ! 521: ; ! 522: ! 523: PrevTypeSpec : syIdentifier ! 524: { $$ = itPrevDecl($1); } ! 525: ; ! 526: ! 527: VarArrayHead : syArray syLBrack syRBrack syOf ! 528: { $$ = 0; } ! 529: | syArray syLBrack syStar syRBrack syOf ! 530: { $$ = 0; } ! 531: | syArray syLBrack syStar syColon IntExp ! 532: syRBrack syOf ! 533: { $$ = $5; } ! 534: ; ! 535: ! 536: ArrayHead : syArray syLBrack IntExp syRBrack syOf ! 537: { $$ = $3; } ! 538: ; ! 539: ! 540: StructHead : syStruct syLBrack IntExp syRBrack syOf ! 541: { $$ = $3; } ! 542: ; ! 543: ! 544: CStringSpec : syCString syLBrack IntExp syRBrack ! 545: { $$ = itCStringDecl($3, FALSE); } ! 546: | syCString syLBrack syStar syColon ! 547: IntExp syRBrack ! 548: { $$ = itCStringDecl($5, TRUE); } ! 549: ; ! 550: ! 551: IntExp : IntExp syPlus IntExp ! 552: { $$ = $1 + $3; } ! 553: | IntExp syMinus IntExp ! 554: { $$ = $1 - $3; } ! 555: | IntExp syStar IntExp ! 556: { $$ = $1 * $3; } ! 557: | IntExp syDiv IntExp ! 558: { $$ = $1 / $3; } ! 559: | syNumber ! 560: { $$ = $1; } ! 561: | syLParen IntExp syRParen ! 562: { $$ = $2; } ! 563: ; ! 564: ! 565: ! 566: RoutineDecl : Routine { $$ = $1; } ! 567: | SimpleRoutine { $$ = $1; } ! 568: | Procedure { $$ = $1; } ! 569: | SimpleProcedure { $$ = $1; } ! 570: | Function { $$ = $1; } ! 571: ; ! 572: ! 573: Routine : syRoutine syIdentifier Arguments ! 574: { $$ = rtMakeRoutine($2, $3); } ! 575: ; ! 576: ! 577: SimpleRoutine : sySimpleRoutine syIdentifier Arguments ! 578: { $$ = rtMakeSimpleRoutine($2, $3); } ! 579: ; ! 580: ! 581: Procedure : syProcedure syIdentifier Arguments ! 582: { $$ = rtMakeProcedure($2, $3); } ! 583: ; ! 584: ! 585: SimpleProcedure : sySimpleProcedure syIdentifier Arguments ! 586: { $$ = rtMakeSimpleProcedure($2, $3); } ! 587: ; ! 588: ! 589: Function : syFunction syIdentifier Arguments ArgumentType ! 590: { $$ = rtMakeFunction($2, $3, $4); } ! 591: ; ! 592: ! 593: Arguments : syLParen syRParen ! 594: { $$ = argNULL; } ! 595: | syLParen ArgumentList syRParen ! 596: { $$ = $2; } ! 597: ! 598: ; ! 599: ! 600: ArgumentList : Argument ! 601: { $$ = $1; } ! 602: | Argument sySemi ArgumentList ! 603: { ! 604: $$ = $1; ! 605: $$->argNext = $3; ! 606: } ! 607: ; ! 608: ! 609: Argument : Direction syIdentifier ArgumentType IPCFlags ! 610: { ! 611: $$ = argAlloc(); ! 612: $$->argKind = $1; ! 613: $$->argName = $2; ! 614: $$->argType = $3; ! 615: $$->argFlags = $4; ! 616: } ! 617: ; ! 618: ! 619: Direction : /* empty */ { $$ = akNone; } ! 620: | syIn { $$ = akIn; } ! 621: | syOut { $$ = akOut; } ! 622: | syInOut { $$ = akInOut; } ! 623: | syRequestPort { $$ = akRequestPort; } ! 624: | syReplyPort { $$ = akReplyPort; } ! 625: | sySReplyPort { $$ = akSReplyPort; } ! 626: | syUReplyPort { $$ = akUReplyPort; } ! 627: | syWaitTime { $$ = akWaitTime; } ! 628: | syMsgOption { $$ = akMsgOption; } ! 629: | syMsgSeqno { $$ = akMsgSeqno; } ! 630: ; ! 631: ! 632: ArgumentType : syColon syIdentifier ! 633: { ! 634: $$ = itLookUp($2); ! 635: if ($$ == itNULL) ! 636: error("type '%s' not defined", $2); ! 637: } ! 638: | syColon NamedTypeSpec ! 639: { $$ = $2; } ! 640: ; ! 641: ! 642: LookString : /* empty */ ! 643: { LookString(); } ! 644: ; ! 645: ! 646: LookFileName : /* empty */ ! 647: { LookFileName(); } ! 648: ; ! 649: ! 650: LookQString : /* empty */ ! 651: { LookQString(); } ! 652: ; ! 653: ! 654: %% ! 655: ! 656: static const char * ! 657: import_name(statement_kind_t sk) ! 658: { ! 659: switch (sk) ! 660: { ! 661: case skImport: ! 662: return "Import"; ! 663: case skSImport: ! 664: return "SImport"; ! 665: case skUImport: ! 666: return "UImport"; ! 667: default: ! 668: fatal("import_name(%d): not import statement", (int) sk); ! 669: /*NOTREACHED*/ ! 670: } ! 671: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.