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) |
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 |
} |
} |
2425 |
$self->{kwd} = chr $self->{nc}; |
$self->{kwd} = chr $self->{nc}; |
2426 |
!!!next-input-character; |
!!!next-input-character; |
2427 |
redo A; |
redo A; |
2428 |
## TODO: " and ' for ENTITY |
} elsif ($self->{nc} == 0x0022 and # " |
2429 |
|
($self->{ct}->{type} == GENERAL_ENTITY_TOKEN or |
2430 |
|
$self->{ct}->{type} == PARAMETER_ENTITY_TOKEN)) { |
2431 |
|
!!!cp (167.21); |
2432 |
|
$self->{state} = DOCTYPE_ENTITY_VALUE_DOUBLE_QUOTED_STATE; |
2433 |
|
$self->{ct}->{value} = ''; # ENTITY |
2434 |
|
!!!next-input-character; |
2435 |
|
redo A; |
2436 |
|
} elsif ($self->{nc} == 0x0027 and # ' |
2437 |
|
($self->{ct}->{type} == GENERAL_ENTITY_TOKEN or |
2438 |
|
$self->{ct}->{type} == PARAMETER_ENTITY_TOKEN)) { |
2439 |
|
!!!cp (167.22); |
2440 |
|
$self->{state} = DOCTYPE_ENTITY_VALUE_SINGLE_QUOTED_STATE; |
2441 |
|
$self->{ct}->{value} = ''; # ENTITY |
2442 |
|
!!!next-input-character; |
2443 |
|
redo A; |
2444 |
} elsif ($self->{is_xml} and |
} elsif ($self->{is_xml} and |
2445 |
$self->{ct}->{type} == DOCTYPE_TOKEN and |
$self->{ct}->{type} == DOCTYPE_TOKEN and |
2446 |
$self->{nc} == 0x005B) { # [ |
$self->{nc} == 0x005B) { # [ |
3231 |
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
3232 |
$self->{entity_add} => 1, |
$self->{entity_add} => 1, |
3233 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
3234 |
!!!cp (1001); |
if ($self->{is_xml}) { |
3235 |
|
!!!cp (1001.1); |
3236 |
|
!!!parse-error (type => 'bare ero', |
3237 |
|
line => $self->{line_prev}, |
3238 |
|
column => $self->{column_prev} |
3239 |
|
+ ($self->{nc} == -1 ? 1 : 0)); |
3240 |
|
} else { |
3241 |
|
!!!cp (1001); |
3242 |
|
## No error |
3243 |
|
} |
3244 |
## Don't consume |
## Don't consume |
|
## No error |
|
3245 |
## Return nothing. |
## Return nothing. |
3246 |
# |
# |
3247 |
} elsif ($self->{nc} == 0x0023) { # # |
} elsif ($self->{nc} == 0x0023) { # # |
3250 |
$self->{kwd} = '#'; |
$self->{kwd} = '#'; |
3251 |
!!!next-input-character; |
!!!next-input-character; |
3252 |
redo A; |
redo A; |
3253 |
} elsif ((0x0041 <= $self->{nc} and |
} elsif ($self->{is_xml} or |
3254 |
|
(0x0041 <= $self->{nc} and |
3255 |
$self->{nc} <= 0x005A) or # A..Z |
$self->{nc} <= 0x005A) or # A..Z |
3256 |
(0x0061 <= $self->{nc} and |
(0x0061 <= $self->{nc} and |
3257 |
$self->{nc} <= 0x007A)) { # a..z |
$self->{nc} <= 0x007A)) { # a..z |
3295 |
redo A; |
redo A; |
3296 |
} |
} |
3297 |
} elsif ($self->{state} == ENTITY_HASH_STATE) { |
} elsif ($self->{state} == ENTITY_HASH_STATE) { |
3298 |
if ($self->{nc} == 0x0078 or # x |
if ($self->{nc} == 0x0078) { # x |
|
$self->{nc} == 0x0058) { # X |
|
3299 |
!!!cp (995); |
!!!cp (995); |
3300 |
$self->{state} = HEXREF_X_STATE; |
$self->{state} = HEXREF_X_STATE; |
3301 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3302 |
!!!next-input-character; |
!!!next-input-character; |
3303 |
redo A; |
redo A; |
3304 |
|
} elsif ($self->{nc} == 0x0058) { # X |
3305 |
|
!!!cp (995.1); |
3306 |
|
if ($self->{is_xml}) { |
3307 |
|
!!!parse-error (type => 'uppercase hcro'); ## TODO: type |
3308 |
|
} |
3309 |
|
$self->{state} = HEXREF_X_STATE; |
3310 |
|
$self->{kwd} .= chr $self->{nc}; |
3311 |
|
!!!next-input-character; |
3312 |
|
redo A; |
3313 |
} elsif (0x0030 <= $self->{nc} and |
} elsif (0x0030 <= $self->{nc} and |
3314 |
$self->{nc} <= 0x0039) { # 0..9 |
$self->{nc} <= 0x0039) { # 0..9 |
3315 |
!!!cp (994); |
!!!cp (994); |
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), |
3521 |
redo A; |
redo A; |
3522 |
} |
} |
3523 |
} elsif ($self->{state} == ENTITY_NAME_STATE) { |
} elsif ($self->{state} == ENTITY_NAME_STATE) { |
3524 |
if (length $self->{kwd} < 30 and |
if ((0x0041 <= $self->{nc} and # a |
3525 |
## NOTE: Some number greater than the maximum length of entity name |
$self->{nc} <= 0x005A) or # x |
3526 |
((0x0041 <= $self->{nc} and # a |
(0x0061 <= $self->{nc} and # a |
3527 |
$self->{nc} <= 0x005A) or # x |
$self->{nc} <= 0x007A) or # z |
3528 |
(0x0061 <= $self->{nc} and # a |
(0x0030 <= $self->{nc} and # 0 |
3529 |
$self->{nc} <= 0x007A) or # z |
$self->{nc} <= 0x0039) or # 9 |
3530 |
(0x0030 <= $self->{nc} and # 0 |
$self->{nc} == 0x003B or # ; |
3531 |
$self->{nc} <= 0x0039) or # 9 |
($self->{is_xml} and |
3532 |
$self->{nc} == 0x003B)) { # ; |
not ($is_space->{$self->{nc}} or |
3533 |
|
{ |
3534 |
|
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
3535 |
|
$self->{entity_add} => 1, |
3536 |
|
}->{$self->{nc}}))) { |
3537 |
our $EntityChar; |
our $EntityChar; |
3538 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3539 |
if (defined $EntityChar->{$self->{kwd}}) { |
if (defined $EntityChar->{$self->{kwd}} or |
3540 |
|
$self->{ge}->{$self->{kwd}}) { |
3541 |
if ($self->{nc} == 0x003B) { # ; |
if ($self->{nc} == 0x003B) { # ; |
3542 |
!!!cp (1020); |
if (defined $self->{ge}->{$self->{kwd}}) { |
3543 |
$self->{entity__value} = $EntityChar->{$self->{kwd}}; |
if ($self->{ge}->{$self->{kwd}}->{only_text}) { |
3544 |
|
!!!cp (1020.1); |
3545 |
|
$self->{entity__value} = $self->{ge}->{$self->{kwd}}->{value}; |
3546 |
|
} else { |
3547 |
|
if (defined $self->{ge}->{$self->{kwd}}->{notation}) { |
3548 |
|
!!!cp (1020.2); |
3549 |
|
!!!parse-error (type => 'unparsed entity', ## TODO: type |
3550 |
|
value => $self->{kwd}); |
3551 |
|
} else { |
3552 |
|
!!!cp (1020.3); |
3553 |
|
} |
3554 |
|
$self->{entity__value} = '&' . $self->{kwd}; ## TODO: expand |
3555 |
|
} |
3556 |
|
} else { |
3557 |
|
if ($self->{is_xml}) { |
3558 |
|
!!!cp (1020.4); |
3559 |
|
!!!parse-error (type => 'entity not declared', ## TODO: type |
3560 |
|
value => $self->{kwd}, |
3561 |
|
level => { |
3562 |
|
'amp;' => $self->{level}->{warn}, |
3563 |
|
'quot;' => $self->{level}->{warn}, |
3564 |
|
'lt;' => $self->{level}->{warn}, |
3565 |
|
'gt;' => $self->{level}->{warn}, |
3566 |
|
'apos;' => $self->{level}->{warn}, |
3567 |
|
}->{$self->{kwd}} || |
3568 |
|
$self->{level}->{must}); |
3569 |
|
} else { |
3570 |
|
!!!cp (1020); |
3571 |
|
} |
3572 |
|
$self->{entity__value} = $EntityChar->{$self->{kwd}}; |
3573 |
|
} |
3574 |
$self->{entity__match} = 1; |
$self->{entity__match} = 1; |
3575 |
!!!next-input-character; |
!!!next-input-character; |
3576 |
# |
# |
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) { # ] |
4058 |
} |
} |
4059 |
$self->{ct} = {type => ELEMENT_TOKEN, name => '', |
$self->{ct} = {type => ELEMENT_TOKEN, name => '', |
4060 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
4061 |
column => $self->{column_prev} - 6}; |
column => $self->{column_prev} - 7}; |
4062 |
$self->{state} = DOCTYPE_MD_STATE; |
$self->{state} = DOCTYPE_MD_STATE; |
4063 |
!!!next-input-character; |
!!!next-input-character; |
4064 |
redo A; |
redo A; |
4106 |
$self->{ct} = {type => ATTLIST_TOKEN, name => '', |
$self->{ct} = {type => ATTLIST_TOKEN, name => '', |
4107 |
attrdefs => [], |
attrdefs => [], |
4108 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
4109 |
column => $self->{column_prev} - 6}; |
column => $self->{column_prev} - 7}; |
4110 |
$self->{state} = DOCTYPE_MD_STATE; |
$self->{state} = DOCTYPE_MD_STATE; |
4111 |
!!!next-input-character; |
!!!next-input-character; |
4112 |
redo A; |
redo A; |
4155 |
} |
} |
4156 |
$self->{ct} = {type => NOTATION_TOKEN, name => '', |
$self->{ct} = {type => NOTATION_TOKEN, name => '', |
4157 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
4158 |
column => $self->{column_prev} - 6}; |
column => $self->{column_prev} - 8}; |
4159 |
$self->{state} = DOCTYPE_MD_STATE; |
$self->{state} = DOCTYPE_MD_STATE; |
4160 |
!!!next-input-character; |
!!!next-input-character; |
4161 |
redo A; |
redo A; |
4267 |
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
4268 |
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
4269 |
} elsif ($self->{ct}->{type} == ELEMENT_TOKEN) { |
} elsif ($self->{ct}->{type} == ELEMENT_TOKEN) { |
4270 |
## TODO: ... |
$self->{state} = AFTER_ELEMENT_NAME_STATE; |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
|
4271 |
} else { # ENTITY/NOTATION |
} else { # ENTITY/NOTATION |
4272 |
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
4273 |
} |
} |
4890 |
} |
} |
4891 |
} elsif ($self->{state} == NOTATION_NAME_STATE) { |
} elsif ($self->{state} == NOTATION_NAME_STATE) { |
4892 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
4893 |
$self->{state} = AFTER_NOTATION_NAME_STATE; |
$self->{state} = AFTER_MD_DEF_STATE; |
4894 |
!!!next-input-character; |
!!!next-input-character; |
4895 |
redo A; |
redo A; |
4896 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
4910 |
!!!next-input-character; |
!!!next-input-character; |
4911 |
redo A; |
redo A; |
4912 |
} |
} |
4913 |
} elsif ($self->{state} == AFTER_NOTATION_NAME_STATE) { |
} elsif ($self->{state} == DOCTYPE_ENTITY_VALUE_DOUBLE_QUOTED_STATE) { |
4914 |
|
if ($self->{nc} == 0x0022) { # " |
4915 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
4916 |
|
!!!next-input-character; |
4917 |
|
redo A; |
4918 |
|
} elsif ($self->{nc} == 0x0026) { # & |
4919 |
|
$self->{prev_state} = $self->{state}; |
4920 |
|
$self->{state} = ENTITY_VALUE_ENTITY_STATE; |
4921 |
|
$self->{entity_add} = 0x0022; # " |
4922 |
|
!!!next-input-character; |
4923 |
|
redo A; |
4924 |
|
## TODO: % |
4925 |
|
} elsif ($self->{nc} == -1) { |
4926 |
|
!!!parse-error (type => 'unclosed entity value'); ## TODO: type |
4927 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4928 |
|
## Reconsume. |
4929 |
|
!!!emit ($self->{ct}); # ENTITY |
4930 |
|
redo A; |
4931 |
|
} else { |
4932 |
|
$self->{ct}->{value} .= chr $self->{nc}; # ENTITY |
4933 |
|
!!!next-input-character; |
4934 |
|
redo A; |
4935 |
|
} |
4936 |
|
} elsif ($self->{state} == DOCTYPE_ENTITY_VALUE_SINGLE_QUOTED_STATE) { |
4937 |
|
if ($self->{nc} == 0x0027) { # ' |
4938 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
4939 |
|
!!!next-input-character; |
4940 |
|
redo A; |
4941 |
|
} elsif ($self->{nc} == 0x0026) { # & |
4942 |
|
$self->{prev_state} = $self->{state}; |
4943 |
|
$self->{state} = ENTITY_VALUE_ENTITY_STATE; |
4944 |
|
$self->{entity_add} = 0x0027; # ' |
4945 |
|
!!!next-input-character; |
4946 |
|
redo A; |
4947 |
|
## TODO: % |
4948 |
|
} elsif ($self->{nc} == -1) { |
4949 |
|
!!!parse-error (type => 'unclosed entity value'); ## TODO: type |
4950 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4951 |
|
## Reconsume. |
4952 |
|
!!!emit ($self->{ct}); # ENTITY |
4953 |
|
redo A; |
4954 |
|
} else { |
4955 |
|
$self->{ct}->{value} .= chr $self->{nc}; # ENTITY |
4956 |
|
!!!next-input-character; |
4957 |
|
redo A; |
4958 |
|
} |
4959 |
|
} elsif ($self->{state} == ENTITY_VALUE_ENTITY_STATE) { |
4960 |
|
if ($is_space->{$self->{nc}} or |
4961 |
|
{ |
4962 |
|
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
4963 |
|
$self->{entity_add} => 1, |
4964 |
|
}->{$self->{nc}}) { |
4965 |
|
!!!parse-error (type => 'bare ero', |
4966 |
|
line => $self->{line_prev}, |
4967 |
|
column => $self->{column_prev} |
4968 |
|
+ ($self->{nc} == -1 ? 1 : 0)); |
4969 |
|
## Don't consume |
4970 |
|
## Return nothing. |
4971 |
|
# |
4972 |
|
} elsif ($self->{nc} == 0x0023) { # # |
4973 |
|
$self->{ca} = $self->{ct}; |
4974 |
|
$self->{state} = ENTITY_HASH_STATE; |
4975 |
|
$self->{kwd} = '#'; |
4976 |
|
!!!next-input-character; |
4977 |
|
redo A; |
4978 |
|
} else { |
4979 |
|
# |
4980 |
|
} |
4981 |
|
|
4982 |
|
$self->{ct}->{value} .= '&'; |
4983 |
|
$self->{state} = $self->{prev_state}; |
4984 |
|
## Reconsume. |
4985 |
|
redo A; |
4986 |
|
} elsif ($self->{state} == AFTER_ELEMENT_NAME_STATE) { |
4987 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
4988 |
|
$self->{state} = BEFORE_ELEMENT_CONTENT_STATE; |
4989 |
|
!!!next-input-character; |
4990 |
|
redo A; |
4991 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4992 |
|
$self->{state} = AFTER_CM_GROUP_OPEN_STATE; |
4993 |
|
$self->{ct}->{content} = ['(']; |
4994 |
|
$self->{group_depth} = 1; |
4995 |
|
!!!next-input-character; |
4996 |
|
redo A; |
4997 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4998 |
|
!!!parse-error (type => 'no md def'); ## TODO: type |
4999 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5000 |
|
!!!next-input-character; |
5001 |
|
!!!emit ($self->{ct}); # ELEMENT |
5002 |
|
redo A; |
5003 |
|
} elsif ($self->{nc} == -1) { |
5004 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5005 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5006 |
|
!!!next-input-character; |
5007 |
|
!!!emit ($self->{ct}); # ELEMENT |
5008 |
|
redo A; |
5009 |
|
} else { |
5010 |
|
$self->{ct}->{content} = [chr $self->{nc}]; |
5011 |
|
$self->{state} = CONTENT_KEYWORD_STATE; |
5012 |
|
!!!next-input-character; |
5013 |
|
redo A; |
5014 |
|
} |
5015 |
|
} elsif ($self->{state} == CONTENT_KEYWORD_STATE) { |
5016 |
|
if ($is_space->{$self->{nc}}) { |
5017 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
5018 |
|
!!!next-input-character; |
5019 |
|
redo A; |
5020 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5021 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5022 |
|
!!!next-input-character; |
5023 |
|
!!!emit ($self->{ct}); # ELEMENT |
5024 |
|
redo A; |
5025 |
|
} elsif ($self->{nc} == -1) { |
5026 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5027 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5028 |
|
!!!next-input-character; |
5029 |
|
!!!emit ($self->{ct}); # ELEMENT |
5030 |
|
redo A; |
5031 |
|
} else { |
5032 |
|
$self->{ct}->{content}->[-1] .= chr $self->{nc}; # ELEMENT |
5033 |
|
## Stay in the state. |
5034 |
|
!!!next-input-character; |
5035 |
|
redo A; |
5036 |
|
} |
5037 |
|
} elsif ($self->{state} == AFTER_CM_GROUP_OPEN_STATE) { |
5038 |
|
if ($is_space->{$self->{nc}}) { |
5039 |
|
## Stay in the state. |
5040 |
|
!!!next-input-character; |
5041 |
|
redo A; |
5042 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
5043 |
|
$self->{group_depth}++; |
5044 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5045 |
|
## Stay in the state. |
5046 |
|
!!!next-input-character; |
5047 |
|
redo A; |
5048 |
|
} elsif ($self->{nc} == 0x007C or # | |
5049 |
|
$self->{nc} == 0x002C) { # , |
5050 |
|
!!!parse-error (type => 'empty element name'); ## TODO: type |
5051 |
## Stay in the state. |
## Stay in the state. |
5052 |
!!!next-input-character; |
!!!next-input-character; |
5053 |
redo A; |
redo A; |
5054 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
5055 |
|
!!!parse-error (type => 'empty element name'); ## TODO: type |
5056 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5057 |
|
$self->{group_depth}--; |
5058 |
|
$self->{state} = AFTER_CM_GROUP_CLOSE_STATE; |
5059 |
|
!!!next-input-character; |
5060 |
|
redo A; |
5061 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
5062 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
5063 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5064 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5065 |
!!!next-input-character; |
!!!next-input-character; |
5066 |
!!!emit ($self->{ct}); # ENTITY |
!!!emit ($self->{ct}); # ELEMENT |
5067 |
redo A; |
redo A; |
5068 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
5069 |
!!!parse-error (type => 'unclosed md'); ## TODO: type |
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5070 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5071 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5072 |
!!!next-input-character; |
!!!next-input-character; |
5073 |
!!!emit ($self->{ct}); # ENTITY |
!!!emit ($self->{ct}); # ELEMENT |
5074 |
|
redo A; |
5075 |
|
} else { |
5076 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5077 |
|
$self->{state} = CM_ELEMENT_NAME_STATE; |
5078 |
|
!!!next-input-character; |
5079 |
|
redo A; |
5080 |
|
} |
5081 |
|
} elsif ($self->{state} == CM_ELEMENT_NAME_STATE) { |
5082 |
|
if ($is_space->{$self->{nc}}) { |
5083 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5084 |
|
!!!next-input-character; |
5085 |
|
redo A; |
5086 |
|
} elsif ($self->{nc} == 0x002A or # * |
5087 |
|
$self->{nc} == 0x002B or # + |
5088 |
|
$self->{nc} == 0x003F) { # ? |
5089 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5090 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5091 |
|
!!!next-input-character; |
5092 |
|
redo A; |
5093 |
|
} elsif ($self->{nc} == 0x007C or # | |
5094 |
|
$self->{nc} == 0x002C) { # , |
5095 |
|
push @{$self->{ct}->{content}}, $self->{nc} == 0x007C ? ' | ' : ', '; |
5096 |
|
$self->{state} = AFTER_CM_GROUP_OPEN_STATE; |
5097 |
|
!!!next-input-character; |
5098 |
|
redo A; |
5099 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
5100 |
|
$self->{group_depth}--; |
5101 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5102 |
|
$self->{state} = AFTER_CM_GROUP_CLOSE_STATE; |
5103 |
|
!!!next-input-character; |
5104 |
|
redo A; |
5105 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5106 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
5107 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5108 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5109 |
|
!!!next-input-character; |
5110 |
|
!!!emit ($self->{ct}); # ELEMENT |
5111 |
|
redo A; |
5112 |
|
} elsif ($self->{nc} == -1) { |
5113 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5114 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5115 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5116 |
|
!!!next-input-character; |
5117 |
|
!!!emit ($self->{ct}); # ELEMENT |
5118 |
redo A; |
redo A; |
5119 |
} else { |
} else { |
5120 |
!!!parse-error (type => 'string after notation name'); ## TODO: type |
$self->{ct}->{content}->[-1] .= chr $self->{nc}; |
5121 |
|
## Stay in the state. |
5122 |
|
!!!next-input-character; |
5123 |
|
redo A; |
5124 |
|
} |
5125 |
|
} elsif ($self->{state} == AFTER_CM_ELEMENT_NAME_STATE) { |
5126 |
|
if ($is_space->{$self->{nc}}) { |
5127 |
|
## Stay in the state. |
5128 |
|
!!!next-input-character; |
5129 |
|
redo A; |
5130 |
|
} elsif ($self->{nc} == 0x007C or # | |
5131 |
|
$self->{nc} == 0x002C) { # , |
5132 |
|
push @{$self->{ct}->{content}}, $self->{nc} == 0x007C ? ' | ' : ', '; |
5133 |
|
$self->{state} = AFTER_CM_GROUP_OPEN_STATE; |
5134 |
|
!!!next-input-character; |
5135 |
|
redo A; |
5136 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
5137 |
|
$self->{group_depth}--; |
5138 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5139 |
|
$self->{state} = AFTER_CM_GROUP_CLOSE_STATE; |
5140 |
|
!!!next-input-character; |
5141 |
|
redo A; |
5142 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5143 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
5144 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5145 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5146 |
|
!!!next-input-character; |
5147 |
|
!!!emit ($self->{ct}); # ELEMENT |
5148 |
|
redo A; |
5149 |
|
} elsif ($self->{nc} == -1) { |
5150 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5151 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5152 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5153 |
|
!!!next-input-character; |
5154 |
|
!!!emit ($self->{ct}); # ELEMENT |
5155 |
|
redo A; |
5156 |
|
} else { |
5157 |
|
!!!parse-error (type => 'after element name'); ## TODO: type |
5158 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5159 |
|
$self->{state} = BOGUS_MD_STATE; |
5160 |
|
!!!next-input-character; |
5161 |
|
redo A; |
5162 |
|
} |
5163 |
|
} elsif ($self->{state} == AFTER_CM_GROUP_CLOSE_STATE) { |
5164 |
|
if ($is_space->{$self->{nc}}) { |
5165 |
|
if ($self->{group_depth}) { |
5166 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5167 |
|
} else { |
5168 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
5169 |
|
} |
5170 |
|
!!!next-input-character; |
5171 |
|
redo A; |
5172 |
|
} elsif ($self->{nc} == 0x002A or # * |
5173 |
|
$self->{nc} == 0x002B or # + |
5174 |
|
$self->{nc} == 0x003F) { # ? |
5175 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5176 |
|
if ($self->{group_depth}) { |
5177 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5178 |
|
} else { |
5179 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
5180 |
|
} |
5181 |
|
!!!next-input-character; |
5182 |
|
redo A; |
5183 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
5184 |
|
if ($self->{group_depth}) { |
5185 |
|
$self->{group_depth}--; |
5186 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5187 |
|
## Stay in the state. |
5188 |
|
!!!next-input-character; |
5189 |
|
redo A; |
5190 |
|
} else { |
5191 |
|
!!!parse-error (type => 'string after md def'); ## TODO: type |
5192 |
|
$self->{state} = BOGUS_MD_STATE; |
5193 |
|
## Reconsume. |
5194 |
|
redo A; |
5195 |
|
} |
5196 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5197 |
|
if ($self->{group_depth}) { |
5198 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
5199 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5200 |
|
} |
5201 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5202 |
|
!!!next-input-character; |
5203 |
|
!!!emit ($self->{ct}); # ELEMENT |
5204 |
|
redo A; |
5205 |
|
} elsif ($self->{nc} == -1) { |
5206 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5207 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5208 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5209 |
|
!!!next-input-character; |
5210 |
|
!!!emit ($self->{ct}); # ELEMENT |
5211 |
|
redo A; |
5212 |
|
} else { |
5213 |
|
if ($self->{group_depth}) { |
5214 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5215 |
|
} else { |
5216 |
|
!!!parse-error (type => 'string after md def'); ## TODO: type |
5217 |
|
$self->{state} = BOGUS_MD_STATE; |
5218 |
|
} |
5219 |
|
## Reconsume. |
5220 |
|
redo A; |
5221 |
|
} |
5222 |
|
} elsif ($self->{state} == AFTER_MD_DEF_STATE) { |
5223 |
|
if ($is_space->{$self->{nc}}) { |
5224 |
|
## Stay in the state. |
5225 |
|
!!!next-input-character; |
5226 |
|
redo A; |
5227 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5228 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5229 |
|
!!!next-input-character; |
5230 |
|
!!!emit ($self->{ct}); # ENTITY/ELEMENT |
5231 |
|
redo A; |
5232 |
|
} elsif ($self->{nc} == -1) { |
5233 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5234 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5235 |
|
!!!next-input-character; |
5236 |
|
!!!emit ($self->{ct}); # ENTITY/ELEMENT |
5237 |
|
redo A; |
5238 |
|
} else { |
5239 |
|
!!!parse-error (type => 'string after md def'); ## TODO: type |
5240 |
$self->{state} = BOGUS_MD_STATE; |
$self->{state} = BOGUS_MD_STATE; |
5241 |
## Reconsume. |
## Reconsume. |
5242 |
redo A; |
redo A; |
5243 |
} |
} |
|
|
|
|
|
|
5244 |
} elsif ($self->{state} == BOGUS_MD_STATE) { |
} elsif ($self->{state} == BOGUS_MD_STATE) { |
5245 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
5246 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |