105 |
sub COMMENT_START_DASH_STATE () { 15 } |
sub COMMENT_START_DASH_STATE () { 15 } |
106 |
sub COMMENT_STATE () { 16 } |
sub COMMENT_STATE () { 16 } |
107 |
sub COMMENT_END_STATE () { 17 } |
sub COMMENT_END_STATE () { 17 } |
108 |
|
sub COMMENT_END_BANG_STATE () { 102 } |
109 |
|
sub COMMENT_END_SPACE_STATE () { 103 } ## LAST |
110 |
sub COMMENT_END_DASH_STATE () { 18 } |
sub COMMENT_END_DASH_STATE () { 18 } |
111 |
sub BOGUS_COMMENT_STATE () { 19 } |
sub BOGUS_COMMENT_STATE () { 19 } |
112 |
sub DOCTYPE_STATE () { 20 } |
sub DOCTYPE_STATE () { 20 } |
950 |
if ({ |
if ({ |
951 |
0x0022 => 1, # " |
0x0022 => 1, # " |
952 |
0x0027 => 1, # ' |
0x0027 => 1, # ' |
953 |
|
0x003C => 1, # < |
954 |
0x003D => 1, # = |
0x003D => 1, # = |
955 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
956 |
!!!cp (55); |
!!!cp (55); |
1073 |
|
|
1074 |
redo A; |
redo A; |
1075 |
} else { |
} else { |
1076 |
if ($self->{nc} == 0x0022 or # " |
if ({ |
1077 |
$self->{nc} == 0x0027) { # ' |
0x0022 => 1, # " |
1078 |
|
0x0027 => 1, # ' |
1079 |
|
0x003C => 1, # < |
1080 |
|
}->{$self->{nc}}) { |
1081 |
!!!cp (69); |
!!!cp (69); |
1082 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1083 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
1188 |
!!!cp (78.2); |
!!!cp (78.2); |
1189 |
} |
} |
1190 |
|
|
1191 |
if ($self->{nc} == 0x0022 or # " |
if ({ |
1192 |
$self->{nc} == 0x0027) { # ' |
0x0022 => 1, # " |
1193 |
|
0x0027 => 1, # ' |
1194 |
|
0x003C => 1, # < |
1195 |
|
}->{$self->{nc}}) { |
1196 |
!!!cp (78); |
!!!cp (78); |
1197 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1198 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
1279 |
|
|
1280 |
redo A; |
redo A; |
1281 |
} else { |
} else { |
1282 |
if ($self->{nc} == 0x003D) { # = |
if ($self->{nc} == 0x003D or $self->{nc} == 0x003C) { # =, < |
1283 |
!!!cp (93); |
!!!cp (93); |
1284 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1285 |
!!!parse-error (type => 'bad attribute value'); |
!!!parse-error (type => 'bad attribute value'); |
1325 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1326 |
!!!next-input-character; |
!!!next-input-character; |
1327 |
redo A; |
redo A; |
1328 |
|
} elsif ($self->{is_xml} and |
1329 |
|
$is_space->{$self->{nc}}) { |
1330 |
|
!!!cp (97.1); |
1331 |
|
$self->{ca}->{value} .= ' '; |
1332 |
|
## Stay in the state. |
1333 |
|
!!!next-input-character; |
1334 |
|
redo A; |
1335 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
1336 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
1337 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1379 |
} |
} |
1380 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1381 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1382 |
q["&<], |
qq["&<\x09\x0C\x20], |
1383 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1384 |
|
|
1385 |
## Stay in the state |
## Stay in the state |
1416 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1417 |
!!!next-input-character; |
!!!next-input-character; |
1418 |
redo A; |
redo A; |
1419 |
|
} elsif ($self->{is_xml} and |
1420 |
|
$is_space->{$self->{nc}}) { |
1421 |
|
!!!cp (103.1); |
1422 |
|
$self->{ca}->{value} .= ' '; |
1423 |
|
## Stay in the state. |
1424 |
|
!!!next-input-character; |
1425 |
|
redo A; |
1426 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
1427 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
1428 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1470 |
} |
} |
1471 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1472 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1473 |
q['&<], |
qq['&<\x09\x0C\x20], |
1474 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1475 |
|
|
1476 |
## Stay in the state |
## Stay in the state |
1582 |
0x0022 => 1, # " |
0x0022 => 1, # " |
1583 |
0x0027 => 1, # ' |
0x0027 => 1, # ' |
1584 |
0x003D => 1, # = |
0x003D => 1, # = |
1585 |
|
0x003C => 1, # < |
1586 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
1587 |
!!!cp (115); |
!!!cp (115); |
1588 |
## XML5: Not a parse error. |
## XML5: Not a parse error. |
1592 |
} |
} |
1593 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1594 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1595 |
q["'=& >], |
qq["'=& \x09\x0C>], |
1596 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1597 |
|
|
1598 |
## Stay in the state |
## Stay in the state |
2084 |
!!!next-input-character; |
!!!next-input-character; |
2085 |
redo A; |
redo A; |
2086 |
} |
} |
2087 |
} elsif ($self->{state} == COMMENT_END_STATE) { |
} elsif ($self->{state} == COMMENT_END_STATE or |
2088 |
|
$self->{state} == COMMENT_END_BANG_STATE) { |
2089 |
## XML5: "Comment end state" and "DOCTYPE comment end state". |
## XML5: "Comment end state" and "DOCTYPE comment end state". |
2090 |
|
## (No comment end bang state.) |
2091 |
|
|
2092 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
2093 |
if ($self->{in_subset}) { |
if ($self->{in_subset}) { |
2104 |
|
|
2105 |
redo A; |
redo A; |
2106 |
} elsif ($self->{nc} == 0x002D) { # - |
} elsif ($self->{nc} == 0x002D) { # - |
2107 |
!!!cp (152); |
if ($self->{state} == COMMENT_END_BANG_STATE) { |
2108 |
## XML5: Not a parse error. |
!!!cp (154.3); |
2109 |
!!!parse-error (type => 'dash in comment', |
$self->{ct}->{data} .= '--!'; # comment |
2110 |
line => $self->{line_prev}, |
$self->{state} = COMMENT_END_DASH_STATE; |
2111 |
column => $self->{column_prev}); |
} else { |
2112 |
$self->{ct}->{data} .= '-'; # comment |
!!!cp (152); |
2113 |
## Stay in the state |
## XML5: Not a parse error. |
2114 |
|
!!!parse-error (type => 'dash in comment', |
2115 |
|
line => $self->{line_prev}, |
2116 |
|
column => $self->{column_prev}); |
2117 |
|
$self->{ct}->{data} .= '-'; # comment |
2118 |
|
## Stay in the state |
2119 |
|
} |
2120 |
|
!!!next-input-character; |
2121 |
|
redo A; |
2122 |
|
} elsif ($self->{state} != COMMENT_END_BANG_STATE and |
2123 |
|
$is_space->{$self->{nc}}) { |
2124 |
|
!!!cp (152.1); |
2125 |
|
!!!parse-error (type => 'comment end space'); # XXX error type |
2126 |
|
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
2127 |
|
$self->{state} = COMMENT_END_SPACE_STATE; |
2128 |
|
!!!next-input-character; |
2129 |
|
redo A; |
2130 |
|
} elsif ($self->{state} != COMMENT_END_BANG_STATE and |
2131 |
|
$self->{nc} == 0x0021) { # ! |
2132 |
|
!!!cp (152.2); |
2133 |
|
!!!parse-error (type => 'comment end bang'); # XXX error type |
2134 |
|
$self->{state} = COMMENT_END_BANG_STATE; |
2135 |
!!!next-input-character; |
!!!next-input-character; |
2136 |
redo A; |
redo A; |
2137 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2144 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2145 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
2146 |
} |
} |
2147 |
## reconsume |
## Reconsume. |
2148 |
|
|
2149 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
2150 |
|
|
2151 |
redo A; |
redo A; |
2152 |
} else { |
} else { |
2153 |
!!!cp (154); |
!!!cp (154); |
2154 |
## XML5: Not a parse error. |
if ($self->{state} == COMMENT_END_BANG_STATE) { |
2155 |
!!!parse-error (type => 'dash in comment', |
$self->{ct}->{data} .= '--!' . chr ($self->{nc}); # comment |
2156 |
line => $self->{line_prev}, |
} else { |
2157 |
column => $self->{column_prev}); |
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
2158 |
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
} |
2159 |
$self->{state} = COMMENT_STATE; |
$self->{state} = COMMENT_STATE; |
2160 |
!!!next-input-character; |
!!!next-input-character; |
2161 |
redo A; |
redo A; |
2162 |
} |
} |
2163 |
|
} elsif ($self->{state} == COMMENT_END_SPACE_STATE) { |
2164 |
|
## XML5: Not exist. |
2165 |
|
|
2166 |
|
if ($self->{nc} == 0x003E) { # > |
2167 |
|
if ($self->{in_subset}) { |
2168 |
|
!!!cp (154.4); |
2169 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2170 |
|
} else { |
2171 |
|
!!!cp (154.5); |
2172 |
|
$self->{state} = DATA_STATE; |
2173 |
|
$self->{s_kwd} = ''; |
2174 |
|
} |
2175 |
|
!!!next-input-character; |
2176 |
|
|
2177 |
|
!!!emit ($self->{ct}); # comment |
2178 |
|
|
2179 |
|
redo A; |
2180 |
|
} elsif ($is_space->{$self->{nc}}) { |
2181 |
|
!!!cp (154.6); |
2182 |
|
$self->{ct}->{data} .= chr ($self->{nc}); # comment |
2183 |
|
## Stay in the state. |
2184 |
|
!!!next-input-character; |
2185 |
|
redo A; |
2186 |
|
} elsif ($self->{nc} == -1) { |
2187 |
|
!!!parse-error (type => 'unclosed comment'); |
2188 |
|
if ($self->{in_subset}) { |
2189 |
|
!!!cp (154.7); |
2190 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2191 |
|
} else { |
2192 |
|
!!!cp (154.8); |
2193 |
|
$self->{state} = DATA_STATE; |
2194 |
|
$self->{s_kwd} = ''; |
2195 |
|
} |
2196 |
|
## Reconsume. |
2197 |
|
|
2198 |
|
!!!emit ($self->{ct}); # comment |
2199 |
|
|
2200 |
|
redo A; |
2201 |
|
} else { |
2202 |
|
!!!cp (154.9); |
2203 |
|
$self->{ct}->{data} .= chr ($self->{nc}); # comment |
2204 |
|
$self->{state} = COMMENT_STATE; |
2205 |
|
!!!next-input-character; |
2206 |
|
redo A; |
2207 |
|
} |
2208 |
} elsif ($self->{state} == DOCTYPE_STATE) { |
} elsif ($self->{state} == DOCTYPE_STATE) { |
2209 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
2210 |
!!!cp (155); |
!!!cp (155); |
2211 |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
2212 |
!!!next-input-character; |
!!!next-input-character; |
2213 |
redo A; |
redo A; |
2214 |
|
} elsif ($self->{nc} == -1) { |
2215 |
|
!!!cp (155.1); |
2216 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
2217 |
|
$self->{ct}->{quirks} = 1; |
2218 |
|
|
2219 |
|
$self->{state} = DATA_STATE; |
2220 |
|
## Reconsume. |
2221 |
|
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
2222 |
|
|
2223 |
|
redo A; |
2224 |
} else { |
} else { |
2225 |
!!!cp (156); |
!!!cp (156); |
2226 |
## XML5: Unless EOF, swith to the bogus comment state. |
## XML5: Swith to the bogus comment state. |
2227 |
!!!parse-error (type => 'no space before DOCTYPE name'); |
!!!parse-error (type => 'no space before DOCTYPE name'); |
2228 |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
2229 |
## reconsume |
## reconsume |
2248 |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
2249 |
|
|
2250 |
redo A; |
redo A; |
2251 |
|
} elsif (0x0041 <= $self->{nc} and $self->{nc} <= 0x005A) { # A..Z |
2252 |
|
!!!cp (158.1); |
2253 |
|
$self->{ct}->{name} # DOCTYPE |
2254 |
|
= chr ($self->{nc} + ($self->{is_xml} ? 0 : 0x0020)); |
2255 |
|
delete $self->{ct}->{quirks}; |
2256 |
|
$self->{state} = DOCTYPE_NAME_STATE; |
2257 |
|
!!!next-input-character; |
2258 |
|
redo A; |
2259 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2260 |
!!!cp (159); |
!!!cp (159); |
2261 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
2302 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2303 |
|
|
2304 |
redo A; |
redo A; |
2305 |
|
} elsif (0x0041 <= $self->{nc} and $self->{nc} <= 0x005A) { # A..Z |
2306 |
|
!!!cp (162.1); |
2307 |
|
$self->{ct}->{name} # DOCTYPE |
2308 |
|
.= chr ($self->{nc} + ($self->{is_xml} ? 0 : 0x0020)); |
2309 |
|
delete $self->{ct}->{quirks}; |
2310 |
|
## Stay in the state. |
2311 |
|
!!!next-input-character; |
2312 |
|
redo A; |
2313 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2314 |
!!!cp (163); |
!!!cp (163); |
2315 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2331 |
redo A; |
redo A; |
2332 |
} else { |
} else { |
2333 |
!!!cp (164); |
!!!cp (164); |
2334 |
$self->{ct}->{name} |
$self->{ct}->{name} .= chr ($self->{nc}); # DOCTYPE |
2335 |
.= chr ($self->{nc}); # DOCTYPE |
## Stay in the state. |
|
## Stay in the state |
|
2336 |
!!!next-input-character; |
!!!next-input-character; |
2337 |
redo A; |
redo A; |
2338 |
} |
} |
3334 |
my $code = $self->{kwd}; |
my $code = $self->{kwd}; |
3335 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3336 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3337 |
if ($charref_map->{$code}) { |
if ((not $self->{is_xml} and $charref_map->{$code}) or |
3338 |
|
($self->{is_xml} and 0xD800 <= $code and $code <= 0xDFFF) or |
3339 |
|
($self->{is_xml} and $code == 0x0000)) { |
3340 |
!!!cp (1015); |
!!!cp (1015); |
3341 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
3342 |
text => (sprintf 'U+%04X', $code), |
text => (sprintf 'U+%04X', $code), |
3449 |
my $code = $self->{kwd}; |
my $code = $self->{kwd}; |
3450 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3451 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3452 |
if ($charref_map->{$code}) { |
if ((not $self->{is_xml} and $charref_map->{$code}) or |
3453 |
|
($self->{is_xml} and 0xD800 <= $code and $code <= 0xDFFF) or |
3454 |
|
($self->{is_xml} and $code == 0x0000)) { |
3455 |
!!!cp (1008); |
!!!cp (1008); |
3456 |
!!!parse-error (type => 'invalid character reference', |
!!!parse-error (type => 'invalid character reference', |
3457 |
text => (sprintf 'U+%04X', $code), |
text => (sprintf 'U+%04X', $code), |
3780 |
## XML5: Not defined yet. |
## XML5: Not defined yet. |
3781 |
|
|
3782 |
## TODO: |
## TODO: |
3783 |
|
|
3784 |
|
if (not $self->{stop_processing} and |
3785 |
|
not $self->{document}->xml_standalone) { |
3786 |
|
!!!parse-error (type => 'stop processing', ## TODO: type |
3787 |
|
level => $self->{level}->{info}); |
3788 |
|
$self->{stop_processing} = 1; |
3789 |
|
} |
3790 |
|
|
3791 |
!!!next-input-character; |
!!!next-input-character; |
3792 |
redo A; |
redo A; |
3793 |
} elsif ($self->{nc} == 0x005D) { # ] |
} elsif ($self->{nc} == 0x005D) { # ] |