|
|
1.1 ! root 1: %k 10000 ! 2: %n 5000 ! 3: %a 20000 ! 4: %e 10000 ! 5: %p 25000 ! 6: ! 7: Ident ([A-Za-z_][A-Za-z_0-9]*) ! 8: Number ([0-9]+) ! 9: String ([-/._$A-Za-z0-9]+) ! 10: QString (\"[^"\n]*\") ! 11: AString (\<[^>\n]*\>) ! 12: FileName ({QString}|{AString}) ! 13: ! 14: %{ ! 15: /* ! 16: * Mach Operating System ! 17: * Copyright (c) 1991,1990 Carnegie Mellon University ! 18: * All Rights Reserved. ! 19: * ! 20: * Permission to use, copy, modify and distribute this software and its ! 21: * documentation is hereby granted, provided that both the copyright ! 22: * notice and this permission notice appear in all copies of the ! 23: * software, derivative works or modified versions, and any portions ! 24: * thereof, and that both notices appear in supporting documentation. ! 25: * ! 26: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" ! 27: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR ! 28: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ! 29: * ! 30: * Carnegie Mellon requests users of this software to return to ! 31: * ! 32: * Software Distribution Coordinator or [email protected] ! 33: * School of Computer Science ! 34: * Carnegie Mellon University ! 35: * Pittsburgh PA 15213-3890 ! 36: * ! 37: * any improvements or extensions that they make and grant Carnegie Mellon ! 38: * the rights to redistribute these changes. ! 39: */ ! 40: ! 41: #include <string.h> ! 42: ! 43: #include "mig_string.h" ! 44: #include "type.h" ! 45: #include "statement.h" ! 46: #include "global.h" ! 47: #include "parser.h" ! 48: #include "lexxer.h" ! 49: #include "cpu.h" ! 50: ! 51: #define stringize(x) #x ! 52: ! 53: #ifdef LDEBUG ! 54: #define RETURN(sym) \ ! 55: { \ ! 56: printf("yylex: returning '%s' (%d)\n", #sym, (sym)); \ ! 57: return (sym); \ ! 58: } ! 59: #else LDEBUG ! 60: #define RETURN(sym) return (sym) ! 61: #endif LDEBUG ! 62: ! 63: #define TPRETURN(intype, outtype, tsize) \ ! 64: { \ ! 65: yylval.symtype.innumber = (intype); \ ! 66: yylval.symtype.instr = stringize(intype); \ ! 67: yylval.symtype.outnumber = (outtype); \ ! 68: yylval.symtype.outstr = stringize(outtype); \ ! 69: yylval.symtype.size = (tsize); \ ! 70: RETURN(sySymbolicType); \ ! 71: } ! 72: ! 73: #define TRETURN(type, tsize) TPRETURN(type,type,tsize) ! 74: ! 75: #define FRETURN(val) \ ! 76: { \ ! 77: yylval.flag = (val); \ ! 78: RETURN(syIPCFlag); \ ! 79: } ! 80: ! 81: extern YYSTYPE yylval; /* added by rm */ ! 82: ! 83: int lineno; ! 84: char *inname; ! 85: ! 86: #ifdef YY_START ! 87: static int oldYYBegin; ! 88: #define SAVE_BEGIN oldYYBegin = YY_START ! 89: #define RSTR_BEGIN BEGIN oldYYBegin ! 90: #else ! 91: static struct yysvf *oldYYBegin; ! 92: #define SAVE_BEGIN oldYYBegin = yybgin ! 93: #define RSTR_BEGIN yybgin = oldYYBegin; ! 94: #endif ! 95: ! 96: static void doSharp(const char *body); /* process body of # directives */ ! 97: %} ! 98: ! 99: %Start Normal String FileName QString SkipToEOL ! 100: ! 101: %% ! 102: ! 103: <Normal>[Rr][Oo][Uu][Tt][Ii][Nn][Ee] RETURN(syRoutine); ! 104: <Normal>[Ff][Uu][Nn][Cc][Tt][Ii][Oo][Nn] RETURN(syFunction); ! 105: <Normal>[Pp][Rr][Oo][Cc][Ee][Dd][Uu][Rr][Ee] RETURN(syProcedure); ! 106: <Normal>[Ss][Ii][Mm][Pp][Ll][Ee][Pp][Rr][Oo][Cc][Ee][Dd][Uu][Rr][Ee] RETURN(sySimpleProcedure); ! 107: <Normal>[Ss][Ii][Mm][Pp][Ll][Ee][Rr][Oo][Uu][Tt][Ii][Nn][Ee] RETURN(sySimpleRoutine); ! 108: <Normal>[Ss][Uu][Bb][Ss][Yy][Ss][Tt][Ee][Mm] RETURN(sySubsystem); ! 109: <Normal>[Mm][Ss][Gg][Oo][Pp][Tt][Ii][Oo][Nn] RETURN(syMsgOption); ! 110: <Normal>[Mm][Ss][Gg][Ss][Ee][Qq][Nn][Oo] RETURN(syMsgSeqno); ! 111: <Normal>[Ww][Aa][Ii][Tt][Tt][Ii][Mm][Ee] RETURN(syWaitTime); ! 112: <Normal>[Nn][Oo][Ww][Aa][Ii][Tt][Tt][Ii][Mm][Ee] RETURN(syNoWaitTime); ! 113: <Normal>[Ii][Nn] RETURN(syIn); ! 114: <Normal>[Oo][Uu][Tt] RETURN(syOut); ! 115: <Normal>[Ii][Nn][Oo][Uu][Tt] RETURN(syInOut); ! 116: <Normal>[Rr][Ee][Qq][Uu][Ee][Ss][Tt][Pp][Oo][Rr][Tt] RETURN(syRequestPort); ! 117: <Normal>[Rr][Ee][Pp][Ll][Yy][Pp][Oo][Rr][Tt] RETURN(syReplyPort); ! 118: <Normal>[Uu][Rr][Ee][Pp][Ll][Yy][Pp][Oo][Rr][Tt] RETURN(syUReplyPort); ! 119: <Normal>[Ss][Rr][Ee][Pp][Ll][Yy][Pp][Oo][Rr][Tt] RETURN(sySReplyPort); ! 120: <Normal>[Aa][Rr][Rr][Aa][Yy] RETURN(syArray); ! 121: <Normal>[Oo][Ff] RETURN(syOf); ! 122: <Normal>[Ee][Rr][Rr][Oo][Rr] RETURN(syErrorProc); ! 123: <Normal>[Ss][Ee][Rr][Vv][Ee][Rr][Pp][Rr][Ee][Ff][Ii][Xx] RETURN(syServerPrefix); ! 124: <Normal>[Uu][Ss][Ee][Rr][Pp][Rr][Ee][Ff][Ii][Xx] RETURN(syUserPrefix); ! 125: <Normal>[Ss][Ee][Rr][Vv][Ee][Rr][Dd][Ee][Mm][Uu][Xx] RETURN(syServerDemux); ! 126: <Normal>[Rr][Cc][Ss][Ii][Dd] RETURN(syRCSId); ! 127: <Normal>[Ii][Mm][Pp][Oo][Rr][Tt] RETURN(syImport); ! 128: <Normal>[Uu][Ii][Mm][Pp][Oo][Rr][Tt] RETURN(syUImport); ! 129: <Normal>[Ss][Ii][Mm][Pp][Oo][Rr][Tt] RETURN(sySImport); ! 130: <Normal>[Tt][Yy][Pp][Ee] RETURN(syType); ! 131: <Normal>[Kk][Ee][Rr][Nn][Ee][Ll][Ss][Ee][Rr][Vv][Ee][Rr] RETURN(syKernelServer); ! 132: <Normal>[Kk][Ee][Rr][Nn][Ee][Ll][Uu][Ss][Ee][Rr] RETURN(syKernelUser); ! 133: <Normal>[Ss][Kk][Ii][Pp] RETURN(sySkip); ! 134: <Normal>[Ss][Tt][Rr][Uu][Cc][Tt] RETURN(syStruct); ! 135: <Normal>[Ii][Nn][Tt][Rr][Aa][Nn] RETURN(syInTran); ! 136: <Normal>[Oo][Uu][Tt][Tt][Rr][Aa][Nn] RETURN(syOutTran); ! 137: <Normal>[Dd][Ee][Ss][Tt][Rr][Uu][Cc][Tt][Oo][Rr] RETURN(syDestructor); ! 138: <Normal>[Cc][Tt][Yy][Pp][Ee] RETURN(syCType); ! 139: <Normal>[Cc][Uu][Ss][Ee][Rr][Tt][Yy][Pp][Ee] RETURN(syCUserType); ! 140: <Normal>[Cc][Ss][Ee][Rr][Vv][Ee][Rr][Tt][Yy][Pp][Ee] RETURN(syCServerType); ! 141: <Normal>[Cc]_[Ss][Tt][Rr][Ii][Nn][Gg] RETURN(syCString); ! 142: ! 143: <Normal>[Ii][Ss][Ll][Oo][Nn][Gg] FRETURN(flLong); ! 144: <Normal>[Ii][Ss][Nn][Oo][Tt][Ll][Oo][Nn][Gg] FRETURN(flNotLong); ! 145: <Normal>[Dd][Ee][Aa][Ll][Ll][Oo][Cc] FRETURN(flDealloc); ! 146: <Normal>[Nn][Oo][Tt][Dd][Ee][Aa][Ll][Ll][Oo][Cc] FRETURN(flNotDealloc); ! 147: <Normal>[Ss][Ee][Rr][Vv][Ee][Rr][Cc][Oo][Pp][Yy] FRETURN(flServerCopy); ! 148: <Normal>[Cc][Oo][Uu][Nn][Tt][Ii][Nn][Oo][Uu][Tt] FRETURN(flCountInOut); ! 149: ! 150: <Normal>[Pp][Oo][Ll][Yy][Mm][Oo][Rr][Pp][Hh][Ii][Cc] TRETURN(MACH_MSG_TYPE_POLYMORPHIC,word_size_in_bits); ! 151: ! 152: <Normal>"MACH_MSG_TYPE_UNSTRUCTURED" TRETURN(MACH_MSG_TYPE_UNSTRUCTURED,0); ! 153: <Normal>"MACH_MSG_TYPE_BIT" TRETURN(MACH_MSG_TYPE_BIT,1); ! 154: <Normal>"MACH_MSG_TYPE_BOOLEAN" TRETURN(MACH_MSG_TYPE_BOOLEAN,32); ! 155: <Normal>"MACH_MSG_TYPE_INTEGER_16" TRETURN(MACH_MSG_TYPE_INTEGER_16,16); ! 156: <Normal>"MACH_MSG_TYPE_INTEGER_32" TRETURN(MACH_MSG_TYPE_INTEGER_32,32); ! 157: <Normal>"MACH_MSG_TYPE_INTEGER_64" TRETURN(MACH_MSG_TYPE_INTEGER_64,64); ! 158: <Normal>"MACH_MSG_TYPE_CHAR" TRETURN(MACH_MSG_TYPE_CHAR,8); ! 159: <Normal>"MACH_MSG_TYPE_BYTE" TRETURN(MACH_MSG_TYPE_BYTE,8); ! 160: <Normal>"MACH_MSG_TYPE_INTEGER_8" TRETURN(MACH_MSG_TYPE_INTEGER_8,8); ! 161: <Normal>"MACH_MSG_TYPE_REAL" TRETURN(MACH_MSG_TYPE_REAL,0); ! 162: <Normal>"MACH_MSG_TYPE_STRING" TRETURN(MACH_MSG_TYPE_STRING,0); ! 163: <Normal>"MACH_MSG_TYPE_STRING_C" TRETURN(MACH_MSG_TYPE_STRING_C,0); ! 164: ! 165: <Normal>"MACH_MSG_TYPE_MOVE_RECEIVE" TPRETURN(MACH_MSG_TYPE_MOVE_RECEIVE,MACH_MSG_TYPE_PORT_RECEIVE,word_size_in_bits); ! 166: <Normal>"MACH_MSG_TYPE_COPY_SEND" TPRETURN(MACH_MSG_TYPE_COPY_SEND,MACH_MSG_TYPE_PORT_SEND,word_size_in_bits); ! 167: <Normal>"MACH_MSG_TYPE_MAKE_SEND" TPRETURN(MACH_MSG_TYPE_MAKE_SEND,MACH_MSG_TYPE_PORT_SEND,word_size_in_bits); ! 168: <Normal>"MACH_MSG_TYPE_MOVE_SEND" TPRETURN(MACH_MSG_TYPE_MOVE_SEND,MACH_MSG_TYPE_PORT_SEND,word_size_in_bits); ! 169: <Normal>"MACH_MSG_TYPE_MAKE_SEND_ONCE" TPRETURN(MACH_MSG_TYPE_MAKE_SEND_ONCE,MACH_MSG_TYPE_PORT_SEND_ONCE,word_size_in_bits); ! 170: <Normal>"MACH_MSG_TYPE_MOVE_SEND_ONCE" TPRETURN(MACH_MSG_TYPE_MOVE_SEND_ONCE,MACH_MSG_TYPE_PORT_SEND_ONCE,word_size_in_bits); ! 171: ! 172: <Normal>"MACH_MSG_TYPE_PORT_NAME" TRETURN(MACH_MSG_TYPE_PORT_NAME,word_size_in_bits); ! 173: <Normal>"MACH_MSG_TYPE_PORT_RECEIVE" TPRETURN(MACH_MSG_TYPE_POLYMORPHIC,MACH_MSG_TYPE_PORT_RECEIVE,word_size_in_bits); ! 174: <Normal>"MACH_MSG_TYPE_PORT_SEND" TPRETURN(MACH_MSG_TYPE_POLYMORPHIC,MACH_MSG_TYPE_PORT_SEND,word_size_in_bits); ! 175: <Normal>"MACH_MSG_TYPE_PORT_SEND_ONCE" TPRETURN(MACH_MSG_TYPE_POLYMORPHIC,MACH_MSG_TYPE_PORT_SEND_ONCE,word_size_in_bits); ! 176: <Normal>"MACH_MSG_TYPE_POLYMORPHIC" TRETURN(MACH_MSG_TYPE_POLYMORPHIC,0); ! 177: ! 178: <Normal>":" RETURN(syColon); ! 179: <Normal>";" RETURN(sySemi); ! 180: <Normal>"," RETURN(syComma); ! 181: <Normal>"+" RETURN(syPlus); ! 182: <Normal>"-" RETURN(syMinus); ! 183: <Normal>"*" RETURN(syStar); ! 184: <Normal>"/" RETURN(syDiv); ! 185: <Normal>"(" RETURN(syLParen); ! 186: <Normal>")" RETURN(syRParen); ! 187: <Normal>"=" RETURN(syEqual); ! 188: <Normal>"^" RETURN(syCaret); ! 189: <Normal>"~" RETURN(syTilde); ! 190: <Normal>"<" RETURN(syLAngle); ! 191: <Normal>">" RETURN(syRAngle); ! 192: <Normal>"[" RETURN(syLBrack); ! 193: <Normal>"]" RETURN(syRBrack); ! 194: <Normal>"|" RETURN(syBar); ! 195: ! 196: <Normal>{Ident} { yylval.identifier = strmake(yytext); ! 197: RETURN(syIdentifier); } ! 198: <Normal>{Number} { yylval.number = atoi(yytext); RETURN(syNumber); } ! 199: ! 200: <String>{String} { yylval.string = strmake(yytext); ! 201: BEGIN Normal; RETURN(syString); } ! 202: <FileName>{FileName} { yylval.string = strmake(yytext); ! 203: BEGIN Normal; RETURN(syFileName); } ! 204: <QString>{QString} { yylval.string = strmake(yytext); ! 205: BEGIN Normal; RETURN(syQString); } ! 206: ! 207: ^\#[ \t]*{Number}[ \t]*\"[^"]*\" { doSharp(yytext+1); ! 208: SAVE_BEGIN; ! 209: BEGIN SkipToEOL; } ! 210: ^\#\ *{Number} { doSharp(yytext+1); ! 211: SAVE_BEGIN; ! 212: BEGIN SkipToEOL; } ! 213: ^\# { yyerror("illegal # directive"); ! 214: SAVE_BEGIN; ! 215: BEGIN SkipToEOL; } ! 216: ! 217: <SkipToEOL>\n RSTR_BEGIN; ! 218: <SkipToEOL>. ; ! 219: ! 220: [ \t] ; ! 221: \n { lineno++; } ! 222: . { BEGIN Normal; RETURN(syError); } ! 223: ! 224: %% ! 225: ! 226: extern void ! 227: LookNormal(void) ! 228: { ! 229: if (inname == 0) ! 230: { ! 231: inname = strmake("(unknown)"); ! 232: lineno = 0; ! 233: } ! 234: ! 235: BEGIN Normal; ! 236: } ! 237: ! 238: extern void ! 239: LookString(void) ! 240: { ! 241: BEGIN String; ! 242: } ! 243: ! 244: extern void ! 245: LookQString(void) ! 246: { ! 247: BEGIN QString; ! 248: } ! 249: ! 250: extern void ! 251: LookFileName(void) ! 252: { ! 253: BEGIN FileName; ! 254: } ! 255: ! 256: static void ! 257: doSharp(const char *body) ! 258: { ! 259: register const char *startName; ! 260: ! 261: lineno = atoi(body); ! 262: startName = strchr(body, '"'); ! 263: if (startName != NULL) ! 264: { ! 265: *strrchr(body, '"') = '\0'; ! 266: strfree(inname); ! 267: inname = strmake(startName+1); ! 268: } ! 269: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.