15 |
CHARACTER_TOKEN |
CHARACTER_TOKEN |
16 |
PI_TOKEN |
PI_TOKEN |
17 |
ABORT_TOKEN |
ABORT_TOKEN |
18 |
|
END_OF_DOCTYPE_TOKEN |
19 |
|
ATTLIST_TOKEN |
20 |
|
ELEMENT_TOKEN |
21 |
|
GENERAL_ENTITY_TOKEN |
22 |
|
PARAMETER_ENTITY_TOKEN |
23 |
|
NOTATION_TOKEN |
24 |
); |
); |
25 |
|
|
26 |
our %EXPORT_TAGS = ( |
our %EXPORT_TAGS = ( |
33 |
CHARACTER_TOKEN |
CHARACTER_TOKEN |
34 |
PI_TOKEN |
PI_TOKEN |
35 |
ABORT_TOKEN |
ABORT_TOKEN |
36 |
|
END_OF_DOCTYPE_TOKEN |
37 |
|
ATTLIST_TOKEN |
38 |
|
ELEMENT_TOKEN |
39 |
|
GENERAL_ENTITY_TOKEN |
40 |
|
PARAMETER_ENTITY_TOKEN |
41 |
|
NOTATION_TOKEN |
42 |
)], |
)], |
43 |
); |
); |
44 |
} |
} |
55 |
sub CHARACTER_TOKEN () { 6 } |
sub CHARACTER_TOKEN () { 6 } |
56 |
sub PI_TOKEN () { 7 } ## NOTE: XML only. |
sub PI_TOKEN () { 7 } ## NOTE: XML only. |
57 |
sub ABORT_TOKEN () { 8 } ## NOTE: For internal processing. |
sub ABORT_TOKEN () { 8 } ## NOTE: For internal processing. |
58 |
|
sub END_OF_DOCTYPE_TOKEN () { 9 } ## NOTE: XML only. |
59 |
|
sub ATTLIST_TOKEN () { 10 } ## NOTE: XML only. |
60 |
|
sub ELEMENT_TOKEN () { 11 } ## NOTE: XML only. |
61 |
|
sub GENERAL_ENTITY_TOKEN () { 12 } ## NOTE: XML only. |
62 |
|
sub PARAMETER_ENTITY_TOKEN () { 13 } ## NOTE: XML only. |
63 |
|
sub NOTATION_TOKEN () { 14 } ## NOTE: XML only. |
64 |
|
|
65 |
## XML5: XML5 has "empty tag token". In this implementation, it is |
## XML5: XML5 has "empty tag token". In this implementation, it is |
66 |
## represented as a start tag token with $self->{self_closing} flag |
## represented as a start tag token with $self->{self_closing} flag |
151 |
sub PI_DATA_AFTER_STATE () { 56 } |
sub PI_DATA_AFTER_STATE () { 56 } |
152 |
sub DOCTYPE_INTERNAL_SUBSET_STATE () { 57 } |
sub DOCTYPE_INTERNAL_SUBSET_STATE () { 57 } |
153 |
sub DOCTYPE_INTERNAL_SUBSET_AFTER_STATE () { 58 } |
sub DOCTYPE_INTERNAL_SUBSET_AFTER_STATE () { 58 } |
154 |
|
sub BOGUS_DOCTYPE_INTERNAL_SUBSET_AFTER_STATE () { 59 } |
155 |
|
sub DOCTYPE_TAG_STATE () { 60 } |
156 |
|
sub DOCTYPE_MARKUP_DECLARATION_OPEN_STATE () { 61 } |
157 |
|
sub MD_ATTLIST_STATE () { 62 } |
158 |
|
sub MD_E_STATE () { 63 } |
159 |
|
sub MD_ELEMENT_STATE () { 64 } |
160 |
|
sub MD_ENTITY_STATE () { 65 } |
161 |
|
sub MD_NOTATION_STATE () { 66 } |
162 |
|
sub DOCTYPE_MD_STATE () { 67 } |
163 |
|
sub BEFORE_MD_NAME_STATE () { 68 } |
164 |
|
sub MD_NAME_STATE () { 69 } |
165 |
|
sub DOCTYPE_ENTITY_PARAMETER_BEFORE_STATE () { 70 } |
166 |
|
sub DOCTYPE_ATTLIST_NAME_AFTER_STATE () { 71 } |
167 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_NAME_STATE () { 72 } |
168 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_NAME_AFTER_STATE () { 73 } |
169 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_TYPE_STATE () { 74 } |
170 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_TYPE_AFTER_STATE () { 75 } |
171 |
|
sub BEFORE_ALLOWED_TOKEN_STATE () { 76 } |
172 |
|
sub ALLOWED_TOKEN_STATE () { 77 } |
173 |
|
sub AFTER_ALLOWED_TOKEN_STATE () { 78 } |
174 |
|
sub AFTER_ALLOWED_TOKENS_STATE () { 79 } |
175 |
|
sub BEFORE_ATTR_DEFAULT_STATE () { 80 } |
176 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_BEFORE_STATE () { 81 } |
177 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_STATE () { 82 } |
178 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_AFTER_STATE () { 83 } |
179 |
|
sub AFTER_ATTLIST_ATTR_VALUE_QUOTED_STATE () { 84 } |
180 |
|
sub BEFORE_NDATA_STATE () { 85 } |
181 |
|
sub NDATA_STATE () { 86 } |
182 |
|
sub AFTER_NDATA_STATE () { 87 } |
183 |
|
sub BEFORE_NOTATION_NAME_STATE () { 88 } |
184 |
|
sub NOTATION_NAME_STATE () { 89 } |
185 |
|
sub DOCTYPE_ENTITY_VALUE_DOUBLE_QUOTED_STATE () { 90 } |
186 |
|
sub DOCTYPE_ENTITY_VALUE_SINGLE_QUOTED_STATE () { 91 } |
187 |
|
sub ENTITY_VALUE_ENTITY_STATE () { 92 } |
188 |
|
sub AFTER_ELEMENT_NAME_STATE () { 93 } |
189 |
|
sub BEFORE_ELEMENT_CONTENT_STATE () { 94 } |
190 |
|
sub CONTENT_KEYWORD_STATE () { 95 } |
191 |
|
sub AFTER_CM_GROUP_OPEN_STATE () { 96 } |
192 |
|
sub CM_ELEMENT_NAME_STATE () { 97 } |
193 |
|
sub AFTER_CM_ELEMENT_NAME_STATE () { 98 } |
194 |
|
sub AFTER_CM_GROUP_CLOSE_STATE () { 99 } |
195 |
|
sub AFTER_MD_DEF_STATE () { 100 } |
196 |
|
sub BOGUS_MD_STATE () { 101 } |
197 |
|
|
198 |
## Tree constructor state constants (see Whatpm::HTML for the full |
## Tree constructor state constants (see Whatpm::HTML for the full |
199 |
## list and descriptions) |
## list and descriptions) |
1270 |
|
|
1271 |
redo A; |
redo A; |
1272 |
} else { |
} else { |
1273 |
if ($self->{nc} == 0x003D) { # = |
if ($self->{nc} == 0x003D or $self->{nc} == 0x003C) { # =, < |
1274 |
!!!cp (93); |
!!!cp (93); |
1275 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1276 |
!!!parse-error (type => 'bad attribute value'); |
!!!parse-error (type => 'bad attribute value'); |
1287 |
redo A; |
redo A; |
1288 |
} |
} |
1289 |
} elsif ($self->{state} == ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE) { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE) { |
1290 |
## XML5: "Tag attribute value double quoted state". |
## XML5: "Tag attribute value double quoted state" and "DOCTYPE |
1291 |
|
## ATTLIST attribute value double quoted state". |
1292 |
|
|
1293 |
if ($self->{nc} == 0x0022) { # " |
if ($self->{nc} == 0x0022) { # " |
1294 |
!!!cp (95); |
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1295 |
## XML5: "Tag attribute name before state". |
!!!cp (95.1); |
1296 |
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
## XML5: "DOCTYPE ATTLIST name after state". |
1297 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1298 |
|
$self->{state} = AFTER_ATTLIST_ATTR_VALUE_QUOTED_STATE; |
1299 |
|
} else { |
1300 |
|
!!!cp (95); |
1301 |
|
## XML5: "Tag attribute name before state". |
1302 |
|
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
1303 |
|
} |
1304 |
!!!next-input-character; |
!!!next-input-character; |
1305 |
redo A; |
redo A; |
1306 |
} elsif ($self->{nc} == 0x0026) { # & |
} elsif ($self->{nc} == 0x0026) { # & |
1316 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1317 |
!!!next-input-character; |
!!!next-input-character; |
1318 |
redo A; |
redo A; |
1319 |
|
} elsif ($self->{is_xml} and |
1320 |
|
$is_space->{$self->{nc}}) { |
1321 |
|
!!!cp (97.1); |
1322 |
|
$self->{ca}->{value} .= ' '; |
1323 |
|
## Stay in the state. |
1324 |
|
!!!next-input-character; |
1325 |
|
redo A; |
1326 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
1327 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
1328 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1329 |
!!!cp (97); |
!!!cp (97); |
1330 |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1331 |
|
|
1332 |
|
$self->{state} = DATA_STATE; |
1333 |
|
$self->{s_kwd} = ''; |
1334 |
|
## reconsume |
1335 |
|
!!!emit ($self->{ct}); # start tag |
1336 |
|
redo A; |
1337 |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1338 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1339 |
if ($self->{ct}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1343 |
## NOTE: This state should never be reached. |
## NOTE: This state should never be reached. |
1344 |
!!!cp (99); |
!!!cp (99); |
1345 |
} |
} |
1346 |
|
|
1347 |
|
$self->{state} = DATA_STATE; |
1348 |
|
$self->{s_kwd} = ''; |
1349 |
|
## reconsume |
1350 |
|
!!!emit ($self->{ct}); # end tag |
1351 |
|
redo A; |
1352 |
|
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1353 |
|
## XML5: No parse error above; not defined yet. |
1354 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1355 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1356 |
|
## Reconsume. |
1357 |
|
!!!emit ($self->{ct}); # ATTLIST |
1358 |
|
redo A; |
1359 |
} else { |
} else { |
1360 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1361 |
} |
} |
|
$self->{state} = DATA_STATE; |
|
|
$self->{s_kwd} = ''; |
|
|
## reconsume |
|
|
|
|
|
!!!emit ($self->{ct}); # start tag or end tag |
|
|
|
|
|
redo A; |
|
1362 |
} else { |
} else { |
1363 |
|
## XML5 [ATTLIST]: Not defined yet. |
1364 |
if ($self->{is_xml} and $self->{nc} == 0x003C) { # < |
if ($self->{is_xml} and $self->{nc} == 0x003C) { # < |
1365 |
!!!cp (100); |
!!!cp (100); |
1366 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1370 |
} |
} |
1371 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1372 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1373 |
q["&<], |
qq["&<\x09\x0C\x20], |
1374 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1375 |
|
|
1376 |
## Stay in the state |
## Stay in the state |
1378 |
redo A; |
redo A; |
1379 |
} |
} |
1380 |
} elsif ($self->{state} == ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE) { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE) { |
1381 |
## XML5: "Tag attribute value single quoted state". |
## XML5: "Tag attribute value single quoted state" and "DOCTYPE |
1382 |
|
## ATTLIST attribute value single quoted state". |
1383 |
|
|
1384 |
if ($self->{nc} == 0x0027) { # ' |
if ($self->{nc} == 0x0027) { # ' |
1385 |
!!!cp (101); |
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1386 |
## XML5: "Before attribute name state" (sic). |
!!!cp (101.1); |
1387 |
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
## XML5: "DOCTYPE ATTLIST name after state". |
1388 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1389 |
|
$self->{state} = AFTER_ATTLIST_ATTR_VALUE_QUOTED_STATE; |
1390 |
|
} else { |
1391 |
|
!!!cp (101); |
1392 |
|
## XML5: "Before attribute name state" (sic). |
1393 |
|
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
1394 |
|
} |
1395 |
!!!next-input-character; |
!!!next-input-character; |
1396 |
redo A; |
redo A; |
1397 |
} elsif ($self->{nc} == 0x0026) { # & |
} elsif ($self->{nc} == 0x0026) { # & |
1407 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1408 |
!!!next-input-character; |
!!!next-input-character; |
1409 |
redo A; |
redo A; |
1410 |
|
} elsif ($self->{is_xml} and |
1411 |
|
$is_space->{$self->{nc}}) { |
1412 |
|
!!!cp (103.1); |
1413 |
|
$self->{ca}->{value} .= ' '; |
1414 |
|
## Stay in the state. |
1415 |
|
!!!next-input-character; |
1416 |
|
redo A; |
1417 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
1418 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
1419 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1420 |
!!!cp (103); |
!!!cp (103); |
1421 |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1422 |
|
|
1423 |
|
$self->{state} = DATA_STATE; |
1424 |
|
$self->{s_kwd} = ''; |
1425 |
|
## reconsume |
1426 |
|
!!!emit ($self->{ct}); # start tag |
1427 |
|
redo A; |
1428 |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1429 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1430 |
if ($self->{ct}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1434 |
## NOTE: This state should never be reached. |
## NOTE: This state should never be reached. |
1435 |
!!!cp (105); |
!!!cp (105); |
1436 |
} |
} |
1437 |
|
|
1438 |
|
$self->{state} = DATA_STATE; |
1439 |
|
$self->{s_kwd} = ''; |
1440 |
|
## reconsume |
1441 |
|
!!!emit ($self->{ct}); # end tag |
1442 |
|
redo A; |
1443 |
|
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1444 |
|
## XML5: No parse error above; not defined yet. |
1445 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1446 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1447 |
|
## Reconsume. |
1448 |
|
!!!emit ($self->{ct}); # ATTLIST |
1449 |
|
redo A; |
1450 |
} else { |
} else { |
1451 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1452 |
} |
} |
|
$self->{state} = DATA_STATE; |
|
|
$self->{s_kwd} = ''; |
|
|
## reconsume |
|
|
|
|
|
!!!emit ($self->{ct}); # start tag or end tag |
|
|
|
|
|
redo A; |
|
1453 |
} else { |
} else { |
1454 |
|
## XML5 [ATTLIST]: Not defined yet. |
1455 |
if ($self->{is_xml} and $self->{nc} == 0x003C) { # < |
if ($self->{is_xml} and $self->{nc} == 0x003C) { # < |
1456 |
!!!cp (106); |
!!!cp (106); |
1457 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1461 |
} |
} |
1462 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1463 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1464 |
q['&<], |
qq['&<\x09\x0C\x20], |
1465 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1466 |
|
|
1467 |
## Stay in the state |
## Stay in the state |
1472 |
## XML5: "Tag attribute value unquoted state". |
## XML5: "Tag attribute value unquoted state". |
1473 |
|
|
1474 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
1475 |
!!!cp (107); |
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1476 |
## XML5: "Tag attribute name before state". |
!!!cp (107.1); |
1477 |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1478 |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
1479 |
|
} else { |
1480 |
|
!!!cp (107); |
1481 |
|
## XML5: "Tag attribute name before state". |
1482 |
|
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
1483 |
|
} |
1484 |
!!!next-input-character; |
!!!next-input-character; |
1485 |
redo A; |
redo A; |
1486 |
} elsif ($self->{nc} == 0x0026) { # & |
} elsif ($self->{nc} == 0x0026) { # & |
1501 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1502 |
!!!cp (109); |
!!!cp (109); |
1503 |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1504 |
|
|
1505 |
|
$self->{state} = DATA_STATE; |
1506 |
|
$self->{s_kwd} = ''; |
1507 |
|
!!!next-input-character; |
1508 |
|
!!!emit ($self->{ct}); # start tag |
1509 |
|
redo A; |
1510 |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1511 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1512 |
if ($self->{ct}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1516 |
## NOTE: This state should never be reached. |
## NOTE: This state should never be reached. |
1517 |
!!!cp (111); |
!!!cp (111); |
1518 |
} |
} |
1519 |
|
|
1520 |
|
$self->{state} = DATA_STATE; |
1521 |
|
$self->{s_kwd} = ''; |
1522 |
|
!!!next-input-character; |
1523 |
|
!!!emit ($self->{ct}); # end tag |
1524 |
|
redo A; |
1525 |
|
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1526 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1527 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1528 |
|
!!!next-input-character; |
1529 |
|
!!!emit ($self->{ct}); # ATTLIST |
1530 |
|
redo A; |
1531 |
} else { |
} else { |
1532 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1533 |
} |
} |
|
$self->{state} = DATA_STATE; |
|
|
$self->{s_kwd} = ''; |
|
|
!!!next-input-character; |
|
|
|
|
|
!!!emit ($self->{ct}); # start tag or end tag |
|
|
|
|
|
redo A; |
|
1534 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!parse-error (type => 'unclosed tag'); |
|
1535 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1536 |
!!!cp (112); |
!!!cp (112); |
1537 |
|
!!!parse-error (type => 'unclosed tag'); |
1538 |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1539 |
|
|
1540 |
|
$self->{state} = DATA_STATE; |
1541 |
|
$self->{s_kwd} = ''; |
1542 |
|
## reconsume |
1543 |
|
!!!emit ($self->{ct}); # start tag |
1544 |
|
redo A; |
1545 |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1546 |
|
!!!parse-error (type => 'unclosed tag'); |
1547 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1548 |
if ($self->{ct}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1549 |
!!!cp (113); |
!!!cp (113); |
1552 |
## NOTE: This state should never be reached. |
## NOTE: This state should never be reached. |
1553 |
!!!cp (114); |
!!!cp (114); |
1554 |
} |
} |
1555 |
|
|
1556 |
|
$self->{state} = DATA_STATE; |
1557 |
|
$self->{s_kwd} = ''; |
1558 |
|
## reconsume |
1559 |
|
!!!emit ($self->{ct}); # end tag |
1560 |
|
redo A; |
1561 |
|
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1562 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
1563 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1564 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1565 |
|
## Reconsume. |
1566 |
|
!!!emit ($self->{ct}); # ATTLIST |
1567 |
|
redo A; |
1568 |
} else { |
} else { |
1569 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1570 |
} |
} |
|
$self->{state} = DATA_STATE; |
|
|
$self->{s_kwd} = ''; |
|
|
## reconsume |
|
|
|
|
|
!!!emit ($self->{ct}); # start tag or end tag |
|
|
|
|
|
redo A; |
|
1571 |
} else { |
} else { |
1572 |
if ({ |
if ({ |
1573 |
0x0022 => 1, # " |
0x0022 => 1, # " |
1574 |
0x0027 => 1, # ' |
0x0027 => 1, # ' |
1575 |
0x003D => 1, # = |
0x003D => 1, # = |
1576 |
|
0x003C => 1, # < |
1577 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
1578 |
!!!cp (115); |
!!!cp (115); |
1579 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1583 |
} |
} |
1584 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1585 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1586 |
q["'=& >], |
qq["'=& \x09\x0C>], |
1587 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1588 |
|
|
1589 |
## Stay in the state |
## Stay in the state |
1711 |
redo A; |
redo A; |
1712 |
} |
} |
1713 |
} elsif ($self->{state} == BOGUS_COMMENT_STATE) { |
} elsif ($self->{state} == BOGUS_COMMENT_STATE) { |
1714 |
## (only happen if PCDATA state) |
## XML5: "Bogus comment state" and "DOCTYPE bogus comment state". |
1715 |
|
|
1716 |
## NOTE: Unlike spec's "bogus comment state", this implementation |
## NOTE: Unlike spec's "bogus comment state", this implementation |
1717 |
## consumes characters one-by-one basis. |
## consumes characters one-by-one basis. |
1718 |
|
|
1719 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
1720 |
!!!cp (124); |
if ($self->{in_subset}) { |
1721 |
$self->{state} = DATA_STATE; |
!!!cp (123); |
1722 |
$self->{s_kwd} = ''; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1723 |
|
} else { |
1724 |
|
!!!cp (124); |
1725 |
|
$self->{state} = DATA_STATE; |
1726 |
|
$self->{s_kwd} = ''; |
1727 |
|
} |
1728 |
!!!next-input-character; |
!!!next-input-character; |
1729 |
|
|
1730 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
1731 |
redo A; |
redo A; |
1732 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
1733 |
!!!cp (125); |
if ($self->{in_subset}) { |
1734 |
$self->{state} = DATA_STATE; |
!!!cp (125.1); |
1735 |
$self->{s_kwd} = ''; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1736 |
|
} else { |
1737 |
|
!!!cp (125); |
1738 |
|
$self->{state} = DATA_STATE; |
1739 |
|
$self->{s_kwd} = ''; |
1740 |
|
} |
1741 |
## reconsume |
## reconsume |
1742 |
|
|
1743 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
1754 |
redo A; |
redo A; |
1755 |
} |
} |
1756 |
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
1757 |
## (only happen if PCDATA state) |
## XML5: "Markup declaration state". |
1758 |
|
|
1759 |
if ($self->{nc} == 0x002D) { # - |
if ($self->{nc} == 0x002D) { # - |
1760 |
!!!cp (133); |
!!!cp (133); |
1930 |
!!!next-input-character; |
!!!next-input-character; |
1931 |
redo A; |
redo A; |
1932 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
|
!!!cp (138); |
|
1933 |
!!!parse-error (type => 'bogus comment'); |
!!!parse-error (type => 'bogus comment'); |
1934 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
1935 |
$self->{s_kwd} = ''; |
!!!cp (138.1); |
1936 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1937 |
|
} else { |
1938 |
|
!!!cp (138); |
1939 |
|
$self->{state} = DATA_STATE; |
1940 |
|
$self->{s_kwd} = ''; |
1941 |
|
} |
1942 |
!!!next-input-character; |
!!!next-input-character; |
1943 |
|
|
1944 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
1945 |
|
|
1946 |
redo A; |
redo A; |
1947 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (139); |
|
1948 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
1949 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
1950 |
$self->{s_kwd} = ''; |
!!!cp (139.1); |
1951 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1952 |
|
} else { |
1953 |
|
!!!cp (139); |
1954 |
|
$self->{state} = DATA_STATE; |
1955 |
|
$self->{s_kwd} = ''; |
1956 |
|
} |
1957 |
## reconsume |
## reconsume |
1958 |
|
|
1959 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
1974 |
!!!next-input-character; |
!!!next-input-character; |
1975 |
redo A; |
redo A; |
1976 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
|
!!!cp (142); |
|
1977 |
!!!parse-error (type => 'bogus comment'); |
!!!parse-error (type => 'bogus comment'); |
1978 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
1979 |
$self->{s_kwd} = ''; |
!!!cp (142.1); |
1980 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1981 |
|
} else { |
1982 |
|
!!!cp (142); |
1983 |
|
$self->{state} = DATA_STATE; |
1984 |
|
$self->{s_kwd} = ''; |
1985 |
|
} |
1986 |
!!!next-input-character; |
!!!next-input-character; |
1987 |
|
|
1988 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
1989 |
|
|
1990 |
redo A; |
redo A; |
1991 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (143); |
|
1992 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
1993 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
1994 |
$self->{s_kwd} = ''; |
!!!cp (143.1); |
1995 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1996 |
|
} else { |
1997 |
|
!!!cp (143); |
1998 |
|
$self->{state} = DATA_STATE; |
1999 |
|
$self->{s_kwd} = ''; |
2000 |
|
} |
2001 |
## reconsume |
## reconsume |
2002 |
|
|
2003 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
2012 |
redo A; |
redo A; |
2013 |
} |
} |
2014 |
} elsif ($self->{state} == COMMENT_STATE) { |
} elsif ($self->{state} == COMMENT_STATE) { |
2015 |
|
## XML5: "Comment state" and "DOCTYPE comment state". |
2016 |
|
|
2017 |
if ($self->{nc} == 0x002D) { # - |
if ($self->{nc} == 0x002D) { # - |
2018 |
!!!cp (145); |
!!!cp (145); |
2019 |
$self->{state} = COMMENT_END_DASH_STATE; |
$self->{state} = COMMENT_END_DASH_STATE; |
2020 |
!!!next-input-character; |
!!!next-input-character; |
2021 |
redo A; |
redo A; |
2022 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (146); |
|
2023 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
2024 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
2025 |
$self->{s_kwd} = ''; |
!!!cp (146.1); |
2026 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2027 |
|
} else { |
2028 |
|
!!!cp (146); |
2029 |
|
$self->{state} = DATA_STATE; |
2030 |
|
$self->{s_kwd} = ''; |
2031 |
|
} |
2032 |
## reconsume |
## reconsume |
2033 |
|
|
2034 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
2046 |
redo A; |
redo A; |
2047 |
} |
} |
2048 |
} elsif ($self->{state} == COMMENT_END_DASH_STATE) { |
} elsif ($self->{state} == COMMENT_END_DASH_STATE) { |
2049 |
## XML5: "comment dash state". |
## XML5: "Comment dash state" and "DOCTYPE comment dash state". |
2050 |
|
|
2051 |
if ($self->{nc} == 0x002D) { # - |
if ($self->{nc} == 0x002D) { # - |
2052 |
!!!cp (148); |
!!!cp (148); |
2054 |
!!!next-input-character; |
!!!next-input-character; |
2055 |
redo A; |
redo A; |
2056 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (149); |
|
2057 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
2058 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
2059 |
$self->{s_kwd} = ''; |
!!!cp (149.1); |
2060 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2061 |
|
} else { |
2062 |
|
!!!cp (149); |
2063 |
|
$self->{state} = DATA_STATE; |
2064 |
|
$self->{s_kwd} = ''; |
2065 |
|
} |
2066 |
## reconsume |
## reconsume |
2067 |
|
|
2068 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
2076 |
redo A; |
redo A; |
2077 |
} |
} |
2078 |
} elsif ($self->{state} == COMMENT_END_STATE) { |
} elsif ($self->{state} == COMMENT_END_STATE) { |
2079 |
|
## XML5: "Comment end state" and "DOCTYPE comment end state". |
2080 |
|
|
2081 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
2082 |
!!!cp (151); |
if ($self->{in_subset}) { |
2083 |
$self->{state} = DATA_STATE; |
!!!cp (151.1); |
2084 |
$self->{s_kwd} = ''; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2085 |
|
} else { |
2086 |
|
!!!cp (151); |
2087 |
|
$self->{state} = DATA_STATE; |
2088 |
|
$self->{s_kwd} = ''; |
2089 |
|
} |
2090 |
!!!next-input-character; |
!!!next-input-character; |
2091 |
|
|
2092 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
2103 |
!!!next-input-character; |
!!!next-input-character; |
2104 |
redo A; |
redo A; |
2105 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (153); |
|
2106 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
2107 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
2108 |
$self->{s_kwd} = ''; |
!!!cp (153.1); |
2109 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2110 |
|
} else { |
2111 |
|
!!!cp (153); |
2112 |
|
$self->{state} = DATA_STATE; |
2113 |
|
$self->{s_kwd} = ''; |
2114 |
|
} |
2115 |
## reconsume |
## reconsume |
2116 |
|
|
2117 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
2119 |
redo A; |
redo A; |
2120 |
} else { |
} else { |
2121 |
!!!cp (154); |
!!!cp (154); |
|
## XML5: Not a parse error. |
|
|
!!!parse-error (type => 'dash in comment', |
|
|
line => $self->{line_prev}, |
|
|
column => $self->{column_prev}); |
|
2122 |
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
2123 |
$self->{state} = COMMENT_STATE; |
$self->{state} = COMMENT_STATE; |
2124 |
!!!next-input-character; |
!!!next-input-character; |
2171 |
!!!cp (159.1); |
!!!cp (159.1); |
2172 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
2173 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2174 |
|
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2175 |
|
$self->{in_subset} = 1; |
2176 |
!!!next-input-character; |
!!!next-input-character; |
2177 |
|
!!!emit ($self->{ct}); # DOCTYPE |
2178 |
redo A; |
redo A; |
2179 |
} else { |
} else { |
2180 |
!!!cp (160); |
!!!cp (160); |
2217 |
} elsif ($self->{is_xml} and $self->{nc} == 0x005B) { # [ |
} elsif ($self->{is_xml} and $self->{nc} == 0x005B) { # [ |
2218 |
!!!cp (163.1); |
!!!cp (163.1); |
2219 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2220 |
|
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2221 |
|
$self->{in_subset} = 1; |
2222 |
!!!next-input-character; |
!!!next-input-character; |
2223 |
|
!!!emit ($self->{ct}); # DOCTYPE |
2224 |
redo A; |
redo A; |
2225 |
} else { |
} else { |
2226 |
!!!cp (164); |
!!!cp (164); |
2240 |
!!!next-input-character; |
!!!next-input-character; |
2241 |
redo A; |
redo A; |
2242 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2243 |
!!!cp (166); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2244 |
$self->{state} = DATA_STATE; |
!!!cp (166); |
2245 |
$self->{s_kwd} = ''; |
$self->{state} = DATA_STATE; |
2246 |
|
$self->{s_kwd} = ''; |
2247 |
|
} else { |
2248 |
|
!!!cp (166.1); |
2249 |
|
!!!parse-error (type => 'no md def'); ## TODO: type |
2250 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2251 |
|
} |
2252 |
|
|
2253 |
!!!next-input-character; |
!!!next-input-character; |
2254 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2255 |
redo A; |
redo A; |
2256 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2257 |
!!!cp (167); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2258 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!cp (167); |
2259 |
$self->{state} = DATA_STATE; |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2260 |
$self->{s_kwd} = ''; |
$self->{state} = DATA_STATE; |
2261 |
## reconsume |
$self->{s_kwd} = ''; |
2262 |
|
$self->{ct}->{quirks} = 1; |
2263 |
$self->{ct}->{quirks} = 1; |
} else { |
2264 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!cp (167.12); |
2265 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
2266 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2267 |
|
} |
2268 |
|
|
2269 |
|
## Reconsume. |
2270 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2271 |
redo A; |
redo A; |
2272 |
} elsif ($self->{nc} == 0x0050 or # P |
} elsif ($self->{nc} == 0x0050 or # P |
2273 |
$self->{nc} == 0x0070) { # p |
$self->{nc} == 0x0070) { # p |
2283 |
$self->{kwd} = chr $self->{nc}; |
$self->{kwd} = chr $self->{nc}; |
2284 |
!!!next-input-character; |
!!!next-input-character; |
2285 |
redo A; |
redo A; |
2286 |
} elsif ($self->{is_xml} and $self->{nc} == 0x005B) { # [ |
} elsif ($self->{nc} == 0x0022 and # " |
2287 |
|
($self->{ct}->{type} == GENERAL_ENTITY_TOKEN or |
2288 |
|
$self->{ct}->{type} == PARAMETER_ENTITY_TOKEN)) { |
2289 |
|
!!!cp (167.21); |
2290 |
|
$self->{state} = DOCTYPE_ENTITY_VALUE_DOUBLE_QUOTED_STATE; |
2291 |
|
$self->{ct}->{value} = ''; # ENTITY |
2292 |
|
!!!next-input-character; |
2293 |
|
redo A; |
2294 |
|
} elsif ($self->{nc} == 0x0027 and # ' |
2295 |
|
($self->{ct}->{type} == GENERAL_ENTITY_TOKEN or |
2296 |
|
$self->{ct}->{type} == PARAMETER_ENTITY_TOKEN)) { |
2297 |
|
!!!cp (167.22); |
2298 |
|
$self->{state} = DOCTYPE_ENTITY_VALUE_SINGLE_QUOTED_STATE; |
2299 |
|
$self->{ct}->{value} = ''; # ENTITY |
2300 |
|
!!!next-input-character; |
2301 |
|
redo A; |
2302 |
|
} elsif ($self->{is_xml} and |
2303 |
|
$self->{ct}->{type} == DOCTYPE_TOKEN and |
2304 |
|
$self->{nc} == 0x005B) { # [ |
2305 |
!!!cp (167.3); |
!!!cp (167.3); |
2306 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2307 |
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2308 |
|
$self->{in_subset} = 1; |
2309 |
!!!next-input-character; |
!!!next-input-character; |
2310 |
|
!!!emit ($self->{ct}); # DOCTYPE |
2311 |
redo A; |
redo A; |
2312 |
} else { |
} else { |
2313 |
!!!cp (180); |
!!!parse-error (type => 'string after DOCTYPE name'); ## TODO: type |
2314 |
!!!parse-error (type => 'string after DOCTYPE name'); |
|
2315 |
$self->{ct}->{quirks} = 1; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2316 |
|
!!!cp (180); |
2317 |
|
$self->{ct}->{quirks} = 1; |
2318 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2319 |
|
} else { |
2320 |
|
!!!cp (180.1); |
2321 |
|
$self->{state} = BOGUS_MD_STATE; |
2322 |
|
} |
2323 |
|
|
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
|
2324 |
!!!next-input-character; |
!!!next-input-character; |
2325 |
redo A; |
redo A; |
2326 |
} |
} |
2362 |
!!!next-input-character; |
!!!next-input-character; |
2363 |
redo A; |
redo A; |
2364 |
} else { |
} else { |
2365 |
!!!cp (169); |
!!!parse-error (type => 'string after DOCTYPE name', ## TODO: type |
|
!!!parse-error (type => 'string after DOCTYPE name', |
|
2366 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2367 |
column => $self->{column_prev} + 1 - length $self->{kwd}); |
column => $self->{column_prev} + 1 - length $self->{kwd}); |
2368 |
$self->{ct}->{quirks} = 1; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2369 |
|
!!!cp (169); |
2370 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
$self->{ct}->{quirks} = 1; |
2371 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2372 |
|
} else { |
2373 |
|
!!!cp (169.1); |
2374 |
|
$self->{state} = BOGUS_MD_STATE; |
2375 |
|
} |
2376 |
## Reconsume. |
## Reconsume. |
2377 |
redo A; |
redo A; |
2378 |
} |
} |
2414 |
!!!next-input-character; |
!!!next-input-character; |
2415 |
redo A; |
redo A; |
2416 |
} else { |
} else { |
2417 |
!!!cp (172); |
!!!parse-error (type => 'string after DOCTYPE name', ## TODO: type |
|
!!!parse-error (type => 'string after DOCTYPE name', |
|
2418 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2419 |
column => $self->{column_prev} + 1 - length $self->{kwd}); |
column => $self->{column_prev} + 1 - length $self->{kwd}); |
2420 |
$self->{ct}->{quirks} = 1; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2421 |
|
!!!cp (172); |
2422 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
$self->{ct}->{quirks} = 1; |
2423 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2424 |
|
} else { |
2425 |
|
!!!cp (172.1); |
2426 |
|
$self->{state} = BOGUS_MD_STATE; |
2427 |
|
} |
2428 |
## Reconsume. |
## Reconsume. |
2429 |
redo A; |
redo A; |
2430 |
} |
} |
2447 |
!!!next-input-character; |
!!!next-input-character; |
2448 |
redo A; |
redo A; |
2449 |
} elsif ($self->{nc} eq 0x003E) { # > |
} elsif ($self->{nc} eq 0x003E) { # > |
|
!!!cp (184); |
|
2450 |
!!!parse-error (type => 'no PUBLIC literal'); |
!!!parse-error (type => 'no PUBLIC literal'); |
2451 |
|
|
2452 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2453 |
$self->{s_kwd} = ''; |
!!!cp (184); |
2454 |
|
$self->{state} = DATA_STATE; |
2455 |
|
$self->{s_kwd} = ''; |
2456 |
|
$self->{ct}->{quirks} = 1; |
2457 |
|
} else { |
2458 |
|
!!!cp (184.1); |
2459 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2460 |
|
} |
2461 |
|
|
2462 |
!!!next-input-character; |
!!!next-input-character; |
2463 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
$self->{ct}->{quirks} = 1; |
|
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2464 |
redo A; |
redo A; |
2465 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2466 |
!!!cp (185); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2467 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!cp (185); |
2468 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
2469 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2470 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
2471 |
|
$self->{ct}->{quirks} = 1; |
2472 |
|
} else { |
2473 |
|
!!!cp (185.1); |
2474 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
2475 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2476 |
|
} |
2477 |
|
|
2478 |
## reconsume |
## reconsume |
|
|
|
|
$self->{ct}->{quirks} = 1; |
|
2479 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
2480 |
redo A; |
redo A; |
2481 |
} elsif ($self->{is_xml} and $self->{nc} == 0x005B) { # [ |
} elsif ($self->{is_xml} and |
2482 |
|
$self->{ct}->{type} == DOCTYPE_TOKEN and |
2483 |
|
$self->{nc} == 0x005B) { # [ |
2484 |
!!!cp (186.1); |
!!!cp (186.1); |
2485 |
!!!parse-error (type => 'no PUBLIC literal'); |
!!!parse-error (type => 'no PUBLIC literal'); |
2486 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2487 |
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2488 |
|
$self->{in_subset} = 1; |
2489 |
!!!next-input-character; |
!!!next-input-character; |
2490 |
|
!!!emit ($self->{ct}); # DOCTYPE |
2491 |
redo A; |
redo A; |
2492 |
} else { |
} else { |
|
!!!cp (186); |
|
2493 |
!!!parse-error (type => 'string after PUBLIC'); |
!!!parse-error (type => 'string after PUBLIC'); |
|
$self->{ct}->{quirks} = 1; |
|
2494 |
|
|
2495 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2496 |
|
!!!cp (186); |
2497 |
|
$self->{ct}->{quirks} = 1; |
2498 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2499 |
|
} else { |
2500 |
|
!!!cp (186.2); |
2501 |
|
$self->{state} = BOGUS_MD_STATE; |
2502 |
|
} |
2503 |
|
|
2504 |
!!!next-input-character; |
!!!next-input-character; |
2505 |
redo A; |
redo A; |
2506 |
} |
} |
2511 |
!!!next-input-character; |
!!!next-input-character; |
2512 |
redo A; |
redo A; |
2513 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
|
!!!cp (188); |
|
2514 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
2515 |
|
|
2516 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2517 |
$self->{s_kwd} = ''; |
!!!cp (188); |
2518 |
!!!next-input-character; |
$self->{state} = DATA_STATE; |
2519 |
|
$self->{s_kwd} = ''; |
2520 |
$self->{ct}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2521 |
!!!emit ($self->{ct}); # DOCTYPE |
} else { |
2522 |
|
!!!cp (188.1); |
2523 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2524 |
|
} |
2525 |
|
|
2526 |
|
!!!next-input-character; |
2527 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2528 |
redo A; |
redo A; |
2529 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (189); |
|
2530 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
2531 |
|
|
2532 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2533 |
$self->{s_kwd} = ''; |
!!!cp (189); |
2534 |
## reconsume |
$self->{state} = DATA_STATE; |
2535 |
|
$self->{s_kwd} = ''; |
2536 |
$self->{ct}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2537 |
|
} else { |
2538 |
|
!!!cp (189.1); |
2539 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2540 |
|
} |
2541 |
|
|
2542 |
|
## Reconsume. |
2543 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
2544 |
redo A; |
redo A; |
2545 |
} else { |
} else { |
2546 |
!!!cp (190); |
!!!cp (190); |
2547 |
$self->{ct}->{pubid} # DOCTYPE |
$self->{ct}->{pubid} .= chr $self->{nc}; # DOCTYPE/ENTITY/NOTATION |
|
.= chr $self->{nc}; |
|
2548 |
$self->{read_until}->($self->{ct}->{pubid}, q[">], |
$self->{read_until}->($self->{ct}->{pubid}, q[">], |
2549 |
length $self->{ct}->{pubid}); |
length $self->{ct}->{pubid}); |
2550 |
|
|
2559 |
!!!next-input-character; |
!!!next-input-character; |
2560 |
redo A; |
redo A; |
2561 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
|
!!!cp (192); |
|
2562 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
2563 |
|
|
2564 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2565 |
$self->{s_kwd} = ''; |
!!!cp (192); |
2566 |
!!!next-input-character; |
$self->{state} = DATA_STATE; |
2567 |
|
$self->{s_kwd} = ''; |
2568 |
$self->{ct}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2569 |
!!!emit ($self->{ct}); # DOCTYPE |
} else { |
2570 |
|
!!!cp (192.1); |
2571 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2572 |
|
} |
2573 |
|
|
2574 |
|
!!!next-input-character; |
2575 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2576 |
redo A; |
redo A; |
2577 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (193); |
|
2578 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
2579 |
|
|
2580 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2581 |
$self->{s_kwd} = ''; |
!!!cp (193); |
2582 |
|
$self->{state} = DATA_STATE; |
2583 |
|
$self->{s_kwd} = ''; |
2584 |
|
$self->{ct}->{quirks} = 1; |
2585 |
|
} else { |
2586 |
|
!!!cp (193.1); |
2587 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2588 |
|
} |
2589 |
|
|
2590 |
## reconsume |
## reconsume |
2591 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
$self->{ct}->{quirks} = 1; |
|
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2592 |
redo A; |
redo A; |
2593 |
} else { |
} else { |
2594 |
!!!cp (194); |
!!!cp (194); |
2595 |
$self->{ct}->{pubid} # DOCTYPE |
$self->{ct}->{pubid} .= chr $self->{nc}; # DOCTYPE/ENTITY/NOTATION |
|
.= chr $self->{nc}; |
|
2596 |
$self->{read_until}->($self->{ct}->{pubid}, q['>], |
$self->{read_until}->($self->{ct}->{pubid}, q['>], |
2597 |
length $self->{ct}->{pubid}); |
length $self->{ct}->{pubid}); |
2598 |
|
|
2608 |
redo A; |
redo A; |
2609 |
} elsif ($self->{nc} == 0x0022) { # " |
} elsif ($self->{nc} == 0x0022) { # " |
2610 |
!!!cp (196); |
!!!cp (196); |
2611 |
$self->{ct}->{sysid} = ''; # DOCTYPE |
$self->{ct}->{sysid} = ''; # DOCTYPE/ENTITY/NOTATION |
2612 |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; |
2613 |
!!!next-input-character; |
!!!next-input-character; |
2614 |
redo A; |
redo A; |
2615 |
} elsif ($self->{nc} == 0x0027) { # ' |
} elsif ($self->{nc} == 0x0027) { # ' |
2616 |
!!!cp (197); |
!!!cp (197); |
2617 |
$self->{ct}->{sysid} = ''; # DOCTYPE |
$self->{ct}->{sysid} = ''; # DOCTYPE/ENTITY/NOTATION |
2618 |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; |
2619 |
!!!next-input-character; |
!!!next-input-character; |
2620 |
redo A; |
redo A; |
2621 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2622 |
if ($self->{is_xml}) { |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2623 |
!!!cp (198.1); |
if ($self->{is_xml}) { |
2624 |
!!!parse-error (type => 'no SYSTEM literal'); |
!!!cp (198.1); |
2625 |
|
!!!parse-error (type => 'no SYSTEM literal'); |
2626 |
|
} else { |
2627 |
|
!!!cp (198); |
2628 |
|
} |
2629 |
|
$self->{state} = DATA_STATE; |
2630 |
|
$self->{s_kwd} = ''; |
2631 |
} else { |
} else { |
2632 |
!!!cp (198); |
if ($self->{ct}->{type} == NOTATION_TOKEN) { |
2633 |
|
!!!cp (198.2); |
2634 |
|
} else { |
2635 |
|
!!!cp (198.3); |
2636 |
|
!!!parse-error (type => 'no SYSTEM literal'); |
2637 |
|
} |
2638 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2639 |
} |
} |
2640 |
$self->{state} = DATA_STATE; |
|
|
$self->{s_kwd} = ''; |
|
2641 |
!!!next-input-character; |
!!!next-input-character; |
2642 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2643 |
redo A; |
redo A; |
2644 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2645 |
!!!cp (199); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2646 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!cp (199); |
2647 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
2648 |
$self->{state} = DATA_STATE; |
|
2649 |
$self->{s_kwd} = ''; |
$self->{state} = DATA_STATE; |
2650 |
|
$self->{s_kwd} = ''; |
2651 |
|
$self->{ct}->{quirks} = 1; |
2652 |
|
} else { |
2653 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
2654 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2655 |
|
} |
2656 |
|
|
2657 |
## reconsume |
## reconsume |
2658 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
$self->{ct}->{quirks} = 1; |
|
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2659 |
redo A; |
redo A; |
2660 |
} elsif ($self->{is_xml} and $self->{nc} == 0x005B) { # [ |
} elsif ($self->{is_xml} and |
2661 |
|
$self->{ct}->{type} == DOCTYPE_TOKEN and |
2662 |
|
$self->{nc} == 0x005B) { # [ |
2663 |
!!!cp (200.1); |
!!!cp (200.1); |
2664 |
!!!parse-error (type => 'no SYSTEM literal'); |
!!!parse-error (type => 'no SYSTEM literal'); |
2665 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2666 |
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2667 |
|
$self->{in_subset} = 1; |
2668 |
!!!next-input-character; |
!!!next-input-character; |
2669 |
|
!!!emit ($self->{ct}); # DOCTYPE |
2670 |
redo A; |
redo A; |
2671 |
} else { |
} else { |
|
!!!cp (200); |
|
2672 |
!!!parse-error (type => 'string after PUBLIC literal'); |
!!!parse-error (type => 'string after PUBLIC literal'); |
|
$self->{ct}->{quirks} = 1; |
|
2673 |
|
|
2674 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2675 |
|
!!!cp (200); |
2676 |
|
$self->{ct}->{quirks} = 1; |
2677 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2678 |
|
} else { |
2679 |
|
!!!cp (200.2); |
2680 |
|
$self->{state} = BOGUS_MD_STATE; |
2681 |
|
} |
2682 |
|
|
2683 |
!!!next-input-character; |
!!!next-input-character; |
2684 |
redo A; |
redo A; |
2685 |
} |
} |
2702 |
!!!next-input-character; |
!!!next-input-character; |
2703 |
redo A; |
redo A; |
2704 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
|
!!!cp (204); |
|
2705 |
!!!parse-error (type => 'no SYSTEM literal'); |
!!!parse-error (type => 'no SYSTEM literal'); |
|
$self->{state} = DATA_STATE; |
|
|
$self->{s_kwd} = ''; |
|
2706 |
!!!next-input-character; |
!!!next-input-character; |
2707 |
|
|
2708 |
$self->{ct}->{quirks} = 1; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2709 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!cp (204); |
2710 |
|
$self->{state} = DATA_STATE; |
2711 |
|
$self->{s_kwd} = ''; |
2712 |
|
$self->{ct}->{quirks} = 1; |
2713 |
|
} else { |
2714 |
|
!!!cp (204.1); |
2715 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2716 |
|
} |
2717 |
|
|
2718 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2719 |
redo A; |
redo A; |
2720 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2721 |
!!!cp (205); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2722 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!cp (205); |
2723 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
2724 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2725 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
2726 |
|
$self->{ct}->{quirks} = 1; |
2727 |
|
} else { |
2728 |
|
!!!cp (205.1); |
2729 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
2730 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2731 |
|
} |
2732 |
|
|
2733 |
## reconsume |
## reconsume |
2734 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
$self->{ct}->{quirks} = 1; |
|
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2735 |
redo A; |
redo A; |
2736 |
} elsif ($self->{is_xml} and $self->{nc} == 0x005B) { # [ |
} elsif ($self->{is_xml} and |
2737 |
|
$self->{ct}->{type} == DOCTYPE_TOKEN and |
2738 |
|
$self->{nc} == 0x005B) { # [ |
2739 |
!!!cp (206.1); |
!!!cp (206.1); |
2740 |
!!!parse-error (type => 'no SYSTEM literal'); |
!!!parse-error (type => 'no SYSTEM literal'); |
2741 |
|
|
2742 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2743 |
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2744 |
|
$self->{in_subset} = 1; |
2745 |
!!!next-input-character; |
!!!next-input-character; |
2746 |
|
!!!emit ($self->{ct}); # DOCTYPE |
2747 |
redo A; |
redo A; |
2748 |
} else { |
} else { |
|
!!!cp (206); |
|
2749 |
!!!parse-error (type => 'string after SYSTEM'); |
!!!parse-error (type => 'string after SYSTEM'); |
|
$self->{ct}->{quirks} = 1; |
|
2750 |
|
|
2751 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2752 |
|
!!!cp (206); |
2753 |
|
$self->{ct}->{quirks} = 1; |
2754 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2755 |
|
} else { |
2756 |
|
!!!cp (206.2); |
2757 |
|
$self->{state} = BOGUS_MD_STATE; |
2758 |
|
} |
2759 |
|
|
2760 |
!!!next-input-character; |
!!!next-input-character; |
2761 |
redo A; |
redo A; |
2762 |
} |
} |
2767 |
!!!next-input-character; |
!!!next-input-character; |
2768 |
redo A; |
redo A; |
2769 |
} elsif (not $self->{is_xml} and $self->{nc} == 0x003E) { # > |
} elsif (not $self->{is_xml} and $self->{nc} == 0x003E) { # > |
|
!!!cp (208); |
|
2770 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
2771 |
|
|
2772 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2773 |
$self->{s_kwd} = ''; |
!!!cp (208); |
2774 |
|
$self->{state} = DATA_STATE; |
2775 |
|
$self->{s_kwd} = ''; |
2776 |
|
$self->{ct}->{quirks} = 1; |
2777 |
|
} else { |
2778 |
|
!!!cp (208.1); |
2779 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2780 |
|
} |
2781 |
|
|
2782 |
!!!next-input-character; |
!!!next-input-character; |
2783 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
$self->{ct}->{quirks} = 1; |
|
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2784 |
redo A; |
redo A; |
2785 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (209); |
|
2786 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
2787 |
|
|
2788 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2789 |
$self->{s_kwd} = ''; |
!!!cp (209); |
2790 |
|
$self->{state} = DATA_STATE; |
2791 |
|
$self->{s_kwd} = ''; |
2792 |
|
$self->{ct}->{quirks} = 1; |
2793 |
|
} else { |
2794 |
|
!!!cp (209.1); |
2795 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2796 |
|
} |
2797 |
|
|
2798 |
## reconsume |
## reconsume |
2799 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
$self->{ct}->{quirks} = 1; |
|
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2800 |
redo A; |
redo A; |
2801 |
} else { |
} else { |
2802 |
!!!cp (210); |
!!!cp (210); |
2803 |
$self->{ct}->{sysid} # DOCTYPE |
$self->{ct}->{sysid} .= chr $self->{nc}; # DOCTYPE/ENTITY/NOTATION |
|
.= chr $self->{nc}; |
|
2804 |
$self->{read_until}->($self->{ct}->{sysid}, q[">], |
$self->{read_until}->($self->{ct}->{sysid}, q[">], |
2805 |
length $self->{ct}->{sysid}); |
length $self->{ct}->{sysid}); |
2806 |
|
|
2827 |
|
|
2828 |
redo A; |
redo A; |
2829 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (213); |
|
2830 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
2831 |
|
|
2832 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2833 |
$self->{s_kwd} = ''; |
!!!cp (213); |
2834 |
## reconsume |
$self->{state} = DATA_STATE; |
2835 |
|
$self->{s_kwd} = ''; |
2836 |
$self->{ct}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2837 |
!!!emit ($self->{ct}); # DOCTYPE |
} else { |
2838 |
|
!!!cp (213.1); |
2839 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2840 |
|
} |
2841 |
|
|
2842 |
|
## reconsume |
2843 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2844 |
redo A; |
redo A; |
2845 |
} else { |
} else { |
2846 |
!!!cp (214); |
!!!cp (214); |
2847 |
$self->{ct}->{sysid} # DOCTYPE |
$self->{ct}->{sysid} .= chr $self->{nc}; # DOCTYPE/ENTITY/NOTATION |
|
.= chr $self->{nc}; |
|
2848 |
$self->{read_until}->($self->{ct}->{sysid}, q['>], |
$self->{read_until}->($self->{ct}->{sysid}, q['>], |
2849 |
length $self->{ct}->{sysid}); |
length $self->{ct}->{sysid}); |
2850 |
|
|
2854 |
} |
} |
2855 |
} elsif ($self->{state} == AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE) { |
} elsif ($self->{state} == AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE) { |
2856 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
2857 |
!!!cp (215); |
if ($self->{ct}->{type} == GENERAL_ENTITY_TOKEN) { |
2858 |
## Stay in the state |
!!!cp (215.1); |
2859 |
|
$self->{state} = BEFORE_NDATA_STATE; |
2860 |
|
} else { |
2861 |
|
!!!cp (215); |
2862 |
|
## Stay in the state |
2863 |
|
} |
2864 |
!!!next-input-character; |
!!!next-input-character; |
2865 |
redo A; |
redo A; |
2866 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2867 |
!!!cp (216); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2868 |
$self->{state} = DATA_STATE; |
!!!cp (216); |
2869 |
$self->{s_kwd} = ''; |
$self->{state} = DATA_STATE; |
2870 |
!!!next-input-character; |
$self->{s_kwd} = ''; |
2871 |
|
} else { |
2872 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!cp (216.1); |
2873 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2874 |
|
} |
2875 |
|
|
2876 |
|
!!!next-input-character; |
2877 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2878 |
|
redo A; |
2879 |
|
} elsif ($self->{ct}->{type} == GENERAL_ENTITY_TOKEN and |
2880 |
|
($self->{nc} == 0x004E or # N |
2881 |
|
$self->{nc} == 0x006E)) { # n |
2882 |
|
!!!cp (216.2); |
2883 |
|
!!!parse-error (type => 'no space before NDATA'); ## TODO: type |
2884 |
|
$self->{state} = NDATA_STATE; |
2885 |
|
$self->{kwd} = chr $self->{nc}; |
2886 |
|
!!!next-input-character; |
2887 |
redo A; |
redo A; |
2888 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2889 |
!!!cp (217); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2890 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!cp (217); |
2891 |
$self->{state} = DATA_STATE; |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2892 |
$self->{s_kwd} = ''; |
$self->{state} = DATA_STATE; |
2893 |
## reconsume |
$self->{s_kwd} = ''; |
2894 |
|
$self->{ct}->{quirks} = 1; |
2895 |
$self->{ct}->{quirks} = 1; |
} else { |
2896 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!cp (217.1); |
2897 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
2898 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2899 |
|
} |
2900 |
|
|
2901 |
|
## reconsume |
2902 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2903 |
redo A; |
redo A; |
2904 |
} elsif ($self->{is_xml} and $self->{nc} == 0x005B) { # [ |
} elsif ($self->{is_xml} and |
2905 |
|
$self->{ct}->{type} == DOCTYPE_TOKEN and |
2906 |
|
$self->{nc} == 0x005B) { # [ |
2907 |
!!!cp (218.1); |
!!!cp (218.1); |
2908 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2909 |
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2910 |
|
$self->{in_subset} = 1; |
2911 |
!!!next-input-character; |
!!!next-input-character; |
2912 |
|
!!!emit ($self->{ct}); # DOCTYPE |
2913 |
redo A; |
redo A; |
2914 |
} else { |
} else { |
|
!!!cp (218); |
|
2915 |
!!!parse-error (type => 'string after SYSTEM literal'); |
!!!parse-error (type => 'string after SYSTEM literal'); |
|
#$self->{ct}->{quirks} = 1; |
|
2916 |
|
|
2917 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2918 |
|
!!!cp (218); |
2919 |
|
#$self->{ct}->{quirks} = 1; |
2920 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2921 |
|
} else { |
2922 |
|
!!!cp (218.2); |
2923 |
|
$self->{state} = BOGUS_MD_STATE; |
2924 |
|
} |
2925 |
|
|
2926 |
|
!!!next-input-character; |
2927 |
|
redo A; |
2928 |
|
} |
2929 |
|
} elsif ($self->{state} == BEFORE_NDATA_STATE) { |
2930 |
|
if ($is_space->{$self->{nc}}) { |
2931 |
|
!!!cp (218.3); |
2932 |
|
## Stay in the state. |
2933 |
|
!!!next-input-character; |
2934 |
|
redo A; |
2935 |
|
} elsif ($self->{nc} == 0x003E) { # > |
2936 |
|
!!!cp (218.4); |
2937 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2938 |
|
!!!next-input-character; |
2939 |
|
!!!emit ($self->{ct}); # ENTITY |
2940 |
|
redo A; |
2941 |
|
} elsif ($self->{nc} == 0x004E or # N |
2942 |
|
$self->{nc} == 0x006E) { # n |
2943 |
|
!!!cp (218.5); |
2944 |
|
$self->{state} = NDATA_STATE; |
2945 |
|
$self->{kwd} = chr $self->{nc}; |
2946 |
|
!!!next-input-character; |
2947 |
|
redo A; |
2948 |
|
} elsif ($self->{nc} == -1) { |
2949 |
|
!!!cp (218.6); |
2950 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
2951 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2952 |
|
## reconsume |
2953 |
|
!!!emit ($self->{ct}); # ENTITY |
2954 |
|
redo A; |
2955 |
|
} else { |
2956 |
|
!!!cp (218.7); |
2957 |
|
!!!parse-error (type => 'string after SYSTEM literal'); |
2958 |
|
$self->{state} = BOGUS_MD_STATE; |
2959 |
!!!next-input-character; |
!!!next-input-character; |
2960 |
redo A; |
redo A; |
2961 |
} |
} |
2970 |
|
|
2971 |
redo A; |
redo A; |
2972 |
} elsif ($self->{is_xml} and $self->{nc} == 0x005B) { # [ |
} elsif ($self->{is_xml} and $self->{nc} == 0x005B) { # [ |
2973 |
if ($self->{ct}->{has_internal_subset}) { # DOCTYPE |
!!!cp (220.1); |
2974 |
!!!cp (220.2); |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2975 |
## Stay in the state. |
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2976 |
!!!next-input-character; |
$self->{in_subset} = 1; |
2977 |
redo A; |
!!!next-input-character; |
2978 |
} else { |
!!!emit ($self->{ct}); # DOCTYPE |
2979 |
!!!cp (220.1); |
redo A; |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
|
|
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
|
|
!!!next-input-character; |
|
|
redo A; |
|
|
} |
|
2980 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2981 |
!!!cp (220); |
!!!cp (220); |
2982 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
3089 |
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
3090 |
$self->{entity_add} => 1, |
$self->{entity_add} => 1, |
3091 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
3092 |
!!!cp (1001); |
if ($self->{is_xml}) { |
3093 |
|
!!!cp (1001.1); |
3094 |
|
!!!parse-error (type => 'bare ero', |
3095 |
|
line => $self->{line_prev}, |
3096 |
|
column => $self->{column_prev} |
3097 |
|
+ ($self->{nc} == -1 ? 1 : 0)); |
3098 |
|
} else { |
3099 |
|
!!!cp (1001); |
3100 |
|
## No error |
3101 |
|
} |
3102 |
## Don't consume |
## Don't consume |
|
## No error |
|
3103 |
## Return nothing. |
## Return nothing. |
3104 |
# |
# |
3105 |
} elsif ($self->{nc} == 0x0023) { # # |
} elsif ($self->{nc} == 0x0023) { # # |
3108 |
$self->{kwd} = '#'; |
$self->{kwd} = '#'; |
3109 |
!!!next-input-character; |
!!!next-input-character; |
3110 |
redo A; |
redo A; |
3111 |
} elsif ((0x0041 <= $self->{nc} and |
} elsif ($self->{is_xml} or |
3112 |
|
(0x0041 <= $self->{nc} and |
3113 |
$self->{nc} <= 0x005A) or # A..Z |
$self->{nc} <= 0x005A) or # A..Z |
3114 |
(0x0061 <= $self->{nc} and |
(0x0061 <= $self->{nc} and |
3115 |
$self->{nc} <= 0x007A)) { # a..z |
$self->{nc} <= 0x007A)) { # a..z |
3153 |
redo A; |
redo A; |
3154 |
} |
} |
3155 |
} elsif ($self->{state} == ENTITY_HASH_STATE) { |
} elsif ($self->{state} == ENTITY_HASH_STATE) { |
3156 |
if ($self->{nc} == 0x0078 or # x |
if ($self->{nc} == 0x0078) { # x |
|
$self->{nc} == 0x0058) { # X |
|
3157 |
!!!cp (995); |
!!!cp (995); |
3158 |
$self->{state} = HEXREF_X_STATE; |
$self->{state} = HEXREF_X_STATE; |
3159 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3160 |
!!!next-input-character; |
!!!next-input-character; |
3161 |
redo A; |
redo A; |
3162 |
|
} elsif ($self->{nc} == 0x0058) { # X |
3163 |
|
!!!cp (995.1); |
3164 |
|
if ($self->{is_xml}) { |
3165 |
|
!!!parse-error (type => 'uppercase hcro'); ## TODO: type |
3166 |
|
} |
3167 |
|
$self->{state} = HEXREF_X_STATE; |
3168 |
|
$self->{kwd} .= chr $self->{nc}; |
3169 |
|
!!!next-input-character; |
3170 |
|
redo A; |
3171 |
} elsif (0x0030 <= $self->{nc} and |
} elsif (0x0030 <= $self->{nc} and |
3172 |
$self->{nc} <= 0x0039) { # 0..9 |
$self->{nc} <= 0x0039) { # 0..9 |
3173 |
!!!cp (994); |
!!!cp (994); |
3228 |
my $code = $self->{kwd}; |
my $code = $self->{kwd}; |
3229 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3230 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3231 |
if ($charref_map->{$code}) { |
if ((not $self->{is_xml} and $charref_map->{$code}) or |
3232 |
|
($self->{is_xml} and 0xD800 <= $code and $code <= 0xDFFF) or |
3233 |
|
($self->{is_xml} and $code == 0x0000)) { |
3234 |
!!!cp (1015); |
!!!cp (1015); |
3235 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
3236 |
text => (sprintf 'U+%04X', $code), |
text => (sprintf 'U+%04X', $code), |
3343 |
my $code = $self->{kwd}; |
my $code = $self->{kwd}; |
3344 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3345 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3346 |
if ($charref_map->{$code}) { |
if ((not $self->{is_xml} and $charref_map->{$code}) or |
3347 |
|
($self->{is_xml} and 0xD800 <= $code and $code <= 0xDFFF) or |
3348 |
|
($self->{is_xml} and $code == 0x0000)) { |
3349 |
!!!cp (1008); |
!!!cp (1008); |
3350 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
3351 |
text => (sprintf 'U+%04X', $code), |
text => (sprintf 'U+%04X', $code), |
3379 |
redo A; |
redo A; |
3380 |
} |
} |
3381 |
} elsif ($self->{state} == ENTITY_NAME_STATE) { |
} elsif ($self->{state} == ENTITY_NAME_STATE) { |
3382 |
if (length $self->{kwd} < 30 and |
if ((0x0041 <= $self->{nc} and # a |
3383 |
## NOTE: Some number greater than the maximum length of entity name |
$self->{nc} <= 0x005A) or # x |
3384 |
((0x0041 <= $self->{nc} and # a |
(0x0061 <= $self->{nc} and # a |
3385 |
$self->{nc} <= 0x005A) or # x |
$self->{nc} <= 0x007A) or # z |
3386 |
(0x0061 <= $self->{nc} and # a |
(0x0030 <= $self->{nc} and # 0 |
3387 |
$self->{nc} <= 0x007A) or # z |
$self->{nc} <= 0x0039) or # 9 |
3388 |
(0x0030 <= $self->{nc} and # 0 |
$self->{nc} == 0x003B or # ; |
3389 |
$self->{nc} <= 0x0039) or # 9 |
($self->{is_xml} and |
3390 |
$self->{nc} == 0x003B)) { # ; |
not ($is_space->{$self->{nc}} or |
3391 |
|
{ |
3392 |
|
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
3393 |
|
$self->{entity_add} => 1, |
3394 |
|
}->{$self->{nc}}))) { |
3395 |
our $EntityChar; |
our $EntityChar; |
3396 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3397 |
if (defined $EntityChar->{$self->{kwd}}) { |
if (defined $EntityChar->{$self->{kwd}} or |
3398 |
|
$self->{ge}->{$self->{kwd}}) { |
3399 |
if ($self->{nc} == 0x003B) { # ; |
if ($self->{nc} == 0x003B) { # ; |
3400 |
!!!cp (1020); |
if (defined $self->{ge}->{$self->{kwd}}) { |
3401 |
$self->{entity__value} = $EntityChar->{$self->{kwd}}; |
if ($self->{ge}->{$self->{kwd}}->{only_text}) { |
3402 |
|
!!!cp (1020.1); |
3403 |
|
$self->{entity__value} = $self->{ge}->{$self->{kwd}}->{value}; |
3404 |
|
} else { |
3405 |
|
if (defined $self->{ge}->{$self->{kwd}}->{notation}) { |
3406 |
|
!!!cp (1020.2); |
3407 |
|
!!!parse-error (type => 'unparsed entity', ## TODO: type |
3408 |
|
value => $self->{kwd}); |
3409 |
|
} else { |
3410 |
|
!!!cp (1020.3); |
3411 |
|
} |
3412 |
|
$self->{entity__value} = '&' . $self->{kwd}; ## TODO: expand |
3413 |
|
} |
3414 |
|
} else { |
3415 |
|
if ($self->{is_xml}) { |
3416 |
|
!!!cp (1020.4); |
3417 |
|
!!!parse-error (type => 'entity not declared', ## TODO: type |
3418 |
|
value => $self->{kwd}, |
3419 |
|
level => { |
3420 |
|
'amp;' => $self->{level}->{warn}, |
3421 |
|
'quot;' => $self->{level}->{warn}, |
3422 |
|
'lt;' => $self->{level}->{warn}, |
3423 |
|
'gt;' => $self->{level}->{warn}, |
3424 |
|
'apos;' => $self->{level}->{warn}, |
3425 |
|
}->{$self->{kwd}} || |
3426 |
|
$self->{level}->{must}); |
3427 |
|
} else { |
3428 |
|
!!!cp (1020); |
3429 |
|
} |
3430 |
|
$self->{entity__value} = $EntityChar->{$self->{kwd}}; |
3431 |
|
} |
3432 |
$self->{entity__match} = 1; |
$self->{entity__match} = 1; |
3433 |
!!!next-input-character; |
!!!next-input-character; |
3434 |
# |
# |
3514 |
## XML-only states |
## XML-only states |
3515 |
|
|
3516 |
} elsif ($self->{state} == PI_STATE) { |
} elsif ($self->{state} == PI_STATE) { |
3517 |
|
## XML5: "Pi state" and "DOCTYPE pi state". |
3518 |
|
|
3519 |
if ($is_space->{$self->{nc}} or |
if ($is_space->{$self->{nc}} or |
3520 |
$self->{nc} == 0x003F or # ? ## XML5: Same as "Anything else" |
$self->{nc} == 0x003F or # ? |
3521 |
$self->{nc} == -1) { |
$self->{nc} == -1) { |
3522 |
|
## XML5: U+003F: "pi state": Same as "Anything else"; "DOCTYPE |
3523 |
|
## pi state": Switch to the "DOCTYPE pi after state". EOF: |
3524 |
|
## "DOCTYPE pi state": Parse error, switch to the "data |
3525 |
|
## state". |
3526 |
!!!parse-error (type => 'bare pio', ## TODO: type |
!!!parse-error (type => 'bare pio', ## TODO: type |
3527 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
3528 |
column => $self->{column_prev} |
column => $self->{column_prev} |
3537 |
}; |
}; |
3538 |
redo A; |
redo A; |
3539 |
} else { |
} else { |
3540 |
|
## XML5: "DOCTYPE pi state": Stay in the state. |
3541 |
$self->{ct} = {type => PI_TOKEN, |
$self->{ct} = {type => PI_TOKEN, |
3542 |
target => chr $self->{nc}, |
target => chr $self->{nc}, |
3543 |
data => '', |
data => '', |
3555 |
redo A; |
redo A; |
3556 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
3557 |
!!!parse-error (type => 'no pic'); ## TODO: type |
!!!parse-error (type => 'no pic'); ## TODO: type |
3558 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
3559 |
$self->{s_kwd} = ''; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
3560 |
|
} else { |
3561 |
|
$self->{state} = DATA_STATE; |
3562 |
|
$self->{s_kwd} = ''; |
3563 |
|
} |
3564 |
## Reconsume. |
## Reconsume. |
3565 |
!!!emit ($self->{ct}); # pi |
!!!emit ($self->{ct}); # pi |
3566 |
redo A; |
redo A; |
3591 |
redo A; |
redo A; |
3592 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
3593 |
!!!parse-error (type => 'no pic'); ## TODO: type |
!!!parse-error (type => 'no pic'); ## TODO: type |
3594 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
3595 |
$self->{s_kwd} = ''; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state" |
3596 |
|
} else { |
3597 |
|
$self->{state} = DATA_STATE; |
3598 |
|
$self->{s_kwd} = ''; |
3599 |
|
} |
3600 |
## Reprocess. |
## Reprocess. |
3601 |
!!!emit ($self->{ct}); # pi |
!!!emit ($self->{ct}); # pi |
3602 |
redo A; |
redo A; |
3610 |
redo A; |
redo A; |
3611 |
} |
} |
3612 |
} elsif ($self->{state} == PI_AFTER_STATE) { |
} elsif ($self->{state} == PI_AFTER_STATE) { |
3613 |
|
## XML5: Part of "Pi after state". |
3614 |
|
|
3615 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
3616 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
3617 |
$self->{s_kwd} = ''; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
3618 |
|
} else { |
3619 |
|
$self->{state} = DATA_STATE; |
3620 |
|
$self->{s_kwd} = ''; |
3621 |
|
} |
3622 |
!!!next-input-character; |
!!!next-input-character; |
3623 |
!!!emit ($self->{ct}); # pi |
!!!emit ($self->{ct}); # pi |
3624 |
redo A; |
redo A; |
3641 |
redo A; |
redo A; |
3642 |
} |
} |
3643 |
} elsif ($self->{state} == PI_DATA_AFTER_STATE) { |
} elsif ($self->{state} == PI_DATA_AFTER_STATE) { |
3644 |
## XML5: Same as "pi after state" in XML5 |
## XML5: Same as "pi after state" and "DOCTYPE pi after state". |
3645 |
|
|
3646 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
3647 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
3648 |
$self->{s_kwd} = ''; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
3649 |
|
} else { |
3650 |
|
$self->{state} = DATA_STATE; |
3651 |
|
$self->{s_kwd} = ''; |
3652 |
|
} |
3653 |
!!!next-input-character; |
!!!next-input-character; |
3654 |
!!!emit ($self->{ct}); # pi |
!!!emit ($self->{ct}); # pi |
3655 |
redo A; |
redo A; |
3667 |
|
|
3668 |
} elsif ($self->{state} == DOCTYPE_INTERNAL_SUBSET_STATE) { |
} elsif ($self->{state} == DOCTYPE_INTERNAL_SUBSET_STATE) { |
3669 |
if ($self->{nc} == 0x003C) { # < |
if ($self->{nc} == 0x003C) { # < |
3670 |
## TODO: |
$self->{state} = DOCTYPE_TAG_STATE; |
3671 |
!!!next-input-character; |
!!!next-input-character; |
3672 |
redo A; |
redo A; |
3673 |
} elsif ($self->{nc} == 0x0025) { # % |
} elsif ($self->{nc} == 0x0025) { # % |
3674 |
## XML5: Not defined yet. |
## XML5: Not defined yet. |
3675 |
|
|
3676 |
## TODO: |
## TODO: |
3677 |
|
|
3678 |
|
if (not $self->{stop_processing} and |
3679 |
|
not $self->{document}->xml_standalone) { |
3680 |
|
!!!parse-error (type => 'stop processing', ## TODO: type |
3681 |
|
level => $self->{level}->{info}); |
3682 |
|
$self->{stop_processing} = 1; |
3683 |
|
} |
3684 |
|
|
3685 |
!!!next-input-character; |
!!!next-input-character; |
3686 |
redo A; |
redo A; |
3687 |
} elsif ($self->{nc} == 0x005D) { # ] |
} elsif ($self->{nc} == 0x005D) { # ] |
3688 |
|
delete $self->{in_subset}; |
3689 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_AFTER_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_AFTER_STATE; |
3690 |
!!!next-input-character; |
!!!next-input-character; |
3691 |
redo A; |
redo A; |
3695 |
redo A; |
redo A; |
3696 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
3697 |
!!!parse-error (type => 'unclosed internal subset'); ## TODO: type |
!!!parse-error (type => 'unclosed internal subset'); ## TODO: type |
3698 |
|
delete $self->{in_subset}; |
3699 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
3700 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
3701 |
## Reconsume. |
## Reconsume. |
3702 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ({type => END_OF_DOCTYPE_TOKEN}); |
3703 |
redo A; |
redo A; |
3704 |
} else { |
} else { |
3705 |
unless ($self->{internal_subset_tainted}) { |
unless ($self->{internal_subset_tainted}) { |
3716 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
3717 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
3718 |
!!!next-input-character; |
!!!next-input-character; |
3719 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ({type => END_OF_DOCTYPE_TOKEN}); |
3720 |
redo A; |
redo A; |
3721 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
3722 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
3723 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
3724 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
3725 |
## Reconsume. |
## Reconsume. |
3726 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ({type => END_OF_DOCTYPE_TOKEN}); |
3727 |
redo A; |
redo A; |
3728 |
} else { |
} else { |
3729 |
## XML5: No parse error and stay in the state. |
## XML5: No parse error and stay in the state. |
3730 |
!!!parse-error (type => 'string after internal subset'); ## TODO: type |
!!!parse-error (type => 'string after internal subset'); ## TODO: type |
3731 |
|
|
3732 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
$self->{state} = BOGUS_DOCTYPE_INTERNAL_SUBSET_AFTER_STATE; |
3733 |
|
!!!next-input-character; |
3734 |
|
redo A; |
3735 |
|
} |
3736 |
|
} elsif ($self->{state} == BOGUS_DOCTYPE_INTERNAL_SUBSET_AFTER_STATE) { |
3737 |
|
if ($self->{nc} == 0x003E) { # > |
3738 |
|
$self->{state} = DATA_STATE; |
3739 |
|
$self->{s_kwd} = ''; |
3740 |
|
!!!next-input-character; |
3741 |
|
!!!emit ({type => END_OF_DOCTYPE_TOKEN}); |
3742 |
|
redo A; |
3743 |
|
} elsif ($self->{nc} == -1) { |
3744 |
|
$self->{state} = DATA_STATE; |
3745 |
|
$self->{s_kwd} = ''; |
3746 |
|
## Reconsume. |
3747 |
|
!!!emit ({type => END_OF_DOCTYPE_TOKEN}); |
3748 |
|
redo A; |
3749 |
|
} else { |
3750 |
|
## Stay in the state. |
3751 |
|
!!!next-input-character; |
3752 |
|
redo A; |
3753 |
|
} |
3754 |
|
} elsif ($self->{state} == DOCTYPE_TAG_STATE) { |
3755 |
|
if ($self->{nc} == 0x0021) { # ! |
3756 |
|
$self->{state} = DOCTYPE_MARKUP_DECLARATION_OPEN_STATE; |
3757 |
|
!!!next-input-character; |
3758 |
|
redo A; |
3759 |
|
} elsif ($self->{nc} == 0x003F) { # ? |
3760 |
|
$self->{state} = PI_STATE; |
3761 |
|
!!!next-input-character; |
3762 |
|
redo A; |
3763 |
|
} elsif ($self->{nc} == -1) { |
3764 |
|
!!!parse-error (type => 'bare stago'); |
3765 |
|
$self->{state} = DATA_STATE; |
3766 |
|
$self->{s_kwd} = ''; |
3767 |
|
## Reconsume. |
3768 |
|
redo A; |
3769 |
|
} else { |
3770 |
|
!!!parse-error (type => 'bare stago', ## XML5: Not a parse error. |
3771 |
|
line => $self->{line_prev}, |
3772 |
|
column => $self->{column_prev}); |
3773 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3774 |
|
$self->{ct} = {type => COMMENT_TOKEN, |
3775 |
|
data => '', |
3776 |
|
}; ## NOTE: Will be discarded. |
3777 |
|
!!!next-input-character; |
3778 |
|
redo A; |
3779 |
|
} |
3780 |
|
} elsif ($self->{state} == DOCTYPE_MARKUP_DECLARATION_OPEN_STATE) { |
3781 |
|
## XML5: "DOCTYPE markup declaration state". |
3782 |
|
|
3783 |
|
if ($self->{nc} == 0x002D) { # - |
3784 |
|
$self->{state} = MD_HYPHEN_STATE; |
3785 |
|
!!!next-input-character; |
3786 |
|
redo A; |
3787 |
|
} elsif ($self->{nc} == 0x0045 or # E |
3788 |
|
$self->{nc} == 0x0065) { # e |
3789 |
|
$self->{state} = MD_E_STATE; |
3790 |
|
$self->{kwd} = chr $self->{nc}; |
3791 |
|
!!!next-input-character; |
3792 |
|
redo A; |
3793 |
|
} elsif ($self->{nc} == 0x0041 or # A |
3794 |
|
$self->{nc} == 0x0061) { # a |
3795 |
|
$self->{state} = MD_ATTLIST_STATE; |
3796 |
|
$self->{kwd} = chr $self->{nc}; |
3797 |
|
!!!next-input-character; |
3798 |
|
redo A; |
3799 |
|
} elsif ($self->{nc} == 0x004E or # N |
3800 |
|
$self->{nc} == 0x006E) { # n |
3801 |
|
$self->{state} = MD_NOTATION_STATE; |
3802 |
|
$self->{kwd} = chr $self->{nc}; |
3803 |
|
!!!next-input-character; |
3804 |
|
redo A; |
3805 |
|
} else { |
3806 |
|
# |
3807 |
|
} |
3808 |
|
|
3809 |
|
## XML5: No parse error. |
3810 |
|
!!!parse-error (type => 'bogus comment', |
3811 |
|
line => $self->{line_prev}, |
3812 |
|
column => $self->{column_prev} - 1); |
3813 |
|
## Reconsume. |
3814 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3815 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded. |
3816 |
|
redo A; |
3817 |
|
} elsif ($self->{state} == MD_E_STATE) { |
3818 |
|
if ($self->{nc} == 0x004E or # N |
3819 |
|
$self->{nc} == 0x006E) { # n |
3820 |
|
$self->{state} = MD_ENTITY_STATE; |
3821 |
|
$self->{kwd} .= chr $self->{nc}; |
3822 |
|
!!!next-input-character; |
3823 |
|
redo A; |
3824 |
|
} elsif ($self->{nc} == 0x004C or # L |
3825 |
|
$self->{nc} == 0x006C) { # l |
3826 |
|
## XML5: <!ELEMENT> not supported. |
3827 |
|
$self->{state} = MD_ELEMENT_STATE; |
3828 |
|
$self->{kwd} .= chr $self->{nc}; |
3829 |
|
!!!next-input-character; |
3830 |
|
redo A; |
3831 |
|
} else { |
3832 |
|
## XML5: No parse error. |
3833 |
|
!!!parse-error (type => 'bogus comment', |
3834 |
|
line => $self->{line_prev}, |
3835 |
|
column => $self->{column_prev} - 2 |
3836 |
|
+ 1 * ($self->{nc} == -1)); |
3837 |
|
## Reconsume. |
3838 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3839 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded |
3840 |
|
redo A; |
3841 |
|
} |
3842 |
|
} elsif ($self->{state} == MD_ENTITY_STATE) { |
3843 |
|
if ($self->{nc} == [ |
3844 |
|
undef, |
3845 |
|
undef, |
3846 |
|
0x0054, # T |
3847 |
|
0x0049, # I |
3848 |
|
0x0054, # T |
3849 |
|
]->[length $self->{kwd}] or |
3850 |
|
$self->{nc} == [ |
3851 |
|
undef, |
3852 |
|
undef, |
3853 |
|
0x0074, # t |
3854 |
|
0x0069, # i |
3855 |
|
0x0074, # t |
3856 |
|
]->[length $self->{kwd}]) { |
3857 |
|
## Stay in the state. |
3858 |
|
$self->{kwd} .= chr $self->{nc}; |
3859 |
|
!!!next-input-character; |
3860 |
|
redo A; |
3861 |
|
} elsif ((length $self->{kwd}) == 5 and |
3862 |
|
($self->{nc} == 0x0059 or # Y |
3863 |
|
$self->{nc} == 0x0079)) { # y |
3864 |
|
if ($self->{kwd} ne 'ENTIT' or $self->{nc} == 0x0079) { |
3865 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
3866 |
|
text => 'ENTITY', |
3867 |
|
line => $self->{line_prev}, |
3868 |
|
column => $self->{column_prev} - 4); |
3869 |
|
} |
3870 |
|
$self->{ct} = {type => GENERAL_ENTITY_TOKEN, name => '', |
3871 |
|
line => $self->{line_prev}, |
3872 |
|
column => $self->{column_prev} - 6}; |
3873 |
|
$self->{state} = DOCTYPE_MD_STATE; |
3874 |
|
!!!next-input-character; |
3875 |
|
redo A; |
3876 |
|
} else { |
3877 |
|
!!!parse-error (type => 'bogus comment', |
3878 |
|
line => $self->{line_prev}, |
3879 |
|
column => $self->{column_prev} - 1 |
3880 |
|
- (length $self->{kwd}) |
3881 |
|
+ 1 * ($self->{nc} == -1)); |
3882 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3883 |
|
## Reconsume. |
3884 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded |
3885 |
|
redo A; |
3886 |
|
} |
3887 |
|
} elsif ($self->{state} == MD_ELEMENT_STATE) { |
3888 |
|
if ($self->{nc} == [ |
3889 |
|
undef, |
3890 |
|
undef, |
3891 |
|
0x0045, # E |
3892 |
|
0x004D, # M |
3893 |
|
0x0045, # E |
3894 |
|
0x004E, # N |
3895 |
|
]->[length $self->{kwd}] or |
3896 |
|
$self->{nc} == [ |
3897 |
|
undef, |
3898 |
|
undef, |
3899 |
|
0x0065, # e |
3900 |
|
0x006D, # m |
3901 |
|
0x0065, # e |
3902 |
|
0x006E, # n |
3903 |
|
]->[length $self->{kwd}]) { |
3904 |
|
## Stay in the state. |
3905 |
|
$self->{kwd} .= chr $self->{nc}; |
3906 |
|
!!!next-input-character; |
3907 |
|
redo A; |
3908 |
|
} elsif ((length $self->{kwd}) == 6 and |
3909 |
|
($self->{nc} == 0x0054 or # T |
3910 |
|
$self->{nc} == 0x0074)) { # t |
3911 |
|
if ($self->{kwd} ne 'ELEMEN' or $self->{nc} == 0x0074) { |
3912 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
3913 |
|
text => 'ELEMENT', |
3914 |
|
line => $self->{line_prev}, |
3915 |
|
column => $self->{column_prev} - 5); |
3916 |
|
} |
3917 |
|
$self->{ct} = {type => ELEMENT_TOKEN, name => '', |
3918 |
|
line => $self->{line_prev}, |
3919 |
|
column => $self->{column_prev} - 7}; |
3920 |
|
$self->{state} = DOCTYPE_MD_STATE; |
3921 |
|
!!!next-input-character; |
3922 |
|
redo A; |
3923 |
|
} else { |
3924 |
|
!!!parse-error (type => 'bogus comment', |
3925 |
|
line => $self->{line_prev}, |
3926 |
|
column => $self->{column_prev} - 1 |
3927 |
|
- (length $self->{kwd}) |
3928 |
|
+ 1 * ($self->{nc} == -1)); |
3929 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3930 |
|
## Reconsume. |
3931 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded |
3932 |
|
redo A; |
3933 |
|
} |
3934 |
|
} elsif ($self->{state} == MD_ATTLIST_STATE) { |
3935 |
|
if ($self->{nc} == [ |
3936 |
|
undef, |
3937 |
|
0x0054, # T |
3938 |
|
0x0054, # T |
3939 |
|
0x004C, # L |
3940 |
|
0x0049, # I |
3941 |
|
0x0053, # S |
3942 |
|
]->[length $self->{kwd}] or |
3943 |
|
$self->{nc} == [ |
3944 |
|
undef, |
3945 |
|
0x0074, # t |
3946 |
|
0x0074, # t |
3947 |
|
0x006C, # l |
3948 |
|
0x0069, # i |
3949 |
|
0x0073, # s |
3950 |
|
]->[length $self->{kwd}]) { |
3951 |
|
## Stay in the state. |
3952 |
|
$self->{kwd} .= chr $self->{nc}; |
3953 |
|
!!!next-input-character; |
3954 |
|
redo A; |
3955 |
|
} elsif ((length $self->{kwd}) == 6 and |
3956 |
|
($self->{nc} == 0x0054 or # T |
3957 |
|
$self->{nc} == 0x0074)) { # t |
3958 |
|
if ($self->{kwd} ne 'ATTLIS' or $self->{nc} == 0x0074) { |
3959 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
3960 |
|
text => 'ATTLIST', |
3961 |
|
line => $self->{line_prev}, |
3962 |
|
column => $self->{column_prev} - 5); |
3963 |
|
} |
3964 |
|
$self->{ct} = {type => ATTLIST_TOKEN, name => '', |
3965 |
|
attrdefs => [], |
3966 |
|
line => $self->{line_prev}, |
3967 |
|
column => $self->{column_prev} - 7}; |
3968 |
|
$self->{state} = DOCTYPE_MD_STATE; |
3969 |
|
!!!next-input-character; |
3970 |
|
redo A; |
3971 |
|
} else { |
3972 |
|
!!!parse-error (type => 'bogus comment', |
3973 |
|
line => $self->{line_prev}, |
3974 |
|
column => $self->{column_prev} - 1 |
3975 |
|
- (length $self->{kwd}) |
3976 |
|
+ 1 * ($self->{nc} == -1)); |
3977 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3978 |
|
## Reconsume. |
3979 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded |
3980 |
|
redo A; |
3981 |
|
} |
3982 |
|
} elsif ($self->{state} == MD_NOTATION_STATE) { |
3983 |
|
if ($self->{nc} == [ |
3984 |
|
undef, |
3985 |
|
0x004F, # O |
3986 |
|
0x0054, # T |
3987 |
|
0x0041, # A |
3988 |
|
0x0054, # T |
3989 |
|
0x0049, # I |
3990 |
|
0x004F, # O |
3991 |
|
]->[length $self->{kwd}] or |
3992 |
|
$self->{nc} == [ |
3993 |
|
undef, |
3994 |
|
0x006F, # o |
3995 |
|
0x0074, # t |
3996 |
|
0x0061, # a |
3997 |
|
0x0074, # t |
3998 |
|
0x0069, # i |
3999 |
|
0x006F, # o |
4000 |
|
]->[length $self->{kwd}]) { |
4001 |
|
## Stay in the state. |
4002 |
|
$self->{kwd} .= chr $self->{nc}; |
4003 |
|
!!!next-input-character; |
4004 |
|
redo A; |
4005 |
|
} elsif ((length $self->{kwd}) == 7 and |
4006 |
|
($self->{nc} == 0x004E or # N |
4007 |
|
$self->{nc} == 0x006E)) { # n |
4008 |
|
if ($self->{kwd} ne 'NOTATIO' or $self->{nc} == 0x006E) { |
4009 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
4010 |
|
text => 'NOTATION', |
4011 |
|
line => $self->{line_prev}, |
4012 |
|
column => $self->{column_prev} - 6); |
4013 |
|
} |
4014 |
|
$self->{ct} = {type => NOTATION_TOKEN, name => '', |
4015 |
|
line => $self->{line_prev}, |
4016 |
|
column => $self->{column_prev} - 8}; |
4017 |
|
$self->{state} = DOCTYPE_MD_STATE; |
4018 |
|
!!!next-input-character; |
4019 |
|
redo A; |
4020 |
|
} else { |
4021 |
|
!!!parse-error (type => 'bogus comment', |
4022 |
|
line => $self->{line_prev}, |
4023 |
|
column => $self->{column_prev} - 1 |
4024 |
|
- (length $self->{kwd}) |
4025 |
|
+ 1 * ($self->{nc} == -1)); |
4026 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
4027 |
|
## Reconsume. |
4028 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded |
4029 |
|
redo A; |
4030 |
|
} |
4031 |
|
} elsif ($self->{state} == DOCTYPE_MD_STATE) { |
4032 |
|
## XML5: "DOCTYPE ENTITY state", "DOCTYPE ATTLIST state", and |
4033 |
|
## "DOCTYPE NOTATION state". |
4034 |
|
|
4035 |
|
if ($is_space->{$self->{nc}}) { |
4036 |
|
## XML5: [NOTATION] Switch to the "DOCTYPE NOTATION identifier state". |
4037 |
|
$self->{state} = BEFORE_MD_NAME_STATE; |
4038 |
|
!!!next-input-character; |
4039 |
|
redo A; |
4040 |
|
} elsif ($self->{ct}->{type} == GENERAL_ENTITY_TOKEN and |
4041 |
|
$self->{nc} == 0x0025) { # % |
4042 |
|
## XML5: Switch to the "DOCTYPE bogus comment state". |
4043 |
|
!!!parse-error (type => 'no space before md name'); ## TODO: type |
4044 |
|
$self->{state} = DOCTYPE_ENTITY_PARAMETER_BEFORE_STATE; |
4045 |
|
!!!next-input-character; |
4046 |
|
redo A; |
4047 |
|
} elsif ($self->{nc} == -1) { |
4048 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4049 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4050 |
|
## Reconsume. |
4051 |
|
redo A; |
4052 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4053 |
|
## XML5: Switch to the "DOCTYPE bogus comment state". |
4054 |
|
!!!parse-error (type => 'no md name'); ## TODO: type |
4055 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4056 |
|
!!!next-input-character; |
4057 |
|
redo A; |
4058 |
|
} else { |
4059 |
|
## XML5: Switch to the "DOCTYPE bogus comment state". |
4060 |
|
!!!parse-error (type => 'no space before md name'); ## TODO: type |
4061 |
|
$self->{state} = BEFORE_MD_NAME_STATE; |
4062 |
|
redo A; |
4063 |
|
} |
4064 |
|
} elsif ($self->{state} == BEFORE_MD_NAME_STATE) { |
4065 |
|
## XML5: "DOCTYPE ENTITY parameter state", "DOCTYPE ENTITY type |
4066 |
|
## before state", "DOCTYPE ATTLIST name before state". |
4067 |
|
|
4068 |
|
if ($is_space->{$self->{nc}}) { |
4069 |
|
## Stay in the state. |
4070 |
|
!!!next-input-character; |
4071 |
|
redo A; |
4072 |
|
} elsif ($self->{ct}->{type} == GENERAL_ENTITY_TOKEN and |
4073 |
|
$self->{nc} == 0x0025) { # % |
4074 |
|
$self->{state} = DOCTYPE_ENTITY_PARAMETER_BEFORE_STATE; |
4075 |
|
!!!next-input-character; |
4076 |
|
redo A; |
4077 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4078 |
|
## XML5: Same as "Anything else". |
4079 |
|
!!!parse-error (type => 'no md name'); ## TODO: type |
4080 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4081 |
|
!!!next-input-character; |
4082 |
|
redo A; |
4083 |
|
} elsif ($self->{nc} == -1) { |
4084 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4085 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4086 |
|
## Reconsume. |
4087 |
|
redo A; |
4088 |
|
} else { |
4089 |
|
## XML5: [ATTLIST] Not defined yet. |
4090 |
|
$self->{ct}->{name} .= chr $self->{nc}; |
4091 |
|
$self->{state} = MD_NAME_STATE; |
4092 |
|
!!!next-input-character; |
4093 |
|
redo A; |
4094 |
|
} |
4095 |
|
} elsif ($self->{state} == DOCTYPE_ENTITY_PARAMETER_BEFORE_STATE) { |
4096 |
|
if ($is_space->{$self->{nc}}) { |
4097 |
|
## XML5: Switch to the "DOCTYPE ENTITY parameter state". |
4098 |
|
$self->{ct}->{type} = PARAMETER_ENTITY_TOKEN; |
4099 |
|
$self->{state} = BEFORE_MD_NAME_STATE; |
4100 |
|
!!!next-input-character; |
4101 |
|
redo A; |
4102 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4103 |
|
## XML5: Same as "Anything else". |
4104 |
|
!!!parse-error (type => 'no md name'); ## TODO: type |
4105 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4106 |
|
!!!next-input-character; |
4107 |
|
redo A; |
4108 |
|
} elsif ($self->{nc} == -1) { |
4109 |
|
!!!parse-error (type => 'unclosed md'); |
4110 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4111 |
|
## Reconsume. |
4112 |
|
redo A; |
4113 |
|
} else { |
4114 |
|
## XML5: No parse error. |
4115 |
|
!!!parse-error (type => 'no space after ENTITY percent'); ## TODO: type |
4116 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
4117 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded |
4118 |
|
## Reconsume. |
4119 |
|
redo A; |
4120 |
|
} |
4121 |
|
} elsif ($self->{state} == MD_NAME_STATE) { |
4122 |
|
## XML5: "DOCTYPE ENTITY name state" and "DOCTYPE ATTLIST name state". |
4123 |
|
|
4124 |
|
if ($is_space->{$self->{nc}}) { |
4125 |
|
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
4126 |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
4127 |
|
} elsif ($self->{ct}->{type} == ELEMENT_TOKEN) { |
4128 |
|
$self->{state} = AFTER_ELEMENT_NAME_STATE; |
4129 |
|
} else { # ENTITY/NOTATION |
4130 |
|
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
4131 |
|
} |
4132 |
|
!!!next-input-character; |
4133 |
|
redo A; |
4134 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4135 |
|
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
4136 |
|
# |
4137 |
|
} else { |
4138 |
|
!!!parse-error (type => 'no md def'); ## TODO: type |
4139 |
|
} |
4140 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4141 |
|
!!!next-input-character; |
4142 |
|
!!!emit ($self->{ct}); # ELEMENT/ENTITY/ATTLIST/NOTATION |
4143 |
|
redo A; |
4144 |
|
} elsif ($self->{nc} == -1) { |
4145 |
|
## XML5: [ATTLIST] No parse error. |
4146 |
|
!!!parse-error (type => 'unclosed md'); |
4147 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4148 |
|
## Reconsume. |
4149 |
|
!!!emit ($self->{ct}); # ELEMENT/ENTITY/ATTLIST/NOTATION |
4150 |
|
redo A; |
4151 |
|
} else { |
4152 |
|
## XML5: [ATTLIST] Not defined yet. |
4153 |
|
$self->{ct}->{name} .= chr $self->{nc}; |
4154 |
|
## Stay in the state. |
4155 |
|
!!!next-input-character; |
4156 |
|
redo A; |
4157 |
|
} |
4158 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_NAME_AFTER_STATE) { |
4159 |
|
if ($is_space->{$self->{nc}}) { |
4160 |
|
## Stay in the state. |
4161 |
|
!!!next-input-character; |
4162 |
|
redo A; |
4163 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4164 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4165 |
|
!!!next-input-character; |
4166 |
|
!!!emit ($self->{ct}); # ATTLIST |
4167 |
|
redo A; |
4168 |
|
} elsif ($self->{nc} == -1) { |
4169 |
|
## XML5: No parse error. |
4170 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4171 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4172 |
|
!!!emit ($self->{ct}); |
4173 |
|
redo A; |
4174 |
|
} else { |
4175 |
|
## XML5: Not defined yet. |
4176 |
|
$self->{ca} = {name => chr ($self->{nc}), # attrdef |
4177 |
|
tokens => [], |
4178 |
|
line => $self->{line}, column => $self->{column}}; |
4179 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_NAME_STATE; |
4180 |
|
!!!next-input-character; |
4181 |
|
redo A; |
4182 |
|
} |
4183 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_NAME_STATE) { |
4184 |
|
if ($is_space->{$self->{nc}}) { |
4185 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_NAME_AFTER_STATE; |
4186 |
|
!!!next-input-character; |
4187 |
|
redo A; |
4188 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4189 |
|
## XML5: Same as "anything else". |
4190 |
|
!!!parse-error (type => 'no attr type'); ## TODO: type |
4191 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4192 |
|
!!!next-input-character; |
4193 |
|
!!!emit ($self->{ct}); # ATTLIST |
4194 |
|
redo A; |
4195 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4196 |
|
## XML5: Same as "anything else". |
4197 |
|
!!!parse-error (type => 'no space before paren'); ## TODO: type |
4198 |
|
$self->{state} = BEFORE_ALLOWED_TOKEN_STATE; |
4199 |
|
!!!next-input-character; |
4200 |
|
redo A; |
4201 |
|
} elsif ($self->{nc} == -1) { |
4202 |
|
## XML5: No parse error. |
4203 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4204 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4205 |
|
!!!next-input-character; |
4206 |
|
!!!emit ($self->{ct}); # ATTLIST |
4207 |
|
redo A; |
4208 |
|
} else { |
4209 |
|
## XML5: Not defined yet. |
4210 |
|
$self->{ca}->{name} .= chr $self->{nc}; |
4211 |
|
## Stay in the state. |
4212 |
|
!!!next-input-character; |
4213 |
|
redo A; |
4214 |
|
} |
4215 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_NAME_AFTER_STATE) { |
4216 |
|
if ($is_space->{$self->{nc}}) { |
4217 |
|
## Stay in the state. |
4218 |
|
!!!next-input-character; |
4219 |
|
redo A; |
4220 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4221 |
|
## XML5: Same as "anything else". |
4222 |
|
!!!parse-error (type => 'no attr type'); ## TODO: type |
4223 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4224 |
|
!!!next-input-character; |
4225 |
|
!!!emit ($self->{ct}); # ATTLIST |
4226 |
|
redo A; |
4227 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4228 |
|
## XML5: Same as "anything else". |
4229 |
|
$self->{state} = BEFORE_ALLOWED_TOKEN_STATE; |
4230 |
|
!!!next-input-character; |
4231 |
|
redo A; |
4232 |
|
} elsif ($self->{nc} == -1) { |
4233 |
|
## XML5: No parse error. |
4234 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4235 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4236 |
|
!!!next-input-character; |
4237 |
|
!!!emit ($self->{ct}); |
4238 |
|
redo A; |
4239 |
|
} else { |
4240 |
|
## XML5: Not defined yet. |
4241 |
|
$self->{ca}->{type} = chr $self->{nc}; |
4242 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_TYPE_STATE; |
4243 |
|
!!!next-input-character; |
4244 |
|
redo A; |
4245 |
|
} |
4246 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_TYPE_STATE) { |
4247 |
|
if ($is_space->{$self->{nc}}) { |
4248 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_TYPE_AFTER_STATE; |
4249 |
|
!!!next-input-character; |
4250 |
|
redo A; |
4251 |
|
} elsif ($self->{nc} == 0x0023) { # # |
4252 |
|
## XML5: Same as "anything else". |
4253 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4254 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_BEFORE_STATE; |
4255 |
|
!!!next-input-character; |
4256 |
|
redo A; |
4257 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4258 |
|
## XML5: Same as "anything else". |
4259 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4260 |
|
$self->{ca}->{value} = ''; |
4261 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4262 |
|
!!!next-input-character; |
4263 |
|
redo A; |
4264 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4265 |
|
## XML5: Same as "anything else". |
4266 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4267 |
|
$self->{ca}->{value} = ''; |
4268 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4269 |
|
!!!next-input-character; |
4270 |
|
redo A; |
4271 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4272 |
|
## XML5: Same as "anything else". |
4273 |
|
!!!parse-error (type => 'no attr default'); ## TODO: type |
4274 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4275 |
|
!!!next-input-character; |
4276 |
|
!!!emit ($self->{ct}); # ATTLIST |
4277 |
|
redo A; |
4278 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4279 |
|
## XML5: Same as "anything else". |
4280 |
|
!!!parse-error (type => 'no space before paren'); ## TODO: type |
4281 |
|
$self->{state} = BEFORE_ALLOWED_TOKEN_STATE; |
4282 |
|
!!!next-input-character; |
4283 |
|
redo A; |
4284 |
|
} elsif ($self->{nc} == -1) { |
4285 |
|
## XML5: No parse error. |
4286 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4287 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4288 |
|
!!!next-input-character; |
4289 |
|
!!!emit ($self->{ct}); |
4290 |
|
redo A; |
4291 |
|
} else { |
4292 |
|
## XML5: Not defined yet. |
4293 |
|
$self->{ca}->{type} .= chr $self->{nc}; |
4294 |
|
## Stay in the state. |
4295 |
|
!!!next-input-character; |
4296 |
|
redo A; |
4297 |
|
} |
4298 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_TYPE_AFTER_STATE) { |
4299 |
|
if ($is_space->{$self->{nc}}) { |
4300 |
|
## Stay in the state. |
4301 |
|
!!!next-input-character; |
4302 |
|
redo A; |
4303 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4304 |
|
## XML5: Same as "anything else". |
4305 |
|
$self->{state} = BEFORE_ALLOWED_TOKEN_STATE; |
4306 |
|
!!!next-input-character; |
4307 |
|
redo A; |
4308 |
|
} elsif ($self->{nc} == 0x0023) { # # |
4309 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_BEFORE_STATE; |
4310 |
|
!!!next-input-character; |
4311 |
|
redo A; |
4312 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4313 |
|
## XML5: Same as "anything else". |
4314 |
|
$self->{ca}->{value} = ''; |
4315 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4316 |
|
!!!next-input-character; |
4317 |
|
redo A; |
4318 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4319 |
|
## XML5: Same as "anything else". |
4320 |
|
$self->{ca}->{value} = ''; |
4321 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4322 |
|
!!!next-input-character; |
4323 |
|
redo A; |
4324 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4325 |
|
## XML5: Same as "anything else". |
4326 |
|
!!!parse-error (type => 'no attr default'); ## TODO: type |
4327 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4328 |
|
!!!next-input-character; |
4329 |
|
!!!emit ($self->{ct}); # ATTLIST |
4330 |
|
redo A; |
4331 |
|
} elsif ($self->{nc} == -1) { |
4332 |
|
## XML5: No parse error. |
4333 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4334 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4335 |
|
!!!next-input-character; |
4336 |
|
!!!emit ($self->{ct}); |
4337 |
|
redo A; |
4338 |
|
} else { |
4339 |
|
## XML5: Switch to the "DOCTYPE bogus comment state". |
4340 |
|
!!!parse-error (type => 'unquoted attr value'); ## TODO: type |
4341 |
|
$self->{ca}->{value} = ''; |
4342 |
|
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
4343 |
|
## Reconsume. |
4344 |
|
redo A; |
4345 |
|
} |
4346 |
|
} elsif ($self->{state} == BEFORE_ALLOWED_TOKEN_STATE) { |
4347 |
|
if ($is_space->{$self->{nc}}) { |
4348 |
|
## Stay in the state. |
4349 |
|
!!!next-input-character; |
4350 |
|
redo A; |
4351 |
|
} elsif ($self->{nc} == 0x007C) { # | |
4352 |
|
!!!parse-error (type => 'empty allowed token'); ## TODO: type |
4353 |
|
## Stay in the state. |
4354 |
|
!!!next-input-character; |
4355 |
|
redo A; |
4356 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
4357 |
|
!!!parse-error (type => 'empty allowed token'); ## TODO: type |
4358 |
|
$self->{state} = AFTER_ALLOWED_TOKENS_STATE; |
4359 |
|
!!!next-input-character; |
4360 |
|
redo A; |
4361 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4362 |
|
!!!parse-error (type => 'unclosed allowed tokens'); ## TODO: type |
4363 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4364 |
|
!!!next-input-character; |
4365 |
|
!!!emit ($self->{ct}); # ATTLIST |
4366 |
|
redo A; |
4367 |
|
} elsif ($self->{nc} == -1) { |
4368 |
|
## XML5: No parse error. |
4369 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4370 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4371 |
|
!!!next-input-character; |
4372 |
|
!!!emit ($self->{ct}); |
4373 |
|
redo A; |
4374 |
|
} else { |
4375 |
|
push @{$self->{ca}->{tokens}}, chr $self->{nc}; |
4376 |
|
$self->{state} = ALLOWED_TOKEN_STATE; |
4377 |
|
!!!next-input-character; |
4378 |
|
redo A; |
4379 |
|
} |
4380 |
|
} elsif ($self->{state} == ALLOWED_TOKEN_STATE) { |
4381 |
|
if ($is_space->{$self->{nc}}) { |
4382 |
|
$self->{state} = AFTER_ALLOWED_TOKEN_STATE; |
4383 |
|
!!!next-input-character; |
4384 |
|
redo A; |
4385 |
|
} elsif ($self->{nc} == 0x007C) { # | |
4386 |
|
$self->{state} = BEFORE_ALLOWED_TOKEN_STATE; |
4387 |
|
!!!next-input-character; |
4388 |
|
redo A; |
4389 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
4390 |
|
$self->{state} = AFTER_ALLOWED_TOKENS_STATE; |
4391 |
|
!!!next-input-character; |
4392 |
|
redo A; |
4393 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4394 |
|
!!!parse-error (type => 'unclosed allowed tokens'); ## TODO: type |
4395 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4396 |
|
!!!next-input-character; |
4397 |
|
!!!emit ($self->{ct}); # ATTLIST |
4398 |
|
redo A; |
4399 |
|
} elsif ($self->{nc} == -1) { |
4400 |
|
## XML5: No parse error. |
4401 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4402 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4403 |
|
!!!next-input-character; |
4404 |
|
!!!emit ($self->{ct}); |
4405 |
|
redo A; |
4406 |
|
} else { |
4407 |
|
$self->{ca}->{tokens}->[-1] .= chr $self->{nc}; |
4408 |
|
## Stay in the state. |
4409 |
|
!!!next-input-character; |
4410 |
|
redo A; |
4411 |
|
} |
4412 |
|
} elsif ($self->{state} == AFTER_ALLOWED_TOKEN_STATE) { |
4413 |
|
if ($is_space->{$self->{nc}}) { |
4414 |
|
## Stay in the state. |
4415 |
|
!!!next-input-character; |
4416 |
|
redo A; |
4417 |
|
} elsif ($self->{nc} == 0x007C) { # | |
4418 |
|
$self->{state} = BEFORE_ALLOWED_TOKEN_STATE; |
4419 |
|
!!!next-input-character; |
4420 |
|
redo A; |
4421 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
4422 |
|
$self->{state} = AFTER_ALLOWED_TOKENS_STATE; |
4423 |
|
!!!next-input-character; |
4424 |
|
redo A; |
4425 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4426 |
|
!!!parse-error (type => 'unclosed allowed tokens'); ## TODO: type |
4427 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4428 |
|
!!!next-input-character; |
4429 |
|
!!!emit ($self->{ct}); # ATTLIST |
4430 |
|
redo A; |
4431 |
|
} elsif ($self->{nc} == -1) { |
4432 |
|
## XML5: No parse error. |
4433 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4434 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4435 |
|
!!!next-input-character; |
4436 |
|
!!!emit ($self->{ct}); |
4437 |
|
redo A; |
4438 |
|
} else { |
4439 |
|
!!!parse-error (type => 'space in allowed token', ## TODO: type |
4440 |
|
line => $self->{line_prev}, |
4441 |
|
column => $self->{column_prev}); |
4442 |
|
$self->{ca}->{tokens}->[-1] .= ' ' . chr $self->{nc}; |
4443 |
|
$self->{state} = ALLOWED_TOKEN_STATE; |
4444 |
|
!!!next-input-character; |
4445 |
|
redo A; |
4446 |
|
} |
4447 |
|
} elsif ($self->{state} == AFTER_ALLOWED_TOKENS_STATE) { |
4448 |
|
if ($is_space->{$self->{nc}}) { |
4449 |
|
$self->{state} = BEFORE_ATTR_DEFAULT_STATE; |
4450 |
|
!!!next-input-character; |
4451 |
|
redo A; |
4452 |
|
} elsif ($self->{nc} == 0x0023) { # # |
4453 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4454 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_BEFORE_STATE; |
4455 |
|
!!!next-input-character; |
4456 |
|
redo A; |
4457 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4458 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4459 |
|
$self->{ca}->{value} = ''; |
4460 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4461 |
|
!!!next-input-character; |
4462 |
|
redo A; |
4463 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4464 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4465 |
|
$self->{ca}->{value} = ''; |
4466 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4467 |
|
!!!next-input-character; |
4468 |
|
redo A; |
4469 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4470 |
|
!!!parse-error (type => 'no attr default'); ## TODO: type |
4471 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4472 |
|
!!!next-input-character; |
4473 |
|
!!!emit ($self->{ct}); # ATTLIST |
4474 |
|
redo A; |
4475 |
|
} elsif ($self->{nc} == -1) { |
4476 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4477 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4478 |
|
!!!next-input-character; |
4479 |
|
!!!emit ($self->{ct}); |
4480 |
|
redo A; |
4481 |
|
} else { |
4482 |
|
!!!parse-error (type => 'unquoted attr value'); ## TODO: type |
4483 |
|
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
4484 |
|
## Reconsume. |
4485 |
|
redo A; |
4486 |
|
} |
4487 |
|
} elsif ($self->{state} == BEFORE_ATTR_DEFAULT_STATE) { |
4488 |
|
if ($is_space->{$self->{nc}}) { |
4489 |
|
## Stay in the state. |
4490 |
|
!!!next-input-character; |
4491 |
|
redo A; |
4492 |
|
} elsif ($self->{nc} == 0x0023) { # # |
4493 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_BEFORE_STATE; |
4494 |
|
!!!next-input-character; |
4495 |
|
redo A; |
4496 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4497 |
|
$self->{ca}->{value} = ''; |
4498 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4499 |
|
!!!next-input-character; |
4500 |
|
redo A; |
4501 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4502 |
|
$self->{ca}->{value} = ''; |
4503 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4504 |
|
!!!next-input-character; |
4505 |
|
redo A; |
4506 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4507 |
|
!!!parse-error (type => 'no attr default'); ## TODO: type |
4508 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4509 |
|
!!!next-input-character; |
4510 |
|
!!!emit ($self->{ct}); # ATTLIST |
4511 |
|
redo A; |
4512 |
|
} elsif ($self->{nc} == -1) { |
4513 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4514 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4515 |
|
!!!next-input-character; |
4516 |
|
!!!emit ($self->{ct}); |
4517 |
|
redo A; |
4518 |
|
} else { |
4519 |
|
!!!parse-error (type => 'unquoted attr value'); ## TODO: type |
4520 |
|
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
4521 |
|
## Reconsume. |
4522 |
|
redo A; |
4523 |
|
} |
4524 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_BEFORE_STATE) { |
4525 |
|
if ($is_space->{$self->{nc}}) { |
4526 |
|
## XML5: No parse error. |
4527 |
|
!!!parse-error (type => 'no default type'); ## TODO: type |
4528 |
|
$self->{state} = BOGUS_MD_STATE; |
4529 |
|
## Reconsume. |
4530 |
|
redo A; |
4531 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4532 |
|
## XML5: Same as "anything else". |
4533 |
|
$self->{ca}->{value} = ''; |
4534 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4535 |
|
!!!next-input-character; |
4536 |
|
redo A; |
4537 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4538 |
|
## XML5: Same as "anything else". |
4539 |
|
$self->{ca}->{value} = ''; |
4540 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4541 |
|
!!!next-input-character; |
4542 |
|
redo A; |
4543 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4544 |
|
## XML5: Same as "anything else". |
4545 |
|
!!!parse-error (type => 'no attr default'); ## TODO: type |
4546 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4547 |
|
!!!next-input-character; |
4548 |
|
!!!emit ($self->{ct}); # ATTLIST |
4549 |
|
redo A; |
4550 |
|
} elsif ($self->{nc} == -1) { |
4551 |
|
## XML5: No parse error. |
4552 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4553 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4554 |
|
!!!next-input-character; |
4555 |
|
!!!emit ($self->{ct}); |
4556 |
|
redo A; |
4557 |
|
} else { |
4558 |
|
$self->{ca}->{default} = chr $self->{nc}; |
4559 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_STATE; |
4560 |
|
!!!next-input-character; |
4561 |
|
redo A; |
4562 |
|
} |
4563 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_STATE) { |
4564 |
|
if ($is_space->{$self->{nc}}) { |
4565 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_AFTER_STATE; |
4566 |
|
!!!next-input-character; |
4567 |
|
redo A; |
4568 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4569 |
|
## XML5: Same as "anything else". |
4570 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4571 |
|
$self->{ca}->{value} = ''; |
4572 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4573 |
|
!!!next-input-character; |
4574 |
|
redo A; |
4575 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4576 |
|
## XML5: Same as "anything else". |
4577 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4578 |
|
$self->{ca}->{value} = ''; |
4579 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4580 |
|
!!!next-input-character; |
4581 |
|
redo A; |
4582 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4583 |
|
## XML5: Same as "anything else". |
4584 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
4585 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4586 |
|
!!!next-input-character; |
4587 |
|
!!!emit ($self->{ct}); # ATTLIST |
4588 |
|
redo A; |
4589 |
|
} elsif ($self->{nc} == -1) { |
4590 |
|
## XML5: No parse error. |
4591 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4592 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
4593 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4594 |
|
!!!next-input-character; |
4595 |
|
!!!emit ($self->{ct}); |
4596 |
|
redo A; |
4597 |
|
} else { |
4598 |
|
$self->{ca}->{default} .= chr $self->{nc}; |
4599 |
|
## Stay in the state. |
4600 |
|
!!!next-input-character; |
4601 |
|
redo A; |
4602 |
|
} |
4603 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_AFTER_STATE) { |
4604 |
|
if ($is_space->{$self->{nc}}) { |
4605 |
|
## Stay in the state. |
4606 |
|
!!!next-input-character; |
4607 |
|
redo A; |
4608 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4609 |
|
$self->{ca}->{value} = ''; |
4610 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4611 |
|
!!!next-input-character; |
4612 |
|
redo A; |
4613 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4614 |
|
$self->{ca}->{value} = ''; |
4615 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4616 |
|
!!!next-input-character; |
4617 |
|
redo A; |
4618 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4619 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
4620 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4621 |
|
!!!next-input-character; |
4622 |
|
!!!emit ($self->{ct}); # ATTLIST |
4623 |
|
redo A; |
4624 |
|
} elsif ($self->{nc} == -1) { |
4625 |
|
## XML5: No parse error. |
4626 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4627 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
4628 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4629 |
|
!!!next-input-character; |
4630 |
|
!!!emit ($self->{ct}); |
4631 |
|
redo A; |
4632 |
|
} else { |
4633 |
|
## XML5: Not defined yet. |
4634 |
|
if ($self->{ca}->{default} eq 'FIXED') { |
4635 |
|
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
4636 |
|
} else { |
4637 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
4638 |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
4639 |
|
} |
4640 |
|
## Reconsume. |
4641 |
|
redo A; |
4642 |
|
} |
4643 |
|
} elsif ($self->{state} == AFTER_ATTLIST_ATTR_VALUE_QUOTED_STATE) { |
4644 |
|
if ($is_space->{$self->{nc}} or |
4645 |
|
$self->{nc} == -1 or |
4646 |
|
$self->{nc} == 0x003E) { # > |
4647 |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
4648 |
|
## Reconsume. |
4649 |
|
redo A; |
4650 |
|
} else { |
4651 |
|
!!!parse-error (type => 'no space before attr name'); ## TODO: type |
4652 |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
4653 |
|
## Reconsume. |
4654 |
|
redo A; |
4655 |
|
} |
4656 |
|
} elsif ($self->{state} == NDATA_STATE) { |
4657 |
|
## ASCII case-insensitive |
4658 |
|
if ($self->{nc} == [ |
4659 |
|
undef, |
4660 |
|
0x0044, # D |
4661 |
|
0x0041, # A |
4662 |
|
0x0054, # T |
4663 |
|
]->[length $self->{kwd}] or |
4664 |
|
$self->{nc} == [ |
4665 |
|
undef, |
4666 |
|
0x0064, # d |
4667 |
|
0x0061, # a |
4668 |
|
0x0074, # t |
4669 |
|
]->[length $self->{kwd}]) { |
4670 |
|
!!!cp (172.2); |
4671 |
|
## Stay in the state. |
4672 |
|
$self->{kwd} .= chr $self->{nc}; |
4673 |
|
!!!next-input-character; |
4674 |
|
redo A; |
4675 |
|
} elsif ((length $self->{kwd}) == 4 and |
4676 |
|
($self->{nc} == 0x0041 or # A |
4677 |
|
$self->{nc} == 0x0061)) { # a |
4678 |
|
if ($self->{kwd} ne 'NDAT' or $self->{nc} == 0x0061) { # a |
4679 |
|
!!!cp (172.3); |
4680 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
4681 |
|
text => 'NDATA', |
4682 |
|
line => $self->{line_prev}, |
4683 |
|
column => $self->{column_prev} - 4); |
4684 |
|
} else { |
4685 |
|
!!!cp (172.4); |
4686 |
|
} |
4687 |
|
$self->{state} = AFTER_NDATA_STATE; |
4688 |
|
!!!next-input-character; |
4689 |
|
redo A; |
4690 |
|
} else { |
4691 |
|
!!!parse-error (type => 'string after literal', ## TODO: type |
4692 |
|
line => $self->{line_prev}, |
4693 |
|
column => $self->{column_prev} + 1 |
4694 |
|
- length $self->{kwd}); |
4695 |
|
!!!cp (172.5); |
4696 |
|
$self->{state} = BOGUS_MD_STATE; |
4697 |
|
## Reconsume. |
4698 |
|
redo A; |
4699 |
|
} |
4700 |
|
} elsif ($self->{state} == AFTER_NDATA_STATE) { |
4701 |
|
if ($is_space->{$self->{nc}}) { |
4702 |
|
$self->{state} = BEFORE_NOTATION_NAME_STATE; |
4703 |
|
!!!next-input-character; |
4704 |
|
redo A; |
4705 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4706 |
|
!!!parse-error (type => 'no notation name'); ## TODO: type |
4707 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4708 |
|
!!!next-input-character; |
4709 |
|
!!!emit ($self->{ct}); # ENTITY |
4710 |
|
redo A; |
4711 |
|
} elsif ($self->{nc} == -1) { |
4712 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4713 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4714 |
|
!!!next-input-character; |
4715 |
|
!!!emit ($self->{ct}); # ENTITY |
4716 |
|
redo A; |
4717 |
|
} else { |
4718 |
|
!!!parse-error (type => 'string after literal', ## TODO: type |
4719 |
|
line => $self->{line_prev}, |
4720 |
|
column => $self->{column_prev} + 1 |
4721 |
|
- length $self->{kwd}); |
4722 |
|
$self->{state} = BOGUS_MD_STATE; |
4723 |
|
## Reconsume. |
4724 |
|
redo A; |
4725 |
|
} |
4726 |
|
} elsif ($self->{state} == BEFORE_NOTATION_NAME_STATE) { |
4727 |
|
if ($is_space->{$self->{nc}}) { |
4728 |
|
## Stay in the state. |
4729 |
|
!!!next-input-character; |
4730 |
|
redo A; |
4731 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4732 |
|
!!!parse-error (type => 'no notation name'); ## TODO: type |
4733 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4734 |
|
!!!next-input-character; |
4735 |
|
!!!emit ($self->{ct}); # ENTITY |
4736 |
|
redo A; |
4737 |
|
} elsif ($self->{nc} == -1) { |
4738 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4739 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4740 |
|
!!!next-input-character; |
4741 |
|
!!!emit ($self->{ct}); # ENTITY |
4742 |
|
redo A; |
4743 |
|
} else { |
4744 |
|
$self->{ct}->{notation} = chr $self->{nc}; # ENTITY |
4745 |
|
$self->{state} = NOTATION_NAME_STATE; |
4746 |
|
!!!next-input-character; |
4747 |
|
redo A; |
4748 |
|
} |
4749 |
|
} elsif ($self->{state} == NOTATION_NAME_STATE) { |
4750 |
|
if ($is_space->{$self->{nc}}) { |
4751 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
4752 |
|
!!!next-input-character; |
4753 |
|
redo A; |
4754 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4755 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4756 |
|
!!!next-input-character; |
4757 |
|
!!!emit ($self->{ct}); # ENTITY |
4758 |
|
redo A; |
4759 |
|
} elsif ($self->{nc} == -1) { |
4760 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4761 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4762 |
|
!!!next-input-character; |
4763 |
|
!!!emit ($self->{ct}); # ENTITY |
4764 |
|
redo A; |
4765 |
|
} else { |
4766 |
|
$self->{ct}->{notation} .= chr $self->{nc}; # ENTITY |
4767 |
|
## Stay in the state. |
4768 |
|
!!!next-input-character; |
4769 |
|
redo A; |
4770 |
|
} |
4771 |
|
} elsif ($self->{state} == DOCTYPE_ENTITY_VALUE_DOUBLE_QUOTED_STATE) { |
4772 |
|
if ($self->{nc} == 0x0022) { # " |
4773 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
4774 |
|
!!!next-input-character; |
4775 |
|
redo A; |
4776 |
|
} elsif ($self->{nc} == 0x0026) { # & |
4777 |
|
$self->{prev_state} = $self->{state}; |
4778 |
|
$self->{state} = ENTITY_VALUE_ENTITY_STATE; |
4779 |
|
$self->{entity_add} = 0x0022; # " |
4780 |
|
!!!next-input-character; |
4781 |
|
redo A; |
4782 |
|
## TODO: % |
4783 |
|
} elsif ($self->{nc} == -1) { |
4784 |
|
!!!parse-error (type => 'unclosed entity value'); ## TODO: type |
4785 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4786 |
|
## Reconsume. |
4787 |
|
!!!emit ($self->{ct}); # ENTITY |
4788 |
|
redo A; |
4789 |
|
} else { |
4790 |
|
$self->{ct}->{value} .= chr $self->{nc}; # ENTITY |
4791 |
|
!!!next-input-character; |
4792 |
|
redo A; |
4793 |
|
} |
4794 |
|
} elsif ($self->{state} == DOCTYPE_ENTITY_VALUE_SINGLE_QUOTED_STATE) { |
4795 |
|
if ($self->{nc} == 0x0027) { # ' |
4796 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
4797 |
|
!!!next-input-character; |
4798 |
|
redo A; |
4799 |
|
} elsif ($self->{nc} == 0x0026) { # & |
4800 |
|
$self->{prev_state} = $self->{state}; |
4801 |
|
$self->{state} = ENTITY_VALUE_ENTITY_STATE; |
4802 |
|
$self->{entity_add} = 0x0027; # ' |
4803 |
|
!!!next-input-character; |
4804 |
|
redo A; |
4805 |
|
## TODO: % |
4806 |
|
} elsif ($self->{nc} == -1) { |
4807 |
|
!!!parse-error (type => 'unclosed entity value'); ## TODO: type |
4808 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4809 |
|
## Reconsume. |
4810 |
|
!!!emit ($self->{ct}); # ENTITY |
4811 |
|
redo A; |
4812 |
|
} else { |
4813 |
|
$self->{ct}->{value} .= chr $self->{nc}; # ENTITY |
4814 |
|
!!!next-input-character; |
4815 |
|
redo A; |
4816 |
|
} |
4817 |
|
} elsif ($self->{state} == ENTITY_VALUE_ENTITY_STATE) { |
4818 |
|
if ($is_space->{$self->{nc}} or |
4819 |
|
{ |
4820 |
|
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
4821 |
|
$self->{entity_add} => 1, |
4822 |
|
}->{$self->{nc}}) { |
4823 |
|
!!!parse-error (type => 'bare ero', |
4824 |
|
line => $self->{line_prev}, |
4825 |
|
column => $self->{column_prev} |
4826 |
|
+ ($self->{nc} == -1 ? 1 : 0)); |
4827 |
|
## Don't consume |
4828 |
|
## Return nothing. |
4829 |
|
# |
4830 |
|
} elsif ($self->{nc} == 0x0023) { # # |
4831 |
|
$self->{ca} = $self->{ct}; |
4832 |
|
$self->{state} = ENTITY_HASH_STATE; |
4833 |
|
$self->{kwd} = '#'; |
4834 |
|
!!!next-input-character; |
4835 |
|
redo A; |
4836 |
|
} else { |
4837 |
|
# |
4838 |
|
} |
4839 |
|
|
4840 |
|
$self->{ct}->{value} .= '&'; |
4841 |
|
$self->{state} = $self->{prev_state}; |
4842 |
|
## Reconsume. |
4843 |
|
redo A; |
4844 |
|
} elsif ($self->{state} == AFTER_ELEMENT_NAME_STATE) { |
4845 |
|
if ($is_space->{$self->{nc}}) { |
4846 |
|
$self->{state} = BEFORE_ELEMENT_CONTENT_STATE; |
4847 |
|
!!!next-input-character; |
4848 |
|
redo A; |
4849 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4850 |
|
$self->{state} = AFTER_CM_GROUP_OPEN_STATE; |
4851 |
|
$self->{ct}->{content} = ['(']; |
4852 |
|
$self->{group_depth} = 1; |
4853 |
|
!!!next-input-character; |
4854 |
|
redo A; |
4855 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4856 |
|
!!!parse-error (type => 'no md def'); ## TODO: type |
4857 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4858 |
|
!!!next-input-character; |
4859 |
|
!!!emit ($self->{ct}); # ELEMENT |
4860 |
|
redo A; |
4861 |
|
} elsif ($self->{nc} == -1) { |
4862 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4863 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4864 |
|
!!!next-input-character; |
4865 |
|
!!!emit ($self->{ct}); # ELEMENT |
4866 |
|
redo A; |
4867 |
|
} else { |
4868 |
|
$self->{ct}->{content} = [chr $self->{nc}]; |
4869 |
|
$self->{state} = CONTENT_KEYWORD_STATE; |
4870 |
|
!!!next-input-character; |
4871 |
|
redo A; |
4872 |
|
} |
4873 |
|
} elsif ($self->{state} == CONTENT_KEYWORD_STATE) { |
4874 |
|
if ($is_space->{$self->{nc}}) { |
4875 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
4876 |
|
!!!next-input-character; |
4877 |
|
redo A; |
4878 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4879 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4880 |
|
!!!next-input-character; |
4881 |
|
!!!emit ($self->{ct}); # ELEMENT |
4882 |
|
redo A; |
4883 |
|
} elsif ($self->{nc} == -1) { |
4884 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4885 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4886 |
|
!!!next-input-character; |
4887 |
|
!!!emit ($self->{ct}); # ELEMENT |
4888 |
|
redo A; |
4889 |
|
} else { |
4890 |
|
$self->{ct}->{content}->[-1] .= chr $self->{nc}; # ELEMENT |
4891 |
|
## Stay in the state. |
4892 |
|
!!!next-input-character; |
4893 |
|
redo A; |
4894 |
|
} |
4895 |
|
} elsif ($self->{state} == AFTER_CM_GROUP_OPEN_STATE) { |
4896 |
|
if ($is_space->{$self->{nc}}) { |
4897 |
|
## Stay in the state. |
4898 |
|
!!!next-input-character; |
4899 |
|
redo A; |
4900 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4901 |
|
$self->{group_depth}++; |
4902 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
4903 |
|
## Stay in the state. |
4904 |
|
!!!next-input-character; |
4905 |
|
redo A; |
4906 |
|
} elsif ($self->{nc} == 0x007C or # | |
4907 |
|
$self->{nc} == 0x002C) { # , |
4908 |
|
!!!parse-error (type => 'empty element name'); ## TODO: type |
4909 |
|
## Stay in the state. |
4910 |
|
!!!next-input-character; |
4911 |
|
redo A; |
4912 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
4913 |
|
!!!parse-error (type => 'empty element name'); ## TODO: type |
4914 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
4915 |
|
$self->{group_depth}--; |
4916 |
|
$self->{state} = AFTER_CM_GROUP_CLOSE_STATE; |
4917 |
|
!!!next-input-character; |
4918 |
|
redo A; |
4919 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4920 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
4921 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
4922 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4923 |
|
!!!next-input-character; |
4924 |
|
!!!emit ($self->{ct}); # ELEMENT |
4925 |
|
redo A; |
4926 |
|
} elsif ($self->{nc} == -1) { |
4927 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4928 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
4929 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4930 |
|
!!!next-input-character; |
4931 |
|
!!!emit ($self->{ct}); # ELEMENT |
4932 |
|
redo A; |
4933 |
|
} else { |
4934 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
4935 |
|
$self->{state} = CM_ELEMENT_NAME_STATE; |
4936 |
|
!!!next-input-character; |
4937 |
|
redo A; |
4938 |
|
} |
4939 |
|
} elsif ($self->{state} == CM_ELEMENT_NAME_STATE) { |
4940 |
|
if ($is_space->{$self->{nc}}) { |
4941 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
4942 |
|
!!!next-input-character; |
4943 |
|
redo A; |
4944 |
|
} elsif ($self->{nc} == 0x002A or # * |
4945 |
|
$self->{nc} == 0x002B or # + |
4946 |
|
$self->{nc} == 0x003F) { # ? |
4947 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
4948 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
4949 |
|
!!!next-input-character; |
4950 |
|
redo A; |
4951 |
|
} elsif ($self->{nc} == 0x007C or # | |
4952 |
|
$self->{nc} == 0x002C) { # , |
4953 |
|
push @{$self->{ct}->{content}}, $self->{nc} == 0x007C ? ' | ' : ', '; |
4954 |
|
$self->{state} = AFTER_CM_GROUP_OPEN_STATE; |
4955 |
|
!!!next-input-character; |
4956 |
|
redo A; |
4957 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
4958 |
|
$self->{group_depth}--; |
4959 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
4960 |
|
$self->{state} = AFTER_CM_GROUP_CLOSE_STATE; |
4961 |
|
!!!next-input-character; |
4962 |
|
redo A; |
4963 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4964 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
4965 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
4966 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4967 |
|
!!!next-input-character; |
4968 |
|
!!!emit ($self->{ct}); # ELEMENT |
4969 |
|
redo A; |
4970 |
|
} elsif ($self->{nc} == -1) { |
4971 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4972 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
4973 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4974 |
|
!!!next-input-character; |
4975 |
|
!!!emit ($self->{ct}); # ELEMENT |
4976 |
|
redo A; |
4977 |
|
} else { |
4978 |
|
$self->{ct}->{content}->[-1] .= chr $self->{nc}; |
4979 |
|
## Stay in the state. |
4980 |
|
!!!next-input-character; |
4981 |
|
redo A; |
4982 |
|
} |
4983 |
|
} elsif ($self->{state} == AFTER_CM_ELEMENT_NAME_STATE) { |
4984 |
|
if ($is_space->{$self->{nc}}) { |
4985 |
|
## Stay in the state. |
4986 |
|
!!!next-input-character; |
4987 |
|
redo A; |
4988 |
|
} elsif ($self->{nc} == 0x007C or # | |
4989 |
|
$self->{nc} == 0x002C) { # , |
4990 |
|
push @{$self->{ct}->{content}}, $self->{nc} == 0x007C ? ' | ' : ', '; |
4991 |
|
$self->{state} = AFTER_CM_GROUP_OPEN_STATE; |
4992 |
|
!!!next-input-character; |
4993 |
|
redo A; |
4994 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
4995 |
|
$self->{group_depth}--; |
4996 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
4997 |
|
$self->{state} = AFTER_CM_GROUP_CLOSE_STATE; |
4998 |
|
!!!next-input-character; |
4999 |
|
redo A; |
5000 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5001 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
5002 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5003 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5004 |
|
!!!next-input-character; |
5005 |
|
!!!emit ($self->{ct}); # ELEMENT |
5006 |
|
redo A; |
5007 |
|
} elsif ($self->{nc} == -1) { |
5008 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5009 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5010 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5011 |
|
!!!next-input-character; |
5012 |
|
!!!emit ($self->{ct}); # ELEMENT |
5013 |
|
redo A; |
5014 |
|
} else { |
5015 |
|
!!!parse-error (type => 'after element name'); ## TODO: type |
5016 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5017 |
|
$self->{state} = BOGUS_MD_STATE; |
5018 |
|
!!!next-input-character; |
5019 |
|
redo A; |
5020 |
|
} |
5021 |
|
} elsif ($self->{state} == AFTER_CM_GROUP_CLOSE_STATE) { |
5022 |
|
if ($is_space->{$self->{nc}}) { |
5023 |
|
if ($self->{group_depth}) { |
5024 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5025 |
|
} else { |
5026 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
5027 |
|
} |
5028 |
|
!!!next-input-character; |
5029 |
|
redo A; |
5030 |
|
} elsif ($self->{nc} == 0x002A or # * |
5031 |
|
$self->{nc} == 0x002B or # + |
5032 |
|
$self->{nc} == 0x003F) { # ? |
5033 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5034 |
|
if ($self->{group_depth}) { |
5035 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5036 |
|
} else { |
5037 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
5038 |
|
} |
5039 |
|
!!!next-input-character; |
5040 |
|
redo A; |
5041 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
5042 |
|
if ($self->{group_depth}) { |
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 |
|
} else { |
5049 |
|
!!!parse-error (type => 'string after md def'); ## TODO: type |
5050 |
|
$self->{state} = BOGUS_MD_STATE; |
5051 |
|
## Reconsume. |
5052 |
|
redo A; |
5053 |
|
} |
5054 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5055 |
|
if ($self->{group_depth}) { |
5056 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
5057 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5058 |
|
} |
5059 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5060 |
|
!!!next-input-character; |
5061 |
|
!!!emit ($self->{ct}); # ELEMENT |
5062 |
|
redo A; |
5063 |
|
} elsif ($self->{nc} == -1) { |
5064 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5065 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5066 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5067 |
|
!!!next-input-character; |
5068 |
|
!!!emit ($self->{ct}); # ELEMENT |
5069 |
|
redo A; |
5070 |
|
} else { |
5071 |
|
if ($self->{group_depth}) { |
5072 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5073 |
|
} else { |
5074 |
|
!!!parse-error (type => 'string after md def'); ## TODO: type |
5075 |
|
$self->{state} = BOGUS_MD_STATE; |
5076 |
|
} |
5077 |
|
## Reconsume. |
5078 |
|
redo A; |
5079 |
|
} |
5080 |
|
} elsif ($self->{state} == AFTER_MD_DEF_STATE) { |
5081 |
|
if ($is_space->{$self->{nc}}) { |
5082 |
|
## Stay in the state. |
5083 |
|
!!!next-input-character; |
5084 |
|
redo A; |
5085 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5086 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5087 |
|
!!!next-input-character; |
5088 |
|
!!!emit ($self->{ct}); # ENTITY/ELEMENT |
5089 |
|
redo A; |
5090 |
|
} elsif ($self->{nc} == -1) { |
5091 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5092 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5093 |
|
!!!next-input-character; |
5094 |
|
!!!emit ($self->{ct}); # ENTITY/ELEMENT |
5095 |
|
redo A; |
5096 |
|
} else { |
5097 |
|
!!!parse-error (type => 'string after md def'); ## TODO: type |
5098 |
|
$self->{state} = BOGUS_MD_STATE; |
5099 |
|
## Reconsume. |
5100 |
|
redo A; |
5101 |
|
} |
5102 |
|
} elsif ($self->{state} == BOGUS_MD_STATE) { |
5103 |
|
if ($self->{nc} == 0x003E) { # > |
5104 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5105 |
|
!!!next-input-character; |
5106 |
|
!!!emit ($self->{ct}); # ATTLIST/ENTITY/NOTATION |
5107 |
|
redo A; |
5108 |
|
} elsif ($self->{nc} == -1) { |
5109 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5110 |
|
## Reconsume. |
5111 |
|
!!!emit ($self->{ct}); # ATTLIST/ENTITY/NOTATION |
5112 |
|
redo A; |
5113 |
|
} else { |
5114 |
|
## Stay in the state. |
5115 |
!!!next-input-character; |
!!!next-input-character; |
5116 |
redo A; |
redo A; |
5117 |
} |
} |
|
|
|
5118 |
} else { |
} else { |
5119 |
die "$0: $self->{state}: Unknown state"; |
die "$0: $self->{state}: Unknown state"; |
5120 |
} |
} |
5125 |
|
|
5126 |
1; |
1; |
5127 |
## $Date$ |
## $Date$ |
5128 |
|
|