1: %{# 2: /* e.y 4.1 83/02/11 */ 3: #include "e.h" 4: # 5: int fromflg; 6: %} 7: %term CONTIG QTEXT SPACE THIN TAB 8: %term MATRIX LCOL CCOL RCOL COL 9: %term MARK LINEUP 10: %term SUM INT PROD UNION INTER 11: %term LPILE PILE CPILE RPILE ABOVE 12: %term DEFINE TDEFINE NDEFINE DELIM GSIZE GFONT INCLUDE 13: %right FROM TO 14: %left OVER SQRT 15: %right SUP SUB 16: %right SIZE FONT ROMAN ITALIC BOLD FAT 17: %right UP DOWN BACK FWD 18: %left LEFT RIGHT 19: %right DOT DOTDOT HAT TILDE BAR UNDER VEC DYAD 20: 21: %% 22: 23: stuff : eqn { putout($1); } 24: | error { error(!FATAL, "syntax error"); } 25: | { eqnreg = 0; } 26: ; 27: 28: eqn : box 29: | eqn box { eqnbox($1, $2, 0); } 30: | eqn lineupbox { eqnbox($1, $2, 1); } 31: | LINEUP { lineup(0); } 32: ; 33: 34: lineupbox: LINEUP box { $$ = $2; lineup(1); } 35: ; 36: 37: matrix : MATRIX { $$ = ct; } ; 38: 39: collist : column 40: | collist column 41: ; 42: 43: column : lcol '{' list '}' { column('L', $1); } 44: | ccol '{' list '}' { column('C', $1); } 45: | rcol '{' list '}' { column('R', $1); } 46: | col '{' list '}' { column('-', $1); } 47: ; 48: 49: lcol : LCOL { $$ = ct++; } ; 50: ccol : CCOL { $$ = ct++; } ; 51: rcol : RCOL { $$ = ct++; } ; 52: col : COL { $$ = ct++; } ; 53: 54: sbox : sup box %prec SUP { $$ = $2; } 55: ; 56: 57: tbox : to box %prec TO { $$ = $2; } 58: | %prec FROM { $$ = 0; } 59: ; 60: 61: box : box OVER box { boverb($1, $3); } 62: | MARK box { mark($2); } 63: | size box %prec SIZE { size($1, $2); } 64: | font box %prec FONT { font($1, $2); } 65: | FAT box { fatbox($2); } 66: | SQRT box { sqrt($2); } 67: | lpile '{' list '}' { lpile('L', $1, ct); ct = $1; } 68: | cpile '{' list '}' { lpile('C', $1, ct); ct = $1; } 69: | rpile '{' list '}' { lpile('R', $1, ct); ct = $1; } 70: | pile '{' list '}' { lpile('-', $1, ct); ct = $1; } 71: | box sub box sbox %prec SUB { shift2($1, $3, $4); } 72: | box sub box %prec SUB { bshiftb($1, $2, $3); } 73: | box sup box %prec SUP { bshiftb($1, $2, $3); } 74: | int sub box sbox %prec SUB { integral($1, $3, $4); } 75: | int sub box %prec SUB { integral($1, $3, 0); } 76: | int sup box %prec SUP { integral($1, 0, $3); } 77: | int { integral($1, 0, 0); } 78: | left eqn right { paren($1, $2, $3); } 79: | pbox 80: | box from box tbox %prec FROM { fromto($1, $3, $4); fromflg=0; } 81: | box to box %prec TO { fromto($1, 0, $3); } 82: | box diacrit { diacrit($1, $2); } 83: | fwd box %prec UP { move(FWD, $1, $2); } 84: | up box %prec UP { move(UP, $1, $2); } 85: | back box %prec UP { move(BACK, $1, $2); } 86: | down box %prec UP { move(DOWN, $1, $2); } 87: | matrix '{' collist '}' { matrix($1); } 88: ; 89: 90: int : INT { setintegral(); } 91: ; 92: 93: fwd : FWD text { $$ = atoi((char *) $1); } ; 94: up : UP text { $$ = atoi((char *) $1); } ; 95: back : BACK text { $$ = atoi((char *) $1); } ; 96: down : DOWN text { $$ = atoi((char *) $1); } ; 97: 98: diacrit : HAT { $$ = HAT; } 99: | VEC { $$ = VEC; } 100: | DYAD { $$ = DYAD; } 101: | BAR { $$ = BAR; } 102: | UNDER { $$ = UNDER; } /* under bar */ 103: | DOT { $$ = DOT; } 104: | TILDE { $$ = TILDE; } 105: | DOTDOT { $$ = DOTDOT; } /* umlaut = double dot */ 106: ; 107: 108: from : FROM { $$=ps; ps -= 3; fromflg = 1; 109: if(dbg)printf(".\tfrom: old ps %d, new ps %d, fflg %d\n", $$, ps, fromflg); 110: } 111: ; 112: 113: to : TO { $$=ps; if(fromflg==0)ps -= 3; 114: if(dbg)printf(".\tto: old ps %d, new ps %d\n", $$, ps); 115: } 116: ; 117: 118: left : LEFT text { $$ = ((char *)$2)[0]; } 119: | LEFT '{' { $$ = '{'; } 120: ; 121: 122: right : RIGHT text { $$ = ((char *)$2)[0]; } 123: | RIGHT '}' { $$ = '}'; } 124: | { $$ = 0; } 125: ; 126: 127: list : eqn { lp[ct++] = $1; } 128: | list ABOVE eqn { lp[ct++] = $3; } 129: ; 130: 131: lpile : LPILE { $$ = ct; } ; 132: cpile : CPILE { $$ = ct; } ; 133: pile : PILE { $$ = ct; } ; 134: rpile : RPILE { $$ = ct; } ; 135: 136: size : SIZE text { $$ = ps; setsize((char *) $2); } 137: ; 138: 139: font : ROMAN { setfont(ROM); } 140: | ITALIC { setfont(ITAL); } 141: | BOLD { setfont(BLD); } 142: | FONT text { setfont(((char *)$2)[0]); } 143: ; 144: 145: sub : SUB { shift(SUB); } 146: ; 147: 148: sup : SUP { shift(SUP); } 149: ; 150: 151: pbox : '{' eqn '}' { $$ = $2; } 152: | QTEXT { text(QTEXT, (char *) $1); } 153: | CONTIG { text(CONTIG, (char *) $1); } 154: | SPACE { text(SPACE, 0); } 155: | THIN { text(THIN, 0); } 156: | TAB { text(TAB, 0); } 157: | SUM { funny(SUM); } 158: | PROD { funny(PROD); } 159: | UNION { funny(UNION); } 160: | INTER { funny(INTER); } /* intersection */ 161: ; 162: 163: text : CONTIG 164: | QTEXT 165: ; 166: 167: %%