1 %{ 2 /* 3 * CDDL HEADER START 4 * 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. 9 * 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. 14 * 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] 20 * 21 * CDDL HEADER END 22 */ 23 %} 24 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 25 /* All Rights Reserved */ 26 27 28 %{# 29 /* from "e.y 1.6 05/06/10 SMI" "ucbeqn:e.y 1.1" */ 30 31 /* 32 * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany 33 * 34 * Sccsid @(#)e.y 1.7 (gritter) 10/2/07 35 */ 36 /* 37 * Changes Copyright (c) 2014 Carsten Kunze (carsten.kunze at arcor.de) 38 */ 39 #include "e.h" 40 #include <stdlib.h> 41 #include <inttypes.h> 42 43 int fromflg; 44 45 #define __YYSCLASS /* to get external access to yyval with HP-UX yacc */ 46 %} 47 %union { 48 int token; 49 char *str; 50 } 51 %token <str> CONTIG QTEXT SPACE THIN TAB 52 %token <token> MATRIX LCOL CCOL RCOL COL 53 %token <token> MARK LINEUP 54 %token <token> SUM INT PROD UNION INTER 55 %token <token> LPILE PILE CPILE RPILE ABOVE 56 %token <token> DEFINE TDEFINE NDEFINE DELIM GSIZE GFONT INCLUDE 57 %type <str> text 58 %type <token> eqn box lineupbox matrix lcol ccol rcol col sbox tbox size font 59 %type <token> lpile cpile rpile pile sub sup int left right diacrit fwd up back 60 %type <token> down from to pbox 61 %right FROM TO 62 %left OVER SQRT 63 %right SUP SUB 64 %right SIZE FONT ROMAN ITALIC BOLD FAT 65 %right UP DOWN BACK FWD 66 %left LEFT RIGHT 67 %right DOT DOTDOT HAT TILDE BAR UNDER VEC DYAD 68 69 %% 70 71 stuff : eqn { putout($1); } 72 | error { error(!FATAL, "syntax error"); } 73 | { eqnreg = 0; } 74 ; 75 76 eqn : box 77 | eqn box { eqnbox($1, $2, 0); } 78 | eqn lineupbox { eqnbox($1, $2, 1); } 79 | LINEUP { lineup(0); } 80 ; 81 82 lineupbox: LINEUP box { $$ = $2; lineup(1); } 83 ; 84 85 matrix : MATRIX { $$ = ct; } ; 86 87 collist : column 88 | collist column 89 ; 90 91 column : lcol '{' list '}' { column('L', $1); } 92 | ccol '{' list '}' { column('C', $1); } 93 | rcol '{' list '}' { column('R', $1); } 94 | col '{' list '}' { column('-', $1); } 95 ; 96 97 lcol : LCOL { $$ = ct++; } ; 98 ccol : CCOL { $$ = ct++; } ; 99 rcol : RCOL { $$ = ct++; } ; 100 col : COL { $$ = ct++; } ; 101 102 sbox : sup box %prec SUP { $$ = $2; } 103 ; 104 105 tbox : to box %prec TO { $$ = $2; } 106 | %prec FROM { $$ = 0; } 107 ; 108 109 box : box OVER box { boverb($1, $3); } 110 | MARK box { mark($2); } 111 | size box %prec SIZE { size($1, $2); } 112 | font box %prec FONT { font($1, $2); } 113 | FAT box { fatbox($2); } 114 | SQRT box { sqrt($2); } 115 | lpile '{' list '}' { lpile('L', $1, ct); ct = $1; } 116 | cpile '{' list '}' { lpile('C', $1, ct); ct = $1; } 117 | rpile '{' list '}' { lpile('R', $1, ct); ct = $1; } 118 | pile '{' list '}' { lpile('-', $1, ct); ct = $1; } 119 | box sub box sbox %prec SUB { shift2($1, $3, $4); } 120 | box sub box %prec SUB { bshiftb($1, $2, $3); } 121 | box sup box %prec SUP { bshiftb($1, $2, $3); } 122 | int sub box sbox %prec SUB { integral($1, $3, $4); } 123 | int sub box %prec SUB { integral($1, $3, 0); } 124 | int sup box %prec SUP { integral($1, 0, $3); } 125 | int { integral($1, 0, 0); } 126 | left eqn right { paren($1, $2, $3); } 127 | pbox 128 | box from box tbox %prec FROM { fromto($1, $3, $4); fromflg=0; } 129 | box to box %prec TO { fromto($1, 0, $3); } 130 | box diacrit { diacrit($1, $2); } 131 | fwd box %prec UP { move(FWD, $1, $2); } 132 | up box %prec UP { move(UP, $1, $2); } 133 | back box %prec UP { move(BACK, $1, $2); } 134 | down box %prec UP { move(DOWN, $1, $2); } 135 | matrix '{' collist '}' { matrix($1); } 136 ; 137 138 int : INT { setintegral(); } 139 ; 140 141 fwd : FWD text { $$ = atoi((char *) $2); } ; 142 up : UP text { $$ = atoi((char *) $2); } ; 143 back : BACK text { $$ = atoi((char *) $2); } ; 144 down : DOWN text { $$ = atoi((char *) $2); } ; 145 146 diacrit : HAT { $$ = HAT; } 147 | VEC { $$ = VEC; } 148 | DYAD { $$ = DYAD; } 149 | BAR { $$ = BAR; } 150 | UNDER { $$ = UNDER; } /* under bar */ 151 | DOT { $$ = DOT; } 152 | TILDE { $$ = TILDE; } 153 | DOTDOT { $$ = DOTDOT; } /* umlaut = double dot */ 154 ; 155 156 from : FROM { $$=ps; ps -= 3; fromflg = 1; 157 if(dbg)printf(".\tfrom: old ps %d, new ps %g, fflg %d\n", $$, ps, fromflg); 158 } 159 ; 160 161 to : TO { $$=ps; if(fromflg==0)ps -= 3; 162 if(dbg)printf(".\tto: old ps %d, new ps %g\n", $$, ps); 163 } 164 ; 165 166 left : LEFT text { $$ = ((char *)$2)[0]; } 167 | LEFT '{' { $$ = '{'; } 168 ; 169 170 right : RIGHT text { $$ = ((char *)$2)[0]; } 171 | RIGHT '}' { $$ = '}'; } 172 | { $$ = 0; } 173 ; 174 175 list : eqn { lp[ct++] = $1; } 176 | list ABOVE eqn { lp[ct++] = $3; } 177 ; 178 179 lpile : LPILE { $$ = ct; } ; 180 cpile : CPILE { $$ = ct; } ; 181 pile : PILE { $$ = ct; } ; 182 rpile : RPILE { $$ = ct; } ; 183 184 size : SIZE text { $$ = ps; setsize((char *) $2); } 185 ; 186 187 font : ROMAN { setfont(ROM); } 188 | ITALIC { setfont(ITAL); } 189 | BOLD { setfont(BLD); } 190 | FONT text { setfont(((char *)$2)[0]); } 191 ; 192 193 sub : SUB { shift(SUB); } 194 ; 195 196 sup : SUP { shift(SUP); } 197 ; 198 199 pbox : '{' eqn '}' { $$ = $2; } 200 | QTEXT { text(QTEXT, (char *) $1); } 201 | CONTIG { text(CONTIG, (char *) $1); } 202 | SPACE { text(SPACE, 0); } 203 | THIN { text(THIN, 0); } 204 | TAB { text(TAB, 0); } 205 | SUM { funny(SUM); } 206 | PROD { funny(PROD); } 207 | UNION { funny(UNION); } 208 | INTER { funny(INTER); } /* intersection */ 209 ; 210 211 text : CONTIG 212 | QTEXT 213 ; 214 215 %% 216