105 |
sub COMMENT_START_DASH_STATE () { 15 } |
sub COMMENT_START_DASH_STATE () { 15 } |
106 |
sub COMMENT_STATE () { 16 } |
sub COMMENT_STATE () { 16 } |
107 |
sub COMMENT_END_STATE () { 17 } |
sub COMMENT_END_STATE () { 17 } |
108 |
|
sub COMMENT_END_BANG_STATE () { 102 } ## LAST |
109 |
sub COMMENT_END_DASH_STATE () { 18 } |
sub COMMENT_END_DASH_STATE () { 18 } |
110 |
sub BOGUS_COMMENT_STATE () { 19 } |
sub BOGUS_COMMENT_STATE () { 19 } |
111 |
sub DOCTYPE_STATE () { 20 } |
sub DOCTYPE_STATE () { 20 } |
949 |
if ({ |
if ({ |
950 |
0x0022 => 1, # " |
0x0022 => 1, # " |
951 |
0x0027 => 1, # ' |
0x0027 => 1, # ' |
952 |
|
0x003C => 1, # < |
953 |
0x003D => 1, # = |
0x003D => 1, # = |
954 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
955 |
!!!cp (55); |
!!!cp (55); |
1072 |
|
|
1073 |
redo A; |
redo A; |
1074 |
} else { |
} else { |
1075 |
if ($self->{nc} == 0x0022 or # " |
if ({ |
1076 |
$self->{nc} == 0x0027) { # ' |
0x0022 => 1, # " |
1077 |
|
0x0027 => 1, # ' |
1078 |
|
0x003C => 1, # < |
1079 |
|
}->{$self->{nc}}) { |
1080 |
!!!cp (69); |
!!!cp (69); |
1081 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1082 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
1187 |
!!!cp (78.2); |
!!!cp (78.2); |
1188 |
} |
} |
1189 |
|
|
1190 |
if ($self->{nc} == 0x0022 or # " |
if ({ |
1191 |
$self->{nc} == 0x0027) { # ' |
0x0022 => 1, # " |
1192 |
|
0x0027 => 1, # ' |
1193 |
|
0x003C => 1, # < |
1194 |
|
}->{$self->{nc}}) { |
1195 |
!!!cp (78); |
!!!cp (78); |
1196 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1197 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
1278 |
|
|
1279 |
redo A; |
redo A; |
1280 |
} else { |
} else { |
1281 |
if ($self->{nc} == 0x003D) { # = |
if ($self->{nc} == 0x003D or $self->{nc} == 0x003C) { # =, < |
1282 |
!!!cp (93); |
!!!cp (93); |
1283 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1284 |
!!!parse-error (type => 'bad attribute value'); |
!!!parse-error (type => 'bad attribute value'); |
1324 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1325 |
!!!next-input-character; |
!!!next-input-character; |
1326 |
redo A; |
redo A; |
1327 |
|
} elsif ($self->{is_xml} and |
1328 |
|
$is_space->{$self->{nc}}) { |
1329 |
|
!!!cp (97.1); |
1330 |
|
$self->{ca}->{value} .= ' '; |
1331 |
|
## Stay in the state. |
1332 |
|
!!!next-input-character; |
1333 |
|
redo A; |
1334 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
1335 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
1336 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1378 |
} |
} |
1379 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1380 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1381 |
q["&<], |
qq["&<\x09\x0C\x20], |
1382 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1383 |
|
|
1384 |
## Stay in the state |
## Stay in the state |
1415 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1416 |
!!!next-input-character; |
!!!next-input-character; |
1417 |
redo A; |
redo A; |
1418 |
|
} elsif ($self->{is_xml} and |
1419 |
|
$is_space->{$self->{nc}}) { |
1420 |
|
!!!cp (103.1); |
1421 |
|
$self->{ca}->{value} .= ' '; |
1422 |
|
## Stay in the state. |
1423 |
|
!!!next-input-character; |
1424 |
|
redo A; |
1425 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
1426 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
1427 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1469 |
} |
} |
1470 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1471 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1472 |
q['&<], |
qq['&<\x09\x0C\x20], |
1473 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1474 |
|
|
1475 |
## Stay in the state |
## Stay in the state |
1581 |
0x0022 => 1, # " |
0x0022 => 1, # " |
1582 |
0x0027 => 1, # ' |
0x0027 => 1, # ' |
1583 |
0x003D => 1, # = |
0x003D => 1, # = |
1584 |
|
0x003C => 1, # < |
1585 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
1586 |
!!!cp (115); |
!!!cp (115); |
1587 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1591 |
} |
} |
1592 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1593 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1594 |
q["'=& >], |
qq["'=& \x09\x0C>], |
1595 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1596 |
|
|
1597 |
## Stay in the state |
## Stay in the state |
2083 |
!!!next-input-character; |
!!!next-input-character; |
2084 |
redo A; |
redo A; |
2085 |
} |
} |
2086 |
} elsif ($self->{state} == COMMENT_END_STATE) { |
} elsif ($self->{state} == COMMENT_END_STATE or |
2087 |
|
$self->{state} == COMMENT_END_BANG_STATE) { |
2088 |
## XML5: "Comment end state" and "DOCTYPE comment end state". |
## XML5: "Comment end state" and "DOCTYPE comment end state". |
2089 |
|
## (No comment end bang state.) |
2090 |
|
|
2091 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
2092 |
if ($self->{in_subset}) { |
if ($self->{in_subset}) { |
2103 |
|
|
2104 |
redo A; |
redo A; |
2105 |
} elsif ($self->{nc} == 0x002D) { # - |
} elsif ($self->{nc} == 0x002D) { # - |
2106 |
!!!cp (152); |
if ($self->{state} == COMMENT_END_BANG_STATE) { |
2107 |
## XML5: Not a parse error. |
!!!cp (154.3); |
2108 |
!!!parse-error (type => 'dash in comment', |
$self->{ct}->{data} .= '--!'; # comment |
2109 |
line => $self->{line_prev}, |
$self->{state} = COMMENT_END_DASH_STATE; |
2110 |
column => $self->{column_prev}); |
} else { |
2111 |
$self->{ct}->{data} .= '-'; # comment |
!!!cp (152); |
2112 |
## Stay in the state |
## XML5: Not a parse error. |
2113 |
|
!!!parse-error (type => 'dash in comment', |
2114 |
|
line => $self->{line_prev}, |
2115 |
|
column => $self->{column_prev}); |
2116 |
|
$self->{ct}->{data} .= '-'; # comment |
2117 |
|
## Stay in the state |
2118 |
|
} |
2119 |
|
!!!next-input-character; |
2120 |
|
redo A; |
2121 |
|
} elsif ($self->{nc} == 0x0021 and # ! |
2122 |
|
$self->{state} != COMMENT_END_BANG_STATE) { |
2123 |
|
!!!parse-error (type => 'comment end bang'); # XXX error type |
2124 |
|
$self->{state} = COMMENT_END_BANG_STATE; |
2125 |
!!!next-input-character; |
!!!next-input-character; |
2126 |
redo A; |
redo A; |
2127 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2134 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2135 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
2136 |
} |
} |
2137 |
## reconsume |
## Reconsume. |
2138 |
|
|
2139 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
2140 |
|
|
2141 |
redo A; |
redo A; |
2142 |
} else { |
} else { |
2143 |
!!!cp (154); |
!!!cp (154); |
2144 |
## XML5: Not a parse error. |
if ($self->{state} == COMMENT_END_BANG_STATE) { |
2145 |
!!!parse-error (type => 'dash in comment', |
$self->{ct}->{data} .= '--!' . chr ($self->{nc}); # comment |
2146 |
line => $self->{line_prev}, |
} else { |
2147 |
column => $self->{column_prev}); |
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
2148 |
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
} |
2149 |
$self->{state} = COMMENT_STATE; |
$self->{state} = COMMENT_STATE; |
2150 |
!!!next-input-character; |
!!!next-input-character; |
2151 |
redo A; |
redo A; |
2156 |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
2157 |
!!!next-input-character; |
!!!next-input-character; |
2158 |
redo A; |
redo A; |
2159 |
|
} elsif ($self->{nc} == -1) { |
2160 |
|
!!!cp (155.1); |
2161 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
2162 |
|
$self->{ct}->{quirks} = 1; |
2163 |
|
|
2164 |
|
$self->{state} = DATA_STATE; |
2165 |
|
## Reconsume. |
2166 |
|
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
2167 |
|
|
2168 |
|
redo A; |
2169 |
} else { |
} else { |
2170 |
!!!cp (156); |
!!!cp (156); |
2171 |
## XML5: Unless EOF, swith to the bogus comment state. |
## XML5: Swith to the bogus comment state. |
2172 |
!!!parse-error (type => 'no space before DOCTYPE name'); |
!!!parse-error (type => 'no space before DOCTYPE name'); |
2173 |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
2174 |
## reconsume |
## reconsume |
2193 |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
2194 |
|
|
2195 |
redo A; |
redo A; |
2196 |
|
} elsif (0x0041 <= $self->{nc} and $self->{nc} <= 0x005A) { # A..Z |
2197 |
|
!!!cp (158.1); |
2198 |
|
$self->{ct}->{name} # DOCTYPE |
2199 |
|
= chr ($self->{nc} + ($self->{is_xml} ? 0 : 0x0020)); |
2200 |
|
delete $self->{ct}->{quirks}; |
2201 |
|
$self->{state} = DOCTYPE_NAME_STATE; |
2202 |
|
!!!next-input-character; |
2203 |
|
redo A; |
2204 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2205 |
!!!cp (159); |
!!!cp (159); |
2206 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
2247 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2248 |
|
|
2249 |
redo A; |
redo A; |
2250 |
|
} elsif (0x0041 <= $self->{nc} and $self->{nc} <= 0x005A) { # A..Z |
2251 |
|
!!!cp (162.1); |
2252 |
|
$self->{ct}->{name} # DOCTYPE |
2253 |
|
.= chr ($self->{nc} + ($self->{is_xml} ? 0 : 0x0020)); |
2254 |
|
delete $self->{ct}->{quirks}; |
2255 |
|
## Stay in the state. |
2256 |
|
!!!next-input-character; |
2257 |
|
redo A; |
2258 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2259 |
!!!cp (163); |
!!!cp (163); |
2260 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2276 |
redo A; |
redo A; |
2277 |
} else { |
} else { |
2278 |
!!!cp (164); |
!!!cp (164); |
2279 |
$self->{ct}->{name} |
$self->{ct}->{name} .= chr ($self->{nc}); # DOCTYPE |
2280 |
.= chr ($self->{nc}); # DOCTYPE |
## Stay in the state. |
|
## Stay in the state |
|
2281 |
!!!next-input-character; |
!!!next-input-character; |
2282 |
redo A; |
redo A; |
2283 |
} |
} |
3140 |
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
3141 |
$self->{entity_add} => 1, |
$self->{entity_add} => 1, |
3142 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
3143 |
!!!cp (1001); |
if ($self->{is_xml}) { |
3144 |
|
!!!cp (1001.1); |
3145 |
|
!!!parse-error (type => 'bare ero', |
3146 |
|
line => $self->{line_prev}, |
3147 |
|
column => $self->{column_prev} |
3148 |
|
+ ($self->{nc} == -1 ? 1 : 0)); |
3149 |
|
} else { |
3150 |
|
!!!cp (1001); |
3151 |
|
## No error |
3152 |
|
} |
3153 |
## Don't consume |
## Don't consume |
|
## No error |
|
3154 |
## Return nothing. |
## Return nothing. |
3155 |
# |
# |
3156 |
} elsif ($self->{nc} == 0x0023) { # # |
} elsif ($self->{nc} == 0x0023) { # # |
3159 |
$self->{kwd} = '#'; |
$self->{kwd} = '#'; |
3160 |
!!!next-input-character; |
!!!next-input-character; |
3161 |
redo A; |
redo A; |
3162 |
} elsif ((0x0041 <= $self->{nc} and |
} elsif ($self->{is_xml} or |
3163 |
|
(0x0041 <= $self->{nc} and |
3164 |
$self->{nc} <= 0x005A) or # A..Z |
$self->{nc} <= 0x005A) or # A..Z |
3165 |
(0x0061 <= $self->{nc} and |
(0x0061 <= $self->{nc} and |
3166 |
$self->{nc} <= 0x007A)) { # a..z |
$self->{nc} <= 0x007A)) { # a..z |
3279 |
my $code = $self->{kwd}; |
my $code = $self->{kwd}; |
3280 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3281 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3282 |
if ($charref_map->{$code}) { |
if ((not $self->{is_xml} and $charref_map->{$code}) or |
3283 |
|
($self->{is_xml} and 0xD800 <= $code and $code <= 0xDFFF) or |
3284 |
|
($self->{is_xml} and $code == 0x0000)) { |
3285 |
!!!cp (1015); |
!!!cp (1015); |
3286 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
3287 |
text => (sprintf 'U+%04X', $code), |
text => (sprintf 'U+%04X', $code), |
3394 |
my $code = $self->{kwd}; |
my $code = $self->{kwd}; |
3395 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3396 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3397 |
if ($charref_map->{$code}) { |
if ((not $self->{is_xml} and $charref_map->{$code}) or |
3398 |
|
($self->{is_xml} and 0xD800 <= $code and $code <= 0xDFFF) or |
3399 |
|
($self->{is_xml} and $code == 0x0000)) { |
3400 |
!!!cp (1008); |
!!!cp (1008); |
3401 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
3402 |
text => (sprintf 'U+%04X', $code), |
text => (sprintf 'U+%04X', $code), |
3436 |
$self->{nc} <= 0x007A) or # z |
$self->{nc} <= 0x007A) or # z |
3437 |
(0x0030 <= $self->{nc} and # 0 |
(0x0030 <= $self->{nc} and # 0 |
3438 |
$self->{nc} <= 0x0039) or # 9 |
$self->{nc} <= 0x0039) or # 9 |
3439 |
$self->{nc} == 0x003B) { # ; |
$self->{nc} == 0x003B or # ; |
3440 |
|
($self->{is_xml} and |
3441 |
|
not ($is_space->{$self->{nc}} or |
3442 |
|
{ |
3443 |
|
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
3444 |
|
$self->{entity_add} => 1, |
3445 |
|
}->{$self->{nc}}))) { |
3446 |
our $EntityChar; |
our $EntityChar; |
3447 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3448 |
if (defined $EntityChar->{$self->{kwd}} or |
if (defined $EntityChar->{$self->{kwd}} or |
3725 |
## XML5: Not defined yet. |
## XML5: Not defined yet. |
3726 |
|
|
3727 |
## TODO: |
## TODO: |
3728 |
|
|
3729 |
|
if (not $self->{stop_processing} and |
3730 |
|
not $self->{document}->xml_standalone) { |
3731 |
|
!!!parse-error (type => 'stop processing', ## TODO: type |
3732 |
|
level => $self->{level}->{info}); |
3733 |
|
$self->{stop_processing} = 1; |
3734 |
|
} |
3735 |
|
|
3736 |
!!!next-input-character; |
!!!next-input-character; |
3737 |
redo A; |
redo A; |
3738 |
} elsif ($self->{nc} == 0x005D) { # ] |
} elsif ($self->{nc} == 0x005D) { # ] |
3967 |
} |
} |
3968 |
$self->{ct} = {type => ELEMENT_TOKEN, name => '', |
$self->{ct} = {type => ELEMENT_TOKEN, name => '', |
3969 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
3970 |
column => $self->{column_prev} - 6}; |
column => $self->{column_prev} - 7}; |
3971 |
$self->{state} = DOCTYPE_MD_STATE; |
$self->{state} = DOCTYPE_MD_STATE; |
3972 |
!!!next-input-character; |
!!!next-input-character; |
3973 |
redo A; |
redo A; |
4015 |
$self->{ct} = {type => ATTLIST_TOKEN, name => '', |
$self->{ct} = {type => ATTLIST_TOKEN, name => '', |
4016 |
attrdefs => [], |
attrdefs => [], |
4017 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
4018 |
column => $self->{column_prev} - 6}; |
column => $self->{column_prev} - 7}; |
4019 |
$self->{state} = DOCTYPE_MD_STATE; |
$self->{state} = DOCTYPE_MD_STATE; |
4020 |
!!!next-input-character; |
!!!next-input-character; |
4021 |
redo A; |
redo A; |
4064 |
} |
} |
4065 |
$self->{ct} = {type => NOTATION_TOKEN, name => '', |
$self->{ct} = {type => NOTATION_TOKEN, name => '', |
4066 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
4067 |
column => $self->{column_prev} - 6}; |
column => $self->{column_prev} - 8}; |
4068 |
$self->{state} = DOCTYPE_MD_STATE; |
$self->{state} = DOCTYPE_MD_STATE; |
4069 |
!!!next-input-character; |
!!!next-input-character; |
4070 |
redo A; |
redo A; |
4866 |
redo A; |
redo A; |
4867 |
} |
} |
4868 |
} elsif ($self->{state} == ENTITY_VALUE_ENTITY_STATE) { |
} elsif ($self->{state} == ENTITY_VALUE_ENTITY_STATE) { |
|
## TODO: XMLize |
|
|
|
|
4869 |
if ($is_space->{$self->{nc}} or |
if ($is_space->{$self->{nc}} or |
4870 |
{ |
{ |
4871 |
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
4872 |
$self->{entity_add} => 1, |
$self->{entity_add} => 1, |
4873 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
4874 |
|
!!!parse-error (type => 'bare ero', |
4875 |
|
line => $self->{line_prev}, |
4876 |
|
column => $self->{column_prev} |
4877 |
|
+ ($self->{nc} == -1 ? 1 : 0)); |
4878 |
## Don't consume |
## Don't consume |
|
## No error |
|
4879 |
## Return nothing. |
## Return nothing. |
4880 |
# |
# |
4881 |
} elsif ($self->{nc} == 0x0023) { # # |
} elsif ($self->{nc} == 0x0023) { # # |
4884 |
$self->{kwd} = '#'; |
$self->{kwd} = '#'; |
4885 |
!!!next-input-character; |
!!!next-input-character; |
4886 |
redo A; |
redo A; |
|
} elsif ((0x0041 <= $self->{nc} and |
|
|
$self->{nc} <= 0x005A) or # A..Z |
|
|
(0x0061 <= $self->{nc} and |
|
|
$self->{nc} <= 0x007A)) { # a..z |
|
|
# |
|
4887 |
} else { |
} else { |
|
!!!parse-error (type => 'bare ero'); |
|
|
## Return nothing. |
|
4888 |
# |
# |
4889 |
} |
} |
4890 |
|
|