1 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
2 Written by James Clark (jjc@jclark.com)
4 This file is part of groff.
6 groff is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 groff is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License along
17 with groff; see the file COPYING. If not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26 extern int non_empty_flag;
27 char *strsave(const char *);
29 void yyerror(const char *);
65 %token <str> QUOTED_TEXT
85 /* these are handled in the lexer */
102 /* The original eqn manual says that `left' is right associative. It's lying.
103 Consider `left ( ~ left ( ~ right ) right )'. */
107 %right LPILE RPILE CPILE PILE TEXT QUOTED_TEXT MATRIX MARK LINEUP '^' '~' '\t' '{' SPLIT NOSPLIT
109 %left SQRT OVER SMALLOVER
111 %right ROMAN BOLD ITALIC FAT FONT SIZE FWD BACK DOWN UP TYPE VCENTER SPECIAL
112 %right BAR UNDER PRIME
115 %type <b> mark from_to sqrt_over script simple equation nonsup
117 %type <str> text delim
118 %type <pb> pile_element_list pile_arg
119 %type <mb> column_list
120 %type <col> column column_arg column_element_list
126 { $1->top_level(); non_empty_flag = 1; }
134 list_box *lb = $1->to_list_box();
136 lb = new list_box($1);
146 { $$ = make_mark_box($2); }
148 { $$ = make_lineup_box($2); }
154 | sqrt_over TO from_to
155 { $$ = make_limit_box($1, 0, $3); }
156 | sqrt_over FROM sqrt_over
157 { $$ = make_limit_box($1, $3, 0); }
158 | sqrt_over FROM sqrt_over TO from_to
159 { $$ = make_limit_box($1, $3, $5); }
160 | sqrt_over FROM sqrt_over FROM from_to
161 { $$ = make_limit_box($1, make_limit_box($3, $5, 0), 0); }
168 { $$ = make_sqrt_box($2); }
169 | sqrt_over OVER sqrt_over
170 { $$ = make_over_box($1, $3); }
171 | sqrt_over SMALLOVER sqrt_over
172 { $$ = make_small_over_box($1, $3); }
179 { $$ = make_script_box($1, 0, $3); }
186 { $$ = make_script_box($1, $3, 0); }
187 | simple SUB simple SUP script
188 { $$ = make_script_box($1, $3, $5); }
193 { $$ = split_text($1); }
195 { $$ = new quoted_text_box($1); }
197 { $$ = split_text($2); }
199 { $$ = new quoted_text_box($2); }
201 { $$ = new half_space_box; }
203 { $$ = new space_box; }
205 { $$ = new tab_box; }
209 { $2->set_alignment(CENTER_ALIGN); $$ = $2; }
211 { $2->set_alignment(LEFT_ALIGN); $$ = $2; }
213 { $2->set_alignment(RIGHT_ALIGN); $$ = $2; }
215 { $2->set_alignment(CENTER_ALIGN); $$ = $2; }
216 | MATRIX '{' column_list '}'
218 | LEFT delim equation RIGHT delim
219 { $$ = make_delim_box($2, $3, $5); }
220 | LEFT delim equation
221 { $$ = make_delim_box($2, $3, 0); }
223 { $$ = make_overline_box($1); }
225 { $$ = make_underline_box($1); }
227 { $$ = make_prime_box($1); }
228 | simple ACCENT simple
229 { $$ = make_accent_box($1, $3); }
230 | simple UACCENT simple
231 { $$ = make_uaccent_box($1, $3); }
233 { $$ = new font_box(strsave(get_grfont()), $2); }
235 { $$ = new font_box(strsave(get_gbfont()), $2); }
237 { $$ = new font_box(strsave(get_gfont()), $2); }
239 { $$ = new fat_box($2); }
241 { $$ = new font_box($2, $3); }
243 { $$ = new size_box($2, $3); }
245 { $$ = new hmotion_box($2, $3); }
247 { $$ = new hmotion_box(-$2, $3); }
249 { $$ = new vmotion_box($2, $3); }
251 { $$ = new vmotion_box(-$2, $3); }
253 { $3->set_spacing_type($2); $$ = $3; }
255 { $$ = new vcenter_box($2); }
256 | SPECIAL text simple
257 { $$ = make_special_box($2, $3); }
264 if (sscanf($1, "%d", &n) == 1)
272 { $$ = new pile_box($1); }
273 | pile_element_list ABOVE equation
274 { $1->append($3); $$ = $1; }
278 '{' pile_element_list '}'
280 | number '{' pile_element_list '}'
281 { $3->set_space($1); $$ = $3; }
286 { $$ = new matrix_box($1); }
288 { $1->append($2); $$ = $1; }
293 { $$ = new column($1); }
294 | column_element_list ABOVE equation
295 { $1->append($3); $$ = $1; }
299 '{' column_element_list '}'
301 | number '{' column_element_list '}'
302 { $3->set_space($1); $$ = $3; }
307 { $2->set_alignment(CENTER_ALIGN); $$ = $2; }
309 { $2->set_alignment(LEFT_ALIGN); $$ = $2; }
311 { $2->set_alignment(RIGHT_ALIGN); $$ = $2; }
313 { $2->set_alignment(CENTER_ALIGN); $$ = $2; }
326 { $$ = strsave("{"); }
328 { $$ = strsave("}"); }