Backed out changeset e05f5705283d (wrong name)
[unleashed.git] / usr / src / cmd / eqn / e.y
blob5f49e87cf3696a0ba81b24d686aa86c67dd67b34
1 %{
2 /*
3 * CDDL HEADER START
5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License, Version 1.0 only
7 * (the "License"). You may not use this file except in compliance
8 * with the License.
10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 * or http://www.opensolaris.org/os/licensing.
12 * See the License for the specific language governing permissions
13 * and limitations under the License.
15 * When distributing Covered Code, include this CDDL HEADER in each
16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 * If applicable, add the following below this CDDL HEADER, with the
18 * fields enclosed by brackets "[]" replaced with your own identifying
19 * information: Portions Copyright [yyyy] [name of copyright owner]
21 * CDDL HEADER END
24 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
25 /* All Rights Reserved */
28 %{#
29 # ident "%Z%%M% %I% %E% SMI" /* "@(#)ucbeqn:e.y 1.1" */
30 #include "e.h"
31 #include <locale.h>
33 int fromflg;
35 %term CONTIG QTEXT SPACE THIN TAB
36 %term MATRIX LCOL CCOL RCOL COL
37 %term MARK LINEUP
38 %term SUM INT PROD UNION INTER
39 %term LPILE PILE CPILE RPILE ABOVE
40 %term DEFINE TDEFINE NDEFINE DELIM GSIZE GFONT INCLUDE
41 %right FROM TO
42 %left OVER SQRT
43 %right SUP SUB
44 %right SIZE FONT ROMAN ITALIC BOLD FAT
45 %right UP DOWN BACK FWD
46 %left LEFT RIGHT
47 %right DOT DOTDOT HAT TILDE BAR UNDER VEC DYAD
51 stuff : eqn { putout($1); }
52 | error { error(!FATAL, gettext("syntax error")); }
53 | { eqnreg = 0; }
56 eqn : box
57 | eqn box { eqnbox($1, $2, 0); }
58 | eqn lineupbox { eqnbox($1, $2, 1); }
59 | LINEUP { lineup(0); }
62 lineupbox: LINEUP box { $$ = $2; lineup(1); }
65 matrix : MATRIX { $$ = ct; } ;
67 collist : column
68 | collist column
71 column : lcol '{' list '}' { column('L', $1); }
72 | ccol '{' list '}' { column('C', $1); }
73 | rcol '{' list '}' { column('R', $1); }
74 | col '{' list '}' { column('-', $1); }
77 lcol : LCOL { $$ = ct++; } ;
78 ccol : CCOL { $$ = ct++; } ;
79 rcol : RCOL { $$ = ct++; } ;
80 col : COL { $$ = ct++; } ;
82 sbox : sup box %prec SUP { $$ = $2; }
85 tbox : to box %prec TO { $$ = $2; }
86 | %prec FROM { $$ = 0; }
89 box : box OVER box { boverb($1, $3); }
90 | MARK box { mark($2); }
91 | size box %prec SIZE { size($1, $2); }
92 | font box %prec FONT { font($1, $2); }
93 | FAT box { fatbox($2); }
94 | SQRT box { sqrt($2); }
95 | lpile '{' list '}' { lpile('L', $1, ct); ct = $1; }
96 | cpile '{' list '}' { lpile('C', $1, ct); ct = $1; }
97 | rpile '{' list '}' { lpile('R', $1, ct); ct = $1; }
98 | pile '{' list '}' { lpile('-', $1, ct); ct = $1; }
99 | box sub box sbox %prec SUB { shift2($1, $3, $4); }
100 | box sub box %prec SUB { bshiftb($1, $2, $3); }
101 | box sup box %prec SUP { bshiftb($1, $2, $3); }
102 | int sub box sbox %prec SUB { integral($1, $3, $4); }
103 | int sub box %prec SUB { integral($1, $3, 0); }
104 | int sup box %prec SUP { integral($1, 0, $3); }
105 | int { integral($1, 0, 0); }
106 | left eqn right { paren($1, $2, $3); }
107 | pbox
108 | box from box tbox %prec FROM { fromto($1, $3, $4); fromflg=0; }
109 | box to box %prec TO { fromto($1, 0, $3); }
110 | box diacrit { diacrit($1, $2); }
111 | fwd box %prec UP { move(FWD, $1, $2); }
112 | up box %prec UP { move(UP, $1, $2); }
113 | back box %prec UP { move(BACK, $1, $2); }
114 | down box %prec UP { move(DOWN, $1, $2); }
115 | matrix '{' collist '}' { matrix($1); }
118 int : INT { setintegral(); }
121 fwd : FWD text { $$ = atoi((char *) $1); } ;
122 up : UP text { $$ = atoi((char *) $1); } ;
123 back : BACK text { $$ = atoi((char *) $1); } ;
124 down : DOWN text { $$ = atoi((char *) $1); } ;
126 diacrit : HAT { $$ = HAT; }
127 | VEC { $$ = VEC; }
128 | DYAD { $$ = DYAD; }
129 | BAR { $$ = BAR; }
130 | UNDER { $$ = UNDER; } /* under bar */
131 | DOT { $$ = DOT; }
132 | TILDE { $$ = TILDE; }
133 | DOTDOT { $$ = DOTDOT; } /* umlaut = double dot */
136 from : FROM { $$=ps; ps -= 3; fromflg = 1;
137 if(dbg)printf(".\tfrom: old ps %d, new ps %d, fflg %d\n", $$, ps, fromflg);
141 to : TO { $$=ps; if(fromflg==0)ps -= 3;
142 if(dbg)printf(".\tto: old ps %d, new ps %d\n", $$, ps);
146 left : LEFT text { $$ = ((char *)$2)[0]; }
147 | LEFT '{' { $$ = '{'; }
150 right : RIGHT text { $$ = ((char *)$2)[0]; }
151 | RIGHT '}' { $$ = '}'; }
152 | { $$ = 0; }
155 list : eqn { lp[ct++] = $1; }
156 | list ABOVE eqn { lp[ct++] = $3; }
159 lpile : LPILE { $$ = ct; } ;
160 cpile : CPILE { $$ = ct; } ;
161 pile : PILE { $$ = ct; } ;
162 rpile : RPILE { $$ = ct; } ;
164 size : SIZE text { $$ = ps; setsize((char *) $2); }
167 font : ROMAN { setfont(ROM); }
168 | ITALIC { setfont(ITAL); }
169 | BOLD { setfont(BLD); }
170 | FONT text { setfont(((char *)$2)[0]); }
173 sub : SUB { shift(SUB); }
176 sup : SUP { shift(SUP); }
179 pbox : '{' eqn '}' { $$ = $2; }
180 | QTEXT { text(QTEXT, (char *) $1); }
181 | CONTIG { text(CONTIG, (char *) $1); }
182 | SPACE { text(SPACE, 0); }
183 | THIN { text(THIN, 0); }
184 | TAB { text(TAB, 0); }
185 | SUM { funny(SUM); }
186 | PROD { funny(PROD); }
187 | UNION { funny(UNION); }
188 | INTER { funny(INTER); } /* intersection */
191 text : CONTIG
192 | QTEXT