htmlparse.c 74 KB

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