| 1 |
package Whatpm::HTML; |
package Whatpm::HTML; |
| 2 |
use strict; |
use strict; |
| 3 |
our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
| 4 |
|
use Error qw(:try); |
| 5 |
|
|
| 6 |
## ISSUE: |
## ISSUE: |
| 7 |
## var doc = implementation.createDocument (null, null, null); |
## var doc = implementation.createDocument (null, null, null); |
| 8 |
## doc.write (''); |
## doc.write (''); |
| 9 |
## alert (doc.compatMode); |
## alert (doc.compatMode); |
| 10 |
|
|
| 11 |
## ISSUE: HTML5 revision 967 says that the encoding layer MUST NOT |
## TODO: Control charcters and noncharacters are not allowed (HTML5 revision 1263) |
| 12 |
## strip BOM and the HTML layer MUST ignore it. Whether we can do it |
## TODO: 1252 parse error (revision 1264) |
| 13 |
## is not yet clear. |
## TODO: 8859-11 = 874 (revision 1271) |
|
## "{U+FEFF}..." in UTF-16BE/UTF-16LE is three or four characters? |
|
|
## "{U+FEFF}..." in GB18030? |
|
| 14 |
|
|
| 15 |
my $permitted_slash_tag_name = { |
my $permitted_slash_tag_name = { |
| 16 |
base => 1, |
base => 1, |
| 18 |
meta => 1, |
meta => 1, |
| 19 |
hr => 1, |
hr => 1, |
| 20 |
br => 1, |
br => 1, |
| 21 |
img=> 1, |
img => 1, |
| 22 |
embed => 1, |
embed => 1, |
| 23 |
param => 1, |
param => 1, |
| 24 |
area => 1, |
area => 1, |
| 83 |
}; |
}; |
| 84 |
# $phrasing_category: all other elements |
# $phrasing_category: all other elements |
| 85 |
|
|
| 86 |
|
sub parse_byte_string ($$$$;$) { |
| 87 |
|
my $self = ref $_[0] ? shift : shift->new; |
| 88 |
|
my $charset = shift; |
| 89 |
|
my $bytes_s = ref $_[0] ? $_[0] : \($_[0]); |
| 90 |
|
my $s; |
| 91 |
|
|
| 92 |
|
if (defined $charset) { |
| 93 |
|
require Encode; ## TODO: decode(utf8) don't delete BOM |
| 94 |
|
$s = \ (Encode::decode ($charset, $$bytes_s)); |
| 95 |
|
$self->{input_encoding} = lc $charset; ## TODO: normalize name |
| 96 |
|
$self->{confident} = 1; |
| 97 |
|
} else { |
| 98 |
|
## TODO: Implement HTML5 detection algorithm |
| 99 |
|
require Whatpm::Charset::UniversalCharDet; |
| 100 |
|
$charset = Whatpm::Charset::UniversalCharDet->detect_byte_string |
| 101 |
|
(substr ($$bytes_s, 0, 1024)); |
| 102 |
|
$charset ||= 'windows-1252'; |
| 103 |
|
$s = \ (Encode::decode ($charset, $$bytes_s)); |
| 104 |
|
$self->{input_encoding} = $charset; |
| 105 |
|
$self->{confident} = 0; |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
$self->{change_encoding} = sub { |
| 109 |
|
my $self = shift; |
| 110 |
|
my $charset = lc shift; |
| 111 |
|
## TODO: if $charset is supported |
| 112 |
|
## TODO: normalize charset name |
| 113 |
|
|
| 114 |
|
## "Change the encoding" algorithm: |
| 115 |
|
|
| 116 |
|
## Step 1 |
| 117 |
|
if ($charset eq 'utf-16') { ## ISSUE: UTF-16BE -> UTF-8? UTF-16LE -> UTF-8? |
| 118 |
|
$charset = 'utf-8'; |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
## Step 2 |
| 122 |
|
if (defined $self->{input_encoding} and |
| 123 |
|
$self->{input_encoding} eq $charset) { |
| 124 |
|
$self->{confident} = 1; |
| 125 |
|
return; |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
!!!parse-error (type => 'charset label detected:'.$self->{input_encoding}. |
| 129 |
|
':'.$charset, level => 'w'); |
| 130 |
|
|
| 131 |
|
## Step 3 |
| 132 |
|
# if (can) { |
| 133 |
|
## change the encoding on the fly. |
| 134 |
|
#$self->{confident} = 1; |
| 135 |
|
#return; |
| 136 |
|
# } |
| 137 |
|
|
| 138 |
|
## Step 4 |
| 139 |
|
throw Whatpm::HTML::RestartParser (charset => $charset); |
| 140 |
|
}; # $self->{change_encoding} |
| 141 |
|
|
| 142 |
|
my @args = @_; shift @args; # $s |
| 143 |
|
my $return; |
| 144 |
|
try { |
| 145 |
|
$return = $self->parse_char_string ($s, @args); |
| 146 |
|
} catch Whatpm::HTML::RestartParser with { |
| 147 |
|
my $charset = shift->{charset}; |
| 148 |
|
$s = \ (Encode::decode ($charset, $$bytes_s)); |
| 149 |
|
$self->{input_encoding} = $charset; ## TODO: normalize |
| 150 |
|
$self->{confident} = 1; |
| 151 |
|
$return = $self->parse_char_string ($s, @args); |
| 152 |
|
}; |
| 153 |
|
return $return; |
| 154 |
|
} # parse_byte_string |
| 155 |
|
|
| 156 |
|
## NOTE: HTML5 spec says that the encoding layer MUST NOT strip BOM |
| 157 |
|
## and the HTML layer MUST ignore it. However, we does strip BOM in |
| 158 |
|
## the encoding layer and the HTML layer does not ignore any U+FEFF, |
| 159 |
|
## because the core part of our HTML parser expects a string of character, |
| 160 |
|
## not a string of bytes or code units or anything which might contain a BOM. |
| 161 |
|
## Therefore, any parser interface that accepts a string of bytes, |
| 162 |
|
## such as |parse_byte_string| in this module, must ensure that it does |
| 163 |
|
## strip the BOM and never strip any ZWNBSP. |
| 164 |
|
|
| 165 |
|
*parse_char_string = \&parse_string; |
| 166 |
|
|
| 167 |
sub parse_string ($$$;$) { |
sub parse_string ($$$;$) { |
| 168 |
my $self = shift->new; |
my $self = ref $_[0] ? shift : shift->new; |
| 169 |
my $s = \$_[0]; |
my $s = ref $_[0] ? $_[0] : \($_[0]); |
| 170 |
$self->{document} = $_[1]; |
$self->{document} = $_[1]; |
| 171 |
|
@{$self->{document}->child_nodes} = (); |
| 172 |
|
|
| 173 |
## NOTE: |set_inner_html| copies most of this method's code |
## NOTE: |set_inner_html| copies most of this method's code |
| 174 |
|
|
| 175 |
|
$self->{confident} = 1 unless exists $self->{confident}; |
| 176 |
|
$self->{document}->input_encoding ($self->{input_encoding}) |
| 177 |
|
if defined $self->{input_encoding}; |
| 178 |
|
|
| 179 |
my $i = 0; |
my $i = 0; |
| 180 |
my $line = 1; |
my $line = 1; |
| 181 |
my $column = 0; |
my $column = 0; |
| 182 |
$self->{set_next_input_character} = sub { |
$self->{set_next_char} = sub { |
| 183 |
my $self = shift; |
my $self = shift; |
| 184 |
|
|
| 185 |
pop @{$self->{prev_input_character}}; |
pop @{$self->{prev_char}}; |
| 186 |
unshift @{$self->{prev_input_character}}, $self->{next_input_character}; |
unshift @{$self->{prev_char}}, $self->{next_char}; |
| 187 |
|
|
| 188 |
$self->{next_input_character} = -1 and return if $i >= length $$s; |
$self->{next_char} = -1 and return if $i >= length $$s; |
| 189 |
$self->{next_input_character} = ord substr $$s, $i++, 1; |
$self->{next_char} = ord substr $$s, $i++, 1; |
| 190 |
$column++; |
$column++; |
| 191 |
|
|
| 192 |
if ($self->{next_input_character} == 0x000A) { # LF |
if ($self->{next_char} == 0x000A) { # LF |
| 193 |
$line++; |
$line++; |
| 194 |
$column = 0; |
$column = 0; |
| 195 |
} elsif ($self->{next_input_character} == 0x000D) { # CR |
} elsif ($self->{next_char} == 0x000D) { # CR |
| 196 |
$i++ if substr ($$s, $i, 1) eq "\x0A"; |
$i++ if substr ($$s, $i, 1) eq "\x0A"; |
| 197 |
$self->{next_input_character} = 0x000A; # LF # MUST |
$self->{next_char} = 0x000A; # LF # MUST |
| 198 |
$line++; |
$line++; |
| 199 |
$column = 0; |
$column = 0; |
| 200 |
} elsif ($self->{next_input_character} > 0x10FFFF) { |
} elsif ($self->{next_char} > 0x10FFFF) { |
| 201 |
$self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
| 202 |
} elsif ($self->{next_input_character} == 0x0000) { # NULL |
} elsif ($self->{next_char} == 0x0000) { # NULL |
| 203 |
!!!parse-error (type => 'NULL'); |
!!!parse-error (type => 'NULL'); |
| 204 |
$self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
| 205 |
} |
} |
| 206 |
}; |
}; |
| 207 |
$self->{prev_input_character} = [-1, -1, -1]; |
$self->{prev_char} = [-1, -1, -1]; |
| 208 |
$self->{next_input_character} = -1; |
$self->{next_char} = -1; |
| 209 |
|
|
| 210 |
my $onerror = $_[2] || sub { |
my $onerror = $_[2] || sub { |
| 211 |
my (%opt) = @_; |
my (%opt) = @_; |
| 226 |
sub new ($) { |
sub new ($) { |
| 227 |
my $class = shift; |
my $class = shift; |
| 228 |
my $self = bless {}, $class; |
my $self = bless {}, $class; |
| 229 |
$self->{set_next_input_character} = sub { |
$self->{set_next_char} = sub { |
| 230 |
$self->{next_input_character} = -1; |
$self->{next_char} = -1; |
| 231 |
}; |
}; |
| 232 |
$self->{parse_error} = sub { |
$self->{parse_error} = sub { |
| 233 |
# |
# |
| 234 |
}; |
}; |
| 235 |
|
$self->{change_encoding} = sub { |
| 236 |
|
# if ($_[0] is a supported encoding) { |
| 237 |
|
# run "change the encoding" algorithm; |
| 238 |
|
# throw Whatpm::HTML::RestartParser (charset => $new_encoding); |
| 239 |
|
# } |
| 240 |
|
}; |
| 241 |
|
$self->{application_cache_selection} = sub { |
| 242 |
|
# |
| 243 |
|
}; |
| 244 |
return $self; |
return $self; |
| 245 |
} # new |
} # new |
| 246 |
|
|
| 253 |
sub RCDATA_CONTENT_MODEL () { CM_ENTITY | CM_LIMITED_MARKUP } |
sub RCDATA_CONTENT_MODEL () { CM_ENTITY | CM_LIMITED_MARKUP } |
| 254 |
sub PCDATA_CONTENT_MODEL () { CM_ENTITY | CM_FULL_MARKUP } |
sub PCDATA_CONTENT_MODEL () { CM_ENTITY | CM_FULL_MARKUP } |
| 255 |
|
|
| 256 |
|
sub DATA_STATE () { 0 } |
| 257 |
|
sub ENTITY_DATA_STATE () { 1 } |
| 258 |
|
sub TAG_OPEN_STATE () { 2 } |
| 259 |
|
sub CLOSE_TAG_OPEN_STATE () { 3 } |
| 260 |
|
sub TAG_NAME_STATE () { 4 } |
| 261 |
|
sub BEFORE_ATTRIBUTE_NAME_STATE () { 5 } |
| 262 |
|
sub ATTRIBUTE_NAME_STATE () { 6 } |
| 263 |
|
sub AFTER_ATTRIBUTE_NAME_STATE () { 7 } |
| 264 |
|
sub BEFORE_ATTRIBUTE_VALUE_STATE () { 8 } |
| 265 |
|
sub ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE () { 9 } |
| 266 |
|
sub ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE () { 10 } |
| 267 |
|
sub ATTRIBUTE_VALUE_UNQUOTED_STATE () { 11 } |
| 268 |
|
sub ENTITY_IN_ATTRIBUTE_VALUE_STATE () { 12 } |
| 269 |
|
sub MARKUP_DECLARATION_OPEN_STATE () { 13 } |
| 270 |
|
sub COMMENT_START_STATE () { 14 } |
| 271 |
|
sub COMMENT_START_DASH_STATE () { 15 } |
| 272 |
|
sub COMMENT_STATE () { 16 } |
| 273 |
|
sub COMMENT_END_STATE () { 17 } |
| 274 |
|
sub COMMENT_END_DASH_STATE () { 18 } |
| 275 |
|
sub BOGUS_COMMENT_STATE () { 19 } |
| 276 |
|
sub DOCTYPE_STATE () { 20 } |
| 277 |
|
sub BEFORE_DOCTYPE_NAME_STATE () { 21 } |
| 278 |
|
sub DOCTYPE_NAME_STATE () { 22 } |
| 279 |
|
sub AFTER_DOCTYPE_NAME_STATE () { 23 } |
| 280 |
|
sub BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE () { 24 } |
| 281 |
|
sub DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE () { 25 } |
| 282 |
|
sub DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE () { 26 } |
| 283 |
|
sub AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE () { 27 } |
| 284 |
|
sub BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE () { 28 } |
| 285 |
|
sub DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE () { 29 } |
| 286 |
|
sub DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE () { 30 } |
| 287 |
|
sub AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE () { 31 } |
| 288 |
|
sub BOGUS_DOCTYPE_STATE () { 32 } |
| 289 |
|
sub AFTER_ATTRIBUTE_VALUE_QUOTED_STATE () { 33 } |
| 290 |
|
|
| 291 |
sub DOCTYPE_TOKEN () { 1 } |
sub DOCTYPE_TOKEN () { 1 } |
| 292 |
sub COMMENT_TOKEN () { 2 } |
sub COMMENT_TOKEN () { 2 } |
| 293 |
sub START_TAG_TOKEN () { 3 } |
sub START_TAG_TOKEN () { 3 } |
| 298 |
sub AFTER_HTML_IMS () { 0b100 } |
sub AFTER_HTML_IMS () { 0b100 } |
| 299 |
sub HEAD_IMS () { 0b1000 } |
sub HEAD_IMS () { 0b1000 } |
| 300 |
sub BODY_IMS () { 0b10000 } |
sub BODY_IMS () { 0b10000 } |
| 301 |
sub BODY_TABLE_IMS () { 0b100000 | BODY_IMS } |
sub BODY_TABLE_IMS () { 0b100000 } |
| 302 |
sub TABLE_IMS () { 0b1000000 } |
sub TABLE_IMS () { 0b1000000 } |
| 303 |
sub ROW_IMS () { 0b10000000 | TABLE_IMS } |
sub ROW_IMS () { 0b10000000 } |
| 304 |
sub BODY_AFTER_IMS () { 0b100000000 } |
sub BODY_AFTER_IMS () { 0b100000000 } |
| 305 |
sub FRAME_IMS () { 0b1000000000 } |
sub FRAME_IMS () { 0b1000000000 } |
| 306 |
|
|
| 311 |
sub AFTER_HEAD_IM () { HEAD_IMS | 0b10 } |
sub AFTER_HEAD_IM () { HEAD_IMS | 0b10 } |
| 312 |
sub BEFORE_HEAD_IM () { HEAD_IMS | 0b11 } |
sub BEFORE_HEAD_IM () { HEAD_IMS | 0b11 } |
| 313 |
sub IN_BODY_IM () { BODY_IMS } |
sub IN_BODY_IM () { BODY_IMS } |
| 314 |
sub IN_CELL_IM () { BODY_TABLE_IMS | 0b01 } |
sub IN_CELL_IM () { BODY_IMS | BODY_TABLE_IMS | 0b01 } |
| 315 |
sub IN_CAPTION_IM () { BODY_TABLE_IMS | 0b10 } |
sub IN_CAPTION_IM () { BODY_IMS | BODY_TABLE_IMS | 0b10 } |
| 316 |
sub IN_ROW_IM () { ROW_IMS | 0b01 } |
sub IN_ROW_IM () { TABLE_IMS | ROW_IMS | 0b01 } |
| 317 |
sub IN_TABLE_BODY_IM () { ROW_IMS | 0b10 } |
sub IN_TABLE_BODY_IM () { TABLE_IMS | ROW_IMS | 0b10 } |
| 318 |
sub IN_TABLE_IM () { TABLE_IMS } |
sub IN_TABLE_IM () { TABLE_IMS } |
| 319 |
sub AFTER_BODY_IM () { BODY_AFTER_IMS } |
sub AFTER_BODY_IM () { BODY_AFTER_IMS } |
| 320 |
sub IN_FRAMESET_IM () { FRAME_IMS | 0b01 } |
sub IN_FRAMESET_IM () { FRAME_IMS | 0b01 } |
| 326 |
|
|
| 327 |
sub _initialize_tokenizer ($) { |
sub _initialize_tokenizer ($) { |
| 328 |
my $self = shift; |
my $self = shift; |
| 329 |
$self->{state} = 'data'; # MUST |
$self->{state} = DATA_STATE; # MUST |
| 330 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # be |
$self->{content_model} = PCDATA_CONTENT_MODEL; # be |
| 331 |
undef $self->{current_token}; # start tag, end tag, comment, or DOCTYPE |
undef $self->{current_token}; # start tag, end tag, comment, or DOCTYPE |
| 332 |
undef $self->{current_attribute}; |
undef $self->{current_attribute}; |
| 333 |
undef $self->{last_emitted_start_tag_name}; |
undef $self->{last_emitted_start_tag_name}; |
| 334 |
undef $self->{last_attribute_value_state}; |
undef $self->{last_attribute_value_state}; |
| 335 |
$self->{char} = []; |
$self->{char} = []; |
| 336 |
# $self->{next_input_character} |
# $self->{next_char} |
| 337 |
!!!next-input-character; |
!!!next-input-character; |
| 338 |
$self->{token} = []; |
$self->{token} = []; |
| 339 |
# $self->{escape} |
# $self->{escape} |
| 346 |
## ->{tag_name} (START_TAG_TOKEN, END_TAG_TOKEN) |
## ->{tag_name} (START_TAG_TOKEN, END_TAG_TOKEN) |
| 347 |
## ->{public_identifier} (DOCTYPE_TOKEN) |
## ->{public_identifier} (DOCTYPE_TOKEN) |
| 348 |
## ->{system_identifier} (DOCTYPE_TOKEN) |
## ->{system_identifier} (DOCTYPE_TOKEN) |
| 349 |
## ->{correct} == 1 or 0 (DOCTYPE_TOKEN) |
## ->{quirks} == 1 or 0 (DOCTYPE_TOKEN): "force-quirks" flag |
| 350 |
## ->{attributes} isa HASH (START_TAG_TOKEN, END_TAG_TOKEN) |
## ->{attributes} isa HASH (START_TAG_TOKEN, END_TAG_TOKEN) |
| 351 |
|
## ->{name} |
| 352 |
|
## ->{value} |
| 353 |
|
## ->{has_reference} == 1 or 0 |
| 354 |
## ->{data} (COMMENT_TOKEN, CHARACTER_TOKEN) |
## ->{data} (COMMENT_TOKEN, CHARACTER_TOKEN) |
| 355 |
|
|
| 356 |
## Emitted token MUST immediately be handled by the tree construction state. |
## Emitted token MUST immediately be handled by the tree construction state. |
| 361 |
## has completed loading. If one has, then it MUST be executed |
## has completed loading. If one has, then it MUST be executed |
| 362 |
## and removed from the list. |
## and removed from the list. |
| 363 |
|
|
| 364 |
|
## NOTE: HTML5 "Writing HTML documents" section, applied to |
| 365 |
|
## documents and not to user agents and conformance checkers, |
| 366 |
|
## contains some requirements that are not detected by the |
| 367 |
|
## parsing algorithm: |
| 368 |
|
## - Some requirements on character encoding declarations. ## TODO |
| 369 |
|
## - "Elements MUST NOT contain content that their content model disallows." |
| 370 |
|
## ... Some are parse error, some are not (will be reported by c.c.). |
| 371 |
|
## - Polytheistic slash SHOULD NOT be used. (Applied only to atheists.) ## TODO |
| 372 |
|
## - Text (in elements, attributes, and comments) SHOULD NOT contain |
| 373 |
|
## control characters other than space characters. ## TODO: (what is control character? C0, C1 and DEL? Unicode control character?) |
| 374 |
|
|
| 375 |
|
## TODO: HTML5 poses authors two SHOULD-level requirements that cannot |
| 376 |
|
## be detected by the HTML5 parsing algorithm: |
| 377 |
|
## - Text, |
| 378 |
|
|
| 379 |
sub _get_next_token ($) { |
sub _get_next_token ($) { |
| 380 |
my $self = shift; |
my $self = shift; |
| 381 |
if (@{$self->{token}}) { |
if (@{$self->{token}}) { |
| 383 |
} |
} |
| 384 |
|
|
| 385 |
A: { |
A: { |
| 386 |
if ($self->{state} eq 'data') { |
if ($self->{state} == DATA_STATE) { |
| 387 |
if ($self->{next_input_character} == 0x0026) { # & |
if ($self->{next_char} == 0x0026) { # & |
| 388 |
if ($self->{content_model} & CM_ENTITY) { # PCDATA | RCDATA |
if ($self->{content_model} & CM_ENTITY and # PCDATA | RCDATA |
| 389 |
$self->{state} = 'entity data'; |
not $self->{escape}) { |
| 390 |
|
!!!cp (1); |
| 391 |
|
$self->{state} = ENTITY_DATA_STATE; |
| 392 |
!!!next-input-character; |
!!!next-input-character; |
| 393 |
redo A; |
redo A; |
| 394 |
} else { |
} else { |
| 395 |
|
!!!cp (2); |
| 396 |
# |
# |
| 397 |
} |
} |
| 398 |
} elsif ($self->{next_input_character} == 0x002D) { # - |
} elsif ($self->{next_char} == 0x002D) { # - |
| 399 |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
| 400 |
unless ($self->{escape}) { |
unless ($self->{escape}) { |
| 401 |
if ($self->{prev_input_character}->[0] == 0x002D and # - |
if ($self->{prev_char}->[0] == 0x002D and # - |
| 402 |
$self->{prev_input_character}->[1] == 0x0021 and # ! |
$self->{prev_char}->[1] == 0x0021 and # ! |
| 403 |
$self->{prev_input_character}->[2] == 0x003C) { # < |
$self->{prev_char}->[2] == 0x003C) { # < |
| 404 |
|
!!!cp (3); |
| 405 |
$self->{escape} = 1; |
$self->{escape} = 1; |
| 406 |
|
} else { |
| 407 |
|
!!!cp (4); |
| 408 |
} |
} |
| 409 |
|
} else { |
| 410 |
|
!!!cp (5); |
| 411 |
} |
} |
| 412 |
} |
} |
| 413 |
|
|
| 414 |
# |
# |
| 415 |
} elsif ($self->{next_input_character} == 0x003C) { # < |
} elsif ($self->{next_char} == 0x003C) { # < |
| 416 |
if ($self->{content_model} & CM_FULL_MARKUP or # PCDATA |
if ($self->{content_model} & CM_FULL_MARKUP or # PCDATA |
| 417 |
(($self->{content_model} & CM_LIMITED_MARKUP) and # CDATA | RCDATA |
(($self->{content_model} & CM_LIMITED_MARKUP) and # CDATA | RCDATA |
| 418 |
not $self->{escape})) { |
not $self->{escape})) { |
| 419 |
$self->{state} = 'tag open'; |
!!!cp (6); |
| 420 |
|
$self->{state} = TAG_OPEN_STATE; |
| 421 |
!!!next-input-character; |
!!!next-input-character; |
| 422 |
redo A; |
redo A; |
| 423 |
} else { |
} else { |
| 424 |
|
!!!cp (7); |
| 425 |
# |
# |
| 426 |
} |
} |
| 427 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 428 |
if ($self->{escape} and |
if ($self->{escape} and |
| 429 |
($self->{content_model} & CM_LIMITED_MARKUP)) { # RCDATA | CDATA |
($self->{content_model} & CM_LIMITED_MARKUP)) { # RCDATA | CDATA |
| 430 |
if ($self->{prev_input_character}->[0] == 0x002D and # - |
if ($self->{prev_char}->[0] == 0x002D and # - |
| 431 |
$self->{prev_input_character}->[1] == 0x002D) { # - |
$self->{prev_char}->[1] == 0x002D) { # - |
| 432 |
|
!!!cp (8); |
| 433 |
delete $self->{escape}; |
delete $self->{escape}; |
| 434 |
|
} else { |
| 435 |
|
!!!cp (9); |
| 436 |
} |
} |
| 437 |
|
} else { |
| 438 |
|
!!!cp (10); |
| 439 |
} |
} |
| 440 |
|
|
| 441 |
# |
# |
| 442 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 443 |
|
!!!cp (11); |
| 444 |
!!!emit ({type => END_OF_FILE_TOKEN}); |
!!!emit ({type => END_OF_FILE_TOKEN}); |
| 445 |
last A; ## TODO: ok? |
last A; ## TODO: ok? |
| 446 |
|
} else { |
| 447 |
|
!!!cp (12); |
| 448 |
} |
} |
| 449 |
# Anything else |
# Anything else |
| 450 |
my $token = {type => CHARACTER_TOKEN, |
my $token = {type => CHARACTER_TOKEN, |
| 451 |
data => chr $self->{next_input_character}}; |
data => chr $self->{next_char}}; |
| 452 |
## Stay in the data state |
## Stay in the data state |
| 453 |
!!!next-input-character; |
!!!next-input-character; |
| 454 |
|
|
| 455 |
!!!emit ($token); |
!!!emit ($token); |
| 456 |
|
|
| 457 |
redo A; |
redo A; |
| 458 |
} elsif ($self->{state} eq 'entity data') { |
} elsif ($self->{state} == ENTITY_DATA_STATE) { |
| 459 |
## (cannot happen in CDATA state) |
## (cannot happen in CDATA state) |
| 460 |
|
|
| 461 |
my $token = $self->_tokenize_attempt_to_consume_an_entity (0); |
my $token = $self->_tokenize_attempt_to_consume_an_entity (0, -1); |
| 462 |
|
|
| 463 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 464 |
# next-input-character is already done |
# next-input-character is already done |
| 465 |
|
|
| 466 |
unless (defined $token) { |
unless (defined $token) { |
| 467 |
|
!!!cp (13); |
| 468 |
!!!emit ({type => CHARACTER_TOKEN, data => '&'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '&'}); |
| 469 |
} else { |
} else { |
| 470 |
|
!!!cp (14); |
| 471 |
!!!emit ($token); |
!!!emit ($token); |
| 472 |
} |
} |
| 473 |
|
|
| 474 |
redo A; |
redo A; |
| 475 |
} elsif ($self->{state} eq 'tag open') { |
} elsif ($self->{state} == TAG_OPEN_STATE) { |
| 476 |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
| 477 |
if ($self->{next_input_character} == 0x002F) { # / |
if ($self->{next_char} == 0x002F) { # / |
| 478 |
|
!!!cp (15); |
| 479 |
!!!next-input-character; |
!!!next-input-character; |
| 480 |
$self->{state} = 'close tag open'; |
$self->{state} = CLOSE_TAG_OPEN_STATE; |
| 481 |
redo A; |
redo A; |
| 482 |
} else { |
} else { |
| 483 |
|
!!!cp (16); |
| 484 |
## reconsume |
## reconsume |
| 485 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 486 |
|
|
| 487 |
!!!emit ({type => CHARACTER_TOKEN, data => '<'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '<'}); |
| 488 |
|
|
| 489 |
redo A; |
redo A; |
| 490 |
} |
} |
| 491 |
} elsif ($self->{content_model} & CM_FULL_MARKUP) { # PCDATA |
} elsif ($self->{content_model} & CM_FULL_MARKUP) { # PCDATA |
| 492 |
if ($self->{next_input_character} == 0x0021) { # ! |
if ($self->{next_char} == 0x0021) { # ! |
| 493 |
$self->{state} = 'markup declaration open'; |
!!!cp (17); |
| 494 |
|
$self->{state} = MARKUP_DECLARATION_OPEN_STATE; |
| 495 |
!!!next-input-character; |
!!!next-input-character; |
| 496 |
redo A; |
redo A; |
| 497 |
} elsif ($self->{next_input_character} == 0x002F) { # / |
} elsif ($self->{next_char} == 0x002F) { # / |
| 498 |
$self->{state} = 'close tag open'; |
!!!cp (18); |
| 499 |
|
$self->{state} = CLOSE_TAG_OPEN_STATE; |
| 500 |
!!!next-input-character; |
!!!next-input-character; |
| 501 |
redo A; |
redo A; |
| 502 |
} elsif (0x0041 <= $self->{next_input_character} and |
} elsif (0x0041 <= $self->{next_char} and |
| 503 |
$self->{next_input_character} <= 0x005A) { # A..Z |
$self->{next_char} <= 0x005A) { # A..Z |
| 504 |
|
!!!cp (19); |
| 505 |
$self->{current_token} |
$self->{current_token} |
| 506 |
= {type => START_TAG_TOKEN, |
= {type => START_TAG_TOKEN, |
| 507 |
tag_name => chr ($self->{next_input_character} + 0x0020)}; |
tag_name => chr ($self->{next_char} + 0x0020)}; |
| 508 |
$self->{state} = 'tag name'; |
$self->{state} = TAG_NAME_STATE; |
| 509 |
!!!next-input-character; |
!!!next-input-character; |
| 510 |
redo A; |
redo A; |
| 511 |
} elsif (0x0061 <= $self->{next_input_character} and |
} elsif (0x0061 <= $self->{next_char} and |
| 512 |
$self->{next_input_character} <= 0x007A) { # a..z |
$self->{next_char} <= 0x007A) { # a..z |
| 513 |
|
!!!cp (20); |
| 514 |
$self->{current_token} = {type => START_TAG_TOKEN, |
$self->{current_token} = {type => START_TAG_TOKEN, |
| 515 |
tag_name => chr ($self->{next_input_character})}; |
tag_name => chr ($self->{next_char})}; |
| 516 |
$self->{state} = 'tag name'; |
$self->{state} = TAG_NAME_STATE; |
| 517 |
!!!next-input-character; |
!!!next-input-character; |
| 518 |
redo A; |
redo A; |
| 519 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 520 |
|
!!!cp (21); |
| 521 |
!!!parse-error (type => 'empty start tag'); |
!!!parse-error (type => 'empty start tag'); |
| 522 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 523 |
!!!next-input-character; |
!!!next-input-character; |
| 524 |
|
|
| 525 |
!!!emit ({type => CHARACTER_TOKEN, data => '<>'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '<>'}); |
| 526 |
|
|
| 527 |
redo A; |
redo A; |
| 528 |
} elsif ($self->{next_input_character} == 0x003F) { # ? |
} elsif ($self->{next_char} == 0x003F) { # ? |
| 529 |
|
!!!cp (22); |
| 530 |
!!!parse-error (type => 'pio'); |
!!!parse-error (type => 'pio'); |
| 531 |
$self->{state} = 'bogus comment'; |
$self->{state} = BOGUS_COMMENT_STATE; |
| 532 |
## $self->{next_input_character} is intentionally left as is |
## $self->{next_char} is intentionally left as is |
| 533 |
redo A; |
redo A; |
| 534 |
} else { |
} else { |
| 535 |
|
!!!cp (23); |
| 536 |
!!!parse-error (type => 'bare stago'); |
!!!parse-error (type => 'bare stago'); |
| 537 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 538 |
## reconsume |
## reconsume |
| 539 |
|
|
| 540 |
!!!emit ({type => CHARACTER_TOKEN, data => '<'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '<'}); |
| 544 |
} else { |
} else { |
| 545 |
die "$0: $self->{content_model} in tag open"; |
die "$0: $self->{content_model} in tag open"; |
| 546 |
} |
} |
| 547 |
} elsif ($self->{state} eq 'close tag open') { |
} elsif ($self->{state} == CLOSE_TAG_OPEN_STATE) { |
| 548 |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
| 549 |
if (defined $self->{last_emitted_start_tag_name}) { |
if (defined $self->{last_emitted_start_tag_name}) { |
| 550 |
## NOTE: <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564> |
## NOTE: <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564> |
| 551 |
my @next_char; |
my @next_char; |
| 552 |
TAGNAME: for (my $i = 0; $i < length $self->{last_emitted_start_tag_name}; $i++) { |
TAGNAME: for (my $i = 0; $i < length $self->{last_emitted_start_tag_name}; $i++) { |
| 553 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_char}; |
| 554 |
my $c = ord substr ($self->{last_emitted_start_tag_name}, $i, 1); |
my $c = ord substr ($self->{last_emitted_start_tag_name}, $i, 1); |
| 555 |
my $C = 0x0061 <= $c && $c <= 0x007A ? $c - 0x0020 : $c; |
my $C = 0x0061 <= $c && $c <= 0x007A ? $c - 0x0020 : $c; |
| 556 |
if ($self->{next_input_character} == $c or $self->{next_input_character} == $C) { |
if ($self->{next_char} == $c or $self->{next_char} == $C) { |
| 557 |
|
!!!cp (24); |
| 558 |
!!!next-input-character; |
!!!next-input-character; |
| 559 |
next TAGNAME; |
next TAGNAME; |
| 560 |
} else { |
} else { |
| 561 |
$self->{next_input_character} = shift @next_char; # reconsume |
!!!cp (25); |
| 562 |
|
$self->{next_char} = shift @next_char; # reconsume |
| 563 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 564 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 565 |
|
|
| 566 |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
| 567 |
|
|
| 568 |
redo A; |
redo A; |
| 569 |
} |
} |
| 570 |
} |
} |
| 571 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_char}; |
| 572 |
|
|
| 573 |
unless ($self->{next_input_character} == 0x0009 or # HT |
unless ($self->{next_char} == 0x0009 or # HT |
| 574 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_char} == 0x000A or # LF |
| 575 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_char} == 0x000B or # VT |
| 576 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_char} == 0x000C or # FF |
| 577 |
$self->{next_input_character} == 0x0020 or # SP |
$self->{next_char} == 0x0020 or # SP |
| 578 |
$self->{next_input_character} == 0x003E or # > |
$self->{next_char} == 0x003E or # > |
| 579 |
$self->{next_input_character} == 0x002F or # / |
$self->{next_char} == 0x002F or # / |
| 580 |
$self->{next_input_character} == -1) { |
$self->{next_char} == -1) { |
| 581 |
$self->{next_input_character} = shift @next_char; # reconsume |
!!!cp (26); |
| 582 |
|
$self->{next_char} = shift @next_char; # reconsume |
| 583 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 584 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 585 |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
| 586 |
redo A; |
redo A; |
| 587 |
} else { |
} else { |
| 588 |
$self->{next_input_character} = shift @next_char; |
!!!cp (27); |
| 589 |
|
$self->{next_char} = shift @next_char; |
| 590 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 591 |
# and consume... |
# and consume... |
| 592 |
} |
} |
| 593 |
} else { |
} else { |
| 594 |
## No start tag token has ever been emitted |
## No start tag token has ever been emitted |
| 595 |
|
!!!cp (28); |
| 596 |
# next-input-character is already done |
# next-input-character is already done |
| 597 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 598 |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
| 599 |
redo A; |
redo A; |
| 600 |
} |
} |
| 601 |
} |
} |
| 602 |
|
|
| 603 |
if (0x0041 <= $self->{next_input_character} and |
if (0x0041 <= $self->{next_char} and |
| 604 |
$self->{next_input_character} <= 0x005A) { # A..Z |
$self->{next_char} <= 0x005A) { # A..Z |
| 605 |
|
!!!cp (29); |
| 606 |
$self->{current_token} = {type => END_TAG_TOKEN, |
$self->{current_token} = {type => END_TAG_TOKEN, |
| 607 |
tag_name => chr ($self->{next_input_character} + 0x0020)}; |
tag_name => chr ($self->{next_char} + 0x0020)}; |
| 608 |
$self->{state} = 'tag name'; |
$self->{state} = TAG_NAME_STATE; |
| 609 |
!!!next-input-character; |
!!!next-input-character; |
| 610 |
redo A; |
redo A; |
| 611 |
} elsif (0x0061 <= $self->{next_input_character} and |
} elsif (0x0061 <= $self->{next_char} and |
| 612 |
$self->{next_input_character} <= 0x007A) { # a..z |
$self->{next_char} <= 0x007A) { # a..z |
| 613 |
|
!!!cp (30); |
| 614 |
$self->{current_token} = {type => END_TAG_TOKEN, |
$self->{current_token} = {type => END_TAG_TOKEN, |
| 615 |
tag_name => chr ($self->{next_input_character})}; |
tag_name => chr ($self->{next_char})}; |
| 616 |
$self->{state} = 'tag name'; |
$self->{state} = TAG_NAME_STATE; |
| 617 |
!!!next-input-character; |
!!!next-input-character; |
| 618 |
redo A; |
redo A; |
| 619 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 620 |
|
!!!cp (31); |
| 621 |
!!!parse-error (type => 'empty end tag'); |
!!!parse-error (type => 'empty end tag'); |
| 622 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 623 |
!!!next-input-character; |
!!!next-input-character; |
| 624 |
redo A; |
redo A; |
| 625 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 626 |
|
!!!cp (32); |
| 627 |
!!!parse-error (type => 'bare etago'); |
!!!parse-error (type => 'bare etago'); |
| 628 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 629 |
# reconsume |
# reconsume |
| 630 |
|
|
| 631 |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
| 632 |
|
|
| 633 |
redo A; |
redo A; |
| 634 |
} else { |
} else { |
| 635 |
|
!!!cp (33); |
| 636 |
!!!parse-error (type => 'bogus end tag'); |
!!!parse-error (type => 'bogus end tag'); |
| 637 |
$self->{state} = 'bogus comment'; |
$self->{state} = BOGUS_COMMENT_STATE; |
| 638 |
## $self->{next_input_character} is intentionally left as is |
## $self->{next_char} is intentionally left as is |
| 639 |
redo A; |
redo A; |
| 640 |
} |
} |
| 641 |
} elsif ($self->{state} eq 'tag name') { |
} elsif ($self->{state} == TAG_NAME_STATE) { |
| 642 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_char} == 0x0009 or # HT |
| 643 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_char} == 0x000A or # LF |
| 644 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_char} == 0x000B or # VT |
| 645 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_char} == 0x000C or # FF |
| 646 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_char} == 0x0020) { # SP |
| 647 |
$self->{state} = 'before attribute name'; |
!!!cp (34); |
| 648 |
|
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 649 |
!!!next-input-character; |
!!!next-input-character; |
| 650 |
redo A; |
redo A; |
| 651 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 652 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 653 |
|
!!!cp (35); |
| 654 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 655 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 656 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 657 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 658 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 659 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 660 |
|
!!!cp (36); |
| 661 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 662 |
|
} else { |
| 663 |
|
!!!cp (37); |
| 664 |
} |
} |
| 665 |
} else { |
} else { |
| 666 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 667 |
} |
} |
| 668 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 669 |
!!!next-input-character; |
!!!next-input-character; |
| 670 |
|
|
| 671 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 672 |
|
|
| 673 |
redo A; |
redo A; |
| 674 |
} elsif (0x0041 <= $self->{next_input_character} and |
} elsif (0x0041 <= $self->{next_char} and |
| 675 |
$self->{next_input_character} <= 0x005A) { # A..Z |
$self->{next_char} <= 0x005A) { # A..Z |
| 676 |
$self->{current_token}->{tag_name} .= chr ($self->{next_input_character} + 0x0020); |
!!!cp (38); |
| 677 |
|
$self->{current_token}->{tag_name} .= chr ($self->{next_char} + 0x0020); |
| 678 |
# start tag or end tag |
# start tag or end tag |
| 679 |
## Stay in this state |
## Stay in this state |
| 680 |
!!!next-input-character; |
!!!next-input-character; |
| 681 |
redo A; |
redo A; |
| 682 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 683 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 684 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 685 |
|
!!!cp (39); |
| 686 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 687 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 688 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 689 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 690 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 691 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 692 |
|
!!!cp (40); |
| 693 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 694 |
|
} else { |
| 695 |
|
!!!cp (41); |
| 696 |
} |
} |
| 697 |
} else { |
} else { |
| 698 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 699 |
} |
} |
| 700 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 701 |
# reconsume |
# reconsume |
| 702 |
|
|
| 703 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 704 |
|
|
| 705 |
redo A; |
redo A; |
| 706 |
} elsif ($self->{next_input_character} == 0x002F) { # / |
} elsif ($self->{next_char} == 0x002F) { # / |
| 707 |
!!!next-input-character; |
!!!next-input-character; |
| 708 |
if ($self->{next_input_character} == 0x003E and # > |
if ($self->{next_char} == 0x003E and # > |
| 709 |
$self->{current_token}->{type} == START_TAG_TOKEN and |
$self->{current_token}->{type} == START_TAG_TOKEN and |
| 710 |
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
| 711 |
# permitted slash |
# permitted slash |
| 712 |
|
!!!cp (42); |
| 713 |
# |
# |
| 714 |
} else { |
} else { |
| 715 |
|
!!!cp (43); |
| 716 |
!!!parse-error (type => 'nestc'); |
!!!parse-error (type => 'nestc'); |
| 717 |
} |
} |
| 718 |
$self->{state} = 'before attribute name'; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 719 |
# next-input-character is already done |
# next-input-character is already done |
| 720 |
redo A; |
redo A; |
| 721 |
} else { |
} else { |
| 722 |
$self->{current_token}->{tag_name} .= chr $self->{next_input_character}; |
!!!cp (44); |
| 723 |
|
$self->{current_token}->{tag_name} .= chr $self->{next_char}; |
| 724 |
# start tag or end tag |
# start tag or end tag |
| 725 |
## Stay in the state |
## Stay in the state |
| 726 |
!!!next-input-character; |
!!!next-input-character; |
| 727 |
redo A; |
redo A; |
| 728 |
} |
} |
| 729 |
} elsif ($self->{state} eq 'before attribute name') { |
} elsif ($self->{state} == BEFORE_ATTRIBUTE_NAME_STATE) { |
| 730 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_char} == 0x0009 or # HT |
| 731 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_char} == 0x000A or # LF |
| 732 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_char} == 0x000B or # VT |
| 733 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_char} == 0x000C or # FF |
| 734 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_char} == 0x0020) { # SP |
| 735 |
|
!!!cp (45); |
| 736 |
## Stay in the state |
## Stay in the state |
| 737 |
!!!next-input-character; |
!!!next-input-character; |
| 738 |
redo A; |
redo A; |
| 739 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 740 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 741 |
|
!!!cp (46); |
| 742 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 743 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 744 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 745 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 746 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 747 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 748 |
|
!!!cp (47); |
| 749 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 750 |
|
} else { |
| 751 |
|
!!!cp (48); |
| 752 |
} |
} |
| 753 |
} else { |
} else { |
| 754 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 755 |
} |
} |
| 756 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 757 |
!!!next-input-character; |
!!!next-input-character; |
| 758 |
|
|
| 759 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 760 |
|
|
| 761 |
redo A; |
redo A; |
| 762 |
} elsif (0x0041 <= $self->{next_input_character} and |
} elsif (0x0041 <= $self->{next_char} and |
| 763 |
$self->{next_input_character} <= 0x005A) { # A..Z |
$self->{next_char} <= 0x005A) { # A..Z |
| 764 |
$self->{current_attribute} = {name => chr ($self->{next_input_character} + 0x0020), |
!!!cp (49); |
| 765 |
|
$self->{current_attribute} = {name => chr ($self->{next_char} + 0x0020), |
| 766 |
value => ''}; |
value => ''}; |
| 767 |
$self->{state} = 'attribute name'; |
$self->{state} = ATTRIBUTE_NAME_STATE; |
| 768 |
!!!next-input-character; |
!!!next-input-character; |
| 769 |
redo A; |
redo A; |
| 770 |
} elsif ($self->{next_input_character} == 0x002F) { # / |
} elsif ($self->{next_char} == 0x002F) { # / |
| 771 |
!!!next-input-character; |
!!!next-input-character; |
| 772 |
if ($self->{next_input_character} == 0x003E and # > |
if ($self->{next_char} == 0x003E and # > |
| 773 |
$self->{current_token}->{type} == START_TAG_TOKEN and |
$self->{current_token}->{type} == START_TAG_TOKEN and |
| 774 |
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
| 775 |
# permitted slash |
# permitted slash |
| 776 |
|
!!!cp (50); |
| 777 |
# |
# |
| 778 |
} else { |
} else { |
| 779 |
|
!!!cp (51); |
| 780 |
!!!parse-error (type => 'nestc'); |
!!!parse-error (type => 'nestc'); |
| 781 |
} |
} |
| 782 |
## Stay in the state |
## Stay in the state |
| 783 |
# next-input-character is already done |
# next-input-character is already done |
| 784 |
redo A; |
redo A; |
| 785 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 786 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 787 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 788 |
|
!!!cp (52); |
| 789 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 790 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 791 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 792 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 793 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 794 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 795 |
|
!!!cp (53); |
| 796 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 797 |
|
} else { |
| 798 |
|
!!!cp (54); |
| 799 |
} |
} |
| 800 |
} else { |
} else { |
| 801 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 802 |
} |
} |
| 803 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 804 |
# reconsume |
# reconsume |
| 805 |
|
|
| 806 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 807 |
|
|
| 808 |
redo A; |
redo A; |
| 809 |
} else { |
} else { |
| 810 |
$self->{current_attribute} = {name => chr ($self->{next_input_character}), |
if ({ |
| 811 |
|
0x0022 => 1, # " |
| 812 |
|
0x0027 => 1, # ' |
| 813 |
|
0x003D => 1, # = |
| 814 |
|
}->{$self->{next_char}}) { |
| 815 |
|
!!!cp (55); |
| 816 |
|
!!!parse-error (type => 'bad attribute name'); |
| 817 |
|
} else { |
| 818 |
|
!!!cp (56); |
| 819 |
|
} |
| 820 |
|
$self->{current_attribute} = {name => chr ($self->{next_char}), |
| 821 |
value => ''}; |
value => ''}; |
| 822 |
$self->{state} = 'attribute name'; |
$self->{state} = ATTRIBUTE_NAME_STATE; |
| 823 |
!!!next-input-character; |
!!!next-input-character; |
| 824 |
redo A; |
redo A; |
| 825 |
} |
} |
| 826 |
} elsif ($self->{state} eq 'attribute name') { |
} elsif ($self->{state} == ATTRIBUTE_NAME_STATE) { |
| 827 |
my $before_leave = sub { |
my $before_leave = sub { |
| 828 |
if (exists $self->{current_token}->{attributes} # start tag or end tag |
if (exists $self->{current_token}->{attributes} # start tag or end tag |
| 829 |
->{$self->{current_attribute}->{name}}) { # MUST |
->{$self->{current_attribute}->{name}}) { # MUST |
| 830 |
|
!!!cp (57); |
| 831 |
!!!parse-error (type => 'duplicate attribute:'.$self->{current_attribute}->{name}); |
!!!parse-error (type => 'duplicate attribute:'.$self->{current_attribute}->{name}); |
| 832 |
## Discard $self->{current_attribute} # MUST |
## Discard $self->{current_attribute} # MUST |
| 833 |
} else { |
} else { |
| 834 |
|
!!!cp (58); |
| 835 |
$self->{current_token}->{attributes}->{$self->{current_attribute}->{name}} |
$self->{current_token}->{attributes}->{$self->{current_attribute}->{name}} |
| 836 |
= $self->{current_attribute}; |
= $self->{current_attribute}; |
| 837 |
} |
} |
| 838 |
}; # $before_leave |
}; # $before_leave |
| 839 |
|
|
| 840 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_char} == 0x0009 or # HT |
| 841 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_char} == 0x000A or # LF |
| 842 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_char} == 0x000B or # VT |
| 843 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_char} == 0x000C or # FF |
| 844 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_char} == 0x0020) { # SP |
| 845 |
|
!!!cp (59); |
| 846 |
$before_leave->(); |
$before_leave->(); |
| 847 |
$self->{state} = 'after attribute name'; |
$self->{state} = AFTER_ATTRIBUTE_NAME_STATE; |
| 848 |
!!!next-input-character; |
!!!next-input-character; |
| 849 |
redo A; |
redo A; |
| 850 |
} elsif ($self->{next_input_character} == 0x003D) { # = |
} elsif ($self->{next_char} == 0x003D) { # = |
| 851 |
|
!!!cp (60); |
| 852 |
$before_leave->(); |
$before_leave->(); |
| 853 |
$self->{state} = 'before attribute value'; |
$self->{state} = BEFORE_ATTRIBUTE_VALUE_STATE; |
| 854 |
!!!next-input-character; |
!!!next-input-character; |
| 855 |
redo A; |
redo A; |
| 856 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 857 |
$before_leave->(); |
$before_leave->(); |
| 858 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 859 |
|
!!!cp (61); |
| 860 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 861 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 862 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 863 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 864 |
|
!!!cp (62); |
| 865 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 866 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 867 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 869 |
} else { |
} else { |
| 870 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 871 |
} |
} |
| 872 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 873 |
!!!next-input-character; |
!!!next-input-character; |
| 874 |
|
|
| 875 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 876 |
|
|
| 877 |
redo A; |
redo A; |
| 878 |
} elsif (0x0041 <= $self->{next_input_character} and |
} elsif (0x0041 <= $self->{next_char} and |
| 879 |
$self->{next_input_character} <= 0x005A) { # A..Z |
$self->{next_char} <= 0x005A) { # A..Z |
| 880 |
$self->{current_attribute}->{name} .= chr ($self->{next_input_character} + 0x0020); |
!!!cp (63); |
| 881 |
|
$self->{current_attribute}->{name} .= chr ($self->{next_char} + 0x0020); |
| 882 |
## Stay in the state |
## Stay in the state |
| 883 |
!!!next-input-character; |
!!!next-input-character; |
| 884 |
redo A; |
redo A; |
| 885 |
} elsif ($self->{next_input_character} == 0x002F) { # / |
} elsif ($self->{next_char} == 0x002F) { # / |
| 886 |
$before_leave->(); |
$before_leave->(); |
| 887 |
!!!next-input-character; |
!!!next-input-character; |
| 888 |
if ($self->{next_input_character} == 0x003E and # > |
if ($self->{next_char} == 0x003E and # > |
| 889 |
$self->{current_token}->{type} == START_TAG_TOKEN and |
$self->{current_token}->{type} == START_TAG_TOKEN and |
| 890 |
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
| 891 |
# permitted slash |
# permitted slash |
| 892 |
|
!!!cp (64); |
| 893 |
# |
# |
| 894 |
} else { |
} else { |
| 895 |
|
!!!cp (65); |
| 896 |
!!!parse-error (type => 'nestc'); |
!!!parse-error (type => 'nestc'); |
| 897 |
} |
} |
| 898 |
$self->{state} = 'before attribute name'; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 899 |
# next-input-character is already done |
# next-input-character is already done |
| 900 |
redo A; |
redo A; |
| 901 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 902 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 903 |
$before_leave->(); |
$before_leave->(); |
| 904 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 905 |
|
!!!cp (66); |
| 906 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 907 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 908 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 909 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 910 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 911 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 912 |
|
!!!cp (67); |
| 913 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 914 |
|
} else { |
| 915 |
|
!!!cp (68); |
| 916 |
} |
} |
| 917 |
} else { |
} else { |
| 918 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 919 |
} |
} |
| 920 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 921 |
# reconsume |
# reconsume |
| 922 |
|
|
| 923 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 924 |
|
|
| 925 |
redo A; |
redo A; |
| 926 |
} else { |
} else { |
| 927 |
$self->{current_attribute}->{name} .= chr ($self->{next_input_character}); |
if ($self->{next_char} == 0x0022 or # " |
| 928 |
|
$self->{next_char} == 0x0027) { # ' |
| 929 |
|
!!!cp (69); |
| 930 |
|
!!!parse-error (type => 'bad attribute name'); |
| 931 |
|
} else { |
| 932 |
|
!!!cp (70); |
| 933 |
|
} |
| 934 |
|
$self->{current_attribute}->{name} .= chr ($self->{next_char}); |
| 935 |
## Stay in the state |
## Stay in the state |
| 936 |
!!!next-input-character; |
!!!next-input-character; |
| 937 |
redo A; |
redo A; |
| 938 |
} |
} |
| 939 |
} elsif ($self->{state} eq 'after attribute name') { |
} elsif ($self->{state} == AFTER_ATTRIBUTE_NAME_STATE) { |
| 940 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_char} == 0x0009 or # HT |
| 941 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_char} == 0x000A or # LF |
| 942 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_char} == 0x000B or # VT |
| 943 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_char} == 0x000C or # FF |
| 944 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_char} == 0x0020) { # SP |
| 945 |
|
!!!cp (71); |
| 946 |
## Stay in the state |
## Stay in the state |
| 947 |
!!!next-input-character; |
!!!next-input-character; |
| 948 |
redo A; |
redo A; |
| 949 |
} elsif ($self->{next_input_character} == 0x003D) { # = |
} elsif ($self->{next_char} == 0x003D) { # = |
| 950 |
$self->{state} = 'before attribute value'; |
!!!cp (72); |
| 951 |
|
$self->{state} = BEFORE_ATTRIBUTE_VALUE_STATE; |
| 952 |
!!!next-input-character; |
!!!next-input-character; |
| 953 |
redo A; |
redo A; |
| 954 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 955 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 956 |
|
!!!cp (73); |
| 957 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 958 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 959 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 960 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 961 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 962 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 963 |
|
!!!cp (74); |
| 964 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 965 |
|
} else { |
| 966 |
|
!!!cp (75); |
| 967 |
} |
} |
| 968 |
} else { |
} else { |
| 969 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 970 |
} |
} |
| 971 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 972 |
!!!next-input-character; |
!!!next-input-character; |
| 973 |
|
|
| 974 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 975 |
|
|
| 976 |
redo A; |
redo A; |
| 977 |
} elsif (0x0041 <= $self->{next_input_character} and |
} elsif (0x0041 <= $self->{next_char} and |
| 978 |
$self->{next_input_character} <= 0x005A) { # A..Z |
$self->{next_char} <= 0x005A) { # A..Z |
| 979 |
$self->{current_attribute} = {name => chr ($self->{next_input_character} + 0x0020), |
!!!cp (76); |
| 980 |
|
$self->{current_attribute} = {name => chr ($self->{next_char} + 0x0020), |
| 981 |
value => ''}; |
value => ''}; |
| 982 |
$self->{state} = 'attribute name'; |
$self->{state} = ATTRIBUTE_NAME_STATE; |
| 983 |
!!!next-input-character; |
!!!next-input-character; |
| 984 |
redo A; |
redo A; |
| 985 |
} elsif ($self->{next_input_character} == 0x002F) { # / |
} elsif ($self->{next_char} == 0x002F) { # / |
| 986 |
!!!next-input-character; |
!!!next-input-character; |
| 987 |
if ($self->{next_input_character} == 0x003E and # > |
if ($self->{next_char} == 0x003E and # > |
| 988 |
$self->{current_token}->{type} == START_TAG_TOKEN and |
$self->{current_token}->{type} == START_TAG_TOKEN and |
| 989 |
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
| 990 |
# permitted slash |
# permitted slash |
| 991 |
|
!!!cp (77); |
| 992 |
# |
# |
| 993 |
} else { |
} else { |
| 994 |
|
!!!cp (78); |
| 995 |
!!!parse-error (type => 'nestc'); |
!!!parse-error (type => 'nestc'); |
| 996 |
## TODO: Different error type for <aa / bb> than <aa/> |
## TODO: Different error type for <aa / bb> than <aa/> |
| 997 |
} |
} |
| 998 |
$self->{state} = 'before attribute name'; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 999 |
# next-input-character is already done |
# next-input-character is already done |
| 1000 |
redo A; |
redo A; |
| 1001 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1002 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 1003 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1004 |
|
!!!cp (79); |
| 1005 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 1006 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 1007 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1008 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1009 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1010 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 1011 |
|
!!!cp (80); |
| 1012 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 1013 |
|
} else { |
| 1014 |
|
!!!cp (81); |
| 1015 |
} |
} |
| 1016 |
} else { |
} else { |
| 1017 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1018 |
} |
} |
| 1019 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1020 |
# reconsume |
# reconsume |
| 1021 |
|
|
| 1022 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 1023 |
|
|
| 1024 |
redo A; |
redo A; |
| 1025 |
} else { |
} else { |
| 1026 |
$self->{current_attribute} = {name => chr ($self->{next_input_character}), |
!!!cp (82); |
| 1027 |
|
$self->{current_attribute} = {name => chr ($self->{next_char}), |
| 1028 |
value => ''}; |
value => ''}; |
| 1029 |
$self->{state} = 'attribute name'; |
$self->{state} = ATTRIBUTE_NAME_STATE; |
| 1030 |
!!!next-input-character; |
!!!next-input-character; |
| 1031 |
redo A; |
redo A; |
| 1032 |
} |
} |
| 1033 |
} elsif ($self->{state} eq 'before attribute value') { |
} elsif ($self->{state} == BEFORE_ATTRIBUTE_VALUE_STATE) { |
| 1034 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_char} == 0x0009 or # HT |
| 1035 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_char} == 0x000A or # LF |
| 1036 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_char} == 0x000B or # VT |
| 1037 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_char} == 0x000C or # FF |
| 1038 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_char} == 0x0020) { # SP |
| 1039 |
|
!!!cp (83); |
| 1040 |
## Stay in the state |
## Stay in the state |
| 1041 |
!!!next-input-character; |
!!!next-input-character; |
| 1042 |
redo A; |
redo A; |
| 1043 |
} elsif ($self->{next_input_character} == 0x0022) { # " |
} elsif ($self->{next_char} == 0x0022) { # " |
| 1044 |
$self->{state} = 'attribute value (double-quoted)'; |
!!!cp (84); |
| 1045 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
| 1046 |
!!!next-input-character; |
!!!next-input-character; |
| 1047 |
redo A; |
redo A; |
| 1048 |
} elsif ($self->{next_input_character} == 0x0026) { # & |
} elsif ($self->{next_char} == 0x0026) { # & |
| 1049 |
$self->{state} = 'attribute value (unquoted)'; |
!!!cp (85); |
| 1050 |
|
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
| 1051 |
## reconsume |
## reconsume |
| 1052 |
redo A; |
redo A; |
| 1053 |
} elsif ($self->{next_input_character} == 0x0027) { # ' |
} elsif ($self->{next_char} == 0x0027) { # ' |
| 1054 |
$self->{state} = 'attribute value (single-quoted)'; |
!!!cp (86); |
| 1055 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
| 1056 |
!!!next-input-character; |
!!!next-input-character; |
| 1057 |
redo A; |
redo A; |
| 1058 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 1059 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1060 |
|
!!!cp (87); |
| 1061 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 1062 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 1063 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1064 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1065 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1066 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 1067 |
|
!!!cp (88); |
| 1068 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 1069 |
|
} else { |
| 1070 |
|
!!!cp (89); |
| 1071 |
} |
} |
| 1072 |
} else { |
} else { |
| 1073 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1074 |
} |
} |
| 1075 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1076 |
!!!next-input-character; |
!!!next-input-character; |
| 1077 |
|
|
| 1078 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 1079 |
|
|
| 1080 |
redo A; |
redo A; |
| 1081 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1082 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 1083 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1084 |
|
!!!cp (90); |
| 1085 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 1086 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 1087 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1088 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1089 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1090 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 1091 |
|
!!!cp (91); |
| 1092 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 1093 |
|
} else { |
| 1094 |
|
!!!cp (92); |
| 1095 |
} |
} |
| 1096 |
} else { |
} else { |
| 1097 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1098 |
} |
} |
| 1099 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1100 |
## reconsume |
## reconsume |
| 1101 |
|
|
| 1102 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 1103 |
|
|
| 1104 |
redo A; |
redo A; |
| 1105 |
} else { |
} else { |
| 1106 |
$self->{current_attribute}->{value} .= chr ($self->{next_input_character}); |
if ($self->{next_char} == 0x003D) { # = |
| 1107 |
$self->{state} = 'attribute value (unquoted)'; |
!!!cp (93); |
| 1108 |
|
!!!parse-error (type => 'bad attribute value'); |
| 1109 |
|
} else { |
| 1110 |
|
!!!cp (94); |
| 1111 |
|
} |
| 1112 |
|
$self->{current_attribute}->{value} .= chr ($self->{next_char}); |
| 1113 |
|
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
| 1114 |
!!!next-input-character; |
!!!next-input-character; |
| 1115 |
redo A; |
redo A; |
| 1116 |
} |
} |
| 1117 |
} elsif ($self->{state} eq 'attribute value (double-quoted)') { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE) { |
| 1118 |
if ($self->{next_input_character} == 0x0022) { # " |
if ($self->{next_char} == 0x0022) { # " |
| 1119 |
$self->{state} = 'before attribute name'; |
!!!cp (95); |
| 1120 |
|
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
| 1121 |
!!!next-input-character; |
!!!next-input-character; |
| 1122 |
redo A; |
redo A; |
| 1123 |
} elsif ($self->{next_input_character} == 0x0026) { # & |
} elsif ($self->{next_char} == 0x0026) { # & |
| 1124 |
$self->{last_attribute_value_state} = 'attribute value (double-quoted)'; |
!!!cp (96); |
| 1125 |
$self->{state} = 'entity in attribute value'; |
$self->{last_attribute_value_state} = $self->{state}; |
| 1126 |
|
$self->{state} = ENTITY_IN_ATTRIBUTE_VALUE_STATE; |
| 1127 |
!!!next-input-character; |
!!!next-input-character; |
| 1128 |
redo A; |
redo A; |
| 1129 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1130 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
| 1131 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1132 |
|
!!!cp (97); |
| 1133 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 1134 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 1135 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1136 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1137 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1138 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 1139 |
|
!!!cp (98); |
| 1140 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 1141 |
|
} else { |
| 1142 |
|
!!!cp (99); |
| 1143 |
} |
} |
| 1144 |
} else { |
} else { |
| 1145 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1146 |
} |
} |
| 1147 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1148 |
## reconsume |
## reconsume |
| 1149 |
|
|
| 1150 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 1151 |
|
|
| 1152 |
redo A; |
redo A; |
| 1153 |
} else { |
} else { |
| 1154 |
$self->{current_attribute}->{value} .= chr ($self->{next_input_character}); |
!!!cp (100); |
| 1155 |
|
$self->{current_attribute}->{value} .= chr ($self->{next_char}); |
| 1156 |
## Stay in the state |
## Stay in the state |
| 1157 |
!!!next-input-character; |
!!!next-input-character; |
| 1158 |
redo A; |
redo A; |
| 1159 |
} |
} |
| 1160 |
} elsif ($self->{state} eq 'attribute value (single-quoted)') { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE) { |
| 1161 |
if ($self->{next_input_character} == 0x0027) { # ' |
if ($self->{next_char} == 0x0027) { # ' |
| 1162 |
$self->{state} = 'before attribute name'; |
!!!cp (101); |
| 1163 |
|
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
| 1164 |
!!!next-input-character; |
!!!next-input-character; |
| 1165 |
redo A; |
redo A; |
| 1166 |
} elsif ($self->{next_input_character} == 0x0026) { # & |
} elsif ($self->{next_char} == 0x0026) { # & |
| 1167 |
$self->{last_attribute_value_state} = 'attribute value (single-quoted)'; |
!!!cp (102); |
| 1168 |
$self->{state} = 'entity in attribute value'; |
$self->{last_attribute_value_state} = $self->{state}; |
| 1169 |
|
$self->{state} = ENTITY_IN_ATTRIBUTE_VALUE_STATE; |
| 1170 |
!!!next-input-character; |
!!!next-input-character; |
| 1171 |
redo A; |
redo A; |
| 1172 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1173 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
| 1174 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1175 |
|
!!!cp (103); |
| 1176 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 1177 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 1178 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1179 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1180 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1181 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 1182 |
|
!!!cp (104); |
| 1183 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 1184 |
|
} else { |
| 1185 |
|
!!!cp (105); |
| 1186 |
} |
} |
| 1187 |
} else { |
} else { |
| 1188 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1189 |
} |
} |
| 1190 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1191 |
## reconsume |
## reconsume |
| 1192 |
|
|
| 1193 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 1194 |
|
|
| 1195 |
redo A; |
redo A; |
| 1196 |
} else { |
} else { |
| 1197 |
$self->{current_attribute}->{value} .= chr ($self->{next_input_character}); |
!!!cp (106); |
| 1198 |
|
$self->{current_attribute}->{value} .= chr ($self->{next_char}); |
| 1199 |
## Stay in the state |
## Stay in the state |
| 1200 |
!!!next-input-character; |
!!!next-input-character; |
| 1201 |
redo A; |
redo A; |
| 1202 |
} |
} |
| 1203 |
} elsif ($self->{state} eq 'attribute value (unquoted)') { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_UNQUOTED_STATE) { |
| 1204 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_char} == 0x0009 or # HT |
| 1205 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_char} == 0x000A or # LF |
| 1206 |
$self->{next_input_character} == 0x000B or # HT |
$self->{next_char} == 0x000B or # HT |
| 1207 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_char} == 0x000C or # FF |
| 1208 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_char} == 0x0020) { # SP |
| 1209 |
$self->{state} = 'before attribute name'; |
!!!cp (107); |
| 1210 |
!!!next-input-character; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 1211 |
redo A; |
!!!next-input-character; |
| 1212 |
} elsif ($self->{next_input_character} == 0x0026) { # & |
redo A; |
| 1213 |
$self->{last_attribute_value_state} = 'attribute value (unquoted)'; |
} elsif ($self->{next_char} == 0x0026) { # & |
| 1214 |
$self->{state} = 'entity in attribute value'; |
!!!cp (108); |
| 1215 |
|
$self->{last_attribute_value_state} = $self->{state}; |
| 1216 |
|
$self->{state} = ENTITY_IN_ATTRIBUTE_VALUE_STATE; |
| 1217 |
!!!next-input-character; |
!!!next-input-character; |
| 1218 |
redo A; |
redo A; |
| 1219 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 1220 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1221 |
|
!!!cp (109); |
| 1222 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 1223 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 1224 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1225 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1226 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1227 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 1228 |
|
!!!cp (110); |
| 1229 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 1230 |
|
} else { |
| 1231 |
|
!!!cp (111); |
| 1232 |
} |
} |
| 1233 |
} else { |
} else { |
| 1234 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1235 |
} |
} |
| 1236 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1237 |
!!!next-input-character; |
!!!next-input-character; |
| 1238 |
|
|
| 1239 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 1240 |
|
|
| 1241 |
redo A; |
redo A; |
| 1242 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1243 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 1244 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1245 |
|
!!!cp (112); |
| 1246 |
$self->{current_token}->{first_start_tag} |
$self->{current_token}->{first_start_tag} |
| 1247 |
= not defined $self->{last_emitted_start_tag_name}; |
= not defined $self->{last_emitted_start_tag_name}; |
| 1248 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1249 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1250 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1251 |
if ($self->{current_token}->{attributes}) { |
if ($self->{current_token}->{attributes}) { |
| 1252 |
|
!!!cp (113); |
| 1253 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
| 1254 |
|
} else { |
| 1255 |
|
!!!cp (114); |
| 1256 |
} |
} |
| 1257 |
} else { |
} else { |
| 1258 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1259 |
} |
} |
| 1260 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1261 |
## reconsume |
## reconsume |
| 1262 |
|
|
| 1263 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 1264 |
|
|
| 1265 |
redo A; |
redo A; |
| 1266 |
} else { |
} else { |
| 1267 |
$self->{current_attribute}->{value} .= chr ($self->{next_input_character}); |
if ({ |
| 1268 |
|
0x0022 => 1, # " |
| 1269 |
|
0x0027 => 1, # ' |
| 1270 |
|
0x003D => 1, # = |
| 1271 |
|
}->{$self->{next_char}}) { |
| 1272 |
|
!!!cp (115); |
| 1273 |
|
!!!parse-error (type => 'bad attribute value'); |
| 1274 |
|
} else { |
| 1275 |
|
!!!cp (116); |
| 1276 |
|
} |
| 1277 |
|
$self->{current_attribute}->{value} .= chr ($self->{next_char}); |
| 1278 |
## Stay in the state |
## Stay in the state |
| 1279 |
!!!next-input-character; |
!!!next-input-character; |
| 1280 |
redo A; |
redo A; |
| 1281 |
} |
} |
| 1282 |
} elsif ($self->{state} eq 'entity in attribute value') { |
} elsif ($self->{state} == ENTITY_IN_ATTRIBUTE_VALUE_STATE) { |
| 1283 |
my $token = $self->_tokenize_attempt_to_consume_an_entity (1); |
my $token = $self->_tokenize_attempt_to_consume_an_entity |
| 1284 |
|
(1, |
| 1285 |
|
$self->{last_attribute_value_state} |
| 1286 |
|
== ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE ? 0x0022 : # " |
| 1287 |
|
$self->{last_attribute_value_state} |
| 1288 |
|
== ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE ? 0x0027 : # ' |
| 1289 |
|
-1); |
| 1290 |
|
|
| 1291 |
unless (defined $token) { |
unless (defined $token) { |
| 1292 |
|
!!!cp (117); |
| 1293 |
$self->{current_attribute}->{value} .= '&'; |
$self->{current_attribute}->{value} .= '&'; |
| 1294 |
} else { |
} else { |
| 1295 |
|
!!!cp (118); |
| 1296 |
$self->{current_attribute}->{value} .= $token->{data}; |
$self->{current_attribute}->{value} .= $token->{data}; |
| 1297 |
|
$self->{current_attribute}->{has_reference} = $token->{has_reference}; |
| 1298 |
## ISSUE: spec says "append the returned character token to the current attribute's value" |
## ISSUE: spec says "append the returned character token to the current attribute's value" |
| 1299 |
} |
} |
| 1300 |
|
|
| 1301 |
$self->{state} = $self->{last_attribute_value_state}; |
$self->{state} = $self->{last_attribute_value_state}; |
| 1302 |
# next-input-character is already done |
# next-input-character is already done |
| 1303 |
redo A; |
redo A; |
| 1304 |
} elsif ($self->{state} eq 'bogus comment') { |
} elsif ($self->{state} == AFTER_ATTRIBUTE_VALUE_QUOTED_STATE) { |
| 1305 |
|
if ($self->{next_char} == 0x0009 or # HT |
| 1306 |
|
$self->{next_char} == 0x000A or # LF |
| 1307 |
|
$self->{next_char} == 0x000B or # VT |
| 1308 |
|
$self->{next_char} == 0x000C or # FF |
| 1309 |
|
$self->{next_char} == 0x0020) { # SP |
| 1310 |
|
!!!cp (118); |
| 1311 |
|
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 1312 |
|
!!!next-input-character; |
| 1313 |
|
redo A; |
| 1314 |
|
} elsif ($self->{next_char} == 0x003E) { # > |
| 1315 |
|
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1316 |
|
!!!cp (119); |
| 1317 |
|
$self->{current_token}->{first_start_tag} |
| 1318 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 1319 |
|
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1320 |
|
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1321 |
|
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1322 |
|
if ($self->{current_token}->{attributes}) { |
| 1323 |
|
!!!cp (120); |
| 1324 |
|
!!!parse-error (type => 'end tag attribute'); |
| 1325 |
|
} else { |
| 1326 |
|
!!!cp (121); |
| 1327 |
|
} |
| 1328 |
|
} else { |
| 1329 |
|
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1330 |
|
} |
| 1331 |
|
$self->{state} = DATA_STATE; |
| 1332 |
|
!!!next-input-character; |
| 1333 |
|
|
| 1334 |
|
!!!emit ($self->{current_token}); # start tag or end tag |
| 1335 |
|
|
| 1336 |
|
redo A; |
| 1337 |
|
} elsif ($self->{next_char} == 0x002F) { # / |
| 1338 |
|
!!!next-input-character; |
| 1339 |
|
if ($self->{next_char} == 0x003E and # > |
| 1340 |
|
$self->{current_token}->{type} == START_TAG_TOKEN and |
| 1341 |
|
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
| 1342 |
|
# permitted slash |
| 1343 |
|
!!!cp (122); |
| 1344 |
|
# |
| 1345 |
|
} else { |
| 1346 |
|
!!!cp (123); |
| 1347 |
|
!!!parse-error (type => 'nestc'); |
| 1348 |
|
} |
| 1349 |
|
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 1350 |
|
# next-input-character is already done |
| 1351 |
|
redo A; |
| 1352 |
|
} else { |
| 1353 |
|
!!!cp (124); |
| 1354 |
|
!!!parse-error (type => 'no space between attributes'); |
| 1355 |
|
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 1356 |
|
## reconsume |
| 1357 |
|
redo A; |
| 1358 |
|
} |
| 1359 |
|
} elsif ($self->{state} == BOGUS_COMMENT_STATE) { |
| 1360 |
## (only happen if PCDATA state) |
## (only happen if PCDATA state) |
| 1361 |
|
|
| 1362 |
my $token = {type => COMMENT_TOKEN, data => ''}; |
my $token = {type => COMMENT_TOKEN, data => ''}; |
| 1363 |
|
|
| 1364 |
BC: { |
BC: { |
| 1365 |
if ($self->{next_input_character} == 0x003E) { # > |
if ($self->{next_char} == 0x003E) { # > |
| 1366 |
$self->{state} = 'data'; |
!!!cp (124); |
| 1367 |
|
$self->{state} = DATA_STATE; |
| 1368 |
!!!next-input-character; |
!!!next-input-character; |
| 1369 |
|
|
| 1370 |
!!!emit ($token); |
!!!emit ($token); |
| 1371 |
|
|
| 1372 |
redo A; |
redo A; |
| 1373 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1374 |
$self->{state} = 'data'; |
!!!cp (125); |
| 1375 |
|
$self->{state} = DATA_STATE; |
| 1376 |
## reconsume |
## reconsume |
| 1377 |
|
|
| 1378 |
!!!emit ($token); |
!!!emit ($token); |
| 1379 |
|
|
| 1380 |
redo A; |
redo A; |
| 1381 |
} else { |
} else { |
| 1382 |
$token->{data} .= chr ($self->{next_input_character}); |
!!!cp (126); |
| 1383 |
|
$token->{data} .= chr ($self->{next_char}); |
| 1384 |
!!!next-input-character; |
!!!next-input-character; |
| 1385 |
redo BC; |
redo BC; |
| 1386 |
} |
} |
| 1387 |
} # BC |
} # BC |
| 1388 |
} elsif ($self->{state} eq 'markup declaration open') { |
|
| 1389 |
|
die "$0: _get_next_token: unexpected case [BC]"; |
| 1390 |
|
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
| 1391 |
## (only happen if PCDATA state) |
## (only happen if PCDATA state) |
| 1392 |
|
|
| 1393 |
my @next_char; |
my @next_char; |
| 1394 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_char}; |
| 1395 |
|
|
| 1396 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_char} == 0x002D) { # - |
| 1397 |
!!!next-input-character; |
!!!next-input-character; |
| 1398 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_char}; |
| 1399 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_char} == 0x002D) { # - |
| 1400 |
|
!!!cp (127); |
| 1401 |
$self->{current_token} = {type => COMMENT_TOKEN, data => ''}; |
$self->{current_token} = {type => COMMENT_TOKEN, data => ''}; |
| 1402 |
$self->{state} = 'comment start'; |
$self->{state} = COMMENT_START_STATE; |
| 1403 |
!!!next-input-character; |
!!!next-input-character; |
| 1404 |
redo A; |
redo A; |
| 1405 |
|
} else { |
| 1406 |
|
!!!cp (128); |
| 1407 |
} |
} |
| 1408 |
} elsif ($self->{next_input_character} == 0x0044 or # D |
} elsif ($self->{next_char} == 0x0044 or # D |
| 1409 |
$self->{next_input_character} == 0x0064) { # d |
$self->{next_char} == 0x0064) { # d |
| 1410 |
!!!next-input-character; |
!!!next-input-character; |
| 1411 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_char}; |
| 1412 |
if ($self->{next_input_character} == 0x004F or # O |
if ($self->{next_char} == 0x004F or # O |
| 1413 |
$self->{next_input_character} == 0x006F) { # o |
$self->{next_char} == 0x006F) { # o |
| 1414 |
!!!next-input-character; |
!!!next-input-character; |
| 1415 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_char}; |
| 1416 |
if ($self->{next_input_character} == 0x0043 or # C |
if ($self->{next_char} == 0x0043 or # C |
| 1417 |
$self->{next_input_character} == 0x0063) { # c |
$self->{next_char} == 0x0063) { # c |
| 1418 |
!!!next-input-character; |
!!!next-input-character; |
| 1419 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_char}; |
| 1420 |
if ($self->{next_input_character} == 0x0054 or # T |
if ($self->{next_char} == 0x0054 or # T |
| 1421 |
$self->{next_input_character} == 0x0074) { # t |
$self->{next_char} == 0x0074) { # t |
| 1422 |
!!!next-input-character; |
!!!next-input-character; |
| 1423 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_char}; |
| 1424 |
if ($self->{next_input_character} == 0x0059 or # Y |
if ($self->{next_char} == 0x0059 or # Y |
| 1425 |
$self->{next_input_character} == 0x0079) { # y |
$self->{next_char} == 0x0079) { # y |
| 1426 |
!!!next-input-character; |
!!!next-input-character; |
| 1427 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_char}; |
| 1428 |
if ($self->{next_input_character} == 0x0050 or # P |
if ($self->{next_char} == 0x0050 or # P |
| 1429 |
$self->{next_input_character} == 0x0070) { # p |
$self->{next_char} == 0x0070) { # p |
| 1430 |
!!!next-input-character; |
!!!next-input-character; |
| 1431 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_char}; |
| 1432 |
if ($self->{next_input_character} == 0x0045 or # E |
if ($self->{next_char} == 0x0045 or # E |
| 1433 |
$self->{next_input_character} == 0x0065) { # e |
$self->{next_char} == 0x0065) { # e |
| 1434 |
## ISSUE: What a stupid code this is! |
!!!cp (129); |
| 1435 |
$self->{state} = 'DOCTYPE'; |
## TODO: What a stupid code this is! |
| 1436 |
|
$self->{state} = DOCTYPE_STATE; |
| 1437 |
!!!next-input-character; |
!!!next-input-character; |
| 1438 |
redo A; |
redo A; |
| 1439 |
|
} else { |
| 1440 |
|
!!!cp (130); |
| 1441 |
} |
} |
| 1442 |
|
} else { |
| 1443 |
|
!!!cp (131); |
| 1444 |
} |
} |
| 1445 |
|
} else { |
| 1446 |
|
!!!cp (132); |
| 1447 |
} |
} |
| 1448 |
|
} else { |
| 1449 |
|
!!!cp (133); |
| 1450 |
} |
} |
| 1451 |
|
} else { |
| 1452 |
|
!!!cp (134); |
| 1453 |
} |
} |
| 1454 |
|
} else { |
| 1455 |
|
!!!cp (135); |
| 1456 |
} |
} |
| 1457 |
|
} else { |
| 1458 |
|
!!!cp (136); |
| 1459 |
} |
} |
| 1460 |
|
|
| 1461 |
!!!parse-error (type => 'bogus comment'); |
!!!parse-error (type => 'bogus comment'); |
| 1462 |
$self->{next_input_character} = shift @next_char; |
$self->{next_char} = shift @next_char; |
| 1463 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 1464 |
$self->{state} = 'bogus comment'; |
$self->{state} = BOGUS_COMMENT_STATE; |
| 1465 |
redo A; |
redo A; |
| 1466 |
|
|
| 1467 |
## ISSUE: typos in spec: chacacters, is is a parse error |
## ISSUE: typos in spec: chacacters, is is a parse error |
| 1468 |
## ISSUE: spec is somewhat unclear on "is the first character that will be in the comment"; what is "that will be in the comment" is what the algorithm defines, isn't it? |
## ISSUE: spec is somewhat unclear on "is the first character that will be in the comment"; what is "that will be in the comment" is what the algorithm defines, isn't it? |
| 1469 |
} elsif ($self->{state} eq 'comment start') { |
} elsif ($self->{state} == COMMENT_START_STATE) { |
| 1470 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_char} == 0x002D) { # - |
| 1471 |
$self->{state} = 'comment start dash'; |
!!!cp (137); |
| 1472 |
|
$self->{state} = COMMENT_START_DASH_STATE; |
| 1473 |
!!!next-input-character; |
!!!next-input-character; |
| 1474 |
redo A; |
redo A; |
| 1475 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 1476 |
|
!!!cp (138); |
| 1477 |
!!!parse-error (type => 'bogus comment'); |
!!!parse-error (type => 'bogus comment'); |
| 1478 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1479 |
!!!next-input-character; |
!!!next-input-character; |
| 1480 |
|
|
| 1481 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1482 |
|
|
| 1483 |
redo A; |
redo A; |
| 1484 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1485 |
|
!!!cp (139); |
| 1486 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
| 1487 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1488 |
## reconsume |
## reconsume |
| 1489 |
|
|
| 1490 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1491 |
|
|
| 1492 |
redo A; |
redo A; |
| 1493 |
} else { |
} else { |
| 1494 |
|
!!!cp (140); |
| 1495 |
$self->{current_token}->{data} # comment |
$self->{current_token}->{data} # comment |
| 1496 |
.= chr ($self->{next_input_character}); |
.= chr ($self->{next_char}); |
| 1497 |
$self->{state} = 'comment'; |
$self->{state} = COMMENT_STATE; |
| 1498 |
!!!next-input-character; |
!!!next-input-character; |
| 1499 |
redo A; |
redo A; |
| 1500 |
} |
} |
| 1501 |
} elsif ($self->{state} eq 'comment start dash') { |
} elsif ($self->{state} == COMMENT_START_DASH_STATE) { |
| 1502 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_char} == 0x002D) { # - |
| 1503 |
$self->{state} = 'comment end'; |
!!!cp (141); |
| 1504 |
|
$self->{state} = COMMENT_END_STATE; |
| 1505 |
!!!next-input-character; |
!!!next-input-character; |
| 1506 |
redo A; |
redo A; |
| 1507 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 1508 |
|
!!!cp (142); |
| 1509 |
!!!parse-error (type => 'bogus comment'); |
!!!parse-error (type => 'bogus comment'); |
| 1510 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1511 |
!!!next-input-character; |
!!!next-input-character; |
| 1512 |
|
|
| 1513 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1514 |
|
|
| 1515 |
redo A; |
redo A; |
| 1516 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1517 |
|
!!!cp (143); |
| 1518 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
| 1519 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1520 |
## reconsume |
## reconsume |
| 1521 |
|
|
| 1522 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1523 |
|
|
| 1524 |
redo A; |
redo A; |
| 1525 |
} else { |
} else { |
| 1526 |
|
!!!cp (144); |
| 1527 |
$self->{current_token}->{data} # comment |
$self->{current_token}->{data} # comment |
| 1528 |
.= '-' . chr ($self->{next_input_character}); |
.= '-' . chr ($self->{next_char}); |
| 1529 |
$self->{state} = 'comment'; |
$self->{state} = COMMENT_STATE; |
| 1530 |
!!!next-input-character; |
!!!next-input-character; |
| 1531 |
redo A; |
redo A; |
| 1532 |
} |
} |
| 1533 |
} elsif ($self->{state} eq 'comment') { |
} elsif ($self->{state} == COMMENT_STATE) { |
| 1534 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_char} == 0x002D) { # - |
| 1535 |
$self->{state} = 'comment end dash'; |
!!!cp (145); |
| 1536 |
|
$self->{state} = COMMENT_END_DASH_STATE; |
| 1537 |
!!!next-input-character; |
!!!next-input-character; |
| 1538 |
redo A; |
redo A; |
| 1539 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1540 |
|
!!!cp (146); |
| 1541 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
| 1542 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1543 |
## reconsume |
## reconsume |
| 1544 |
|
|
| 1545 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1546 |
|
|
| 1547 |
redo A; |
redo A; |
| 1548 |
} else { |
} else { |
| 1549 |
$self->{current_token}->{data} .= chr ($self->{next_input_character}); # comment |
!!!cp (147); |
| 1550 |
|
$self->{current_token}->{data} .= chr ($self->{next_char}); # comment |
| 1551 |
## Stay in the state |
## Stay in the state |
| 1552 |
!!!next-input-character; |
!!!next-input-character; |
| 1553 |
redo A; |
redo A; |
| 1554 |
} |
} |
| 1555 |
} elsif ($self->{state} eq 'comment end dash') { |
} elsif ($self->{state} == COMMENT_END_DASH_STATE) { |
| 1556 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_char} == 0x002D) { # - |
| 1557 |
$self->{state} = 'comment end'; |
!!!cp (148); |
| 1558 |
|
$self->{state} = COMMENT_END_STATE; |
| 1559 |
!!!next-input-character; |
!!!next-input-character; |
| 1560 |
redo A; |
redo A; |
| 1561 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1562 |
|
!!!cp (149); |
| 1563 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
| 1564 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1565 |
## reconsume |
## reconsume |
| 1566 |
|
|
| 1567 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1568 |
|
|
| 1569 |
redo A; |
redo A; |
| 1570 |
} else { |
} else { |
| 1571 |
$self->{current_token}->{data} .= '-' . chr ($self->{next_input_character}); # comment |
!!!cp (150); |
| 1572 |
$self->{state} = 'comment'; |
$self->{current_token}->{data} .= '-' . chr ($self->{next_char}); # comment |
| 1573 |
|
$self->{state} = COMMENT_STATE; |
| 1574 |
!!!next-input-character; |
!!!next-input-character; |
| 1575 |
redo A; |
redo A; |
| 1576 |
} |
} |
| 1577 |
} elsif ($self->{state} eq 'comment end') { |
} elsif ($self->{state} == COMMENT_END_STATE) { |
| 1578 |
if ($self->{next_input_character} == 0x003E) { # > |
if ($self->{next_char} == 0x003E) { # > |
| 1579 |
$self->{state} = 'data'; |
!!!cp (151); |
| 1580 |
|
$self->{state} = DATA_STATE; |
| 1581 |
!!!next-input-character; |
!!!next-input-character; |
| 1582 |
|
|
| 1583 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1584 |
|
|
| 1585 |
redo A; |
redo A; |
| 1586 |
} elsif ($self->{next_input_character} == 0x002D) { # - |
} elsif ($self->{next_char} == 0x002D) { # - |
| 1587 |
|
!!!cp (152); |
| 1588 |
!!!parse-error (type => 'dash in comment'); |
!!!parse-error (type => 'dash in comment'); |
| 1589 |
$self->{current_token}->{data} .= '-'; # comment |
$self->{current_token}->{data} .= '-'; # comment |
| 1590 |
## Stay in the state |
## Stay in the state |
| 1591 |
!!!next-input-character; |
!!!next-input-character; |
| 1592 |
redo A; |
redo A; |
| 1593 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1594 |
|
!!!cp (153); |
| 1595 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
| 1596 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1597 |
## reconsume |
## reconsume |
| 1598 |
|
|
| 1599 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1600 |
|
|
| 1601 |
redo A; |
redo A; |
| 1602 |
} else { |
} else { |
| 1603 |
|
!!!cp (154); |
| 1604 |
!!!parse-error (type => 'dash in comment'); |
!!!parse-error (type => 'dash in comment'); |
| 1605 |
$self->{current_token}->{data} .= '--' . chr ($self->{next_input_character}); # comment |
$self->{current_token}->{data} .= '--' . chr ($self->{next_char}); # comment |
| 1606 |
$self->{state} = 'comment'; |
$self->{state} = COMMENT_STATE; |
| 1607 |
!!!next-input-character; |
!!!next-input-character; |
| 1608 |
redo A; |
redo A; |
| 1609 |
} |
} |
| 1610 |
} elsif ($self->{state} eq 'DOCTYPE') { |
} elsif ($self->{state} == DOCTYPE_STATE) { |
| 1611 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_char} == 0x0009 or # HT |
| 1612 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_char} == 0x000A or # LF |
| 1613 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_char} == 0x000B or # VT |
| 1614 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_char} == 0x000C or # FF |
| 1615 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_char} == 0x0020) { # SP |
| 1616 |
$self->{state} = 'before DOCTYPE name'; |
!!!cp (155); |
| 1617 |
|
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
| 1618 |
!!!next-input-character; |
!!!next-input-character; |
| 1619 |
redo A; |
redo A; |
| 1620 |
} else { |
} else { |
| 1621 |
|
!!!cp (156); |
| 1622 |
!!!parse-error (type => 'no space before DOCTYPE name'); |
!!!parse-error (type => 'no space before DOCTYPE name'); |
| 1623 |
$self->{state} = 'before DOCTYPE name'; |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
| 1624 |
## reconsume |
## reconsume |
| 1625 |
redo A; |
redo A; |
| 1626 |
} |
} |
| 1627 |
} elsif ($self->{state} eq 'before DOCTYPE name') { |
} elsif ($self->{state} == BEFORE_DOCTYPE_NAME_STATE) { |
| 1628 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_char} == 0x0009 or # HT |
| 1629 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_char} == 0x000A or # LF |
| 1630 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_char} == 0x000B or # VT |
| 1631 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_char} == 0x000C or # FF |
| 1632 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_char} == 0x0020) { # SP |
| 1633 |
|
!!!cp (157); |
| 1634 |
## Stay in the state |
## Stay in the state |
| 1635 |
!!!next-input-character; |
!!!next-input-character; |
| 1636 |
redo A; |
redo A; |
| 1637 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 1638 |
|
!!!cp (158); |
| 1639 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
| 1640 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1641 |
!!!next-input-character; |
!!!next-input-character; |
| 1642 |
|
|
| 1643 |
!!!emit ({type => DOCTYPE_TOKEN}); # incorrect |
!!!emit ({type => DOCTYPE_TOKEN, quirks => 1}); |
| 1644 |
|
|
| 1645 |
redo A; |
redo A; |
| 1646 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1647 |
|
!!!cp (159); |
| 1648 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
| 1649 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1650 |
## reconsume |
## reconsume |
| 1651 |
|
|
| 1652 |
!!!emit ({type => DOCTYPE_TOKEN}); # incorrect |
!!!emit ({type => DOCTYPE_TOKEN, quirks => 1}); |
| 1653 |
|
|
| 1654 |
redo A; |
redo A; |
| 1655 |
} else { |
} else { |
| 1656 |
|
!!!cp (160); |
| 1657 |
$self->{current_token} |
$self->{current_token} |
| 1658 |
= {type => DOCTYPE_TOKEN, |
= {type => DOCTYPE_TOKEN, |
| 1659 |
name => chr ($self->{next_input_character}), |
name => chr ($self->{next_char}), |
| 1660 |
correct => 1}; |
#quirks => 0, |
| 1661 |
|
}; |
| 1662 |
## ISSUE: "Set the token's name name to the" in the spec |
## ISSUE: "Set the token's name name to the" in the spec |
| 1663 |
$self->{state} = 'DOCTYPE name'; |
$self->{state} = DOCTYPE_NAME_STATE; |
| 1664 |
!!!next-input-character; |
!!!next-input-character; |
| 1665 |
redo A; |
redo A; |
| 1666 |
} |
} |
| 1667 |
} elsif ($self->{state} eq 'DOCTYPE name') { |
} elsif ($self->{state} == DOCTYPE_NAME_STATE) { |
| 1668 |
## ISSUE: Redundant "First," in the spec. |
## ISSUE: Redundant "First," in the spec. |
| 1669 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_char} == 0x0009 or # HT |
| 1670 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_char} == 0x000A or # LF |
| 1671 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_char} == 0x000B or # VT |
| 1672 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_char} == 0x000C or # FF |
| 1673 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_char} == 0x0020) { # SP |
| 1674 |
$self->{state} = 'after DOCTYPE name'; |
!!!cp (161); |
| 1675 |
|
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
| 1676 |
!!!next-input-character; |
!!!next-input-character; |
| 1677 |
redo A; |
redo A; |
| 1678 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 1679 |
$self->{state} = 'data'; |
!!!cp (162); |
| 1680 |
|
$self->{state} = DATA_STATE; |
| 1681 |
!!!next-input-character; |
!!!next-input-character; |
| 1682 |
|
|
| 1683 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1684 |
|
|
| 1685 |
redo A; |
redo A; |
| 1686 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1687 |
|
!!!cp (163); |
| 1688 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1689 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1690 |
## reconsume |
## reconsume |
| 1691 |
|
|
| 1692 |
delete $self->{current_token}->{correct}; |
$self->{current_token}->{quirks} = 1; |
| 1693 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1694 |
|
|
| 1695 |
redo A; |
redo A; |
| 1696 |
} else { |
} else { |
| 1697 |
|
!!!cp (164); |
| 1698 |
$self->{current_token}->{name} |
$self->{current_token}->{name} |
| 1699 |
.= chr ($self->{next_input_character}); # DOCTYPE |
.= chr ($self->{next_char}); # DOCTYPE |
| 1700 |
## Stay in the state |
## Stay in the state |
| 1701 |
!!!next-input-character; |
!!!next-input-character; |
| 1702 |
redo A; |
redo A; |
| 1703 |
} |
} |
| 1704 |
} elsif ($self->{state} eq 'after DOCTYPE name') { |
} elsif ($self->{state} == AFTER_DOCTYPE_NAME_STATE) { |
| 1705 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_char} == 0x0009 or # HT |
| 1706 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_char} == 0x000A or # LF |
| 1707 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_char} == 0x000B or # VT |
| 1708 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_char} == 0x000C or # FF |
| 1709 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_char} == 0x0020) { # SP |
| 1710 |
|
!!!cp (165); |
| 1711 |
## Stay in the state |
## Stay in the state |
| 1712 |
!!!next-input-character; |
!!!next-input-character; |
| 1713 |
redo A; |
redo A; |
| 1714 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 1715 |
$self->{state} = 'data'; |
!!!cp (166); |
| 1716 |
|
$self->{state} = DATA_STATE; |
| 1717 |
!!!next-input-character; |
!!!next-input-character; |
| 1718 |
|
|
| 1719 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1720 |
|
|
| 1721 |
redo A; |
redo A; |
| 1722 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1723 |
|
!!!cp (167); |
| 1724 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1725 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1726 |
## reconsume |
## reconsume |
| 1727 |
|
|
| 1728 |
delete $self->{current_token}->{correct}; |
$self->{current_token}->{quirks} = 1; |
| 1729 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1730 |
|
|
| 1731 |
redo A; |
redo A; |
| 1732 |
} elsif ($self->{next_input_character} == 0x0050 or # P |
} elsif ($self->{next_char} == 0x0050 or # P |
| 1733 |
$self->{next_input_character} == 0x0070) { # p |
$self->{next_char} == 0x0070) { # p |
| 1734 |
!!!next-input-character; |
!!!next-input-character; |
| 1735 |
if ($self->{next_input_character} == 0x0055 or # U |
if ($self->{next_char} == 0x0055 or # U |
| 1736 |
$self->{next_input_character} == 0x0075) { # u |
$self->{next_char} == 0x0075) { # u |
| 1737 |
!!!next-input-character; |
!!!next-input-character; |
| 1738 |
if ($self->{next_input_character} == 0x0042 or # B |
if ($self->{next_char} == 0x0042 or # B |
| 1739 |
$self->{next_input_character} == 0x0062) { # b |
$self->{next_char} == 0x0062) { # b |
| 1740 |
!!!next-input-character; |
!!!next-input-character; |
| 1741 |
if ($self->{next_input_character} == 0x004C or # L |
if ($self->{next_char} == 0x004C or # L |
| 1742 |
$self->{next_input_character} == 0x006C) { # l |
$self->{next_char} == 0x006C) { # l |
| 1743 |
!!!next-input-character; |
!!!next-input-character; |
| 1744 |
if ($self->{next_input_character} == 0x0049 or # I |
if ($self->{next_char} == 0x0049 or # I |
| 1745 |
$self->{next_input_character} == 0x0069) { # i |
$self->{next_char} == 0x0069) { # i |
| 1746 |
!!!next-input-character; |
!!!next-input-character; |
| 1747 |
if ($self->{next_input_character} == 0x0043 or # C |
if ($self->{next_char} == 0x0043 or # C |
| 1748 |
$self->{next_input_character} == 0x0063) { # c |
$self->{next_char} == 0x0063) { # c |
| 1749 |
$self->{state} = 'before DOCTYPE public identifier'; |
!!!cp (168); |
| 1750 |
|
$self->{state} = BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
| 1751 |
!!!next-input-character; |
!!!next-input-character; |
| 1752 |
redo A; |
redo A; |
| 1753 |
|
} else { |
| 1754 |
|
!!!cp (169); |
| 1755 |
} |
} |
| 1756 |
|
} else { |
| 1757 |
|
!!!cp (170); |
| 1758 |
} |
} |
| 1759 |
|
} else { |
| 1760 |
|
!!!cp (171); |
| 1761 |
} |
} |
| 1762 |
|
} else { |
| 1763 |
|
!!!cp (172); |
| 1764 |
} |
} |
| 1765 |
|
} else { |
| 1766 |
|
!!!cp (173); |
| 1767 |
} |
} |
| 1768 |
|
|
| 1769 |
# |
# |
| 1770 |
} elsif ($self->{next_input_character} == 0x0053 or # S |
} elsif ($self->{next_char} == 0x0053 or # S |
| 1771 |
$self->{next_input_character} == 0x0073) { # s |
$self->{next_char} == 0x0073) { # s |
| 1772 |
!!!next-input-character; |
!!!next-input-character; |
| 1773 |
if ($self->{next_input_character} == 0x0059 or # Y |
if ($self->{next_char} == 0x0059 or # Y |
| 1774 |
$self->{next_input_character} == 0x0079) { # y |
$self->{next_char} == 0x0079) { # y |
| 1775 |
!!!next-input-character; |
!!!next-input-character; |
| 1776 |
if ($self->{next_input_character} == 0x0053 or # S |
if ($self->{next_char} == 0x0053 or # S |
| 1777 |
$self->{next_input_character} == 0x0073) { # s |
$self->{next_char} == 0x0073) { # s |
| 1778 |
!!!next-input-character; |
!!!next-input-character; |
| 1779 |
if ($self->{next_input_character} == 0x0054 or # T |
if ($self->{next_char} == 0x0054 or # T |
| 1780 |
$self->{next_input_character} == 0x0074) { # t |
$self->{next_char} == 0x0074) { # t |
| 1781 |
!!!next-input-character; |
!!!next-input-character; |
| 1782 |
if ($self->{next_input_character} == 0x0045 or # E |
if ($self->{next_char} == 0x0045 or # E |
| 1783 |
$self->{next_input_character} == 0x0065) { # e |
$self->{next_char} == 0x0065) { # e |
| 1784 |
!!!next-input-character; |
!!!next-input-character; |
| 1785 |
if ($self->{next_input_character} == 0x004D or # M |
if ($self->{next_char} == 0x004D or # M |
| 1786 |
$self->{next_input_character} == 0x006D) { # m |
$self->{next_char} == 0x006D) { # m |
| 1787 |
$self->{state} = 'before DOCTYPE system identifier'; |
!!!cp (174); |
| 1788 |
|
$self->{state} = BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
| 1789 |
!!!next-input-character; |
!!!next-input-character; |
| 1790 |
redo A; |
redo A; |
| 1791 |
|
} else { |
| 1792 |
|
!!!cp (175); |
| 1793 |
} |
} |
| 1794 |
|
} else { |
| 1795 |
|
!!!cp (176); |
| 1796 |
} |
} |
| 1797 |
|
} else { |
| 1798 |
|
!!!cp (177); |
| 1799 |
} |
} |
| 1800 |
|
} else { |
| 1801 |
|
!!!cp (178); |
| 1802 |
} |
} |
| 1803 |
|
} else { |
| 1804 |
|
!!!cp (179); |
| 1805 |
} |
} |
| 1806 |
|
|
| 1807 |
# |
# |
| 1808 |
} else { |
} else { |
| 1809 |
|
!!!cp (180); |
| 1810 |
!!!next-input-character; |
!!!next-input-character; |
| 1811 |
# |
# |
| 1812 |
} |
} |
| 1813 |
|
|
| 1814 |
!!!parse-error (type => 'string after DOCTYPE name'); |
!!!parse-error (type => 'string after DOCTYPE name'); |
| 1815 |
$self->{state} = 'bogus DOCTYPE'; |
$self->{current_token}->{quirks} = 1; |
| 1816 |
|
|
| 1817 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
| 1818 |
# next-input-character is already done |
# next-input-character is already done |
| 1819 |
redo A; |
redo A; |
| 1820 |
} elsif ($self->{state} eq 'before DOCTYPE public identifier') { |
} elsif ($self->{state} == BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE) { |
| 1821 |
if ({ |
if ({ |
| 1822 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
| 1823 |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
| 1824 |
}->{$self->{next_input_character}}) { |
}->{$self->{next_char}}) { |
| 1825 |
|
!!!cp (181); |
| 1826 |
## Stay in the state |
## Stay in the state |
| 1827 |
!!!next-input-character; |
!!!next-input-character; |
| 1828 |
redo A; |
redo A; |
| 1829 |
} elsif ($self->{next_input_character} eq 0x0022) { # " |
} elsif ($self->{next_char} eq 0x0022) { # " |
| 1830 |
|
!!!cp (182); |
| 1831 |
$self->{current_token}->{public_identifier} = ''; # DOCTYPE |
$self->{current_token}->{public_identifier} = ''; # DOCTYPE |
| 1832 |
$self->{state} = 'DOCTYPE public identifier (double-quoted)'; |
$self->{state} = DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE; |
| 1833 |
!!!next-input-character; |
!!!next-input-character; |
| 1834 |
redo A; |
redo A; |
| 1835 |
} elsif ($self->{next_input_character} eq 0x0027) { # ' |
} elsif ($self->{next_char} eq 0x0027) { # ' |
| 1836 |
|
!!!cp (183); |
| 1837 |
$self->{current_token}->{public_identifier} = ''; # DOCTYPE |
$self->{current_token}->{public_identifier} = ''; # DOCTYPE |
| 1838 |
$self->{state} = 'DOCTYPE public identifier (single-quoted)'; |
$self->{state} = DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE; |
| 1839 |
!!!next-input-character; |
!!!next-input-character; |
| 1840 |
redo A; |
redo A; |
| 1841 |
} elsif ($self->{next_input_character} eq 0x003E) { # > |
} elsif ($self->{next_char} eq 0x003E) { # > |
| 1842 |
|
!!!cp (184); |
| 1843 |
!!!parse-error (type => 'no PUBLIC literal'); |
!!!parse-error (type => 'no PUBLIC literal'); |
| 1844 |
|
|
| 1845 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1846 |
!!!next-input-character; |
!!!next-input-character; |
| 1847 |
|
|
| 1848 |
delete $self->{current_token}->{correct}; |
$self->{current_token}->{quirks} = 1; |
| 1849 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1850 |
|
|
| 1851 |
redo A; |
redo A; |
| 1852 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1853 |
|
!!!cp (185); |
| 1854 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1855 |
|
|
| 1856 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1857 |
## reconsume |
## reconsume |
| 1858 |
|
|
| 1859 |
delete $self->{current_token}->{correct}; |
$self->{current_token}->{quirks} = 1; |
| 1860 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1861 |
|
|
| 1862 |
redo A; |
redo A; |
| 1863 |
} else { |
} else { |
| 1864 |
|
!!!cp (186); |
| 1865 |
!!!parse-error (type => 'string after PUBLIC'); |
!!!parse-error (type => 'string after PUBLIC'); |
| 1866 |
$self->{state} = 'bogus DOCTYPE'; |
$self->{current_token}->{quirks} = 1; |
| 1867 |
|
|
| 1868 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
| 1869 |
!!!next-input-character; |
!!!next-input-character; |
| 1870 |
redo A; |
redo A; |
| 1871 |
} |
} |
| 1872 |
} elsif ($self->{state} eq 'DOCTYPE public identifier (double-quoted)') { |
} elsif ($self->{state} == DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE) { |
| 1873 |
if ($self->{next_input_character} == 0x0022) { # " |
if ($self->{next_char} == 0x0022) { # " |
| 1874 |
$self->{state} = 'after DOCTYPE public identifier'; |
!!!cp (187); |
| 1875 |
|
$self->{state} = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
| 1876 |
!!!next-input-character; |
!!!next-input-character; |
| 1877 |
redo A; |
redo A; |
| 1878 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == 0x003E) { # > |
| 1879 |
|
!!!cp (188); |
| 1880 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 1881 |
|
|
| 1882 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1883 |
|
!!!next-input-character; |
| 1884 |
|
|
| 1885 |
|
$self->{current_token}->{quirks} = 1; |
| 1886 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1887 |
|
|
| 1888 |
|
redo A; |
| 1889 |
|
} elsif ($self->{next_char} == -1) { |
| 1890 |
|
!!!cp (189); |
| 1891 |
|
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 1892 |
|
|
| 1893 |
|
$self->{state} = DATA_STATE; |
| 1894 |
## reconsume |
## reconsume |
| 1895 |
|
|
| 1896 |
delete $self->{current_token}->{correct}; |
$self->{current_token}->{quirks} = 1; |
| 1897 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1898 |
|
|
| 1899 |
redo A; |
redo A; |
| 1900 |
} else { |
} else { |
| 1901 |
|
!!!cp (190); |
| 1902 |
$self->{current_token}->{public_identifier} # DOCTYPE |
$self->{current_token}->{public_identifier} # DOCTYPE |
| 1903 |
.= chr $self->{next_input_character}; |
.= chr $self->{next_char}; |
| 1904 |
## Stay in the state |
## Stay in the state |
| 1905 |
!!!next-input-character; |
!!!next-input-character; |
| 1906 |
redo A; |
redo A; |
| 1907 |
} |
} |
| 1908 |
} elsif ($self->{state} eq 'DOCTYPE public identifier (single-quoted)') { |
} elsif ($self->{state} == DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE) { |
| 1909 |
if ($self->{next_input_character} == 0x0027) { # ' |
if ($self->{next_char} == 0x0027) { # ' |
| 1910 |
$self->{state} = 'after DOCTYPE public identifier'; |
!!!cp (191); |
| 1911 |
|
$self->{state} = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
| 1912 |
|
!!!next-input-character; |
| 1913 |
|
redo A; |
| 1914 |
|
} elsif ($self->{next_char} == 0x003E) { # > |
| 1915 |
|
!!!cp (192); |
| 1916 |
|
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 1917 |
|
|
| 1918 |
|
$self->{state} = DATA_STATE; |
| 1919 |
!!!next-input-character; |
!!!next-input-character; |
| 1920 |
|
|
| 1921 |
|
$self->{current_token}->{quirks} = 1; |
| 1922 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1923 |
|
|
| 1924 |
redo A; |
redo A; |
| 1925 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1926 |
|
!!!cp (193); |
| 1927 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 1928 |
|
|
| 1929 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1930 |
## reconsume |
## reconsume |
| 1931 |
|
|
| 1932 |
delete $self->{current_token}->{correct}; |
$self->{current_token}->{quirks} = 1; |
| 1933 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1934 |
|
|
| 1935 |
redo A; |
redo A; |
| 1936 |
} else { |
} else { |
| 1937 |
|
!!!cp (194); |
| 1938 |
$self->{current_token}->{public_identifier} # DOCTYPE |
$self->{current_token}->{public_identifier} # DOCTYPE |
| 1939 |
.= chr $self->{next_input_character}; |
.= chr $self->{next_char}; |
| 1940 |
## Stay in the state |
## Stay in the state |
| 1941 |
!!!next-input-character; |
!!!next-input-character; |
| 1942 |
redo A; |
redo A; |
| 1943 |
} |
} |
| 1944 |
} elsif ($self->{state} eq 'after DOCTYPE public identifier') { |
} elsif ($self->{state} == AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE) { |
| 1945 |
if ({ |
if ({ |
| 1946 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
| 1947 |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
| 1948 |
}->{$self->{next_input_character}}) { |
}->{$self->{next_char}}) { |
| 1949 |
|
!!!cp (195); |
| 1950 |
## Stay in the state |
## Stay in the state |
| 1951 |
!!!next-input-character; |
!!!next-input-character; |
| 1952 |
redo A; |
redo A; |
| 1953 |
} elsif ($self->{next_input_character} == 0x0022) { # " |
} elsif ($self->{next_char} == 0x0022) { # " |
| 1954 |
|
!!!cp (196); |
| 1955 |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
| 1956 |
$self->{state} = 'DOCTYPE system identifier (double-quoted)'; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; |
| 1957 |
!!!next-input-character; |
!!!next-input-character; |
| 1958 |
redo A; |
redo A; |
| 1959 |
} elsif ($self->{next_input_character} == 0x0027) { # ' |
} elsif ($self->{next_char} == 0x0027) { # ' |
| 1960 |
|
!!!cp (197); |
| 1961 |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
| 1962 |
$self->{state} = 'DOCTYPE system identifier (single-quoted)'; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; |
| 1963 |
!!!next-input-character; |
!!!next-input-character; |
| 1964 |
redo A; |
redo A; |
| 1965 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 1966 |
$self->{state} = 'data'; |
!!!cp (198); |
| 1967 |
|
$self->{state} = DATA_STATE; |
| 1968 |
!!!next-input-character; |
!!!next-input-character; |
| 1969 |
|
|
| 1970 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1971 |
|
|
| 1972 |
redo A; |
redo A; |
| 1973 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1974 |
|
!!!cp (199); |
| 1975 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1976 |
|
|
| 1977 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1978 |
## reconsume |
## reconsume |
| 1979 |
|
|
| 1980 |
delete $self->{current_token}->{correct}; |
$self->{current_token}->{quirks} = 1; |
| 1981 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1982 |
|
|
| 1983 |
redo A; |
redo A; |
| 1984 |
} else { |
} else { |
| 1985 |
|
!!!cp (200); |
| 1986 |
!!!parse-error (type => 'string after PUBLIC literal'); |
!!!parse-error (type => 'string after PUBLIC literal'); |
| 1987 |
$self->{state} = 'bogus DOCTYPE'; |
$self->{current_token}->{quirks} = 1; |
| 1988 |
|
|
| 1989 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
| 1990 |
!!!next-input-character; |
!!!next-input-character; |
| 1991 |
redo A; |
redo A; |
| 1992 |
} |
} |
| 1993 |
} elsif ($self->{state} eq 'before DOCTYPE system identifier') { |
} elsif ($self->{state} == BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE) { |
| 1994 |
if ({ |
if ({ |
| 1995 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
| 1996 |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
| 1997 |
}->{$self->{next_input_character}}) { |
}->{$self->{next_char}}) { |
| 1998 |
|
!!!cp (201); |
| 1999 |
## Stay in the state |
## Stay in the state |
| 2000 |
!!!next-input-character; |
!!!next-input-character; |
| 2001 |
redo A; |
redo A; |
| 2002 |
} elsif ($self->{next_input_character} == 0x0022) { # " |
} elsif ($self->{next_char} == 0x0022) { # " |
| 2003 |
|
!!!cp (202); |
| 2004 |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
| 2005 |
$self->{state} = 'DOCTYPE system identifier (double-quoted)'; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; |
| 2006 |
!!!next-input-character; |
!!!next-input-character; |
| 2007 |
redo A; |
redo A; |
| 2008 |
} elsif ($self->{next_input_character} == 0x0027) { # ' |
} elsif ($self->{next_char} == 0x0027) { # ' |
| 2009 |
|
!!!cp (203); |
| 2010 |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
| 2011 |
$self->{state} = 'DOCTYPE system identifier (single-quoted)'; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; |
| 2012 |
!!!next-input-character; |
!!!next-input-character; |
| 2013 |
redo A; |
redo A; |
| 2014 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 2015 |
|
!!!cp (204); |
| 2016 |
!!!parse-error (type => 'no SYSTEM literal'); |
!!!parse-error (type => 'no SYSTEM literal'); |
| 2017 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 2018 |
!!!next-input-character; |
!!!next-input-character; |
| 2019 |
|
|
| 2020 |
delete $self->{current_token}->{correct}; |
$self->{current_token}->{quirks} = 1; |
| 2021 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 2022 |
|
|
| 2023 |
redo A; |
redo A; |
| 2024 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 2025 |
|
!!!cp (205); |
| 2026 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 2027 |
|
|
| 2028 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 2029 |
## reconsume |
## reconsume |
| 2030 |
|
|
| 2031 |
delete $self->{current_token}->{correct}; |
$self->{current_token}->{quirks} = 1; |
| 2032 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 2033 |
|
|
| 2034 |
redo A; |
redo A; |
| 2035 |
} else { |
} else { |
| 2036 |
|
!!!cp (206); |
| 2037 |
!!!parse-error (type => 'string after SYSTEM'); |
!!!parse-error (type => 'string after SYSTEM'); |
| 2038 |
$self->{state} = 'bogus DOCTYPE'; |
$self->{current_token}->{quirks} = 1; |
| 2039 |
|
|
| 2040 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
| 2041 |
!!!next-input-character; |
!!!next-input-character; |
| 2042 |
redo A; |
redo A; |
| 2043 |
} |
} |
| 2044 |
} elsif ($self->{state} eq 'DOCTYPE system identifier (double-quoted)') { |
} elsif ($self->{state} == DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE) { |
| 2045 |
if ($self->{next_input_character} == 0x0022) { # " |
if ($self->{next_char} == 0x0022) { # " |
| 2046 |
$self->{state} = 'after DOCTYPE system identifier'; |
!!!cp (207); |
| 2047 |
|
$self->{state} = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
| 2048 |
|
!!!next-input-character; |
| 2049 |
|
redo A; |
| 2050 |
|
} elsif ($self->{next_char} == 0x003E) { # > |
| 2051 |
|
!!!cp (208); |
| 2052 |
|
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 2053 |
|
|
| 2054 |
|
$self->{state} = DATA_STATE; |
| 2055 |
!!!next-input-character; |
!!!next-input-character; |
| 2056 |
|
|
| 2057 |
|
$self->{current_token}->{quirks} = 1; |
| 2058 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 2059 |
|
|
| 2060 |
redo A; |
redo A; |
| 2061 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 2062 |
|
!!!cp (209); |
| 2063 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
| 2064 |
|
|
| 2065 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 2066 |
## reconsume |
## reconsume |
| 2067 |
|
|
| 2068 |
delete $self->{current_token}->{correct}; |
$self->{current_token}->{quirks} = 1; |
| 2069 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 2070 |
|
|
| 2071 |
redo A; |
redo A; |
| 2072 |
} else { |
} else { |
| 2073 |
|
!!!cp (210); |
| 2074 |
$self->{current_token}->{system_identifier} # DOCTYPE |
$self->{current_token}->{system_identifier} # DOCTYPE |
| 2075 |
.= chr $self->{next_input_character}; |
.= chr $self->{next_char}; |
| 2076 |
## Stay in the state |
## Stay in the state |
| 2077 |
!!!next-input-character; |
!!!next-input-character; |
| 2078 |
redo A; |
redo A; |
| 2079 |
} |
} |
| 2080 |
} elsif ($self->{state} eq 'DOCTYPE system identifier (single-quoted)') { |
} elsif ($self->{state} == DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE) { |
| 2081 |
if ($self->{next_input_character} == 0x0027) { # ' |
if ($self->{next_char} == 0x0027) { # ' |
| 2082 |
$self->{state} = 'after DOCTYPE system identifier'; |
!!!cp (211); |
| 2083 |
|
$self->{state} = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
| 2084 |
!!!next-input-character; |
!!!next-input-character; |
| 2085 |
redo A; |
redo A; |
| 2086 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == 0x003E) { # > |
| 2087 |
|
!!!cp (212); |
| 2088 |
|
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 2089 |
|
|
| 2090 |
|
$self->{state} = DATA_STATE; |
| 2091 |
|
!!!next-input-character; |
| 2092 |
|
|
| 2093 |
|
$self->{current_token}->{quirks} = 1; |
| 2094 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 2095 |
|
|
| 2096 |
|
redo A; |
| 2097 |
|
} elsif ($self->{next_char} == -1) { |
| 2098 |
|
!!!cp (213); |
| 2099 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
| 2100 |
|
|
| 2101 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 2102 |
## reconsume |
## reconsume |
| 2103 |
|
|
| 2104 |
delete $self->{current_token}->{correct}; |
$self->{current_token}->{quirks} = 1; |
| 2105 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 2106 |
|
|
| 2107 |
redo A; |
redo A; |
| 2108 |
} else { |
} else { |
| 2109 |
|
!!!cp (214); |
| 2110 |
$self->{current_token}->{system_identifier} # DOCTYPE |
$self->{current_token}->{system_identifier} # DOCTYPE |
| 2111 |
.= chr $self->{next_input_character}; |
.= chr $self->{next_char}; |
| 2112 |
## Stay in the state |
## Stay in the state |
| 2113 |
!!!next-input-character; |
!!!next-input-character; |
| 2114 |
redo A; |
redo A; |
| 2115 |
} |
} |
| 2116 |
} elsif ($self->{state} eq 'after DOCTYPE system identifier') { |
} elsif ($self->{state} == AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE) { |
| 2117 |
if ({ |
if ({ |
| 2118 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
| 2119 |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
| 2120 |
}->{$self->{next_input_character}}) { |
}->{$self->{next_char}}) { |
| 2121 |
|
!!!cp (215); |
| 2122 |
## Stay in the state |
## Stay in the state |
| 2123 |
!!!next-input-character; |
!!!next-input-character; |
| 2124 |
redo A; |
redo A; |
| 2125 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 2126 |
$self->{state} = 'data'; |
!!!cp (216); |
| 2127 |
|
$self->{state} = DATA_STATE; |
| 2128 |
!!!next-input-character; |
!!!next-input-character; |
| 2129 |
|
|
| 2130 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 2131 |
|
|
| 2132 |
redo A; |
redo A; |
| 2133 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 2134 |
|
!!!cp (217); |
| 2135 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 2136 |
|
|
| 2137 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 2138 |
## reconsume |
## reconsume |
| 2139 |
|
|
| 2140 |
delete $self->{current_token}->{correct}; |
$self->{current_token}->{quirks} = 1; |
| 2141 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 2142 |
|
|
| 2143 |
redo A; |
redo A; |
| 2144 |
} else { |
} else { |
| 2145 |
|
!!!cp (218); |
| 2146 |
!!!parse-error (type => 'string after SYSTEM literal'); |
!!!parse-error (type => 'string after SYSTEM literal'); |
| 2147 |
$self->{state} = 'bogus DOCTYPE'; |
#$self->{current_token}->{quirks} = 1; |
| 2148 |
|
|
| 2149 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
| 2150 |
!!!next-input-character; |
!!!next-input-character; |
| 2151 |
redo A; |
redo A; |
| 2152 |
} |
} |
| 2153 |
} elsif ($self->{state} eq 'bogus DOCTYPE') { |
} elsif ($self->{state} == BOGUS_DOCTYPE_STATE) { |
| 2154 |
if ($self->{next_input_character} == 0x003E) { # > |
if ($self->{next_char} == 0x003E) { # > |
| 2155 |
$self->{state} = 'data'; |
!!!cp (219); |
| 2156 |
|
$self->{state} = DATA_STATE; |
| 2157 |
!!!next-input-character; |
!!!next-input-character; |
| 2158 |
|
|
|
delete $self->{current_token}->{correct}; |
|
| 2159 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 2160 |
|
|
| 2161 |
redo A; |
redo A; |
| 2162 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 2163 |
|
!!!cp (220); |
| 2164 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 2165 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 2166 |
## reconsume |
## reconsume |
| 2167 |
|
|
|
delete $self->{current_token}->{correct}; |
|
| 2168 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 2169 |
|
|
| 2170 |
redo A; |
redo A; |
| 2171 |
} else { |
} else { |
| 2172 |
|
!!!cp (221); |
| 2173 |
## Stay in the state |
## Stay in the state |
| 2174 |
!!!next-input-character; |
!!!next-input-character; |
| 2175 |
redo A; |
redo A; |
| 2182 |
die "$0: _get_next_token: unexpected case"; |
die "$0: _get_next_token: unexpected case"; |
| 2183 |
} # _get_next_token |
} # _get_next_token |
| 2184 |
|
|
| 2185 |
sub _tokenize_attempt_to_consume_an_entity ($$) { |
sub _tokenize_attempt_to_consume_an_entity ($$$) { |
| 2186 |
my ($self, $in_attr) = @_; |
my ($self, $in_attr, $additional) = @_; |
| 2187 |
|
|
| 2188 |
if ({ |
if ({ |
| 2189 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF, |
| 2190 |
0x0020 => 1, 0x003C => 1, 0x0026 => 1, -1 => 1, # SP, <, & # 0x000D # CR |
0x0020 => 1, 0x003C => 1, 0x0026 => 1, -1 => 1, # SP, <, & # 0x000D # CR |
| 2191 |
}->{$self->{next_input_character}}) { |
$additional => 1, |
| 2192 |
|
}->{$self->{next_char}}) { |
| 2193 |
## Don't consume |
## Don't consume |
| 2194 |
## No error |
## No error |
| 2195 |
return undef; |
return undef; |
| 2196 |
} elsif ($self->{next_input_character} == 0x0023) { # # |
} elsif ($self->{next_char} == 0x0023) { # # |
| 2197 |
!!!next-input-character; |
!!!next-input-character; |
| 2198 |
if ($self->{next_input_character} == 0x0078 or # x |
if ($self->{next_char} == 0x0078 or # x |
| 2199 |
$self->{next_input_character} == 0x0058) { # X |
$self->{next_char} == 0x0058) { # X |
| 2200 |
my $code; |
my $code; |
| 2201 |
X: { |
X: { |
| 2202 |
my $x_char = $self->{next_input_character}; |
my $x_char = $self->{next_char}; |
| 2203 |
!!!next-input-character; |
!!!next-input-character; |
| 2204 |
if (0x0030 <= $self->{next_input_character} and |
if (0x0030 <= $self->{next_char} and |
| 2205 |
$self->{next_input_character} <= 0x0039) { # 0..9 |
$self->{next_char} <= 0x0039) { # 0..9 |
| 2206 |
$code ||= 0; |
$code ||= 0; |
| 2207 |
$code *= 0x10; |
$code *= 0x10; |
| 2208 |
$code += $self->{next_input_character} - 0x0030; |
$code += $self->{next_char} - 0x0030; |
| 2209 |
redo X; |
redo X; |
| 2210 |
} elsif (0x0061 <= $self->{next_input_character} and |
} elsif (0x0061 <= $self->{next_char} and |
| 2211 |
$self->{next_input_character} <= 0x0066) { # a..f |
$self->{next_char} <= 0x0066) { # a..f |
| 2212 |
$code ||= 0; |
$code ||= 0; |
| 2213 |
$code *= 0x10; |
$code *= 0x10; |
| 2214 |
$code += $self->{next_input_character} - 0x0060 + 9; |
$code += $self->{next_char} - 0x0060 + 9; |
| 2215 |
redo X; |
redo X; |
| 2216 |
} elsif (0x0041 <= $self->{next_input_character} and |
} elsif (0x0041 <= $self->{next_char} and |
| 2217 |
$self->{next_input_character} <= 0x0046) { # A..F |
$self->{next_char} <= 0x0046) { # A..F |
| 2218 |
$code ||= 0; |
$code ||= 0; |
| 2219 |
$code *= 0x10; |
$code *= 0x10; |
| 2220 |
$code += $self->{next_input_character} - 0x0040 + 9; |
$code += $self->{next_char} - 0x0040 + 9; |
| 2221 |
redo X; |
redo X; |
| 2222 |
} elsif (not defined $code) { # no hexadecimal digit |
} elsif (not defined $code) { # no hexadecimal digit |
| 2223 |
!!!parse-error (type => 'bare hcro'); |
!!!parse-error (type => 'bare hcro'); |
| 2224 |
!!!back-next-input-character ($x_char, $self->{next_input_character}); |
!!!back-next-input-character ($x_char, $self->{next_char}); |
| 2225 |
$self->{next_input_character} = 0x0023; # # |
$self->{next_char} = 0x0023; # # |
| 2226 |
return undef; |
return undef; |
| 2227 |
} elsif ($self->{next_input_character} == 0x003B) { # ; |
} elsif ($self->{next_char} == 0x003B) { # ; |
| 2228 |
!!!next-input-character; |
!!!next-input-character; |
| 2229 |
} else { |
} else { |
| 2230 |
!!!parse-error (type => 'no refc'); |
!!!parse-error (type => 'no refc'); |
| 2244 |
$code = $c1_entity_char->{$code}; |
$code = $c1_entity_char->{$code}; |
| 2245 |
} |
} |
| 2246 |
|
|
| 2247 |
return {type => CHARACTER_TOKEN, data => chr $code}; |
return {type => CHARACTER_TOKEN, data => chr $code, |
| 2248 |
|
has_reference => 1}; |
| 2249 |
} # X |
} # X |
| 2250 |
} elsif (0x0030 <= $self->{next_input_character} and |
} elsif (0x0030 <= $self->{next_char} and |
| 2251 |
$self->{next_input_character} <= 0x0039) { # 0..9 |
$self->{next_char} <= 0x0039) { # 0..9 |
| 2252 |
my $code = $self->{next_input_character} - 0x0030; |
my $code = $self->{next_char} - 0x0030; |
| 2253 |
!!!next-input-character; |
!!!next-input-character; |
| 2254 |
|
|
| 2255 |
while (0x0030 <= $self->{next_input_character} and |
while (0x0030 <= $self->{next_char} and |
| 2256 |
$self->{next_input_character} <= 0x0039) { # 0..9 |
$self->{next_char} <= 0x0039) { # 0..9 |
| 2257 |
$code *= 10; |
$code *= 10; |
| 2258 |
$code += $self->{next_input_character} - 0x0030; |
$code += $self->{next_char} - 0x0030; |
| 2259 |
|
|
| 2260 |
!!!next-input-character; |
!!!next-input-character; |
| 2261 |
} |
} |
| 2262 |
|
|
| 2263 |
if ($self->{next_input_character} == 0x003B) { # ; |
if ($self->{next_char} == 0x003B) { # ; |
| 2264 |
!!!next-input-character; |
!!!next-input-character; |
| 2265 |
} else { |
} else { |
| 2266 |
!!!parse-error (type => 'no refc'); |
!!!parse-error (type => 'no refc'); |
| 2280 |
$code = $c1_entity_char->{$code}; |
$code = $c1_entity_char->{$code}; |
| 2281 |
} |
} |
| 2282 |
|
|
| 2283 |
return {type => CHARACTER_TOKEN, data => chr $code}; |
return {type => CHARACTER_TOKEN, data => chr $code, has_reference => 1}; |
| 2284 |
} else { |
} else { |
| 2285 |
!!!parse-error (type => 'bare nero'); |
!!!parse-error (type => 'bare nero'); |
| 2286 |
!!!back-next-input-character ($self->{next_input_character}); |
!!!back-next-input-character ($self->{next_char}); |
| 2287 |
$self->{next_input_character} = 0x0023; # # |
$self->{next_char} = 0x0023; # # |
| 2288 |
return undef; |
return undef; |
| 2289 |
} |
} |
| 2290 |
} elsif ((0x0041 <= $self->{next_input_character} and |
} elsif ((0x0041 <= $self->{next_char} and |
| 2291 |
$self->{next_input_character} <= 0x005A) or |
$self->{next_char} <= 0x005A) or |
| 2292 |
(0x0061 <= $self->{next_input_character} and |
(0x0061 <= $self->{next_char} and |
| 2293 |
$self->{next_input_character} <= 0x007A)) { |
$self->{next_char} <= 0x007A)) { |
| 2294 |
my $entity_name = chr $self->{next_input_character}; |
my $entity_name = chr $self->{next_char}; |
| 2295 |
!!!next-input-character; |
!!!next-input-character; |
| 2296 |
|
|
| 2297 |
my $value = $entity_name; |
my $value = $entity_name; |
| 2301 |
|
|
| 2302 |
while (length $entity_name < 10 and |
while (length $entity_name < 10 and |
| 2303 |
## NOTE: Some number greater than the maximum length of entity name |
## NOTE: Some number greater than the maximum length of entity name |
| 2304 |
((0x0041 <= $self->{next_input_character} and # a |
((0x0041 <= $self->{next_char} and # a |
| 2305 |
$self->{next_input_character} <= 0x005A) or # x |
$self->{next_char} <= 0x005A) or # x |
| 2306 |
(0x0061 <= $self->{next_input_character} and # a |
(0x0061 <= $self->{next_char} and # a |
| 2307 |
$self->{next_input_character} <= 0x007A) or # z |
$self->{next_char} <= 0x007A) or # z |
| 2308 |
(0x0030 <= $self->{next_input_character} and # 0 |
(0x0030 <= $self->{next_char} and # 0 |
| 2309 |
$self->{next_input_character} <= 0x0039) or # 9 |
$self->{next_char} <= 0x0039) or # 9 |
| 2310 |
$self->{next_input_character} == 0x003B)) { # ; |
$self->{next_char} == 0x003B)) { # ; |
| 2311 |
$entity_name .= chr $self->{next_input_character}; |
$entity_name .= chr $self->{next_char}; |
| 2312 |
if (defined $EntityChar->{$entity_name}) { |
if (defined $EntityChar->{$entity_name}) { |
| 2313 |
if ($self->{next_input_character} == 0x003B) { # ; |
if ($self->{next_char} == 0x003B) { # ; |
| 2314 |
$value = $EntityChar->{$entity_name}; |
$value = $EntityChar->{$entity_name}; |
| 2315 |
$match = 1; |
$match = 1; |
| 2316 |
!!!next-input-character; |
!!!next-input-character; |
| 2321 |
!!!next-input-character; |
!!!next-input-character; |
| 2322 |
} |
} |
| 2323 |
} else { |
} else { |
| 2324 |
$value .= chr $self->{next_input_character}; |
$value .= chr $self->{next_char}; |
| 2325 |
$match *= 2; |
$match *= 2; |
| 2326 |
!!!next-input-character; |
!!!next-input-character; |
| 2327 |
} |
} |
| 2328 |
} |
} |
| 2329 |
|
|
| 2330 |
if ($match > 0) { |
if ($match > 0) { |
| 2331 |
return {type => CHARACTER_TOKEN, data => $value}; |
return {type => CHARACTER_TOKEN, data => $value, has_reference => 1}; |
| 2332 |
} elsif ($match < 0) { |
} elsif ($match < 0) { |
| 2333 |
!!!parse-error (type => 'no refc'); |
!!!parse-error (type => 'no refc'); |
| 2334 |
if ($in_attr and $match < -1) { |
if ($in_attr and $match < -1) { |
| 2335 |
return {type => CHARACTER_TOKEN, data => '&'.$entity_name}; |
return {type => CHARACTER_TOKEN, data => '&'.$entity_name}; |
| 2336 |
} else { |
} else { |
| 2337 |
return {type => CHARACTER_TOKEN, data => $value}; |
return {type => CHARACTER_TOKEN, data => $value, has_reference => 1}; |
| 2338 |
} |
} |
| 2339 |
} else { |
} else { |
| 2340 |
!!!parse-error (type => 'bare ero'); |
!!!parse-error (type => 'bare ero'); |
| 2341 |
## NOTE: No characters are consumed in the spec. |
## NOTE: "No characters are consumed" in the spec. |
| 2342 |
return {type => CHARACTER_TOKEN, data => '&'.$value}; |
return {type => CHARACTER_TOKEN, data => '&'.$value}; |
| 2343 |
} |
} |
| 2344 |
} else { |
} else { |
| 2421 |
## ISSUE: internalSubset = null?? |
## ISSUE: internalSubset = null?? |
| 2422 |
$self->{document}->append_child ($doctype); |
$self->{document}->append_child ($doctype); |
| 2423 |
|
|
| 2424 |
if (not $token->{correct} or $doctype_name ne 'HTML') { |
if ($token->{quirks} or $doctype_name ne 'HTML') { |
| 2425 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
| 2426 |
} elsif (defined $token->{public_identifier}) { |
} elsif (defined $token->{public_identifier}) { |
| 2427 |
my $pubid = $token->{public_identifier}; |
my $pubid = $token->{public_identifier}; |
| 2475 |
"-//NETSCAPE COMM. CORP.//DTD STRICT HTML//EN" => 1, |
"-//NETSCAPE COMM. CORP.//DTD STRICT HTML//EN" => 1, |
| 2476 |
"-//O'REILLY AND ASSOCIATES//DTD HTML 2.0//EN" => 1, |
"-//O'REILLY AND ASSOCIATES//DTD HTML 2.0//EN" => 1, |
| 2477 |
"-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED 1.0//EN" => 1, |
"-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED 1.0//EN" => 1, |
| 2478 |
|
"-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED RELAXED 1.0//EN" => 1, |
| 2479 |
|
"-//SOFTQUAD SOFTWARE//DTD HOTMETAL PRO 6.0::19990601::EXTENSIONS TO HTML 4.0//EN" => 1, |
| 2480 |
|
"-//SOFTQUAD//DTD HOTMETAL PRO 4.0::19971010::EXTENSIONS TO HTML 4.0//EN" => 1, |
| 2481 |
"-//SPYGLASS//DTD HTML 2.0 EXTENDED//EN" => 1, |
"-//SPYGLASS//DTD HTML 2.0 EXTENDED//EN" => 1, |
| 2482 |
"-//SQ//DTD HTML 2.0 HOTMETAL + EXTENSIONS//EN" => 1, |
"-//SQ//DTD HTML 2.0 HOTMETAL + EXTENSIONS//EN" => 1, |
| 2483 |
"-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA HTML//EN" => 1, |
"-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA HTML//EN" => 1, |
| 2589 |
redo B; |
redo B; |
| 2590 |
} |
} |
| 2591 |
} |
} |
| 2592 |
|
|
| 2593 |
|
$self->{application_cache_selection}->(undef); |
| 2594 |
|
|
| 2595 |
|
# |
| 2596 |
|
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 2597 |
|
if ($token->{tag_name} eq 'html' and |
| 2598 |
|
$token->{attributes}->{manifest}) { |
| 2599 |
|
$self->{application_cache_selection} |
| 2600 |
|
->($token->{attributes}->{manifest}->{value}); |
| 2601 |
|
## ISSUE: No relative reference resolution? |
| 2602 |
|
} else { |
| 2603 |
|
$self->{application_cache_selection}->(undef); |
| 2604 |
|
} |
| 2605 |
|
|
| 2606 |
|
## ISSUE: There is an issue in the spec |
| 2607 |
# |
# |
| 2608 |
} elsif ({ |
} elsif ({ |
|
START_TAG_TOKEN, 1, |
|
| 2609 |
END_TAG_TOKEN, 1, |
END_TAG_TOKEN, 1, |
| 2610 |
END_OF_FILE_TOKEN, 1, |
END_OF_FILE_TOKEN, 1, |
| 2611 |
}->{$token->{type}}) { |
}->{$token->{type}}) { |
| 2612 |
|
$self->{application_cache_selection}->(undef); |
| 2613 |
|
|
| 2614 |
## ISSUE: There is an issue in the spec |
## ISSUE: There is an issue in the spec |
| 2615 |
# |
# |
| 2616 |
} else { |
} else { |
| 2617 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 2618 |
} |
} |
| 2619 |
|
|
| 2620 |
my $root_element; !!!create-element ($root_element, 'html'); |
my $root_element; !!!create-element ($root_element, 'html'); |
| 2621 |
$self->{document}->append_child ($root_element); |
$self->{document}->append_child ($root_element); |
| 2622 |
push @{$self->{open_elements}}, [$root_element, 'html']; |
push @{$self->{open_elements}}, [$root_element, 'html']; |
| 3099 |
!!!next-token; |
!!!next-token; |
| 3100 |
redo B; |
redo B; |
| 3101 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 3102 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM or |
if ($self->{insertion_mode} & AFTER_HTML_IMS) { |
|
$self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
|
| 3103 |
# |
# |
| 3104 |
} else { |
} else { |
| 3105 |
## Generate implied end tags |
## Generate implied end tags |
| 3155 |
redo B; |
redo B; |
| 3156 |
} elsif ($token->{type} == COMMENT_TOKEN) { |
} elsif ($token->{type} == COMMENT_TOKEN) { |
| 3157 |
my $comment = $self->{document}->create_comment ($token->{data}); |
my $comment = $self->{document}->create_comment ($token->{data}); |
| 3158 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM or |
if ($self->{insertion_mode} & AFTER_HTML_IMS) { |
|
$self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
|
| 3159 |
$self->{document}->append_child ($comment); |
$self->{document}->append_child ($comment); |
| 3160 |
} elsif ($self->{insertion_mode} == AFTER_BODY_IM) { |
} elsif ($self->{insertion_mode} == AFTER_BODY_IM) { |
| 3161 |
$self->{open_elements}->[0]->[0]->append_child ($comment); |
$self->{open_elements}->[0]->[0]->append_child ($comment); |
| 3164 |
} |
} |
| 3165 |
!!!next-token; |
!!!next-token; |
| 3166 |
redo B; |
redo B; |
| 3167 |
} elsif ($self->{insertion_mode} == IN_HEAD_IM or |
} elsif ($self->{insertion_mode} & HEAD_IMS) { |
|
$self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM or |
|
|
$self->{insertion_mode} == AFTER_HEAD_IM or |
|
|
$self->{insertion_mode} == BEFORE_HEAD_IM) { |
|
| 3168 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 3169 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 3170 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 3273 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3274 |
} |
} |
| 3275 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3276 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3277 |
|
|
| 3278 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
|
my $charset; |
|
| 3279 |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
| 3280 |
$charset = $token->{attributes}->{charset}->{value}; |
$self->{change_encoding} |
| 3281 |
} |
->($self, $token->{attributes}->{charset}->{value}); |
| 3282 |
if ($token->{attributes}->{'http-equiv'}) { |
|
| 3283 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
| 3284 |
|
->set_user_data (manakai_has_reference => |
| 3285 |
|
$token->{attributes}->{charset} |
| 3286 |
|
->{has_reference}); |
| 3287 |
|
} elsif ($token->{attributes}->{content}) { |
| 3288 |
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition. |
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition. |
| 3289 |
if ($token->{attributes}->{'http-equiv'}->{value} |
if ($token->{attributes}->{content}->{value} |
| 3290 |
=~ /\A[^;]*;[\x09-\x0D\x20]*charset[\x09-\x0D\x20]*= |
=~ /\A[^;]*;[\x09-\x0D\x20]*[Cc][Hh][Aa][Rr][Ss][Ee][Tt] |
| 3291 |
|
[\x09-\x0D\x20]*= |
| 3292 |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
| 3293 |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
| 3294 |
$charset = defined $1 ? $1 : defined $2 ? $2 : $3; |
$self->{change_encoding} |
| 3295 |
} ## TODO: And if supported |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3); |
| 3296 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 3297 |
|
->set_user_data (manakai_has_reference => |
| 3298 |
|
$token->{attributes}->{content} |
| 3299 |
|
->{has_reference}); |
| 3300 |
|
} |
| 3301 |
|
} |
| 3302 |
|
} else { |
| 3303 |
|
if ($token->{attributes}->{charset}) { |
| 3304 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
| 3305 |
|
->set_user_data (manakai_has_reference => |
| 3306 |
|
$token->{attributes}->{charset} |
| 3307 |
|
->{has_reference}); |
| 3308 |
|
} |
| 3309 |
|
if ($token->{attributes}->{content}) { |
| 3310 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 3311 |
|
->set_user_data (manakai_has_reference => |
| 3312 |
|
$token->{attributes}->{content} |
| 3313 |
|
->{has_reference}); |
| 3314 |
} |
} |
|
## TODO: Change the encoding |
|
| 3315 |
} |
} |
| 3316 |
|
|
|
## TODO: Extracting |charset| from |meta|. |
|
| 3317 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} |
| 3318 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3319 |
!!!next-token; |
!!!next-token; |
| 3562 |
} |
} |
| 3563 |
|
|
| 3564 |
## ISSUE: An issue in the spec. |
## ISSUE: An issue in the spec. |
| 3565 |
} elsif ($self->{insertion_mode} == IN_BODY_IM or |
} elsif ($self->{insertion_mode} & BODY_IMS) { |
|
$self->{insertion_mode} == IN_CELL_IM or |
|
|
$self->{insertion_mode} == IN_CAPTION_IM) { |
|
| 3566 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 3567 |
## NOTE: There is a code clone of "character in body". |
## NOTE: There is a code clone of "character in body". |
| 3568 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 3856 |
} elsif ({ |
} elsif ({ |
| 3857 |
body => 1, col => 1, colgroup => 1, html => 1, |
body => 1, col => 1, colgroup => 1, html => 1, |
| 3858 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3859 |
if ($self->{insertion_mode} == IN_CELL_IM or |
if ($self->{insertion_mode} & BODY_TABLE_IMS) { |
|
$self->{insertion_mode} == IN_CAPTION_IM) { |
|
| 3860 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3861 |
## Ignore the token |
## Ignore the token |
| 3862 |
!!!next-token; |
!!!next-token; |
| 3882 |
|
|
| 3883 |
$insert = $insert_to_current; |
$insert = $insert_to_current; |
| 3884 |
# |
# |
| 3885 |
} elsif ($self->{insertion_mode} == IN_ROW_IM or |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
| 3886 |
$self->{insertion_mode} == IN_TABLE_BODY_IM or |
if ($token->{type} == CHARACTER_TOKEN) { |
|
$self->{insertion_mode} == IN_TABLE_IM) { |
|
|
if ($token->{type} == CHARACTER_TOKEN) { |
|
|
## NOTE: There are "character in table" code clones. |
|
| 3887 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 3888 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 3889 |
|
|
| 3940 |
|
|
| 3941 |
!!!next-token; |
!!!next-token; |
| 3942 |
redo B; |
redo B; |
| 3943 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 3944 |
if ({ |
if ({ |
| 3945 |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
| 3946 |
th => 1, td => 1, |
th => 1, td => 1, |
| 4126 |
die "$0: in table: <>: $token->{tag_name}"; |
die "$0: in table: <>: $token->{tag_name}"; |
| 4127 |
} |
} |
| 4128 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
|
## NOTE: There are code clones for this "table in table" |
|
| 4129 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4130 |
|
|
| 4131 |
## As if </table> |
## As if </table> |
| 4173 |
|
|
| 4174 |
## reprocess |
## reprocess |
| 4175 |
redo B; |
redo B; |
| 4176 |
} else { |
} else { |
| 4177 |
# |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
| 4178 |
} |
|
| 4179 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
$insert = $insert_to_foster; |
| 4180 |
|
# |
| 4181 |
|
} |
| 4182 |
|
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 4183 |
if ($token->{tag_name} eq 'tr' and |
if ($token->{tag_name} eq 'tr' and |
| 4184 |
$self->{insertion_mode} == IN_ROW_IM) { |
$self->{insertion_mode} == IN_ROW_IM) { |
| 4185 |
## have an element in table scope |
## have an element in table scope |
| 4338 |
} elsif ({ |
} elsif ({ |
| 4339 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
| 4340 |
}->{$token->{tag_name}} and |
}->{$token->{tag_name}} and |
| 4341 |
($self->{insertion_mode} == IN_ROW_IM or |
$self->{insertion_mode} & ROW_IMS) { |
|
$self->{insertion_mode} == IN_TABLE_BODY_IM)) { |
|
| 4342 |
if ($self->{insertion_mode} == IN_ROW_IM) { |
if ($self->{insertion_mode} == IN_ROW_IM) { |
| 4343 |
## have an element in table scope |
## have an element in table scope |
| 4344 |
my $i; |
my $i; |
| 4436 |
## Ignore the token |
## Ignore the token |
| 4437 |
!!!next-token; |
!!!next-token; |
| 4438 |
redo B; |
redo B; |
| 4439 |
} else { |
} else { |
| 4440 |
# |
!!!parse-error (type => 'in table:/'.$token->{tag_name}); |
|
} |
|
|
} else { |
|
|
die "$0: $token->{type}: Unknown token type"; |
|
|
} |
|
|
|
|
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
|
| 4441 |
|
|
| 4442 |
$insert = $insert_to_foster; |
$insert = $insert_to_foster; |
| 4443 |
# |
# |
| 4444 |
|
} |
| 4445 |
|
} else { |
| 4446 |
|
die "$0: $token->{type}: Unknown token type"; |
| 4447 |
|
} |
| 4448 |
} elsif ($self->{insertion_mode} == IN_COLUMN_GROUP_IM) { |
} elsif ($self->{insertion_mode} == IN_COLUMN_GROUP_IM) { |
| 4449 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 4450 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4503 |
redo B; |
redo B; |
| 4504 |
} |
} |
| 4505 |
} elsif ($self->{insertion_mode} == IN_SELECT_IM) { |
} elsif ($self->{insertion_mode} == IN_SELECT_IM) { |
| 4506 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 4507 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 4508 |
!!!next-token; |
!!!next-token; |
| 4509 |
redo B; |
redo B; |
| 4510 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 4511 |
if ($token->{tag_name} eq 'option') { |
if ($token->{tag_name} eq 'option') { |
| 4512 |
if ($self->{open_elements}->[-1]->[1] eq 'option') { |
if ($self->{open_elements}->[-1]->[1] eq 'option') { |
| 4513 |
## As if </option> |
## As if </option> |
| 4560 |
|
|
| 4561 |
!!!next-token; |
!!!next-token; |
| 4562 |
redo B; |
redo B; |
| 4563 |
} else { |
} else { |
| 4564 |
# |
!!!parse-error (type => 'in select:'.$token->{tag_name}); |
| 4565 |
} |
## Ignore the token |
| 4566 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
!!!next-token; |
| 4567 |
|
redo B; |
| 4568 |
|
} |
| 4569 |
|
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 4570 |
if ($token->{tag_name} eq 'optgroup') { |
if ($token->{tag_name} eq 'optgroup') { |
| 4571 |
if ($self->{open_elements}->[-1]->[1] eq 'option' and |
if ($self->{open_elements}->[-1]->[1] eq 'option' and |
| 4572 |
$self->{open_elements}->[-2]->[1] eq 'optgroup') { |
$self->{open_elements}->[-2]->[1] eq 'optgroup') { |
| 4668 |
|
|
| 4669 |
## reprocess |
## reprocess |
| 4670 |
redo B; |
redo B; |
| 4671 |
} else { |
} else { |
| 4672 |
# |
!!!parse-error (type => 'in select:/'.$token->{tag_name}); |
|
} |
|
|
} else { |
|
|
# |
|
|
} |
|
|
|
|
|
!!!parse-error (type => 'in select:'.$token->{tag_name}); |
|
| 4673 |
## Ignore the token |
## Ignore the token |
| 4674 |
!!!next-token; |
!!!next-token; |
| 4675 |
redo B; |
redo B; |
| 4676 |
} elsif ($self->{insertion_mode} == AFTER_BODY_IM or |
} |
| 4677 |
$self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
} else { |
| 4678 |
|
die "$0: $token->{type}: Unknown token type"; |
| 4679 |
|
} |
| 4680 |
|
} elsif ($self->{insertion_mode} & BODY_AFTER_IMS) { |
| 4681 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 4682 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4683 |
my $data = $1; |
my $data = $1; |
| 4747 |
} else { |
} else { |
| 4748 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 4749 |
} |
} |
| 4750 |
} elsif ($self->{insertion_mode} == IN_FRAMESET_IM or |
} elsif ($self->{insertion_mode} & FRAME_IMS) { |
|
$self->{insertion_mode} == AFTER_FRAMESET_IM or |
|
|
$self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
|
| 4751 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 4752 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4753 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 4884 |
} elsif ($token->{tag_name} eq 'meta') { |
} elsif ($token->{tag_name} eq 'meta') { |
| 4885 |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
| 4886 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 4887 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 4888 |
|
|
| 4889 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
|
my $charset; |
|
| 4890 |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
| 4891 |
$charset = $token->{attributes}->{charset}->{value}; |
$self->{change_encoding} |
| 4892 |
} |
->($self, $token->{attributes}->{charset}->{value}); |
| 4893 |
if ($token->{attributes}->{'http-equiv'}) { |
|
| 4894 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
| 4895 |
|
->set_user_data (manakai_has_reference => |
| 4896 |
|
$token->{attributes}->{charset} |
| 4897 |
|
->{has_reference}); |
| 4898 |
|
} elsif ($token->{attributes}->{content}) { |
| 4899 |
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition. |
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition. |
| 4900 |
if ($token->{attributes}->{'http-equiv'}->{value} |
if ($token->{attributes}->{content}->{value} |
| 4901 |
=~ /\A[^;]*;[\x09-\x0D\x20]*charset[\x09-\x0D\x20]*= |
=~ /\A[^;]*;[\x09-\x0D\x20]*[Cc][Hh][Aa][Rr][Ss][Ee][Tt] |
| 4902 |
|
[\x09-\x0D\x20]*= |
| 4903 |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
| 4904 |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
| 4905 |
$charset = defined $1 ? $1 : defined $2 ? $2 : $3; |
$self->{change_encoding} |
| 4906 |
} ## TODO: And if supported |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3); |
| 4907 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 4908 |
|
->set_user_data (manakai_has_reference => |
| 4909 |
|
$token->{attributes}->{content} |
| 4910 |
|
->{has_reference}); |
| 4911 |
|
} |
| 4912 |
|
} |
| 4913 |
|
} else { |
| 4914 |
|
if ($token->{attributes}->{charset}) { |
| 4915 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
| 4916 |
|
->set_user_data (manakai_has_reference => |
| 4917 |
|
$token->{attributes}->{charset} |
| 4918 |
|
->{has_reference}); |
| 4919 |
|
} |
| 4920 |
|
if ($token->{attributes}->{content}) { |
| 4921 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 4922 |
|
->set_user_data (manakai_has_reference => |
| 4923 |
|
$token->{attributes}->{content} |
| 4924 |
|
->{has_reference}); |
| 4925 |
} |
} |
|
## TODO: Change the encoding |
|
| 4926 |
} |
} |
| 4927 |
|
|
| 4928 |
!!!next-token; |
!!!next-token; |
| 5229 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5230 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5231 |
if ($node->[1] eq 'nobr') { |
if ($node->[1] eq 'nobr') { |
| 5232 |
!!!parse-error (type => 'not closed:nobr'); |
!!!parse-error (type => 'in nobr:nobr'); |
| 5233 |
!!!back-token; |
!!!back-token; |
| 5234 |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr'}; |
| 5235 |
redo B; |
redo B; |
| 5434 |
noframes => 1, |
noframes => 1, |
| 5435 |
noscript => 0, ## TODO: 1 if scripting is enabled |
noscript => 0, ## TODO: 1 if scripting is enabled |
| 5436 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5437 |
## NOTE: There are two "as if in body" code clones. |
## NOTE: There is an "as if in body" code clone. |
| 5438 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
| 5439 |
redo B; |
redo B; |
| 5440 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select') { |
| 5590 |
if ($self->{open_elements}->[-1]->[1] eq $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[1] eq $token->{tag_name}) { |
| 5591 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5592 |
} else { |
} else { |
| 5593 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 5594 |
} |
} |
| 5595 |
|
|
| 5596 |
undef $self->{form_element}; |
undef $self->{form_element}; |
| 5628 |
} # INSCOPE |
} # INSCOPE |
| 5629 |
|
|
| 5630 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 5631 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 5632 |
} |
} |
| 5633 |
|
|
| 5634 |
splice @{$self->{open_elements}}, $i if defined $i; |
splice @{$self->{open_elements}}, $i if defined $i; |
| 5697 |
|
|
| 5698 |
## Step 2 |
## Step 2 |
| 5699 |
if ($token->{tag_name} ne $self->{open_elements}->[-1]->[1]) { |
if ($token->{tag_name} ne $self->{open_elements}->[-1]->[1]) { |
| 5700 |
|
## NOTE: <x><y></x> |
| 5701 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 5702 |
} |
} |
| 5703 |
|
|
| 5748 |
my $s = \$_[0]; |
my $s = \$_[0]; |
| 5749 |
my $onerror = $_[1]; |
my $onerror = $_[1]; |
| 5750 |
|
|
| 5751 |
|
## ISSUE: Should {confident} be true? |
| 5752 |
|
|
| 5753 |
my $nt = $node->node_type; |
my $nt = $node->node_type; |
| 5754 |
if ($nt == 9) { |
if ($nt == 9) { |
| 5755 |
# MUST |
# MUST |
| 5782 |
my $i = 0; |
my $i = 0; |
| 5783 |
my $line = 1; |
my $line = 1; |
| 5784 |
my $column = 0; |
my $column = 0; |
| 5785 |
$p->{set_next_input_character} = sub { |
$p->{set_next_char} = sub { |
| 5786 |
my $self = shift; |
my $self = shift; |
| 5787 |
|
|
| 5788 |
pop @{$self->{prev_input_character}}; |
pop @{$self->{prev_char}}; |
| 5789 |
unshift @{$self->{prev_input_character}}, $self->{next_input_character}; |
unshift @{$self->{prev_char}}, $self->{next_char}; |
| 5790 |
|
|
| 5791 |
$self->{next_input_character} = -1 and return if $i >= length $$s; |
$self->{next_char} = -1 and return if $i >= length $$s; |
| 5792 |
$self->{next_input_character} = ord substr $$s, $i++, 1; |
$self->{next_char} = ord substr $$s, $i++, 1; |
| 5793 |
$column++; |
$column++; |
| 5794 |
|
|
| 5795 |
if ($self->{next_input_character} == 0x000A) { # LF |
if ($self->{next_char} == 0x000A) { # LF |
| 5796 |
$line++; |
$line++; |
| 5797 |
$column = 0; |
$column = 0; |
| 5798 |
} elsif ($self->{next_input_character} == 0x000D) { # CR |
} elsif ($self->{next_char} == 0x000D) { # CR |
| 5799 |
$i++ if substr ($$s, $i, 1) eq "\x0A"; |
$i++ if substr ($$s, $i, 1) eq "\x0A"; |
| 5800 |
$self->{next_input_character} = 0x000A; # LF # MUST |
$self->{next_char} = 0x000A; # LF # MUST |
| 5801 |
$line++; |
$line++; |
| 5802 |
$column = 0; |
$column = 0; |
| 5803 |
} elsif ($self->{next_input_character} > 0x10FFFF) { |
} elsif ($self->{next_char} > 0x10FFFF) { |
| 5804 |
$self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
| 5805 |
} elsif ($self->{next_input_character} == 0x0000) { # NULL |
} elsif ($self->{next_char} == 0x0000) { # NULL |
| 5806 |
!!!parse-error (type => 'NULL'); |
!!!parse-error (type => 'NULL'); |
| 5807 |
$self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
| 5808 |
} |
} |
| 5809 |
}; |
}; |
| 5810 |
$p->{prev_input_character} = [-1, -1, -1]; |
$p->{prev_char} = [-1, -1, -1]; |
| 5811 |
$p->{next_input_character} = -1; |
$p->{next_char} = -1; |
| 5812 |
|
|
| 5813 |
my $ponerror = $onerror || sub { |
my $ponerror = $onerror || sub { |
| 5814 |
my (%opt) = @_; |
my (%opt) = @_; |
| 5822 |
$p->_initialize_tree_constructor; |
$p->_initialize_tree_constructor; |
| 5823 |
|
|
| 5824 |
## Step 2 |
## Step 2 |
| 5825 |
my $node_ln = $node->local_name; |
my $node_ln = $node->manakai_local_name; |
| 5826 |
$p->{content_model} = { |
$p->{content_model} = { |
| 5827 |
title => RCDATA_CONTENT_MODEL, |
title => RCDATA_CONTENT_MODEL, |
| 5828 |
textarea => RCDATA_CONTENT_MODEL, |
textarea => RCDATA_CONTENT_MODEL, |
| 5862 |
if ($anode->node_type == 1) { |
if ($anode->node_type == 1) { |
| 5863 |
my $nsuri = $anode->namespace_uri; |
my $nsuri = $anode->namespace_uri; |
| 5864 |
if (defined $nsuri and $nsuri eq 'http://www.w3.org/1999/xhtml') { |
if (defined $nsuri and $nsuri eq 'http://www.w3.org/1999/xhtml') { |
| 5865 |
if ($anode->local_name eq 'form') { ## TODO: case? |
if ($anode->manakai_local_name eq 'form') { |
| 5866 |
$p->{form_element} = $anode; |
$p->{form_element} = $anode; |
| 5867 |
last AN; |
last AN; |
| 5868 |
} |
} |
| 5902 |
|
|
| 5903 |
} # tree construction stage |
} # tree construction stage |
| 5904 |
|
|
| 5905 |
sub get_inner_html ($$$) { |
package Whatpm::HTML::RestartParser; |
| 5906 |
my (undef, $node, $on_error) = @_; |
push our @ISA, 'Error'; |
|
|
|
|
## Step 1 |
|
|
my $s = ''; |
|
|
|
|
|
my $in_cdata; |
|
|
my $parent = $node; |
|
|
while (defined $parent) { |
|
|
if ($parent->node_type == 1 and |
|
|
$parent->namespace_uri eq 'http://www.w3.org/1999/xhtml' and |
|
|
{ |
|
|
style => 1, script => 1, xmp => 1, iframe => 1, |
|
|
noembed => 1, noframes => 1, noscript => 1, |
|
|
}->{$parent->local_name}) { ## TODO: case thingy |
|
|
$in_cdata = 1; |
|
|
} |
|
|
$parent = $parent->parent_node; |
|
|
} |
|
|
|
|
|
## Step 2 |
|
|
my @node = @{$node->child_nodes}; |
|
|
C: while (@node) { |
|
|
my $child = shift @node; |
|
|
unless (ref $child) { |
|
|
if ($child eq 'cdata-out') { |
|
|
$in_cdata = 0; |
|
|
} else { |
|
|
$s .= $child; # end tag |
|
|
} |
|
|
next C; |
|
|
} |
|
|
|
|
|
my $nt = $child->node_type; |
|
|
if ($nt == 1) { # Element |
|
|
my $tag_name = $child->tag_name; ## TODO: manakai_tag_name |
|
|
$s .= '<' . $tag_name; |
|
|
## NOTE: Non-HTML case: |
|
|
## <http://permalink.gmane.org/gmane.org.w3c.whatwg.discuss/11191> |
|
|
|
|
|
my @attrs = @{$child->attributes}; # sort order MUST be stable |
|
|
for my $attr (@attrs) { # order is implementation dependent |
|
|
my $attr_name = $attr->name; ## TODO: manakai_name |
|
|
$s .= ' ' . $attr_name . '="'; |
|
|
my $attr_value = $attr->value; |
|
|
## escape |
|
|
$attr_value =~ s/&/&/g; |
|
|
$attr_value =~ s/</</g; |
|
|
$attr_value =~ s/>/>/g; |
|
|
$attr_value =~ s/"/"/g; |
|
|
$s .= $attr_value . '"'; |
|
|
} |
|
|
$s .= '>'; |
|
|
|
|
|
next C if { |
|
|
area => 1, base => 1, basefont => 1, bgsound => 1, |
|
|
br => 1, col => 1, embed => 1, frame => 1, hr => 1, |
|
|
img => 1, input => 1, link => 1, meta => 1, param => 1, |
|
|
spacer => 1, wbr => 1, |
|
|
}->{$tag_name}; |
|
|
|
|
|
$s .= "\x0A" if $tag_name eq 'pre' or $tag_name eq 'textarea'; |
|
|
|
|
|
if (not $in_cdata and { |
|
|
style => 1, script => 1, xmp => 1, iframe => 1, |
|
|
noembed => 1, noframes => 1, noscript => 1, |
|
|
plaintext => 1, |
|
|
}->{$tag_name}) { |
|
|
unshift @node, 'cdata-out'; |
|
|
$in_cdata = 1; |
|
|
} |
|
|
|
|
|
unshift @node, @{$child->child_nodes}, '</' . $tag_name . '>'; |
|
|
} elsif ($nt == 3 or $nt == 4) { |
|
|
if ($in_cdata) { |
|
|
$s .= $child->data; |
|
|
} else { |
|
|
my $value = $child->data; |
|
|
$value =~ s/&/&/g; |
|
|
$value =~ s/</</g; |
|
|
$value =~ s/>/>/g; |
|
|
$value =~ s/"/"/g; |
|
|
$s .= $value; |
|
|
} |
|
|
} elsif ($nt == 8) { |
|
|
$s .= '<!--' . $child->data . '-->'; |
|
|
} elsif ($nt == 10) { |
|
|
$s .= '<!DOCTYPE ' . $child->name . '>'; |
|
|
} elsif ($nt == 5) { # entrefs |
|
|
push @node, @{$child->child_nodes}; |
|
|
} else { |
|
|
$on_error->($child) if defined $on_error; |
|
|
} |
|
|
## ISSUE: This code does not support PIs. |
|
|
} # C |
|
|
|
|
|
## Step 3 |
|
|
return \$s; |
|
|
} # get_inner_html |
|
| 5907 |
|
|
| 5908 |
1; |
1; |
| 5909 |
# $Date$ |
# $Date$ |