1: # include "ne.h" 2: 3: fromto(p1,p2,p3) int p1,p2,p3; { 4: int w,h,b,h1,b1; 5: yyval = oalloc(); 6: h1 = eht[yyval] = eht[p1]; 7: b1 = ebase[p1]; 8: b = 0; 9: w = ewid[p1]; 10: if( p2>0 ){ 11: w = max(w, ewid[p2]); 12: eht[yyval] =+ eht[p2]; 13: b = eht[p2]; 14: } 15: if( p3>0 ){ 16: w = max(w, ewid[p3]); 17: eht[yyval] =+ eht[p3]; 18: } 19: ewid[yyval] = w; 20: printf(".ds %d ", yyval); /* bottom of middle box */ 21: if( p2>0 ){ 22: down(eht[p2]-ebase[p2]+b1); 23: fwd((w-ewid[p2])/2); 24: printf("\\*(%d", p2); 25: back((w+ewid[p2])/2); 26: up(eht[p2]-ebase[p2]+b1); 27: } 28: fwd((w-ewid[p1])/2); 29: printf("\\*(%d", p1); 30: fwd((1+w-ewid[p1])/2); 31: if( p3>0 ){ 32: up(h1-b1+ebase[p3]); 33: back((w+ewid[p3])/2); 34: printf("\\*(%d", p3); 35: fwd((w-ewid[p3])/2); 36: down(h1-b1+ebase[p3]); 37: } 38: putchar('\n'); 39: ebase[yyval] = b + b1; 40: if(dbg)printf(".\tfrom to: S%d <- %d f %d t %d; h=%d b=%d,w=%d\n", 41: yyval,p1,p2,p3,eht[yyval], ebase[yyval], ewid[yyval]); 42: ofree(p1); 43: if( p2>0 ) ofree(p2); 44: if( p3>0 ) ofree(p3); 45: } 46: 47: paren(leftc,p1,rightc) int p1, leftc, rightc; { 48: int n,h1,b1; 49: yyval = oalloc(); 50: h1 = eht[p1]; ebase[yyval] = b1 = ebase[p1]; 51: n = max(b1+1, h1-b1-1); 52: eht[yyval] = 2*n; 53: if( eht[yyval] > h1 ) 54: ++ebase[yyval]; 55: printf(".ds %d ", yyval); 56: brack(n,'|'); 57: printf("\\*(%d", p1); 58: if( rightc ) 59: brack(n,'|'); 60: putchar('\n'); 61: ewid[yyval] = ewid[p1] + 1 + (rightc ? 1 : 0); 62: if(dbg)printf(".\tcurly: h=%d b=%d n=%d w=%d l=%c,r=%c\n", 63: eht[yyval],ebase[yyval],n,ewid[yyval],leftc,rightc); 64: ofree(p1); 65: } 66: 67: brack(n,c) int n,c; { 68: int j; 69: down(n-1); 70: for( j=0; j < n; j++ ){ 71: putchar(c); 72: back(1); 73: up(2); 74: } 75: down(n+1); 76: fwd(1); 77: } 78: 79: diacrit(p1,type) int p1,type; { 80: int c,t; 81: c = oalloc(); 82: switch(type){ 83: case 'H': 84: printf(".ds %d ^\n",c); 85: ewid[c] = 1; 86: break; 87: case 'T': 88: printf(".ds %d ~\n",c); 89: ewid[c] = 1; 90: break; 91: case 'D': 92: printf(".ds %d ", c); 93: up(2); 94: putchar('.'); 95: down(2); 96: putchar('\n'); 97: ewid[c] = 1; 98: break; 99: case 'U': 100: printf(".ds %d ", c); 101: up(2); 102: printf(".."); 103: down(2); 104: putchar('\n'); 105: ewid[c] = 2; 106: break; 107: case 'B': 108: printf(".ds %d ", c); 109: up(eht[p1]); 110: line(ewid[p1]); 111: down(eht[p1]); 112: putchar('\n'); 113: ewid[c] = ewid[p1]; 114: break; 115: case 'N': 116: printf(".ds %d ", c); 117: down(ebase[p1]); 118: line(ewid[p1]); 119: up(ebase[p1]); 120: putchar('\n'); 121: ewid[c] = ewid[p1]; 122: break; 123: } 124: yyval = oalloc(); 125: printf(".ds %d \\*(%d", yyval, p1); 126: back((ewid[p1]+ewid[c])/2); 127: printf("\\*(%d", c); 128: fwd(abs(ewid[p1]-ewid[c])/2); 129: putchar('\n'); 130: ewid[yyval] = max(ewid[p1], ewid[c]); 131: ebase[yyval] = ebase[p1]; 132: eht[yyval] = eht[p1]; 133: if( type != 'N' ) 134: eht[yyval]++; 135: if(dbg)printf(".\t%c diacrit: S%d <- %d; h=%d,b=%d,w=%d\n", 136: type, yyval, p1, eht[yyval], ebase[yyval], ewid[yyval]); 137: ofree(p1); ofree(c); 138: } 139: 140: move(dir, amt, p) int dir, amt; char *p; { 141: yyval = p; 142: printf(".ds %d ", yyval); 143: if( dir==0 ) fwd(amt); 144: else if( dir==1 ) up(amt); 145: else if( dir==2 ) back(amt); 146: else if( dir==3 ) down(amt); 147: printf("\\*(%d\n", p); 148: if( dir==1 ) 149: ebase[yyval] =- amt; 150: else if( dir==3 ) 151: ebase[yyval] =+ amt; 152: if(dbg)printf(".\tmove %d dir %d amt %d; h=%d b=%d\n", 153: p,dir,amt,eht[yyval],ebase[yyval]); 154: }