mkdev: default to ../home for TBASE
[troff.git] / eqn / eqn.y
blobed8a33547974c726ebbf449b538a1556b995663a
1 %term CONTIG QTEXT SPACE THIN TAB
2 %term MATRIX LCOL CCOL RCOL COL ABOVE
3 %term MARK LINEUP
4 %term SUM INT PROD UNION INTER
5 %term DEFINE TDEFINE NDEFINE DELIM GSIZE GFONT INCLUDE SPACE IFDEF
6 %term DOTEQ DOTEN
8 %right FROM TO
9 %left OVER SQRT
10 %right SUP SUB
11 %right SIZE FONT ROMAN ITALIC BOLD FAT
12 %right UP DOWN BACK FWD
13 %left LEFT RIGHT
14 %right DOT DOTDOT HAT TILDE BAR LOWBAR HIGHBAR UNDER VEC DYAD UTILDE
17 #include "e.h"
19 int yylex(void);
24 stuff : eqn { putout($1); }
25 | error { ERROR "syntax error" WARNING; } /* should be SYNTAX */
26 | { eqnreg = 0; }
29 eqn : box
30 | eqn box { eqnbox($1, $2, 0); }
31 | eqn lineupbox { eqnbox($1, $2, 1); }
32 | LINEUP { lineup(0); }
35 lineupbox: LINEUP box { $$ = $2; lineup(1); }
38 sbox : SUP box %prec SUP { $$ = $2; }
39 | %prec SUP { $$ = 0; }
42 tbox : TO box %prec TO { $$ = $2; }
43 | %prec FROM { $$ = 0; }
46 box : '{' eqn '}' { $$ = $2; }
47 | QTEXT { text(QTEXT, (char *) $1); }
48 | CONTIG { text(CONTIG, (char *) $1); }
49 | SPACE { text(SPACE, (char *) 0); }
50 | THIN { text(THIN, (char *) 0); }
51 | TAB { text(TAB, (char *) 0); }
52 | SUM { funny(SUM); }
53 | PROD { funny(PROD); }
54 | UNION { funny(UNION); }
55 | INTER { funny(INTER); }
56 | box OVER box { boverb($1, $3); }
57 | MARK box { mark($2); }
58 | size box %prec SIZE { size($1, $2); }
59 | font box %prec FONT { font($1, $2); }
60 | FAT box { fatbox($2); }
61 | SQRT box { sqrtx($2); }
62 | box SUB {ps -= deltaps;} box sbox %prec SUB { subsup($1, $4, $5); }
63 | box SUP {ps -= deltaps;} box %prec SUP { subsup($1, 0, $4); }
64 | int SUB {ps -= deltaps;} box sbox %prec SUB { integral($1, $4, $5); }
65 | int SUP {ps -= deltaps;} box %prec SUP { integral($1, 0, $4); }
66 | int { integral($1, 0, 0); }
67 | box FROM {ps -= deltaps;} box tbox %prec FROM { fromto($1, $4, $5); }
68 | box TO {ps -= deltaps;} box %prec TO { fromto($1, 0, $4); }
69 | left eqn right { paren($1, $2, $3); }
70 | left eqn { paren($1, $2, 0); }
71 | box diacrit { diacrit($1, $2); }
72 | fwd box %prec UP { move(FWD, $1, $2); }
73 | up box %prec UP { move(UP, $1, $2); }
74 | back box %prec UP { move(BACK, $1, $2); }
75 | down box %prec UP { move(DOWN, $1, $2); }
76 | column { pile($1); ct = $1; }
77 | MATRIX {$$=ct;} '{' collist '}' { matrix($2); ct = $2; }
80 int : INT { setintegral(); }
83 fwd : FWD text { $$ = atoi((char *) $1); } ;
84 up : UP text { $$ = atoi((char *) $1); } ;
85 back : BACK text { $$ = atoi((char *) $1); } ;
86 down : DOWN text { $$ = atoi((char *) $1); } ;
88 diacrit : HAT { $$ = HAT; }
89 | VEC { $$ = VEC; }
90 | DYAD { $$ = DYAD; }
91 | BAR { $$ = BAR; }
92 | LOWBAR { $$ = LOWBAR; }
93 | HIGHBAR { $$ = HIGHBAR; }
94 | UNDER { $$ = UNDER; } /* underbar */
95 | DOT { $$ = DOT; }
96 | TILDE { $$ = TILDE; }
97 | UTILDE { $$ = UTILDE; }
98 | DOTDOT { $$ = DOTDOT; } /* umlaut = double dot */
101 left : LEFT text { $$ = ((char *)$2)[0]; }
102 | LEFT '{' { $$ = '{'; }
105 right : RIGHT text { $$ = ((char *)$2)[0]; }
106 | RIGHT '}' { $$ = '}'; }
109 collist : column
110 | collist column
113 column : col '{' list '}' { column($1, DEFGAP); }
114 | col text {$$=atoi((char*)$2);} '{' list '}' { column($1, $3); }
117 col : LCOL { $$ = startcol(LCOL); }
118 | CCOL { $$ = startcol(CCOL); }
119 | RCOL { $$ = startcol(RCOL); }
120 | COL { $$ = startcol(COL); }
123 list : eqn { lp[ct++] = $1; }
124 | list ABOVE eqn { lp[ct++] = $3; }
127 size : SIZE text { $$ = ps; setsize((char *) $2); }
130 font : ROMAN { static char R[]="R"; setfont(R); }
131 | ITALIC { static char I[]="I"; setfont(I); }
132 | BOLD { static char B[]="B"; setfont(B); }
133 | FONT text { setfont((char *)$2); }
136 text : CONTIG
137 | QTEXT