1 %{# 2 /*- 3 * Copyright (c) 1979, 1980, 1981, 1986, 1988, 1990, 1991, 1992 4 * The Regents of the University of California. 5 * Copyright (C) Caldera International Inc. 2001-2002. 6 * Copyright (c) 2003, 2004, 2007 7 * Thorsten "mirabilos" Glaser <tg@mirbsd.org> 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, 11 * with or without modification, are permitted provided 12 * that the following conditions are met: 13 * 14 * Redistributions of source code and documentation must retain 15 * the above copyright notice, this list of conditions and the 16 * following disclaimer. Redistributions in binary form must 17 * reproduce the above copyright notice, this list of conditions 18 * and the following disclaimer in the documentation and/or other 19 * materials provided with the distribution. 20 * 21 * All advertising materials mentioning features or use of this 22 * software must display the following acknowledgement: 23 * This product includes software developed or owned by 24 * Caldera International, Inc. 25 * 26 * Neither the name of Caldera International, Inc. nor the names 27 * of other contributors may be used to endorse or promote products 28 * derived from this software without specific prior written permission. 29 * 30 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 31 * INTERNATIONAL, INC. AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 32 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 33 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 34 * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 35 * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 36 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 38 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 40 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 41 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 */ 43 44 #include <sys/cdefs.h> 45 __SCCSID("@(#)e.y 4.2 (Berkeley) 4/17/91"); 46 __RCSID("$MirOS: src/usr.bin/oldroff/neqn/ey.y,v 1.2 2008/11/08 23:04:36 tg Exp $"); 47 48 #include "e.h" 49 int fromflg; 50 %} 51 %term CONTIG QTEXT SPACE THIN TAB 52 %term MATRIX LCOL CCOL RCOL COL 53 %term MARK LINEUP 54 %term SUM INT PROD UNION INTER 55 %term LPILE PILE CPILE RPILE ABOVE 56 %term DEFINE TDEFINE NDEFINE DELIM GSIZE GFONT INCLUDE 57 %right FROM TO 58 %left OVER SQRT 59 %right SUP SUB 60 %right SIZE FONT ROMAN ITALIC BOLD FAT 61 %right UP DOWN BACK FWD 62 %left LEFT RIGHT 63 %right DOT DOTDOT HAT TILDE BAR UNDER VEC DYAD 64 65 %% 66 67 stuff : eqn { putout($1); } 68 | error { error(!FATAL, "syntax error"); } 69 | { eqnreg = 0; } 70 ; 71 72 eqn : box 73 | eqn box { eqnbox($1, $2, 0); } 74 | eqn lineupbox { eqnbox($1, $2, 1); } 75 | LINEUP { lineup(0); } 76 ; 77 78 lineupbox: LINEUP box { $$ = $2; lineup(1); } 79 ; 80 81 matrix : MATRIX { $$ = ct; } ; 82 83 collist : column 84 | collist column 85 ; 86 87 column : lcol '{' list '}' { column('L', $1); } 88 | ccol '{' list '}' { column('C', $1); } 89 | rcol '{' list '}' { column('R', $1); } 90 | col '{' list '}' { column('-', $1); } 91 ; 92 93 lcol : LCOL { $$ = ct++; } ; 94 ccol : CCOL { $$ = ct++; } ; 95 rcol : RCOL { $$ = ct++; } ; 96 col : COL { $$ = ct++; } ; 97 98 sbox : sup box %prec SUP { $$ = $2; } 99 ; 100 101 tbox : to box %prec TO { $$ = $2; } 102 | %prec FROM { $$ = 0; } 103 ; 104 105 box : box OVER box { boverb($1, $3); } 106 | MARK box { mark($2); } 107 | size box %prec SIZE { size($1, $2); } 108 | font box %prec FONT { font($1, $2); } 109 | FAT box { fatbox($2); } 110 | SQRT box { eqnsqrt($2); } 111 | lpile '{' list '}' { lpile('L', $1, ct); ct = $1; } 112 | cpile '{' list '}' { lpile('C', $1, ct); ct = $1; } 113 | rpile '{' list '}' { lpile('R', $1, ct); ct = $1; } 114 | pile '{' list '}' { lpile('-', $1, ct); ct = $1; } 115 | box sub box sbox %prec SUB { shift2($1, $3, $4); } 116 | box sub box %prec SUB { bshiftb($1, $2, $3); } 117 | box sup box %prec SUP { bshiftb($1, $2, $3); } 118 | int sub box sbox %prec SUB { integral($1, $3, $4); } 119 | int sub box %prec SUB { integral($1, $3, 0); } 120 | int sup box %prec SUP { integral($1, 0, $3); } 121 | int { integral($1, 0, 0); } 122 | left eqn right { paren($1, $2, $3); } 123 | pbox 124 | box from box tbox %prec FROM { fromto($1, $3, $4); fromflg=0; } 125 | box to box %prec TO { fromto($1, 0, $3); } 126 | box diacrit { diacrit($1, $2); } 127 | fwd box %prec UP { move(FWD, $1, $2); } 128 | up box %prec UP { move(UP, $1, $2); } 129 | back box %prec UP { move(BACK, $1, $2); } 130 | down box %prec UP { move(DOWN, $1, $2); } 131 | matrix '{' collist '}' { matrix($1); } 132 ; 133 134 int : INT { setintegral(); } 135 ; 136 137 fwd : FWD text { $$ = atoi((char *) $1); } ; 138 up : UP text { $$ = atoi((char *) $1); } ; 139 back : BACK text { $$ = atoi((char *) $1); } ; 140 down : DOWN text { $$ = atoi((char *) $1); } ; 141 142 diacrit : HAT { $$ = HAT; } 143 | VEC { $$ = VEC; } 144 | DYAD { $$ = DYAD; } 145 | BAR { $$ = BAR; } 146 | UNDER { $$ = UNDER; } /* under bar */ 147 | DOT { $$ = DOT; } 148 | TILDE { $$ = TILDE; } 149 | DOTDOT { $$ = DOTDOT; } /* umlaut = double dot */ 150 ; 151 152 from : FROM { $$=ps; ps -= 3; fromflg = 1; 153 if(dbg)printf(".\tfrom: old ps %d, new ps %d, fflg %d\n", $$, ps, fromflg); 154 } 155 ; 156 157 to : TO { $$=ps; if(fromflg==0)ps -= 3; 158 if(dbg)printf(".\tto: old ps %d, new ps %d\n", $$, ps); 159 } 160 ; 161 162 left : LEFT text { $$ = ((char *)$2)[0]; } 163 | LEFT '{' { $$ = '{'; } 164 ; 165 166 right : RIGHT text { $$ = ((char *)$2)[0]; } 167 | RIGHT '}' { $$ = '}'; } 168 | { $$ = 0; } 169 ; 170 171 list : eqn { lp[ct++] = $1; } 172 | list ABOVE eqn { lp[ct++] = $3; } 173 ; 174 175 lpile : LPILE { $$ = ct; } ; 176 cpile : CPILE { $$ = ct; } ; 177 pile : PILE { $$ = ct; } ; 178 rpile : RPILE { $$ = ct; } ; 179 180 size : SIZE text { $$ = ps; setsize((char *) $2); } 181 ; 182 183 font : ROMAN { setfont(ROM); } 184 | ITALIC { setfont(ITAL); } 185 | BOLD { setfont(BLD); } 186 | FONT text { setfont(((char *)$2)[0]); } 187 ; 188 189 sub : SUB { shift(SUB); } 190 ; 191 192 sup : SUP { shift(SUP); } 193 ; 194 195 pbox : '{' eqn '}' { $$ = $2; } 196 | QTEXT { text(QTEXT, (char *) $1); } 197 | CONTIG { text(CONTIG, (char *) $1); } 198 | SPACE { text(SPACE, 0); } 199 | THIN { text(THIN, 0); } 200 | TAB { text(TAB, 0); } 201 | SUM { funny(SUM); } 202 | PROD { funny(PROD); } 203 | UNION { funny(UNION); } 204 | INTER { funny(INTER); } /* intersection */ 205 ; 206 207 text : CONTIG 208 | QTEXT 209 ; 210 211 %% 212