1: /* @(#)c05.c 2.1 SCCS id keyword */ 2: # 3: #include "c0.h" 4: /* 5: * info on operators: 6: * 01-- is binary operator 7: * 02-- left (or only) operand must be lvalue 8: * 04-- is relational operator 9: * 010-- is assignment-type operator 10: * 020-- non-float req. on left 11: * 040-- non-float req. on right 12: * 0100-- is commutative 13: * 0200-- is right, not left-associative 14: * 0400-- is leaf of tree 15: * *0XX000-- XX is priority of operator 16: */ 17: int opdope[] { 18: 000000, /* EOFC */ 19: 000000, /* ; */ 20: 000000, /* { */ 21: 000000, /* } */ 22: 036000, /* [ */ 23: 002000, /* ] */ 24: 037000, /* ( */ 25: 002000, /* ) */ 26: 014201, /* : */ 27: 007001, /* , */ 28: 000001, /* field selection */ 29: 034201, /* CAST */ 30: 000000, /* ETYPE */ 31: 000001, /* integer->ptr */ 32: 000001, /* ptr->integer */ 33: 000001, /* long->ptr */ 34: 000000, /* 16 */ 35: 000000, /* 17 */ 36: 000000, /* 18 */ 37: 000000, /* 19 */ 38: 000400, /* name */ 39: 000400, /* short constant */ 40: 000400, /* string */ 41: 000400, /* float */ 42: 000400, /* double */ 43: 000400, /* long constant */ 44: 000400, /* long constant <= 16 bits */ 45: 000000, /* 27 */ 46: 000000, /* 28 */ 47: 000000, /* 29 */ 48: 034203, /* ++pre */ 49: 034203, /* --pre */ 50: 034203, /* ++post */ 51: 034203, /* --post */ 52: 034200, /* !un */ 53: 034202, /* &un */ 54: 034220, /* *un */ 55: 034200, /* -un */ 56: 034220, /* ~un */ 57: 036001, /* . (structure reference) */ 58: 030101, /* + */ 59: 030001, /* - */ 60: 032101, /* * */ 61: 032001, /* / */ 62: 032001, /* % */ 63: 026061, /* >> */ 64: 026061, /* << */ 65: 020161, /* & */ 66: 017161, /* | */ 67: 017161, /* ^ */ 68: 036001, /* -> */ 69: 000000, /* int -> double */ 70: 000000, /* double -> int */ 71: 016001, /* && */ 72: 015001, /* || */ 73: 030001, /* &~ */ 74: 000000, /* 56 */ 75: 000000, /* 57 */ 76: 000000, /* 58 */ 77: 000000, /* 59 */ 78: 022005, /* == */ 79: 022005, /* != */ 80: 024005, /* <= */ 81: 024005, /* < */ 82: 024005, /* >= */ 83: 024005, /* > */ 84: 024005, /* <p */ 85: 024005, /* <=p */ 86: 024005, /* >p */ 87: 024005, /* >=p */ 88: 012213, /* =+ */ 89: 012213, /* =- */ 90: 012213, /* =* */ 91: 012213, /* =/ */ 92: 012213, /* =% */ 93: 012253, /* =>> */ 94: 012253, /* =<< */ 95: 012253, /* =& */ 96: 012253, /* =| */ 97: 012253, /* =^ */ 98: 012213, /* = */ 99: 000000, /* 81 */ 100: 000000, /* 82 */ 101: 000000, /* 83 */ 102: 000000, /* 84 */ 103: 000000, /* 85 */ 104: 000000, /* 86 */ 105: 000000, /* 87 */ 106: 000000, /* 88 */ 107: 000000, /* 89 */ 108: 014201, /* ? */ 109: 034200, /* sizeof */ 110: 000000, /* 92 */ 111: 021101, /* min */ 112: 021101, /* minp */ 113: 021101, /* max */ 114: 021101, /* maxp */ 115: 007001, /* , */ 116: 000000, /* 98 */ 117: 000000, /* 99 */ 118: 036001, /* call */ 119: 036001, /* mcall */ 120: 000000, /* goto */ 121: 000000, /* jump cond */ 122: 000000, /* branch cond */ 123: 000000, /* 105 */ 124: 000000, /* 106 */ 125: 000000, /* 107 */ 126: 000000, /* 108 */ 127: 000000, /* char->int */ 128: 000000 /* force r0 */ 129: }; 130: 131: /* 132: * conversion table: 133: * FTI: float (or double) to integer 134: * ITF: integer to float 135: * ITP: integer to pointer 136: * ITL: integer to long 137: * LTI: long to integer 138: * LTF: long to float 139: * FTL: float to long 140: * PTI: pointer to integer 141: * LTP: long to ptr (ptr[long]) 142: * XX: usually illegal 143: * When FTI, LTI, FTL are added in they specify 144: * that it is the left operand that should be converted. 145: * For + this is done and the conversion is turned back into 146: * ITF, ITL, LTF. 147: * For = however the left operand can't be converted 148: * and the specified conversion is applied to the rhs. 149: */ 150: char cvtab[4][4] { 151: /* int double long ptr */ 152: /* int */ 0, (FTI<<4)+ITF, (LTI<<4)+ITL, (ITP<<4)+ITP, 153: /* double */ ITF, 0, LTF, XX, 154: /* long */ ITL, (FTL<<4)+LTF, 0, (LTP<<4)+LTP, 155: /* ptr */ ITP, XX, LTP, PTI, 156: }; 157: 158: /* 159: * relate conversion numbers to operators 160: */ 161: char cvntab[] { 162: 0, ITOF, ITOL, LTOF, ITOP, PTOI, FTOI, LTOI, FTOL, LTOP, 163: }; 164: 165: /* 166: * character type table 167: */ 168: char ctab[] { 169: EOFC, INSERT, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, 170: UNKN, SPACE, NEWLN, SPACE, SPACE, UNKN, UNKN, UNKN, 171: UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, 172: UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, 173: SPACE, EXCLA, DQUOTE, SHARP, UNKN, MOD, AND, SQUOTE, 174: LPARN, RPARN, TIMES, PLUS, COMMA, MINUS, PERIOD, DIVIDE, 175: DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, 176: DIGIT, DIGIT, COLON, SEMI, LESS, ASSIGN, GREAT, QUEST, 177: UNKN, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, 178: LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, 179: LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, 180: LETTER, LETTER, LETTER, LBRACK, BSLASH, RBRACK, EXOR, LETTER, 181: UNKN, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, 182: LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, 183: LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, 184: LETTER, LETTER, LETTER, LBRACE, OR, RBRACE, COMPL, UNKN 185: };