|
|
1.1 ! root 1: #ifndef lint ! 2: static char sccsid[] = "@(#)r0.c 1.2 (Berkeley) 8/11/83"; ! 3: #endif ! 4: ! 5: #include "r.h" ! 6: ! 7: int swlevel = -1; ! 8: int swexit[5]; ! 9: int nextcase[5]; ! 10: ! 11: swcode() { ! 12: transfer = 0; ! 13: putcom("switch"); ! 14: swlevel++; ! 15: if (swlevel >= 5) ! 16: error("Switches nested > 5"); ! 17: swexit[swlevel] = yyval = genlab(1); ! 18: outcode("\tI"); ! 19: outnum(yyval); ! 20: outcode(" = "); ! 21: balpar(); ! 22: outdon(); ! 23: nextcase[swlevel] = 0; ! 24: indent++; ! 25: } ! 26: ! 27: getcase() { ! 28: int t, lpar; ! 29: char token[100]; ! 30: ! 31: if (nextcase[swlevel] != 0) { ! 32: outgoto(swexit[swlevel]); ! 33: outcont(nextcase[swlevel]); ! 34: } ! 35: indent--; ! 36: outcode("\tif(.not.("); ! 37: do { ! 38: outcode("I"); ! 39: outnum(swexit[swlevel]); ! 40: outcode(".eq.("); ! 41: lpar = 0; ! 42: do { ! 43: if ((t=gtok(token)) == ':') ! 44: break; ! 45: if (t == '(') ! 46: lpar++; ! 47: else if (t == ')') ! 48: lpar--; ! 49: else if (t == ',') { ! 50: if (lpar == 0) ! 51: break; ! 52: } ! 53: outcode(token); ! 54: } while (lpar >= 0); ! 55: if (lpar < 0) ! 56: error("Missing left parenthesis in case"); ! 57: if (t == ',') ! 58: outcode(").or."); ! 59: } while (t != ':'); ! 60: if (lpar != 0) ! 61: error("Missing parenthesis in case"); ! 62: outcode(")))"); ! 63: nextcase[swlevel] = genlab(1); ! 64: outgoto(nextcase[swlevel]); ! 65: indent++; ! 66: } ! 67: ! 68: getdefault() { ! 69: char token[20]; ! 70: if (gnbtok(token) != ':') ! 71: error("Missing colon after default"); ! 72: outgoto(swexit[swlevel]); ! 73: outcont(nextcase[swlevel]); ! 74: indent--; ! 75: putcom("default"); ! 76: indent++; ! 77: } ! 78: ! 79: endsw(n, def) { ! 80: if (def == 0) ! 81: outcont(nextcase[swlevel]); ! 82: swlevel--; ! 83: if (swlevel < -1) ! 84: error("Switches unwound too far"); ! 85: indent--; ! 86: outcont(n); ! 87: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.