Graphviz 13.0.0~dev.20250607.1528
Loading...
Searching...
No Matches
htmlparse.c
Go to the documentation of this file.
1/* A Bison parser, made by GNU Bison 3.8.2. */
2
3/* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6 Inc.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
20
21/* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
30
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
33
34/* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
36
37/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 especially those whose name start with YY_ or yy_. They are
39 private implementation details that can be changed or removed. */
40
41/* All symbols defined below should begin with yy or YY, to avoid
42 infringing on user name space. This should be done even for local
43 variables, as they might otherwise be expanded by user macros.
44 There are some unavoidable exceptions within include files to
45 define necessary library symbols; they are noted "INFRINGES ON
46 USER NAME SPACE" below. */
47
48/* Identify Bison output, and Bison version. */
49#define YYBISON 30802
50
51/* Bison version string. */
52#define YYBISON_VERSION "3.8.2"
53
54/* Skeleton name. */
55#define YYSKELETON_NAME "yacc.c"
56
57/* Pure parsers. */
58#define YYPURE 2
59
60/* Push parsers. */
61#define YYPUSH 0
62
63/* Pull parsers. */
64#define YYPULL 1
65
66/* Substitute the type names. */
67#define YYSTYPE HTMLSTYPE
68/* Substitute the variable and function names. */
69#define yyparse htmlparse
70#define yylex htmllex
71#define yyerror htmlerror
72#define yydebug htmldebug
73#define yynerrs htmlnerrs
74
75/* First part of user prologue. */
76#line 90 "../../lib/common/htmlparse.y"
77
78
79#include <common/render.h>
80#include <common/htmltable.h>
81#include <common/htmllex.h>
82#include <stdbool.h>
83#include <util/alloc.h>
84
86static void cleanCell(htmlcell_t *cp);
87
89static void cleanTbl(htmltbl_t *tp) {
90 rows_t *rows = &tp->u.p.rows;
91 for (size_t r = 0; r < rows_size(rows); ++r) {
92 row_t *rp = rows_get(rows, r);
93 for (size_t c = 0; c < cells_size(&rp->rp); ++c) {
94 cleanCell(cells_get(&rp->rp, c));
95 }
96 }
97 rows_free(rows);
98 free_html_data(&tp->data);
99 free(tp);
100}
101
103static void
105{
106 if (cp->child.kind == HTML_TBL) cleanTbl (cp->child.u.tbl);
107 else if (cp->child.kind == HTML_TEXT) free_html_text (cp->child.u.txt);
108 free_html_data (&cp->data);
109 free (cp);
110}
111
113static void
114appendFItemList (htmlparserstate_t *html_state, agxbuf *ag);
115
116static void
117appendFLineList (htmlparserstate_t *html_state, int v);
118
119static htmltxt_t*
120mkText(htmlparserstate_t *html_state);
121
122static row_t *lastRow(htmlparserstate_t *html_state);
123
125static void addRow(htmlparserstate_t *html_state);
126
128static void setCell(htmlparserstate_t *html_state, htmlcell_t *cp, void *obj, label_type_t kind);
129
131static htmllabel_t *mkLabel(void *obj, label_type_t kind) {
132 htmllabel_t* lp = gv_alloc(sizeof(htmllabel_t));
133
134 lp->kind = kind;
135 if (kind == HTML_TEXT)
136 lp->u.txt = obj;
137 else
138 lp->u.tbl = obj;
139 return lp;
140}
141
142/* Called on error. Frees resources allocated during parsing.
143 * This includes a label, plus a walk down the stack of
144 * tables. Note that `cleanTbl` frees the contained cells.
145 */
146static void cleanup (htmlparserstate_t *html_state);
147
149static bool nonSpace(const char *s) {
150 char c;
151
152 while ((c = *s++)) {
153 if (c != ' ') return true;
154 }
155 return false;
156}
157
159static void
160pushFont (htmlparserstate_t *html_state, textfont_t *fp);
161
162static void
163popFont (htmlparserstate_t *html_state);
164
165
166#line 167 "htmlparse.c"
167
168# ifndef YY_CAST
169# ifdef __cplusplus
170# define YY_CAST(Type, Val) static_cast<Type> (Val)
171# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
172# else
173# define YY_CAST(Type, Val) ((Type) (Val))
174# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
175# endif
176# endif
177# ifndef YY_NULLPTR
178# if defined __cplusplus
179# if 201103L <= __cplusplus
180# define YY_NULLPTR nullptr
181# else
182# define YY_NULLPTR 0
183# endif
184# else
185# define YY_NULLPTR ((void*)0)
186# endif
187# endif
188
189#include "htmlparse.h"
190/* Symbol kind. */
192{
194 YYSYMBOL_YYEOF = 0, /* "end of file" */
195 YYSYMBOL_YYerror = 1, /* error */
196 YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
197 YYSYMBOL_T_end_br = 3, /* T_end_br */
198 YYSYMBOL_T_end_img = 4, /* T_end_img */
199 YYSYMBOL_T_row = 5, /* T_row */
200 YYSYMBOL_T_end_row = 6, /* T_end_row */
201 YYSYMBOL_T_html = 7, /* T_html */
202 YYSYMBOL_T_end_html = 8, /* T_end_html */
203 YYSYMBOL_T_end_table = 9, /* T_end_table */
204 YYSYMBOL_T_end_cell = 10, /* T_end_cell */
205 YYSYMBOL_T_end_font = 11, /* T_end_font */
206 YYSYMBOL_T_string = 12, /* T_string */
207 YYSYMBOL_T_error = 13, /* T_error */
208 YYSYMBOL_T_n_italic = 14, /* T_n_italic */
209 YYSYMBOL_T_n_bold = 15, /* T_n_bold */
210 YYSYMBOL_T_n_underline = 16, /* T_n_underline */
211 YYSYMBOL_T_n_overline = 17, /* T_n_overline */
212 YYSYMBOL_T_n_sup = 18, /* T_n_sup */
213 YYSYMBOL_T_n_sub = 19, /* T_n_sub */
214 YYSYMBOL_T_n_s = 20, /* T_n_s */
215 YYSYMBOL_T_HR = 21, /* T_HR */
216 YYSYMBOL_T_hr = 22, /* T_hr */
217 YYSYMBOL_T_end_hr = 23, /* T_end_hr */
218 YYSYMBOL_T_VR = 24, /* T_VR */
219 YYSYMBOL_T_vr = 25, /* T_vr */
220 YYSYMBOL_T_end_vr = 26, /* T_end_vr */
221 YYSYMBOL_T_BR = 27, /* T_BR */
222 YYSYMBOL_T_br = 28, /* T_br */
223 YYSYMBOL_T_IMG = 29, /* T_IMG */
224 YYSYMBOL_T_img = 30, /* T_img */
225 YYSYMBOL_T_table = 31, /* T_table */
226 YYSYMBOL_T_cell = 32, /* T_cell */
227 YYSYMBOL_T_font = 33, /* T_font */
228 YYSYMBOL_T_italic = 34, /* T_italic */
229 YYSYMBOL_T_bold = 35, /* T_bold */
230 YYSYMBOL_T_underline = 36, /* T_underline */
231 YYSYMBOL_T_overline = 37, /* T_overline */
232 YYSYMBOL_T_sup = 38, /* T_sup */
233 YYSYMBOL_T_sub = 39, /* T_sub */
234 YYSYMBOL_T_s = 40, /* T_s */
235 YYSYMBOL_YYACCEPT = 41, /* $accept */
236 YYSYMBOL_html = 42, /* html */
237 YYSYMBOL_fonttext = 43, /* fonttext */
238 YYSYMBOL_text = 44, /* text */
239 YYSYMBOL_textitem = 45, /* textitem */
240 YYSYMBOL_font = 46, /* font */
241 YYSYMBOL_n_font = 47, /* n_font */
242 YYSYMBOL_italic = 48, /* italic */
243 YYSYMBOL_n_italic = 49, /* n_italic */
244 YYSYMBOL_bold = 50, /* bold */
245 YYSYMBOL_n_bold = 51, /* n_bold */
246 YYSYMBOL_strike = 52, /* strike */
247 YYSYMBOL_n_strike = 53, /* n_strike */
248 YYSYMBOL_underline = 54, /* underline */
249 YYSYMBOL_n_underline = 55, /* n_underline */
250 YYSYMBOL_overline = 56, /* overline */
251 YYSYMBOL_n_overline = 57, /* n_overline */
252 YYSYMBOL_sup = 58, /* sup */
253 YYSYMBOL_n_sup = 59, /* n_sup */
254 YYSYMBOL_sub = 60, /* sub */
255 YYSYMBOL_n_sub = 61, /* n_sub */
256 YYSYMBOL_br = 62, /* br */
257 YYSYMBOL_string = 63, /* string */
258 YYSYMBOL_table = 64, /* table */
259 YYSYMBOL_65_1 = 65, /* @1 */
260 YYSYMBOL_fonttable = 66, /* fonttable */
261 YYSYMBOL_opt_space = 67, /* opt_space */
262 YYSYMBOL_rows = 68, /* rows */
263 YYSYMBOL_row = 69, /* row */
264 YYSYMBOL_70_2 = 70, /* $@2 */
265 YYSYMBOL_cells = 71, /* cells */
266 YYSYMBOL_cell = 72, /* cell */
267 YYSYMBOL_73_3 = 73, /* $@3 */
268 YYSYMBOL_74_4 = 74, /* $@4 */
269 YYSYMBOL_75_5 = 75, /* $@5 */
270 YYSYMBOL_76_6 = 76, /* $@6 */
271 YYSYMBOL_image = 77, /* image */
272 YYSYMBOL_HR = 78, /* HR */
273 YYSYMBOL_VR = 79 /* VR */
276
277
278
279
280#ifdef short
281# undef short
282#endif
283
284/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
285 <limits.h> and (if available) <stdint.h> are included
286 so that the code can choose integer types of a good width. */
287
288#ifndef __PTRDIFF_MAX__
289# include <limits.h> /* INFRINGES ON USER NAME SPACE */
290# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
291# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
292# define YY_STDINT_H
293# endif
294#endif
295
296/* Narrow types that promote to a signed type and that can represent a
297 signed or unsigned integer of at least N bits. In tables they can
298 save space and decrease cache pressure. Promoting to a signed type
299 helps avoid bugs in integer arithmetic. */
300
301#ifdef __INT_LEAST8_MAX__
302typedef __INT_LEAST8_TYPE__ yytype_int8;
303#elif defined YY_STDINT_H
304typedef int_least8_t yytype_int8;
305#else
306typedef signed char yytype_int8;
307#endif
308
309#ifdef __INT_LEAST16_MAX__
310typedef __INT_LEAST16_TYPE__ yytype_int16;
311#elif defined YY_STDINT_H
312typedef int_least16_t yytype_int16;
313#else
314typedef short yytype_int16;
315#endif
316
317/* Work around bug in HP-UX 11.23, which defines these macros
318 incorrectly for preprocessor constants. This workaround can likely
319 be removed in 2023, as HPE has promised support for HP-UX 11.23
320 (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
321 <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
322#ifdef __hpux
323# undef UINT_LEAST8_MAX
324# undef UINT_LEAST16_MAX
325# define UINT_LEAST8_MAX 255
326# define UINT_LEAST16_MAX 65535
327#endif
328
329#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
330typedef __UINT_LEAST8_TYPE__ yytype_uint8;
331#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
332 && UINT_LEAST8_MAX <= INT_MAX)
333typedef uint_least8_t yytype_uint8;
334#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
335typedef unsigned char yytype_uint8;
336#else
337typedef short yytype_uint8;
338#endif
339
340#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
341typedef __UINT_LEAST16_TYPE__ yytype_uint16;
342#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
343 && UINT_LEAST16_MAX <= INT_MAX)
344typedef uint_least16_t yytype_uint16;
345#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
346typedef unsigned short yytype_uint16;
347#else
348typedef int yytype_uint16;
349#endif
350
351#ifndef YYPTRDIFF_T
352# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
353# define YYPTRDIFF_T __PTRDIFF_TYPE__
354# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
355# elif defined PTRDIFF_MAX
356# ifndef ptrdiff_t
357# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
358# endif
359# define YYPTRDIFF_T ptrdiff_t
360# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
361# else
362# define YYPTRDIFF_T long
363# define YYPTRDIFF_MAXIMUM LONG_MAX
364# endif
365#endif
366
367#ifndef YYSIZE_T
368# ifdef __SIZE_TYPE__
369# define YYSIZE_T __SIZE_TYPE__
370# elif defined size_t
371# define YYSIZE_T size_t
372# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
373# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
374# define YYSIZE_T size_t
375# else
376# define YYSIZE_T unsigned
377# endif
378#endif
379
380#define YYSIZE_MAXIMUM \
381 YY_CAST (YYPTRDIFF_T, \
382 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
383 ? YYPTRDIFF_MAXIMUM \
384 : YY_CAST (YYSIZE_T, -1)))
385
386#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
387
388
389/* Stored state numbers (used for stacks). */
391
392/* State numbers in computations. */
393typedef int yy_state_fast_t;
394
395#ifndef YY_
396# if defined YYENABLE_NLS && YYENABLE_NLS
397# if ENABLE_NLS
398# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
399# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
400# endif
401# endif
402# ifndef YY_
403# define YY_(Msgid) Msgid
404# endif
405#endif
406
407
408#ifndef YY_ATTRIBUTE_PURE
409# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
410# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
411# else
412# define YY_ATTRIBUTE_PURE
413# endif
414#endif
415
416#ifndef YY_ATTRIBUTE_UNUSED
417# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
418# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
419# else
420# define YY_ATTRIBUTE_UNUSED
421# endif
422#endif
423
424/* Suppress unused-variable warnings by "using" E. */
425#if ! defined lint || defined __GNUC__
426# define YY_USE(E) ((void) (E))
427#else
428# define YY_USE(E) /* empty */
429#endif
430
431/* Suppress an incorrect diagnostic about yylval being uninitialized. */
432#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
433# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
434# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
435 _Pragma ("GCC diagnostic push") \
436 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
437# else
438# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
439 _Pragma ("GCC diagnostic push") \
440 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
441 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
442# endif
443# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
444 _Pragma ("GCC diagnostic pop")
445#else
446# define YY_INITIAL_VALUE(Value) Value
447#endif
448#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
449# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
450# define YY_IGNORE_MAYBE_UNINITIALIZED_END
451#endif
452#ifndef YY_INITIAL_VALUE
453# define YY_INITIAL_VALUE(Value) /* Nothing. */
454#endif
455
456#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
457# define YY_IGNORE_USELESS_CAST_BEGIN \
458 _Pragma ("GCC diagnostic push") \
459 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
460# define YY_IGNORE_USELESS_CAST_END \
461 _Pragma ("GCC diagnostic pop")
462#endif
463#ifndef YY_IGNORE_USELESS_CAST_BEGIN
464# define YY_IGNORE_USELESS_CAST_BEGIN
465# define YY_IGNORE_USELESS_CAST_END
466#endif
467
468
469#define YY_ASSERT(E) ((void) (0 && (E)))
470
471#if !defined yyoverflow
472
473/* The parser invokes alloca or malloc; define the necessary symbols. */
474
475# ifdef YYSTACK_USE_ALLOCA
476# if YYSTACK_USE_ALLOCA
477# ifdef __GNUC__
478# define YYSTACK_ALLOC __builtin_alloca
479# elif defined __BUILTIN_VA_ARG_INCR
480# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
481# elif defined _AIX
482# define YYSTACK_ALLOC __alloca
483# elif defined _MSC_VER
484# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
485# define alloca _alloca
486# else
487# define YYSTACK_ALLOC alloca
488# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
489# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
490 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
491# ifndef EXIT_SUCCESS
492# define EXIT_SUCCESS 0
493# endif
494# endif
495# endif
496# endif
497# endif
498
499# ifdef YYSTACK_ALLOC
500 /* Pacify GCC's 'empty if-body' warning. */
501# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
502# ifndef YYSTACK_ALLOC_MAXIMUM
503 /* The OS might guarantee only one guard page at the bottom of the stack,
504 and a page size can be as small as 4096 bytes. So we cannot safely
505 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
506 to allow for a few compiler-allocated temporary stack slots. */
507# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
508# endif
509# else
510# define YYSTACK_ALLOC YYMALLOC
511# define YYSTACK_FREE YYFREE
512# ifndef YYSTACK_ALLOC_MAXIMUM
513# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
514# endif
515# if (defined __cplusplus && ! defined EXIT_SUCCESS \
516 && ! ((defined YYMALLOC || defined malloc) \
517 && (defined YYFREE || defined free)))
518# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
519# ifndef EXIT_SUCCESS
520# define EXIT_SUCCESS 0
521# endif
522# endif
523# ifndef YYMALLOC
524# define YYMALLOC malloc
525# if ! defined malloc && ! defined EXIT_SUCCESS
526void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
527# endif
528# endif
529# ifndef YYFREE
530# define YYFREE free
531# if ! defined free && ! defined EXIT_SUCCESS
532void free (void *); /* INFRINGES ON USER NAME SPACE */
533# endif
534# endif
535# endif
536#endif /* !defined yyoverflow */
537
538#if (! defined yyoverflow \
539 && (! defined __cplusplus \
540 || (defined HTMLSTYPE_IS_TRIVIAL && HTMLSTYPE_IS_TRIVIAL)))
541
542/* A type that is properly aligned for any stack member. */
543union yyalloc
544{
545 yy_state_t yyss_alloc;
546 YYSTYPE yyvs_alloc;
547};
548
549/* The size of the maximum gap between one aligned stack and the next. */
550# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
551
552/* The size of an array large to enough to hold all stacks, each with
553 N elements. */
554# define YYSTACK_BYTES(N) \
555 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
556 + YYSTACK_GAP_MAXIMUM)
557
558# define YYCOPY_NEEDED 1
559
560/* Relocate STACK from its old location to the new one. The
561 local variables YYSIZE and YYSTACKSIZE give the old and new number of
562 elements in the stack, and YYPTR gives the new location of the
563 stack. Advance YYPTR to a properly aligned location for the next
564 stack. */
565# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
566 do \
567 { \
568 YYPTRDIFF_T yynewbytes; \
569 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
570 Stack = &yyptr->Stack_alloc; \
571 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
572 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
573 } \
574 while (0)
575
576#endif
577
578#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
579/* Copy COUNT objects from SRC to DST. The source and destination do
580 not overlap. */
581# ifndef YYCOPY
582# if defined __GNUC__ && 1 < __GNUC__
583# define YYCOPY(Dst, Src, Count) \
584 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
585# else
586# define YYCOPY(Dst, Src, Count) \
587 do \
588 { \
589 YYPTRDIFF_T yyi; \
590 for (yyi = 0; yyi < (Count); yyi++) \
591 (Dst)[yyi] = (Src)[yyi]; \
592 } \
593 while (0)
594# endif
595# endif
596#endif /* !YYCOPY_NEEDED */
597
598/* YYFINAL -- State number of the termination state. */
599#define YYFINAL 31
600/* YYLAST -- Last index in YYTABLE. */
601#define YYLAST 271
602
603/* YYNTOKENS -- Number of terminals. */
604#define YYNTOKENS 41
605/* YYNNTS -- Number of nonterminals. */
606#define YYNNTS 39
607/* YYNRULES -- Number of rules. */
608#define YYNRULES 69
609/* YYNSTATES -- Number of states. */
610#define YYNSTATES 116
611
612/* YYMAXUTOK -- Last valid token kind. */
613#define YYMAXUTOK 295
614
615
616/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
617 as returned by yylex, with out-of-bounds checking. */
618#define YYTRANSLATE(YYX) \
619 (0 <= (YYX) && (YYX) <= YYMAXUTOK \
620 ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
621 : YYSYMBOL_YYUNDEF)
622
623/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
624 as returned by yylex. */
625static const yytype_int8 yytranslate[] =
626{
627 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
628 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
629 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
630 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
631 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
632 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
633 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
634 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
635 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
636 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
637 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
638 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
639 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
640 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
641 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
642 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
643 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
644 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
645 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
646 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
647 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
648 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
649 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
650 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
651 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
652 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
653 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
654 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
655 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
656 35, 36, 37, 38, 39, 40
657};
658
659#if HTMLDEBUG
660/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
661static const yytype_int16 yyrline[] =
662{
663 0, 212, 212, 213, 214, 217, 220, 221, 224, 225,
664 226, 227, 228, 229, 230, 231, 232, 233, 236, 239,
665 242, 245, 248, 251, 254, 257, 260, 263, 266, 269,
666 272, 275, 278, 281, 284, 285, 288, 289, 292, 292,
667 313, 314, 315, 316, 317, 318, 321, 322, 325, 326,
668 327, 330, 330, 333, 334, 335, 338, 338, 339, 339,
669 340, 340, 341, 341, 344, 345, 348, 349, 352, 353
670};
671#endif
672
674#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
675
676#if HTMLDEBUG || 0
677/* The user-facing name of the symbol whose (internal) number is
678 YYSYMBOL. No bounds checking. */
679static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
680
681/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
682 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
683static const char *const yytname[] =
684{
685 "\"end of file\"", "error", "\"invalid token\"", "T_end_br",
686 "T_end_img", "T_row", "T_end_row", "T_html", "T_end_html", "T_end_table",
687 "T_end_cell", "T_end_font", "T_string", "T_error", "T_n_italic",
688 "T_n_bold", "T_n_underline", "T_n_overline", "T_n_sup", "T_n_sub",
689 "T_n_s", "T_HR", "T_hr", "T_end_hr", "T_VR", "T_vr", "T_end_vr", "T_BR",
690 "T_br", "T_IMG", "T_img", "T_table", "T_cell", "T_font", "T_italic",
691 "T_bold", "T_underline", "T_overline", "T_sup", "T_sub", "T_s",
692 "$accept", "html", "fonttext", "text", "textitem", "font", "n_font",
693 "italic", "n_italic", "bold", "n_bold", "strike", "n_strike",
694 "underline", "n_underline", "overline", "n_overline", "sup", "n_sup",
695 "sub", "n_sub", "br", "string", "table", "@1", "fonttable", "opt_space",
696 "rows", "row", "$@2", "cells", "cell", "$@3", "$@4", "$@5", "$@6",
697 "image", "HR", "VR", YY_NULLPTR
698};
699
700static const char *
702{
703 return yytname[yysymbol];
704}
705#endif
706
707#define YYPACT_NINF (-82)
708
709#define yypact_value_is_default(Yyn) \
710 ((Yyn) == YYPACT_NINF)
711
712#define YYTABLE_NINF (-63)
713
714#define yytable_value_is_error(Yyn) \
715 0
716
717/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
718 STATE-NUM. */
719static const yytype_int16 yypact[] =
720{
721 8, -82, 209, 10, -82, -82, 11, -82, -82, -82,
722 -82, -82, -82, -82, -82, 5, 209, -82, 209, 209,
723 209, 209, 209, 209, 209, 209, -82, -5, -82, 14,
724 -20, -82, -82, -82, -82, 209, 209, 209, 209, 209,
725 13, 37, 12, 66, 16, 80, 19, 109, 123, 20,
726 152, 15, 166, 195, -82, -82, -82, -82, -82, -82,
727 -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
728 -82, -82, -82, -82, -82, -82, -82, -82, 23, -82,
729 119, -82, 7, 46, -82, 38, -82, 23, 17, 35,
730 -82, 13, -82, -82, -82, -82, 58, -82, -82, 53,
731 -82, -82, -82, 40, -82, 7, -82, 59, 69, -82,
732 72, -82, -82, -82, -82, -82
733};
734
735/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
736 Performed when YYTABLE does not specify something else to do. Zero
737 means the default is an error. */
738static const yytype_int8 yydefact[] =
739{
740 0, 4, 47, 0, 36, 35, 0, 18, 20, 22,
741 26, 28, 30, 32, 24, 0, 5, 7, 47, 47,
742 47, 0, 47, 47, 0, 0, 9, 8, 40, 0,
743 0, 1, 34, 2, 6, 0, 0, 0, 0, 0,
744 8, 0, 0, 0, 0, 0, 0, 0, 0, 0,
745 0, 0, 0, 0, 37, 3, 38, 19, 10, 41,
746 21, 11, 42, 23, 14, 45, 25, 17, 27, 12,
747 43, 29, 13, 44, 31, 15, 33, 16, 0, 51,
748 0, 48, 0, 47, 67, 0, 49, 0, 47, 0,
749 53, 46, 39, 66, 50, 65, 0, 58, 56, 0,
750 60, 52, 69, 0, 54, 0, 64, 0, 0, 63,
751 0, 68, 55, 59, 57, 61
752};
753
754/* YYPGOTO[NTERM-NUM]. */
755static const yytype_int16 yypgoto[] =
756{
757 -82, -82, -4, 232, -10, -1, 26, 0, 39, 1,
758 50, -82, -82, 2, 36, 3, 47, -82, -82, -82,
759 -82, -82, -2, 148, -82, 9, 27, -82, -68, -82,
760 -82, -81, -82, -82, -82, -82, -82, -82, -82
761};
762
763/* YYDEFGOTO[NTERM-NUM]. */
764static const yytype_int8 yydefgoto[] =
765{
766 0, 3, 15, 16, 17, 35, 58, 36, 61, 37,
767 64, 21, 67, 38, 69, 39, 72, 24, 75, 25,
768 77, 26, 40, 28, 78, 29, 30, 80, 81, 82,
769 89, 90, 108, 107, 110, 99, 100, 87, 105
770};
771
772/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
773 positive, shift that token. If negative, reduce the rule whose
774 number is the opposite. If YYTABLE_NINF, syntax error. */
775static const yytype_int8 yytable[] =
776{
777 27, 18, 19, 20, 22, 23, 34, 54, 104, 1,
778 31, 56, 86, 33, 32, 2, 27, 27, 27, 94,
779 27, 27, 55, 57, 112, 54, -46, -62, 79, 4,
780 60, 34, 71, 34, 63, 34, 68, 34, 34, 88,
781 34, 101, 34, 34, 5, 6, 95, 96, 57, 4,
782 7, 8, 9, 10, 11, 12, 13, 14, 4, 102,
783 103, 93, 106, 109, 5, 6, 111, 88, 59, 113,
784 7, 8, 9, 10, 11, 12, 13, 14, 4, 114,
785 60, 91, 115, 62, 97, 70, 27, 18, 19, 20,
786 22, 23, 4, 5, 6, 63, 65, 98, 73, 7,
787 8, 9, 10, 11, 12, 13, 14, 5, 6, 0,
788 92, 0, 0, 7, 8, 9, 10, 11, 12, 13,
789 14, 4, 0, 0, 79, 0, 0, 0, 83, 66,
790 0, 0, 0, 0, 0, 4, 5, 6, 0, 68,
791 84, 85, 7, 8, 9, 10, 11, 12, 13, 14,
792 5, 6, 0, 0, 0, 0, 7, 8, 9, 10,
793 11, 12, 13, 14, 4, 0, 42, 44, 46, 71,
794 49, 51, 0, 0, 0, 0, 0, 0, 4, 5,
795 6, 0, 0, 0, 74, 7, 8, 9, 10, 11,
796 12, 13, 14, 5, 6, 0, 0, 0, 0, 7,
797 8, 9, 10, 11, 12, 13, 14, 4, 0, 0,
798 0, 0, 0, 0, 76, 0, 0, 0, 0, 0,
799 0, 4, 5, 6, 0, 0, 0, 0, 7, 8,
800 9, 10, 11, 12, 13, 14, 5, 6, 0, 0,
801 0, 0, 7, 8, 9, 10, 11, 12, 13, 14,
802 41, 43, 45, 47, 48, 50, 52, 53, 0, 0,
803 0, 0, 0, 0, 0, 0, 0, 41, 43, 45,
804 48, 50
805};
806
807static const yytype_int8 yycheck[] =
808{
809 2, 2, 2, 2, 2, 2, 16, 12, 89, 1,
810 0, 31, 80, 8, 3, 7, 18, 19, 20, 87,
811 22, 23, 8, 11, 105, 12, 31, 10, 5, 12,
812 14, 41, 17, 43, 15, 45, 16, 47, 48, 32,
813 50, 6, 52, 53, 27, 28, 29, 30, 11, 12,
814 33, 34, 35, 36, 37, 38, 39, 40, 12, 24,
815 25, 23, 4, 10, 27, 28, 26, 32, 42, 10,
816 33, 34, 35, 36, 37, 38, 39, 40, 12, 10,
817 14, 83, 10, 44, 88, 49, 88, 88, 88, 88,
818 88, 88, 12, 27, 28, 15, 46, 88, 51, 33,
819 34, 35, 36, 37, 38, 39, 40, 27, 28, -1,
820 83, -1, -1, 33, 34, 35, 36, 37, 38, 39,
821 40, 12, -1, -1, 5, -1, -1, -1, 9, 20,
822 -1, -1, -1, -1, -1, 12, 27, 28, -1, 16,
823 21, 22, 33, 34, 35, 36, 37, 38, 39, 40,
824 27, 28, -1, -1, -1, -1, 33, 34, 35, 36,
825 37, 38, 39, 40, 12, -1, 18, 19, 20, 17,
826 22, 23, -1, -1, -1, -1, -1, -1, 12, 27,
827 28, -1, -1, -1, 18, 33, 34, 35, 36, 37,
828 38, 39, 40, 27, 28, -1, -1, -1, -1, 33,
829 34, 35, 36, 37, 38, 39, 40, 12, -1, -1,
830 -1, -1, -1, -1, 19, -1, -1, -1, -1, -1,
831 -1, 12, 27, 28, -1, -1, -1, -1, 33, 34,
832 35, 36, 37, 38, 39, 40, 27, 28, -1, -1,
833 -1, -1, 33, 34, 35, 36, 37, 38, 39, 40,
834 18, 19, 20, 21, 22, 23, 24, 25, -1, -1,
835 -1, -1, -1, -1, -1, -1, -1, 35, 36, 37,
836 38, 39
837};
838
839/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
840 state STATE-NUM. */
841static const yytype_int8 yystos[] =
842{
843 0, 1, 7, 42, 12, 27, 28, 33, 34, 35,
844 36, 37, 38, 39, 40, 43, 44, 45, 46, 48,
845 50, 52, 54, 56, 58, 60, 62, 63, 64, 66,
846 67, 0, 3, 8, 45, 46, 48, 50, 54, 56,
847 63, 44, 64, 44, 64, 44, 64, 44, 44, 64,
848 44, 64, 44, 44, 12, 8, 31, 11, 47, 47,
849 14, 49, 49, 15, 51, 51, 20, 53, 16, 55,
850 55, 17, 57, 57, 18, 59, 19, 61, 65, 5,
851 68, 69, 70, 9, 21, 22, 69, 78, 32, 71,
852 72, 63, 67, 23, 69, 29, 30, 43, 66, 76,
853 77, 6, 24, 25, 72, 79, 4, 74, 73, 10,
854 75, 26, 72, 10, 10, 10
855};
856
857/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
858static const yytype_int8 yyr1[] =
859{
860 0, 41, 42, 42, 42, 43, 44, 44, 45, 45,
861 45, 45, 45, 45, 45, 45, 45, 45, 46, 47,
862 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
863 58, 59, 60, 61, 62, 62, 63, 63, 65, 64,
864 66, 66, 66, 66, 66, 66, 67, 67, 68, 68,
865 68, 70, 69, 71, 71, 71, 73, 72, 74, 72,
866 75, 72, 76, 72, 77, 77, 78, 78, 79, 79
867};
868
869/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
870static const yytype_int8 yyr2[] =
871{
872 0, 2, 3, 3, 1, 1, 2, 1, 1, 1,
873 3, 3, 3, 3, 3, 3, 3, 3, 1, 1,
874 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
875 1, 1, 1, 1, 2, 1, 1, 2, 0, 6,
876 1, 3, 3, 3, 3, 3, 1, 0, 1, 2,
877 3, 0, 4, 1, 2, 3, 0, 4, 0, 4,
878 0, 4, 0, 3, 2, 1, 2, 1, 2, 1
879};
880
881
882enum { YYENOMEM = -2 };
883
884#define yyerrok (yyerrstatus = 0)
885#define yyclearin (yychar = HTMLEMPTY)
886
887#define YYACCEPT goto yyacceptlab
888#define YYABORT goto yyabortlab
889#define YYERROR goto yyerrorlab
890#define YYNOMEM goto yyexhaustedlab
891
892
893#define YYRECOVERING() (!!yyerrstatus)
894
895#define YYBACKUP(Token, Value) \
896 do \
897 if (yychar == HTMLEMPTY) \
898 { \
899 yychar = (Token); \
900 yylval = (Value); \
901 YYPOPSTACK (yylen); \
902 yystate = *yyssp; \
903 goto yybackup; \
904 } \
905 else \
906 { \
907 yyerror (scanner, YY_("syntax error: cannot back up")); \
908 YYERROR; \
909 } \
910 while (0)
911
912/* Backward compatibility with an undocumented macro.
913 Use HTMLerror or HTMLUNDEF. */
914#define YYERRCODE HTMLUNDEF
915
916
917/* Enable debugging if requested. */
918#if HTMLDEBUG
919
920# ifndef YYFPRINTF
921# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
922# define YYFPRINTF fprintf
923# endif
924
925# define YYDPRINTF(Args) \
926do { \
927 if (yydebug) \
928 YYFPRINTF Args; \
929} while (0)
930
931
932
933
934# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
935do { \
936 if (yydebug) \
937 { \
938 YYFPRINTF (stderr, "%s ", Title); \
939 yy_symbol_print (stderr, \
940 Kind, Value, scanner); \
941 YYFPRINTF (stderr, "\n"); \
942 } \
943} while (0)
944
945
946/*-----------------------------------.
947| Print this symbol's value on YYO. |
948`-----------------------------------*/
949
950static void
951yy_symbol_value_print (FILE *yyo,
952 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, htmlscan_t *scanner)
953{
954 FILE *yyoutput = yyo;
955 YY_USE (yyoutput);
956 YY_USE (scanner);
957 if (!yyvaluep)
958 return;
960 YY_USE (yykind);
962}
963
964
965/*---------------------------.
966| Print this symbol on YYO. |
967`---------------------------*/
968
969static void
970yy_symbol_print (FILE *yyo,
971 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, htmlscan_t *scanner)
972{
973 YYFPRINTF (yyo, "%s %s (",
974 yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
975
976 yy_symbol_value_print (yyo, yykind, yyvaluep, scanner);
977 YYFPRINTF (yyo, ")");
978}
979
980/*------------------------------------------------------------------.
981| yy_stack_print -- Print the state stack from its BOTTOM up to its |
982| TOP (included). |
983`------------------------------------------------------------------*/
984
985static void
986yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
987{
988 YYFPRINTF (stderr, "Stack now");
989 for (; yybottom <= yytop; yybottom++)
990 {
991 int yybot = *yybottom;
992 YYFPRINTF (stderr, " %d", yybot);
993 }
994 YYFPRINTF (stderr, "\n");
995}
996
997# define YY_STACK_PRINT(Bottom, Top) \
998do { \
999 if (yydebug) \
1000 yy_stack_print ((Bottom), (Top)); \
1001} while (0)
1002
1003
1004/*------------------------------------------------.
1005| Report that the YYRULE is going to be reduced. |
1006`------------------------------------------------*/
1007
1008static void
1009yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
1010 int yyrule, htmlscan_t *scanner)
1011{
1012 int yylno = yyrline[yyrule];
1013 int yynrhs = yyr2[yyrule];
1014 int yyi;
1015 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
1016 yyrule - 1, yylno);
1017 /* The symbols being reduced. */
1018 for (yyi = 0; yyi < yynrhs; yyi++)
1019 {
1020 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1021 yy_symbol_print (stderr,
1022 YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
1023 &yyvsp[(yyi + 1) - (yynrhs)], scanner);
1024 YYFPRINTF (stderr, "\n");
1025 }
1026}
1027
1028# define YY_REDUCE_PRINT(Rule) \
1029do { \
1030 if (yydebug) \
1031 yy_reduce_print (yyssp, yyvsp, Rule, scanner); \
1032} while (0)
1033
1034/* Nonzero means print parse trace. It is left uninitialized so that
1035 multiple parsers can coexist. */
1036int yydebug;
1037#else /* !HTMLDEBUG */
1038# define YYDPRINTF(Args) ((void) 0)
1039# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
1040# define YY_STACK_PRINT(Bottom, Top)
1041# define YY_REDUCE_PRINT(Rule)
1042#endif /* !HTMLDEBUG */
1043
1044
1045/* YYINITDEPTH -- initial size of the parser's stacks. */
1046#ifndef YYINITDEPTH
1047# define YYINITDEPTH 200
1048#endif
1049
1050/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1051 if the built-in stack extension method is used).
1052
1053 Do not make this value too large; the results are undefined if
1054 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1055 evaluated with infinite-precision integer arithmetic. */
1056
1057#ifndef YYMAXDEPTH
1058# define YYMAXDEPTH 10000
1059#endif
1060
1061
1062
1063
1064
1065
1066/*-----------------------------------------------.
1067| Release the memory associated to this symbol. |
1068`-----------------------------------------------*/
1069
1070static void
1071yydestruct (const char *yymsg,
1072 yysymbol_kind_t yykind, YYSTYPE *yyvaluep, htmlscan_t *scanner)
1073{
1074 YY_USE (yyvaluep);
1075 YY_USE (scanner);
1076 if (!yymsg)
1077 yymsg = "Deleting";
1078 YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1079
1081 YY_USE (yykind);
1083}
1084
1085
1086
1087
1088
1089
1090/*----------.
1091| yyparse. |
1092`----------*/
1093
1094int
1096{
1097/* Lookahead token kind. */
1098int yychar;
1099
1100
1101/* The semantic value of the lookahead symbol. */
1102/* Default value used for initialization, for pacifying older GCCs
1103 or non-GCC compilers. */
1104YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1105YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1106
1107 /* Number of syntax errors so far. */
1108 int yynerrs = 0;
1109
1110 yy_state_fast_t yystate = 0;
1111 /* Number of tokens to shift before error messages enabled. */
1112 int yyerrstatus = 0;
1113
1114 /* Refer to the stacks through separate pointers, to allow yyoverflow
1115 to reallocate them elsewhere. */
1116
1117 /* Their size. */
1118 YYPTRDIFF_T yystacksize = YYINITDEPTH;
1119
1120 /* The state stack: array, bottom, top. */
1121 yy_state_t yyssa[YYINITDEPTH];
1122 yy_state_t *yyss = yyssa;
1123 yy_state_t *yyssp = yyss;
1124
1125 /* The semantic value stack: array, bottom, top. */
1126 YYSTYPE yyvsa[YYINITDEPTH];
1127 YYSTYPE *yyvs = yyvsa;
1128 YYSTYPE *yyvsp = yyvs;
1129
1130 int yyn;
1131 /* The return value of yyparse. */
1132 int yyresult;
1133 /* Lookahead symbol kind. */
1135 /* The variables used to return semantic value and location from the
1136 action routines. */
1137 YYSTYPE yyval;
1138
1139
1140
1141#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1142
1143 /* The number of symbols on the RHS of the reduced rule.
1144 Keep to zero when no symbol should be popped. */
1145 int yylen = 0;
1146
1147 YYDPRINTF ((stderr, "Starting parse\n"));
1148
1149 yychar = HTMLEMPTY; /* Cause a token to be read. */
1150
1151 goto yysetstate;
1152
1153
1154/*------------------------------------------------------------.
1155| yynewstate -- push a new state, which is found in yystate. |
1156`------------------------------------------------------------*/
1157yynewstate:
1158 /* In all cases, when you get here, the value and location stacks
1159 have just been pushed. So pushing a state here evens the stacks. */
1160 yyssp++;
1161
1162
1163/*--------------------------------------------------------------------.
1164| yysetstate -- set current state (the top of the stack) to yystate. |
1165`--------------------------------------------------------------------*/
1166yysetstate:
1167 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1168 YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1170 *yyssp = YY_CAST (yy_state_t, yystate);
1172 YY_STACK_PRINT (yyss, yyssp);
1173
1174 if (yyss + yystacksize - 1 <= yyssp)
1175#if !defined yyoverflow && !defined YYSTACK_RELOCATE
1176 YYNOMEM;
1177#else
1178 {
1179 /* Get the current used size of the three stacks, in elements. */
1180 YYPTRDIFF_T yysize = yyssp - yyss + 1;
1181
1182# if defined yyoverflow
1183 {
1184 /* Give user a chance to reallocate the stack. Use copies of
1185 these so that the &'s don't force the real ones into
1186 memory. */
1187 yy_state_t *yyss1 = yyss;
1188 YYSTYPE *yyvs1 = yyvs;
1189
1190 /* Each stack pointer address is followed by the size of the
1191 data in use in that stack, in bytes. This used to be a
1192 conditional around just the two extra args, but that might
1193 be undefined if yyoverflow is a macro. */
1194 yyoverflow (YY_("memory exhausted"),
1195 &yyss1, yysize * YYSIZEOF (*yyssp),
1196 &yyvs1, yysize * YYSIZEOF (*yyvsp),
1197 &yystacksize);
1198 yyss = yyss1;
1199 yyvs = yyvs1;
1200 }
1201# else /* defined YYSTACK_RELOCATE */
1202 /* Extend the stack our own way. */
1203 if (YYMAXDEPTH <= yystacksize)
1204 YYNOMEM;
1205 yystacksize *= 2;
1206 if (YYMAXDEPTH < yystacksize)
1207 yystacksize = YYMAXDEPTH;
1208
1209 {
1210 yy_state_t *yyss1 = yyss;
1211 union yyalloc *yyptr =
1212 YY_CAST (union yyalloc *,
1213 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1214 if (! yyptr)
1215 YYNOMEM;
1216 YYSTACK_RELOCATE (yyss_alloc, yyss);
1217 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1218# undef YYSTACK_RELOCATE
1219 if (yyss1 != yyssa)
1220 YYSTACK_FREE (yyss1);
1221 }
1222# endif
1223
1224 yyssp = yyss + yysize - 1;
1225 yyvsp = yyvs + yysize - 1;
1226
1228 YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1229 YY_CAST (long, yystacksize)));
1231
1232 if (yyss + yystacksize - 1 <= yyssp)
1233 YYABORT;
1234 }
1235#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1236
1237
1238 if (yystate == YYFINAL)
1239 YYACCEPT;
1240
1241 goto yybackup;
1242
1243
1244/*-----------.
1245| yybackup. |
1246`-----------*/
1247yybackup:
1248 /* Do appropriate processing given the current state. Read a
1249 lookahead token if we need one and don't already have one. */
1250
1251 /* First try to decide what to do without reference to lookahead token. */
1252 yyn = yypact[yystate];
1253 if (yypact_value_is_default (yyn))
1254 goto yydefault;
1255
1256 /* Not known => get a lookahead token if don't already have one. */
1257
1258 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1259 if (yychar == HTMLEMPTY)
1260 {
1261 YYDPRINTF ((stderr, "Reading a token\n"));
1262 yychar = yylex (&yylval, scanner);
1263 }
1264
1265 if (yychar <= HTMLEOF)
1266 {
1267 yychar = HTMLEOF;
1268 yytoken = YYSYMBOL_YYEOF;
1269 YYDPRINTF ((stderr, "Now at end of input.\n"));
1270 }
1271 else if (yychar == HTMLerror)
1272 {
1273 /* The scanner already issued an error message, process directly
1274 to error recovery. But do not keep the error token as
1275 lookahead, it is too special and may lead us to an endless
1276 loop in error recovery. */
1277 yychar = HTMLUNDEF;
1278 yytoken = YYSYMBOL_YYerror;
1279 goto yyerrlab1;
1280 }
1281 else
1282 {
1283 yytoken = YYTRANSLATE (yychar);
1284 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1285 }
1286
1287 /* If the proper action on seeing token YYTOKEN is to reduce or to
1288 detect an error, take that action. */
1289 yyn += yytoken;
1290 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1291 goto yydefault;
1292 yyn = yytable[yyn];
1293 if (yyn <= 0)
1294 {
1295 if (yytable_value_is_error (yyn))
1296 goto yyerrlab;
1297 yyn = -yyn;
1298 goto yyreduce;
1299 }
1300
1301 /* Count tokens shifted since error; after three, turn off error
1302 status. */
1303 if (yyerrstatus)
1304 yyerrstatus--;
1305
1306 /* Shift the lookahead token. */
1307 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1308 yystate = yyn;
1310 *++yyvsp = yylval;
1312
1313 /* Discard the shifted token. */
1314 yychar = HTMLEMPTY;
1315 goto yynewstate;
1316
1317
1318/*-----------------------------------------------------------.
1319| yydefault -- do the default action for the current state. |
1320`-----------------------------------------------------------*/
1321yydefault:
1322 yyn = yydefact[yystate];
1323 if (yyn == 0)
1324 goto yyerrlab;
1325 goto yyreduce;
1326
1327
1328/*-----------------------------.
1329| yyreduce -- do a reduction. |
1330`-----------------------------*/
1331yyreduce:
1332 /* yyn is the number of a rule to reduce with. */
1333 yylen = yyr2[yyn];
1334
1335 /* If YYLEN is nonzero, implement the default value of the action:
1336 '$$ = $1'.
1337
1338 Otherwise, the following line sets YYVAL to garbage.
1339 This behavior is undocumented and Bison
1340 users should not rely upon it. Assigning to YYVAL
1341 unconditionally makes the parser a bit smaller, and it avoids a
1342 GCC warning that YYVAL may be used uninitialized. */
1343 yyval = yyvsp[1-yylen];
1344
1345
1346 YY_REDUCE_PRINT (yyn);
1347 switch (yyn)
1348 {
1349 case 2: /* html: T_html fonttext T_end_html */
1350#line 212 "../../lib/common/htmlparse.y"
1351 { scanner->parser.lbl = mkLabel((yyvsp[-1].txt),HTML_TEXT); }
1352#line 1353 "htmlparse.c"
1353 break;
1354
1355 case 3: /* html: T_html fonttable T_end_html */
1356#line 213 "../../lib/common/htmlparse.y"
1357 { scanner->parser.lbl = mkLabel((yyvsp[-1].tbl),HTML_TBL); }
1358#line 1359 "htmlparse.c"
1359 break;
1360
1361 case 4: /* html: error */
1362#line 214 "../../lib/common/htmlparse.y"
1363 { cleanup(&scanner->parser); YYABORT; }
1364#line 1365 "htmlparse.c"
1365 break;
1366
1367 case 5: /* fonttext: text */
1368#line 217 "../../lib/common/htmlparse.y"
1369 { (yyval.txt) = mkText(&scanner->parser); }
1370#line 1371 "htmlparse.c"
1371 break;
1372
1373 case 8: /* textitem: string */
1374#line 224 "../../lib/common/htmlparse.y"
1375 { appendFItemList(&scanner->parser,scanner->parser.str);}
1376#line 1377 "htmlparse.c"
1377 break;
1378
1379 case 9: /* textitem: br */
1380#line 225 "../../lib/common/htmlparse.y"
1381 {appendFLineList(&scanner->parser,(yyvsp[0].i));}
1382#line 1383 "htmlparse.c"
1383 break;
1384
1385 case 18: /* font: T_font */
1386#line 236 "../../lib/common/htmlparse.y"
1387 { pushFont (&scanner->parser,(yyvsp[0].font)); }
1388#line 1389 "htmlparse.c"
1389 break;
1390
1391 case 19: /* n_font: T_end_font */
1392#line 239 "../../lib/common/htmlparse.y"
1393 { popFont (&scanner->parser); }
1394#line 1395 "htmlparse.c"
1395 break;
1396
1397 case 20: /* italic: T_italic */
1398#line 242 "../../lib/common/htmlparse.y"
1399 {pushFont(&scanner->parser,(yyvsp[0].font));}
1400#line 1401 "htmlparse.c"
1401 break;
1402
1403 case 21: /* n_italic: T_n_italic */
1404#line 245 "../../lib/common/htmlparse.y"
1405 {popFont(&scanner->parser);}
1406#line 1407 "htmlparse.c"
1407 break;
1408
1409 case 22: /* bold: T_bold */
1410#line 248 "../../lib/common/htmlparse.y"
1411 {pushFont(&scanner->parser,(yyvsp[0].font));}
1412#line 1413 "htmlparse.c"
1413 break;
1414
1415 case 23: /* n_bold: T_n_bold */
1416#line 251 "../../lib/common/htmlparse.y"
1417 {popFont(&scanner->parser);}
1418#line 1419 "htmlparse.c"
1419 break;
1420
1421 case 24: /* strike: T_s */
1422#line 254 "../../lib/common/htmlparse.y"
1423 {pushFont(&scanner->parser,(yyvsp[0].font));}
1424#line 1425 "htmlparse.c"
1425 break;
1426
1427 case 25: /* n_strike: T_n_s */
1428#line 257 "../../lib/common/htmlparse.y"
1429 {popFont(&scanner->parser);}
1430#line 1431 "htmlparse.c"
1431 break;
1432
1433 case 26: /* underline: T_underline */
1434#line 260 "../../lib/common/htmlparse.y"
1435 {pushFont(&scanner->parser,(yyvsp[0].font));}
1436#line 1437 "htmlparse.c"
1437 break;
1438
1439 case 27: /* n_underline: T_n_underline */
1440#line 263 "../../lib/common/htmlparse.y"
1441 {popFont(&scanner->parser);}
1442#line 1443 "htmlparse.c"
1443 break;
1444
1445 case 28: /* overline: T_overline */
1446#line 266 "../../lib/common/htmlparse.y"
1447 {pushFont(&scanner->parser,(yyvsp[0].font));}
1448#line 1449 "htmlparse.c"
1449 break;
1450
1451 case 29: /* n_overline: T_n_overline */
1452#line 269 "../../lib/common/htmlparse.y"
1453 {popFont(&scanner->parser);}
1454#line 1455 "htmlparse.c"
1455 break;
1456
1457 case 30: /* sup: T_sup */
1458#line 272 "../../lib/common/htmlparse.y"
1459 {pushFont(&scanner->parser,(yyvsp[0].font));}
1460#line 1461 "htmlparse.c"
1461 break;
1462
1463 case 31: /* n_sup: T_n_sup */
1464#line 275 "../../lib/common/htmlparse.y"
1465 {popFont(&scanner->parser);}
1466#line 1467 "htmlparse.c"
1467 break;
1468
1469 case 32: /* sub: T_sub */
1470#line 278 "../../lib/common/htmlparse.y"
1471 {pushFont(&scanner->parser,(yyvsp[0].font));}
1472#line 1473 "htmlparse.c"
1473 break;
1474
1475 case 33: /* n_sub: T_n_sub */
1476#line 281 "../../lib/common/htmlparse.y"
1477 {popFont(&scanner->parser);}
1478#line 1479 "htmlparse.c"
1479 break;
1480
1481 case 34: /* br: T_br T_end_br */
1482#line 284 "../../lib/common/htmlparse.y"
1483 { (yyval.i) = (yyvsp[-1].i); }
1484#line 1485 "htmlparse.c"
1485 break;
1486
1487 case 35: /* br: T_BR */
1488#line 285 "../../lib/common/htmlparse.y"
1489 { (yyval.i) = (yyvsp[0].i); }
1490#line 1491 "htmlparse.c"
1491 break;
1492
1493 case 38: /* @1: %empty */
1494#line 292 "../../lib/common/htmlparse.y"
1495 {
1496 if (nonSpace(agxbuse(scanner->parser.str))) {
1497 htmlerror (scanner,"Syntax error: non-space string used before <TABLE>");
1498 cleanup(&scanner->parser); YYABORT;
1499 }
1500 (yyvsp[0].tbl)->u.p.prev = scanner->parser.tblstack;
1501 (yyvsp[0].tbl)->u.p.rows = (rows_t){0};
1502 scanner->parser.tblstack = (yyvsp[0].tbl);
1503 (yyvsp[0].tbl)->font = *sfont_back(&scanner->parser.fontstack);
1504 (yyval.tbl) = (yyvsp[0].tbl);
1505 }
1506#line 1507 "htmlparse.c"
1507 break;
1508
1509 case 39: /* table: opt_space T_table @1 rows T_end_table opt_space */
1510#line 303 "../../lib/common/htmlparse.y"
1511 {
1512 if (nonSpace(agxbuse(scanner->parser.str))) {
1513 htmlerror (scanner,"Syntax error: non-space string used after </TABLE>");
1514 cleanup(&scanner->parser); YYABORT;
1515 }
1516 (yyval.tbl) = scanner->parser.tblstack;
1517 scanner->parser.tblstack = scanner->parser.tblstack->u.p.prev;
1518 }
1519#line 1520 "htmlparse.c"
1520 break;
1521
1522 case 40: /* fonttable: table */
1523#line 313 "../../lib/common/htmlparse.y"
1524 { (yyval.tbl) = (yyvsp[0].tbl); }
1525#line 1526 "htmlparse.c"
1526 break;
1527
1528 case 41: /* fonttable: font table n_font */
1529#line 314 "../../lib/common/htmlparse.y"
1530 { (yyval.tbl)=(yyvsp[-1].tbl); }
1531#line 1532 "htmlparse.c"
1532 break;
1533
1534 case 42: /* fonttable: italic table n_italic */
1535#line 315 "../../lib/common/htmlparse.y"
1536 { (yyval.tbl)=(yyvsp[-1].tbl); }
1537#line 1538 "htmlparse.c"
1538 break;
1539
1540 case 43: /* fonttable: underline table n_underline */
1541#line 316 "../../lib/common/htmlparse.y"
1542 { (yyval.tbl)=(yyvsp[-1].tbl); }
1543#line 1544 "htmlparse.c"
1544 break;
1545
1546 case 44: /* fonttable: overline table n_overline */
1547#line 317 "../../lib/common/htmlparse.y"
1548 { (yyval.tbl)=(yyvsp[-1].tbl); }
1549#line 1550 "htmlparse.c"
1550 break;
1551
1552 case 45: /* fonttable: bold table n_bold */
1553#line 318 "../../lib/common/htmlparse.y"
1554 { (yyval.tbl)=(yyvsp[-1].tbl); }
1555#line 1556 "htmlparse.c"
1556 break;
1557
1558 case 48: /* rows: row */
1559#line 325 "../../lib/common/htmlparse.y"
1560 { (yyval.p) = (yyvsp[0].p); }
1561#line 1562 "htmlparse.c"
1562 break;
1563
1564 case 49: /* rows: rows row */
1565#line 326 "../../lib/common/htmlparse.y"
1566 { (yyval.p) = (yyvsp[0].p); }
1567#line 1568 "htmlparse.c"
1568 break;
1569
1570 case 50: /* rows: rows HR row */
1571#line 327 "../../lib/common/htmlparse.y"
1572 { (yyvsp[-2].p)->ruled = true; (yyval.p) = (yyvsp[0].p); }
1573#line 1574 "htmlparse.c"
1574 break;
1575
1576 case 51: /* $@2: %empty */
1577#line 330 "../../lib/common/htmlparse.y"
1578 { addRow (&scanner->parser); }
1579#line 1580 "htmlparse.c"
1580 break;
1581
1582 case 52: /* row: T_row $@2 cells T_end_row */
1583#line 330 "../../lib/common/htmlparse.y"
1584 { (yyval.p) = lastRow(&scanner->parser); }
1585#line 1586 "htmlparse.c"
1586 break;
1587
1588 case 53: /* cells: cell */
1589#line 333 "../../lib/common/htmlparse.y"
1590 { (yyval.cell) = (yyvsp[0].cell); }
1591#line 1592 "htmlparse.c"
1592 break;
1593
1594 case 54: /* cells: cells cell */
1595#line 334 "../../lib/common/htmlparse.y"
1596 { (yyval.cell) = (yyvsp[0].cell); }
1597#line 1598 "htmlparse.c"
1598 break;
1599
1600 case 55: /* cells: cells VR cell */
1601#line 335 "../../lib/common/htmlparse.y"
1602 { (yyvsp[-2].cell)->vruled = true; (yyval.cell) = (yyvsp[0].cell); }
1603#line 1604 "htmlparse.c"
1604 break;
1605
1606 case 56: /* $@3: %empty */
1607#line 338 "../../lib/common/htmlparse.y"
1608 { setCell(&scanner->parser,(yyvsp[-1].cell),(yyvsp[0].tbl),HTML_TBL); }
1609#line 1610 "htmlparse.c"
1610 break;
1611
1612 case 57: /* cell: T_cell fonttable $@3 T_end_cell */
1613#line 338 "../../lib/common/htmlparse.y"
1614 { (yyval.cell) = (yyvsp[-3].cell); }
1615#line 1616 "htmlparse.c"
1616 break;
1617
1618 case 58: /* $@4: %empty */
1619#line 339 "../../lib/common/htmlparse.y"
1620 { setCell(&scanner->parser,(yyvsp[-1].cell),(yyvsp[0].txt),HTML_TEXT); }
1621#line 1622 "htmlparse.c"
1622 break;
1623
1624 case 59: /* cell: T_cell fonttext $@4 T_end_cell */
1625#line 339 "../../lib/common/htmlparse.y"
1626 { (yyval.cell) = (yyvsp[-3].cell); }
1627#line 1628 "htmlparse.c"
1628 break;
1629
1630 case 60: /* $@5: %empty */
1631#line 340 "../../lib/common/htmlparse.y"
1632 { setCell(&scanner->parser,(yyvsp[-1].cell),(yyvsp[0].img),HTML_IMAGE); }
1633#line 1634 "htmlparse.c"
1634 break;
1635
1636 case 61: /* cell: T_cell image $@5 T_end_cell */
1637#line 340 "../../lib/common/htmlparse.y"
1638 { (yyval.cell) = (yyvsp[-3].cell); }
1639#line 1640 "htmlparse.c"
1640 break;
1641
1642 case 62: /* $@6: %empty */
1643#line 341 "../../lib/common/htmlparse.y"
1644 { setCell(&scanner->parser,(yyvsp[0].cell),mkText(&scanner->parser),HTML_TEXT); }
1645#line 1646 "htmlparse.c"
1646 break;
1647
1648 case 63: /* cell: T_cell $@6 T_end_cell */
1649#line 341 "../../lib/common/htmlparse.y"
1650 { (yyval.cell) = (yyvsp[-2].cell); }
1651#line 1652 "htmlparse.c"
1652 break;
1653
1654 case 64: /* image: T_img T_end_img */
1655#line 344 "../../lib/common/htmlparse.y"
1656 { (yyval.img) = (yyvsp[-1].img); }
1657#line 1658 "htmlparse.c"
1658 break;
1659
1660 case 65: /* image: T_IMG */
1661#line 345 "../../lib/common/htmlparse.y"
1662 { (yyval.img) = (yyvsp[0].img); }
1663#line 1664 "htmlparse.c"
1664 break;
1665
1666
1667#line 1668 "htmlparse.c"
1668
1669 default: break;
1670 }
1671 /* User semantic actions sometimes alter yychar, and that requires
1672 that yytoken be updated with the new translation. We take the
1673 approach of translating immediately before every use of yytoken.
1674 One alternative is translating here after every semantic action,
1675 but that translation would be missed if the semantic action invokes
1676 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1677 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1678 incorrect destructor might then be invoked immediately. In the
1679 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1680 to an incorrect destructor call or verbose syntax error message
1681 before the lookahead is translated. */
1682 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1683
1684 YYPOPSTACK (yylen);
1685 yylen = 0;
1686
1687 *++yyvsp = yyval;
1688
1689 /* Now 'shift' the result of the reduction. Determine what state
1690 that goes to, based on the state we popped back to and the rule
1691 number reduced by. */
1692 {
1693 const int yylhs = yyr1[yyn] - YYNTOKENS;
1694 const int yyi = yypgoto[yylhs] + *yyssp;
1695 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1696 ? yytable[yyi]
1697 : yydefgoto[yylhs]);
1698 }
1699
1700 goto yynewstate;
1701
1702
1703/*--------------------------------------.
1704| yyerrlab -- here on detecting error. |
1705`--------------------------------------*/
1706yyerrlab:
1707 /* Make sure we have latest lookahead translation. See comments at
1708 user semantic actions for why this is necessary. */
1710 /* If not already recovering from an error, report this error. */
1711 if (!yyerrstatus)
1712 {
1713 ++yynerrs;
1714 yyerror (scanner, YY_("syntax error"));
1715 }
1716
1717 if (yyerrstatus == 3)
1718 {
1719 /* If just tried and failed to reuse lookahead token after an
1720 error, discard it. */
1721
1722 if (yychar <= HTMLEOF)
1723 {
1724 /* Return failure if at end of input. */
1725 if (yychar == HTMLEOF)
1726 YYABORT;
1727 }
1728 else
1729 {
1730 yydestruct ("Error: discarding",
1731 yytoken, &yylval, scanner);
1732 yychar = HTMLEMPTY;
1733 }
1734 }
1735
1736 /* Else will try to reuse lookahead token after shifting the error
1737 token. */
1738 goto yyerrlab1;
1739
1740
1741/*---------------------------------------------------.
1742| yyerrorlab -- error raised explicitly by YYERROR. |
1743`---------------------------------------------------*/
1744yyerrorlab:
1745 /* Pacify compilers when the user code never invokes YYERROR and the
1746 label yyerrorlab therefore never appears in user code. */
1747 if (0)
1748 YYERROR;
1749 ++yynerrs;
1750
1751 /* Do not reclaim the symbols of the rule whose action triggered
1752 this YYERROR. */
1753 YYPOPSTACK (yylen);
1754 yylen = 0;
1755 YY_STACK_PRINT (yyss, yyssp);
1756 yystate = *yyssp;
1757 goto yyerrlab1;
1758
1759
1760/*-------------------------------------------------------------.
1761| yyerrlab1 -- common code for both syntax error and YYERROR. |
1762`-------------------------------------------------------------*/
1763yyerrlab1:
1764 yyerrstatus = 3; /* Each real token shifted decrements this. */
1765
1766 /* Pop stack until we find a state that shifts the error token. */
1767 for (;;)
1768 {
1769 yyn = yypact[yystate];
1770 if (!yypact_value_is_default (yyn))
1771 {
1772 yyn += YYSYMBOL_YYerror;
1773 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1774 {
1775 yyn = yytable[yyn];
1776 if (0 < yyn)
1777 break;
1778 }
1779 }
1780
1781 /* Pop the current state because it cannot handle the error token. */
1782 if (yyssp == yyss)
1783 YYABORT;
1784
1785
1786 yydestruct ("Error: popping",
1787 YY_ACCESSING_SYMBOL (yystate), yyvsp, scanner);
1788 YYPOPSTACK (1);
1789 yystate = *yyssp;
1790 YY_STACK_PRINT (yyss, yyssp);
1791 }
1792
1794 *++yyvsp = yylval;
1796
1797
1798 /* Shift the error token. */
1799 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1800
1801 yystate = yyn;
1802 goto yynewstate;
1803
1804
1805/*-------------------------------------.
1806| yyacceptlab -- YYACCEPT comes here. |
1807`-------------------------------------*/
1808yyacceptlab:
1809 yyresult = 0;
1810 goto yyreturnlab;
1811
1812
1813/*-----------------------------------.
1814| yyabortlab -- YYABORT comes here. |
1815`-----------------------------------*/
1816yyabortlab:
1817 yyresult = 1;
1818 goto yyreturnlab;
1819
1820
1821/*-----------------------------------------------------------.
1822| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
1823`-----------------------------------------------------------*/
1824yyexhaustedlab:
1825 yyerror (scanner, YY_("memory exhausted"));
1826 yyresult = 2;
1827 goto yyreturnlab;
1828
1829
1830/*----------------------------------------------------------.
1831| yyreturnlab -- parsing is finished, clean up and return. |
1832`----------------------------------------------------------*/
1833yyreturnlab:
1834 if (yychar != HTMLEMPTY)
1835 {
1836 /* Make sure we have latest lookahead translation. See comments at
1837 user semantic actions for why this is necessary. */
1838 yytoken = YYTRANSLATE (yychar);
1839 yydestruct ("Cleanup: discarding lookahead",
1840 yytoken, &yylval, scanner);
1841 }
1842 /* Do not reclaim the symbols of the rule whose action triggered
1843 this YYABORT or YYACCEPT. */
1844 YYPOPSTACK (yylen);
1845 YY_STACK_PRINT (yyss, yyssp);
1846 while (yyssp != yyss)
1847 {
1848 yydestruct ("Cleanup: popping",
1849 YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, scanner);
1850 YYPOPSTACK (1);
1851 }
1852#ifndef yyoverflow
1853 if (yyss != yyssa)
1854 YYSTACK_FREE (yyss);
1855#endif
1856
1857 return yyresult;
1858}
1859
1860#line 357 "../../lib/common/htmlparse.y"
1861
1862
1863static void
1865{
1866 const textspan_t ti = {.str = agxbdisown(ag),
1867 .font = *sfont_back(&html_state->fontstack)};
1868 textspans_append(&html_state->fitemList, ti);
1869}
1870
1871static void
1873{
1874 htextspan_t lp = {0};
1875 textspans_t *ilist = &html_state->fitemList;
1876
1877 size_t cnt = textspans_size(ilist);
1878 lp.just = v;
1879 if (cnt) {
1880 lp.nitems = cnt;
1881 lp.items = gv_calloc(cnt, sizeof(textspan_t));
1882
1883 for (size_t i = 0; i < textspans_size(ilist); ++i) {
1884 // move this text span into the new list
1885 textspan_t *ti = textspans_at(ilist, i);
1886 lp.items[i] = *ti;
1887 *ti = (textspan_t){0};
1888 }
1889 }
1890 else {
1891 lp.items = gv_alloc(sizeof(textspan_t));
1892 lp.nitems = 1;
1893 lp.items[0].str = gv_strdup("");
1894 lp.items[0].font = *sfont_back(&html_state->fontstack);
1895 }
1896
1897 textspans_clear(ilist);
1898
1899 htextspans_append(&html_state->fspanList, lp);
1900}
1901
1902static htmltxt_t*
1904{
1905 htextspans_t *ispan = &html_state->fspanList;
1906 htmltxt_t *hft = gv_alloc(sizeof(htmltxt_t));
1907
1908 if (!textspans_is_empty(&html_state->fitemList))
1909 appendFLineList (html_state, UNSET_ALIGN);
1910
1911 size_t cnt = htextspans_size(ispan);
1912 hft->nspans = cnt;
1913
1914 hft->spans = gv_calloc(cnt, sizeof(htextspan_t));
1915 for (size_t i = 0; i < htextspans_size(ispan); ++i) {
1916 // move this HTML text span into the new list
1917 htextspan_t *hi = htextspans_at(ispan, i);
1918 hft->spans[i] = *hi;
1919 *hi = (htextspan_t){0};
1920 }
1921
1922 htextspans_clear(ispan);
1923
1924 return hft;
1925}
1926
1927static row_t *lastRow(htmlparserstate_t *html_state) {
1928 htmltbl_t* tbl = html_state->tblstack;
1929 row_t *sp = *rows_back(&tbl->u.p.rows);
1930 return sp;
1931}
1932
1933static void addRow(htmlparserstate_t *html_state) {
1934 htmltbl_t* tbl = html_state->tblstack;
1935 row_t *sp = gv_alloc(sizeof(row_t));
1936 if (tbl->hrule)
1937 sp->ruled = true;
1938 rows_append(&tbl->u.p.rows, sp);
1939}
1940
1941static void setCell(htmlparserstate_t *html_state, htmlcell_t *cp, void *obj, label_type_t kind) {
1942 htmltbl_t* tbl = html_state->tblstack;
1943 row_t *rp = *rows_back(&tbl->u.p.rows);
1944 cells_t *row = &rp->rp;
1945 cells_append(row, cp);
1946 cp->child.kind = kind;
1947 if (tbl->vrule) {
1948 cp->vruled = true;
1949 cp->hruled = false;
1950 }
1951
1952 if(kind == HTML_TEXT)
1953 cp->child.u.txt = obj;
1954 else if (kind == HTML_IMAGE)
1955 cp->child.u.img = obj;
1956 else
1957 cp->child.u.tbl = obj;
1958}
1959
1960static void cleanup (htmlparserstate_t *html_state)
1961{
1962 htmltbl_t* tp = html_state->tblstack;
1963 htmltbl_t* next;
1964
1965 if (html_state->lbl) {
1966 free_html_label (html_state->lbl,1);
1967 html_state->lbl = NULL;
1968 }
1969 while (tp) {
1970 next = tp->u.p.prev;
1971 cleanTbl (tp);
1972 tp = next;
1973 }
1974
1975 textspans_clear(&html_state->fitemList);
1976 htextspans_clear(&html_state->fspanList);
1977
1978 sfont_free(&html_state->fontstack);
1979}
1980
1981static void
1983{
1984 textfont_t* curfont = *sfont_back(&html_state->fontstack);
1985 textfont_t f = *fp;
1986
1987 if (curfont) {
1988 if (!f.color && curfont->color)
1989 f.color = curfont->color;
1990 if ((f.size < 0.0) && (curfont->size >= 0.0))
1991 f.size = curfont->size;
1992 if (!f.name && curfont->name)
1993 f.name = curfont->name;
1994 if (curfont->flags)
1995 f.flags |= curfont->flags;
1996 }
1997
1998 textfont_t *const ft = dtinsert(html_state->gvc->textfont_dt, &f);
1999 sfont_push_back(&html_state->fontstack, ft);
2000}
2001
2002static void
2004{
2005 (void)sfont_pop_back(&html_state->fontstack);
2006}
2007
2008/* Return parsed label or NULL if failure.
2009 * Set warn to 0 on success; 1 for warning message; 2 if no expat; 3 for error
2010 * message.
2011 */
2013parseHTML (char* txt, int* warn, htmlenv_t *env)
2014{
2015 agxbuf str = {0};
2016 htmllabel_t* l = NULL;
2017 htmlscan_t scanner = {0};
2018
2019 sfont_push_back(&scanner.parser.fontstack, NULL);
2020 scanner.parser.gvc = GD_gvc(env->g);
2021 scanner.parser.str = &str;
2022
2023 if (initHTMLlexer (&scanner, txt, &str, env)) {/* failed: no libexpat - give up */
2024 *warn = 2;
2025 }
2026 else {
2028 *warn = clearHTMLlexer (&scanner);
2029 l = scanner.parser.lbl;
2030 }
2031
2032 textspans_free(&scanner.parser.fitemList);
2033 htextspans_free(&scanner.parser.fspanList);
2034
2035 sfont_free(&scanner.parser.fontstack);
2036
2037 agxbfree (&str);
2038
2039 return l;
2040}
static void agxbfree(agxbuf *xb)
free any malloced resources
Definition agxbuf.h:78
static WUR char * agxbuse(agxbuf *xb)
Definition agxbuf.h:307
static char * agxbdisown(agxbuf *xb)
Definition agxbuf.h:327
Memory allocation wrappers that exit on failure.
static char * gv_strdup(const char *original)
Definition alloc.h:101
static void * gv_calloc(size_t nmemb, size_t size)
Definition alloc.h:26
static void * gv_alloc(size_t size)
Definition alloc.h:47
#define dtinsert(d, o)
Definition cdt.h:185
static const char * yysymbol_name(yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED
Definition exparse.c:731
static const char *const yytname[]
Definition exparse.c:706
yysymbol_kind_t
Definition gmlparse.c:282
#define YYSTYPE
Definition gmlparse.c:67
short yytype_int16
Definition gmlparse.c:381
#define yychar
Definition gmlparse.c:75
static void cleanup(void)
Definition gmlparse.c:130
#define yylval
Definition gmlparse.c:74
int yy_state_fast_t
Definition gmlparse.c:460
signed char yytype_int8
Definition gmlparse.c:373
yytype_int8 yy_state_t
Definition gmlparse.c:457
node NULL
Definition grammar.y:180
static int cnt(Dict_t *d, Dtlink_t **set)
Definition graph.c:198
#define GD_gvc(g)
Definition types.h:355
int clearHTMLlexer(htmlscan_t *scanner)
Definition htmllex.c:783
int initHTMLlexer(htmlscan_t *scanner, char *src, agxbuf *xb, htmlenv_t *env)
Definition htmllex.c:745
void htmlerror(htmlscan_t *scanner, const char *msg)
Definition htmllex.c:58
#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Definition htmlparse.c:449
#define YYMAXDEPTH
Definition htmlparse.c:1058
static void appendFItemList(htmlparserstate_t *html_state, agxbuf *ag)
Append a new text span to the list.
Definition htmlparse.c:1864
#define YYSTACK_FREE
Definition htmlparse.c:511
static const yytype_int8 yytranslate[]
Definition htmlparse.c:625
yysymbol_kind_t
Definition htmlparse.c:192
@ YYSYMBOL_overline
Definition htmlparse.c:250
@ YYSYMBOL_T_BR
Definition htmlparse.c:221
@ YYSYMBOL_T_end_vr
Definition htmlparse.c:220
@ YYSYMBOL_sup
Definition htmlparse.c:252
@ YYSYMBOL_T_underline
Definition htmlparse.c:230
@ YYSYMBOL_table
Definition htmlparse.c:258
@ YYSYMBOL_T_n_s
Definition htmlparse.c:214
@ YYSYMBOL_YYUNDEF
Definition htmlparse.c:196
@ YYSYMBOL_T_end_font
Definition htmlparse.c:205
@ YYSYMBOL_image
Definition htmlparse.c:271
@ YYSYMBOL_74_4
Definition htmlparse.c:268
@ YYSYMBOL_n_bold
Definition htmlparse.c:245
@ YYSYMBOL_n_underline
Definition htmlparse.c:249
@ YYSYMBOL_T_sub
Definition htmlparse.c:233
@ YYSYMBOL_T_n_underline
Definition htmlparse.c:210
@ YYSYMBOL_T_n_italic
Definition htmlparse.c:208
@ YYSYMBOL_br
Definition htmlparse.c:256
@ YYSYMBOL_n_font
Definition htmlparse.c:241
@ YYSYMBOL_70_2
Definition htmlparse.c:264
@ YYSYMBOL_n_overline
Definition htmlparse.c:251
@ YYSYMBOL_T_end_row
Definition htmlparse.c:200
@ YYSYMBOL_73_3
Definition htmlparse.c:267
@ YYSYMBOL_YYerror
Definition htmlparse.c:195
@ YYSYMBOL_T_end_table
Definition htmlparse.c:203
@ YYSYMBOL_T_table
Definition htmlparse.c:225
@ YYSYMBOL_strike
Definition htmlparse.c:246
@ YYSYMBOL_75_5
Definition htmlparse.c:269
@ YYSYMBOL_n_sup
Definition htmlparse.c:253
@ YYSYMBOL_T_VR
Definition htmlparse.c:218
@ YYSYMBOL_T_HR
Definition htmlparse.c:215
@ YYSYMBOL_html
Definition htmlparse.c:236
@ YYSYMBOL_T_br
Definition htmlparse.c:222
@ YYSYMBOL_T_end_br
Definition htmlparse.c:197
@ YYSYMBOL_T_n_sup
Definition htmlparse.c:212
@ YYSYMBOL_string
Definition htmlparse.c:257
@ YYSYMBOL_T_end_img
Definition htmlparse.c:198
@ YYSYMBOL_text
Definition htmlparse.c:238
@ YYSYMBOL_underline
Definition htmlparse.c:248
@ YYSYMBOL_n_sub
Definition htmlparse.c:255
@ YYSYMBOL_T_end_cell
Definition htmlparse.c:204
@ YYSYMBOL_VR
Definition htmlparse.c:273
@ YYSYMBOL_T_overline
Definition htmlparse.c:231
@ YYSYMBOL_T_end_html
Definition htmlparse.c:202
@ YYSYMBOL_T_italic
Definition htmlparse.c:228
@ YYSYMBOL_T_html
Definition htmlparse.c:201
@ YYSYMBOL_bold
Definition htmlparse.c:244
@ YYSYMBOL_sub
Definition htmlparse.c:254
@ YYSYMBOL_T_row
Definition htmlparse.c:199
@ YYSYMBOL_T_img
Definition htmlparse.c:224
@ YYSYMBOL_T_n_overline
Definition htmlparse.c:211
@ YYSYMBOL_YYACCEPT
Definition htmlparse.c:235
@ YYSYMBOL_n_italic
Definition htmlparse.c:243
@ YYSYMBOL_rows
Definition htmlparse.c:262
@ YYSYMBOL_T_hr
Definition htmlparse.c:216
@ YYSYMBOL_n_strike
Definition htmlparse.c:247
@ YYSYMBOL_YYEOF
Definition htmlparse.c:194
@ YYSYMBOL_T_s
Definition htmlparse.c:234
@ YYSYMBOL_T_bold
Definition htmlparse.c:229
@ YYSYMBOL_T_string
Definition htmlparse.c:206
@ YYSYMBOL_65_1
Definition htmlparse.c:259
@ YYSYMBOL_T_sup
Definition htmlparse.c:232
@ YYSYMBOL_cell
Definition htmlparse.c:266
@ YYSYMBOL_T_end_hr
Definition htmlparse.c:217
@ YYSYMBOL_cells
Definition htmlparse.c:265
@ YYSYMBOL_T_n_bold
Definition htmlparse.c:209
@ YYSYMBOL_T_font
Definition htmlparse.c:227
@ YYSYMBOL_fonttable
Definition htmlparse.c:260
@ YYSYMBOL_row
Definition htmlparse.c:263
@ YYSYMBOL_YYEMPTY
Definition htmlparse.c:193
@ YYSYMBOL_T_error
Definition htmlparse.c:207
@ YYSYMBOL_font
Definition htmlparse.c:240
@ YYSYMBOL_T_n_sub
Definition htmlparse.c:213
@ YYSYMBOL_T_IMG
Definition htmlparse.c:223
@ YYSYMBOL_italic
Definition htmlparse.c:242
@ YYSYMBOL_opt_space
Definition htmlparse.c:261
@ YYSYMBOL_fonttext
Definition htmlparse.c:237
@ YYSYMBOL_T_cell
Definition htmlparse.c:226
@ YYSYMBOL_textitem
Definition htmlparse.c:239
@ YYSYMBOL_76_6
Definition htmlparse.c:270
@ YYSYMBOL_HR
Definition htmlparse.c:272
@ YYSYMBOL_T_vr
Definition htmlparse.c:219
#define YY_ASSERT(E)
Definition htmlparse.c:469
#define YY_(Msgid)
Definition htmlparse.c:403
#define YYNOMEM
Definition htmlparse.c:890
#define YY_IGNORE_MAYBE_UNINITIALIZED_END
Definition htmlparse.c:450
static const yytype_int8 yydefact[]
Definition htmlparse.c:738
#define YYNSTATES
Definition htmlparse.c:610
#define YYSTYPE
Definition htmlparse.c:67
static void popFont(htmlparserstate_t *html_state)
Definition htmlparse.c:2003
#define YY_IGNORE_USELESS_CAST_END
Definition htmlparse.c:465
short yytype_int16
Definition htmlparse.c:314
static void addRow(htmlparserstate_t *html_state)
Add new cell row to current table.
Definition htmlparse.c:1933
#define YYABORT
Definition htmlparse.c:888
#define YYSTACK_BYTES(N)
Definition htmlparse.c:554
static const yytype_int8 yycheck[]
Definition htmlparse.c:807
static void cleanTbl(htmltbl_t *tp)
Clean up table if error in parsing.
Definition htmlparse.c:89
static void appendFLineList(htmlparserstate_t *html_state, int v)
Definition htmlparse.c:1872
htmllabel_t * parseHTML(char *txt, int *warn, htmlenv_t *env)
Definition htmlparse.c:2013
#define YY_REDUCE_PRINT(Rule)
Definition htmlparse.c:1041
#define YY_CAST(Type, Val)
Definition htmlparse.c:173
static const yytype_int16 yypact[]
Definition htmlparse.c:719
#define yylex
Definition htmlparse.c:70
#define YY_NULLPTR
Definition htmlparse.c:185
static row_t * lastRow(htmlparserstate_t *html_state)
Definition htmlparse.c:1927
#define YYFINAL
Definition htmlparse.c:599
#define YY_ACCESSING_SYMBOL(State)
Definition htmlparse.c:674
#define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
Definition htmlparse.c:1039
static const yytype_int16 yypgoto[]
Definition htmlparse.c:755
#define YY_INITIAL_VALUE(Value)
Definition htmlparse.c:446
static void yydestruct(const char *yymsg, yysymbol_kind_t yykind, YYSTYPE *yyvaluep, htmlscan_t *scanner)
Definition htmlparse.c:1071
#define yyparse
Definition htmlparse.c:69
static void cleanCell(htmlcell_t *cp)
Clean up cell if error in parsing.
Definition htmlparse.c:104
#define YYNTOKENS
Definition htmlparse.c:604
unsigned char yytype_uint8
Definition htmlparse.c:335
@ YYENOMEM
Definition htmlparse.c:882
#define YY_STACK_PRINT(Bottom, Top)
Definition htmlparse.c:1040
#define YYSIZE_T
Definition htmlparse.c:376
#define yydebug
Definition htmlparse.c:72
#define YY_IGNORE_USELESS_CAST_BEGIN
Definition htmlparse.c:464
static const yytype_int8 yyr2[]
Definition htmlparse.c:870
void * malloc(YYSIZE_T)
static const yytype_int8 yytable[]
Definition htmlparse.c:775
#define YYPTRDIFF_T
Definition htmlparse.c:362
static htmltxt_t * mkText(htmlparserstate_t *html_state)
Definition htmlparse.c:1903
#define yynerrs
Definition htmlparse.c:73
#define YYACCEPT
Definition htmlparse.c:887
#define yytable_value_is_error(Yyn)
Definition htmlparse.c:714
#define YYTRANSLATE(YYX)
Definition htmlparse.c:618
static void setCell(htmlparserstate_t *html_state, htmlcell_t *cp, void *obj, label_type_t kind)
Set cell body and type and attach to row.
Definition htmlparse.c:1941
static const yytype_int8 yystos[]
Definition htmlparse.c:841
#define YY_ATTRIBUTE_UNUSED
Definition htmlparse.c:420
static const yytype_int8 yyr1[]
Definition htmlparse.c:858
static htmllabel_t * mkLabel(void *obj, label_type_t kind)
Create label, given body and type.
Definition htmlparse.c:131
#define YYPOPSTACK(N)
int yy_state_fast_t
Definition htmlparse.c:393
unsigned short yytype_uint16
Definition htmlparse.c:346
static const yytype_int8 yydefgoto[]
Definition htmlparse.c:764
static bool nonSpace(const char *s)
Return 1 if s contains a non-space character.
Definition htmlparse.c:149
#define YYLAST
Definition htmlparse.c:601
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
Definition htmlparse.c:565
#define yypact_value_is_default(Yyn)
Definition htmlparse.c:709
#define YYINITDEPTH
Definition htmlparse.c:1047
signed char yytype_int8
Definition htmlparse.c:306
static void pushFont(htmlparserstate_t *html_state, textfont_t *fp)
Fonts are allocated in the lexer.
Definition htmlparse.c:1982
void free(void *)
#define YYERROR
Definition htmlparse.c:889
#define YYSIZEOF(X)
Definition htmlparse.c:386
#define YYSTACK_ALLOC
Definition htmlparse.c:510
yytype_int8 yy_state_t
Definition htmlparse.c:390
#define YYDPRINTF(Args)
Definition htmlparse.c:1038
#define YY_USE(E)
Definition htmlparse.c:426
#define yyerror
Definition htmlparse.c:71
int htmlparse(htmlscan_t *scanner)
#define HTMLerror
Definition htmlparse.h:121
#define HTMLEMPTY
Definition htmlparse.h:119
#define HTMLUNDEF
Definition htmlparse.h:122
#define HTMLEOF
Definition htmlparse.h:120
textitem scanner parser str
Definition htmlparse.y:224
$2 font
Definition htmlparse.y:300
$2 u p rows
Definition htmlparse.y:298
rows row
Definition htmlparse.y:326
cell HTML_TBL
Definition htmlparse.y:338
cleanup & scanner
Definition htmlparse.y:295
void free_html_text(htmltxt_t *t)
Definition htmltable.c:802
void free_html_label(htmllabel_t *lp, int root)
Definition htmltable.c:859
void free_html_data(htmldata_t *dp)
Definition htmltable.c:791
#define UNSET_ALIGN
Definition htmltable.h:44
label_type_t
Definition htmltable.h:101
@ HTML_TEXT
Definition htmltable.h:101
@ HTML_IMAGE
Definition htmltable.h:101
Dt_t * textfont_dt
Definition gvcint.h:108
result of partitioning available space, part of maze
Definition grid.h:33
size_t nitems
Definition htmltable.h:54
textspan_t * items
Definition htmltable.h:53
htmllabel_t child
Definition htmltable.h:163
bool vruled
vertically ruled?
Definition htmltable.h:165
bool hruled
horizontally ruled?
Definition htmltable.h:166
htmldata_t data
Definition htmltable.h:158
graph_t * g
Definition htmltable.h:173
htmltxt_t * txt
Definition htmltable.h:151
htmltbl_t * tbl
Definition htmltable.h:150
htmlimg_t * img
Definition htmltable.h:152
union htmllabel_t::@80 u
label_type_t kind
Definition htmltable.h:154
textspans_t fitemList
Definition htmlparse.h:213
htextspans_t fspanList
Definition htmlparse.h:214
htmllabel_t * lbl
Definition htmlparse.h:211
htmltbl_t * tblstack
Definition htmlparse.h:212
struct htmltbl_t::@77::@79 p
bool vrule
vertical rule
Definition htmltable.h:145
union htmltbl_t::@77 u
bool hrule
horizontal rule
Definition htmltable.h:144
htmltbl_t * prev
Definition htmltable.h:134
htmldata_t data
Definition htmltable.h:127
rows_t rows
cells
Definition htmltable.h:135
size_t nspans
Definition htmltable.h:62
htextspan_t * spans
Definition htmltable.h:61
cells_t rp
Definition htmltable.h:114
bool ruled
Definition htmltable.h:115
char * color
Definition textspan.h:55
char * name
Definition textspan.h:54
unsigned int flags
Definition textspan.h:58
double size
Definition textspan.h:57
char * str
Definition textspan.h:65
textfont_t * font
Definition textspan.h:66
Definition grammar.c:89