1 /* A Bison parser, made by GNU Bison 3.0.4. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
29
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
35
36 /* All symbols defined below should begin with html or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
42
43 /* Identify Bison output. */
44 #define YYBISON 1
45
46 /* Bison version. */
47 #define YYBISON_VERSION "3.0.4"
48
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers. */
53 #define YYPURE 0
54
55 /* Push parsers. */
56 #define YYPUSH 0
57
58 /* Pull parsers. */
59 #define YYPULL 1
60
61
62
63
64 /* Copy the first part of user declarations. */
65 #line 14 "../../lib/common/htmlparse.y" /* yacc.c:339 */
66
67
68 #include "render.h"
69 #include "htmltable.h"
70 #include "htmllex.h"
71
72 extern int htmlparse(void);
73
74 typedef struct sfont_t {
75 textfont_t *cfont;
76 struct sfont_t *pfont;
77 } sfont_t;
78
79 static struct {
80 htmllabel_t* lbl; /* Generated label */
81 htmltbl_t* tblstack; /* Stack of tables maintained during parsing */
82 Dt_t* fitemList; /* Dictionary for font text items */
83 Dt_t* fspanList;
84 agxbuf* str; /* Buffer for text */
85 sfont_t* fontstack;
86 GVC_t* gvc;
87 } HTMLstate;
88
89 /* free_ritem:
90 * Free row. This closes and frees row's list, then
91 * the pitem itself is freed.
92 */
93 static void
free_ritem(Dt_t * d,pitem * p,Dtdisc_t * ds)94 free_ritem(Dt_t* d, pitem* p,Dtdisc_t* ds)
95 {
96 dtclose (p->u.rp);
97 free (p);
98 }
99
100 /* free_item:
101 * Generic Dt free. Only frees container, assuming contents
102 * have been copied elsewhere.
103 */
104 static void
free_item(Dt_t * d,void * p,Dtdisc_t * ds)105 free_item(Dt_t* d, void* p,Dtdisc_t* ds)
106 {
107 free (p);
108 }
109
110 /* cleanTbl:
111 * Clean up table if error in parsing.
112 */
113 static void
cleanTbl(htmltbl_t * tp)114 cleanTbl (htmltbl_t* tp)
115 {
116 dtclose (tp->u.p.rows);
117 free_html_data (&tp->data);
118 free (tp);
119 }
120
121 /* cleanCell:
122 * Clean up cell if error in parsing.
123 */
124 static void
cleanCell(htmlcell_t * cp)125 cleanCell (htmlcell_t* cp)
126 {
127 if (cp->child.kind == HTML_TBL) cleanTbl (cp->child.u.tbl);
128 else if (cp->child.kind == HTML_TEXT) free_html_text (cp->child.u.txt);
129 free_html_data (&cp->data);
130 free (cp);
131 }
132
133 /* free_citem:
134 * Free cell item during parsing. This frees cell and pitem.
135 */
136 static void
free_citem(Dt_t * d,pitem * p,Dtdisc_t * ds)137 free_citem(Dt_t* d, pitem* p,Dtdisc_t* ds)
138 {
139 cleanCell (p->u.cp);
140 free (p);
141 }
142
143 static Dtdisc_t rowDisc = {
144 offsetof(pitem,u),
145 sizeof(void*),
146 offsetof(pitem,link),
147 NIL(Dtmake_f),
148 (Dtfree_f)free_ritem,
149 NIL(Dtcompar_f),
150 NIL(Dthash_f),
151 NIL(Dtmemory_f),
152 NIL(Dtevent_f)
153 };
154 static Dtdisc_t cellDisc = {
155 offsetof(pitem,u),
156 sizeof(void*),
157 offsetof(pitem,link),
158 NIL(Dtmake_f),
159 (Dtfree_f)free_item,
160 NIL(Dtcompar_f),
161 NIL(Dthash_f),
162 NIL(Dtmemory_f),
163 NIL(Dtevent_f)
164 };
165
166 typedef struct {
167 Dtlink_t link;
168 textspan_t ti;
169 } fitem;
170
171 typedef struct {
172 Dtlink_t link;
173 htextspan_t lp;
174 } fspan;
175
176 static void
free_fitem(Dt_t * d,fitem * p,Dtdisc_t * ds)177 free_fitem(Dt_t* d, fitem* p, Dtdisc_t* ds)
178 {
179 if (p->ti.str)
180 free (p->ti.str);
181 free (p);
182 }
183
184 static void
free_fspan(Dt_t * d,fspan * p,Dtdisc_t * ds)185 free_fspan(Dt_t* d, fspan* p, Dtdisc_t* ds)
186 {
187 textspan_t* ti;
188
189 if (p->lp.nitems) {
190 int i;
191 ti = p->lp.items;
192 for (i = 0; i < p->lp.nitems; i++) {
193 if (ti->str) free (ti->str);
194 ti++;
195 }
196 free (p->lp.items);
197 }
198 free (p);
199 }
200
201 static Dtdisc_t fstrDisc = {
202 0,
203 0,
204 offsetof(fitem,link),
205 NIL(Dtmake_f),
206 (Dtfree_f)free_item,
207 NIL(Dtcompar_f),
208 NIL(Dthash_f),
209 NIL(Dtmemory_f),
210 NIL(Dtevent_f)
211 };
212
213
214 static Dtdisc_t fspanDisc = {
215 0,
216 0,
217 offsetof(fspan,link),
218 NIL(Dtmake_f),
219 (Dtfree_f)free_item,
220 NIL(Dtcompar_f),
221 NIL(Dthash_f),
222 NIL(Dtmemory_f),
223 NIL(Dtevent_f)
224 };
225
226 /* appendFItemList:
227 * Append a new fitem to the list.
228 */
229 static void
appendFItemList(agxbuf * ag)230 appendFItemList (agxbuf *ag)
231 {
232 fitem *fi = NEW(fitem);
233
234 fi->ti.str = strdup(agxbuse(ag));
235 fi->ti.font = HTMLstate.fontstack->cfont;
236 dtinsert(HTMLstate.fitemList, fi);
237 }
238
239 /* appendFLineList:
240 */
241 static void
appendFLineList(int v)242 appendFLineList (int v)
243 {
244 int cnt;
245 fspan *ln = NEW(fspan);
246 fitem *fi;
247 Dt_t *ilist = HTMLstate.fitemList;
248
249 cnt = dtsize(ilist);
250 ln->lp.just = v;
251 if (cnt) {
252 int i = 0;
253 ln->lp.nitems = cnt;
254 ln->lp.items = N_NEW(cnt, textspan_t);
255
256 fi = (fitem*)dtflatten(ilist);
257 for (; fi; fi = (fitem*)dtlink(fitemList,(Dtlink_t*)fi)) {
258 /* NOTE: When fitemList is closed, it uses free_item, which only frees the container,
259 * not the contents, so this copy is safe.
260 */
261 ln->lp.items[i] = fi->ti;
262 i++;
263 }
264 }
265 else {
266 ln->lp.items = NEW(textspan_t);
267 ln->lp.nitems = 1;
268 ln->lp.items[0].str = strdup("");
269 ln->lp.items[0].font = HTMLstate.fontstack->cfont;
270 }
271
272 dtclear(ilist);
273
274 dtinsert(HTMLstate.fspanList, ln);
275 }
276
277 static htmltxt_t*
mkText(void)278 mkText(void)
279 {
280 int cnt;
281 Dt_t * ispan = HTMLstate.fspanList;
282 fspan *fl ;
283 htmltxt_t *hft = NEW(htmltxt_t);
284
285 if (dtsize (HTMLstate.fitemList))
286 appendFLineList (UNSET_ALIGN);
287
288 cnt = dtsize(ispan);
289 hft->nspans = cnt;
290
291 if (cnt) {
292 int i = 0;
293 hft->spans = N_NEW(cnt,htextspan_t);
294 for(fl=(fspan *)dtfirst(ispan); fl; fl=(fspan *)dtnext(ispan,fl)) {
295 hft->spans[i] = fl->lp;
296 i++;
297 }
298 }
299
300 dtclear(ispan);
301
302 return hft;
303 }
304
lastRow(void)305 static pitem* lastRow (void)
306 {
307 htmltbl_t* tbl = HTMLstate.tblstack;
308 pitem* sp = dtlast (tbl->u.p.rows);
309 return sp;
310 }
311
312 /* addRow:
313 * Add new cell row to current table.
314 */
addRow(void)315 static pitem* addRow (void)
316 {
317 Dt_t* dp = dtopen(&cellDisc, Dtqueue);
318 htmltbl_t* tbl = HTMLstate.tblstack;
319 pitem* sp = NEW(pitem);
320 sp->u.rp = dp;
321 if (tbl->flags & HTML_HRULE)
322 sp->ruled = 1;
323 dtinsert (tbl->u.p.rows, sp);
324 return sp;
325 }
326
327 /* setCell:
328 * Set cell body and type and attach to row
329 */
setCell(htmlcell_t * cp,void * obj,int kind)330 static void setCell (htmlcell_t* cp, void* obj, int kind)
331 {
332 pitem* sp = NEW(pitem);
333 htmltbl_t* tbl = HTMLstate.tblstack;
334 pitem* rp = (pitem*)dtlast (tbl->u.p.rows);
335 Dt_t* row = rp->u.rp;
336 sp->u.cp = cp;
337 dtinsert (row, sp);
338 cp->child.kind = kind;
339 if (tbl->flags & HTML_VRULE)
340 cp->ruled = HTML_VRULE;
341
342 if(kind == HTML_TEXT)
343 cp->child.u.txt = (htmltxt_t*)obj;
344 else if (kind == HTML_IMAGE)
345 cp->child.u.img = (htmlimg_t*)obj;
346 else
347 cp->child.u.tbl = (htmltbl_t*)obj;
348 }
349
350 /* mkLabel:
351 * Create label, given body and type.
352 */
mkLabel(void * obj,int kind)353 static htmllabel_t* mkLabel (void* obj, int kind)
354 {
355 htmllabel_t* lp = NEW(htmllabel_t);
356
357 lp->kind = kind;
358 if (kind == HTML_TEXT)
359 lp->u.txt = (htmltxt_t*)obj;
360 else
361 lp->u.tbl = (htmltbl_t*)obj;
362 return lp;
363 }
364
365 /* freeFontstack:
366 * Free all stack items but the last, which is
367 * put on artificially during in parseHTML.
368 */
369 static void
freeFontstack(void)370 freeFontstack(void)
371 {
372 sfont_t* s;
373 sfont_t* next;
374
375 for (s = HTMLstate.fontstack; (next = s->pfont); s = next) {
376 free(s);
377 }
378 }
379
380 /* cleanup:
381 * Called on error. Frees resources allocated during parsing.
382 * This includes a label, plus a walk down the stack of
383 * tables. Note that we use the free_citem function to actually
384 * free cells.
385 */
cleanup(void)386 static void cleanup (void)
387 {
388 htmltbl_t* tp = HTMLstate.tblstack;
389 htmltbl_t* next;
390
391 if (HTMLstate.lbl) {
392 free_html_label (HTMLstate.lbl,1);
393 HTMLstate.lbl = NULL;
394 }
395 cellDisc.freef = (Dtfree_f)free_citem;
396 while (tp) {
397 next = tp->u.p.prev;
398 cleanTbl (tp);
399 tp = next;
400 }
401 cellDisc.freef = (Dtfree_f)free_item;
402
403 fstrDisc.freef = (Dtfree_f)free_fitem;
404 dtclear (HTMLstate.fitemList);
405 fstrDisc.freef = (Dtfree_f)free_item;
406
407 fspanDisc.freef = (Dtfree_f)free_fspan;
408 dtclear (HTMLstate.fspanList);
409 fspanDisc.freef = (Dtfree_f)free_item;
410
411 freeFontstack();
412 }
413
414 /* nonSpace:
415 * Return 1 if s contains a non-space character.
416 */
nonSpace(char * s)417 static int nonSpace (char* s)
418 {
419 char c;
420
421 while ((c = *s++)) {
422 if (c != ' ') return 1;
423 }
424 return 0;
425 }
426
427 /* pushFont:
428 * Fonts are allocated in the lexer.
429 */
430 static void
pushFont(textfont_t * fp)431 pushFont (textfont_t *fp)
432 {
433 sfont_t *ft = NEW(sfont_t);
434 textfont_t* curfont = HTMLstate.fontstack->cfont;
435 textfont_t f = *fp;
436
437 if (curfont) {
438 if (!f.color && curfont->color)
439 f.color = curfont->color;
440 if ((f.size < 0.0) && (curfont->size >= 0.0))
441 f.size = curfont->size;
442 if (!f.name && curfont->name)
443 f.name = curfont->name;
444 if (curfont->flags)
445 f.flags |= curfont->flags;
446 }
447
448 ft->cfont = dtinsert(HTMLstate.gvc->textfont_dt, &f);
449 ft->pfont = HTMLstate.fontstack;
450 HTMLstate.fontstack = ft;
451 }
452
453 /* popFont:
454 */
455 static void
popFont(void)456 popFont (void)
457 {
458 sfont_t* curfont = HTMLstate.fontstack;
459 sfont_t* prevfont = curfont->pfont;
460
461 free (curfont);
462 HTMLstate.fontstack = prevfont;
463 }
464
465
466 #line 467 "y.tab.c" /* yacc.c:339 */
467
468 # ifndef YY_NULLPTR
469 # if defined __cplusplus && 201103L <= __cplusplus
470 # define YY_NULLPTR nullptr
471 # else
472 # define YY_NULLPTR 0
473 # endif
474 # endif
475
476 /* Enabling verbose error messages. */
477 #ifdef YYERROR_VERBOSE
478 # undef YYERROR_VERBOSE
479 # define YYERROR_VERBOSE 1
480 #else
481 # define YYERROR_VERBOSE 0
482 #endif
483
484 /* In a future release of Bison, this section will be replaced
485 by #include "y.tab.h". */
486 #ifndef YY_YY_Y_TAB_H_INCLUDED
487 # define YY_YY_Y_TAB_H_INCLUDED
488 /* Debug traces. */
489 #ifndef YYDEBUG
490 # define YYDEBUG 0
491 #endif
492 #if YYDEBUG
493 extern int htmldebug;
494 #endif
495
496 /* Token type. */
497 #ifndef YYTOKENTYPE
498 # define YYTOKENTYPE
499 enum htmltokentype
500 {
501 T_end_br = 258,
502 T_end_img = 259,
503 T_row = 260,
504 T_end_row = 261,
505 T_html = 262,
506 T_end_html = 263,
507 T_end_table = 264,
508 T_end_cell = 265,
509 T_end_font = 266,
510 T_string = 267,
511 T_error = 268,
512 T_n_italic = 269,
513 T_n_bold = 270,
514 T_n_underline = 271,
515 T_n_overline = 272,
516 T_n_sup = 273,
517 T_n_sub = 274,
518 T_n_s = 275,
519 T_HR = 276,
520 T_hr = 277,
521 T_end_hr = 278,
522 T_VR = 279,
523 T_vr = 280,
524 T_end_vr = 281,
525 T_BR = 282,
526 T_br = 283,
527 T_IMG = 284,
528 T_img = 285,
529 T_table = 286,
530 T_cell = 287,
531 T_font = 288,
532 T_italic = 289,
533 T_bold = 290,
534 T_underline = 291,
535 T_overline = 292,
536 T_sup = 293,
537 T_sub = 294,
538 T_s = 295
539 };
540 #endif
541 /* Tokens. */
542 #define T_end_br 258
543 #define T_end_img 259
544 #define T_row 260
545 #define T_end_row 261
546 #define T_html 262
547 #define T_end_html 263
548 #define T_end_table 264
549 #define T_end_cell 265
550 #define T_end_font 266
551 #define T_string 267
552 #define T_error 268
553 #define T_n_italic 269
554 #define T_n_bold 270
555 #define T_n_underline 271
556 #define T_n_overline 272
557 #define T_n_sup 273
558 #define T_n_sub 274
559 #define T_n_s 275
560 #define T_HR 276
561 #define T_hr 277
562 #define T_end_hr 278
563 #define T_VR 279
564 #define T_vr 280
565 #define T_end_vr 281
566 #define T_BR 282
567 #define T_br 283
568 #define T_IMG 284
569 #define T_img 285
570 #define T_table 286
571 #define T_cell 287
572 #define T_font 288
573 #define T_italic 289
574 #define T_bold 290
575 #define T_underline 291
576 #define T_overline 292
577 #define T_sup 293
578 #define T_sub 294
579 #define T_s 295
580
581 /* Value type. */
582 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
583
584 union YYSTYPE
585 {
586 #line 415 "../../lib/common/htmlparse.y" /* yacc.c:355 */
587
588 int i;
589 htmltxt_t* txt;
590 htmlcell_t* cell;
591 htmltbl_t* tbl;
592 textfont_t* font;
593 htmlimg_t* img;
594 pitem* p;
595
596 #line 597 "y.tab.c" /* yacc.c:355 */
597 };
598
599 typedef union YYSTYPE YYSTYPE;
600 # define YYSTYPE_IS_TRIVIAL 1
601 # define YYSTYPE_IS_DECLARED 1
602 #endif
603
604
605 extern YYSTYPE htmllval;
606
607 int htmlparse (void);
608
609 #endif /* !YY_YY_Y_TAB_H_INCLUDED */
610
611 /* Copy the second part of user declarations. */
612
613 #line 614 "y.tab.c" /* yacc.c:358 */
614
615 #ifdef short
616 # undef short
617 #endif
618
619 #ifdef YYTYPE_UINT8
620 typedef YYTYPE_UINT8 htmltype_uint8;
621 #else
622 typedef unsigned char htmltype_uint8;
623 #endif
624
625 #ifdef YYTYPE_INT8
626 typedef YYTYPE_INT8 htmltype_int8;
627 #else
628 typedef signed char htmltype_int8;
629 #endif
630
631 #ifdef YYTYPE_UINT16
632 typedef YYTYPE_UINT16 htmltype_uint16;
633 #else
634 typedef unsigned short int htmltype_uint16;
635 #endif
636
637 #ifdef YYTYPE_INT16
638 typedef YYTYPE_INT16 htmltype_int16;
639 #else
640 typedef short int htmltype_int16;
641 #endif
642
643 #ifndef YYSIZE_T
644 # ifdef __SIZE_TYPE__
645 # define YYSIZE_T __SIZE_TYPE__
646 # elif defined size_t
647 # define YYSIZE_T size_t
648 # elif ! defined YYSIZE_T
649 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
650 # define YYSIZE_T size_t
651 # else
652 # define YYSIZE_T unsigned int
653 # endif
654 #endif
655
656 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
657
658 #ifndef YY_
659 # if defined YYENABLE_NLS && YYENABLE_NLS
660 # if ENABLE_NLS
661 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
662 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
663 # endif
664 # endif
665 # ifndef YY_
666 # define YY_(Msgid) Msgid
667 # endif
668 #endif
669
670 #ifndef YY_ATTRIBUTE
671 # if (defined __GNUC__ \
672 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
673 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
674 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
675 # else
676 # define YY_ATTRIBUTE(Spec) /* empty */
677 # endif
678 #endif
679
680 #ifndef YY_ATTRIBUTE_PURE
681 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
682 #endif
683
684 #ifndef YY_ATTRIBUTE_UNUSED
685 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
686 #endif
687
688 #if !defined _Noreturn \
689 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
690 # if defined _MSC_VER && 1200 <= _MSC_VER
691 # define _Noreturn __declspec (noreturn)
692 # else
693 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
694 # endif
695 #endif
696
697 /* Suppress unused-variable warnings by "using" E. */
698 #if ! defined lint || defined __GNUC__
699 # define YYUSE(E) ((void) (E))
700 #else
701 # define YYUSE(E) /* empty */
702 #endif
703
704 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
705 /* Suppress an incorrect diagnostic about htmllval being uninitialized. */
706 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
707 _Pragma ("GCC diagnostic push") \
708 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
709 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
710 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
711 _Pragma ("GCC diagnostic pop")
712 #else
713 # define YY_INITIAL_VALUE(Value) Value
714 #endif
715 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
716 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
717 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
718 #endif
719 #ifndef YY_INITIAL_VALUE
720 # define YY_INITIAL_VALUE(Value) /* Nothing. */
721 #endif
722
723
724 #if ! defined htmloverflow || YYERROR_VERBOSE
725
726 /* The parser invokes alloca or malloc; define the necessary symbols. */
727
728 # ifdef YYSTACK_USE_ALLOCA
729 # if YYSTACK_USE_ALLOCA
730 # ifdef __GNUC__
731 # define YYSTACK_ALLOC __builtin_alloca
732 # elif defined __BUILTIN_VA_ARG_INCR
733 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
734 # elif defined _AIX
735 # define YYSTACK_ALLOC __alloca
736 # elif defined _MSC_VER
737 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
738 # define alloca _alloca
739 # else
740 # define YYSTACK_ALLOC alloca
741 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
742 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
743 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
744 # ifndef EXIT_SUCCESS
745 # define EXIT_SUCCESS 0
746 # endif
747 # endif
748 # endif
749 # endif
750 # endif
751
752 # ifdef YYSTACK_ALLOC
753 /* Pacify GCC's 'empty if-body' warning. */
754 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
755 # ifndef YYSTACK_ALLOC_MAXIMUM
756 /* The OS might guarantee only one guard page at the bottom of the stack,
757 and a page size can be as small as 4096 bytes. So we cannot safely
758 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
759 to allow for a few compiler-allocated temporary stack slots. */
760 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
761 # endif
762 # else
763 # define YYSTACK_ALLOC YYMALLOC
764 # define YYSTACK_FREE YYFREE
765 # ifndef YYSTACK_ALLOC_MAXIMUM
766 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
767 # endif
768 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
769 && ! ((defined YYMALLOC || defined malloc) \
770 && (defined YYFREE || defined free)))
771 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
772 # ifndef EXIT_SUCCESS
773 # define EXIT_SUCCESS 0
774 # endif
775 # endif
776 # ifndef YYMALLOC
777 # define YYMALLOC malloc
778 # if ! defined malloc && ! defined EXIT_SUCCESS
779 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
780 # endif
781 # endif
782 # ifndef YYFREE
783 # define YYFREE free
784 # if ! defined free && ! defined EXIT_SUCCESS
785 void free (void *); /* INFRINGES ON USER NAME SPACE */
786 # endif
787 # endif
788 # endif
789 #endif /* ! defined htmloverflow || YYERROR_VERBOSE */
790
791
792 #if (! defined htmloverflow \
793 && (! defined __cplusplus \
794 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
795
796 /* A type that is properly aligned for any stack member. */
797 union htmlalloc
798 {
799 htmltype_int16 htmlss_alloc;
800 YYSTYPE htmlvs_alloc;
801 };
802
803 /* The size of the maximum gap between one aligned stack and the next. */
804 # define YYSTACK_GAP_MAXIMUM (sizeof (union htmlalloc) - 1)
805
806 /* The size of an array large to enough to hold all stacks, each with
807 N elements. */
808 # define YYSTACK_BYTES(N) \
809 ((N) * (sizeof (htmltype_int16) + sizeof (YYSTYPE)) \
810 + YYSTACK_GAP_MAXIMUM)
811
812 # define YYCOPY_NEEDED 1
813
814 /* Relocate STACK from its old location to the new one. The
815 local variables YYSIZE and YYSTACKSIZE give the old and new number of
816 elements in the stack, and YYPTR gives the new location of the
817 stack. Advance YYPTR to a properly aligned location for the next
818 stack. */
819 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
820 do \
821 { \
822 YYSIZE_T htmlnewbytes; \
823 YYCOPY (&htmlptr->Stack_alloc, Stack, htmlsize); \
824 Stack = &htmlptr->Stack_alloc; \
825 htmlnewbytes = htmlstacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
826 htmlptr += htmlnewbytes / sizeof (*htmlptr); \
827 } \
828 while (0)
829
830 #endif
831
832 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
833 /* Copy COUNT objects from SRC to DST. The source and destination do
834 not overlap. */
835 # ifndef YYCOPY
836 # if defined __GNUC__ && 1 < __GNUC__
837 # define YYCOPY(Dst, Src, Count) \
838 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
839 # else
840 # define YYCOPY(Dst, Src, Count) \
841 do \
842 { \
843 YYSIZE_T htmli; \
844 for (htmli = 0; htmli < (Count); htmli++) \
845 (Dst)[htmli] = (Src)[htmli]; \
846 } \
847 while (0)
848 # endif
849 # endif
850 #endif /* !YYCOPY_NEEDED */
851
852 /* YYFINAL -- State number of the termination state. */
853 #define YYFINAL 31
854 /* YYLAST -- Last index in YYTABLE. */
855 #define YYLAST 271
856
857 /* YYNTOKENS -- Number of terminals. */
858 #define YYNTOKENS 41
859 /* YYNNTS -- Number of nonterminals. */
860 #define YYNNTS 39
861 /* YYNRULES -- Number of rules. */
862 #define YYNRULES 69
863 /* YYNSTATES -- Number of states. */
864 #define YYNSTATES 116
865
866 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
867 by htmllex, with out-of-bounds checking. */
868 #define YYUNDEFTOK 2
869 #define YYMAXUTOK 295
870
871 #define YYTRANSLATE(YYX) \
872 ((unsigned int) (YYX) <= YYMAXUTOK ? htmltranslate[YYX] : YYUNDEFTOK)
873
874 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
875 as returned by htmllex, without out-of-bounds checking. */
876 static const htmltype_uint8 htmltranslate[] =
877 {
878 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
879 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
880 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
881 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
882 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
883 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
884 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
885 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
886 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
887 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
888 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
889 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
890 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
891 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
892 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
893 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
894 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
895 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
896 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
897 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
898 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
899 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
900 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
901 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
902 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
903 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
904 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
905 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
906 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
907 35, 36, 37, 38, 39, 40
908 };
909
910 #if YYDEBUG
911 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
912 static const htmltype_uint16 htmlrline[] =
913 {
914 0, 447, 447, 448, 449, 452, 455, 456, 459, 460,
915 461, 462, 463, 464, 465, 466, 467, 468, 471, 474,
916 477, 480, 483, 486, 489, 492, 495, 498, 501, 504,
917 507, 510, 513, 516, 519, 520, 523, 524, 527, 527,
918 548, 549, 550, 551, 552, 553, 556, 557, 560, 561,
919 562, 565, 565, 568, 569, 570, 573, 573, 574, 574,
920 575, 575, 576, 576, 579, 580, 583, 584, 587, 588
921 };
922 #endif
923
924 #if YYDEBUG || YYERROR_VERBOSE || 0
925 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
926 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
927 static const char *const htmltname[] =
928 {
929 "$end", "error", "$undefined", "T_end_br", "T_end_img", "T_row",
930 "T_end_row", "T_html", "T_end_html", "T_end_table", "T_end_cell",
931 "T_end_font", "T_string", "T_error", "T_n_italic", "T_n_bold",
932 "T_n_underline", "T_n_overline", "T_n_sup", "T_n_sub", "T_n_s", "T_HR",
933 "T_hr", "T_end_hr", "T_VR", "T_vr", "T_end_vr", "T_BR", "T_br", "T_IMG",
934 "T_img", "T_table", "T_cell", "T_font", "T_italic", "T_bold",
935 "T_underline", "T_overline", "T_sup", "T_sub", "T_s", "$accept", "html",
936 "fonttext", "text", "textitem", "font", "n_font", "italic", "n_italic",
937 "bold", "n_bold", "strike", "n_strike", "underline", "n_underline",
938 "overline", "n_overline", "sup", "n_sup", "sub", "n_sub", "br", "string",
939 "table", "@1", "fonttable", "opt_space", "rows", "row", "$@2", "cells",
940 "cell", "$@3", "$@4", "$@5", "$@6", "image", "HR", "VR", YY_NULLPTR
941 };
942 #endif
943
944 # ifdef YYPRINT
945 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
946 (internal) symbol number NUM (which must be that of a token). */
947 static const htmltype_uint16 htmltoknum[] =
948 {
949 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
950 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
951 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
952 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
953 295
954 };
955 # endif
956
957 #define YYPACT_NINF -82
958
959 #define htmlpact_value_is_default(Yystate) \
960 (!!((Yystate) == (-82)))
961
962 #define YYTABLE_NINF -63
963
964 #define htmltable_value_is_error(Yytable_value) \
965 0
966
967 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
968 STATE-NUM. */
969 static const htmltype_int16 htmlpact[] =
970 {
971 8, -82, 209, 10, -82, -82, 11, -82, -82, -82,
972 -82, -82, -82, -82, -82, 5, 209, -82, 209, 209,
973 209, 209, 209, 209, 209, 209, -82, -5, -82, 14,
974 -20, -82, -82, -82, -82, 209, 209, 209, 209, 209,
975 13, 37, 12, 66, 16, 80, 19, 109, 123, 20,
976 152, 15, 166, 195, -82, -82, -82, -82, -82, -82,
977 -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
978 -82, -82, -82, -82, -82, -82, -82, -82, 23, -82,
979 119, -82, 7, 46, -82, 38, -82, 23, 17, 35,
980 -82, 13, -82, -82, -82, -82, 58, -82, -82, 53,
981 -82, -82, -82, 40, -82, 7, -82, 59, 69, -82,
982 72, -82, -82, -82, -82, -82
983 };
984
985 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
986 Performed when YYTABLE does not specify something else to do. Zero
987 means the default is an error. */
988 static const htmltype_uint8 htmldefact[] =
989 {
990 0, 4, 47, 0, 36, 35, 0, 18, 20, 22,
991 26, 28, 30, 32, 24, 0, 5, 7, 47, 47,
992 47, 0, 47, 47, 0, 0, 9, 8, 40, 0,
993 0, 1, 34, 2, 6, 0, 0, 0, 0, 0,
994 8, 0, 0, 0, 0, 0, 0, 0, 0, 0,
995 0, 0, 0, 0, 37, 3, 38, 19, 10, 41,
996 21, 11, 42, 23, 14, 45, 25, 17, 27, 12,
997 43, 29, 13, 44, 31, 15, 33, 16, 0, 51,
998 0, 48, 0, 47, 67, 0, 49, 0, 47, 0,
999 53, 46, 39, 66, 50, 65, 0, 58, 56, 0,
1000 60, 52, 69, 0, 54, 0, 64, 0, 0, 63,
1001 0, 68, 55, 59, 57, 61
1002 };
1003
1004 /* YYPGOTO[NTERM-NUM]. */
1005 static const htmltype_int16 htmlpgoto[] =
1006 {
1007 -82, -82, -4, 232, -10, -1, 26, 0, 39, 1,
1008 50, -82, -82, 2, 36, 3, 47, -82, -82, -82,
1009 -82, -82, -2, 148, -82, 9, 27, -82, -68, -82,
1010 -82, -81, -82, -82, -82, -82, -82, -82, -82
1011 };
1012
1013 /* YYDEFGOTO[NTERM-NUM]. */
1014 static const htmltype_int8 htmldefgoto[] =
1015 {
1016 -1, 3, 15, 16, 17, 35, 58, 36, 61, 37,
1017 64, 21, 67, 38, 69, 39, 72, 24, 75, 25,
1018 77, 26, 40, 28, 78, 29, 30, 80, 81, 82,
1019 89, 90, 108, 107, 110, 99, 100, 87, 105
1020 };
1021
1022 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
1023 positive, shift that token. If negative, reduce the rule whose
1024 number is the opposite. If YYTABLE_NINF, syntax error. */
1025 static const htmltype_int8 htmltable[] =
1026 {
1027 27, 18, 19, 20, 22, 23, 34, 54, 104, 1,
1028 31, 56, 86, 33, 32, 2, 27, 27, 27, 94,
1029 27, 27, 55, 57, 112, 54, -46, -62, 79, 4,
1030 60, 34, 71, 34, 63, 34, 68, 34, 34, 88,
1031 34, 101, 34, 34, 5, 6, 95, 96, 57, 4,
1032 7, 8, 9, 10, 11, 12, 13, 14, 4, 102,
1033 103, 93, 106, 109, 5, 6, 111, 88, 59, 113,
1034 7, 8, 9, 10, 11, 12, 13, 14, 4, 114,
1035 60, 91, 115, 62, 97, 70, 27, 18, 19, 20,
1036 22, 23, 4, 5, 6, 63, 65, 98, 73, 7,
1037 8, 9, 10, 11, 12, 13, 14, 5, 6, 0,
1038 92, 0, 0, 7, 8, 9, 10, 11, 12, 13,
1039 14, 4, 0, 0, 79, 0, 0, 0, 83, 66,
1040 0, 0, 0, 0, 0, 4, 5, 6, 0, 68,
1041 84, 85, 7, 8, 9, 10, 11, 12, 13, 14,
1042 5, 6, 0, 0, 0, 0, 7, 8, 9, 10,
1043 11, 12, 13, 14, 4, 0, 42, 44, 46, 71,
1044 49, 51, 0, 0, 0, 0, 0, 0, 4, 5,
1045 6, 0, 0, 0, 74, 7, 8, 9, 10, 11,
1046 12, 13, 14, 5, 6, 0, 0, 0, 0, 7,
1047 8, 9, 10, 11, 12, 13, 14, 4, 0, 0,
1048 0, 0, 0, 0, 76, 0, 0, 0, 0, 0,
1049 0, 4, 5, 6, 0, 0, 0, 0, 7, 8,
1050 9, 10, 11, 12, 13, 14, 5, 6, 0, 0,
1051 0, 0, 7, 8, 9, 10, 11, 12, 13, 14,
1052 41, 43, 45, 47, 48, 50, 52, 53, 0, 0,
1053 0, 0, 0, 0, 0, 0, 0, 41, 43, 45,
1054 48, 50
1055 };
1056
1057 static const htmltype_int8 htmlcheck[] =
1058 {
1059 2, 2, 2, 2, 2, 2, 16, 12, 89, 1,
1060 0, 31, 80, 8, 3, 7, 18, 19, 20, 87,
1061 22, 23, 8, 11, 105, 12, 31, 10, 5, 12,
1062 14, 41, 17, 43, 15, 45, 16, 47, 48, 32,
1063 50, 6, 52, 53, 27, 28, 29, 30, 11, 12,
1064 33, 34, 35, 36, 37, 38, 39, 40, 12, 24,
1065 25, 23, 4, 10, 27, 28, 26, 32, 42, 10,
1066 33, 34, 35, 36, 37, 38, 39, 40, 12, 10,
1067 14, 83, 10, 44, 88, 49, 88, 88, 88, 88,
1068 88, 88, 12, 27, 28, 15, 46, 88, 51, 33,
1069 34, 35, 36, 37, 38, 39, 40, 27, 28, -1,
1070 83, -1, -1, 33, 34, 35, 36, 37, 38, 39,
1071 40, 12, -1, -1, 5, -1, -1, -1, 9, 20,
1072 -1, -1, -1, -1, -1, 12, 27, 28, -1, 16,
1073 21, 22, 33, 34, 35, 36, 37, 38, 39, 40,
1074 27, 28, -1, -1, -1, -1, 33, 34, 35, 36,
1075 37, 38, 39, 40, 12, -1, 18, 19, 20, 17,
1076 22, 23, -1, -1, -1, -1, -1, -1, 12, 27,
1077 28, -1, -1, -1, 18, 33, 34, 35, 36, 37,
1078 38, 39, 40, 27, 28, -1, -1, -1, -1, 33,
1079 34, 35, 36, 37, 38, 39, 40, 12, -1, -1,
1080 -1, -1, -1, -1, 19, -1, -1, -1, -1, -1,
1081 -1, 12, 27, 28, -1, -1, -1, -1, 33, 34,
1082 35, 36, 37, 38, 39, 40, 27, 28, -1, -1,
1083 -1, -1, 33, 34, 35, 36, 37, 38, 39, 40,
1084 18, 19, 20, 21, 22, 23, 24, 25, -1, -1,
1085 -1, -1, -1, -1, -1, -1, -1, 35, 36, 37,
1086 38, 39
1087 };
1088
1089 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1090 symbol of state STATE-NUM. */
1091 static const htmltype_uint8 htmlstos[] =
1092 {
1093 0, 1, 7, 42, 12, 27, 28, 33, 34, 35,
1094 36, 37, 38, 39, 40, 43, 44, 45, 46, 48,
1095 50, 52, 54, 56, 58, 60, 62, 63, 64, 66,
1096 67, 0, 3, 8, 45, 46, 48, 50, 54, 56,
1097 63, 44, 64, 44, 64, 44, 64, 44, 44, 64,
1098 44, 64, 44, 44, 12, 8, 31, 11, 47, 47,
1099 14, 49, 49, 15, 51, 51, 20, 53, 16, 55,
1100 55, 17, 57, 57, 18, 59, 19, 61, 65, 5,
1101 68, 69, 70, 9, 21, 22, 69, 78, 32, 71,
1102 72, 63, 67, 23, 69, 29, 30, 43, 66, 76,
1103 77, 6, 24, 25, 72, 79, 4, 74, 73, 10,
1104 75, 26, 72, 10, 10, 10
1105 };
1106
1107 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1108 static const htmltype_uint8 htmlr1[] =
1109 {
1110 0, 41, 42, 42, 42, 43, 44, 44, 45, 45,
1111 45, 45, 45, 45, 45, 45, 45, 45, 46, 47,
1112 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
1113 58, 59, 60, 61, 62, 62, 63, 63, 65, 64,
1114 66, 66, 66, 66, 66, 66, 67, 67, 68, 68,
1115 68, 70, 69, 71, 71, 71, 73, 72, 74, 72,
1116 75, 72, 76, 72, 77, 77, 78, 78, 79, 79
1117 };
1118
1119 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
1120 static const htmltype_uint8 htmlr2[] =
1121 {
1122 0, 2, 3, 3, 1, 1, 2, 1, 1, 1,
1123 3, 3, 3, 3, 3, 3, 3, 3, 1, 1,
1124 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1125 1, 1, 1, 1, 2, 1, 1, 2, 0, 6,
1126 1, 3, 3, 3, 3, 3, 1, 0, 1, 2,
1127 3, 0, 4, 1, 2, 3, 0, 4, 0, 4,
1128 0, 4, 0, 3, 2, 1, 2, 1, 2, 1
1129 };
1130
1131
1132 #define htmlerrok (htmlerrstatus = 0)
1133 #define htmlclearin (htmlchar = YYEMPTY)
1134 #define YYEMPTY (-2)
1135 #define YYEOF 0
1136
1137 #define YYACCEPT goto htmlacceptlab
1138 #define YYABORT goto htmlabortlab
1139 #define YYERROR goto htmlerrorlab
1140
1141
1142 #define YYRECOVERING() (!!htmlerrstatus)
1143
1144 #define YYBACKUP(Token, Value) \
1145 do \
1146 if (htmlchar == YYEMPTY) \
1147 { \
1148 htmlchar = (Token); \
1149 htmllval = (Value); \
1150 YYPOPSTACK (htmllen); \
1151 htmlstate = *htmlssp; \
1152 goto htmlbackup; \
1153 } \
1154 else \
1155 { \
1156 htmlerror (YY_("syntax error: cannot back up")); \
1157 YYERROR; \
1158 } \
1159 while (0)
1160
1161 /* Error token number */
1162 #define YYTERROR 1
1163 #define YYERRCODE 256
1164
1165
1166
1167 /* Enable debugging if requested. */
1168 #if YYDEBUG
1169
1170 # ifndef YYFPRINTF
1171 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1172 # define YYFPRINTF fprintf
1173 # endif
1174
1175 # define YYDPRINTF(Args) \
1176 do { \
1177 if (htmldebug) \
1178 YYFPRINTF Args; \
1179 } while (0)
1180
1181 /* This macro is provided for backward compatibility. */
1182 #ifndef YY_LOCATION_PRINT
1183 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1184 #endif
1185
1186
1187 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1188 do { \
1189 if (htmldebug) \
1190 { \
1191 YYFPRINTF (stderr, "%s ", Title); \
1192 html_symbol_print (stderr, \
1193 Type, Value); \
1194 YYFPRINTF (stderr, "\n"); \
1195 } \
1196 } while (0)
1197
1198
1199 /*----------------------------------------.
1200 | Print this symbol's value on YYOUTPUT. |
1201 `----------------------------------------*/
1202
1203 static void
html_symbol_value_print(FILE * htmloutput,int htmltype,YYSTYPE const * const htmlvaluep)1204 html_symbol_value_print (FILE *htmloutput, int htmltype, YYSTYPE const * const htmlvaluep)
1205 {
1206 FILE *htmlo = htmloutput;
1207 YYUSE (htmlo);
1208 if (!htmlvaluep)
1209 return;
1210 # ifdef YYPRINT
1211 if (htmltype < YYNTOKENS)
1212 YYPRINT (htmloutput, htmltoknum[htmltype], *htmlvaluep);
1213 # endif
1214 YYUSE (htmltype);
1215 }
1216
1217
1218 /*--------------------------------.
1219 | Print this symbol on YYOUTPUT. |
1220 `--------------------------------*/
1221
1222 static void
html_symbol_print(FILE * htmloutput,int htmltype,YYSTYPE const * const htmlvaluep)1223 html_symbol_print (FILE *htmloutput, int htmltype, YYSTYPE const * const htmlvaluep)
1224 {
1225 YYFPRINTF (htmloutput, "%s %s (",
1226 htmltype < YYNTOKENS ? "token" : "nterm", htmltname[htmltype]);
1227
1228 html_symbol_value_print (htmloutput, htmltype, htmlvaluep);
1229 YYFPRINTF (htmloutput, ")");
1230 }
1231
1232 /*------------------------------------------------------------------.
1233 | html_stack_print -- Print the state stack from its BOTTOM up to its |
1234 | TOP (included). |
1235 `------------------------------------------------------------------*/
1236
1237 static void
html_stack_print(htmltype_int16 * htmlbottom,htmltype_int16 * htmltop)1238 html_stack_print (htmltype_int16 *htmlbottom, htmltype_int16 *htmltop)
1239 {
1240 YYFPRINTF (stderr, "Stack now");
1241 for (; htmlbottom <= htmltop; htmlbottom++)
1242 {
1243 int htmlbot = *htmlbottom;
1244 YYFPRINTF (stderr, " %d", htmlbot);
1245 }
1246 YYFPRINTF (stderr, "\n");
1247 }
1248
1249 # define YY_STACK_PRINT(Bottom, Top) \
1250 do { \
1251 if (htmldebug) \
1252 html_stack_print ((Bottom), (Top)); \
1253 } while (0)
1254
1255
1256 /*------------------------------------------------.
1257 | Report that the YYRULE is going to be reduced. |
1258 `------------------------------------------------*/
1259
1260 static void
html_reduce_print(htmltype_int16 * htmlssp,YYSTYPE * htmlvsp,int htmlrule)1261 html_reduce_print (htmltype_int16 *htmlssp, YYSTYPE *htmlvsp, int htmlrule)
1262 {
1263 uint64_t htmllno = htmlrline[htmlrule];
1264 int htmlnrhs = htmlr2[htmlrule];
1265 int htmli;
1266 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1267 htmlrule - 1, htmllno);
1268 /* The symbols being reduced. */
1269 for (htmli = 0; htmli < htmlnrhs; htmli++)
1270 {
1271 YYFPRINTF (stderr, " $%d = ", htmli + 1);
1272 html_symbol_print (stderr,
1273 htmlstos[htmlssp[htmli + 1 - htmlnrhs]],
1274 &(htmlvsp[(htmli + 1) - (htmlnrhs)])
1275 );
1276 YYFPRINTF (stderr, "\n");
1277 }
1278 }
1279
1280 # define YY_REDUCE_PRINT(Rule) \
1281 do { \
1282 if (htmldebug) \
1283 html_reduce_print (htmlssp, htmlvsp, Rule); \
1284 } while (0)
1285
1286 /* Nonzero means print parse trace. It is left uninitialized so that
1287 multiple parsers can coexist. */
1288 int htmldebug;
1289 #else /* !YYDEBUG */
1290 # define YYDPRINTF(Args)
1291 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1292 # define YY_STACK_PRINT(Bottom, Top)
1293 # define YY_REDUCE_PRINT(Rule)
1294 #endif /* !YYDEBUG */
1295
1296
1297 /* YYINITDEPTH -- initial size of the parser's stacks. */
1298 #ifndef YYINITDEPTH
1299 # define YYINITDEPTH 200
1300 #endif
1301
1302 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1303 if the built-in stack extension method is used).
1304
1305 Do not make this value too large; the results are undefined if
1306 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1307 evaluated with infinite-precision integer arithmetic. */
1308
1309 #ifndef YYMAXDEPTH
1310 # define YYMAXDEPTH 10000
1311 #endif
1312
1313
1314 #if YYERROR_VERBOSE
1315
1316 # ifndef htmlstrlen
1317 # if defined __GLIBC__ && defined _STRING_H
1318 # define htmlstrlen strlen
1319 # else
1320 /* Return the length of YYSTR. */
1321 static YYSIZE_T
htmlstrlen(const char * htmlstr)1322 htmlstrlen (const char *htmlstr)
1323 {
1324 YYSIZE_T htmllen;
1325 for (htmllen = 0; htmlstr[htmllen]; htmllen++)
1326 continue;
1327 return htmllen;
1328 }
1329 # endif
1330 # endif
1331
1332 # ifndef htmlstpcpy
1333 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1334 # define htmlstpcpy stpcpy
1335 # else
1336 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1337 YYDEST. */
1338 static char *
htmlstpcpy(char * htmldest,const char * htmlsrc)1339 htmlstpcpy (char *htmldest, const char *htmlsrc)
1340 {
1341 char *htmld = htmldest;
1342 const char *htmls = htmlsrc;
1343
1344 while ((*htmld++ = *htmls++) != '\0')
1345 continue;
1346
1347 return htmld - 1;
1348 }
1349 # endif
1350 # endif
1351
1352 # ifndef htmltnamerr
1353 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1354 quotes and backslashes, so that it's suitable for htmlerror. The
1355 heuristic is that double-quoting is unnecessary unless the string
1356 contains an apostrophe, a comma, or backslash (other than
1357 backslash-backslash). YYSTR is taken from htmltname. If YYRES is
1358 null, do not copy; instead, return the length of what the result
1359 would have been. */
1360 static YYSIZE_T
htmltnamerr(char * htmlres,const char * htmlstr)1361 htmltnamerr (char *htmlres, const char *htmlstr)
1362 {
1363 if (*htmlstr == '"')
1364 {
1365 YYSIZE_T htmln = 0;
1366 char const *htmlp = htmlstr;
1367
1368 for (;;)
1369 switch (*++htmlp)
1370 {
1371 case '\'':
1372 case ',':
1373 goto do_not_strip_quotes;
1374
1375 case '\\':
1376 if (*++htmlp != '\\')
1377 goto do_not_strip_quotes;
1378 /* Fall through. */
1379 default:
1380 if (htmlres)
1381 htmlres[htmln] = *htmlp;
1382 htmln++;
1383 break;
1384
1385 case '"':
1386 if (htmlres)
1387 htmlres[htmln] = '\0';
1388 return htmln;
1389 }
1390 do_not_strip_quotes: ;
1391 }
1392
1393 if (! htmlres)
1394 return htmlstrlen (htmlstr);
1395
1396 return htmlstpcpy (htmlres, htmlstr) - htmlres;
1397 }
1398 # endif
1399
1400 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1401 about the unexpected token YYTOKEN for the state stack whose top is
1402 YYSSP.
1403
1404 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1405 not large enough to hold the message. In that case, also set
1406 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1407 required number of bytes is too large to store. */
1408 static int
htmlsyntax_error(YYSIZE_T * htmlmsg_alloc,char ** htmlmsg,htmltype_int16 * htmlssp,int htmltoken)1409 htmlsyntax_error (YYSIZE_T *htmlmsg_alloc, char **htmlmsg,
1410 htmltype_int16 *htmlssp, int htmltoken)
1411 {
1412 YYSIZE_T htmlsize0 = htmltnamerr (YY_NULLPTR, htmltname[htmltoken]);
1413 YYSIZE_T htmlsize = htmlsize0;
1414 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1415 /* Internationalized format string. */
1416 const char *htmlformat = YY_NULLPTR;
1417 /* Arguments of htmlformat. */
1418 char const *htmlarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1419 /* Number of reported tokens (one for the "unexpected", one per
1420 "expected"). */
1421 int htmlcount = 0;
1422
1423 /* There are many possibilities here to consider:
1424 - If this state is a consistent state with a default action, then
1425 the only way this function was invoked is if the default action
1426 is an error action. In that case, don't check for expected
1427 tokens because there are none.
1428 - The only way there can be no lookahead present (in htmlchar) is if
1429 this state is a consistent state with a default action. Thus,
1430 detecting the absence of a lookahead is sufficient to determine
1431 that there is no unexpected or expected token to report. In that
1432 case, just report a simple "syntax error".
1433 - Don't assume there isn't a lookahead just because this state is a
1434 consistent state with a default action. There might have been a
1435 previous inconsistent state, consistent state with a non-default
1436 action, or user semantic action that manipulated htmlchar.
1437 - Of course, the expected token list depends on states to have
1438 correct lookahead information, and it depends on the parser not
1439 to perform extra reductions after fetching a lookahead from the
1440 scanner and before detecting a syntax error. Thus, state merging
1441 (from LALR or IELR) and default reductions corrupt the expected
1442 token list. However, the list is correct for canonical LR with
1443 one exception: it will still contain any token that will not be
1444 accepted due to an error action in a later state.
1445 */
1446 if (htmltoken != YYEMPTY)
1447 {
1448 int htmln = htmlpact[*htmlssp];
1449 htmlarg[htmlcount++] = htmltname[htmltoken];
1450 if (!htmlpact_value_is_default (htmln))
1451 {
1452 /* Start YYX at -YYN if negative to avoid negative indexes in
1453 YYCHECK. In other words, skip the first -YYN actions for
1454 this state because they are default actions. */
1455 int htmlxbegin = htmln < 0 ? -htmln : 0;
1456 /* Stay within bounds of both htmlcheck and htmltname. */
1457 int htmlchecklim = YYLAST - htmln + 1;
1458 int htmlxend = htmlchecklim < YYNTOKENS ? htmlchecklim : YYNTOKENS;
1459 int htmlx;
1460
1461 for (htmlx = htmlxbegin; htmlx < htmlxend; ++htmlx)
1462 if (htmlcheck[htmlx + htmln] == htmlx && htmlx != YYTERROR
1463 && !htmltable_value_is_error (htmltable[htmlx + htmln]))
1464 {
1465 if (htmlcount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1466 {
1467 htmlcount = 1;
1468 htmlsize = htmlsize0;
1469 break;
1470 }
1471 htmlarg[htmlcount++] = htmltname[htmlx];
1472 {
1473 YYSIZE_T htmlsize1 = htmlsize + htmltnamerr (YY_NULLPTR, htmltname[htmlx]);
1474 if (! (htmlsize <= htmlsize1
1475 && htmlsize1 <= YYSTACK_ALLOC_MAXIMUM))
1476 return 2;
1477 htmlsize = htmlsize1;
1478 }
1479 }
1480 }
1481 }
1482
1483 switch (htmlcount)
1484 {
1485 # define YYCASE_(N, S) \
1486 case N: \
1487 htmlformat = S; \
1488 break
1489 YYCASE_(0, YY_("syntax error"));
1490 YYCASE_(1, YY_("syntax error, unexpected %s"));
1491 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1492 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1493 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1494 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1495 # undef YYCASE_
1496 }
1497
1498 {
1499 YYSIZE_T htmlsize1 = htmlsize + htmlstrlen (htmlformat);
1500 if (! (htmlsize <= htmlsize1 && htmlsize1 <= YYSTACK_ALLOC_MAXIMUM))
1501 return 2;
1502 htmlsize = htmlsize1;
1503 }
1504
1505 if (*htmlmsg_alloc < htmlsize)
1506 {
1507 *htmlmsg_alloc = 2 * htmlsize;
1508 if (! (htmlsize <= *htmlmsg_alloc
1509 && *htmlmsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1510 *htmlmsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1511 return 1;
1512 }
1513
1514 /* Avoid sprintf, as that infringes on the user's name space.
1515 Don't have undefined behavior even if the translation
1516 produced a string with the wrong number of "%s"s. */
1517 {
1518 char *htmlp = *htmlmsg;
1519 int htmli = 0;
1520 while ((*htmlp = *htmlformat) != '\0')
1521 if (*htmlp == '%' && htmlformat[1] == 's' && htmli < htmlcount)
1522 {
1523 htmlp += htmltnamerr (htmlp, htmlarg[htmli++]);
1524 htmlformat += 2;
1525 }
1526 else
1527 {
1528 htmlp++;
1529 htmlformat++;
1530 }
1531 }
1532 return 0;
1533 }
1534 #endif /* YYERROR_VERBOSE */
1535
1536 /*-----------------------------------------------.
1537 | Release the memory associated to this symbol. |
1538 `-----------------------------------------------*/
1539
1540 static void
htmldestruct(const char * htmlmsg,int htmltype,YYSTYPE * htmlvaluep)1541 htmldestruct (const char *htmlmsg, int htmltype, YYSTYPE *htmlvaluep)
1542 {
1543 YYUSE (htmlvaluep);
1544 if (!htmlmsg)
1545 htmlmsg = "Deleting";
1546 YY_SYMBOL_PRINT (htmlmsg, htmltype, htmlvaluep, htmllocationp);
1547
1548 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1549 YYUSE (htmltype);
1550 YY_IGNORE_MAYBE_UNINITIALIZED_END
1551 }
1552
1553
1554
1555
1556 /* The lookahead symbol. */
1557 int htmlchar;
1558
1559 /* The semantic value of the lookahead symbol. */
1560 YYSTYPE htmllval;
1561 /* Number of syntax errors so far. */
1562 int htmlnerrs;
1563
1564
1565 /*----------.
1566 | htmlparse. |
1567 `----------*/
1568
1569 int
htmlparse(void)1570 htmlparse (void)
1571 {
1572 int htmlstate;
1573 /* Number of tokens to shift before error messages enabled. */
1574 int htmlerrstatus;
1575
1576 /* The stacks and their tools:
1577 'htmlss': related to states.
1578 'htmlvs': related to semantic values.
1579
1580 Refer to the stacks through separate pointers, to allow htmloverflow
1581 to reallocate them elsewhere. */
1582
1583 /* The state stack. */
1584 htmltype_int16 htmlssa[YYINITDEPTH];
1585 htmltype_int16 *htmlss;
1586 htmltype_int16 *htmlssp;
1587
1588 /* The semantic value stack. */
1589 YYSTYPE htmlvsa[YYINITDEPTH];
1590 YYSTYPE *htmlvs;
1591 YYSTYPE *htmlvsp;
1592
1593 YYSIZE_T htmlstacksize;
1594
1595 int htmln;
1596 int htmlresult;
1597 /* Lookahead token as an internal (translated) token number. */
1598 int htmltoken = 0;
1599 /* The variables used to return semantic value and location from the
1600 action routines. */
1601 YYSTYPE htmlval;
1602
1603 #if YYERROR_VERBOSE
1604 /* Buffer for error messages, and its allocated size. */
1605 char htmlmsgbuf[128];
1606 char *htmlmsg = htmlmsgbuf;
1607 YYSIZE_T htmlmsg_alloc = sizeof htmlmsgbuf;
1608 #endif
1609
1610 #define YYPOPSTACK(N) (htmlvsp -= (N), htmlssp -= (N))
1611
1612 /* The number of symbols on the RHS of the reduced rule.
1613 Keep to zero when no symbol should be popped. */
1614 int htmllen = 0;
1615
1616 htmlssp = htmlss = htmlssa;
1617 htmlvsp = htmlvs = htmlvsa;
1618 htmlstacksize = YYINITDEPTH;
1619
1620 YYDPRINTF ((stderr, "Starting parse\n"));
1621
1622 htmlstate = 0;
1623 htmlerrstatus = 0;
1624 htmlnerrs = 0;
1625 htmlchar = YYEMPTY; /* Cause a token to be read. */
1626 goto htmlsetstate;
1627
1628 /*------------------------------------------------------------.
1629 | htmlnewstate -- Push a new state, which is found in htmlstate. |
1630 `------------------------------------------------------------*/
1631 htmlnewstate:
1632 /* In all cases, when you get here, the value and location stacks
1633 have just been pushed. So pushing a state here evens the stacks. */
1634 htmlssp++;
1635
1636 htmlsetstate:
1637 *htmlssp = htmlstate;
1638
1639 if (htmlss + htmlstacksize - 1 <= htmlssp)
1640 {
1641 /* Get the current used size of the three stacks, in elements. */
1642 YYSIZE_T htmlsize = htmlssp - htmlss + 1;
1643
1644 #ifdef htmloverflow
1645 {
1646 /* Give user a chance to reallocate the stack. Use copies of
1647 these so that the &'s don't force the real ones into
1648 memory. */
1649 YYSTYPE *htmlvs1 = htmlvs;
1650 htmltype_int16 *htmlss1 = htmlss;
1651
1652 /* Each stack pointer address is followed by the size of the
1653 data in use in that stack, in bytes. This used to be a
1654 conditional around just the two extra args, but that might
1655 be undefined if htmloverflow is a macro. */
1656 htmloverflow (YY_("memory exhausted"),
1657 &htmlss1, htmlsize * sizeof (*htmlssp),
1658 &htmlvs1, htmlsize * sizeof (*htmlvsp),
1659 &htmlstacksize);
1660
1661 htmlss = htmlss1;
1662 htmlvs = htmlvs1;
1663 }
1664 #else /* no htmloverflow */
1665 # ifndef YYSTACK_RELOCATE
1666 goto htmlexhaustedlab;
1667 # else
1668 /* Extend the stack our own way. */
1669 if (YYMAXDEPTH <= htmlstacksize)
1670 goto htmlexhaustedlab;
1671 htmlstacksize *= 2;
1672 if (YYMAXDEPTH < htmlstacksize)
1673 htmlstacksize = YYMAXDEPTH;
1674
1675 {
1676 htmltype_int16 *htmlss1 = htmlss;
1677 union htmlalloc *htmlptr =
1678 (union htmlalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (htmlstacksize));
1679 if (! htmlptr)
1680 goto htmlexhaustedlab;
1681 YYSTACK_RELOCATE (htmlss_alloc, htmlss);
1682 YYSTACK_RELOCATE (htmlvs_alloc, htmlvs);
1683 # undef YYSTACK_RELOCATE
1684 if (htmlss1 != htmlssa)
1685 YYSTACK_FREE (htmlss1);
1686 }
1687 # endif
1688 #endif /* no htmloverflow */
1689
1690 htmlssp = htmlss + htmlsize - 1;
1691 htmlvsp = htmlvs + htmlsize - 1;
1692
1693 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1694 (uint64_t) htmlstacksize));
1695
1696 if (htmlss + htmlstacksize - 1 <= htmlssp)
1697 YYABORT;
1698 }
1699
1700 YYDPRINTF ((stderr, "Entering state %d\n", htmlstate));
1701
1702 if (htmlstate == YYFINAL)
1703 YYACCEPT;
1704
1705 goto htmlbackup;
1706
1707 /*-----------.
1708 | htmlbackup. |
1709 `-----------*/
1710 htmlbackup:
1711
1712 /* Do appropriate processing given the current state. Read a
1713 lookahead token if we need one and don't already have one. */
1714
1715 /* First try to decide what to do without reference to lookahead token. */
1716 htmln = htmlpact[htmlstate];
1717 if (htmlpact_value_is_default (htmln))
1718 goto htmldefault;
1719
1720 /* Not known => get a lookahead token if don't already have one. */
1721
1722 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1723 if (htmlchar == YYEMPTY)
1724 {
1725 YYDPRINTF ((stderr, "Reading a token: "));
1726 htmlchar = htmllex ();
1727 }
1728
1729 if (htmlchar <= YYEOF)
1730 {
1731 htmlchar = htmltoken = YYEOF;
1732 YYDPRINTF ((stderr, "Now at end of input.\n"));
1733 }
1734 else
1735 {
1736 htmltoken = YYTRANSLATE (htmlchar);
1737 YY_SYMBOL_PRINT ("Next token is", htmltoken, &htmllval, &htmllloc);
1738 }
1739
1740 /* If the proper action on seeing token YYTOKEN is to reduce or to
1741 detect an error, take that action. */
1742 htmln += htmltoken;
1743 if (htmln < 0 || YYLAST < htmln || htmlcheck[htmln] != htmltoken)
1744 goto htmldefault;
1745 htmln = htmltable[htmln];
1746 if (htmln <= 0)
1747 {
1748 if (htmltable_value_is_error (htmln))
1749 goto htmlerrlab;
1750 htmln = -htmln;
1751 goto htmlreduce;
1752 }
1753
1754 /* Count tokens shifted since error; after three, turn off error
1755 status. */
1756 if (htmlerrstatus)
1757 htmlerrstatus--;
1758
1759 /* Shift the lookahead token. */
1760 YY_SYMBOL_PRINT ("Shifting", htmltoken, &htmllval, &htmllloc);
1761
1762 /* Discard the shifted token. */
1763 htmlchar = YYEMPTY;
1764
1765 htmlstate = htmln;
1766 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1767 *++htmlvsp = htmllval;
1768 YY_IGNORE_MAYBE_UNINITIALIZED_END
1769
1770 goto htmlnewstate;
1771
1772
1773 /*-----------------------------------------------------------.
1774 | htmldefault -- do the default action for the current state. |
1775 `-----------------------------------------------------------*/
1776 htmldefault:
1777 htmln = htmldefact[htmlstate];
1778 if (htmln == 0)
1779 goto htmlerrlab;
1780 goto htmlreduce;
1781
1782
1783 /*-----------------------------.
1784 | htmlreduce -- Do a reduction. |
1785 `-----------------------------*/
1786 htmlreduce:
1787 /* htmln is the number of a rule to reduce with. */
1788 htmllen = htmlr2[htmln];
1789
1790 /* If YYLEN is nonzero, implement the default value of the action:
1791 '$$ = $1'.
1792
1793 Otherwise, the following line sets YYVAL to garbage.
1794 This behavior is undocumented and Bison
1795 users should not rely upon it. Assigning to YYVAL
1796 unconditionally makes the parser a bit smaller, and it avoids a
1797 GCC warning that YYVAL may be used uninitialized. */
1798 htmlval = htmlvsp[1-htmllen];
1799
1800
1801 YY_REDUCE_PRINT (htmln);
1802 switch (htmln)
1803 {
1804 case 2:
1805 #line 447 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1806 { HTMLstate.lbl = mkLabel((htmlvsp[-1].txt),HTML_TEXT); }
1807 #line 1808 "y.tab.c" /* yacc.c:1646 */
1808 break;
1809
1810 case 3:
1811 #line 448 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1812 { HTMLstate.lbl = mkLabel((htmlvsp[-1].tbl),HTML_TBL); }
1813 #line 1814 "y.tab.c" /* yacc.c:1646 */
1814 break;
1815
1816 case 4:
1817 #line 449 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1818 { cleanup(); YYABORT; }
1819 #line 1820 "y.tab.c" /* yacc.c:1646 */
1820 break;
1821
1822 case 5:
1823 #line 452 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1824 { (htmlval.txt) = mkText(); }
1825 #line 1826 "y.tab.c" /* yacc.c:1646 */
1826 break;
1827
1828 case 8:
1829 #line 459 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1830 { appendFItemList(HTMLstate.str);}
1831 #line 1832 "y.tab.c" /* yacc.c:1646 */
1832 break;
1833
1834 case 9:
1835 #line 460 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1836 {appendFLineList((htmlvsp[0].i));}
1837 #line 1838 "y.tab.c" /* yacc.c:1646 */
1838 break;
1839
1840 case 18:
1841 #line 471 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1842 { pushFont ((htmlvsp[0].font)); }
1843 #line 1844 "y.tab.c" /* yacc.c:1646 */
1844 break;
1845
1846 case 19:
1847 #line 474 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1848 { popFont (); }
1849 #line 1850 "y.tab.c" /* yacc.c:1646 */
1850 break;
1851
1852 case 20:
1853 #line 477 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1854 {pushFont((htmlvsp[0].font));}
1855 #line 1856 "y.tab.c" /* yacc.c:1646 */
1856 break;
1857
1858 case 21:
1859 #line 480 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1860 {popFont();}
1861 #line 1862 "y.tab.c" /* yacc.c:1646 */
1862 break;
1863
1864 case 22:
1865 #line 483 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1866 {pushFont((htmlvsp[0].font));}
1867 #line 1868 "y.tab.c" /* yacc.c:1646 */
1868 break;
1869
1870 case 23:
1871 #line 486 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1872 {popFont();}
1873 #line 1874 "y.tab.c" /* yacc.c:1646 */
1874 break;
1875
1876 case 24:
1877 #line 489 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1878 {pushFont((htmlvsp[0].font));}
1879 #line 1880 "y.tab.c" /* yacc.c:1646 */
1880 break;
1881
1882 case 25:
1883 #line 492 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1884 {popFont();}
1885 #line 1886 "y.tab.c" /* yacc.c:1646 */
1886 break;
1887
1888 case 26:
1889 #line 495 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1890 {pushFont((htmlvsp[0].font));}
1891 #line 1892 "y.tab.c" /* yacc.c:1646 */
1892 break;
1893
1894 case 27:
1895 #line 498 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1896 {popFont();}
1897 #line 1898 "y.tab.c" /* yacc.c:1646 */
1898 break;
1899
1900 case 28:
1901 #line 501 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1902 {pushFont((htmlvsp[0].font));}
1903 #line 1904 "y.tab.c" /* yacc.c:1646 */
1904 break;
1905
1906 case 29:
1907 #line 504 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1908 {popFont();}
1909 #line 1910 "y.tab.c" /* yacc.c:1646 */
1910 break;
1911
1912 case 30:
1913 #line 507 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1914 {pushFont((htmlvsp[0].font));}
1915 #line 1916 "y.tab.c" /* yacc.c:1646 */
1916 break;
1917
1918 case 31:
1919 #line 510 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1920 {popFont();}
1921 #line 1922 "y.tab.c" /* yacc.c:1646 */
1922 break;
1923
1924 case 32:
1925 #line 513 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1926 {pushFont((htmlvsp[0].font));}
1927 #line 1928 "y.tab.c" /* yacc.c:1646 */
1928 break;
1929
1930 case 33:
1931 #line 516 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1932 {popFont();}
1933 #line 1934 "y.tab.c" /* yacc.c:1646 */
1934 break;
1935
1936 case 34:
1937 #line 519 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1938 { (htmlval.i) = (htmlvsp[-1].i); }
1939 #line 1940 "y.tab.c" /* yacc.c:1646 */
1940 break;
1941
1942 case 35:
1943 #line 520 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1944 { (htmlval.i) = (htmlvsp[0].i); }
1945 #line 1946 "y.tab.c" /* yacc.c:1646 */
1946 break;
1947
1948 case 38:
1949 #line 527 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1950 {
1951 if (nonSpace(agxbuse(HTMLstate.str))) {
1952 htmlerror ("Syntax error: non-space string used before <TABLE>");
1953 cleanup(); YYABORT;
1954 }
1955 (htmlvsp[0].tbl)->u.p.prev = HTMLstate.tblstack;
1956 (htmlvsp[0].tbl)->u.p.rows = dtopen(&rowDisc, Dtqueue);
1957 HTMLstate.tblstack = (htmlvsp[0].tbl);
1958 (htmlvsp[0].tbl)->font = HTMLstate.fontstack->cfont;
1959 (htmlval.tbl) = (htmlvsp[0].tbl);
1960 }
1961 #line 1962 "y.tab.c" /* yacc.c:1646 */
1962 break;
1963
1964 case 39:
1965 #line 538 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1966 {
1967 if (nonSpace(agxbuse(HTMLstate.str))) {
1968 htmlerror ("Syntax error: non-space string used after </TABLE>");
1969 cleanup(); YYABORT;
1970 }
1971 (htmlval.tbl) = HTMLstate.tblstack;
1972 HTMLstate.tblstack = HTMLstate.tblstack->u.p.prev;
1973 }
1974 #line 1975 "y.tab.c" /* yacc.c:1646 */
1975 break;
1976
1977 case 40:
1978 #line 548 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1979 { (htmlval.tbl) = (htmlvsp[0].tbl); }
1980 #line 1981 "y.tab.c" /* yacc.c:1646 */
1981 break;
1982
1983 case 41:
1984 #line 549 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1985 { (htmlval.tbl)=(htmlvsp[-1].tbl); }
1986 #line 1987 "y.tab.c" /* yacc.c:1646 */
1987 break;
1988
1989 case 42:
1990 #line 550 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1991 { (htmlval.tbl)=(htmlvsp[-1].tbl); }
1992 #line 1993 "y.tab.c" /* yacc.c:1646 */
1993 break;
1994
1995 case 43:
1996 #line 551 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
1997 { (htmlval.tbl)=(htmlvsp[-1].tbl); }
1998 #line 1999 "y.tab.c" /* yacc.c:1646 */
1999 break;
2000
2001 case 44:
2002 #line 552 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2003 { (htmlval.tbl)=(htmlvsp[-1].tbl); }
2004 #line 2005 "y.tab.c" /* yacc.c:1646 */
2005 break;
2006
2007 case 45:
2008 #line 553 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2009 { (htmlval.tbl)=(htmlvsp[-1].tbl); }
2010 #line 2011 "y.tab.c" /* yacc.c:1646 */
2011 break;
2012
2013 case 48:
2014 #line 560 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2015 { (htmlval.p) = (htmlvsp[0].p); }
2016 #line 2017 "y.tab.c" /* yacc.c:1646 */
2017 break;
2018
2019 case 49:
2020 #line 561 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2021 { (htmlval.p) = (htmlvsp[0].p); }
2022 #line 2023 "y.tab.c" /* yacc.c:1646 */
2023 break;
2024
2025 case 50:
2026 #line 562 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2027 { (htmlvsp[-2].p)->ruled = 1; (htmlval.p) = (htmlvsp[0].p); }
2028 #line 2029 "y.tab.c" /* yacc.c:1646 */
2029 break;
2030
2031 case 51:
2032 #line 565 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2033 { addRow (); }
2034 #line 2035 "y.tab.c" /* yacc.c:1646 */
2035 break;
2036
2037 case 52:
2038 #line 565 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2039 { (htmlval.p) = lastRow(); }
2040 #line 2041 "y.tab.c" /* yacc.c:1646 */
2041 break;
2042
2043 case 53:
2044 #line 568 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2045 { (htmlval.cell) = (htmlvsp[0].cell); }
2046 #line 2047 "y.tab.c" /* yacc.c:1646 */
2047 break;
2048
2049 case 54:
2050 #line 569 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2051 { (htmlval.cell) = (htmlvsp[0].cell); }
2052 #line 2053 "y.tab.c" /* yacc.c:1646 */
2053 break;
2054
2055 case 55:
2056 #line 570 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2057 { (htmlvsp[-2].cell)->ruled |= HTML_VRULE; (htmlval.cell) = (htmlvsp[0].cell); }
2058 #line 2059 "y.tab.c" /* yacc.c:1646 */
2059 break;
2060
2061 case 56:
2062 #line 573 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2063 { setCell((htmlvsp[-1].cell),(htmlvsp[0].tbl),HTML_TBL); }
2064 #line 2065 "y.tab.c" /* yacc.c:1646 */
2065 break;
2066
2067 case 57:
2068 #line 573 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2069 { (htmlval.cell) = (htmlvsp[-3].cell); }
2070 #line 2071 "y.tab.c" /* yacc.c:1646 */
2071 break;
2072
2073 case 58:
2074 #line 574 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2075 { setCell((htmlvsp[-1].cell),(htmlvsp[0].txt),HTML_TEXT); }
2076 #line 2077 "y.tab.c" /* yacc.c:1646 */
2077 break;
2078
2079 case 59:
2080 #line 574 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2081 { (htmlval.cell) = (htmlvsp[-3].cell); }
2082 #line 2083 "y.tab.c" /* yacc.c:1646 */
2083 break;
2084
2085 case 60:
2086 #line 575 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2087 { setCell((htmlvsp[-1].cell),(htmlvsp[0].img),HTML_IMAGE); }
2088 #line 2089 "y.tab.c" /* yacc.c:1646 */
2089 break;
2090
2091 case 61:
2092 #line 575 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2093 { (htmlval.cell) = (htmlvsp[-3].cell); }
2094 #line 2095 "y.tab.c" /* yacc.c:1646 */
2095 break;
2096
2097 case 62:
2098 #line 576 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2099 { setCell((htmlvsp[0].cell),mkText(),HTML_TEXT); }
2100 #line 2101 "y.tab.c" /* yacc.c:1646 */
2101 break;
2102
2103 case 63:
2104 #line 576 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2105 { (htmlval.cell) = (htmlvsp[-2].cell); }
2106 #line 2107 "y.tab.c" /* yacc.c:1646 */
2107 break;
2108
2109 case 64:
2110 #line 579 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2111 { (htmlval.img) = (htmlvsp[-1].img); }
2112 #line 2113 "y.tab.c" /* yacc.c:1646 */
2113 break;
2114
2115 case 65:
2116 #line 580 "../../lib/common/htmlparse.y" /* yacc.c:1646 */
2117 { (htmlval.img) = (htmlvsp[0].img); }
2118 #line 2119 "y.tab.c" /* yacc.c:1646 */
2119 break;
2120
2121
2122 #line 2123 "y.tab.c" /* yacc.c:1646 */
2123 default: break;
2124 }
2125 /* User semantic actions sometimes alter htmlchar, and that requires
2126 that htmltoken be updated with the new translation. We take the
2127 approach of translating immediately before every use of htmltoken.
2128 One alternative is translating here after every semantic action,
2129 but that translation would be missed if the semantic action invokes
2130 YYABORT, YYACCEPT, or YYERROR immediately after altering htmlchar or
2131 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2132 incorrect destructor might then be invoked immediately. In the
2133 case of YYERROR or YYBACKUP, subsequent parser actions might lead
2134 to an incorrect destructor call or verbose syntax error message
2135 before the lookahead is translated. */
2136 YY_SYMBOL_PRINT ("-> $$ =", htmlr1[htmln], &htmlval, &htmlloc);
2137
2138 YYPOPSTACK (htmllen);
2139 htmllen = 0;
2140 YY_STACK_PRINT (htmlss, htmlssp);
2141
2142 *++htmlvsp = htmlval;
2143
2144 /* Now 'shift' the result of the reduction. Determine what state
2145 that goes to, based on the state we popped back to and the rule
2146 number reduced by. */
2147
2148 htmln = htmlr1[htmln];
2149
2150 htmlstate = htmlpgoto[htmln - YYNTOKENS] + *htmlssp;
2151 if (0 <= htmlstate && htmlstate <= YYLAST && htmlcheck[htmlstate] == *htmlssp)
2152 htmlstate = htmltable[htmlstate];
2153 else
2154 htmlstate = htmldefgoto[htmln - YYNTOKENS];
2155
2156 goto htmlnewstate;
2157
2158
2159 /*--------------------------------------.
2160 | htmlerrlab -- here on detecting error. |
2161 `--------------------------------------*/
2162 htmlerrlab:
2163 /* Make sure we have latest lookahead translation. See comments at
2164 user semantic actions for why this is necessary. */
2165 htmltoken = htmlchar == YYEMPTY ? YYEMPTY : YYTRANSLATE (htmlchar);
2166
2167 /* If not already recovering from an error, report this error. */
2168 if (!htmlerrstatus)
2169 {
2170 ++htmlnerrs;
2171 #if ! YYERROR_VERBOSE
2172 htmlerror (YY_("syntax error"));
2173 #else
2174 # define YYSYNTAX_ERROR htmlsyntax_error (&htmlmsg_alloc, &htmlmsg, \
2175 htmlssp, htmltoken)
2176 {
2177 char const *htmlmsgp = YY_("syntax error");
2178 int htmlsyntax_error_status;
2179 htmlsyntax_error_status = YYSYNTAX_ERROR;
2180 if (htmlsyntax_error_status == 0)
2181 htmlmsgp = htmlmsg;
2182 else if (htmlsyntax_error_status == 1)
2183 {
2184 if (htmlmsg != htmlmsgbuf)
2185 YYSTACK_FREE (htmlmsg);
2186 htmlmsg = (char *) YYSTACK_ALLOC (htmlmsg_alloc);
2187 if (!htmlmsg)
2188 {
2189 htmlmsg = htmlmsgbuf;
2190 htmlmsg_alloc = sizeof htmlmsgbuf;
2191 htmlsyntax_error_status = 2;
2192 }
2193 else
2194 {
2195 htmlsyntax_error_status = YYSYNTAX_ERROR;
2196 htmlmsgp = htmlmsg;
2197 }
2198 }
2199 htmlerror (htmlmsgp);
2200 if (htmlsyntax_error_status == 2)
2201 goto htmlexhaustedlab;
2202 }
2203 # undef YYSYNTAX_ERROR
2204 #endif
2205 }
2206
2207
2208
2209 if (htmlerrstatus == 3)
2210 {
2211 /* If just tried and failed to reuse lookahead token after an
2212 error, discard it. */
2213
2214 if (htmlchar <= YYEOF)
2215 {
2216 /* Return failure if at end of input. */
2217 if (htmlchar == YYEOF)
2218 YYABORT;
2219 }
2220 else
2221 {
2222 htmldestruct ("Error: discarding",
2223 htmltoken, &htmllval);
2224 htmlchar = YYEMPTY;
2225 }
2226 }
2227
2228 /* Else will try to reuse lookahead token after shifting the error
2229 token. */
2230 goto htmlerrlab1;
2231
2232
2233 /*---------------------------------------------------.
2234 | htmlerrorlab -- error raised explicitly by YYERROR. |
2235 `---------------------------------------------------*/
2236 htmlerrorlab:
2237
2238 /* Pacify compilers like GCC when the user code never invokes
2239 YYERROR and the label htmlerrorlab therefore never appears in user
2240 code. */
2241 if (/*CONSTCOND*/ 0)
2242 goto htmlerrorlab;
2243
2244 /* Do not reclaim the symbols of the rule whose action triggered
2245 this YYERROR. */
2246 YYPOPSTACK (htmllen);
2247 htmllen = 0;
2248 YY_STACK_PRINT (htmlss, htmlssp);
2249 htmlstate = *htmlssp;
2250 goto htmlerrlab1;
2251
2252
2253 /*-------------------------------------------------------------.
2254 | htmlerrlab1 -- common code for both syntax error and YYERROR. |
2255 `-------------------------------------------------------------*/
2256 htmlerrlab1:
2257 htmlerrstatus = 3; /* Each real token shifted decrements this. */
2258
2259 for (;;)
2260 {
2261 htmln = htmlpact[htmlstate];
2262 if (!htmlpact_value_is_default (htmln))
2263 {
2264 htmln += YYTERROR;
2265 if (0 <= htmln && htmln <= YYLAST && htmlcheck[htmln] == YYTERROR)
2266 {
2267 htmln = htmltable[htmln];
2268 if (0 < htmln)
2269 break;
2270 }
2271 }
2272
2273 /* Pop the current state because it cannot handle the error token. */
2274 if (htmlssp == htmlss)
2275 YYABORT;
2276
2277
2278 htmldestruct ("Error: popping",
2279 htmlstos[htmlstate], htmlvsp);
2280 YYPOPSTACK (1);
2281 htmlstate = *htmlssp;
2282 YY_STACK_PRINT (htmlss, htmlssp);
2283 }
2284
2285 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2286 *++htmlvsp = htmllval;
2287 YY_IGNORE_MAYBE_UNINITIALIZED_END
2288
2289
2290 /* Shift the error token. */
2291 YY_SYMBOL_PRINT ("Shifting", htmlstos[htmln], htmlvsp, htmllsp);
2292
2293 htmlstate = htmln;
2294 goto htmlnewstate;
2295
2296
2297 /*-------------------------------------.
2298 | htmlacceptlab -- YYACCEPT comes here. |
2299 `-------------------------------------*/
2300 htmlacceptlab:
2301 htmlresult = 0;
2302 goto htmlreturn;
2303
2304 /*-----------------------------------.
2305 | htmlabortlab -- YYABORT comes here. |
2306 `-----------------------------------*/
2307 htmlabortlab:
2308 htmlresult = 1;
2309 goto htmlreturn;
2310
2311 #if !defined htmloverflow || YYERROR_VERBOSE
2312 /*-------------------------------------------------.
2313 | htmlexhaustedlab -- memory exhaustion comes here. |
2314 `-------------------------------------------------*/
2315 htmlexhaustedlab:
2316 htmlerror (YY_("memory exhausted"));
2317 htmlresult = 2;
2318 /* Fall through. */
2319 #endif
2320
2321 htmlreturn:
2322 if (htmlchar != YYEMPTY)
2323 {
2324 /* Make sure we have latest lookahead translation. See comments at
2325 user semantic actions for why this is necessary. */
2326 htmltoken = YYTRANSLATE (htmlchar);
2327 htmldestruct ("Cleanup: discarding lookahead",
2328 htmltoken, &htmllval);
2329 }
2330 /* Do not reclaim the symbols of the rule whose action triggered
2331 this YYABORT or YYACCEPT. */
2332 YYPOPSTACK (htmllen);
2333 YY_STACK_PRINT (htmlss, htmlssp);
2334 while (htmlssp != htmlss)
2335 {
2336 htmldestruct ("Cleanup: popping",
2337 htmlstos[*htmlssp], htmlvsp);
2338 YYPOPSTACK (1);
2339 }
2340 #ifndef htmloverflow
2341 if (htmlss != htmlssa)
2342 YYSTACK_FREE (htmlss);
2343 #endif
2344 #if YYERROR_VERBOSE
2345 if (htmlmsg != htmlmsgbuf)
2346 YYSTACK_FREE (htmlmsg);
2347 #endif
2348 return htmlresult;
2349 }
2350 #line 592 "../../lib/common/htmlparse.y" /* yacc.c:1906 */
2351
2352
2353 /* parseHTML:
2354 * Return parsed label or NULL if failure.
2355 * Set warn to 0 on success; 1 for warning message; 2 if no expat.
2356 */
2357 htmllabel_t*
parseHTML(char * txt,int * warn,htmlenv_t * env)2358 parseHTML (char* txt, int* warn, htmlenv_t *env)
2359 {
2360 unsigned char buf[SMALLBUF];
2361 agxbuf str;
2362 htmllabel_t* l;
2363 sfont_t dfltf;
2364
2365 dfltf.cfont = NULL;
2366 dfltf.pfont = NULL;
2367 HTMLstate.fontstack = &dfltf;
2368 HTMLstate.tblstack = 0;
2369 HTMLstate.lbl = 0;
2370 HTMLstate.gvc = GD_gvc(env->g);
2371 HTMLstate.fitemList = dtopen(&fstrDisc, Dtqueue);
2372 HTMLstate.fspanList = dtopen(&fspanDisc, Dtqueue);
2373
2374 agxbinit (&str, SMALLBUF, buf);
2375 HTMLstate.str = &str;
2376
2377 if (initHTMLlexer (txt, &str, env)) {/* failed: no libexpat - give up */
2378 *warn = 2;
2379 l = NULL;
2380 }
2381 else {
2382 htmlparse();
2383 *warn = clearHTMLlexer ();
2384 l = HTMLstate.lbl;
2385 }
2386
2387 dtclose (HTMLstate.fitemList);
2388 dtclose (HTMLstate.fspanList);
2389
2390 HTMLstate.fitemList = NULL;
2391 HTMLstate.fspanList = NULL;
2392 HTMLstate.fontstack = NULL;
2393
2394 agxbfree (&str);
2395
2396 return l;
2397 }
2398
2399