1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
%{ /* -*-indented-text-*- */
/*
* Copyright © 1998-2017 World Wide Web Consortium
* See http://www.w3.org/Consortium/Legal/copyright-software
*
* Part of HTML-XML-utils, see:
* http://www.w3.org/Tools/HTML-XML-utils/
*
* Author: Bert Bos <bert@w3.org>
* Created: 5 Nov 1998
*
* Input file for gperf, to generate a perfect hash function
* for all HTML tags, and to store each element's type.
*
* mixed = element accepts text content
* empty = element is empty
* cdata = element has character data content (i.e., unparsed content)
* stag = start tag is required
* etag = end tag is required
* pre = element is preformatted
* break_before, break_after = pretty-print with a newline before/after the elt
* parents = array of possible parents, first one is preferred parent
*
* The DTD is a mixture of strict HTML 4.0 and some HTML5
*
*/
#include <config.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>
#include "export.h"
#include "types.e"
#define MAXNAMELEN 10 /* Max. len. of elt. name */
EXPORTDEF(MAXNAMELEN)
EXPORT typedef struct _ElementType {
string name;
bool mixed, empty, cdata, stag, etag, pre, break_before, break_after;
string parents[76];
} ElementType;
/* lookup_element -- look up the string in the hash table */
EXPORT const ElementType * lookup_element(register const char *str,
register size_t len);
/* Different kinds of parent elements: */
#define PHRASE "abbr", "acronym", "b", "bdi", "bdo", "big", "cite", "code", "dfn", "em", "i", "kbd", "q", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "tt", "u", "var"
#define BRIDGE "p", "address", "caption", "dt", "h1", "h2", "h3", "h4", "h5", "h6", "legend", "pre"
#define FLOW "article", "aside", "dd", "del", "details", "div", "fieldset", "figcaption", "figure", "footer", "header", "ins", "li", "nav", "section", "main", "object", "td", "th"
#define INLINE_PARENT BRIDGE, PHRASE, FLOW
#define BLOCK_PARENT "body", "blockquote", "map", "main"
%}
ElementType {}
%%
# name mixed empty cdata stag etag pre b a parents
# ---- ----- ----- ----- ---- ---- --- - - -------
"%data", 1, 0, 0, 1, 0, 0, 0, 0, {"p", NULL}
a, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "label", NULL}
abbr, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
acronym, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
address, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
area, 0, 1, 0, 1, 0, 0, 0, 0, {"map", NULL}
article, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
aside, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
audio, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
b, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
base, 0, 1, 0, 1, 0, 0, 1, 1, {"head", NULL}
bdi, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
bdo, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
big, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
blockquote, 0, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
body, 0, 0, 0, 0, 0, 0, 1, 1, {"html", NULL}
br, 0, 1, 0, 1, 0, 0, 0, 1, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
button, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "label", NULL}
caption, 1, 0, 0, 1, 1, 0, 1, 1, {"table", NULL}
cite, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
code, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
col, 0, 1, 0, 1, 0, 0, 0, 0, {"colgroup", "table", NULL}
colgroup, 0, 0, 0, 1, 1, 0, 1, 1, {"table", NULL}
dd, 1, 0, 0, 1, 0, 0, 1, 1, {"dl", NULL}
del, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, BLOCK_PARENT, "a", "button", "noscript", "form", "label", "option", "textarea", NULL}
details, 1, 0, 0, 1, 1, 0, 1, 1, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
dfn, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
div, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
dl, 0, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
dt, 1, 0, 0, 1, 0, 0, 1, 1, {"dl", NULL}
em, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
embed, 0, 1, 0, 1, 0, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
fieldset, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "form", NULL}
figcaption, 1, 0, 0, 1, 1, 0, 1, 1, {"figure", NULL}
figure, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
footer, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
form, 0, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, NULL}
h1, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
h2, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
h3, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
h4, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
h5, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
h6, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
head, 0, 0, 0, 0, 0, 0, 1, 1, {"html", NULL}
header, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
hr, 0, 1, 0, 1, 0, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
html, 0, 0, 0, 0, 0, 0, 1, 1, {NULL, NULL}
i, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
img, 0, 1, 0, 1, 0, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
input, 0, 1, 0, 1, 0, 0, 0, 0, {INLINE_PARENT, "a", "label", NULL}
ins, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, BLOCK_PARENT, "a", "button", "noscript", "form", "label", "option", "textarea", NULL}
kbd, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
keygen, 0, 1, 0, 1, 0, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
label, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", NULL}
legend, 1, 0, 0, 1, 1, 0, 1, 1, {"fieldset", NULL}
li, 1, 0, 0, 1, 0, 0, 1, 1, {"ul", "ol", NULL}
link, 0, 1, 0, 1, 0, 0, 1, 0, {"head", NULL}
main, 1, 0, 0, 1, 1, 0, 1, 1, {"body", "div", "noscript", NULL}
map, 0, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
meta, 0, 1, 0, 1, 0, 0, 1, 0, {INLINE_PARENT, "head", "a", "button", "noscript", "label", NULL}
nav, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
noscript, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, BLOCK_PARENT, "a", "button", "noscript", "form", "label", "option", "textarea", NULL}
object, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "del", "header", "aside", "section", "main", "article", "nav", "fieldset", "head", "ins", "label", "object", NULL}
ol, 0, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
optgroup, 0, 0, 0, 1, 1, 0, 1, 1, {"select", NULL}
option, 1, 0, 0, 1, 0, 0, 1, 1, {"select", "optgroup", NULL}
p, 1, 0, 0, 1, 0, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
param, 0, 1, 0, 1, 0, 0, 1, 1, {"object", NULL}
pre, 1, 0, 0, 1, 1, 1, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
q, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
samp, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
script, 1, 0, 1, 1, 1, 1, 1, 0, {"body", INLINE_PARENT, "blockquote", "head", "map", "a", "button", "noscript", "form", "label", NULL}
section, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
select, 0, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "label", NULL}
small, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
source, 0, 1, 0, 1, 0, 0, 1, 1, {"audio", "video", "template", NULL}
span, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
strong, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
style, 1, 0, 1, 1, 1, 1, 1, 0, {"head", NULL}
sub, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
summary, 1, 0, 0, 1, 1, 0, 0, 0, {"details", NULL}
sup, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
table, 0, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
tbody, 0, 0, 0, 0, 0, 0, 1, 1, {"table", NULL}
td, 1, 0, 0, 1, 0, 0, 1, 1, {"tr", NULL}
textarea, 1, 0, 0, 1, 1, 1, 0, 0, {INLINE_PARENT, "a", "label", NULL}
tfoot, 0, 0, 0, 1, 0, 0, 1, 1, {"table", NULL}
th, 1, 0, 0, 1, 0, 0, 1, 1, {"tr", NULL}
thead, 0, 0, 0, 1, 0, 0, 1, 1, {"table", NULL}
title, 1, 0, 0, 1, 1, 0, 1, 1, {"head", NULL}
tr, 0, 0, 0, 1, 0, 0, 1, 1, {"tbody", "tfoot", "thead", NULL}
track, 0, 1, 0, 1, 0, 0, 1, 1, {"audio", "video", "template", NULL}
tt, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
ul, 0, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL}
var, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
video, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
wbr, 0, 1, 0, 1, 0, 0, 0, 1, {INLINE_PARENT, "a", "button", "noscript", "label", NULL}
%%
|