652 |
$self->{line_prev} = $self->{line} = 1; |
$self->{line_prev} = $self->{line} = 1; |
653 |
$self->{column_prev} = -1; |
$self->{column_prev} = -1; |
654 |
$self->{column} = 0; |
$self->{column} = 0; |
655 |
$self->{set_next_char} = sub { |
$self->{set_nc} = sub { |
656 |
my $self = shift; |
my $self = shift; |
657 |
|
|
658 |
my $char = ''; |
my $char = ''; |
659 |
if (defined $self->{next_next_char}) { |
if (defined $self->{next_nc}) { |
660 |
$char = $self->{next_next_char}; |
$char = $self->{next_nc}; |
661 |
delete $self->{next_next_char}; |
delete $self->{next_nc}; |
662 |
$self->{next_char} = ord $char; |
$self->{nc} = ord $char; |
663 |
} else { |
} else { |
664 |
$self->{char_buffer} = ''; |
$self->{char_buffer} = ''; |
665 |
$self->{char_buffer_pos} = 0; |
$self->{char_buffer_pos} = 0; |
670 |
$self->{line_prev} = $self->{line}; |
$self->{line_prev} = $self->{line}; |
671 |
$self->{column_prev} = $self->{column}; |
$self->{column_prev} = $self->{column}; |
672 |
$self->{column}++; |
$self->{column}++; |
673 |
$self->{next_char} |
$self->{nc} |
674 |
= ord substr ($self->{char_buffer}, $self->{char_buffer_pos}++, 1); |
= ord substr ($self->{char_buffer}, $self->{char_buffer_pos}++, 1); |
675 |
return; |
return; |
676 |
} |
} |
677 |
|
|
678 |
if ($input->read ($char, 1)) { |
if ($input->read ($char, 1)) { |
679 |
$self->{next_char} = ord $char; |
$self->{nc} = ord $char; |
680 |
} else { |
} else { |
681 |
$self->{next_char} = -1; |
$self->{nc} = -1; |
682 |
return; |
return; |
683 |
} |
} |
684 |
} |
} |
687 |
= ($self->{line}, $self->{column}); |
= ($self->{line}, $self->{column}); |
688 |
$self->{column}++; |
$self->{column}++; |
689 |
|
|
690 |
if ($self->{next_char} == 0x000A) { # LF |
if ($self->{nc} == 0x000A) { # LF |
691 |
!!!cp ('j1'); |
!!!cp ('j1'); |
692 |
$self->{line}++; |
$self->{line}++; |
693 |
$self->{column} = 0; |
$self->{column} = 0; |
694 |
} elsif ($self->{next_char} == 0x000D) { # CR |
} elsif ($self->{nc} == 0x000D) { # CR |
695 |
!!!cp ('j2'); |
!!!cp ('j2'); |
696 |
## TODO: support for abort/streaming |
## TODO: support for abort/streaming |
697 |
my $next = ''; |
my $next = ''; |
698 |
if ($input->read ($next, 1) and $next ne "\x0A") { |
if ($input->read ($next, 1) and $next ne "\x0A") { |
699 |
$self->{next_next_char} = $next; |
$self->{next_nc} = $next; |
700 |
} |
} |
701 |
$self->{next_char} = 0x000A; # LF # MUST |
$self->{nc} = 0x000A; # LF # MUST |
702 |
$self->{line}++; |
$self->{line}++; |
703 |
$self->{column} = 0; |
$self->{column} = 0; |
704 |
} elsif ($self->{next_char} == 0x0000) { # NULL |
} elsif ($self->{nc} == 0x0000) { # NULL |
705 |
!!!cp ('j4'); |
!!!cp ('j4'); |
706 |
!!!parse-error (type => 'NULL'); |
!!!parse-error (type => 'NULL'); |
707 |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{nc} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
708 |
} |
} |
709 |
}; |
}; |
710 |
|
|
711 |
$self->{read_until} = sub { |
$self->{read_until} = sub { |
712 |
#my ($scalar, $specials_range, $offset) = @_; |
#my ($scalar, $specials_range, $offset) = @_; |
713 |
return 0 if defined $self->{next_next_char}; |
return 0 if defined $self->{next_nc}; |
714 |
|
|
715 |
my $pattern = qr/[^$_[1]\x00\x0A\x0D]/; |
my $pattern = qr/[^$_[1]\x00\x0A\x0D]/; |
716 |
my $offset = $_[2] || 0; |
my $offset = $_[2] || 0; |
727 |
$self->{line_prev} = $self->{line}; |
$self->{line_prev} = $self->{line}; |
728 |
$self->{column_prev} = $self->{column} - 1; |
$self->{column_prev} = $self->{column} - 1; |
729 |
$self->{prev_char} = [-1, -1, -1]; |
$self->{prev_char} = [-1, -1, -1]; |
730 |
$self->{next_char} = -1; |
$self->{nc} = -1; |
731 |
} |
} |
732 |
return $count; |
return $count; |
733 |
} else { |
} else { |
740 |
$self->{line_prev} = $self->{line}; |
$self->{line_prev} = $self->{line}; |
741 |
$self->{column_prev} = $self->{column} - 1; |
$self->{column_prev} = $self->{column} - 1; |
742 |
$self->{prev_char} = [-1, -1, -1]; |
$self->{prev_char} = [-1, -1, -1]; |
743 |
$self->{next_char} = -1; |
$self->{nc} = -1; |
744 |
} |
} |
745 |
return $count; |
return $count; |
746 |
} |
} |
789 |
info => 'i', |
info => 'i', |
790 |
uncertain => 'u'}, |
uncertain => 'u'}, |
791 |
}, $class; |
}, $class; |
792 |
$self->{set_next_char} = sub { |
$self->{set_nc} = sub { |
793 |
$self->{next_char} = -1; |
$self->{nc} = -1; |
794 |
}; |
}; |
795 |
$self->{parse_error} = sub { |
$self->{parse_error} = sub { |
796 |
# |
# |
921 |
sub _initialize_tokenizer ($) { |
sub _initialize_tokenizer ($) { |
922 |
my $self = shift; |
my $self = shift; |
923 |
$self->{state} = DATA_STATE; # MUST |
$self->{state} = DATA_STATE; # MUST |
924 |
#$self->{state_keyword}; # initialized when used |
#$self->{s_kwd}; # state keyword - initialized when used |
925 |
#$self->{entity__value}; # initialized when used |
#$self->{entity__value}; # initialized when used |
926 |
#$self->{entity__match}; # initialized when used |
#$self->{entity__match}; # initialized when used |
927 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # be |
$self->{content_model} = PCDATA_CONTENT_MODEL; # be |
928 |
undef $self->{current_token}; |
undef $self->{ct}; # current token |
929 |
undef $self->{current_attribute}; |
undef $self->{ca}; # current attribute |
930 |
undef $self->{last_emitted_start_tag_name}; |
undef $self->{last_stag_name}; # last emitted start tag name |
931 |
#$self->{prev_state}; # initialized when used |
#$self->{prev_state}; # initialized when used |
932 |
delete $self->{self_closing}; |
delete $self->{self_closing}; |
933 |
$self->{char_buffer} = ''; |
$self->{char_buffer} = ''; |
934 |
$self->{char_buffer_pos} = 0; |
$self->{char_buffer_pos} = 0; |
935 |
$self->{prev_char} = [-1, -1, -1]; |
$self->{prev_char} = [-1, -1, -1]; |
936 |
$self->{next_char} = -1; |
$self->{nc} = -1; # next input character |
937 |
|
#$self->{next_nc} |
938 |
!!!next-input-character; |
!!!next-input-character; |
939 |
$self->{token} = []; |
$self->{token} = []; |
940 |
# $self->{escape} |
# $self->{escape} |
945 |
## CHARACTER_TOKEN, or END_OF_FILE_TOKEN |
## CHARACTER_TOKEN, or END_OF_FILE_TOKEN |
946 |
## ->{name} (DOCTYPE_TOKEN) |
## ->{name} (DOCTYPE_TOKEN) |
947 |
## ->{tag_name} (START_TAG_TOKEN, END_TAG_TOKEN) |
## ->{tag_name} (START_TAG_TOKEN, END_TAG_TOKEN) |
948 |
## ->{public_identifier} (DOCTYPE_TOKEN) |
## ->{pubid} (DOCTYPE_TOKEN) |
949 |
## ->{system_identifier} (DOCTYPE_TOKEN) |
## ->{sysid} (DOCTYPE_TOKEN) |
950 |
## ->{quirks} == 1 or 0 (DOCTYPE_TOKEN): "force-quirks" flag |
## ->{quirks} == 1 or 0 (DOCTYPE_TOKEN): "force-quirks" flag |
951 |
## ->{attributes} isa HASH (START_TAG_TOKEN, END_TAG_TOKEN) |
## ->{attributes} isa HASH (START_TAG_TOKEN, END_TAG_TOKEN) |
952 |
## ->{name} |
## ->{name} |
972 |
my $self = shift; |
my $self = shift; |
973 |
|
|
974 |
if ($self->{self_closing}) { |
if ($self->{self_closing}) { |
975 |
!!!parse-error (type => 'nestc', token => $self->{current_token}); |
!!!parse-error (type => 'nestc', token => $self->{ct}); |
976 |
## NOTE: The |self_closing| flag is only set by start tag token. |
## NOTE: The |self_closing| flag is only set by start tag token. |
977 |
## In addition, when a start tag token is emitted, it is always set to |
## In addition, when a start tag token is emitted, it is always set to |
978 |
## |current_token|. |
## |ct|. |
979 |
delete $self->{self_closing}; |
delete $self->{self_closing}; |
980 |
} |
} |
981 |
|
|
986 |
|
|
987 |
A: { |
A: { |
988 |
if ($self->{state} == DATA_STATE) { |
if ($self->{state} == DATA_STATE) { |
989 |
if ($self->{next_char} == 0x0026) { # & |
if ($self->{nc} == 0x0026) { # & |
990 |
if ($self->{content_model} & CM_ENTITY and # PCDATA | RCDATA |
if ($self->{content_model} & CM_ENTITY and # PCDATA | RCDATA |
991 |
not $self->{escape}) { |
not $self->{escape}) { |
992 |
!!!cp (1); |
!!!cp (1); |
994 |
## "entity data state". In this implementation, the tokenizer |
## "entity data state". In this implementation, the tokenizer |
995 |
## is switched to the |ENTITY_STATE|, which is an implementation |
## is switched to the |ENTITY_STATE|, which is an implementation |
996 |
## of the "consume a character reference" algorithm. |
## of the "consume a character reference" algorithm. |
997 |
$self->{entity_additional} = -1; |
$self->{entity_add} = -1; |
998 |
$self->{prev_state} = DATA_STATE; |
$self->{prev_state} = DATA_STATE; |
999 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1000 |
!!!next-input-character; |
!!!next-input-character; |
1003 |
!!!cp (2); |
!!!cp (2); |
1004 |
# |
# |
1005 |
} |
} |
1006 |
} elsif ($self->{next_char} == 0x002D) { # - |
} elsif ($self->{nc} == 0x002D) { # - |
1007 |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
1008 |
unless ($self->{escape}) { |
unless ($self->{escape}) { |
1009 |
if ($self->{prev_char}->[0] == 0x002D and # - |
if ($self->{prev_char}->[0] == 0x002D and # - |
1020 |
} |
} |
1021 |
|
|
1022 |
# |
# |
1023 |
} elsif ($self->{next_char} == 0x003C) { # < |
} elsif ($self->{nc} == 0x003C) { # < |
1024 |
if ($self->{content_model} & CM_FULL_MARKUP or # PCDATA |
if ($self->{content_model} & CM_FULL_MARKUP or # PCDATA |
1025 |
(($self->{content_model} & CM_LIMITED_MARKUP) and # CDATA | RCDATA |
(($self->{content_model} & CM_LIMITED_MARKUP) and # CDATA | RCDATA |
1026 |
not $self->{escape})) { |
not $self->{escape})) { |
1032 |
!!!cp (7); |
!!!cp (7); |
1033 |
# |
# |
1034 |
} |
} |
1035 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
1036 |
if ($self->{escape} and |
if ($self->{escape} and |
1037 |
($self->{content_model} & CM_LIMITED_MARKUP)) { # RCDATA | CDATA |
($self->{content_model} & CM_LIMITED_MARKUP)) { # RCDATA | CDATA |
1038 |
if ($self->{prev_char}->[0] == 0x002D and # - |
if ($self->{prev_char}->[0] == 0x002D and # - |
1047 |
} |
} |
1048 |
|
|
1049 |
# |
# |
1050 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
1051 |
!!!cp (11); |
!!!cp (11); |
1052 |
!!!emit ({type => END_OF_FILE_TOKEN, |
!!!emit ({type => END_OF_FILE_TOKEN, |
1053 |
line => $self->{line}, column => $self->{column}}); |
line => $self->{line}, column => $self->{column}}); |
1057 |
} |
} |
1058 |
# Anything else |
# Anything else |
1059 |
my $token = {type => CHARACTER_TOKEN, |
my $token = {type => CHARACTER_TOKEN, |
1060 |
data => chr $self->{next_char}, |
data => chr $self->{nc}, |
1061 |
line => $self->{line}, column => $self->{column}, |
line => $self->{line}, column => $self->{column}, |
1062 |
}; |
}; |
1063 |
$self->{read_until}->($token->{data}, q[-!<>&], length $token->{data}); |
$self->{read_until}->($token->{data}, q[-!<>&], length $token->{data}); |
1070 |
redo A; |
redo A; |
1071 |
} elsif ($self->{state} == TAG_OPEN_STATE) { |
} elsif ($self->{state} == TAG_OPEN_STATE) { |
1072 |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
1073 |
if ($self->{next_char} == 0x002F) { # / |
if ($self->{nc} == 0x002F) { # / |
1074 |
!!!cp (15); |
!!!cp (15); |
1075 |
!!!next-input-character; |
!!!next-input-character; |
1076 |
$self->{state} = CLOSE_TAG_OPEN_STATE; |
$self->{state} = CLOSE_TAG_OPEN_STATE; |
1088 |
redo A; |
redo A; |
1089 |
} |
} |
1090 |
} elsif ($self->{content_model} & CM_FULL_MARKUP) { # PCDATA |
} elsif ($self->{content_model} & CM_FULL_MARKUP) { # PCDATA |
1091 |
if ($self->{next_char} == 0x0021) { # ! |
if ($self->{nc} == 0x0021) { # ! |
1092 |
!!!cp (17); |
!!!cp (17); |
1093 |
$self->{state} = MARKUP_DECLARATION_OPEN_STATE; |
$self->{state} = MARKUP_DECLARATION_OPEN_STATE; |
1094 |
!!!next-input-character; |
!!!next-input-character; |
1095 |
redo A; |
redo A; |
1096 |
} elsif ($self->{next_char} == 0x002F) { # / |
} elsif ($self->{nc} == 0x002F) { # / |
1097 |
!!!cp (18); |
!!!cp (18); |
1098 |
$self->{state} = CLOSE_TAG_OPEN_STATE; |
$self->{state} = CLOSE_TAG_OPEN_STATE; |
1099 |
!!!next-input-character; |
!!!next-input-character; |
1100 |
redo A; |
redo A; |
1101 |
} elsif (0x0041 <= $self->{next_char} and |
} elsif (0x0041 <= $self->{nc} and |
1102 |
$self->{next_char} <= 0x005A) { # A..Z |
$self->{nc} <= 0x005A) { # A..Z |
1103 |
!!!cp (19); |
!!!cp (19); |
1104 |
$self->{current_token} |
$self->{ct} |
1105 |
= {type => START_TAG_TOKEN, |
= {type => START_TAG_TOKEN, |
1106 |
tag_name => chr ($self->{next_char} + 0x0020), |
tag_name => chr ($self->{nc} + 0x0020), |
1107 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1108 |
column => $self->{column_prev}}; |
column => $self->{column_prev}}; |
1109 |
$self->{state} = TAG_NAME_STATE; |
$self->{state} = TAG_NAME_STATE; |
1110 |
!!!next-input-character; |
!!!next-input-character; |
1111 |
redo A; |
redo A; |
1112 |
} elsif (0x0061 <= $self->{next_char} and |
} elsif (0x0061 <= $self->{nc} and |
1113 |
$self->{next_char} <= 0x007A) { # a..z |
$self->{nc} <= 0x007A) { # a..z |
1114 |
!!!cp (20); |
!!!cp (20); |
1115 |
$self->{current_token} = {type => START_TAG_TOKEN, |
$self->{ct} = {type => START_TAG_TOKEN, |
1116 |
tag_name => chr ($self->{next_char}), |
tag_name => chr ($self->{nc}), |
1117 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1118 |
column => $self->{column_prev}}; |
column => $self->{column_prev}}; |
1119 |
$self->{state} = TAG_NAME_STATE; |
$self->{state} = TAG_NAME_STATE; |
1120 |
!!!next-input-character; |
!!!next-input-character; |
1121 |
redo A; |
redo A; |
1122 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
1123 |
!!!cp (21); |
!!!cp (21); |
1124 |
!!!parse-error (type => 'empty start tag', |
!!!parse-error (type => 'empty start tag', |
1125 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1133 |
}); |
}); |
1134 |
|
|
1135 |
redo A; |
redo A; |
1136 |
} elsif ($self->{next_char} == 0x003F) { # ? |
} elsif ($self->{nc} == 0x003F) { # ? |
1137 |
!!!cp (22); |
!!!cp (22); |
1138 |
!!!parse-error (type => 'pio', |
!!!parse-error (type => 'pio', |
1139 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1140 |
column => $self->{column_prev}); |
column => $self->{column_prev}); |
1141 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
1142 |
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
$self->{ct} = {type => COMMENT_TOKEN, data => '', |
1143 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1144 |
column => $self->{column_prev}, |
column => $self->{column_prev}, |
1145 |
}; |
}; |
1146 |
## $self->{next_char} is intentionally left as is |
## $self->{nc} is intentionally left as is |
1147 |
redo A; |
redo A; |
1148 |
} else { |
} else { |
1149 |
!!!cp (23); |
!!!cp (23); |
1169 |
|
|
1170 |
my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1); # "<"of"</" |
my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1); # "<"of"</" |
1171 |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
1172 |
if (defined $self->{last_emitted_start_tag_name}) { |
if (defined $self->{last_stag_name}) { |
1173 |
$self->{state} = CDATA_PCDATA_CLOSE_TAG_STATE; |
$self->{state} = CDATA_PCDATA_CLOSE_TAG_STATE; |
1174 |
$self->{state_keyword} = ''; |
$self->{s_kwd} = ''; |
1175 |
## Reconsume. |
## Reconsume. |
1176 |
redo A; |
redo A; |
1177 |
} else { |
} else { |
1187 |
} |
} |
1188 |
} |
} |
1189 |
|
|
1190 |
if (0x0041 <= $self->{next_char} and |
if (0x0041 <= $self->{nc} and |
1191 |
$self->{next_char} <= 0x005A) { # A..Z |
$self->{nc} <= 0x005A) { # A..Z |
1192 |
!!!cp (29); |
!!!cp (29); |
1193 |
$self->{current_token} |
$self->{ct} |
1194 |
= {type => END_TAG_TOKEN, |
= {type => END_TAG_TOKEN, |
1195 |
tag_name => chr ($self->{next_char} + 0x0020), |
tag_name => chr ($self->{nc} + 0x0020), |
1196 |
line => $l, column => $c}; |
line => $l, column => $c}; |
1197 |
$self->{state} = TAG_NAME_STATE; |
$self->{state} = TAG_NAME_STATE; |
1198 |
!!!next-input-character; |
!!!next-input-character; |
1199 |
redo A; |
redo A; |
1200 |
} elsif (0x0061 <= $self->{next_char} and |
} elsif (0x0061 <= $self->{nc} and |
1201 |
$self->{next_char} <= 0x007A) { # a..z |
$self->{nc} <= 0x007A) { # a..z |
1202 |
!!!cp (30); |
!!!cp (30); |
1203 |
$self->{current_token} = {type => END_TAG_TOKEN, |
$self->{ct} = {type => END_TAG_TOKEN, |
1204 |
tag_name => chr ($self->{next_char}), |
tag_name => chr ($self->{nc}), |
1205 |
line => $l, column => $c}; |
line => $l, column => $c}; |
1206 |
$self->{state} = TAG_NAME_STATE; |
$self->{state} = TAG_NAME_STATE; |
1207 |
!!!next-input-character; |
!!!next-input-character; |
1208 |
redo A; |
redo A; |
1209 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
1210 |
!!!cp (31); |
!!!cp (31); |
1211 |
!!!parse-error (type => 'empty end tag', |
!!!parse-error (type => 'empty end tag', |
1212 |
line => $self->{line_prev}, ## "<" in "</>" |
line => $self->{line_prev}, ## "<" in "</>" |
1214 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1215 |
!!!next-input-character; |
!!!next-input-character; |
1216 |
redo A; |
redo A; |
1217 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
1218 |
!!!cp (32); |
!!!cp (32); |
1219 |
!!!parse-error (type => 'bare etago'); |
!!!parse-error (type => 'bare etago'); |
1220 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1229 |
!!!cp (33); |
!!!cp (33); |
1230 |
!!!parse-error (type => 'bogus end tag'); |
!!!parse-error (type => 'bogus end tag'); |
1231 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
1232 |
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
$self->{ct} = {type => COMMENT_TOKEN, data => '', |
1233 |
line => $self->{line_prev}, # "<" of "</" |
line => $self->{line_prev}, # "<" of "</" |
1234 |
column => $self->{column_prev} - 1, |
column => $self->{column_prev} - 1, |
1235 |
}; |
}; |
1236 |
## NOTE: $self->{next_char} is intentionally left as is. |
## NOTE: $self->{nc} is intentionally left as is. |
1237 |
## Although the "anything else" case of the spec not explicitly |
## Although the "anything else" case of the spec not explicitly |
1238 |
## states that the next input character is to be reconsumed, |
## states that the next input character is to be reconsumed, |
1239 |
## it will be included to the |data| of the comment token |
## it will be included to the |data| of the comment token |
1242 |
redo A; |
redo A; |
1243 |
} |
} |
1244 |
} elsif ($self->{state} == CDATA_PCDATA_CLOSE_TAG_STATE) { |
} elsif ($self->{state} == CDATA_PCDATA_CLOSE_TAG_STATE) { |
1245 |
my $ch = substr $self->{last_emitted_start_tag_name}, length $self->{state_keyword}, 1; |
my $ch = substr $self->{last_stag_name}, length $self->{s_kwd}, 1; |
1246 |
if (length $ch) { |
if (length $ch) { |
1247 |
my $CH = $ch; |
my $CH = $ch; |
1248 |
$ch =~ tr/a-z/A-Z/; |
$ch =~ tr/a-z/A-Z/; |
1249 |
my $nch = chr $self->{next_char}; |
my $nch = chr $self->{nc}; |
1250 |
if ($nch eq $ch or $nch eq $CH) { |
if ($nch eq $ch or $nch eq $CH) { |
1251 |
!!!cp (24); |
!!!cp (24); |
1252 |
## Stay in the state. |
## Stay in the state. |
1253 |
$self->{state_keyword} .= $nch; |
$self->{s_kwd} .= $nch; |
1254 |
!!!next-input-character; |
!!!next-input-character; |
1255 |
redo A; |
redo A; |
1256 |
} else { |
} else { |
1258 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1259 |
## Reconsume. |
## Reconsume. |
1260 |
!!!emit ({type => CHARACTER_TOKEN, |
!!!emit ({type => CHARACTER_TOKEN, |
1261 |
data => '</' . $self->{state_keyword}, |
data => '</' . $self->{s_kwd}, |
1262 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1263 |
column => $self->{column_prev} - 1 - length $self->{state_keyword}, |
column => $self->{column_prev} - 1 - length $self->{s_kwd}, |
1264 |
}); |
}); |
1265 |
redo A; |
redo A; |
1266 |
} |
} |
1274 |
0x003E => 1, # > |
0x003E => 1, # > |
1275 |
0x002F => 1, # / |
0x002F => 1, # / |
1276 |
-1 => 1, # EOF |
-1 => 1, # EOF |
1277 |
}->{$self->{next_char}}) { |
}->{$self->{nc}}) { |
1278 |
!!!cp (26); |
!!!cp (26); |
1279 |
## Reconsume. |
## Reconsume. |
1280 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1281 |
!!!emit ({type => CHARACTER_TOKEN, |
!!!emit ({type => CHARACTER_TOKEN, |
1282 |
data => '</' . $self->{state_keyword}, |
data => '</' . $self->{s_kwd}, |
1283 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1284 |
column => $self->{column_prev} - 1 - length $self->{state_keyword}, |
column => $self->{column_prev} - 1 - length $self->{s_kwd}, |
1285 |
}); |
}); |
1286 |
redo A; |
redo A; |
1287 |
} else { |
} else { |
1288 |
!!!cp (27); |
!!!cp (27); |
1289 |
$self->{current_token} |
$self->{ct} |
1290 |
= {type => END_TAG_TOKEN, |
= {type => END_TAG_TOKEN, |
1291 |
tag_name => $self->{last_emitted_start_tag_name}, |
tag_name => $self->{last_stag_name}, |
1292 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1293 |
column => $self->{column_prev} - 1 - length $self->{state_keyword}}; |
column => $self->{column_prev} - 1 - length $self->{s_kwd}}; |
1294 |
$self->{state} = TAG_NAME_STATE; |
$self->{state} = TAG_NAME_STATE; |
1295 |
## Reconsume. |
## Reconsume. |
1296 |
redo A; |
redo A; |
1297 |
} |
} |
1298 |
} |
} |
1299 |
} elsif ($self->{state} == TAG_NAME_STATE) { |
} elsif ($self->{state} == TAG_NAME_STATE) { |
1300 |
if ($self->{next_char} == 0x0009 or # HT |
if ($self->{nc} == 0x0009 or # HT |
1301 |
$self->{next_char} == 0x000A or # LF |
$self->{nc} == 0x000A or # LF |
1302 |
$self->{next_char} == 0x000B or # VT |
$self->{nc} == 0x000B or # VT |
1303 |
$self->{next_char} == 0x000C or # FF |
$self->{nc} == 0x000C or # FF |
1304 |
$self->{next_char} == 0x0020) { # SP |
$self->{nc} == 0x0020) { # SP |
1305 |
!!!cp (34); |
!!!cp (34); |
1306 |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
1307 |
!!!next-input-character; |
!!!next-input-character; |
1308 |
redo A; |
redo A; |
1309 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
1310 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1311 |
!!!cp (35); |
!!!cp (35); |
1312 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1313 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1314 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1315 |
#if ($self->{current_token}->{attributes}) { |
#if ($self->{ct}->{attributes}) { |
1316 |
# ## NOTE: This should never be reached. |
# ## NOTE: This should never be reached. |
1317 |
# !!! cp (36); |
# !!! cp (36); |
1318 |
# !!! parse-error (type => 'end tag attribute'); |
# !!! parse-error (type => 'end tag attribute'); |
1320 |
!!!cp (37); |
!!!cp (37); |
1321 |
#} |
#} |
1322 |
} else { |
} else { |
1323 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1324 |
} |
} |
1325 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1326 |
!!!next-input-character; |
!!!next-input-character; |
1327 |
|
|
1328 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1329 |
|
|
1330 |
redo A; |
redo A; |
1331 |
} elsif (0x0041 <= $self->{next_char} and |
} elsif (0x0041 <= $self->{nc} and |
1332 |
$self->{next_char} <= 0x005A) { # A..Z |
$self->{nc} <= 0x005A) { # A..Z |
1333 |
!!!cp (38); |
!!!cp (38); |
1334 |
$self->{current_token}->{tag_name} .= chr ($self->{next_char} + 0x0020); |
$self->{ct}->{tag_name} .= chr ($self->{nc} + 0x0020); |
1335 |
# start tag or end tag |
# start tag or end tag |
1336 |
## Stay in this state |
## Stay in this state |
1337 |
!!!next-input-character; |
!!!next-input-character; |
1338 |
redo A; |
redo A; |
1339 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
1340 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
1341 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1342 |
!!!cp (39); |
!!!cp (39); |
1343 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1344 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1345 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1346 |
#if ($self->{current_token}->{attributes}) { |
#if ($self->{ct}->{attributes}) { |
1347 |
# ## NOTE: This state should never be reached. |
# ## NOTE: This state should never be reached. |
1348 |
# !!! cp (40); |
# !!! cp (40); |
1349 |
# !!! parse-error (type => 'end tag attribute'); |
# !!! parse-error (type => 'end tag attribute'); |
1351 |
!!!cp (41); |
!!!cp (41); |
1352 |
#} |
#} |
1353 |
} else { |
} else { |
1354 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1355 |
} |
} |
1356 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1357 |
# reconsume |
# reconsume |
1358 |
|
|
1359 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1360 |
|
|
1361 |
redo A; |
redo A; |
1362 |
} elsif ($self->{next_char} == 0x002F) { # / |
} elsif ($self->{nc} == 0x002F) { # / |
1363 |
!!!cp (42); |
!!!cp (42); |
1364 |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
1365 |
!!!next-input-character; |
!!!next-input-character; |
1366 |
redo A; |
redo A; |
1367 |
} else { |
} else { |
1368 |
!!!cp (44); |
!!!cp (44); |
1369 |
$self->{current_token}->{tag_name} .= chr $self->{next_char}; |
$self->{ct}->{tag_name} .= chr $self->{nc}; |
1370 |
# start tag or end tag |
# start tag or end tag |
1371 |
## Stay in the state |
## Stay in the state |
1372 |
!!!next-input-character; |
!!!next-input-character; |
1373 |
redo A; |
redo A; |
1374 |
} |
} |
1375 |
} elsif ($self->{state} == BEFORE_ATTRIBUTE_NAME_STATE) { |
} elsif ($self->{state} == BEFORE_ATTRIBUTE_NAME_STATE) { |
1376 |
if ($self->{next_char} == 0x0009 or # HT |
if ($self->{nc} == 0x0009 or # HT |
1377 |
$self->{next_char} == 0x000A or # LF |
$self->{nc} == 0x000A or # LF |
1378 |
$self->{next_char} == 0x000B or # VT |
$self->{nc} == 0x000B or # VT |
1379 |
$self->{next_char} == 0x000C or # FF |
$self->{nc} == 0x000C or # FF |
1380 |
$self->{next_char} == 0x0020) { # SP |
$self->{nc} == 0x0020) { # SP |
1381 |
!!!cp (45); |
!!!cp (45); |
1382 |
## Stay in the state |
## Stay in the state |
1383 |
!!!next-input-character; |
!!!next-input-character; |
1384 |
redo A; |
redo A; |
1385 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
1386 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1387 |
!!!cp (46); |
!!!cp (46); |
1388 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1389 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1390 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1391 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1392 |
!!!cp (47); |
!!!cp (47); |
1393 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1394 |
} else { |
} else { |
1395 |
!!!cp (48); |
!!!cp (48); |
1396 |
} |
} |
1397 |
} else { |
} else { |
1398 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1399 |
} |
} |
1400 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1401 |
!!!next-input-character; |
!!!next-input-character; |
1402 |
|
|
1403 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1404 |
|
|
1405 |
redo A; |
redo A; |
1406 |
} elsif (0x0041 <= $self->{next_char} and |
} elsif (0x0041 <= $self->{nc} and |
1407 |
$self->{next_char} <= 0x005A) { # A..Z |
$self->{nc} <= 0x005A) { # A..Z |
1408 |
!!!cp (49); |
!!!cp (49); |
1409 |
$self->{current_attribute} |
$self->{ca} |
1410 |
= {name => chr ($self->{next_char} + 0x0020), |
= {name => chr ($self->{nc} + 0x0020), |
1411 |
value => '', |
value => '', |
1412 |
line => $self->{line}, column => $self->{column}}; |
line => $self->{line}, column => $self->{column}}; |
1413 |
$self->{state} = ATTRIBUTE_NAME_STATE; |
$self->{state} = ATTRIBUTE_NAME_STATE; |
1414 |
!!!next-input-character; |
!!!next-input-character; |
1415 |
redo A; |
redo A; |
1416 |
} elsif ($self->{next_char} == 0x002F) { # / |
} elsif ($self->{nc} == 0x002F) { # / |
1417 |
!!!cp (50); |
!!!cp (50); |
1418 |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
1419 |
!!!next-input-character; |
!!!next-input-character; |
1420 |
redo A; |
redo A; |
1421 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
1422 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
1423 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1424 |
!!!cp (52); |
!!!cp (52); |
1425 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1426 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1427 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1428 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1429 |
!!!cp (53); |
!!!cp (53); |
1430 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1431 |
} else { |
} else { |
1432 |
!!!cp (54); |
!!!cp (54); |
1433 |
} |
} |
1434 |
} else { |
} else { |
1435 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1436 |
} |
} |
1437 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1438 |
# reconsume |
# reconsume |
1439 |
|
|
1440 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1441 |
|
|
1442 |
redo A; |
redo A; |
1443 |
} else { |
} else { |
1445 |
0x0022 => 1, # " |
0x0022 => 1, # " |
1446 |
0x0027 => 1, # ' |
0x0027 => 1, # ' |
1447 |
0x003D => 1, # = |
0x003D => 1, # = |
1448 |
}->{$self->{next_char}}) { |
}->{$self->{nc}}) { |
1449 |
!!!cp (55); |
!!!cp (55); |
1450 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
1451 |
} else { |
} else { |
1452 |
!!!cp (56); |
!!!cp (56); |
1453 |
} |
} |
1454 |
$self->{current_attribute} |
$self->{ca} |
1455 |
= {name => chr ($self->{next_char}), |
= {name => chr ($self->{nc}), |
1456 |
value => '', |
value => '', |
1457 |
line => $self->{line}, column => $self->{column}}; |
line => $self->{line}, column => $self->{column}}; |
1458 |
$self->{state} = ATTRIBUTE_NAME_STATE; |
$self->{state} = ATTRIBUTE_NAME_STATE; |
1461 |
} |
} |
1462 |
} elsif ($self->{state} == ATTRIBUTE_NAME_STATE) { |
} elsif ($self->{state} == ATTRIBUTE_NAME_STATE) { |
1463 |
my $before_leave = sub { |
my $before_leave = sub { |
1464 |
if (exists $self->{current_token}->{attributes} # start tag or end tag |
if (exists $self->{ct}->{attributes} # start tag or end tag |
1465 |
->{$self->{current_attribute}->{name}}) { # MUST |
->{$self->{ca}->{name}}) { # MUST |
1466 |
!!!cp (57); |
!!!cp (57); |
1467 |
!!!parse-error (type => 'duplicate attribute', text => $self->{current_attribute}->{name}, line => $self->{current_attribute}->{line}, column => $self->{current_attribute}->{column}); |
!!!parse-error (type => 'duplicate attribute', text => $self->{ca}->{name}, line => $self->{ca}->{line}, column => $self->{ca}->{column}); |
1468 |
## Discard $self->{current_attribute} # MUST |
## Discard $self->{ca} # MUST |
1469 |
} else { |
} else { |
1470 |
!!!cp (58); |
!!!cp (58); |
1471 |
$self->{current_token}->{attributes}->{$self->{current_attribute}->{name}} |
$self->{ct}->{attributes}->{$self->{ca}->{name}} |
1472 |
= $self->{current_attribute}; |
= $self->{ca}; |
1473 |
} |
} |
1474 |
}; # $before_leave |
}; # $before_leave |
1475 |
|
|
1476 |
if ($self->{next_char} == 0x0009 or # HT |
if ($self->{nc} == 0x0009 or # HT |
1477 |
$self->{next_char} == 0x000A or # LF |
$self->{nc} == 0x000A or # LF |
1478 |
$self->{next_char} == 0x000B or # VT |
$self->{nc} == 0x000B or # VT |
1479 |
$self->{next_char} == 0x000C or # FF |
$self->{nc} == 0x000C or # FF |
1480 |
$self->{next_char} == 0x0020) { # SP |
$self->{nc} == 0x0020) { # SP |
1481 |
!!!cp (59); |
!!!cp (59); |
1482 |
$before_leave->(); |
$before_leave->(); |
1483 |
$self->{state} = AFTER_ATTRIBUTE_NAME_STATE; |
$self->{state} = AFTER_ATTRIBUTE_NAME_STATE; |
1484 |
!!!next-input-character; |
!!!next-input-character; |
1485 |
redo A; |
redo A; |
1486 |
} elsif ($self->{next_char} == 0x003D) { # = |
} elsif ($self->{nc} == 0x003D) { # = |
1487 |
!!!cp (60); |
!!!cp (60); |
1488 |
$before_leave->(); |
$before_leave->(); |
1489 |
$self->{state} = BEFORE_ATTRIBUTE_VALUE_STATE; |
$self->{state} = BEFORE_ATTRIBUTE_VALUE_STATE; |
1490 |
!!!next-input-character; |
!!!next-input-character; |
1491 |
redo A; |
redo A; |
1492 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
1493 |
$before_leave->(); |
$before_leave->(); |
1494 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1495 |
!!!cp (61); |
!!!cp (61); |
1496 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1497 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1498 |
!!!cp (62); |
!!!cp (62); |
1499 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1500 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1501 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1502 |
} |
} |
1503 |
} else { |
} else { |
1504 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1505 |
} |
} |
1506 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1507 |
!!!next-input-character; |
!!!next-input-character; |
1508 |
|
|
1509 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1510 |
|
|
1511 |
redo A; |
redo A; |
1512 |
} elsif (0x0041 <= $self->{next_char} and |
} elsif (0x0041 <= $self->{nc} and |
1513 |
$self->{next_char} <= 0x005A) { # A..Z |
$self->{nc} <= 0x005A) { # A..Z |
1514 |
!!!cp (63); |
!!!cp (63); |
1515 |
$self->{current_attribute}->{name} .= chr ($self->{next_char} + 0x0020); |
$self->{ca}->{name} .= chr ($self->{nc} + 0x0020); |
1516 |
## Stay in the state |
## Stay in the state |
1517 |
!!!next-input-character; |
!!!next-input-character; |
1518 |
redo A; |
redo A; |
1519 |
} elsif ($self->{next_char} == 0x002F) { # / |
} elsif ($self->{nc} == 0x002F) { # / |
1520 |
!!!cp (64); |
!!!cp (64); |
1521 |
$before_leave->(); |
$before_leave->(); |
1522 |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
1523 |
!!!next-input-character; |
!!!next-input-character; |
1524 |
redo A; |
redo A; |
1525 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
1526 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
1527 |
$before_leave->(); |
$before_leave->(); |
1528 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1529 |
!!!cp (66); |
!!!cp (66); |
1530 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1531 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1532 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1533 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1534 |
!!!cp (67); |
!!!cp (67); |
1535 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1536 |
} else { |
} else { |
1538 |
!!!cp (68); |
!!!cp (68); |
1539 |
} |
} |
1540 |
} else { |
} else { |
1541 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1542 |
} |
} |
1543 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1544 |
# reconsume |
# reconsume |
1545 |
|
|
1546 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1547 |
|
|
1548 |
redo A; |
redo A; |
1549 |
} else { |
} else { |
1550 |
if ($self->{next_char} == 0x0022 or # " |
if ($self->{nc} == 0x0022 or # " |
1551 |
$self->{next_char} == 0x0027) { # ' |
$self->{nc} == 0x0027) { # ' |
1552 |
!!!cp (69); |
!!!cp (69); |
1553 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
1554 |
} else { |
} else { |
1555 |
!!!cp (70); |
!!!cp (70); |
1556 |
} |
} |
1557 |
$self->{current_attribute}->{name} .= chr ($self->{next_char}); |
$self->{ca}->{name} .= chr ($self->{nc}); |
1558 |
## Stay in the state |
## Stay in the state |
1559 |
!!!next-input-character; |
!!!next-input-character; |
1560 |
redo A; |
redo A; |
1561 |
} |
} |
1562 |
} elsif ($self->{state} == AFTER_ATTRIBUTE_NAME_STATE) { |
} elsif ($self->{state} == AFTER_ATTRIBUTE_NAME_STATE) { |
1563 |
if ($self->{next_char} == 0x0009 or # HT |
if ($self->{nc} == 0x0009 or # HT |
1564 |
$self->{next_char} == 0x000A or # LF |
$self->{nc} == 0x000A or # LF |
1565 |
$self->{next_char} == 0x000B or # VT |
$self->{nc} == 0x000B or # VT |
1566 |
$self->{next_char} == 0x000C or # FF |
$self->{nc} == 0x000C or # FF |
1567 |
$self->{next_char} == 0x0020) { # SP |
$self->{nc} == 0x0020) { # SP |
1568 |
!!!cp (71); |
!!!cp (71); |
1569 |
## Stay in the state |
## Stay in the state |
1570 |
!!!next-input-character; |
!!!next-input-character; |
1571 |
redo A; |
redo A; |
1572 |
} elsif ($self->{next_char} == 0x003D) { # = |
} elsif ($self->{nc} == 0x003D) { # = |
1573 |
!!!cp (72); |
!!!cp (72); |
1574 |
$self->{state} = BEFORE_ATTRIBUTE_VALUE_STATE; |
$self->{state} = BEFORE_ATTRIBUTE_VALUE_STATE; |
1575 |
!!!next-input-character; |
!!!next-input-character; |
1576 |
redo A; |
redo A; |
1577 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
1578 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1579 |
!!!cp (73); |
!!!cp (73); |
1580 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1581 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1582 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1583 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1584 |
!!!cp (74); |
!!!cp (74); |
1585 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1586 |
} else { |
} else { |
1588 |
!!!cp (75); |
!!!cp (75); |
1589 |
} |
} |
1590 |
} else { |
} else { |
1591 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1592 |
} |
} |
1593 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1594 |
!!!next-input-character; |
!!!next-input-character; |
1595 |
|
|
1596 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1597 |
|
|
1598 |
redo A; |
redo A; |
1599 |
} elsif (0x0041 <= $self->{next_char} and |
} elsif (0x0041 <= $self->{nc} and |
1600 |
$self->{next_char} <= 0x005A) { # A..Z |
$self->{nc} <= 0x005A) { # A..Z |
1601 |
!!!cp (76); |
!!!cp (76); |
1602 |
$self->{current_attribute} |
$self->{ca} |
1603 |
= {name => chr ($self->{next_char} + 0x0020), |
= {name => chr ($self->{nc} + 0x0020), |
1604 |
value => '', |
value => '', |
1605 |
line => $self->{line}, column => $self->{column}}; |
line => $self->{line}, column => $self->{column}}; |
1606 |
$self->{state} = ATTRIBUTE_NAME_STATE; |
$self->{state} = ATTRIBUTE_NAME_STATE; |
1607 |
!!!next-input-character; |
!!!next-input-character; |
1608 |
redo A; |
redo A; |
1609 |
} elsif ($self->{next_char} == 0x002F) { # / |
} elsif ($self->{nc} == 0x002F) { # / |
1610 |
!!!cp (77); |
!!!cp (77); |
1611 |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
1612 |
!!!next-input-character; |
!!!next-input-character; |
1613 |
redo A; |
redo A; |
1614 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
1615 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
1616 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1617 |
!!!cp (79); |
!!!cp (79); |
1618 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1619 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1620 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1621 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1622 |
!!!cp (80); |
!!!cp (80); |
1623 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1624 |
} else { |
} else { |
1626 |
!!!cp (81); |
!!!cp (81); |
1627 |
} |
} |
1628 |
} else { |
} else { |
1629 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1630 |
} |
} |
1631 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1632 |
# reconsume |
# reconsume |
1633 |
|
|
1634 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1635 |
|
|
1636 |
redo A; |
redo A; |
1637 |
} else { |
} else { |
1638 |
if ($self->{next_char} == 0x0022 or # " |
if ($self->{nc} == 0x0022 or # " |
1639 |
$self->{next_char} == 0x0027) { # ' |
$self->{nc} == 0x0027) { # ' |
1640 |
!!!cp (78); |
!!!cp (78); |
1641 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
1642 |
} else { |
} else { |
1643 |
!!!cp (82); |
!!!cp (82); |
1644 |
} |
} |
1645 |
$self->{current_attribute} |
$self->{ca} |
1646 |
= {name => chr ($self->{next_char}), |
= {name => chr ($self->{nc}), |
1647 |
value => '', |
value => '', |
1648 |
line => $self->{line}, column => $self->{column}}; |
line => $self->{line}, column => $self->{column}}; |
1649 |
$self->{state} = ATTRIBUTE_NAME_STATE; |
$self->{state} = ATTRIBUTE_NAME_STATE; |
1651 |
redo A; |
redo A; |
1652 |
} |
} |
1653 |
} elsif ($self->{state} == BEFORE_ATTRIBUTE_VALUE_STATE) { |
} elsif ($self->{state} == BEFORE_ATTRIBUTE_VALUE_STATE) { |
1654 |
if ($self->{next_char} == 0x0009 or # HT |
if ($self->{nc} == 0x0009 or # HT |
1655 |
$self->{next_char} == 0x000A or # LF |
$self->{nc} == 0x000A or # LF |
1656 |
$self->{next_char} == 0x000B or # VT |
$self->{nc} == 0x000B or # VT |
1657 |
$self->{next_char} == 0x000C or # FF |
$self->{nc} == 0x000C or # FF |
1658 |
$self->{next_char} == 0x0020) { # SP |
$self->{nc} == 0x0020) { # SP |
1659 |
!!!cp (83); |
!!!cp (83); |
1660 |
## Stay in the state |
## Stay in the state |
1661 |
!!!next-input-character; |
!!!next-input-character; |
1662 |
redo A; |
redo A; |
1663 |
} elsif ($self->{next_char} == 0x0022) { # " |
} elsif ($self->{nc} == 0x0022) { # " |
1664 |
!!!cp (84); |
!!!cp (84); |
1665 |
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
1666 |
!!!next-input-character; |
!!!next-input-character; |
1667 |
redo A; |
redo A; |
1668 |
} elsif ($self->{next_char} == 0x0026) { # & |
} elsif ($self->{nc} == 0x0026) { # & |
1669 |
!!!cp (85); |
!!!cp (85); |
1670 |
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
1671 |
## reconsume |
## reconsume |
1672 |
redo A; |
redo A; |
1673 |
} elsif ($self->{next_char} == 0x0027) { # ' |
} elsif ($self->{nc} == 0x0027) { # ' |
1674 |
!!!cp (86); |
!!!cp (86); |
1675 |
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
1676 |
!!!next-input-character; |
!!!next-input-character; |
1677 |
redo A; |
redo A; |
1678 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
1679 |
!!!parse-error (type => 'empty unquoted attribute value'); |
!!!parse-error (type => 'empty unquoted attribute value'); |
1680 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1681 |
!!!cp (87); |
!!!cp (87); |
1682 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1683 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1684 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1685 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1686 |
!!!cp (88); |
!!!cp (88); |
1687 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1688 |
} else { |
} else { |
1690 |
!!!cp (89); |
!!!cp (89); |
1691 |
} |
} |
1692 |
} else { |
} else { |
1693 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1694 |
} |
} |
1695 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1696 |
!!!next-input-character; |
!!!next-input-character; |
1697 |
|
|
1698 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1699 |
|
|
1700 |
redo A; |
redo A; |
1701 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
1702 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
1703 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1704 |
!!!cp (90); |
!!!cp (90); |
1705 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1706 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1707 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1708 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1709 |
!!!cp (91); |
!!!cp (91); |
1710 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1711 |
} else { |
} else { |
1713 |
!!!cp (92); |
!!!cp (92); |
1714 |
} |
} |
1715 |
} else { |
} else { |
1716 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1717 |
} |
} |
1718 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1719 |
## reconsume |
## reconsume |
1720 |
|
|
1721 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1722 |
|
|
1723 |
redo A; |
redo A; |
1724 |
} else { |
} else { |
1725 |
if ($self->{next_char} == 0x003D) { # = |
if ($self->{nc} == 0x003D) { # = |
1726 |
!!!cp (93); |
!!!cp (93); |
1727 |
!!!parse-error (type => 'bad attribute value'); |
!!!parse-error (type => 'bad attribute value'); |
1728 |
} else { |
} else { |
1729 |
!!!cp (94); |
!!!cp (94); |
1730 |
} |
} |
1731 |
$self->{current_attribute}->{value} .= chr ($self->{next_char}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1732 |
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
1733 |
!!!next-input-character; |
!!!next-input-character; |
1734 |
redo A; |
redo A; |
1735 |
} |
} |
1736 |
} elsif ($self->{state} == ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE) { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE) { |
1737 |
if ($self->{next_char} == 0x0022) { # " |
if ($self->{nc} == 0x0022) { # " |
1738 |
!!!cp (95); |
!!!cp (95); |
1739 |
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
1740 |
!!!next-input-character; |
!!!next-input-character; |
1741 |
redo A; |
redo A; |
1742 |
} elsif ($self->{next_char} == 0x0026) { # & |
} elsif ($self->{nc} == 0x0026) { # & |
1743 |
!!!cp (96); |
!!!cp (96); |
1744 |
## NOTE: In the spec, the tokenizer is switched to the |
## NOTE: In the spec, the tokenizer is switched to the |
1745 |
## "entity in attribute value state". In this implementation, the |
## "entity in attribute value state". In this implementation, the |
1746 |
## tokenizer is switched to the |ENTITY_STATE|, which is an |
## tokenizer is switched to the |ENTITY_STATE|, which is an |
1747 |
## implementation of the "consume a character reference" algorithm. |
## implementation of the "consume a character reference" algorithm. |
1748 |
$self->{prev_state} = $self->{state}; |
$self->{prev_state} = $self->{state}; |
1749 |
$self->{entity_additional} = 0x0022; # " |
$self->{entity_add} = 0x0022; # " |
1750 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1751 |
!!!next-input-character; |
!!!next-input-character; |
1752 |
redo A; |
redo A; |
1753 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
1754 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
1755 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1756 |
!!!cp (97); |
!!!cp (97); |
1757 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1758 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1759 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1760 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1761 |
!!!cp (98); |
!!!cp (98); |
1762 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1763 |
} else { |
} else { |
1765 |
!!!cp (99); |
!!!cp (99); |
1766 |
} |
} |
1767 |
} else { |
} else { |
1768 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1769 |
} |
} |
1770 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1771 |
## reconsume |
## reconsume |
1772 |
|
|
1773 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1774 |
|
|
1775 |
redo A; |
redo A; |
1776 |
} else { |
} else { |
1777 |
!!!cp (100); |
!!!cp (100); |
1778 |
$self->{current_attribute}->{value} .= chr ($self->{next_char}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1779 |
$self->{read_until}->($self->{current_attribute}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1780 |
q["&], |
q["&], |
1781 |
length $self->{current_attribute}->{value}); |
length $self->{ca}->{value}); |
1782 |
|
|
1783 |
## Stay in the state |
## Stay in the state |
1784 |
!!!next-input-character; |
!!!next-input-character; |
1785 |
redo A; |
redo A; |
1786 |
} |
} |
1787 |
} elsif ($self->{state} == ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE) { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE) { |
1788 |
if ($self->{next_char} == 0x0027) { # ' |
if ($self->{nc} == 0x0027) { # ' |
1789 |
!!!cp (101); |
!!!cp (101); |
1790 |
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
1791 |
!!!next-input-character; |
!!!next-input-character; |
1792 |
redo A; |
redo A; |
1793 |
} elsif ($self->{next_char} == 0x0026) { # & |
} elsif ($self->{nc} == 0x0026) { # & |
1794 |
!!!cp (102); |
!!!cp (102); |
1795 |
## NOTE: In the spec, the tokenizer is switched to the |
## NOTE: In the spec, the tokenizer is switched to the |
1796 |
## "entity in attribute value state". In this implementation, the |
## "entity in attribute value state". In this implementation, the |
1797 |
## tokenizer is switched to the |ENTITY_STATE|, which is an |
## tokenizer is switched to the |ENTITY_STATE|, which is an |
1798 |
## implementation of the "consume a character reference" algorithm. |
## implementation of the "consume a character reference" algorithm. |
1799 |
$self->{entity_additional} = 0x0027; # ' |
$self->{entity_add} = 0x0027; # ' |
1800 |
$self->{prev_state} = $self->{state}; |
$self->{prev_state} = $self->{state}; |
1801 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1802 |
!!!next-input-character; |
!!!next-input-character; |
1803 |
redo A; |
redo A; |
1804 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
1805 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
1806 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1807 |
!!!cp (103); |
!!!cp (103); |
1808 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1809 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1810 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1811 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1812 |
!!!cp (104); |
!!!cp (104); |
1813 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1814 |
} else { |
} else { |
1816 |
!!!cp (105); |
!!!cp (105); |
1817 |
} |
} |
1818 |
} else { |
} else { |
1819 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1820 |
} |
} |
1821 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1822 |
## reconsume |
## reconsume |
1823 |
|
|
1824 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1825 |
|
|
1826 |
redo A; |
redo A; |
1827 |
} else { |
} else { |
1828 |
!!!cp (106); |
!!!cp (106); |
1829 |
$self->{current_attribute}->{value} .= chr ($self->{next_char}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1830 |
$self->{read_until}->($self->{current_attribute}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1831 |
q['&], |
q['&], |
1832 |
length $self->{current_attribute}->{value}); |
length $self->{ca}->{value}); |
1833 |
|
|
1834 |
## Stay in the state |
## Stay in the state |
1835 |
!!!next-input-character; |
!!!next-input-character; |
1836 |
redo A; |
redo A; |
1837 |
} |
} |
1838 |
} elsif ($self->{state} == ATTRIBUTE_VALUE_UNQUOTED_STATE) { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_UNQUOTED_STATE) { |
1839 |
if ($self->{next_char} == 0x0009 or # HT |
if ($self->{nc} == 0x0009 or # HT |
1840 |
$self->{next_char} == 0x000A or # LF |
$self->{nc} == 0x000A or # LF |
1841 |
$self->{next_char} == 0x000B or # HT |
$self->{nc} == 0x000B or # HT |
1842 |
$self->{next_char} == 0x000C or # FF |
$self->{nc} == 0x000C or # FF |
1843 |
$self->{next_char} == 0x0020) { # SP |
$self->{nc} == 0x0020) { # SP |
1844 |
!!!cp (107); |
!!!cp (107); |
1845 |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
1846 |
!!!next-input-character; |
!!!next-input-character; |
1847 |
redo A; |
redo A; |
1848 |
} elsif ($self->{next_char} == 0x0026) { # & |
} elsif ($self->{nc} == 0x0026) { # & |
1849 |
!!!cp (108); |
!!!cp (108); |
1850 |
## NOTE: In the spec, the tokenizer is switched to the |
## NOTE: In the spec, the tokenizer is switched to the |
1851 |
## "entity in attribute value state". In this implementation, the |
## "entity in attribute value state". In this implementation, the |
1852 |
## tokenizer is switched to the |ENTITY_STATE|, which is an |
## tokenizer is switched to the |ENTITY_STATE|, which is an |
1853 |
## implementation of the "consume a character reference" algorithm. |
## implementation of the "consume a character reference" algorithm. |
1854 |
$self->{entity_additional} = -1; |
$self->{entity_add} = -1; |
1855 |
$self->{prev_state} = $self->{state}; |
$self->{prev_state} = $self->{state}; |
1856 |
$self->{state} = ENTITY_STATE; |
$self->{state} = ENTITY_STATE; |
1857 |
!!!next-input-character; |
!!!next-input-character; |
1858 |
redo A; |
redo A; |
1859 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
1860 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1861 |
!!!cp (109); |
!!!cp (109); |
1862 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1863 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1864 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1865 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1866 |
!!!cp (110); |
!!!cp (110); |
1867 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1868 |
} else { |
} else { |
1870 |
!!!cp (111); |
!!!cp (111); |
1871 |
} |
} |
1872 |
} else { |
} else { |
1873 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1874 |
} |
} |
1875 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1876 |
!!!next-input-character; |
!!!next-input-character; |
1877 |
|
|
1878 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1879 |
|
|
1880 |
redo A; |
redo A; |
1881 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
1882 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
1883 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1884 |
!!!cp (112); |
!!!cp (112); |
1885 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1886 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1887 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1888 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1889 |
!!!cp (113); |
!!!cp (113); |
1890 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1891 |
} else { |
} else { |
1893 |
!!!cp (114); |
!!!cp (114); |
1894 |
} |
} |
1895 |
} else { |
} else { |
1896 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1897 |
} |
} |
1898 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1899 |
## reconsume |
## reconsume |
1900 |
|
|
1901 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1902 |
|
|
1903 |
redo A; |
redo A; |
1904 |
} else { |
} else { |
1906 |
0x0022 => 1, # " |
0x0022 => 1, # " |
1907 |
0x0027 => 1, # ' |
0x0027 => 1, # ' |
1908 |
0x003D => 1, # = |
0x003D => 1, # = |
1909 |
}->{$self->{next_char}}) { |
}->{$self->{nc}}) { |
1910 |
!!!cp (115); |
!!!cp (115); |
1911 |
!!!parse-error (type => 'bad attribute value'); |
!!!parse-error (type => 'bad attribute value'); |
1912 |
} else { |
} else { |
1913 |
!!!cp (116); |
!!!cp (116); |
1914 |
} |
} |
1915 |
$self->{current_attribute}->{value} .= chr ($self->{next_char}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1916 |
$self->{read_until}->($self->{current_attribute}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1917 |
q["'=& >], |
q["'=& >], |
1918 |
length $self->{current_attribute}->{value}); |
length $self->{ca}->{value}); |
1919 |
|
|
1920 |
## Stay in the state |
## Stay in the state |
1921 |
!!!next-input-character; |
!!!next-input-character; |
1922 |
redo A; |
redo A; |
1923 |
} |
} |
1924 |
} elsif ($self->{state} == AFTER_ATTRIBUTE_VALUE_QUOTED_STATE) { |
} elsif ($self->{state} == AFTER_ATTRIBUTE_VALUE_QUOTED_STATE) { |
1925 |
if ($self->{next_char} == 0x0009 or # HT |
if ($self->{nc} == 0x0009 or # HT |
1926 |
$self->{next_char} == 0x000A or # LF |
$self->{nc} == 0x000A or # LF |
1927 |
$self->{next_char} == 0x000B or # VT |
$self->{nc} == 0x000B or # VT |
1928 |
$self->{next_char} == 0x000C or # FF |
$self->{nc} == 0x000C or # FF |
1929 |
$self->{next_char} == 0x0020) { # SP |
$self->{nc} == 0x0020) { # SP |
1930 |
!!!cp (118); |
!!!cp (118); |
1931 |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
1932 |
!!!next-input-character; |
!!!next-input-character; |
1933 |
redo A; |
redo A; |
1934 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
1935 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1936 |
!!!cp (119); |
!!!cp (119); |
1937 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1938 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1939 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1940 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1941 |
!!!cp (120); |
!!!cp (120); |
1942 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1943 |
} else { |
} else { |
1945 |
!!!cp (121); |
!!!cp (121); |
1946 |
} |
} |
1947 |
} else { |
} else { |
1948 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1949 |
} |
} |
1950 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1951 |
!!!next-input-character; |
!!!next-input-character; |
1952 |
|
|
1953 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1954 |
|
|
1955 |
redo A; |
redo A; |
1956 |
} elsif ($self->{next_char} == 0x002F) { # / |
} elsif ($self->{nc} == 0x002F) { # / |
1957 |
!!!cp (122); |
!!!cp (122); |
1958 |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
1959 |
!!!next-input-character; |
!!!next-input-character; |
1960 |
redo A; |
redo A; |
1961 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
1962 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
1963 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1964 |
!!!cp (122.3); |
!!!cp (122.3); |
1965 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1966 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1967 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1968 |
!!!cp (122.1); |
!!!cp (122.1); |
1969 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1970 |
} else { |
} else { |
1972 |
!!!cp (122.2); |
!!!cp (122.2); |
1973 |
} |
} |
1974 |
} else { |
} else { |
1975 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1976 |
} |
} |
1977 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1978 |
## Reconsume. |
## Reconsume. |
1979 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1980 |
redo A; |
redo A; |
1981 |
} else { |
} else { |
1982 |
!!!cp ('124.1'); |
!!!cp ('124.1'); |
1986 |
redo A; |
redo A; |
1987 |
} |
} |
1988 |
} elsif ($self->{state} == SELF_CLOSING_START_TAG_STATE) { |
} elsif ($self->{state} == SELF_CLOSING_START_TAG_STATE) { |
1989 |
if ($self->{next_char} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
1990 |
if ($self->{current_token}->{type} == END_TAG_TOKEN) { |
if ($self->{ct}->{type} == END_TAG_TOKEN) { |
1991 |
!!!cp ('124.2'); |
!!!cp ('124.2'); |
1992 |
!!!parse-error (type => 'nestc', token => $self->{current_token}); |
!!!parse-error (type => 'nestc', token => $self->{ct}); |
1993 |
## TODO: Different type than slash in start tag |
## TODO: Different type than slash in start tag |
1994 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1995 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1996 |
!!!cp ('124.4'); |
!!!cp ('124.4'); |
1997 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
1998 |
} else { |
} else { |
2007 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2008 |
!!!next-input-character; |
!!!next-input-character; |
2009 |
|
|
2010 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
2011 |
|
|
2012 |
redo A; |
redo A; |
2013 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2014 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
2015 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
2016 |
!!!cp (124.7); |
!!!cp (124.7); |
2017 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
2018 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
2019 |
if ($self->{current_token}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
2020 |
!!!cp (124.5); |
!!!cp (124.5); |
2021 |
!!!parse-error (type => 'end tag attribute'); |
!!!parse-error (type => 'end tag attribute'); |
2022 |
} else { |
} else { |
2024 |
!!!cp (124.6); |
!!!cp (124.6); |
2025 |
} |
} |
2026 |
} else { |
} else { |
2027 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
2028 |
} |
} |
2029 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2030 |
## Reconsume. |
## Reconsume. |
2031 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
2032 |
redo A; |
redo A; |
2033 |
} else { |
} else { |
2034 |
!!!cp ('124.4'); |
!!!cp ('124.4'); |
2044 |
## NOTE: Unlike spec's "bogus comment state", this implementation |
## NOTE: Unlike spec's "bogus comment state", this implementation |
2045 |
## consumes characters one-by-one basis. |
## consumes characters one-by-one basis. |
2046 |
|
|
2047 |
if ($self->{next_char} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
2048 |
!!!cp (124); |
!!!cp (124); |
2049 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2050 |
!!!next-input-character; |
!!!next-input-character; |
2051 |
|
|
2052 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{ct}); # comment |
2053 |
redo A; |
redo A; |
2054 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2055 |
!!!cp (125); |
!!!cp (125); |
2056 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2057 |
## reconsume |
## reconsume |
2058 |
|
|
2059 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{ct}); # comment |
2060 |
redo A; |
redo A; |
2061 |
} else { |
} else { |
2062 |
!!!cp (126); |
!!!cp (126); |
2063 |
$self->{current_token}->{data} .= chr ($self->{next_char}); # comment |
$self->{ct}->{data} .= chr ($self->{nc}); # comment |
2064 |
$self->{read_until}->($self->{current_token}->{data}, |
$self->{read_until}->($self->{ct}->{data}, |
2065 |
q[>], |
q[>], |
2066 |
length $self->{current_token}->{data}); |
length $self->{ct}->{data}); |
2067 |
|
|
2068 |
## Stay in the state. |
## Stay in the state. |
2069 |
!!!next-input-character; |
!!!next-input-character; |
2072 |
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
2073 |
## (only happen if PCDATA state) |
## (only happen if PCDATA state) |
2074 |
|
|
2075 |
if ($self->{next_char} == 0x002D) { # - |
if ($self->{nc} == 0x002D) { # - |
2076 |
!!!cp (133); |
!!!cp (133); |
2077 |
$self->{state} = MD_HYPHEN_STATE; |
$self->{state} = MD_HYPHEN_STATE; |
2078 |
!!!next-input-character; |
!!!next-input-character; |
2079 |
redo A; |
redo A; |
2080 |
} elsif ($self->{next_char} == 0x0044 or # D |
} elsif ($self->{nc} == 0x0044 or # D |
2081 |
$self->{next_char} == 0x0064) { # d |
$self->{nc} == 0x0064) { # d |
2082 |
## ASCII case-insensitive. |
## ASCII case-insensitive. |
2083 |
!!!cp (130); |
!!!cp (130); |
2084 |
$self->{state} = MD_DOCTYPE_STATE; |
$self->{state} = MD_DOCTYPE_STATE; |
2085 |
$self->{state_keyword} = chr $self->{next_char}; |
$self->{s_kwd} = chr $self->{nc}; |
2086 |
!!!next-input-character; |
!!!next-input-character; |
2087 |
redo A; |
redo A; |
2088 |
} elsif ($self->{insertion_mode} & IN_FOREIGN_CONTENT_IM and |
} elsif ($self->{insertion_mode} & IN_FOREIGN_CONTENT_IM and |
2089 |
$self->{open_elements}->[-1]->[1] & FOREIGN_EL and |
$self->{open_elements}->[-1]->[1] & FOREIGN_EL and |
2090 |
$self->{next_char} == 0x005B) { # [ |
$self->{nc} == 0x005B) { # [ |
2091 |
!!!cp (135.4); |
!!!cp (135.4); |
2092 |
$self->{state} = MD_CDATA_STATE; |
$self->{state} = MD_CDATA_STATE; |
2093 |
$self->{state_keyword} = '['; |
$self->{s_kwd} = '['; |
2094 |
!!!next-input-character; |
!!!next-input-character; |
2095 |
redo A; |
redo A; |
2096 |
} else { |
} else { |
2102 |
column => $self->{column_prev} - 1); |
column => $self->{column_prev} - 1); |
2103 |
## Reconsume. |
## Reconsume. |
2104 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
2105 |
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
$self->{ct} = {type => COMMENT_TOKEN, data => '', |
2106 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2107 |
column => $self->{column_prev} - 1, |
column => $self->{column_prev} - 1, |
2108 |
}; |
}; |
2109 |
redo A; |
redo A; |
2110 |
} elsif ($self->{state} == MD_HYPHEN_STATE) { |
} elsif ($self->{state} == MD_HYPHEN_STATE) { |
2111 |
if ($self->{next_char} == 0x002D) { # - |
if ($self->{nc} == 0x002D) { # - |
2112 |
!!!cp (127); |
!!!cp (127); |
2113 |
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
$self->{ct} = {type => COMMENT_TOKEN, data => '', |
2114 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2115 |
column => $self->{column_prev} - 2, |
column => $self->{column_prev} - 2, |
2116 |
}; |
}; |
2124 |
column => $self->{column_prev} - 2); |
column => $self->{column_prev} - 2); |
2125 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
2126 |
## Reconsume. |
## Reconsume. |
2127 |
$self->{current_token} = {type => COMMENT_TOKEN, |
$self->{ct} = {type => COMMENT_TOKEN, |
2128 |
data => '-', |
data => '-', |
2129 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2130 |
column => $self->{column_prev} - 2, |
column => $self->{column_prev} - 2, |
2133 |
} |
} |
2134 |
} elsif ($self->{state} == MD_DOCTYPE_STATE) { |
} elsif ($self->{state} == MD_DOCTYPE_STATE) { |
2135 |
## ASCII case-insensitive. |
## ASCII case-insensitive. |
2136 |
if ($self->{next_char} == [ |
if ($self->{nc} == [ |
2137 |
undef, |
undef, |
2138 |
0x004F, # O |
0x004F, # O |
2139 |
0x0043, # C |
0x0043, # C |
2140 |
0x0054, # T |
0x0054, # T |
2141 |
0x0059, # Y |
0x0059, # Y |
2142 |
0x0050, # P |
0x0050, # P |
2143 |
]->[length $self->{state_keyword}] or |
]->[length $self->{s_kwd}] or |
2144 |
$self->{next_char} == [ |
$self->{nc} == [ |
2145 |
undef, |
undef, |
2146 |
0x006F, # o |
0x006F, # o |
2147 |
0x0063, # c |
0x0063, # c |
2148 |
0x0074, # t |
0x0074, # t |
2149 |
0x0079, # y |
0x0079, # y |
2150 |
0x0070, # p |
0x0070, # p |
2151 |
]->[length $self->{state_keyword}]) { |
]->[length $self->{s_kwd}]) { |
2152 |
!!!cp (131); |
!!!cp (131); |
2153 |
## Stay in the state. |
## Stay in the state. |
2154 |
$self->{state_keyword} .= chr $self->{next_char}; |
$self->{s_kwd} .= chr $self->{nc}; |
2155 |
!!!next-input-character; |
!!!next-input-character; |
2156 |
redo A; |
redo A; |
2157 |
} elsif ((length $self->{state_keyword}) == 6 and |
} elsif ((length $self->{s_kwd}) == 6 and |
2158 |
($self->{next_char} == 0x0045 or # E |
($self->{nc} == 0x0045 or # E |
2159 |
$self->{next_char} == 0x0065)) { # e |
$self->{nc} == 0x0065)) { # e |
2160 |
!!!cp (129); |
!!!cp (129); |
2161 |
$self->{state} = DOCTYPE_STATE; |
$self->{state} = DOCTYPE_STATE; |
2162 |
$self->{current_token} = {type => DOCTYPE_TOKEN, |
$self->{ct} = {type => DOCTYPE_TOKEN, |
2163 |
quirks => 1, |
quirks => 1, |
2164 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2165 |
column => $self->{column_prev} - 7, |
column => $self->{column_prev} - 7, |
2170 |
!!!cp (132); |
!!!cp (132); |
2171 |
!!!parse-error (type => 'bogus comment', |
!!!parse-error (type => 'bogus comment', |
2172 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2173 |
column => $self->{column_prev} - 1 - length $self->{state_keyword}); |
column => $self->{column_prev} - 1 - length $self->{s_kwd}); |
2174 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
2175 |
## Reconsume. |
## Reconsume. |
2176 |
$self->{current_token} = {type => COMMENT_TOKEN, |
$self->{ct} = {type => COMMENT_TOKEN, |
2177 |
data => $self->{state_keyword}, |
data => $self->{s_kwd}, |
2178 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2179 |
column => $self->{column_prev} - 1 - length $self->{state_keyword}, |
column => $self->{column_prev} - 1 - length $self->{s_kwd}, |
2180 |
}; |
}; |
2181 |
redo A; |
redo A; |
2182 |
} |
} |
2183 |
} elsif ($self->{state} == MD_CDATA_STATE) { |
} elsif ($self->{state} == MD_CDATA_STATE) { |
2184 |
if ($self->{next_char} == { |
if ($self->{nc} == { |
2185 |
'[' => 0x0043, # C |
'[' => 0x0043, # C |
2186 |
'[C' => 0x0044, # D |
'[C' => 0x0044, # D |
2187 |
'[CD' => 0x0041, # A |
'[CD' => 0x0041, # A |
2188 |
'[CDA' => 0x0054, # T |
'[CDA' => 0x0054, # T |
2189 |
'[CDAT' => 0x0041, # A |
'[CDAT' => 0x0041, # A |
2190 |
}->{$self->{state_keyword}}) { |
}->{$self->{s_kwd}}) { |
2191 |
!!!cp (135.1); |
!!!cp (135.1); |
2192 |
## Stay in the state. |
## Stay in the state. |
2193 |
$self->{state_keyword} .= chr $self->{next_char}; |
$self->{s_kwd} .= chr $self->{nc}; |
2194 |
!!!next-input-character; |
!!!next-input-character; |
2195 |
redo A; |
redo A; |
2196 |
} elsif ($self->{state_keyword} eq '[CDATA' and |
} elsif ($self->{s_kwd} eq '[CDATA' and |
2197 |
$self->{next_char} == 0x005B) { # [ |
$self->{nc} == 0x005B) { # [ |
2198 |
!!!cp (135.2); |
!!!cp (135.2); |
2199 |
$self->{current_token} = {type => CHARACTER_TOKEN, |
$self->{ct} = {type => CHARACTER_TOKEN, |
2200 |
data => '', |
data => '', |
2201 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2202 |
column => $self->{column_prev} - 7}; |
column => $self->{column_prev} - 7}; |
2207 |
!!!cp (135.3); |
!!!cp (135.3); |
2208 |
!!!parse-error (type => 'bogus comment', |
!!!parse-error (type => 'bogus comment', |
2209 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2210 |
column => $self->{column_prev} - 1 - length $self->{state_keyword}); |
column => $self->{column_prev} - 1 - length $self->{s_kwd}); |
2211 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
2212 |
## Reconsume. |
## Reconsume. |
2213 |
$self->{current_token} = {type => COMMENT_TOKEN, |
$self->{ct} = {type => COMMENT_TOKEN, |
2214 |
data => $self->{state_keyword}, |
data => $self->{s_kwd}, |
2215 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2216 |
column => $self->{column_prev} - 1 - length $self->{state_keyword}, |
column => $self->{column_prev} - 1 - length $self->{s_kwd}, |
2217 |
}; |
}; |
2218 |
redo A; |
redo A; |
2219 |
} |
} |
2220 |
} elsif ($self->{state} == COMMENT_START_STATE) { |
} elsif ($self->{state} == COMMENT_START_STATE) { |
2221 |
if ($self->{next_char} == 0x002D) { # - |
if ($self->{nc} == 0x002D) { # - |
2222 |
!!!cp (137); |
!!!cp (137); |
2223 |
$self->{state} = COMMENT_START_DASH_STATE; |
$self->{state} = COMMENT_START_DASH_STATE; |
2224 |
!!!next-input-character; |
!!!next-input-character; |
2225 |
redo A; |
redo A; |
2226 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2227 |
!!!cp (138); |
!!!cp (138); |
2228 |
!!!parse-error (type => 'bogus comment'); |
!!!parse-error (type => 'bogus comment'); |
2229 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2230 |
!!!next-input-character; |
!!!next-input-character; |
2231 |
|
|
2232 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{ct}); # comment |
2233 |
|
|
2234 |
redo A; |
redo A; |
2235 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2236 |
!!!cp (139); |
!!!cp (139); |
2237 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
2238 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2239 |
## reconsume |
## reconsume |
2240 |
|
|
2241 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{ct}); # comment |
2242 |
|
|
2243 |
redo A; |
redo A; |
2244 |
} else { |
} else { |
2245 |
!!!cp (140); |
!!!cp (140); |
2246 |
$self->{current_token}->{data} # comment |
$self->{ct}->{data} # comment |
2247 |
.= chr ($self->{next_char}); |
.= chr ($self->{nc}); |
2248 |
$self->{state} = COMMENT_STATE; |
$self->{state} = COMMENT_STATE; |
2249 |
!!!next-input-character; |
!!!next-input-character; |
2250 |
redo A; |
redo A; |
2251 |
} |
} |
2252 |
} elsif ($self->{state} == COMMENT_START_DASH_STATE) { |
} elsif ($self->{state} == COMMENT_START_DASH_STATE) { |
2253 |
if ($self->{next_char} == 0x002D) { # - |
if ($self->{nc} == 0x002D) { # - |
2254 |
!!!cp (141); |
!!!cp (141); |
2255 |
$self->{state} = COMMENT_END_STATE; |
$self->{state} = COMMENT_END_STATE; |
2256 |
!!!next-input-character; |
!!!next-input-character; |
2257 |
redo A; |
redo A; |
2258 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2259 |
!!!cp (142); |
!!!cp (142); |
2260 |
!!!parse-error (type => 'bogus comment'); |
!!!parse-error (type => 'bogus comment'); |
2261 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2262 |
!!!next-input-character; |
!!!next-input-character; |
2263 |
|
|
2264 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{ct}); # comment |
2265 |
|
|
2266 |
redo A; |
redo A; |
2267 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2268 |
!!!cp (143); |
!!!cp (143); |
2269 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
2270 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2271 |
## reconsume |
## reconsume |
2272 |
|
|
2273 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{ct}); # comment |
2274 |
|
|
2275 |
redo A; |
redo A; |
2276 |
} else { |
} else { |
2277 |
!!!cp (144); |
!!!cp (144); |
2278 |
$self->{current_token}->{data} # comment |
$self->{ct}->{data} # comment |
2279 |
.= '-' . chr ($self->{next_char}); |
.= '-' . chr ($self->{nc}); |
2280 |
$self->{state} = COMMENT_STATE; |
$self->{state} = COMMENT_STATE; |
2281 |
!!!next-input-character; |
!!!next-input-character; |
2282 |
redo A; |
redo A; |
2283 |
} |
} |
2284 |
} elsif ($self->{state} == COMMENT_STATE) { |
} elsif ($self->{state} == COMMENT_STATE) { |
2285 |
if ($self->{next_char} == 0x002D) { # - |
if ($self->{nc} == 0x002D) { # - |
2286 |
!!!cp (145); |
!!!cp (145); |
2287 |
$self->{state} = COMMENT_END_DASH_STATE; |
$self->{state} = COMMENT_END_DASH_STATE; |
2288 |
!!!next-input-character; |
!!!next-input-character; |
2289 |
redo A; |
redo A; |
2290 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2291 |
!!!cp (146); |
!!!cp (146); |
2292 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
2293 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2294 |
## reconsume |
## reconsume |
2295 |
|
|
2296 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{ct}); # comment |
2297 |
|
|
2298 |
redo A; |
redo A; |
2299 |
} else { |
} else { |
2300 |
!!!cp (147); |
!!!cp (147); |
2301 |
$self->{current_token}->{data} .= chr ($self->{next_char}); # comment |
$self->{ct}->{data} .= chr ($self->{nc}); # comment |
2302 |
$self->{read_until}->($self->{current_token}->{data}, |
$self->{read_until}->($self->{ct}->{data}, |
2303 |
q[-], |
q[-], |
2304 |
length $self->{current_token}->{data}); |
length $self->{ct}->{data}); |
2305 |
|
|
2306 |
## Stay in the state |
## Stay in the state |
2307 |
!!!next-input-character; |
!!!next-input-character; |
2308 |
redo A; |
redo A; |
2309 |
} |
} |
2310 |
} elsif ($self->{state} == COMMENT_END_DASH_STATE) { |
} elsif ($self->{state} == COMMENT_END_DASH_STATE) { |
2311 |
if ($self->{next_char} == 0x002D) { # - |
if ($self->{nc} == 0x002D) { # - |
2312 |
!!!cp (148); |
!!!cp (148); |
2313 |
$self->{state} = COMMENT_END_STATE; |
$self->{state} = COMMENT_END_STATE; |
2314 |
!!!next-input-character; |
!!!next-input-character; |
2315 |
redo A; |
redo A; |
2316 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2317 |
!!!cp (149); |
!!!cp (149); |
2318 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
2319 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2320 |
## reconsume |
## reconsume |
2321 |
|
|
2322 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{ct}); # comment |
2323 |
|
|
2324 |
redo A; |
redo A; |
2325 |
} else { |
} else { |
2326 |
!!!cp (150); |
!!!cp (150); |
2327 |
$self->{current_token}->{data} .= '-' . chr ($self->{next_char}); # comment |
$self->{ct}->{data} .= '-' . chr ($self->{nc}); # comment |
2328 |
$self->{state} = COMMENT_STATE; |
$self->{state} = COMMENT_STATE; |
2329 |
!!!next-input-character; |
!!!next-input-character; |
2330 |
redo A; |
redo A; |
2331 |
} |
} |
2332 |
} elsif ($self->{state} == COMMENT_END_STATE) { |
} elsif ($self->{state} == COMMENT_END_STATE) { |
2333 |
if ($self->{next_char} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
2334 |
!!!cp (151); |
!!!cp (151); |
2335 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2336 |
!!!next-input-character; |
!!!next-input-character; |
2337 |
|
|
2338 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{ct}); # comment |
2339 |
|
|
2340 |
redo A; |
redo A; |
2341 |
} elsif ($self->{next_char} == 0x002D) { # - |
} elsif ($self->{nc} == 0x002D) { # - |
2342 |
!!!cp (152); |
!!!cp (152); |
2343 |
!!!parse-error (type => 'dash in comment', |
!!!parse-error (type => 'dash in comment', |
2344 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2345 |
column => $self->{column_prev}); |
column => $self->{column_prev}); |
2346 |
$self->{current_token}->{data} .= '-'; # comment |
$self->{ct}->{data} .= '-'; # comment |
2347 |
## Stay in the state |
## Stay in the state |
2348 |
!!!next-input-character; |
!!!next-input-character; |
2349 |
redo A; |
redo A; |
2350 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2351 |
!!!cp (153); |
!!!cp (153); |
2352 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
2353 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2354 |
## reconsume |
## reconsume |
2355 |
|
|
2356 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{ct}); # comment |
2357 |
|
|
2358 |
redo A; |
redo A; |
2359 |
} else { |
} else { |
2361 |
!!!parse-error (type => 'dash in comment', |
!!!parse-error (type => 'dash in comment', |
2362 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2363 |
column => $self->{column_prev}); |
column => $self->{column_prev}); |
2364 |
$self->{current_token}->{data} .= '--' . chr ($self->{next_char}); # comment |
$self->{ct}->{data} .= '--' . chr ($self->{nc}); # comment |
2365 |
$self->{state} = COMMENT_STATE; |
$self->{state} = COMMENT_STATE; |
2366 |
!!!next-input-character; |
!!!next-input-character; |
2367 |
redo A; |
redo A; |
2368 |
} |
} |
2369 |
} elsif ($self->{state} == DOCTYPE_STATE) { |
} elsif ($self->{state} == DOCTYPE_STATE) { |
2370 |
if ($self->{next_char} == 0x0009 or # HT |
if ($self->{nc} == 0x0009 or # HT |
2371 |
$self->{next_char} == 0x000A or # LF |
$self->{nc} == 0x000A or # LF |
2372 |
$self->{next_char} == 0x000B or # VT |
$self->{nc} == 0x000B or # VT |
2373 |
$self->{next_char} == 0x000C or # FF |
$self->{nc} == 0x000C or # FF |
2374 |
$self->{next_char} == 0x0020) { # SP |
$self->{nc} == 0x0020) { # SP |
2375 |
!!!cp (155); |
!!!cp (155); |
2376 |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
2377 |
!!!next-input-character; |
!!!next-input-character; |
2384 |
redo A; |
redo A; |
2385 |
} |
} |
2386 |
} elsif ($self->{state} == BEFORE_DOCTYPE_NAME_STATE) { |
} elsif ($self->{state} == BEFORE_DOCTYPE_NAME_STATE) { |
2387 |
if ($self->{next_char} == 0x0009 or # HT |
if ($self->{nc} == 0x0009 or # HT |
2388 |
$self->{next_char} == 0x000A or # LF |
$self->{nc} == 0x000A or # LF |
2389 |
$self->{next_char} == 0x000B or # VT |
$self->{nc} == 0x000B or # VT |
2390 |
$self->{next_char} == 0x000C or # FF |
$self->{nc} == 0x000C or # FF |
2391 |
$self->{next_char} == 0x0020) { # SP |
$self->{nc} == 0x0020) { # SP |
2392 |
!!!cp (157); |
!!!cp (157); |
2393 |
## Stay in the state |
## Stay in the state |
2394 |
!!!next-input-character; |
!!!next-input-character; |
2395 |
redo A; |
redo A; |
2396 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2397 |
!!!cp (158); |
!!!cp (158); |
2398 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
2399 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2400 |
!!!next-input-character; |
!!!next-input-character; |
2401 |
|
|
2402 |
!!!emit ($self->{current_token}); # DOCTYPE (quirks) |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
2403 |
|
|
2404 |
redo A; |
redo A; |
2405 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2406 |
!!!cp (159); |
!!!cp (159); |
2407 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
2408 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2409 |
## reconsume |
## reconsume |
2410 |
|
|
2411 |
!!!emit ($self->{current_token}); # DOCTYPE (quirks) |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
2412 |
|
|
2413 |
redo A; |
redo A; |
2414 |
} else { |
} else { |
2415 |
!!!cp (160); |
!!!cp (160); |
2416 |
$self->{current_token}->{name} = chr $self->{next_char}; |
$self->{ct}->{name} = chr $self->{nc}; |
2417 |
delete $self->{current_token}->{quirks}; |
delete $self->{ct}->{quirks}; |
2418 |
## ISSUE: "Set the token's name name to the" in the spec |
## ISSUE: "Set the token's name name to the" in the spec |
2419 |
$self->{state} = DOCTYPE_NAME_STATE; |
$self->{state} = DOCTYPE_NAME_STATE; |
2420 |
!!!next-input-character; |
!!!next-input-character; |
2422 |
} |
} |
2423 |
} elsif ($self->{state} == DOCTYPE_NAME_STATE) { |
} elsif ($self->{state} == DOCTYPE_NAME_STATE) { |
2424 |
## ISSUE: Redundant "First," in the spec. |
## ISSUE: Redundant "First," in the spec. |
2425 |
if ($self->{next_char} == 0x0009 or # HT |
if ($self->{nc} == 0x0009 or # HT |
2426 |
$self->{next_char} == 0x000A or # LF |
$self->{nc} == 0x000A or # LF |
2427 |
$self->{next_char} == 0x000B or # VT |
$self->{nc} == 0x000B or # VT |
2428 |
$self->{next_char} == 0x000C or # FF |
$self->{nc} == 0x000C or # FF |
2429 |
$self->{next_char} == 0x0020) { # SP |
$self->{nc} == 0x0020) { # SP |
2430 |
!!!cp (161); |
!!!cp (161); |
2431 |
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
2432 |
!!!next-input-character; |
!!!next-input-character; |
2433 |
redo A; |
redo A; |
2434 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2435 |
!!!cp (162); |
!!!cp (162); |
2436 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2437 |
!!!next-input-character; |
!!!next-input-character; |
2438 |
|
|
2439 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2440 |
|
|
2441 |
redo A; |
redo A; |
2442 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2443 |
!!!cp (163); |
!!!cp (163); |
2444 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2445 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2446 |
## reconsume |
## reconsume |
2447 |
|
|
2448 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2449 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2450 |
|
|
2451 |
redo A; |
redo A; |
2452 |
} else { |
} else { |
2453 |
!!!cp (164); |
!!!cp (164); |
2454 |
$self->{current_token}->{name} |
$self->{ct}->{name} |
2455 |
.= chr ($self->{next_char}); # DOCTYPE |
.= chr ($self->{nc}); # DOCTYPE |
2456 |
## Stay in the state |
## Stay in the state |
2457 |
!!!next-input-character; |
!!!next-input-character; |
2458 |
redo A; |
redo A; |
2459 |
} |
} |
2460 |
} elsif ($self->{state} == AFTER_DOCTYPE_NAME_STATE) { |
} elsif ($self->{state} == AFTER_DOCTYPE_NAME_STATE) { |
2461 |
if ($self->{next_char} == 0x0009 or # HT |
if ($self->{nc} == 0x0009 or # HT |
2462 |
$self->{next_char} == 0x000A or # LF |
$self->{nc} == 0x000A or # LF |
2463 |
$self->{next_char} == 0x000B or # VT |
$self->{nc} == 0x000B or # VT |
2464 |
$self->{next_char} == 0x000C or # FF |
$self->{nc} == 0x000C or # FF |
2465 |
$self->{next_char} == 0x0020) { # SP |
$self->{nc} == 0x0020) { # SP |
2466 |
!!!cp (165); |
!!!cp (165); |
2467 |
## Stay in the state |
## Stay in the state |
2468 |
!!!next-input-character; |
!!!next-input-character; |
2469 |
redo A; |
redo A; |
2470 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2471 |
!!!cp (166); |
!!!cp (166); |
2472 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2473 |
!!!next-input-character; |
!!!next-input-character; |
2474 |
|
|
2475 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2476 |
|
|
2477 |
redo A; |
redo A; |
2478 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2479 |
!!!cp (167); |
!!!cp (167); |
2480 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2481 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2482 |
## reconsume |
## reconsume |
2483 |
|
|
2484 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2485 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2486 |
|
|
2487 |
redo A; |
redo A; |
2488 |
} elsif ($self->{next_char} == 0x0050 or # P |
} elsif ($self->{nc} == 0x0050 or # P |
2489 |
$self->{next_char} == 0x0070) { # p |
$self->{nc} == 0x0070) { # p |
2490 |
$self->{state} = PUBLIC_STATE; |
$self->{state} = PUBLIC_STATE; |
2491 |
$self->{state_keyword} = chr $self->{next_char}; |
$self->{s_kwd} = chr $self->{nc}; |
2492 |
!!!next-input-character; |
!!!next-input-character; |
2493 |
redo A; |
redo A; |
2494 |
} elsif ($self->{next_char} == 0x0053 or # S |
} elsif ($self->{nc} == 0x0053 or # S |
2495 |
$self->{next_char} == 0x0073) { # s |
$self->{nc} == 0x0073) { # s |
2496 |
$self->{state} = SYSTEM_STATE; |
$self->{state} = SYSTEM_STATE; |
2497 |
$self->{state_keyword} = chr $self->{next_char}; |
$self->{s_kwd} = chr $self->{nc}; |
2498 |
!!!next-input-character; |
!!!next-input-character; |
2499 |
redo A; |
redo A; |
2500 |
} else { |
} else { |
2501 |
!!!cp (180); |
!!!cp (180); |
2502 |
!!!parse-error (type => 'string after DOCTYPE name'); |
!!!parse-error (type => 'string after DOCTYPE name'); |
2503 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2504 |
|
|
2505 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
$self->{state} = BOGUS_DOCTYPE_STATE; |
2506 |
!!!next-input-character; |
!!!next-input-character; |
2508 |
} |
} |
2509 |
} elsif ($self->{state} == PUBLIC_STATE) { |
} elsif ($self->{state} == PUBLIC_STATE) { |
2510 |
## ASCII case-insensitive |
## ASCII case-insensitive |
2511 |
if ($self->{next_char} == [ |
if ($self->{nc} == [ |
2512 |
undef, |
undef, |
2513 |
0x0055, # U |
0x0055, # U |
2514 |
0x0042, # B |
0x0042, # B |
2515 |
0x004C, # L |
0x004C, # L |
2516 |
0x0049, # I |
0x0049, # I |
2517 |
]->[length $self->{state_keyword}] or |
]->[length $self->{s_kwd}] or |
2518 |
$self->{next_char} == [ |
$self->{nc} == [ |
2519 |
undef, |
undef, |
2520 |
0x0075, # u |
0x0075, # u |
2521 |
0x0062, # b |
0x0062, # b |
2522 |
0x006C, # l |
0x006C, # l |
2523 |
0x0069, # i |
0x0069, # i |
2524 |
]->[length $self->{state_keyword}]) { |
]->[length $self->{s_kwd}]) { |
2525 |
!!!cp (175); |
!!!cp (175); |
2526 |
## Stay in the state. |
## Stay in the state. |
2527 |
$self->{state_keyword} .= chr $self->{next_char}; |
$self->{s_kwd} .= chr $self->{nc}; |
2528 |
!!!next-input-character; |
!!!next-input-character; |
2529 |
redo A; |
redo A; |
2530 |
} elsif ((length $self->{state_keyword}) == 5 and |
} elsif ((length $self->{s_kwd}) == 5 and |
2531 |
($self->{next_char} == 0x0043 or # C |
($self->{nc} == 0x0043 or # C |
2532 |
$self->{next_char} == 0x0063)) { # c |
$self->{nc} == 0x0063)) { # c |
2533 |
!!!cp (168); |
!!!cp (168); |
2534 |
$self->{state} = BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
$self->{state} = BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
2535 |
!!!next-input-character; |
!!!next-input-character; |
2538 |
!!!cp (169); |
!!!cp (169); |
2539 |
!!!parse-error (type => 'string after DOCTYPE name', |
!!!parse-error (type => 'string after DOCTYPE name', |
2540 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2541 |
column => $self->{column_prev} + 1 - length $self->{state_keyword}); |
column => $self->{column_prev} + 1 - length $self->{s_kwd}); |
2542 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2543 |
|
|
2544 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
$self->{state} = BOGUS_DOCTYPE_STATE; |
2545 |
## Reconsume. |
## Reconsume. |
2547 |
} |
} |
2548 |
} elsif ($self->{state} == SYSTEM_STATE) { |
} elsif ($self->{state} == SYSTEM_STATE) { |
2549 |
## ASCII case-insensitive |
## ASCII case-insensitive |
2550 |
if ($self->{next_char} == [ |
if ($self->{nc} == [ |
2551 |
undef, |
undef, |
2552 |
0x0059, # Y |
0x0059, # Y |
2553 |
0x0053, # S |
0x0053, # S |
2554 |
0x0054, # T |
0x0054, # T |
2555 |
0x0045, # E |
0x0045, # E |
2556 |
]->[length $self->{state_keyword}] or |
]->[length $self->{s_kwd}] or |
2557 |
$self->{next_char} == [ |
$self->{nc} == [ |
2558 |
undef, |
undef, |
2559 |
0x0079, # y |
0x0079, # y |
2560 |
0x0073, # s |
0x0073, # s |
2561 |
0x0074, # t |
0x0074, # t |
2562 |
0x0065, # e |
0x0065, # e |
2563 |
]->[length $self->{state_keyword}]) { |
]->[length $self->{s_kwd}]) { |
2564 |
!!!cp (170); |
!!!cp (170); |
2565 |
## Stay in the state. |
## Stay in the state. |
2566 |
$self->{state_keyword} .= chr $self->{next_char}; |
$self->{s_kwd} .= chr $self->{nc}; |
2567 |
!!!next-input-character; |
!!!next-input-character; |
2568 |
redo A; |
redo A; |
2569 |
} elsif ((length $self->{state_keyword}) == 5 and |
} elsif ((length $self->{s_kwd}) == 5 and |
2570 |
($self->{next_char} == 0x004D or # M |
($self->{nc} == 0x004D or # M |
2571 |
$self->{next_char} == 0x006D)) { # m |
$self->{nc} == 0x006D)) { # m |
2572 |
!!!cp (171); |
!!!cp (171); |
2573 |
$self->{state} = BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
$self->{state} = BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
2574 |
!!!next-input-character; |
!!!next-input-character; |
2577 |
!!!cp (172); |
!!!cp (172); |
2578 |
!!!parse-error (type => 'string after DOCTYPE name', |
!!!parse-error (type => 'string after DOCTYPE name', |
2579 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2580 |
column => $self->{column_prev} + 1 - length $self->{state_keyword}); |
column => $self->{column_prev} + 1 - length $self->{s_kwd}); |
2581 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2582 |
|
|
2583 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
$self->{state} = BOGUS_DOCTYPE_STATE; |
2584 |
## Reconsume. |
## Reconsume. |
2588 |
if ({ |
if ({ |
2589 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
2590 |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
2591 |
}->{$self->{next_char}}) { |
}->{$self->{nc}}) { |
2592 |
!!!cp (181); |
!!!cp (181); |
2593 |
## Stay in the state |
## Stay in the state |
2594 |
!!!next-input-character; |
!!!next-input-character; |
2595 |
redo A; |
redo A; |
2596 |
} elsif ($self->{next_char} eq 0x0022) { # " |
} elsif ($self->{nc} eq 0x0022) { # " |
2597 |
!!!cp (182); |
!!!cp (182); |
2598 |
$self->{current_token}->{public_identifier} = ''; # DOCTYPE |
$self->{ct}->{pubid} = ''; # DOCTYPE |
2599 |
$self->{state} = DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE; |
$self->{state} = DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE; |
2600 |
!!!next-input-character; |
!!!next-input-character; |
2601 |
redo A; |
redo A; |
2602 |
} elsif ($self->{next_char} eq 0x0027) { # ' |
} elsif ($self->{nc} eq 0x0027) { # ' |
2603 |
!!!cp (183); |
!!!cp (183); |
2604 |
$self->{current_token}->{public_identifier} = ''; # DOCTYPE |
$self->{ct}->{pubid} = ''; # DOCTYPE |
2605 |
$self->{state} = DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE; |
$self->{state} = DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE; |
2606 |
!!!next-input-character; |
!!!next-input-character; |
2607 |
redo A; |
redo A; |
2608 |
} elsif ($self->{next_char} eq 0x003E) { # > |
} elsif ($self->{nc} eq 0x003E) { # > |
2609 |
!!!cp (184); |
!!!cp (184); |
2610 |
!!!parse-error (type => 'no PUBLIC literal'); |
!!!parse-error (type => 'no PUBLIC literal'); |
2611 |
|
|
2612 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2613 |
!!!next-input-character; |
!!!next-input-character; |
2614 |
|
|
2615 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2616 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2617 |
|
|
2618 |
redo A; |
redo A; |
2619 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2620 |
!!!cp (185); |
!!!cp (185); |
2621 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2622 |
|
|
2623 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2624 |
## reconsume |
## reconsume |
2625 |
|
|
2626 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2627 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2628 |
|
|
2629 |
redo A; |
redo A; |
2630 |
} else { |
} else { |
2631 |
!!!cp (186); |
!!!cp (186); |
2632 |
!!!parse-error (type => 'string after PUBLIC'); |
!!!parse-error (type => 'string after PUBLIC'); |
2633 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2634 |
|
|
2635 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
$self->{state} = BOGUS_DOCTYPE_STATE; |
2636 |
!!!next-input-character; |
!!!next-input-character; |
2637 |
redo A; |
redo A; |
2638 |
} |
} |
2639 |
} elsif ($self->{state} == DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE) { |
} elsif ($self->{state} == DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE) { |
2640 |
if ($self->{next_char} == 0x0022) { # " |
if ($self->{nc} == 0x0022) { # " |
2641 |
!!!cp (187); |
!!!cp (187); |
2642 |
$self->{state} = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
$self->{state} = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
2643 |
!!!next-input-character; |
!!!next-input-character; |
2644 |
redo A; |
redo A; |
2645 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2646 |
!!!cp (188); |
!!!cp (188); |
2647 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
2648 |
|
|
2649 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2650 |
!!!next-input-character; |
!!!next-input-character; |
2651 |
|
|
2652 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2653 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2654 |
|
|
2655 |
redo A; |
redo A; |
2656 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2657 |
!!!cp (189); |
!!!cp (189); |
2658 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
2659 |
|
|
2660 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2661 |
## reconsume |
## reconsume |
2662 |
|
|
2663 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2664 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2665 |
|
|
2666 |
redo A; |
redo A; |
2667 |
} else { |
} else { |
2668 |
!!!cp (190); |
!!!cp (190); |
2669 |
$self->{current_token}->{public_identifier} # DOCTYPE |
$self->{ct}->{pubid} # DOCTYPE |
2670 |
.= chr $self->{next_char}; |
.= chr $self->{nc}; |
2671 |
$self->{read_until}->($self->{current_token}->{public_identifier}, |
$self->{read_until}->($self->{ct}->{pubid}, q[">], |
2672 |
q[">], |
length $self->{ct}->{pubid}); |
|
length $self->{current_token}->{public_identifier}); |
|
2673 |
|
|
2674 |
## Stay in the state |
## Stay in the state |
2675 |
!!!next-input-character; |
!!!next-input-character; |
2676 |
redo A; |
redo A; |
2677 |
} |
} |
2678 |
} elsif ($self->{state} == DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE) { |
} elsif ($self->{state} == DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE) { |
2679 |
if ($self->{next_char} == 0x0027) { # ' |
if ($self->{nc} == 0x0027) { # ' |
2680 |
!!!cp (191); |
!!!cp (191); |
2681 |
$self->{state} = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
$self->{state} = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
2682 |
!!!next-input-character; |
!!!next-input-character; |
2683 |
redo A; |
redo A; |
2684 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2685 |
!!!cp (192); |
!!!cp (192); |
2686 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
2687 |
|
|
2688 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2689 |
!!!next-input-character; |
!!!next-input-character; |
2690 |
|
|
2691 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2692 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2693 |
|
|
2694 |
redo A; |
redo A; |
2695 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2696 |
!!!cp (193); |
!!!cp (193); |
2697 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
2698 |
|
|
2699 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2700 |
## reconsume |
## reconsume |
2701 |
|
|
2702 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2703 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2704 |
|
|
2705 |
redo A; |
redo A; |
2706 |
} else { |
} else { |
2707 |
!!!cp (194); |
!!!cp (194); |
2708 |
$self->{current_token}->{public_identifier} # DOCTYPE |
$self->{ct}->{pubid} # DOCTYPE |
2709 |
.= chr $self->{next_char}; |
.= chr $self->{nc}; |
2710 |
$self->{read_until}->($self->{current_token}->{public_identifier}, |
$self->{read_until}->($self->{ct}->{pubid}, q['>], |
2711 |
q['>], |
length $self->{ct}->{pubid}); |
|
length $self->{current_token}->{public_identifier}); |
|
2712 |
|
|
2713 |
## Stay in the state |
## Stay in the state |
2714 |
!!!next-input-character; |
!!!next-input-character; |
2718 |
if ({ |
if ({ |
2719 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
2720 |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
2721 |
}->{$self->{next_char}}) { |
}->{$self->{nc}}) { |
2722 |
!!!cp (195); |
!!!cp (195); |
2723 |
## Stay in the state |
## Stay in the state |
2724 |
!!!next-input-character; |
!!!next-input-character; |
2725 |
redo A; |
redo A; |
2726 |
} elsif ($self->{next_char} == 0x0022) { # " |
} elsif ($self->{nc} == 0x0022) { # " |
2727 |
!!!cp (196); |
!!!cp (196); |
2728 |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
$self->{ct}->{sysid} = ''; # DOCTYPE |
2729 |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; |
2730 |
!!!next-input-character; |
!!!next-input-character; |
2731 |
redo A; |
redo A; |
2732 |
} elsif ($self->{next_char} == 0x0027) { # ' |
} elsif ($self->{nc} == 0x0027) { # ' |
2733 |
!!!cp (197); |
!!!cp (197); |
2734 |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
$self->{ct}->{sysid} = ''; # DOCTYPE |
2735 |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; |
2736 |
!!!next-input-character; |
!!!next-input-character; |
2737 |
redo A; |
redo A; |
2738 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2739 |
!!!cp (198); |
!!!cp (198); |
2740 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2741 |
!!!next-input-character; |
!!!next-input-character; |
2742 |
|
|
2743 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2744 |
|
|
2745 |
redo A; |
redo A; |
2746 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2747 |
!!!cp (199); |
!!!cp (199); |
2748 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2749 |
|
|
2750 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2751 |
## reconsume |
## reconsume |
2752 |
|
|
2753 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2754 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2755 |
|
|
2756 |
redo A; |
redo A; |
2757 |
} else { |
} else { |
2758 |
!!!cp (200); |
!!!cp (200); |
2759 |
!!!parse-error (type => 'string after PUBLIC literal'); |
!!!parse-error (type => 'string after PUBLIC literal'); |
2760 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2761 |
|
|
2762 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
$self->{state} = BOGUS_DOCTYPE_STATE; |
2763 |
!!!next-input-character; |
!!!next-input-character; |
2767 |
if ({ |
if ({ |
2768 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
2769 |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
2770 |
}->{$self->{next_char}}) { |
}->{$self->{nc}}) { |
2771 |
!!!cp (201); |
!!!cp (201); |
2772 |
## Stay in the state |
## Stay in the state |
2773 |
!!!next-input-character; |
!!!next-input-character; |
2774 |
redo A; |
redo A; |
2775 |
} elsif ($self->{next_char} == 0x0022) { # " |
} elsif ($self->{nc} == 0x0022) { # " |
2776 |
!!!cp (202); |
!!!cp (202); |
2777 |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
$self->{ct}->{sysid} = ''; # DOCTYPE |
2778 |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; |
2779 |
!!!next-input-character; |
!!!next-input-character; |
2780 |
redo A; |
redo A; |
2781 |
} elsif ($self->{next_char} == 0x0027) { # ' |
} elsif ($self->{nc} == 0x0027) { # ' |
2782 |
!!!cp (203); |
!!!cp (203); |
2783 |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
$self->{ct}->{sysid} = ''; # DOCTYPE |
2784 |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; |
2785 |
!!!next-input-character; |
!!!next-input-character; |
2786 |
redo A; |
redo A; |
2787 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2788 |
!!!cp (204); |
!!!cp (204); |
2789 |
!!!parse-error (type => 'no SYSTEM literal'); |
!!!parse-error (type => 'no SYSTEM literal'); |
2790 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2791 |
!!!next-input-character; |
!!!next-input-character; |
2792 |
|
|
2793 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2794 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2795 |
|
|
2796 |
redo A; |
redo A; |
2797 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2798 |
!!!cp (205); |
!!!cp (205); |
2799 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2800 |
|
|
2801 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2802 |
## reconsume |
## reconsume |
2803 |
|
|
2804 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2805 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2806 |
|
|
2807 |
redo A; |
redo A; |
2808 |
} else { |
} else { |
2809 |
!!!cp (206); |
!!!cp (206); |
2810 |
!!!parse-error (type => 'string after SYSTEM'); |
!!!parse-error (type => 'string after SYSTEM'); |
2811 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2812 |
|
|
2813 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
$self->{state} = BOGUS_DOCTYPE_STATE; |
2814 |
!!!next-input-character; |
!!!next-input-character; |
2815 |
redo A; |
redo A; |
2816 |
} |
} |
2817 |
} elsif ($self->{state} == DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE) { |
} elsif ($self->{state} == DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE) { |
2818 |
if ($self->{next_char} == 0x0022) { # " |
if ($self->{nc} == 0x0022) { # " |
2819 |
!!!cp (207); |
!!!cp (207); |
2820 |
$self->{state} = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
$self->{state} = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
2821 |
!!!next-input-character; |
!!!next-input-character; |
2822 |
redo A; |
redo A; |
2823 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2824 |
!!!cp (208); |
!!!cp (208); |
2825 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
2826 |
|
|
2827 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2828 |
!!!next-input-character; |
!!!next-input-character; |
2829 |
|
|
2830 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2831 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2832 |
|
|
2833 |
redo A; |
redo A; |
2834 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2835 |
!!!cp (209); |
!!!cp (209); |
2836 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
2837 |
|
|
2838 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2839 |
## reconsume |
## reconsume |
2840 |
|
|
2841 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2842 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2843 |
|
|
2844 |
redo A; |
redo A; |
2845 |
} else { |
} else { |
2846 |
!!!cp (210); |
!!!cp (210); |
2847 |
$self->{current_token}->{system_identifier} # DOCTYPE |
$self->{ct}->{sysid} # DOCTYPE |
2848 |
.= chr $self->{next_char}; |
.= chr $self->{nc}; |
2849 |
$self->{read_until}->($self->{current_token}->{system_identifier}, |
$self->{read_until}->($self->{ct}->{sysid}, q[">], |
2850 |
q[">], |
length $self->{ct}->{sysid}); |
|
length $self->{current_token}->{system_identifier}); |
|
2851 |
|
|
2852 |
## Stay in the state |
## Stay in the state |
2853 |
!!!next-input-character; |
!!!next-input-character; |
2854 |
redo A; |
redo A; |
2855 |
} |
} |
2856 |
} elsif ($self->{state} == DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE) { |
} elsif ($self->{state} == DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE) { |
2857 |
if ($self->{next_char} == 0x0027) { # ' |
if ($self->{nc} == 0x0027) { # ' |
2858 |
!!!cp (211); |
!!!cp (211); |
2859 |
$self->{state} = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
$self->{state} = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
2860 |
!!!next-input-character; |
!!!next-input-character; |
2861 |
redo A; |
redo A; |
2862 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2863 |
!!!cp (212); |
!!!cp (212); |
2864 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
2865 |
|
|
2866 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2867 |
!!!next-input-character; |
!!!next-input-character; |
2868 |
|
|
2869 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2870 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2871 |
|
|
2872 |
redo A; |
redo A; |
2873 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2874 |
!!!cp (213); |
!!!cp (213); |
2875 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
2876 |
|
|
2877 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2878 |
## reconsume |
## reconsume |
2879 |
|
|
2880 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2881 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2882 |
|
|
2883 |
redo A; |
redo A; |
2884 |
} else { |
} else { |
2885 |
!!!cp (214); |
!!!cp (214); |
2886 |
$self->{current_token}->{system_identifier} # DOCTYPE |
$self->{ct}->{sysid} # DOCTYPE |
2887 |
.= chr $self->{next_char}; |
.= chr $self->{nc}; |
2888 |
$self->{read_until}->($self->{current_token}->{system_identifier}, |
$self->{read_until}->($self->{ct}->{sysid}, q['>], |
2889 |
q['>], |
length $self->{ct}->{sysid}); |
|
length $self->{current_token}->{system_identifier}); |
|
2890 |
|
|
2891 |
## Stay in the state |
## Stay in the state |
2892 |
!!!next-input-character; |
!!!next-input-character; |
2896 |
if ({ |
if ({ |
2897 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
2898 |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
2899 |
}->{$self->{next_char}}) { |
}->{$self->{nc}}) { |
2900 |
!!!cp (215); |
!!!cp (215); |
2901 |
## Stay in the state |
## Stay in the state |
2902 |
!!!next-input-character; |
!!!next-input-character; |
2903 |
redo A; |
redo A; |
2904 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2905 |
!!!cp (216); |
!!!cp (216); |
2906 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2907 |
!!!next-input-character; |
!!!next-input-character; |
2908 |
|
|
2909 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2910 |
|
|
2911 |
redo A; |
redo A; |
2912 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2913 |
!!!cp (217); |
!!!cp (217); |
2914 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2915 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2916 |
## reconsume |
## reconsume |
2917 |
|
|
2918 |
$self->{current_token}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2919 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2920 |
|
|
2921 |
redo A; |
redo A; |
2922 |
} else { |
} else { |
2923 |
!!!cp (218); |
!!!cp (218); |
2924 |
!!!parse-error (type => 'string after SYSTEM literal'); |
!!!parse-error (type => 'string after SYSTEM literal'); |
2925 |
#$self->{current_token}->{quirks} = 1; |
#$self->{ct}->{quirks} = 1; |
2926 |
|
|
2927 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
$self->{state} = BOGUS_DOCTYPE_STATE; |
2928 |
!!!next-input-character; |
!!!next-input-character; |
2929 |
redo A; |
redo A; |
2930 |
} |
} |
2931 |
} elsif ($self->{state} == BOGUS_DOCTYPE_STATE) { |
} elsif ($self->{state} == BOGUS_DOCTYPE_STATE) { |
2932 |
if ($self->{next_char} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
2933 |
!!!cp (219); |
!!!cp (219); |
2934 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2935 |
!!!next-input-character; |
!!!next-input-character; |
2936 |
|
|
2937 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2938 |
|
|
2939 |
redo A; |
redo A; |
2940 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2941 |
!!!cp (220); |
!!!cp (220); |
2942 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2943 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2944 |
## reconsume |
## reconsume |
2945 |
|
|
2946 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2947 |
|
|
2948 |
redo A; |
redo A; |
2949 |
} else { |
} else { |
2960 |
## by three states, |CDATA_SECTION_STATE|, |CDATA_SECTION_MSE1_STATE|, |
## by three states, |CDATA_SECTION_STATE|, |CDATA_SECTION_MSE1_STATE|, |
2961 |
## and |CDATA_SECTION_MSE2_STATE|. |
## and |CDATA_SECTION_MSE2_STATE|. |
2962 |
|
|
2963 |
if ($self->{next_char} == 0x005D) { # ] |
if ($self->{nc} == 0x005D) { # ] |
2964 |
!!!cp (221.1); |
!!!cp (221.1); |
2965 |
$self->{state} = CDATA_SECTION_MSE1_STATE; |
$self->{state} = CDATA_SECTION_MSE1_STATE; |
2966 |
!!!next-input-character; |
!!!next-input-character; |
2967 |
redo A; |
redo A; |
2968 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{nc} == -1) { |
2969 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2970 |
!!!next-input-character; |
!!!next-input-character; |
2971 |
if (length $self->{current_token}->{data}) { # character |
if (length $self->{ct}->{data}) { # character |
2972 |
!!!cp (221.2); |
!!!cp (221.2); |
2973 |
!!!emit ($self->{current_token}); # character |
!!!emit ($self->{ct}); # character |
2974 |
} else { |
} else { |
2975 |
!!!cp (221.3); |
!!!cp (221.3); |
2976 |
## No token to emit. $self->{current_token} is discarded. |
## No token to emit. $self->{ct} is discarded. |
2977 |
} |
} |
2978 |
redo A; |
redo A; |
2979 |
} else { |
} else { |
2980 |
!!!cp (221.4); |
!!!cp (221.4); |
2981 |
$self->{current_token}->{data} .= chr $self->{next_char}; |
$self->{ct}->{data} .= chr $self->{nc}; |
2982 |
$self->{read_until}->($self->{current_token}->{data}, |
$self->{read_until}->($self->{ct}->{data}, |
2983 |
q<]>, |
q<]>, |
2984 |
length $self->{current_token}->{data}); |
length $self->{ct}->{data}); |
2985 |
|
|
2986 |
## Stay in the state. |
## Stay in the state. |
2987 |
!!!next-input-character; |
!!!next-input-character; |
2990 |
|
|
2991 |
## ISSUE: "text tokens" in spec. |
## ISSUE: "text tokens" in spec. |
2992 |
} elsif ($self->{state} == CDATA_SECTION_MSE1_STATE) { |
} elsif ($self->{state} == CDATA_SECTION_MSE1_STATE) { |
2993 |
if ($self->{next_char} == 0x005D) { # ] |
if ($self->{nc} == 0x005D) { # ] |
2994 |
!!!cp (221.5); |
!!!cp (221.5); |
2995 |
$self->{state} = CDATA_SECTION_MSE2_STATE; |
$self->{state} = CDATA_SECTION_MSE2_STATE; |
2996 |
!!!next-input-character; |
!!!next-input-character; |
2997 |
redo A; |
redo A; |
2998 |
} else { |
} else { |
2999 |
!!!cp (221.6); |
!!!cp (221.6); |
3000 |
$self->{current_token}->{data} .= ']'; |
$self->{ct}->{data} .= ']'; |
3001 |
$self->{state} = CDATA_SECTION_STATE; |
$self->{state} = CDATA_SECTION_STATE; |
3002 |
## Reconsume. |
## Reconsume. |
3003 |
redo A; |
redo A; |
3004 |
} |
} |
3005 |
} elsif ($self->{state} == CDATA_SECTION_MSE2_STATE) { |
} elsif ($self->{state} == CDATA_SECTION_MSE2_STATE) { |
3006 |
if ($self->{next_char} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
3007 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
3008 |
!!!next-input-character; |
!!!next-input-character; |
3009 |
if (length $self->{current_token}->{data}) { # character |
if (length $self->{ct}->{data}) { # character |
3010 |
!!!cp (221.7); |
!!!cp (221.7); |
3011 |
!!!emit ($self->{current_token}); # character |
!!!emit ($self->{ct}); # character |
3012 |
} else { |
} else { |
3013 |
!!!cp (221.8); |
!!!cp (221.8); |
3014 |
## No token to emit. $self->{current_token} is discarded. |
## No token to emit. $self->{ct} is discarded. |
3015 |
} |
} |
3016 |
redo A; |
redo A; |
3017 |
} elsif ($self->{next_char} == 0x005D) { # ] |
} elsif ($self->{nc} == 0x005D) { # ] |
3018 |
!!!cp (221.9); # character |
!!!cp (221.9); # character |
3019 |
$self->{current_token}->{data} .= ']'; ## Add first "]" of "]]]". |
$self->{ct}->{data} .= ']'; ## Add first "]" of "]]]". |
3020 |
## Stay in the state. |
## Stay in the state. |
3021 |
!!!next-input-character; |
!!!next-input-character; |
3022 |
redo A; |
redo A; |
3023 |
} else { |
} else { |
3024 |
!!!cp (221.11); |
!!!cp (221.11); |
3025 |
$self->{current_token}->{data} .= ']]'; # character |
$self->{ct}->{data} .= ']]'; # character |
3026 |
$self->{state} = CDATA_SECTION_STATE; |
$self->{state} = CDATA_SECTION_STATE; |
3027 |
## Reconsume. |
## Reconsume. |
3028 |
redo A; |
redo A; |
3031 |
if ({ |
if ({ |
3032 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF, |
3033 |
0x0020 => 1, 0x003C => 1, 0x0026 => 1, -1 => 1, # SP, <, & |
0x0020 => 1, 0x003C => 1, 0x0026 => 1, -1 => 1, # SP, <, & |
3034 |
$self->{entity_additional} => 1, |
$self->{entity_add} => 1, |
3035 |
}->{$self->{next_char}}) { |
}->{$self->{nc}}) { |
3036 |
!!!cp (1001); |
!!!cp (1001); |
3037 |
## Don't consume |
## Don't consume |
3038 |
## No error |
## No error |
3039 |
## Return nothing. |
## Return nothing. |
3040 |
# |
# |
3041 |
} elsif ($self->{next_char} == 0x0023) { # # |
} elsif ($self->{nc} == 0x0023) { # # |
3042 |
!!!cp (999); |
!!!cp (999); |
3043 |
$self->{state} = ENTITY_HASH_STATE; |
$self->{state} = ENTITY_HASH_STATE; |
3044 |
$self->{state_keyword} = '#'; |
$self->{s_kwd} = '#'; |
3045 |
!!!next-input-character; |
!!!next-input-character; |
3046 |
redo A; |
redo A; |
3047 |
} elsif ((0x0041 <= $self->{next_char} and |
} elsif ((0x0041 <= $self->{nc} and |
3048 |
$self->{next_char} <= 0x005A) or # A..Z |
$self->{nc} <= 0x005A) or # A..Z |
3049 |
(0x0061 <= $self->{next_char} and |
(0x0061 <= $self->{nc} and |
3050 |
$self->{next_char} <= 0x007A)) { # a..z |
$self->{nc} <= 0x007A)) { # a..z |
3051 |
!!!cp (998); |
!!!cp (998); |
3052 |
require Whatpm::_NamedEntityList; |
require Whatpm::_NamedEntityList; |
3053 |
$self->{state} = ENTITY_NAME_STATE; |
$self->{state} = ENTITY_NAME_STATE; |
3054 |
$self->{state_keyword} = chr $self->{next_char}; |
$self->{s_kwd} = chr $self->{nc}; |
3055 |
$self->{entity__value} = $self->{state_keyword}; |
$self->{entity__value} = $self->{s_kwd}; |
3056 |
$self->{entity__match} = 0; |
$self->{entity__match} = 0; |
3057 |
!!!next-input-character; |
!!!next-input-character; |
3058 |
redo A; |
redo A; |
3080 |
redo A; |
redo A; |
3081 |
} else { |
} else { |
3082 |
!!!cp (996); |
!!!cp (996); |
3083 |
$self->{current_attribute}->{value} .= '&'; |
$self->{ca}->{value} .= '&'; |
3084 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3085 |
## Reconsume. |
## Reconsume. |
3086 |
redo A; |
redo A; |
3087 |
} |
} |
3088 |
} elsif ($self->{state} == ENTITY_HASH_STATE) { |
} elsif ($self->{state} == ENTITY_HASH_STATE) { |
3089 |
if ($self->{next_char} == 0x0078 or # x |
if ($self->{nc} == 0x0078 or # x |
3090 |
$self->{next_char} == 0x0058) { # X |
$self->{nc} == 0x0058) { # X |
3091 |
!!!cp (995); |
!!!cp (995); |
3092 |
$self->{state} = HEXREF_X_STATE; |
$self->{state} = HEXREF_X_STATE; |
3093 |
$self->{state_keyword} .= chr $self->{next_char}; |
$self->{s_kwd} .= chr $self->{nc}; |
3094 |
!!!next-input-character; |
!!!next-input-character; |
3095 |
redo A; |
redo A; |
3096 |
} elsif (0x0030 <= $self->{next_char} and |
} elsif (0x0030 <= $self->{nc} and |
3097 |
$self->{next_char} <= 0x0039) { # 0..9 |
$self->{nc} <= 0x0039) { # 0..9 |
3098 |
!!!cp (994); |
!!!cp (994); |
3099 |
$self->{state} = NCR_NUM_STATE; |
$self->{state} = NCR_NUM_STATE; |
3100 |
$self->{state_keyword} = $self->{next_char} - 0x0030; |
$self->{s_kwd} = $self->{nc} - 0x0030; |
3101 |
!!!next-input-character; |
!!!next-input-character; |
3102 |
redo A; |
redo A; |
3103 |
} else { |
} else { |
3121 |
redo A; |
redo A; |
3122 |
} else { |
} else { |
3123 |
!!!cp (993); |
!!!cp (993); |
3124 |
$self->{current_attribute}->{value} .= '&#'; |
$self->{ca}->{value} .= '&#'; |
3125 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3126 |
## Reconsume. |
## Reconsume. |
3127 |
redo A; |
redo A; |
3128 |
} |
} |
3129 |
} |
} |
3130 |
} elsif ($self->{state} == NCR_NUM_STATE) { |
} elsif ($self->{state} == NCR_NUM_STATE) { |
3131 |
if (0x0030 <= $self->{next_char} and |
if (0x0030 <= $self->{nc} and |
3132 |
$self->{next_char} <= 0x0039) { # 0..9 |
$self->{nc} <= 0x0039) { # 0..9 |
3133 |
!!!cp (1012); |
!!!cp (1012); |
3134 |
$self->{state_keyword} *= 10; |
$self->{s_kwd} *= 10; |
3135 |
$self->{state_keyword} += $self->{next_char} - 0x0030; |
$self->{s_kwd} += $self->{nc} - 0x0030; |
3136 |
|
|
3137 |
## Stay in the state. |
## Stay in the state. |
3138 |
!!!next-input-character; |
!!!next-input-character; |
3139 |
redo A; |
redo A; |
3140 |
} elsif ($self->{next_char} == 0x003B) { # ; |
} elsif ($self->{nc} == 0x003B) { # ; |
3141 |
!!!cp (1013); |
!!!cp (1013); |
3142 |
!!!next-input-character; |
!!!next-input-character; |
3143 |
# |
# |
3148 |
# |
# |
3149 |
} |
} |
3150 |
|
|
3151 |
my $code = $self->{state_keyword}; |
my $code = $self->{s_kwd}; |
3152 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3153 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3154 |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
3186 |
redo A; |
redo A; |
3187 |
} else { |
} else { |
3188 |
!!!cp (991); |
!!!cp (991); |
3189 |
$self->{current_attribute}->{value} .= chr $code; |
$self->{ca}->{value} .= chr $code; |
3190 |
$self->{current_attribute}->{has_reference} = 1; |
$self->{ca}->{has_reference} = 1; |
3191 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3192 |
## Reconsume. |
## Reconsume. |
3193 |
redo A; |
redo A; |
3194 |
} |
} |
3195 |
} elsif ($self->{state} == HEXREF_X_STATE) { |
} elsif ($self->{state} == HEXREF_X_STATE) { |
3196 |
if ((0x0030 <= $self->{next_char} and $self->{next_char} <= 0x0039) or |
if ((0x0030 <= $self->{nc} and $self->{nc} <= 0x0039) or |
3197 |
(0x0041 <= $self->{next_char} and $self->{next_char} <= 0x0046) or |
(0x0041 <= $self->{nc} and $self->{nc} <= 0x0046) or |
3198 |
(0x0061 <= $self->{next_char} and $self->{next_char} <= 0x0066)) { |
(0x0061 <= $self->{nc} and $self->{nc} <= 0x0066)) { |
3199 |
# 0..9, A..F, a..f |
# 0..9, A..F, a..f |
3200 |
!!!cp (990); |
!!!cp (990); |
3201 |
$self->{state} = HEXREF_HEX_STATE; |
$self->{state} = HEXREF_HEX_STATE; |
3202 |
$self->{state_keyword} = 0; |
$self->{s_kwd} = 0; |
3203 |
## Reconsume. |
## Reconsume. |
3204 |
redo A; |
redo A; |
3205 |
} else { |
} else { |
3216 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3217 |
## Reconsume. |
## Reconsume. |
3218 |
!!!emit ({type => CHARACTER_TOKEN, |
!!!emit ({type => CHARACTER_TOKEN, |
3219 |
data => '&' . $self->{state_keyword}, |
data => '&' . $self->{s_kwd}, |
3220 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
3221 |
column => $self->{column_prev} - length $self->{state_keyword}, |
column => $self->{column_prev} - length $self->{s_kwd}, |
3222 |
}); |
}); |
3223 |
redo A; |
redo A; |
3224 |
} else { |
} else { |
3225 |
!!!cp (989); |
!!!cp (989); |
3226 |
$self->{current_attribute}->{value} .= '&' . $self->{state_keyword}; |
$self->{ca}->{value} .= '&' . $self->{s_kwd}; |
3227 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3228 |
## Reconsume. |
## Reconsume. |
3229 |
redo A; |
redo A; |
3230 |
} |
} |
3231 |
} |
} |
3232 |
} elsif ($self->{state} == HEXREF_HEX_STATE) { |
} elsif ($self->{state} == HEXREF_HEX_STATE) { |
3233 |
if (0x0030 <= $self->{next_char} and $self->{next_char} <= 0x0039) { |
if (0x0030 <= $self->{nc} and $self->{nc} <= 0x0039) { |
3234 |
# 0..9 |
# 0..9 |
3235 |
!!!cp (1002); |
!!!cp (1002); |
3236 |
$self->{state_keyword} *= 0x10; |
$self->{s_kwd} *= 0x10; |
3237 |
$self->{state_keyword} += $self->{next_char} - 0x0030; |
$self->{s_kwd} += $self->{nc} - 0x0030; |
3238 |
## Stay in the state. |
## Stay in the state. |
3239 |
!!!next-input-character; |
!!!next-input-character; |
3240 |
redo A; |
redo A; |
3241 |
} elsif (0x0061 <= $self->{next_char} and |
} elsif (0x0061 <= $self->{nc} and |
3242 |
$self->{next_char} <= 0x0066) { # a..f |
$self->{nc} <= 0x0066) { # a..f |
3243 |
!!!cp (1003); |
!!!cp (1003); |
3244 |
$self->{state_keyword} *= 0x10; |
$self->{s_kwd} *= 0x10; |
3245 |
$self->{state_keyword} += $self->{next_char} - 0x0060 + 9; |
$self->{s_kwd} += $self->{nc} - 0x0060 + 9; |
3246 |
## Stay in the state. |
## Stay in the state. |
3247 |
!!!next-input-character; |
!!!next-input-character; |
3248 |
redo A; |
redo A; |
3249 |
} elsif (0x0041 <= $self->{next_char} and |
} elsif (0x0041 <= $self->{nc} and |
3250 |
$self->{next_char} <= 0x0046) { # A..F |
$self->{nc} <= 0x0046) { # A..F |
3251 |
!!!cp (1004); |
!!!cp (1004); |
3252 |
$self->{state_keyword} *= 0x10; |
$self->{s_kwd} *= 0x10; |
3253 |
$self->{state_keyword} += $self->{next_char} - 0x0040 + 9; |
$self->{s_kwd} += $self->{nc} - 0x0040 + 9; |
3254 |
## Stay in the state. |
## Stay in the state. |
3255 |
!!!next-input-character; |
!!!next-input-character; |
3256 |
redo A; |
redo A; |
3257 |
} elsif ($self->{next_char} == 0x003B) { # ; |
} elsif ($self->{nc} == 0x003B) { # ; |
3258 |
!!!cp (1006); |
!!!cp (1006); |
3259 |
!!!next-input-character; |
!!!next-input-character; |
3260 |
# |
# |
3267 |
# |
# |
3268 |
} |
} |
3269 |
|
|
3270 |
my $code = $self->{state_keyword}; |
my $code = $self->{s_kwd}; |
3271 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3272 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3273 |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
3302 |
redo A; |
redo A; |
3303 |
} else { |
} else { |
3304 |
!!!cp (987); |
!!!cp (987); |
3305 |
$self->{current_attribute}->{value} .= chr $code; |
$self->{ca}->{value} .= chr $code; |
3306 |
$self->{current_attribute}->{has_reference} = 1; |
$self->{ca}->{has_reference} = 1; |
3307 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3308 |
## Reconsume. |
## Reconsume. |
3309 |
redo A; |
redo A; |
3310 |
} |
} |
3311 |
} elsif ($self->{state} == ENTITY_NAME_STATE) { |
} elsif ($self->{state} == ENTITY_NAME_STATE) { |
3312 |
if (length $self->{state_keyword} < 30 and |
if (length $self->{s_kwd} < 30 and |
3313 |
## NOTE: Some number greater than the maximum length of entity name |
## NOTE: Some number greater than the maximum length of entity name |
3314 |
((0x0041 <= $self->{next_char} and # a |
((0x0041 <= $self->{nc} and # a |
3315 |
$self->{next_char} <= 0x005A) or # x |
$self->{nc} <= 0x005A) or # x |
3316 |
(0x0061 <= $self->{next_char} and # a |
(0x0061 <= $self->{nc} and # a |
3317 |
$self->{next_char} <= 0x007A) or # z |
$self->{nc} <= 0x007A) or # z |
3318 |
(0x0030 <= $self->{next_char} and # 0 |
(0x0030 <= $self->{nc} and # 0 |
3319 |
$self->{next_char} <= 0x0039) or # 9 |
$self->{nc} <= 0x0039) or # 9 |
3320 |
$self->{next_char} == 0x003B)) { # ; |
$self->{nc} == 0x003B)) { # ; |
3321 |
our $EntityChar; |
our $EntityChar; |
3322 |
$self->{state_keyword} .= chr $self->{next_char}; |
$self->{s_kwd} .= chr $self->{nc}; |
3323 |
if (defined $EntityChar->{$self->{state_keyword}}) { |
if (defined $EntityChar->{$self->{s_kwd}}) { |
3324 |
if ($self->{next_char} == 0x003B) { # ; |
if ($self->{nc} == 0x003B) { # ; |
3325 |
!!!cp (1020); |
!!!cp (1020); |
3326 |
$self->{entity__value} = $EntityChar->{$self->{state_keyword}}; |
$self->{entity__value} = $EntityChar->{$self->{s_kwd}}; |
3327 |
$self->{entity__match} = 1; |
$self->{entity__match} = 1; |
3328 |
!!!next-input-character; |
!!!next-input-character; |
3329 |
# |
# |
3330 |
} else { |
} else { |
3331 |
!!!cp (1021); |
!!!cp (1021); |
3332 |
$self->{entity__value} = $EntityChar->{$self->{state_keyword}}; |
$self->{entity__value} = $EntityChar->{$self->{s_kwd}}; |
3333 |
$self->{entity__match} = -1; |
$self->{entity__match} = -1; |
3334 |
## Stay in the state. |
## Stay in the state. |
3335 |
!!!next-input-character; |
!!!next-input-character; |
3337 |
} |
} |
3338 |
} else { |
} else { |
3339 |
!!!cp (1022); |
!!!cp (1022); |
3340 |
$self->{entity__value} .= chr $self->{next_char}; |
$self->{entity__value} .= chr $self->{nc}; |
3341 |
$self->{entity__match} *= 2; |
$self->{entity__match} *= 2; |
3342 |
## Stay in the state. |
## Stay in the state. |
3343 |
!!!next-input-character; |
!!!next-input-character; |
3357 |
if ($self->{prev_state} != DATA_STATE and # in attribute |
if ($self->{prev_state} != DATA_STATE and # in attribute |
3358 |
$self->{entity__match} < -1) { |
$self->{entity__match} < -1) { |
3359 |
!!!cp (1024); |
!!!cp (1024); |
3360 |
$data = '&' . $self->{state_keyword}; |
$data = '&' . $self->{s_kwd}; |
3361 |
# |
# |
3362 |
} else { |
} else { |
3363 |
!!!cp (1025); |
!!!cp (1025); |
3369 |
!!!cp (1026); |
!!!cp (1026); |
3370 |
!!!parse-error (type => 'bare ero', |
!!!parse-error (type => 'bare ero', |
3371 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
3372 |
column => $self->{column_prev} - length $self->{state_keyword}); |
column => $self->{column_prev} - length $self->{s_kwd}); |
3373 |
$data = '&' . $self->{state_keyword}; |
$data = '&' . $self->{s_kwd}; |
3374 |
# |
# |
3375 |
} |
} |
3376 |
|
|
3391 |
!!!emit ({type => CHARACTER_TOKEN, |
!!!emit ({type => CHARACTER_TOKEN, |
3392 |
data => $data, |
data => $data, |
3393 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
3394 |
column => $self->{column_prev} + 1 - length $self->{state_keyword}, |
column => $self->{column_prev} + 1 - length $self->{s_kwd}, |
3395 |
}); |
}); |
3396 |
redo A; |
redo A; |
3397 |
} else { |
} else { |
3398 |
!!!cp (985); |
!!!cp (985); |
3399 |
$self->{current_attribute}->{value} .= $data; |
$self->{ca}->{value} .= $data; |
3400 |
$self->{current_attribute}->{has_reference} = 1 if $has_ref; |
$self->{ca}->{has_reference} = 1 if $has_ref; |
3401 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3402 |
## Reconsume. |
## Reconsume. |
3403 |
redo A; |
redo A; |
3475 |
$doctype_name = '' unless defined $doctype_name; |
$doctype_name = '' unless defined $doctype_name; |
3476 |
$doctype_name =~ tr/a-z/A-Z/; # ASCII case-insensitive |
$doctype_name =~ tr/a-z/A-Z/; # ASCII case-insensitive |
3477 |
if (not defined $token->{name} or # <!DOCTYPE> |
if (not defined $token->{name} or # <!DOCTYPE> |
3478 |
defined $token->{system_identifier}) { |
defined $token->{sysid}) { |
3479 |
!!!cp ('t1'); |
!!!cp ('t1'); |
3480 |
!!!parse-error (type => 'not HTML5', token => $token); |
!!!parse-error (type => 'not HTML5', token => $token); |
3481 |
} elsif ($doctype_name ne 'HTML') { |
} elsif ($doctype_name ne 'HTML') { |
3482 |
!!!cp ('t2'); |
!!!cp ('t2'); |
3483 |
!!!parse-error (type => 'not HTML5', token => $token); |
!!!parse-error (type => 'not HTML5', token => $token); |
3484 |
} elsif (defined $token->{public_identifier}) { |
} elsif (defined $token->{pubid}) { |
3485 |
if ($token->{public_identifier} eq 'XSLT-compat') { |
if ($token->{pubid} eq 'XSLT-compat') { |
3486 |
!!!cp ('t1.2'); |
!!!cp ('t1.2'); |
3487 |
!!!parse-error (type => 'XSLT-compat', token => $token, |
!!!parse-error (type => 'XSLT-compat', token => $token, |
3488 |
level => $self->{level}->{should}); |
level => $self->{level}->{should}); |
3498 |
($token->{name}); ## ISSUE: If name is missing (e.g. <!DOCTYPE>)? |
($token->{name}); ## ISSUE: If name is missing (e.g. <!DOCTYPE>)? |
3499 |
## NOTE: Default value for both |public_id| and |system_id| attributes |
## NOTE: Default value for both |public_id| and |system_id| attributes |
3500 |
## are empty strings, so that we don't set any value in missing cases. |
## are empty strings, so that we don't set any value in missing cases. |
3501 |
$doctype->public_id ($token->{public_identifier}) |
$doctype->public_id ($token->{pubid}) if defined $token->{pubid}; |
3502 |
if defined $token->{public_identifier}; |
$doctype->system_id ($token->{sysid}) if defined $token->{sysid}; |
|
$doctype->system_id ($token->{system_identifier}) |
|
|
if defined $token->{system_identifier}; |
|
3503 |
## NOTE: Other DocumentType attributes are null or empty lists. |
## NOTE: Other DocumentType attributes are null or empty lists. |
3504 |
## ISSUE: internalSubset = null?? |
## ISSUE: internalSubset = null?? |
3505 |
$self->{document}->append_child ($doctype); |
$self->{document}->append_child ($doctype); |
3507 |
if ($token->{quirks} or $doctype_name ne 'HTML') { |
if ($token->{quirks} or $doctype_name ne 'HTML') { |
3508 |
!!!cp ('t4'); |
!!!cp ('t4'); |
3509 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
3510 |
} elsif (defined $token->{public_identifier}) { |
} elsif (defined $token->{pubid}) { |
3511 |
my $pubid = $token->{public_identifier}; |
my $pubid = $token->{pubid}; |
3512 |
$pubid =~ tr/a-z/A-z/; |
$pubid =~ tr/a-z/A-z/; |
3513 |
my $prefix = [ |
my $prefix = [ |
3514 |
"+//SILMARIL//DTD HTML PRO V0R11 19970101//", |
"+//SILMARIL//DTD HTML PRO V0R11 19970101//", |
3582 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
3583 |
} elsif ($pubid =~ m[^-//W3C//DTD HTML 4.01 FRAMESET//] or |
} elsif ($pubid =~ m[^-//W3C//DTD HTML 4.01 FRAMESET//] or |
3584 |
$pubid =~ m[^-//W3C//DTD HTML 4.01 TRANSITIONAL//]) { |
$pubid =~ m[^-//W3C//DTD HTML 4.01 TRANSITIONAL//]) { |
3585 |
if (defined $token->{system_identifier}) { |
if (defined $token->{sysid}) { |
3586 |
!!!cp ('t6'); |
!!!cp ('t6'); |
3587 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
3588 |
} else { |
} else { |
3599 |
} else { |
} else { |
3600 |
!!!cp ('t10'); |
!!!cp ('t10'); |
3601 |
} |
} |
3602 |
if (defined $token->{system_identifier}) { |
if (defined $token->{sysid}) { |
3603 |
my $sysid = $token->{system_identifier}; |
my $sysid = $token->{sysid}; |
3604 |
$sysid =~ tr/A-Z/a-z/; |
$sysid =~ tr/A-Z/a-z/; |
3605 |
if ($sysid eq "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd") { |
if ($sysid eq "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd") { |
3606 |
## NOTE: Ensure that |PUBLIC "(limited quirks)" "(quirks)"| is |
## NOTE: Ensure that |PUBLIC "(limited quirks)" "(quirks)"| is |
7807 |
require Whatpm::Charset::DecodeHandle; |
require Whatpm::Charset::DecodeHandle; |
7808 |
my $input = Whatpm::Charset::DecodeHandle::CharString->new (\($_[0])); |
my $input = Whatpm::Charset::DecodeHandle::CharString->new (\($_[0])); |
7809 |
$input = $get_wrapper->($input); |
$input = $get_wrapper->($input); |
7810 |
$p->{set_next_char} = sub { |
$p->{set_nc} = sub { |
7811 |
my $self = shift; |
my $self = shift; |
7812 |
|
|
7813 |
my $char = ''; |
my $char = ''; |
7814 |
if (defined $self->{next_next_char}) { |
if (defined $self->{next_nc}) { |
7815 |
$char = $self->{next_next_char}; |
$char = $self->{next_nc}; |
7816 |
delete $self->{next_next_char}; |
delete $self->{next_nc}; |
7817 |
$self->{next_char} = ord $char; |
$self->{nc} = ord $char; |
7818 |
} else { |
} else { |
7819 |
$self->{char_buffer} = ''; |
$self->{char_buffer} = ''; |
7820 |
$self->{char_buffer_pos} = 0; |
$self->{char_buffer_pos} = 0; |
7826 |
$self->{line_prev} = $self->{line}; |
$self->{line_prev} = $self->{line}; |
7827 |
$self->{column_prev} = $self->{column}; |
$self->{column_prev} = $self->{column}; |
7828 |
$self->{column}++; |
$self->{column}++; |
7829 |
$self->{next_char} |
$self->{nc} |
7830 |
= ord substr ($self->{char_buffer}, |
= ord substr ($self->{char_buffer}, |
7831 |
$self->{char_buffer_pos}++, 1); |
$self->{char_buffer_pos}++, 1); |
7832 |
return; |
return; |
7833 |
} |
} |
7834 |
|
|
7835 |
if ($input->read ($char, 1)) { |
if ($input->read ($char, 1)) { |
7836 |
$self->{next_char} = ord $char; |
$self->{nc} = ord $char; |
7837 |
} else { |
} else { |
7838 |
$self->{next_char} = -1; |
$self->{nc} = -1; |
7839 |
return; |
return; |
7840 |
} |
} |
7841 |
} |
} |
7843 |
($p->{line_prev}, $p->{column_prev}) = ($p->{line}, $p->{column}); |
($p->{line_prev}, $p->{column_prev}) = ($p->{line}, $p->{column}); |
7844 |
$p->{column}++; |
$p->{column}++; |
7845 |
|
|
7846 |
if ($self->{next_char} == 0x000A) { # LF |
if ($self->{nc} == 0x000A) { # LF |
7847 |
$p->{line}++; |
$p->{line}++; |
7848 |
$p->{column} = 0; |
$p->{column} = 0; |
7849 |
!!!cp ('i1'); |
!!!cp ('i1'); |
7850 |
} elsif ($self->{next_char} == 0x000D) { # CR |
} elsif ($self->{nc} == 0x000D) { # CR |
7851 |
## TODO: support for abort/streaming |
## TODO: support for abort/streaming |
7852 |
my $next = ''; |
my $next = ''; |
7853 |
if ($input->read ($next, 1) and $next ne "\x0A") { |
if ($input->read ($next, 1) and $next ne "\x0A") { |
7854 |
$self->{next_next_char} = $next; |
$self->{next_nc} = $next; |
7855 |
} |
} |
7856 |
$self->{next_char} = 0x000A; # LF # MUST |
$self->{nc} = 0x000A; # LF # MUST |
7857 |
$p->{line}++; |
$p->{line}++; |
7858 |
$p->{column} = 0; |
$p->{column} = 0; |
7859 |
!!!cp ('i2'); |
!!!cp ('i2'); |
7860 |
} elsif ($self->{next_char} == 0x0000) { # NULL |
} elsif ($self->{nc} == 0x0000) { # NULL |
7861 |
!!!cp ('i4'); |
!!!cp ('i4'); |
7862 |
!!!parse-error (type => 'NULL'); |
!!!parse-error (type => 'NULL'); |
7863 |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{nc} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
7864 |
} |
} |
7865 |
}; |
}; |
7866 |
|
|
7867 |
$p->{read_until} = sub { |
$p->{read_until} = sub { |
7868 |
#my ($scalar, $specials_range, $offset) = @_; |
#my ($scalar, $specials_range, $offset) = @_; |
7869 |
return 0 if defined $p->{next_next_char}; |
return 0 if defined $p->{next_nc}; |
7870 |
|
|
7871 |
my $pattern = qr/[^$_[1]\x00\x0A\x0D]/; |
my $pattern = qr/[^$_[1]\x00\x0A\x0D]/; |
7872 |
my $offset = $_[2] || 0; |
my $offset = $_[2] || 0; |
7883 |
$p->{line_prev} = $p->{line}; |
$p->{line_prev} = $p->{line}; |
7884 |
$p->{column_prev} = $p->{column} - 1; |
$p->{column_prev} = $p->{column} - 1; |
7885 |
$p->{prev_char} = [-1, -1, -1]; |
$p->{prev_char} = [-1, -1, -1]; |
7886 |
$p->{next_char} = -1; |
$p->{nc} = -1; |
7887 |
} |
} |
7888 |
return $count; |
return $count; |
7889 |
} else { |
} else { |
7895 |
$p->{column} += $count; |
$p->{column} += $count; |
7896 |
$p->{column_prev} += $count; |
$p->{column_prev} += $count; |
7897 |
$p->{prev_char} = [-1, -1, -1]; |
$p->{prev_char} = [-1, -1, -1]; |
7898 |
$p->{next_char} = -1; |
$p->{nc} = -1; |
7899 |
} |
} |
7900 |
return $count; |
return $count; |
7901 |
} |
} |