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 } |
206 |
## Character reference mappings |
## Character reference mappings |
207 |
|
|
208 |
my $charref_map = { |
my $charref_map = { |
209 |
|
0x00 => 0xFFFD, # REPLACEMENT CHARACTER |
210 |
0x0D => 0x000A, |
0x0D => 0x000A, |
211 |
0x80 => 0x20AC, |
0x80 => 0x20AC, |
212 |
0x81 => 0xFFFD, |
0x81 => 0x0081, |
213 |
0x82 => 0x201A, |
0x82 => 0x201A, |
214 |
0x83 => 0x0192, |
0x83 => 0x0192, |
215 |
0x84 => 0x201E, |
0x84 => 0x201E, |
221 |
0x8A => 0x0160, |
0x8A => 0x0160, |
222 |
0x8B => 0x2039, |
0x8B => 0x2039, |
223 |
0x8C => 0x0152, |
0x8C => 0x0152, |
224 |
0x8D => 0xFFFD, |
0x8D => 0x008D, |
225 |
0x8E => 0x017D, |
0x8E => 0x017D, |
226 |
0x8F => 0xFFFD, |
0x8F => 0x008F, |
227 |
0x90 => 0xFFFD, |
0x90 => 0x0090, |
228 |
0x91 => 0x2018, |
0x91 => 0x2018, |
229 |
0x92 => 0x2019, |
0x92 => 0x2019, |
230 |
0x93 => 0x201C, |
0x93 => 0x201C, |
237 |
0x9A => 0x0161, |
0x9A => 0x0161, |
238 |
0x9B => 0x203A, |
0x9B => 0x203A, |
239 |
0x9C => 0x0153, |
0x9C => 0x0153, |
240 |
0x9D => 0xFFFD, |
0x9D => 0x009D, |
241 |
0x9E => 0x017E, |
0x9E => 0x017E, |
242 |
0x9F => 0x0178, |
0x9F => 0x0178, |
243 |
}; # $charref_map |
}; # $charref_map |
244 |
$charref_map->{$_} = 0xFFFD |
$charref_map->{$_} = $_ |
245 |
for 0x0000..0x0008, 0x000B, 0x000E..0x001F, 0x007F, |
for 0x0001..0x0008, 0x000B, 0x000E..0x001F, 0x007F, |
246 |
0xD800..0xDFFF, 0xFDD0..0xFDDF, ## ISSUE: 0xFDEF |
0xD800..0xDFFF, 0xFDD0..0xFDEF, |
247 |
0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, |
0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, |
248 |
0x4FFFE, 0x4FFFF, 0x5FFFE, 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, |
0x4FFFE, 0x4FFFF, 0x5FFFE, 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, |
249 |
0x7FFFF, 0x8FFFE, 0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, |
0x7FFFF, 0x8FFFE, 0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, |
863 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
864 |
# reconsume |
# reconsume |
865 |
|
|
866 |
!!!emit ($self->{ct}); # start tag or end tag |
## Discard the token. |
867 |
|
#!!!emit ($self->{ct}); # start tag or end tag |
868 |
|
|
869 |
redo A; |
redo A; |
870 |
} elsif ($self->{nc} == 0x002F) { # / |
} elsif ($self->{nc} == 0x002F) { # / |
945 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
946 |
# reconsume |
# reconsume |
947 |
|
|
948 |
!!!emit ($self->{ct}); # start tag or end tag |
## Discard the token. |
949 |
|
#!!!emit ($self->{ct}); # start tag or end tag |
950 |
|
|
951 |
redo A; |
redo A; |
952 |
} else { |
} else { |
953 |
if ({ |
if ({ |
954 |
0x0022 => 1, # " |
0x0022 => 1, # " |
955 |
0x0027 => 1, # ' |
0x0027 => 1, # ' |
956 |
|
0x003C => 1, # < |
957 |
0x003D => 1, # = |
0x003D => 1, # = |
958 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
959 |
!!!cp (55); |
!!!cp (55); |
1072 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
1073 |
# reconsume |
# reconsume |
1074 |
|
|
1075 |
!!!emit ($self->{ct}); # start tag or end tag |
## Discard the token. |
1076 |
|
#!!!emit ($self->{ct}); # start tag or end tag |
1077 |
|
|
1078 |
redo A; |
redo A; |
1079 |
} else { |
} else { |
1080 |
if ($self->{nc} == 0x0022 or # " |
if ({ |
1081 |
$self->{nc} == 0x0027) { # ' |
0x0022 => 1, # " |
1082 |
|
0x0027 => 1, # ' |
1083 |
|
0x003C => 1, # < |
1084 |
|
}->{$self->{nc}}) { |
1085 |
!!!cp (69); |
!!!cp (69); |
1086 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1087 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
1180 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1181 |
# reconsume |
# reconsume |
1182 |
|
|
1183 |
!!!emit ($self->{ct}); # start tag or end tag |
## Discard the token. |
1184 |
|
#!!!emit ($self->{ct}); # start tag or end tag |
1185 |
|
|
1186 |
redo A; |
redo A; |
1187 |
} else { |
} else { |
1193 |
!!!cp (78.2); |
!!!cp (78.2); |
1194 |
} |
} |
1195 |
|
|
1196 |
if ($self->{nc} == 0x0022 or # " |
if ({ |
1197 |
$self->{nc} == 0x0027) { # ' |
0x0022 => 1, # " |
1198 |
|
0x0027 => 1, # ' |
1199 |
|
0x003C => 1, # < |
1200 |
|
}->{$self->{nc}}) { |
1201 |
!!!cp (78); |
!!!cp (78); |
1202 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1203 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
1280 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
1281 |
## reconsume |
## reconsume |
1282 |
|
|
1283 |
!!!emit ($self->{ct}); # start tag or end tag |
## Discard the token. |
1284 |
|
#!!!emit ($self->{ct}); # start tag or end tag |
1285 |
|
|
1286 |
redo A; |
redo A; |
1287 |
} else { |
} else { |
1288 |
if ($self->{nc} == 0x003D) { # = |
if ($self->{nc} == 0x003D or $self->{nc} == 0x003C) { # =, < |
1289 |
!!!cp (93); |
!!!cp (93); |
1290 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1291 |
!!!parse-error (type => 'bad attribute value'); |
!!!parse-error (type => 'bad attribute value'); |
1331 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1332 |
!!!next-input-character; |
!!!next-input-character; |
1333 |
redo A; |
redo A; |
1334 |
|
} elsif ($self->{is_xml} and |
1335 |
|
$is_space->{$self->{nc}}) { |
1336 |
|
!!!cp (97.1); |
1337 |
|
$self->{ca}->{value} .= ' '; |
1338 |
|
## Stay in the state. |
1339 |
|
!!!next-input-character; |
1340 |
|
redo A; |
1341 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
1342 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
1343 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1362 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1363 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
1364 |
## reconsume |
## reconsume |
1365 |
!!!emit ($self->{ct}); # end tag |
|
1366 |
|
## Discard the token. |
1367 |
|
#!!!emit ($self->{ct}); # end tag |
1368 |
|
|
1369 |
redo A; |
redo A; |
1370 |
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1371 |
## XML5: No parse error above; not defined yet. |
## XML5: No parse error above; not defined yet. |
1372 |
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1373 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1374 |
## Reconsume. |
## Reconsume. |
1375 |
!!!emit ($self->{ct}); # ATTLIST |
|
1376 |
|
## Discard the token. |
1377 |
|
#!!!emit ($self->{ct}); # ATTLIST |
1378 |
|
|
1379 |
redo A; |
redo A; |
1380 |
} else { |
} else { |
1381 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1391 |
} |
} |
1392 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1393 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1394 |
q["&<], |
qq["&<\x09\x0C\x20], |
1395 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1396 |
|
|
1397 |
## Stay in the state |
## Stay in the state |
1428 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1429 |
!!!next-input-character; |
!!!next-input-character; |
1430 |
redo A; |
redo A; |
1431 |
|
} elsif ($self->{is_xml} and |
1432 |
|
$is_space->{$self->{nc}}) { |
1433 |
|
!!!cp (103.1); |
1434 |
|
$self->{ca}->{value} .= ' '; |
1435 |
|
## Stay in the state. |
1436 |
|
!!!next-input-character; |
1437 |
|
redo A; |
1438 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
1439 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
1440 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1444 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1445 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
1446 |
## reconsume |
## reconsume |
1447 |
!!!emit ($self->{ct}); # start tag |
|
1448 |
|
## Discard the token. |
1449 |
|
#!!!emit ($self->{ct}); # start tag |
1450 |
|
|
1451 |
redo A; |
redo A; |
1452 |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1453 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1462 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1463 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
1464 |
## reconsume |
## reconsume |
1465 |
!!!emit ($self->{ct}); # end tag |
|
1466 |
|
## Discard the token. |
1467 |
|
#!!!emit ($self->{ct}); # end tag |
1468 |
|
|
1469 |
redo A; |
redo A; |
1470 |
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1471 |
## XML5: No parse error above; not defined yet. |
## XML5: No parse error above; not defined yet. |
1472 |
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1473 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1474 |
## Reconsume. |
## Reconsume. |
1475 |
!!!emit ($self->{ct}); # ATTLIST |
|
1476 |
|
## Discard the token. |
1477 |
|
#!!!emit ($self->{ct}); # ATTLIST |
1478 |
|
|
1479 |
redo A; |
redo A; |
1480 |
} else { |
} else { |
1481 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1491 |
} |
} |
1492 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1493 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1494 |
q['&<], |
qq['&<\x09\x0C\x20], |
1495 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1496 |
|
|
1497 |
## Stay in the state |
## Stay in the state |
1570 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1571 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
1572 |
## reconsume |
## reconsume |
1573 |
!!!emit ($self->{ct}); # start tag |
|
1574 |
|
## Discard the token. |
1575 |
|
#!!!emit ($self->{ct}); # start tag |
1576 |
|
|
1577 |
redo A; |
redo A; |
1578 |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1579 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
1589 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1590 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
1591 |
## reconsume |
## reconsume |
1592 |
!!!emit ($self->{ct}); # end tag |
|
1593 |
|
## Discard the token. |
1594 |
|
#!!!emit ($self->{ct}); # end tag |
1595 |
|
|
1596 |
redo A; |
redo A; |
1597 |
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1598 |
!!!parse-error (type => 'unclosed md'); ## TODO: type |
!!!parse-error (type => 'unclosed md'); ## TODO: type |
1599 |
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1600 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1601 |
## Reconsume. |
## Reconsume. |
1602 |
!!!emit ($self->{ct}); # ATTLIST |
|
1603 |
|
## Discard the token. |
1604 |
|
#!!!emit ($self->{ct}); # ATTLIST |
1605 |
|
|
1606 |
redo A; |
redo A; |
1607 |
} else { |
} else { |
1608 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1612 |
0x0022 => 1, # " |
0x0022 => 1, # " |
1613 |
0x0027 => 1, # ' |
0x0027 => 1, # ' |
1614 |
0x003D => 1, # = |
0x003D => 1, # = |
1615 |
|
0x003C => 1, # < |
1616 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
1617 |
!!!cp (115); |
!!!cp (115); |
1618 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1622 |
} |
} |
1623 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1624 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1625 |
q["'=& >], |
qq["'=& \x09\x0C>], |
1626 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1627 |
|
|
1628 |
## Stay in the state |
## Stay in the state |
1682 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1683 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
1684 |
## Reconsume. |
## Reconsume. |
1685 |
!!!emit ($self->{ct}); # start tag or end tag |
|
1686 |
|
## Discard the token. |
1687 |
|
#!!!emit ($self->{ct}); # start tag or end tag |
1688 |
|
|
1689 |
redo A; |
redo A; |
1690 |
} else { |
} else { |
1691 |
!!!cp ('124.1'); |
!!!cp ('124.1'); |
1742 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1743 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
1744 |
## Reconsume. |
## Reconsume. |
1745 |
!!!emit ($self->{ct}); # start tag or end tag |
|
1746 |
|
## Discard the token. |
1747 |
|
#!!!emit ($self->{ct}); # start tag or end tag |
1748 |
|
|
1749 |
redo A; |
redo A; |
1750 |
} else { |
} else { |
1751 |
!!!cp ('124.4'); |
!!!cp ('124.4'); |
2120 |
!!!next-input-character; |
!!!next-input-character; |
2121 |
redo A; |
redo A; |
2122 |
} |
} |
2123 |
} elsif ($self->{state} == COMMENT_END_STATE) { |
} elsif ($self->{state} == COMMENT_END_STATE or |
2124 |
|
$self->{state} == COMMENT_END_BANG_STATE) { |
2125 |
## XML5: "Comment end state" and "DOCTYPE comment end state". |
## XML5: "Comment end state" and "DOCTYPE comment end state". |
2126 |
|
## (No comment end bang state.) |
2127 |
|
|
2128 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
2129 |
if ($self->{in_subset}) { |
if ($self->{in_subset}) { |
2140 |
|
|
2141 |
redo A; |
redo A; |
2142 |
} elsif ($self->{nc} == 0x002D) { # - |
} elsif ($self->{nc} == 0x002D) { # - |
2143 |
!!!cp (152); |
if ($self->{state} == COMMENT_END_BANG_STATE) { |
2144 |
## XML5: Not a parse error. |
!!!cp (154.3); |
2145 |
!!!parse-error (type => 'dash in comment', |
$self->{ct}->{data} .= '--!'; # comment |
2146 |
line => $self->{line_prev}, |
$self->{state} = COMMENT_END_DASH_STATE; |
2147 |
column => $self->{column_prev}); |
} else { |
2148 |
$self->{ct}->{data} .= '-'; # comment |
!!!cp (152); |
2149 |
## Stay in the state |
## XML5: Not a parse error. |
2150 |
|
!!!parse-error (type => 'dash in comment', |
2151 |
|
line => $self->{line_prev}, |
2152 |
|
column => $self->{column_prev}); |
2153 |
|
$self->{ct}->{data} .= '-'; # comment |
2154 |
|
## Stay in the state |
2155 |
|
} |
2156 |
|
!!!next-input-character; |
2157 |
|
redo A; |
2158 |
|
} elsif ($self->{state} != COMMENT_END_BANG_STATE and |
2159 |
|
$is_space->{$self->{nc}}) { |
2160 |
|
!!!cp (152.1); |
2161 |
|
!!!parse-error (type => 'comment end space'); # XXX error type |
2162 |
|
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
2163 |
|
$self->{state} = COMMENT_END_SPACE_STATE; |
2164 |
|
!!!next-input-character; |
2165 |
|
redo A; |
2166 |
|
} elsif ($self->{state} != COMMENT_END_BANG_STATE and |
2167 |
|
$self->{nc} == 0x0021) { # ! |
2168 |
|
!!!cp (152.2); |
2169 |
|
!!!parse-error (type => 'comment end bang'); # XXX error type |
2170 |
|
$self->{state} = COMMENT_END_BANG_STATE; |
2171 |
!!!next-input-character; |
!!!next-input-character; |
2172 |
redo A; |
redo A; |
2173 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2180 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2181 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
2182 |
} |
} |
2183 |
## reconsume |
## Reconsume. |
2184 |
|
|
2185 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
2186 |
|
|
2187 |
redo A; |
redo A; |
2188 |
} else { |
} else { |
2189 |
!!!cp (154); |
!!!cp (154); |
2190 |
## XML5: Not a parse error. |
if ($self->{state} == COMMENT_END_BANG_STATE) { |
2191 |
!!!parse-error (type => 'dash in comment', |
$self->{ct}->{data} .= '--!' . chr ($self->{nc}); # comment |
2192 |
line => $self->{line_prev}, |
} else { |
2193 |
column => $self->{column_prev}); |
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
2194 |
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
} |
2195 |
$self->{state} = COMMENT_STATE; |
$self->{state} = COMMENT_STATE; |
2196 |
!!!next-input-character; |
!!!next-input-character; |
2197 |
redo A; |
redo A; |
2198 |
} |
} |
2199 |
|
} elsif ($self->{state} == COMMENT_END_SPACE_STATE) { |
2200 |
|
## XML5: Not exist. |
2201 |
|
|
2202 |
|
if ($self->{nc} == 0x003E) { # > |
2203 |
|
if ($self->{in_subset}) { |
2204 |
|
!!!cp (154.4); |
2205 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2206 |
|
} else { |
2207 |
|
!!!cp (154.5); |
2208 |
|
$self->{state} = DATA_STATE; |
2209 |
|
$self->{s_kwd} = ''; |
2210 |
|
} |
2211 |
|
!!!next-input-character; |
2212 |
|
|
2213 |
|
!!!emit ($self->{ct}); # comment |
2214 |
|
|
2215 |
|
redo A; |
2216 |
|
} elsif ($is_space->{$self->{nc}}) { |
2217 |
|
!!!cp (154.6); |
2218 |
|
$self->{ct}->{data} .= chr ($self->{nc}); # comment |
2219 |
|
## Stay in the state. |
2220 |
|
!!!next-input-character; |
2221 |
|
redo A; |
2222 |
|
} elsif ($self->{nc} == -1) { |
2223 |
|
!!!parse-error (type => 'unclosed comment'); |
2224 |
|
if ($self->{in_subset}) { |
2225 |
|
!!!cp (154.7); |
2226 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2227 |
|
} else { |
2228 |
|
!!!cp (154.8); |
2229 |
|
$self->{state} = DATA_STATE; |
2230 |
|
$self->{s_kwd} = ''; |
2231 |
|
} |
2232 |
|
## Reconsume. |
2233 |
|
|
2234 |
|
!!!emit ($self->{ct}); # comment |
2235 |
|
|
2236 |
|
redo A; |
2237 |
|
} else { |
2238 |
|
!!!cp (154.9); |
2239 |
|
$self->{ct}->{data} .= chr ($self->{nc}); # comment |
2240 |
|
$self->{state} = COMMENT_STATE; |
2241 |
|
!!!next-input-character; |
2242 |
|
redo A; |
2243 |
|
} |
2244 |
} elsif ($self->{state} == DOCTYPE_STATE) { |
} elsif ($self->{state} == DOCTYPE_STATE) { |
2245 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
2246 |
!!!cp (155); |
!!!cp (155); |
2247 |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
2248 |
!!!next-input-character; |
!!!next-input-character; |
2249 |
redo A; |
redo A; |
2250 |
|
} elsif ($self->{nc} == -1) { |
2251 |
|
!!!cp (155.1); |
2252 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
2253 |
|
$self->{ct}->{quirks} = 1; |
2254 |
|
|
2255 |
|
$self->{state} = DATA_STATE; |
2256 |
|
## Reconsume. |
2257 |
|
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
2258 |
|
|
2259 |
|
redo A; |
2260 |
} else { |
} else { |
2261 |
!!!cp (156); |
!!!cp (156); |
2262 |
## XML5: Unless EOF, swith to the bogus comment state. |
## XML5: Swith to the bogus comment state. |
2263 |
!!!parse-error (type => 'no space before DOCTYPE name'); |
!!!parse-error (type => 'no space before DOCTYPE name'); |
2264 |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
2265 |
## reconsume |
## reconsume |
2284 |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
2285 |
|
|
2286 |
redo A; |
redo A; |
2287 |
|
} elsif (0x0041 <= $self->{nc} and $self->{nc} <= 0x005A) { # A..Z |
2288 |
|
!!!cp (158.1); |
2289 |
|
$self->{ct}->{name} # DOCTYPE |
2290 |
|
= chr ($self->{nc} + ($self->{is_xml} ? 0 : 0x0020)); |
2291 |
|
delete $self->{ct}->{quirks}; |
2292 |
|
$self->{state} = DOCTYPE_NAME_STATE; |
2293 |
|
!!!next-input-character; |
2294 |
|
redo A; |
2295 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2296 |
!!!cp (159); |
!!!cp (159); |
2297 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
2338 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2339 |
|
|
2340 |
redo A; |
redo A; |
2341 |
|
} elsif (0x0041 <= $self->{nc} and $self->{nc} <= 0x005A) { # A..Z |
2342 |
|
!!!cp (162.1); |
2343 |
|
$self->{ct}->{name} # DOCTYPE |
2344 |
|
.= chr ($self->{nc} + ($self->{is_xml} ? 0 : 0x0020)); |
2345 |
|
delete $self->{ct}->{quirks}; |
2346 |
|
## Stay in the state. |
2347 |
|
!!!next-input-character; |
2348 |
|
redo A; |
2349 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2350 |
!!!cp (163); |
!!!cp (163); |
2351 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2367 |
redo A; |
redo A; |
2368 |
} else { |
} else { |
2369 |
!!!cp (164); |
!!!cp (164); |
2370 |
$self->{ct}->{name} |
$self->{ct}->{name} .= chr ($self->{nc}); # DOCTYPE |
2371 |
.= chr ($self->{nc}); # DOCTYPE |
## Stay in the state. |
|
## Stay in the state |
|
2372 |
!!!next-input-character; |
!!!next-input-character; |
2373 |
redo A; |
redo A; |
2374 |
} |
} |
3370 |
my $code = $self->{kwd}; |
my $code = $self->{kwd}; |
3371 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3372 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3373 |
if ($charref_map->{$code}) { |
if ((not $self->{is_xml} and $charref_map->{$code}) or |
3374 |
|
($self->{is_xml} and 0xD800 <= $code and $code <= 0xDFFF) or |
3375 |
|
($self->{is_xml} and $code == 0x0000)) { |
3376 |
!!!cp (1015); |
!!!cp (1015); |
3377 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
3378 |
text => (sprintf 'U+%04X', $code), |
text => (sprintf 'U+%04X', $code), |
3485 |
my $code = $self->{kwd}; |
my $code = $self->{kwd}; |
3486 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3487 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3488 |
if ($charref_map->{$code}) { |
if ((not $self->{is_xml} and $charref_map->{$code}) or |
3489 |
|
($self->{is_xml} and 0xD800 <= $code and $code <= 0xDFFF) or |
3490 |
|
($self->{is_xml} and $code == 0x0000)) { |
3491 |
!!!cp (1008); |
!!!cp (1008); |
3492 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
3493 |
text => (sprintf 'U+%04X', $code), |
text => (sprintf 'U+%04X', $code), |
3816 |
## XML5: Not defined yet. |
## XML5: Not defined yet. |
3817 |
|
|
3818 |
## TODO: |
## TODO: |
3819 |
|
|
3820 |
|
if (not $self->{stop_processing} and |
3821 |
|
not $self->{document}->xml_standalone) { |
3822 |
|
!!!parse-error (type => 'stop processing', ## TODO: type |
3823 |
|
level => $self->{level}->{info}); |
3824 |
|
$self->{stop_processing} = 1; |
3825 |
|
} |
3826 |
|
|
3827 |
!!!next-input-character; |
!!!next-input-character; |
3828 |
redo A; |
redo A; |
3829 |
} elsif ($self->{nc} == 0x005D) { # ] |
} elsif ($self->{nc} == 0x005D) { # ] |