2 * Copyright (c) 2014 - 2015 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
4 * Copyright (C) 1989 - 1992, 2004 Free Software Foundation, Inc.
5 * Written by James Clark (jjc@jclark.com)
7 * This is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2, or (at your option) any later
12 * This is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * You should have received a copy of the GNU General Public License along
18 * with groff; see the file COPYING. If not, write to the Free Software
19 * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
24 #include "eqn-config.h"
34 extern
int non_empty_flag
;
37 void yyerror(const char *);
73 %token
<str
> QUOTED_TEXT
93 /* these are handled in the lexer */
110 /* The original eqn manual says that `left' is right associative. It's lying.
111 Consider `left ( ~ left ( ~ right ) right )'. */
115 %right LPILE RPILE CPILE PILE TEXT QUOTED_TEXT MATRIX MARK LINEUP
'^' '~' '\t' '{' SPLIT NOSPLIT
117 %left SQRT OVER SMALLOVER
119 %right ROMAN BOLD ITALIC FAT FONT SIZE FWD BACK DOWN UP TYPE VCENTER SPECIAL
120 %right BAR UNDER PRIME
123 %type
<b
> mark from_to sqrt_over script simple equation nonsup
125 %type
<str
> text delim
126 %type
<pb
> pile_element_list pile_arg
127 %type
<mb
> column_list
128 %type
<col
> column column_arg column_element_list
134 { $1->top_level
(); non_empty_flag
= 1; }
142 list_box
*lb
= $1->to_list_box
();
144 lb
= new list_box
($1);
154 { $$
= make_mark_box
($2); }
156 { $$
= make_lineup_box
($2); }
162 | sqrt_over TO from_to
163 { $$
= make_limit_box
($1, 0, $3); }
164 | sqrt_over FROM sqrt_over
165 { $$
= make_limit_box
($1, $3, 0); }
166 | sqrt_over FROM sqrt_over TO from_to
167 { $$
= make_limit_box
($1, $3, $5); }
168 | sqrt_over FROM sqrt_over FROM from_to
169 { $$
= make_limit_box
($1, make_limit_box
($3, $5, 0), 0); }
176 { $$
= make_sqrt_box
($2); }
177 | sqrt_over OVER sqrt_over
178 { $$
= make_over_box
($1, $3); }
179 | sqrt_over SMALLOVER sqrt_over
180 { $$
= make_small_over_box
($1, $3); }
187 { $$
= make_script_box
($1, 0, $3); }
194 { $$
= make_script_box
($1, $3, 0); }
195 | simple SUB simple SUP script
196 { $$
= make_script_box
($1, $3, $5); }
201 { $$
= split_text
($1); }
203 { $$
= new quoted_text_box
($1); }
205 { $$
= split_text
($2); }
207 { $$
= new quoted_text_box
($2); }
209 { $$
= new half_space_box
; }
211 { $$
= new space_box
; }
213 { $$
= new tab_box
; }
217 { $2->set_alignment
(CENTER_ALIGN
); $$
= $2; }
219 { $2->set_alignment
(LEFT_ALIGN
); $$
= $2; }
221 { $2->set_alignment
(RIGHT_ALIGN
); $$
= $2; }
223 { $2->set_alignment
(CENTER_ALIGN
); $$
= $2; }
224 | MATRIX
'{' column_list
'}'
226 | LEFT delim equation RIGHT delim
227 { $$
= make_delim_box
($2, $3, $5); }
228 | LEFT delim equation
229 { $$
= make_delim_box
($2, $3, 0); }
231 { $$
= make_overline_box
($1); }
233 { $$
= make_underline_box
($1); }
235 { $$
= make_prime_box
($1); }
236 | simple ACCENT simple
237 { $$
= make_accent_box
($1, $3); }
238 | simple UACCENT simple
239 { $$
= make_uaccent_box
($1, $3); }
241 { $$
= new font_box
(strsave
(get_grfont
()), $2); }
243 { $$
= new font_box
(strsave
(get_gbfont
()), $2); }
245 { $$
= new font_box
(strsave
(get_gfont
()), $2); }
247 { $$
= new fat_box
($2); }
249 { $$
= new font_box
($2, $3); }
251 { $$
= new size_box
($2, $3); }
253 { $$
= new hmotion_box
($2, $3); }
255 { $$
= new hmotion_box
(-$2, $3); }
257 { $$
= new vmotion_box
($2, $3); }
259 { $$
= new vmotion_box
(-$2, $3); }
261 { $3->set_spacing_type
($2); $$
= $3; }
263 { $$
= new vcenter_box
($2); }
264 | SPECIAL text simple
265 { $$
= make_special_box
($2, $3); }
272 if
(sscanf
($1, "%d", &n
) == 1)
280 { $$
= new pile_box
($1); }
281 | pile_element_list ABOVE equation
282 { $1->append
($3); $$
= $1; }
286 '{' pile_element_list
'}'
288 | number
'{' pile_element_list
'}'
289 { $3->set_space
($1); $$
= $3; }
294 { $$
= new matrix_box
($1); }
296 { $1->append
($2); $$
= $1; }
301 { $$
= new column
($1); }
302 | column_element_list ABOVE equation
303 { $1->append
($3); $$
= $1; }
307 '{' column_element_list
'}'
309 | number
'{' column_element_list
'}'
310 { $3->set_space
($1); $$
= $3; }
315 { $2->set_alignment
(CENTER_ALIGN
); $$
= $2; }
317 { $2->set_alignment
(LEFT_ALIGN
); $$
= $2; }
319 { $2->set_alignment
(RIGHT_ALIGN
); $$
= $2; }
321 { $2->set_alignment
(CENTER_ALIGN
); $$
= $2; }
334 { $$
= strsave
("{"); }
336 { $$
= strsave
("}"); }