105 |
sub COMMENT_START_DASH_STATE () { 15 } |
sub COMMENT_START_DASH_STATE () { 15 } |
106 |
sub COMMENT_STATE () { 16 } |
sub COMMENT_STATE () { 16 } |
107 |
sub COMMENT_END_STATE () { 17 } |
sub COMMENT_END_STATE () { 17 } |
108 |
|
sub COMMENT_END_BANG_STATE () { 102 } |
109 |
|
sub COMMENT_END_SPACE_STATE () { 103 } ## LAST |
110 |
sub COMMENT_END_DASH_STATE () { 18 } |
sub COMMENT_END_DASH_STATE () { 18 } |
111 |
sub BOGUS_COMMENT_STATE () { 19 } |
sub BOGUS_COMMENT_STATE () { 19 } |
112 |
sub DOCTYPE_STATE () { 20 } |
sub DOCTYPE_STATE () { 20 } |
184 |
sub AFTER_NDATA_STATE () { 87 } |
sub AFTER_NDATA_STATE () { 87 } |
185 |
sub BEFORE_NOTATION_NAME_STATE () { 88 } |
sub BEFORE_NOTATION_NAME_STATE () { 88 } |
186 |
sub NOTATION_NAME_STATE () { 89 } |
sub NOTATION_NAME_STATE () { 89 } |
187 |
sub AFTER_NOTATION_NAME_STATE () { 90 } |
sub DOCTYPE_ENTITY_VALUE_DOUBLE_QUOTED_STATE () { 90 } |
188 |
sub BOGUS_MD_STATE () { 91 } |
sub DOCTYPE_ENTITY_VALUE_SINGLE_QUOTED_STATE () { 91 } |
189 |
|
sub ENTITY_VALUE_ENTITY_STATE () { 92 } |
190 |
|
sub AFTER_ELEMENT_NAME_STATE () { 93 } |
191 |
|
sub BEFORE_ELEMENT_CONTENT_STATE () { 94 } |
192 |
|
sub CONTENT_KEYWORD_STATE () { 95 } |
193 |
|
sub AFTER_CM_GROUP_OPEN_STATE () { 96 } |
194 |
|
sub CM_ELEMENT_NAME_STATE () { 97 } |
195 |
|
sub AFTER_CM_ELEMENT_NAME_STATE () { 98 } |
196 |
|
sub AFTER_CM_GROUP_CLOSE_STATE () { 99 } |
197 |
|
sub AFTER_MD_DEF_STATE () { 100 } |
198 |
|
sub BOGUS_MD_STATE () { 101 } |
199 |
|
|
200 |
## Tree constructor state constants (see Whatpm::HTML for the full |
## Tree constructor state constants (see Whatpm::HTML for the full |
201 |
## list and descriptions) |
## list and descriptions) |
950 |
if ({ |
if ({ |
951 |
0x0022 => 1, # " |
0x0022 => 1, # " |
952 |
0x0027 => 1, # ' |
0x0027 => 1, # ' |
953 |
|
0x003C => 1, # < |
954 |
0x003D => 1, # = |
0x003D => 1, # = |
955 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
956 |
!!!cp (55); |
!!!cp (55); |
1073 |
|
|
1074 |
redo A; |
redo A; |
1075 |
} else { |
} else { |
1076 |
if ($self->{nc} == 0x0022 or # " |
if ({ |
1077 |
$self->{nc} == 0x0027) { # ' |
0x0022 => 1, # " |
1078 |
|
0x0027 => 1, # ' |
1079 |
|
0x003C => 1, # < |
1080 |
|
}->{$self->{nc}}) { |
1081 |
!!!cp (69); |
!!!cp (69); |
1082 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1083 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
1188 |
!!!cp (78.2); |
!!!cp (78.2); |
1189 |
} |
} |
1190 |
|
|
1191 |
if ($self->{nc} == 0x0022 or # " |
if ({ |
1192 |
$self->{nc} == 0x0027) { # ' |
0x0022 => 1, # " |
1193 |
|
0x0027 => 1, # ' |
1194 |
|
0x003C => 1, # < |
1195 |
|
}->{$self->{nc}}) { |
1196 |
!!!cp (78); |
!!!cp (78); |
1197 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1198 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
1279 |
|
|
1280 |
redo A; |
redo A; |
1281 |
} else { |
} else { |
1282 |
if ($self->{nc} == 0x003D) { # = |
if ($self->{nc} == 0x003D or $self->{nc} == 0x003C) { # =, < |
1283 |
!!!cp (93); |
!!!cp (93); |
1284 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1285 |
!!!parse-error (type => 'bad attribute value'); |
!!!parse-error (type => 'bad attribute value'); |
1325 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1326 |
!!!next-input-character; |
!!!next-input-character; |
1327 |
redo A; |
redo A; |
1328 |
|
} elsif ($self->{is_xml} and |
1329 |
|
$is_space->{$self->{nc}}) { |
1330 |
|
!!!cp (97.1); |
1331 |
|
$self->{ca}->{value} .= ' '; |
1332 |
|
## Stay in the state. |
1333 |
|
!!!next-input-character; |
1334 |
|
redo A; |
1335 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
1336 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
1337 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1379 |
} |
} |
1380 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1381 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1382 |
q["&<], |
qq["&<\x09\x0C\x20], |
1383 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1384 |
|
|
1385 |
## Stay in the state |
## Stay in the state |
1416 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1417 |
!!!next-input-character; |
!!!next-input-character; |
1418 |
redo A; |
redo A; |
1419 |
|
} elsif ($self->{is_xml} and |
1420 |
|
$is_space->{$self->{nc}}) { |
1421 |
|
!!!cp (103.1); |
1422 |
|
$self->{ca}->{value} .= ' '; |
1423 |
|
## Stay in the state. |
1424 |
|
!!!next-input-character; |
1425 |
|
redo A; |
1426 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
1427 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
1428 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1470 |
} |
} |
1471 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1472 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1473 |
q['&<], |
qq['&<\x09\x0C\x20], |
1474 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1475 |
|
|
1476 |
## Stay in the state |
## Stay in the state |
1582 |
0x0022 => 1, # " |
0x0022 => 1, # " |
1583 |
0x0027 => 1, # ' |
0x0027 => 1, # ' |
1584 |
0x003D => 1, # = |
0x003D => 1, # = |
1585 |
|
0x003C => 1, # < |
1586 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
1587 |
!!!cp (115); |
!!!cp (115); |
1588 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1592 |
} |
} |
1593 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1594 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1595 |
q["'=& >], |
qq["'=& \x09\x0C>], |
1596 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1597 |
|
|
1598 |
## Stay in the state |
## Stay in the state |
2084 |
!!!next-input-character; |
!!!next-input-character; |
2085 |
redo A; |
redo A; |
2086 |
} |
} |
2087 |
} elsif ($self->{state} == COMMENT_END_STATE) { |
} elsif ($self->{state} == COMMENT_END_STATE or |
2088 |
|
$self->{state} == COMMENT_END_BANG_STATE) { |
2089 |
## XML5: "Comment end state" and "DOCTYPE comment end state". |
## XML5: "Comment end state" and "DOCTYPE comment end state". |
2090 |
|
## (No comment end bang state.) |
2091 |
|
|
2092 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
2093 |
if ($self->{in_subset}) { |
if ($self->{in_subset}) { |
2104 |
|
|
2105 |
redo A; |
redo A; |
2106 |
} elsif ($self->{nc} == 0x002D) { # - |
} elsif ($self->{nc} == 0x002D) { # - |
2107 |
!!!cp (152); |
if ($self->{state} == COMMENT_END_BANG_STATE) { |
2108 |
## XML5: Not a parse error. |
!!!cp (154.3); |
2109 |
!!!parse-error (type => 'dash in comment', |
$self->{ct}->{data} .= '--!'; # comment |
2110 |
line => $self->{line_prev}, |
$self->{state} = COMMENT_END_DASH_STATE; |
2111 |
column => $self->{column_prev}); |
} else { |
2112 |
$self->{ct}->{data} .= '-'; # comment |
!!!cp (152); |
2113 |
## Stay in the state |
## XML5: Not a parse error. |
2114 |
|
!!!parse-error (type => 'dash in comment', |
2115 |
|
line => $self->{line_prev}, |
2116 |
|
column => $self->{column_prev}); |
2117 |
|
$self->{ct}->{data} .= '-'; # comment |
2118 |
|
## Stay in the state |
2119 |
|
} |
2120 |
|
!!!next-input-character; |
2121 |
|
redo A; |
2122 |
|
} elsif ($self->{state} != COMMENT_END_BANG_STATE and |
2123 |
|
$is_space->{$self->{nc}}) { |
2124 |
|
!!!cp (152.1); |
2125 |
|
!!!parse-error (type => 'comment end space'); # XXX error type |
2126 |
|
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
2127 |
|
$self->{state} = COMMENT_END_SPACE_STATE; |
2128 |
|
!!!next-input-character; |
2129 |
|
redo A; |
2130 |
|
} elsif ($self->{state} != COMMENT_END_BANG_STATE and |
2131 |
|
$self->{nc} == 0x0021) { # ! |
2132 |
|
!!!cp (152.2); |
2133 |
|
!!!parse-error (type => 'comment end bang'); # XXX error type |
2134 |
|
$self->{state} = COMMENT_END_BANG_STATE; |
2135 |
!!!next-input-character; |
!!!next-input-character; |
2136 |
redo A; |
redo A; |
2137 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2144 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2145 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
2146 |
} |
} |
2147 |
## reconsume |
## Reconsume. |
2148 |
|
|
2149 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
2150 |
|
|
2151 |
redo A; |
redo A; |
2152 |
} else { |
} else { |
2153 |
!!!cp (154); |
!!!cp (154); |
2154 |
## XML5: Not a parse error. |
if ($self->{state} == COMMENT_END_BANG_STATE) { |
2155 |
!!!parse-error (type => 'dash in comment', |
$self->{ct}->{data} .= '--!' . chr ($self->{nc}); # comment |
2156 |
line => $self->{line_prev}, |
} else { |
2157 |
column => $self->{column_prev}); |
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
2158 |
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
} |
2159 |
$self->{state} = COMMENT_STATE; |
$self->{state} = COMMENT_STATE; |
2160 |
!!!next-input-character; |
!!!next-input-character; |
2161 |
redo A; |
redo A; |
2162 |
} |
} |
2163 |
|
} elsif ($self->{state} == COMMENT_END_SPACE_STATE) { |
2164 |
|
## XML5: Not exist. |
2165 |
|
|
2166 |
|
if ($self->{nc} == 0x003E) { # > |
2167 |
|
if ($self->{in_subset}) { |
2168 |
|
!!!cp (154.4); |
2169 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2170 |
|
} else { |
2171 |
|
!!!cp (154.5); |
2172 |
|
$self->{state} = DATA_STATE; |
2173 |
|
$self->{s_kwd} = ''; |
2174 |
|
} |
2175 |
|
!!!next-input-character; |
2176 |
|
|
2177 |
|
!!!emit ($self->{ct}); # comment |
2178 |
|
|
2179 |
|
redo A; |
2180 |
|
} elsif ($is_space->{$self->{nc}}) { |
2181 |
|
!!!cp (154.6); |
2182 |
|
$self->{ct}->{data} .= chr ($self->{nc}); # comment |
2183 |
|
## Stay in the state. |
2184 |
|
!!!next-input-character; |
2185 |
|
redo A; |
2186 |
|
} elsif ($self->{nc} == -1) { |
2187 |
|
!!!parse-error (type => 'unclosed comment'); |
2188 |
|
if ($self->{in_subset}) { |
2189 |
|
!!!cp (154.7); |
2190 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2191 |
|
} else { |
2192 |
|
!!!cp (154.8); |
2193 |
|
$self->{state} = DATA_STATE; |
2194 |
|
$self->{s_kwd} = ''; |
2195 |
|
} |
2196 |
|
## Reconsume. |
2197 |
|
|
2198 |
|
!!!emit ($self->{ct}); # comment |
2199 |
|
|
2200 |
|
redo A; |
2201 |
|
} else { |
2202 |
|
!!!cp (154.9); |
2203 |
|
$self->{ct}->{data} .= chr ($self->{nc}); # comment |
2204 |
|
$self->{state} = COMMENT_STATE; |
2205 |
|
!!!next-input-character; |
2206 |
|
redo A; |
2207 |
|
} |
2208 |
} elsif ($self->{state} == DOCTYPE_STATE) { |
} elsif ($self->{state} == DOCTYPE_STATE) { |
2209 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
2210 |
!!!cp (155); |
!!!cp (155); |
2211 |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
2212 |
!!!next-input-character; |
!!!next-input-character; |
2213 |
redo A; |
redo A; |
2214 |
|
} elsif ($self->{nc} == -1) { |
2215 |
|
!!!cp (155.1); |
2216 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
2217 |
|
$self->{ct}->{quirks} = 1; |
2218 |
|
|
2219 |
|
$self->{state} = DATA_STATE; |
2220 |
|
## Reconsume. |
2221 |
|
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
2222 |
|
|
2223 |
|
redo A; |
2224 |
} else { |
} else { |
2225 |
!!!cp (156); |
!!!cp (156); |
2226 |
## XML5: Unless EOF, swith to the bogus comment state. |
## XML5: Swith to the bogus comment state. |
2227 |
!!!parse-error (type => 'no space before DOCTYPE name'); |
!!!parse-error (type => 'no space before DOCTYPE name'); |
2228 |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
2229 |
## reconsume |
## reconsume |
2248 |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
2249 |
|
|
2250 |
redo A; |
redo A; |
2251 |
|
} elsif (0x0041 <= $self->{nc} and $self->{nc} <= 0x005A) { # A..Z |
2252 |
|
!!!cp (158.1); |
2253 |
|
$self->{ct}->{name} # DOCTYPE |
2254 |
|
= chr ($self->{nc} + ($self->{is_xml} ? 0 : 0x0020)); |
2255 |
|
delete $self->{ct}->{quirks}; |
2256 |
|
$self->{state} = DOCTYPE_NAME_STATE; |
2257 |
|
!!!next-input-character; |
2258 |
|
redo A; |
2259 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2260 |
!!!cp (159); |
!!!cp (159); |
2261 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
2302 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2303 |
|
|
2304 |
redo A; |
redo A; |
2305 |
|
} elsif (0x0041 <= $self->{nc} and $self->{nc} <= 0x005A) { # A..Z |
2306 |
|
!!!cp (162.1); |
2307 |
|
$self->{ct}->{name} # DOCTYPE |
2308 |
|
.= chr ($self->{nc} + ($self->{is_xml} ? 0 : 0x0020)); |
2309 |
|
delete $self->{ct}->{quirks}; |
2310 |
|
## Stay in the state. |
2311 |
|
!!!next-input-character; |
2312 |
|
redo A; |
2313 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2314 |
!!!cp (163); |
!!!cp (163); |
2315 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2331 |
redo A; |
redo A; |
2332 |
} else { |
} else { |
2333 |
!!!cp (164); |
!!!cp (164); |
2334 |
$self->{ct}->{name} |
$self->{ct}->{name} .= chr ($self->{nc}); # DOCTYPE |
2335 |
.= chr ($self->{nc}); # DOCTYPE |
## Stay in the state. |
|
## Stay in the state |
|
2336 |
!!!next-input-character; |
!!!next-input-character; |
2337 |
redo A; |
redo A; |
2338 |
} |
} |
2389 |
$self->{kwd} = chr $self->{nc}; |
$self->{kwd} = chr $self->{nc}; |
2390 |
!!!next-input-character; |
!!!next-input-character; |
2391 |
redo A; |
redo A; |
2392 |
## TODO: " and ' for ENTITY |
} elsif ($self->{nc} == 0x0022 and # " |
2393 |
|
($self->{ct}->{type} == GENERAL_ENTITY_TOKEN or |
2394 |
|
$self->{ct}->{type} == PARAMETER_ENTITY_TOKEN)) { |
2395 |
|
!!!cp (167.21); |
2396 |
|
$self->{state} = DOCTYPE_ENTITY_VALUE_DOUBLE_QUOTED_STATE; |
2397 |
|
$self->{ct}->{value} = ''; # ENTITY |
2398 |
|
!!!next-input-character; |
2399 |
|
redo A; |
2400 |
|
} elsif ($self->{nc} == 0x0027 and # ' |
2401 |
|
($self->{ct}->{type} == GENERAL_ENTITY_TOKEN or |
2402 |
|
$self->{ct}->{type} == PARAMETER_ENTITY_TOKEN)) { |
2403 |
|
!!!cp (167.22); |
2404 |
|
$self->{state} = DOCTYPE_ENTITY_VALUE_SINGLE_QUOTED_STATE; |
2405 |
|
$self->{ct}->{value} = ''; # ENTITY |
2406 |
|
!!!next-input-character; |
2407 |
|
redo A; |
2408 |
} elsif ($self->{is_xml} and |
} elsif ($self->{is_xml} and |
2409 |
$self->{ct}->{type} == DOCTYPE_TOKEN and |
$self->{ct}->{type} == DOCTYPE_TOKEN and |
2410 |
$self->{nc} == 0x005B) { # [ |
$self->{nc} == 0x005B) { # [ |
3195 |
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
3196 |
$self->{entity_add} => 1, |
$self->{entity_add} => 1, |
3197 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
3198 |
!!!cp (1001); |
if ($self->{is_xml}) { |
3199 |
|
!!!cp (1001.1); |
3200 |
|
!!!parse-error (type => 'bare ero', |
3201 |
|
line => $self->{line_prev}, |
3202 |
|
column => $self->{column_prev} |
3203 |
|
+ ($self->{nc} == -1 ? 1 : 0)); |
3204 |
|
} else { |
3205 |
|
!!!cp (1001); |
3206 |
|
## No error |
3207 |
|
} |
3208 |
## Don't consume |
## Don't consume |
|
## No error |
|
3209 |
## Return nothing. |
## Return nothing. |
3210 |
# |
# |
3211 |
} elsif ($self->{nc} == 0x0023) { # # |
} elsif ($self->{nc} == 0x0023) { # # |
3214 |
$self->{kwd} = '#'; |
$self->{kwd} = '#'; |
3215 |
!!!next-input-character; |
!!!next-input-character; |
3216 |
redo A; |
redo A; |
3217 |
} elsif ((0x0041 <= $self->{nc} and |
} elsif ($self->{is_xml} or |
3218 |
|
(0x0041 <= $self->{nc} and |
3219 |
$self->{nc} <= 0x005A) or # A..Z |
$self->{nc} <= 0x005A) or # A..Z |
3220 |
(0x0061 <= $self->{nc} and |
(0x0061 <= $self->{nc} and |
3221 |
$self->{nc} <= 0x007A)) { # a..z |
$self->{nc} <= 0x007A)) { # a..z |
3259 |
redo A; |
redo A; |
3260 |
} |
} |
3261 |
} elsif ($self->{state} == ENTITY_HASH_STATE) { |
} elsif ($self->{state} == ENTITY_HASH_STATE) { |
3262 |
if ($self->{nc} == 0x0078 or # x |
if ($self->{nc} == 0x0078) { # x |
|
$self->{nc} == 0x0058) { # X |
|
3263 |
!!!cp (995); |
!!!cp (995); |
3264 |
$self->{state} = HEXREF_X_STATE; |
$self->{state} = HEXREF_X_STATE; |
3265 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3266 |
!!!next-input-character; |
!!!next-input-character; |
3267 |
redo A; |
redo A; |
3268 |
|
} elsif ($self->{nc} == 0x0058) { # X |
3269 |
|
!!!cp (995.1); |
3270 |
|
if ($self->{is_xml}) { |
3271 |
|
!!!parse-error (type => 'uppercase hcro'); ## TODO: type |
3272 |
|
} |
3273 |
|
$self->{state} = HEXREF_X_STATE; |
3274 |
|
$self->{kwd} .= chr $self->{nc}; |
3275 |
|
!!!next-input-character; |
3276 |
|
redo A; |
3277 |
} elsif (0x0030 <= $self->{nc} and |
} elsif (0x0030 <= $self->{nc} and |
3278 |
$self->{nc} <= 0x0039) { # 0..9 |
$self->{nc} <= 0x0039) { # 0..9 |
3279 |
!!!cp (994); |
!!!cp (994); |
3334 |
my $code = $self->{kwd}; |
my $code = $self->{kwd}; |
3335 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3336 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3337 |
if ($charref_map->{$code}) { |
if ((not $self->{is_xml} and $charref_map->{$code}) or |
3338 |
|
($self->{is_xml} and 0xD800 <= $code and $code <= 0xDFFF) or |
3339 |
|
($self->{is_xml} and $code == 0x0000)) { |
3340 |
!!!cp (1015); |
!!!cp (1015); |
3341 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
3342 |
text => (sprintf 'U+%04X', $code), |
text => (sprintf 'U+%04X', $code), |
3449 |
my $code = $self->{kwd}; |
my $code = $self->{kwd}; |
3450 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3451 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3452 |
if ($charref_map->{$code}) { |
if ((not $self->{is_xml} and $charref_map->{$code}) or |
3453 |
|
($self->{is_xml} and 0xD800 <= $code and $code <= 0xDFFF) or |
3454 |
|
($self->{is_xml} and $code == 0x0000)) { |
3455 |
!!!cp (1008); |
!!!cp (1008); |
3456 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
3457 |
text => (sprintf 'U+%04X', $code), |
text => (sprintf 'U+%04X', $code), |
3485 |
redo A; |
redo A; |
3486 |
} |
} |
3487 |
} elsif ($self->{state} == ENTITY_NAME_STATE) { |
} elsif ($self->{state} == ENTITY_NAME_STATE) { |
3488 |
if (length $self->{kwd} < 30 and |
if ((0x0041 <= $self->{nc} and # a |
3489 |
## NOTE: Some number greater than the maximum length of entity name |
$self->{nc} <= 0x005A) or # x |
3490 |
((0x0041 <= $self->{nc} and # a |
(0x0061 <= $self->{nc} and # a |
3491 |
$self->{nc} <= 0x005A) or # x |
$self->{nc} <= 0x007A) or # z |
3492 |
(0x0061 <= $self->{nc} and # a |
(0x0030 <= $self->{nc} and # 0 |
3493 |
$self->{nc} <= 0x007A) or # z |
$self->{nc} <= 0x0039) or # 9 |
3494 |
(0x0030 <= $self->{nc} and # 0 |
$self->{nc} == 0x003B or # ; |
3495 |
$self->{nc} <= 0x0039) or # 9 |
($self->{is_xml} and |
3496 |
$self->{nc} == 0x003B)) { # ; |
not ($is_space->{$self->{nc}} or |
3497 |
|
{ |
3498 |
|
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
3499 |
|
$self->{entity_add} => 1, |
3500 |
|
}->{$self->{nc}}))) { |
3501 |
our $EntityChar; |
our $EntityChar; |
3502 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3503 |
if (defined $EntityChar->{$self->{kwd}}) { |
if (defined $EntityChar->{$self->{kwd}} or |
3504 |
|
$self->{ge}->{$self->{kwd}}) { |
3505 |
if ($self->{nc} == 0x003B) { # ; |
if ($self->{nc} == 0x003B) { # ; |
3506 |
!!!cp (1020); |
if (defined $self->{ge}->{$self->{kwd}}) { |
3507 |
$self->{entity__value} = $EntityChar->{$self->{kwd}}; |
if ($self->{ge}->{$self->{kwd}}->{only_text}) { |
3508 |
|
!!!cp (1020.1); |
3509 |
|
$self->{entity__value} = $self->{ge}->{$self->{kwd}}->{value}; |
3510 |
|
} else { |
3511 |
|
if (defined $self->{ge}->{$self->{kwd}}->{notation}) { |
3512 |
|
!!!cp (1020.2); |
3513 |
|
!!!parse-error (type => 'unparsed entity', ## TODO: type |
3514 |
|
value => $self->{kwd}); |
3515 |
|
} else { |
3516 |
|
!!!cp (1020.3); |
3517 |
|
} |
3518 |
|
$self->{entity__value} = '&' . $self->{kwd}; ## TODO: expand |
3519 |
|
} |
3520 |
|
} else { |
3521 |
|
if ($self->{is_xml}) { |
3522 |
|
!!!cp (1020.4); |
3523 |
|
!!!parse-error (type => 'entity not declared', ## TODO: type |
3524 |
|
value => $self->{kwd}, |
3525 |
|
level => { |
3526 |
|
'amp;' => $self->{level}->{warn}, |
3527 |
|
'quot;' => $self->{level}->{warn}, |
3528 |
|
'lt;' => $self->{level}->{warn}, |
3529 |
|
'gt;' => $self->{level}->{warn}, |
3530 |
|
'apos;' => $self->{level}->{warn}, |
3531 |
|
}->{$self->{kwd}} || |
3532 |
|
$self->{level}->{must}); |
3533 |
|
} else { |
3534 |
|
!!!cp (1020); |
3535 |
|
} |
3536 |
|
$self->{entity__value} = $EntityChar->{$self->{kwd}}; |
3537 |
|
} |
3538 |
$self->{entity__match} = 1; |
$self->{entity__match} = 1; |
3539 |
!!!next-input-character; |
!!!next-input-character; |
3540 |
# |
# |
3780 |
## XML5: Not defined yet. |
## XML5: Not defined yet. |
3781 |
|
|
3782 |
## TODO: |
## TODO: |
3783 |
|
|
3784 |
|
if (not $self->{stop_processing} and |
3785 |
|
not $self->{document}->xml_standalone) { |
3786 |
|
!!!parse-error (type => 'stop processing', ## TODO: type |
3787 |
|
level => $self->{level}->{info}); |
3788 |
|
$self->{stop_processing} = 1; |
3789 |
|
} |
3790 |
|
|
3791 |
!!!next-input-character; |
!!!next-input-character; |
3792 |
redo A; |
redo A; |
3793 |
} elsif ($self->{nc} == 0x005D) { # ] |
} elsif ($self->{nc} == 0x005D) { # ] |
4022 |
} |
} |
4023 |
$self->{ct} = {type => ELEMENT_TOKEN, name => '', |
$self->{ct} = {type => ELEMENT_TOKEN, name => '', |
4024 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
4025 |
column => $self->{column_prev} - 6}; |
column => $self->{column_prev} - 7}; |
4026 |
$self->{state} = DOCTYPE_MD_STATE; |
$self->{state} = DOCTYPE_MD_STATE; |
4027 |
!!!next-input-character; |
!!!next-input-character; |
4028 |
redo A; |
redo A; |
4070 |
$self->{ct} = {type => ATTLIST_TOKEN, name => '', |
$self->{ct} = {type => ATTLIST_TOKEN, name => '', |
4071 |
attrdefs => [], |
attrdefs => [], |
4072 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
4073 |
column => $self->{column_prev} - 6}; |
column => $self->{column_prev} - 7}; |
4074 |
$self->{state} = DOCTYPE_MD_STATE; |
$self->{state} = DOCTYPE_MD_STATE; |
4075 |
!!!next-input-character; |
!!!next-input-character; |
4076 |
redo A; |
redo A; |
4119 |
} |
} |
4120 |
$self->{ct} = {type => NOTATION_TOKEN, name => '', |
$self->{ct} = {type => NOTATION_TOKEN, name => '', |
4121 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
4122 |
column => $self->{column_prev} - 6}; |
column => $self->{column_prev} - 8}; |
4123 |
$self->{state} = DOCTYPE_MD_STATE; |
$self->{state} = DOCTYPE_MD_STATE; |
4124 |
!!!next-input-character; |
!!!next-input-character; |
4125 |
redo A; |
redo A; |
4231 |
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
4232 |
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
4233 |
} elsif ($self->{ct}->{type} == ELEMENT_TOKEN) { |
} elsif ($self->{ct}->{type} == ELEMENT_TOKEN) { |
4234 |
## TODO: ... |
$self->{state} = AFTER_ELEMENT_NAME_STATE; |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
|
4235 |
} else { # ENTITY/NOTATION |
} else { # ENTITY/NOTATION |
4236 |
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
4237 |
} |
} |
4854 |
} |
} |
4855 |
} elsif ($self->{state} == NOTATION_NAME_STATE) { |
} elsif ($self->{state} == NOTATION_NAME_STATE) { |
4856 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
4857 |
$self->{state} = AFTER_NOTATION_NAME_STATE; |
$self->{state} = AFTER_MD_DEF_STATE; |
4858 |
!!!next-input-character; |
!!!next-input-character; |
4859 |
redo A; |
redo A; |
4860 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
4874 |
!!!next-input-character; |
!!!next-input-character; |
4875 |
redo A; |
redo A; |
4876 |
} |
} |
4877 |
} elsif ($self->{state} == AFTER_NOTATION_NAME_STATE) { |
} elsif ($self->{state} == DOCTYPE_ENTITY_VALUE_DOUBLE_QUOTED_STATE) { |
4878 |
|
if ($self->{nc} == 0x0022) { # " |
4879 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
4880 |
|
!!!next-input-character; |
4881 |
|
redo A; |
4882 |
|
} elsif ($self->{nc} == 0x0026) { # & |
4883 |
|
$self->{prev_state} = $self->{state}; |
4884 |
|
$self->{state} = ENTITY_VALUE_ENTITY_STATE; |
4885 |
|
$self->{entity_add} = 0x0022; # " |
4886 |
|
!!!next-input-character; |
4887 |
|
redo A; |
4888 |
|
## TODO: % |
4889 |
|
} elsif ($self->{nc} == -1) { |
4890 |
|
!!!parse-error (type => 'unclosed entity value'); ## TODO: type |
4891 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4892 |
|
## Reconsume. |
4893 |
|
!!!emit ($self->{ct}); # ENTITY |
4894 |
|
redo A; |
4895 |
|
} else { |
4896 |
|
$self->{ct}->{value} .= chr $self->{nc}; # ENTITY |
4897 |
|
!!!next-input-character; |
4898 |
|
redo A; |
4899 |
|
} |
4900 |
|
} elsif ($self->{state} == DOCTYPE_ENTITY_VALUE_SINGLE_QUOTED_STATE) { |
4901 |
|
if ($self->{nc} == 0x0027) { # ' |
4902 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
4903 |
|
!!!next-input-character; |
4904 |
|
redo A; |
4905 |
|
} elsif ($self->{nc} == 0x0026) { # & |
4906 |
|
$self->{prev_state} = $self->{state}; |
4907 |
|
$self->{state} = ENTITY_VALUE_ENTITY_STATE; |
4908 |
|
$self->{entity_add} = 0x0027; # ' |
4909 |
|
!!!next-input-character; |
4910 |
|
redo A; |
4911 |
|
## TODO: % |
4912 |
|
} elsif ($self->{nc} == -1) { |
4913 |
|
!!!parse-error (type => 'unclosed entity value'); ## TODO: type |
4914 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4915 |
|
## Reconsume. |
4916 |
|
!!!emit ($self->{ct}); # ENTITY |
4917 |
|
redo A; |
4918 |
|
} else { |
4919 |
|
$self->{ct}->{value} .= chr $self->{nc}; # ENTITY |
4920 |
|
!!!next-input-character; |
4921 |
|
redo A; |
4922 |
|
} |
4923 |
|
} elsif ($self->{state} == ENTITY_VALUE_ENTITY_STATE) { |
4924 |
|
if ($is_space->{$self->{nc}} or |
4925 |
|
{ |
4926 |
|
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
4927 |
|
$self->{entity_add} => 1, |
4928 |
|
}->{$self->{nc}}) { |
4929 |
|
!!!parse-error (type => 'bare ero', |
4930 |
|
line => $self->{line_prev}, |
4931 |
|
column => $self->{column_prev} |
4932 |
|
+ ($self->{nc} == -1 ? 1 : 0)); |
4933 |
|
## Don't consume |
4934 |
|
## Return nothing. |
4935 |
|
# |
4936 |
|
} elsif ($self->{nc} == 0x0023) { # # |
4937 |
|
$self->{ca} = $self->{ct}; |
4938 |
|
$self->{state} = ENTITY_HASH_STATE; |
4939 |
|
$self->{kwd} = '#'; |
4940 |
|
!!!next-input-character; |
4941 |
|
redo A; |
4942 |
|
} else { |
4943 |
|
# |
4944 |
|
} |
4945 |
|
|
4946 |
|
$self->{ct}->{value} .= '&'; |
4947 |
|
$self->{state} = $self->{prev_state}; |
4948 |
|
## Reconsume. |
4949 |
|
redo A; |
4950 |
|
} elsif ($self->{state} == AFTER_ELEMENT_NAME_STATE) { |
4951 |
|
if ($is_space->{$self->{nc}}) { |
4952 |
|
$self->{state} = BEFORE_ELEMENT_CONTENT_STATE; |
4953 |
|
!!!next-input-character; |
4954 |
|
redo A; |
4955 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4956 |
|
$self->{state} = AFTER_CM_GROUP_OPEN_STATE; |
4957 |
|
$self->{ct}->{content} = ['(']; |
4958 |
|
$self->{group_depth} = 1; |
4959 |
|
!!!next-input-character; |
4960 |
|
redo A; |
4961 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4962 |
|
!!!parse-error (type => 'no md def'); ## TODO: type |
4963 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4964 |
|
!!!next-input-character; |
4965 |
|
!!!emit ($self->{ct}); # ELEMENT |
4966 |
|
redo A; |
4967 |
|
} elsif ($self->{nc} == -1) { |
4968 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4969 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4970 |
|
!!!next-input-character; |
4971 |
|
!!!emit ($self->{ct}); # ELEMENT |
4972 |
|
redo A; |
4973 |
|
} else { |
4974 |
|
$self->{ct}->{content} = [chr $self->{nc}]; |
4975 |
|
$self->{state} = CONTENT_KEYWORD_STATE; |
4976 |
|
!!!next-input-character; |
4977 |
|
redo A; |
4978 |
|
} |
4979 |
|
} elsif ($self->{state} == CONTENT_KEYWORD_STATE) { |
4980 |
|
if ($is_space->{$self->{nc}}) { |
4981 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
4982 |
|
!!!next-input-character; |
4983 |
|
redo A; |
4984 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4985 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4986 |
|
!!!next-input-character; |
4987 |
|
!!!emit ($self->{ct}); # ELEMENT |
4988 |
|
redo A; |
4989 |
|
} elsif ($self->{nc} == -1) { |
4990 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4991 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4992 |
|
!!!next-input-character; |
4993 |
|
!!!emit ($self->{ct}); # ELEMENT |
4994 |
|
redo A; |
4995 |
|
} else { |
4996 |
|
$self->{ct}->{content}->[-1] .= chr $self->{nc}; # ELEMENT |
4997 |
|
## Stay in the state. |
4998 |
|
!!!next-input-character; |
4999 |
|
redo A; |
5000 |
|
} |
5001 |
|
} elsif ($self->{state} == AFTER_CM_GROUP_OPEN_STATE) { |
5002 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
5003 |
## Stay in the state. |
## Stay in the state. |
5004 |
!!!next-input-character; |
!!!next-input-character; |
5005 |
redo A; |
redo A; |
5006 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
5007 |
|
$self->{group_depth}++; |
5008 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5009 |
|
## Stay in the state. |
5010 |
|
!!!next-input-character; |
5011 |
|
redo A; |
5012 |
|
} elsif ($self->{nc} == 0x007C or # | |
5013 |
|
$self->{nc} == 0x002C) { # , |
5014 |
|
!!!parse-error (type => 'empty element name'); ## TODO: type |
5015 |
|
## Stay in the state. |
5016 |
|
!!!next-input-character; |
5017 |
|
redo A; |
5018 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
5019 |
|
!!!parse-error (type => 'empty element name'); ## TODO: type |
5020 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5021 |
|
$self->{group_depth}--; |
5022 |
|
$self->{state} = AFTER_CM_GROUP_CLOSE_STATE; |
5023 |
|
!!!next-input-character; |
5024 |
|
redo A; |
5025 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
5026 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
5027 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5028 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5029 |
!!!next-input-character; |
!!!next-input-character; |
5030 |
!!!emit ($self->{ct}); # ENTITY |
!!!emit ($self->{ct}); # ELEMENT |
5031 |
redo A; |
redo A; |
5032 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
5033 |
!!!parse-error (type => 'unclosed md'); ## TODO: type |
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5034 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5035 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5036 |
!!!next-input-character; |
!!!next-input-character; |
5037 |
!!!emit ($self->{ct}); # ENTITY |
!!!emit ($self->{ct}); # ELEMENT |
5038 |
redo A; |
redo A; |
5039 |
} else { |
} else { |
5040 |
!!!parse-error (type => 'string after notation name'); ## TODO: type |
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5041 |
|
$self->{state} = CM_ELEMENT_NAME_STATE; |
5042 |
|
!!!next-input-character; |
5043 |
|
redo A; |
5044 |
|
} |
5045 |
|
} elsif ($self->{state} == CM_ELEMENT_NAME_STATE) { |
5046 |
|
if ($is_space->{$self->{nc}}) { |
5047 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5048 |
|
!!!next-input-character; |
5049 |
|
redo A; |
5050 |
|
} elsif ($self->{nc} == 0x002A or # * |
5051 |
|
$self->{nc} == 0x002B or # + |
5052 |
|
$self->{nc} == 0x003F) { # ? |
5053 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5054 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5055 |
|
!!!next-input-character; |
5056 |
|
redo A; |
5057 |
|
} elsif ($self->{nc} == 0x007C or # | |
5058 |
|
$self->{nc} == 0x002C) { # , |
5059 |
|
push @{$self->{ct}->{content}}, $self->{nc} == 0x007C ? ' | ' : ', '; |
5060 |
|
$self->{state} = AFTER_CM_GROUP_OPEN_STATE; |
5061 |
|
!!!next-input-character; |
5062 |
|
redo A; |
5063 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
5064 |
|
$self->{group_depth}--; |
5065 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5066 |
|
$self->{state} = AFTER_CM_GROUP_CLOSE_STATE; |
5067 |
|
!!!next-input-character; |
5068 |
|
redo A; |
5069 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5070 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
5071 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5072 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5073 |
|
!!!next-input-character; |
5074 |
|
!!!emit ($self->{ct}); # ELEMENT |
5075 |
|
redo A; |
5076 |
|
} elsif ($self->{nc} == -1) { |
5077 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5078 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5079 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5080 |
|
!!!next-input-character; |
5081 |
|
!!!emit ($self->{ct}); # ELEMENT |
5082 |
|
redo A; |
5083 |
|
} else { |
5084 |
|
$self->{ct}->{content}->[-1] .= chr $self->{nc}; |
5085 |
|
## Stay in the state. |
5086 |
|
!!!next-input-character; |
5087 |
|
redo A; |
5088 |
|
} |
5089 |
|
} elsif ($self->{state} == AFTER_CM_ELEMENT_NAME_STATE) { |
5090 |
|
if ($is_space->{$self->{nc}}) { |
5091 |
|
## Stay in the state. |
5092 |
|
!!!next-input-character; |
5093 |
|
redo A; |
5094 |
|
} elsif ($self->{nc} == 0x007C or # | |
5095 |
|
$self->{nc} == 0x002C) { # , |
5096 |
|
push @{$self->{ct}->{content}}, $self->{nc} == 0x007C ? ' | ' : ', '; |
5097 |
|
$self->{state} = AFTER_CM_GROUP_OPEN_STATE; |
5098 |
|
!!!next-input-character; |
5099 |
|
redo A; |
5100 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
5101 |
|
$self->{group_depth}--; |
5102 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5103 |
|
$self->{state} = AFTER_CM_GROUP_CLOSE_STATE; |
5104 |
|
!!!next-input-character; |
5105 |
|
redo A; |
5106 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5107 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
5108 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5109 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5110 |
|
!!!next-input-character; |
5111 |
|
!!!emit ($self->{ct}); # ELEMENT |
5112 |
|
redo A; |
5113 |
|
} elsif ($self->{nc} == -1) { |
5114 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5115 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5116 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5117 |
|
!!!next-input-character; |
5118 |
|
!!!emit ($self->{ct}); # ELEMENT |
5119 |
|
redo A; |
5120 |
|
} else { |
5121 |
|
!!!parse-error (type => 'after element name'); ## TODO: type |
5122 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5123 |
|
$self->{state} = BOGUS_MD_STATE; |
5124 |
|
!!!next-input-character; |
5125 |
|
redo A; |
5126 |
|
} |
5127 |
|
} elsif ($self->{state} == AFTER_CM_GROUP_CLOSE_STATE) { |
5128 |
|
if ($is_space->{$self->{nc}}) { |
5129 |
|
if ($self->{group_depth}) { |
5130 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5131 |
|
} else { |
5132 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
5133 |
|
} |
5134 |
|
!!!next-input-character; |
5135 |
|
redo A; |
5136 |
|
} elsif ($self->{nc} == 0x002A or # * |
5137 |
|
$self->{nc} == 0x002B or # + |
5138 |
|
$self->{nc} == 0x003F) { # ? |
5139 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5140 |
|
if ($self->{group_depth}) { |
5141 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5142 |
|
} else { |
5143 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
5144 |
|
} |
5145 |
|
!!!next-input-character; |
5146 |
|
redo A; |
5147 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
5148 |
|
if ($self->{group_depth}) { |
5149 |
|
$self->{group_depth}--; |
5150 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5151 |
|
## Stay in the state. |
5152 |
|
!!!next-input-character; |
5153 |
|
redo A; |
5154 |
|
} else { |
5155 |
|
!!!parse-error (type => 'string after md def'); ## TODO: type |
5156 |
|
$self->{state} = BOGUS_MD_STATE; |
5157 |
|
## Reconsume. |
5158 |
|
redo A; |
5159 |
|
} |
5160 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5161 |
|
if ($self->{group_depth}) { |
5162 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
5163 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5164 |
|
} |
5165 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5166 |
|
!!!next-input-character; |
5167 |
|
!!!emit ($self->{ct}); # ELEMENT |
5168 |
|
redo A; |
5169 |
|
} elsif ($self->{nc} == -1) { |
5170 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5171 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5172 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5173 |
|
!!!next-input-character; |
5174 |
|
!!!emit ($self->{ct}); # ELEMENT |
5175 |
|
redo A; |
5176 |
|
} else { |
5177 |
|
if ($self->{group_depth}) { |
5178 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5179 |
|
} else { |
5180 |
|
!!!parse-error (type => 'string after md def'); ## TODO: type |
5181 |
|
$self->{state} = BOGUS_MD_STATE; |
5182 |
|
} |
5183 |
|
## Reconsume. |
5184 |
|
redo A; |
5185 |
|
} |
5186 |
|
} elsif ($self->{state} == AFTER_MD_DEF_STATE) { |
5187 |
|
if ($is_space->{$self->{nc}}) { |
5188 |
|
## Stay in the state. |
5189 |
|
!!!next-input-character; |
5190 |
|
redo A; |
5191 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5192 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5193 |
|
!!!next-input-character; |
5194 |
|
!!!emit ($self->{ct}); # ENTITY/ELEMENT |
5195 |
|
redo A; |
5196 |
|
} elsif ($self->{nc} == -1) { |
5197 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5198 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5199 |
|
!!!next-input-character; |
5200 |
|
!!!emit ($self->{ct}); # ENTITY/ELEMENT |
5201 |
|
redo A; |
5202 |
|
} else { |
5203 |
|
!!!parse-error (type => 'string after md def'); ## TODO: type |
5204 |
$self->{state} = BOGUS_MD_STATE; |
$self->{state} = BOGUS_MD_STATE; |
5205 |
## Reconsume. |
## Reconsume. |
5206 |
redo A; |
redo A; |
5207 |
} |
} |
|
|
|
|
|
|
5208 |
} elsif ($self->{state} == BOGUS_MD_STATE) { |
} elsif ($self->{state} == BOGUS_MD_STATE) { |
5209 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
5210 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |