1 /* Copyright (C) 1989-2018 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 3 of the License, or
9 (at your option) any later version.
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
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 extern int non_empty_flag;
27 void yyerror(const char *);
63 %token <str> QUOTED_TEXT
83 /* these are handled in the lexer */
100 /* The original eqn manual says that 'left' is right associative. It's lying.
101 Consider 'left ( ~ left ( ~ right ) right )'. */
105 %right LPILE RPILE CPILE PILE TEXT QUOTED_TEXT MATRIX MARK LINEUP '^' '~' '\t' '{' SPLIT NOSPLIT
107 %left SQRT OVER SMALLOVER
109 %right ROMAN BOLD ITALIC FAT FONT SIZE FWD BACK DOWN UP TYPE VCENTER SPECIAL
110 %right BAR UNDER PRIME
113 %type <b> mark from_to sqrt_over script simple equation nonsup
115 %type <str> text delim
116 %type <pb> pile_element_list pile_arg
117 %type <mb> column_list
118 %type <col> column column_arg column_element_list
124 { $1->top_level(); non_empty_flag = 1; }
132 list_box *lb = $1->to_list_box();
134 lb = new list_box($1);
144 { $$ = make_mark_box($2); }
146 { $$ = make_lineup_box($2); }
152 | sqrt_over TO from_to
153 { $$ = make_limit_box($1, 0, $3); }
154 | sqrt_over FROM sqrt_over
155 { $$ = make_limit_box($1, $3, 0); }
156 | sqrt_over FROM sqrt_over TO from_to
157 { $$ = make_limit_box($1, $3, $5); }
158 | sqrt_over FROM sqrt_over FROM from_to
159 { $$ = make_limit_box($1, make_limit_box($3, $5, 0), 0); }
166 { $$ = make_sqrt_box($2); }
167 | sqrt_over OVER sqrt_over
168 { $$ = make_over_box($1, $3); }
169 | sqrt_over SMALLOVER sqrt_over
170 { $$ = make_small_over_box($1, $3); }
177 { $$ = make_script_box($1, 0, $3); }
184 { $$ = make_script_box($1, $3, 0); }
185 | simple SUB simple SUP script
186 { $$ = make_script_box($1, $3, $5); }
191 { $$ = split_text($1); }
193 { $$ = new quoted_text_box($1); }
195 { $$ = split_text($2); }
197 { $$ = new quoted_text_box($2); }
199 { $$ = new half_space_box; }
201 { $$ = new space_box; }
203 { $$ = new tab_box; }
207 { $2->set_alignment(CENTER_ALIGN); $$ = $2; }
209 { $2->set_alignment(LEFT_ALIGN); $$ = $2; }
211 { $2->set_alignment(RIGHT_ALIGN); $$ = $2; }
213 { $2->set_alignment(CENTER_ALIGN); $$ = $2; }
214 | MATRIX '{' column_list '}'
216 | LEFT delim equation RIGHT delim
217 { $$ = make_delim_box($2, $3, $5); }
218 | LEFT delim equation
219 { $$ = make_delim_box($2, $3, 0); }
221 { $$ = make_overline_box($1); }
223 { $$ = make_underline_box($1); }
225 { $$ = make_prime_box($1); }
226 | simple ACCENT simple
227 { $$ = make_accent_box($1, $3); }
228 | simple UACCENT simple
229 { $$ = make_uaccent_box($1, $3); }
231 { $$ = new font_box(strsave(get_grfont()), $2); }
233 { $$ = new font_box(strsave(get_gbfont()), $2); }
235 { $$ = new font_box(strsave(get_gfont()), $2); }
237 { $$ = new fat_box($2); }
239 { $$ = new font_box($2, $3); }
241 { $$ = new size_box($2, $3); }
243 { $$ = new hmotion_box($2, $3); }
245 { $$ = new hmotion_box(-$2, $3); }
247 { $$ = new vmotion_box($2, $3); }
249 { $$ = new vmotion_box(-$2, $3); }
251 { $3->set_spacing_type($2); $$ = $3; }
253 { $$ = new vcenter_box($2); }
254 | SPECIAL text simple
255 { $$ = make_special_box($2, $3); }
262 if (sscanf($1, "%d", &n) == 1)
270 { $$ = new pile_box($1); }
271 | pile_element_list ABOVE equation
272 { $1->append($3); $$ = $1; }
276 '{' pile_element_list '}'
278 | number '{' pile_element_list '}'
279 { $3->set_space($1); $$ = $3; }
284 { $$ = new matrix_box($1); }
286 { $1->append($2); $$ = $1; }
291 { $$ = new column($1); }
292 | column_element_list ABOVE equation
293 { $1->append($3); $$ = $1; }
297 '{' column_element_list '}'
299 | number '{' column_element_list '}'
300 { $3->set_space($1); $$ = $3; }
305 { $2->set_alignment(CENTER_ALIGN); $$ = $2; }
307 { $2->set_alignment(LEFT_ALIGN); $$ = $2; }
309 { $2->set_alignment(RIGHT_ALIGN); $$ = $2; }
311 { $2->set_alignment(CENTER_ALIGN); $$ = $2; }
324 { $$ = strsave("{"); }
326 { $$ = strsave("}"); }