1: # include "e.h" 2: 3: paren(leftc, p1, rightc) int p1, leftc, rightc; { 4: int n, m, h1, j, b1, v; 5: h1 = eht[p1]; b1 = ebase[p1]; 6: yyval = p1; 7: n = max(b1+VERT(1), h1-b1-VERT(1)) / VERT(1); 8: if( n<2 ) n = 1; 9: m = n-2; 10: if (leftc=='{' || rightc == '}') { 11: n = n%2 ? n : ++n; 12: if( n<3 ) n=3; 13: m = n-3; 14: } 15: eht[yyval] = VERT(2 * n); 16: ebase[yyval] = (n)/2 * VERT(2); 17: if (n%2 == 0) 18: ebase[yyval] -= VERT(1); 19: v = b1 - h1/2 + VERT(1); 20: printf(".ds %d \\|\\v'%du'", yyval, v); 21: switch( leftc ) { 22: case 'n': /* nothing */ 23: case '\0': 24: break; 25: case 'f': /* floor */ 26: if (n <= 1) 27: printf("\\(lf"); 28: else 29: brack(m, "\\(bv", "\\(bv", "\\(lf"); 30: break; 31: case 'c': /* ceiling */ 32: if (n <= 1) 33: printf("\\(lc"); 34: else 35: brack(m, "\\(lc", "\\(bv", "\\(bv"); 36: break; 37: case '{': 38: printf("\\b'\\(lt"); 39: for(j = 0; j < m; j += 2) printf("\\(bv"); 40: printf("\\(lk"); 41: for(j = 0; j < m; j += 2) printf("\\(bv"); 42: printf("\\(lb'"); 43: break; 44: case '(': 45: brack(m, "\\(lt", "\\(bv", "\\(lb"); 46: break; 47: case '[': 48: brack(m, "\\(lc", "\\(bv", "\\(lf"); 49: break; 50: case '|': 51: brack(m, "|", "|", "|"); 52: break; 53: default: 54: brack(m, (char *) &leftc, (char *) &leftc, (char *) &leftc); 55: break; 56: } 57: printf("\\v'%du'\\*(%d", -v, p1); 58: if( rightc ) { 59: printf("\\|\\v'%du'", v); 60: switch( rightc ) { 61: case 'f': /* floor */ 62: if (n <= 1) 63: printf("\\(rf"); 64: else 65: brack(m, "\\(bv", "\\(bv", "\\(rf"); 66: break; 67: case 'c': /* ceiling */ 68: if (n <= 1) 69: printf("\\(rc"); 70: else 71: brack(m, "\\(rc", "\\(bv", "\\(bv"); 72: break; 73: case '}': 74: printf("\\b'\\(rt"); 75: for(j = 0; j< m; j += 2)printf("\\(bv"); 76: printf("\\(rk"); 77: for(j = 0; j< m; j += 2) printf("\\(bv"); 78: printf("\\(rb'"); 79: break; 80: case ']': 81: brack(m, "\\(rc", "\\(bv", "\\(rf"); 82: break; 83: case ')': 84: brack(m, "\\(rt", "\\(bv", "\\(rb"); 85: break; 86: case '|': 87: brack(m, "|", "|", "|"); 88: break; 89: default: 90: brack(m, (char *) &rightc, (char *) &rightc, (char *) &rightc); 91: break; 92: } 93: printf("\\v'%du'", -v); 94: } 95: printf("\n"); 96: if(dbg)printf(".\tcurly: h=%d b=%d n=%d v=%d l=%c, r=%c\n", 97: eht[yyval], ebase[yyval], n, v, leftc, rightc); 98: } 99: 100: brack(m, t, c, b) int m; char *t, *c, *b; { 101: int j; 102: printf("\\b'%s", t); 103: for( j=0; j<m; j++) 104: printf("%s", c); 105: printf("%s'", b); 106: }