15 |
CHARACTER_TOKEN |
CHARACTER_TOKEN |
16 |
PI_TOKEN |
PI_TOKEN |
17 |
ABORT_TOKEN |
ABORT_TOKEN |
18 |
|
END_OF_DOCTYPE_TOKEN |
19 |
|
ATTLIST_TOKEN |
20 |
|
ELEMENT_TOKEN |
21 |
|
GENERAL_ENTITY_TOKEN |
22 |
|
PARAMETER_ENTITY_TOKEN |
23 |
|
NOTATION_TOKEN |
24 |
); |
); |
25 |
|
|
26 |
our %EXPORT_TAGS = ( |
our %EXPORT_TAGS = ( |
33 |
CHARACTER_TOKEN |
CHARACTER_TOKEN |
34 |
PI_TOKEN |
PI_TOKEN |
35 |
ABORT_TOKEN |
ABORT_TOKEN |
36 |
|
END_OF_DOCTYPE_TOKEN |
37 |
|
ATTLIST_TOKEN |
38 |
|
ELEMENT_TOKEN |
39 |
|
GENERAL_ENTITY_TOKEN |
40 |
|
PARAMETER_ENTITY_TOKEN |
41 |
|
NOTATION_TOKEN |
42 |
)], |
)], |
43 |
); |
); |
44 |
} |
} |
45 |
|
|
46 |
|
## NOTE: Differences from the XML5 draft are marked as "XML5:". |
47 |
|
|
48 |
## Token types |
## Token types |
49 |
|
|
50 |
sub DOCTYPE_TOKEN () { 1 } |
sub DOCTYPE_TOKEN () { 1 } ## XML5: No DOCTYPE token. |
51 |
sub COMMENT_TOKEN () { 2 } |
sub COMMENT_TOKEN () { 2 } |
52 |
sub START_TAG_TOKEN () { 3 } |
sub START_TAG_TOKEN () { 3 } |
53 |
sub END_TAG_TOKEN () { 4 } |
sub END_TAG_TOKEN () { 4 } |
54 |
sub END_OF_FILE_TOKEN () { 5 } |
sub END_OF_FILE_TOKEN () { 5 } |
55 |
sub CHARACTER_TOKEN () { 6 } |
sub CHARACTER_TOKEN () { 6 } |
56 |
sub PI_TOKEN () { 7 } # XML5 |
sub PI_TOKEN () { 7 } ## NOTE: XML only. |
57 |
sub ABORT_TOKEN () { 8 } # Not a token actually |
sub ABORT_TOKEN () { 8 } ## NOTE: For internal processing. |
58 |
|
sub END_OF_DOCTYPE_TOKEN () { 9 } ## NOTE: XML only. |
59 |
|
sub ATTLIST_TOKEN () { 10 } ## NOTE: XML only. |
60 |
|
sub ELEMENT_TOKEN () { 11 } ## NOTE: XML only. |
61 |
|
sub GENERAL_ENTITY_TOKEN () { 12 } ## NOTE: XML only. |
62 |
|
sub PARAMETER_ENTITY_TOKEN () { 13 } ## NOTE: XML only. |
63 |
|
sub NOTATION_TOKEN () { 14 } ## NOTE: XML only. |
64 |
|
|
65 |
|
## XML5: XML5 has "empty tag token". In this implementation, it is |
66 |
|
## represented as a start tag token with $self->{self_closing} flag |
67 |
|
## set to true. |
68 |
|
|
69 |
|
## XML5: XML5 has "short end tag token". In this implementation, it |
70 |
|
## is represented as an end tag token with $token->{tag_name} flag set |
71 |
|
## to an empty string. |
72 |
|
|
73 |
package Whatpm::HTML; |
package Whatpm::HTML; |
74 |
|
|
142 |
sub ENTITY_NAME_STATE () { 49 } |
sub ENTITY_NAME_STATE () { 49 } |
143 |
sub PCDATA_STATE () { 50 } # "data state" in the spec |
sub PCDATA_STATE () { 50 } # "data state" in the spec |
144 |
|
|
145 |
|
## XML-only states |
146 |
|
sub PI_STATE () { 51 } |
147 |
|
sub PI_TARGET_STATE () { 52 } |
148 |
|
sub PI_TARGET_AFTER_STATE () { 53 } |
149 |
|
sub PI_DATA_STATE () { 54 } |
150 |
|
sub PI_AFTER_STATE () { 55 } |
151 |
|
sub PI_DATA_AFTER_STATE () { 56 } |
152 |
|
sub DOCTYPE_INTERNAL_SUBSET_STATE () { 57 } |
153 |
|
sub DOCTYPE_INTERNAL_SUBSET_AFTER_STATE () { 58 } |
154 |
|
sub BOGUS_DOCTYPE_INTERNAL_SUBSET_AFTER_STATE () { 59 } |
155 |
|
sub DOCTYPE_TAG_STATE () { 60 } |
156 |
|
sub DOCTYPE_MARKUP_DECLARATION_OPEN_STATE () { 61 } |
157 |
|
sub MD_ATTLIST_STATE () { 62 } |
158 |
|
sub MD_E_STATE () { 63 } |
159 |
|
sub MD_ELEMENT_STATE () { 64 } |
160 |
|
sub MD_ENTITY_STATE () { 65 } |
161 |
|
sub MD_NOTATION_STATE () { 66 } |
162 |
|
sub DOCTYPE_MD_STATE () { 67 } |
163 |
|
sub BEFORE_MD_NAME_STATE () { 68 } |
164 |
|
sub MD_NAME_STATE () { 69 } |
165 |
|
sub DOCTYPE_ENTITY_PARAMETER_BEFORE_STATE () { 70 } |
166 |
|
sub DOCTYPE_ATTLIST_NAME_AFTER_STATE () { 71 } |
167 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_NAME_STATE () { 72 } |
168 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_NAME_AFTER_STATE () { 73 } |
169 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_TYPE_STATE () { 74 } |
170 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_TYPE_AFTER_STATE () { 75 } |
171 |
|
sub BEFORE_ALLOWED_TOKEN_STATE () { 76 } |
172 |
|
sub ALLOWED_TOKEN_STATE () { 77 } |
173 |
|
sub AFTER_ALLOWED_TOKEN_STATE () { 78 } |
174 |
|
sub AFTER_ALLOWED_TOKENS_STATE () { 79 } |
175 |
|
sub BEFORE_ATTR_DEFAULT_STATE () { 80 } |
176 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_BEFORE_STATE () { 81 } |
177 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_STATE () { 82 } |
178 |
|
sub DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_AFTER_STATE () { 83 } |
179 |
|
sub AFTER_ATTLIST_ATTR_VALUE_QUOTED_STATE () { 84 } |
180 |
|
sub BOGUS_MD_STATE () { 85 } |
181 |
|
|
182 |
## Tree constructor state constants (see Whatpm::HTML for the full |
## Tree constructor state constants (see Whatpm::HTML for the full |
183 |
## list and descriptions) |
## list and descriptions) |
184 |
|
|
243 |
#$self->{is_xml} (if XML) |
#$self->{is_xml} (if XML) |
244 |
|
|
245 |
$self->{state} = DATA_STATE; # MUST |
$self->{state} = DATA_STATE; # MUST |
246 |
#$self->{s_kwd}; # state keyword - initialized when used |
$self->{s_kwd} = ''; # Data state keyword |
247 |
|
#$self->{kwd} = ''; # State-dependent keyword; initialized when used |
248 |
#$self->{entity__value}; # initialized when used |
#$self->{entity__value}; # initialized when used |
249 |
#$self->{entity__match}; # initialized when used |
#$self->{entity__match}; # initialized when used |
250 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # be |
$self->{content_model} = PCDATA_CONTENT_MODEL; # be |
264 |
|
|
265 |
## A token has: |
## A token has: |
266 |
## ->{type} == DOCTYPE_TOKEN, START_TAG_TOKEN, END_TAG_TOKEN, COMMENT_TOKEN, |
## ->{type} == DOCTYPE_TOKEN, START_TAG_TOKEN, END_TAG_TOKEN, COMMENT_TOKEN, |
267 |
## CHARACTER_TOKEN, or END_OF_FILE_TOKEN |
## CHARACTER_TOKEN, END_OF_FILE_TOKEN, PI_TOKEN, or ABORT_TOKEN |
268 |
## ->{name} (DOCTYPE_TOKEN) |
## ->{name} (DOCTYPE_TOKEN) |
269 |
## ->{tag_name} (START_TAG_TOKEN, END_TAG_TOKEN) |
## ->{tag_name} (START_TAG_TOKEN, END_TAG_TOKEN) |
270 |
|
## ->{target} (PI_TOKEN) |
271 |
## ->{pubid} (DOCTYPE_TOKEN) |
## ->{pubid} (DOCTYPE_TOKEN) |
272 |
## ->{sysid} (DOCTYPE_TOKEN) |
## ->{sysid} (DOCTYPE_TOKEN) |
273 |
## ->{quirks} == 1 or 0 (DOCTYPE_TOKEN): "force-quirks" flag |
## ->{quirks} == 1 or 0 (DOCTYPE_TOKEN): "force-quirks" flag |
275 |
## ->{name} |
## ->{name} |
276 |
## ->{value} |
## ->{value} |
277 |
## ->{has_reference} == 1 or 0 |
## ->{has_reference} == 1 or 0 |
278 |
## ->{data} (COMMENT_TOKEN, CHARACTER_TOKEN) |
## ->{index}: Index of the attribute in a tag. |
279 |
|
## ->{data} (COMMENT_TOKEN, CHARACTER_TOKEN, PI_TOKEN) |
280 |
|
## ->{has_reference} == 1 or 0 (CHARACTER_TOKEN) |
281 |
|
## ->{last_index} (ELEMENT_TOKEN): Next attribute's index - 1. |
282 |
|
## ->{has_internal_subset} = 1 or 0 (DOCTYPE_TOKEN) |
283 |
|
|
284 |
## NOTE: The "self-closing flag" is hold as |$self->{self_closing}|. |
## NOTE: The "self-closing flag" is hold as |$self->{self_closing}|. |
285 |
## |->{self_closing}| is used to save the value of |$self->{self_closing}| |
## |->{self_closing}| is used to save the value of |$self->{self_closing}| |
286 |
## while the token is pushed back to the stack. |
## while the token is pushed back to the stack. |
300 |
0x0009 => 1, # CHARACTER TABULATION (HT) |
0x0009 => 1, # CHARACTER TABULATION (HT) |
301 |
0x000A => 1, # LINE FEED (LF) |
0x000A => 1, # LINE FEED (LF) |
302 |
#0x000B => 0, # LINE TABULATION (VT) |
#0x000B => 0, # LINE TABULATION (VT) |
303 |
0x000C => 1, # FORM FEED (FF) |
0x000C => 1, # FORM FEED (FF) ## XML5: Not a space character. |
304 |
#0x000D => 1, # CARRIAGE RETURN (CR) |
#0x000D => 1, # CARRIAGE RETURN (CR) |
305 |
0x0020 => 1, # SPACE (SP) |
0x0020 => 1, # SPACE (SP) |
306 |
}; |
}; |
384 |
} |
} |
385 |
} elsif ($self->{nc} == 0x002D) { # - |
} elsif ($self->{nc} == 0x002D) { # - |
386 |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
387 |
$self->{s_kwd} .= '-'; |
if ($self->{s_kwd} eq '<!-') { |
|
|
|
|
if ($self->{s_kwd} eq '<!--') { |
|
388 |
!!!cp (3); |
!!!cp (3); |
389 |
$self->{escape} = 1; # unless $self->{escape}; |
$self->{escape} = 1; # unless $self->{escape}; |
390 |
$self->{s_kwd} = '--'; |
$self->{s_kwd} = '--'; |
391 |
# |
# |
392 |
} elsif ($self->{s_kwd} eq '---') { |
} elsif ($self->{s_kwd} eq '-') { |
393 |
!!!cp (4); |
!!!cp (4); |
394 |
$self->{s_kwd} = '--'; |
$self->{s_kwd} = '--'; |
395 |
# |
# |
396 |
|
} elsif ($self->{s_kwd} eq '<!' or $self->{s_kwd} eq '-') { |
397 |
|
!!!cp (4.1); |
398 |
|
$self->{s_kwd} .= '-'; |
399 |
|
# |
400 |
} else { |
} else { |
401 |
!!!cp (5); |
!!!cp (5); |
402 |
|
$self->{s_kwd} = '-'; |
403 |
# |
# |
404 |
} |
} |
405 |
} |
} |
435 |
if ($self->{s_kwd} eq '--') { |
if ($self->{s_kwd} eq '--') { |
436 |
!!!cp (8); |
!!!cp (8); |
437 |
delete $self->{escape}; |
delete $self->{escape}; |
438 |
|
# |
439 |
} else { |
} else { |
440 |
!!!cp (9); |
!!!cp (9); |
441 |
|
# |
442 |
} |
} |
443 |
|
} elsif ($self->{is_xml} and $self->{s_kwd} eq ']]') { |
444 |
|
!!!cp (9.1); |
445 |
|
!!!parse-error (type => 'unmatched mse', ## TODO: type |
446 |
|
line => $self->{line_prev}, |
447 |
|
column => $self->{column_prev} - 1); |
448 |
|
# |
449 |
} else { |
} else { |
450 |
!!!cp (10); |
!!!cp (10); |
451 |
|
# |
452 |
} |
} |
453 |
|
|
454 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
455 |
# |
# |
456 |
|
} elsif ($self->{nc} == 0x005D) { # ] |
457 |
|
if ($self->{s_kwd} eq ']' or $self->{s_kwd} eq '') { |
458 |
|
!!!cp (10.1); |
459 |
|
$self->{s_kwd} .= ']'; |
460 |
|
} elsif ($self->{s_kwd} eq ']]') { |
461 |
|
!!!cp (10.2); |
462 |
|
# |
463 |
|
} else { |
464 |
|
!!!cp (10.3); |
465 |
|
$self->{s_kwd} = ''; |
466 |
|
} |
467 |
|
# |
468 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
469 |
!!!cp (11); |
!!!cp (11); |
470 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
482 |
data => chr $self->{nc}, |
data => chr $self->{nc}, |
483 |
line => $self->{line}, column => $self->{column}, |
line => $self->{line}, column => $self->{column}, |
484 |
}; |
}; |
485 |
if ($self->{read_until}->($token->{data}, q[-!<>&], |
if ($self->{read_until}->($token->{data}, q{-!<>&\]}, |
486 |
length $token->{data})) { |
length $token->{data})) { |
487 |
$self->{s_kwd} = ''; |
$self->{s_kwd} = ''; |
488 |
} |
} |
489 |
|
|
490 |
## Stay in the data state. |
## Stay in the data state. |
491 |
if ($self->{content_model} == PCDATA_CONTENT_MODEL) { |
if (not $self->{is_xml} and |
492 |
|
$self->{content_model} == PCDATA_CONTENT_MODEL) { |
493 |
!!!cp (13); |
!!!cp (13); |
494 |
$self->{state} = PCDATA_STATE; |
$self->{state} = PCDATA_STATE; |
495 |
} else { |
} else { |
500 |
!!!emit ($token); |
!!!emit ($token); |
501 |
redo A; |
redo A; |
502 |
} elsif ($self->{state} == TAG_OPEN_STATE) { |
} elsif ($self->{state} == TAG_OPEN_STATE) { |
503 |
|
## XML5: "tag state". |
504 |
|
|
505 |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
506 |
if ($self->{nc} == 0x002F) { # / |
if ($self->{nc} == 0x002F) { # / |
507 |
!!!cp (15); |
!!!cp (15); |
510 |
redo A; |
redo A; |
511 |
} elsif ($self->{nc} == 0x0021) { # ! |
} elsif ($self->{nc} == 0x0021) { # ! |
512 |
!!!cp (15.1); |
!!!cp (15.1); |
513 |
$self->{s_kwd} = '<' unless $self->{escape}; |
$self->{s_kwd} = $self->{escaped} ? '' : '<'; |
514 |
# |
# |
515 |
} else { |
} else { |
516 |
!!!cp (16); |
!!!cp (16); |
517 |
|
$self->{s_kwd} = ''; |
518 |
# |
# |
519 |
} |
} |
520 |
|
|
563 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
564 |
column => $self->{column_prev}); |
column => $self->{column_prev}); |
565 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
566 |
|
$self->{s_kwd} = ''; |
567 |
!!!next-input-character; |
!!!next-input-character; |
568 |
|
|
569 |
!!!emit ({type => CHARACTER_TOKEN, data => '<>', |
!!!emit ({type => CHARACTER_TOKEN, data => '<>', |
573 |
|
|
574 |
redo A; |
redo A; |
575 |
} elsif ($self->{nc} == 0x003F) { # ? |
} elsif ($self->{nc} == 0x003F) { # ? |
576 |
!!!cp (22); |
if ($self->{is_xml}) { |
577 |
!!!parse-error (type => 'pio', |
!!!cp (22.1); |
578 |
line => $self->{line_prev}, |
$self->{state} = PI_STATE; |
579 |
column => $self->{column_prev}); |
!!!next-input-character; |
580 |
$self->{state} = BOGUS_COMMENT_STATE; |
redo A; |
581 |
$self->{ct} = {type => COMMENT_TOKEN, data => '', |
} else { |
582 |
line => $self->{line_prev}, |
!!!cp (22); |
583 |
column => $self->{column_prev}, |
!!!parse-error (type => 'pio', |
584 |
}; |
line => $self->{line_prev}, |
585 |
## $self->{nc} is intentionally left as is |
column => $self->{column_prev}); |
586 |
redo A; |
$self->{state} = BOGUS_COMMENT_STATE; |
587 |
} else { |
$self->{ct} = {type => COMMENT_TOKEN, data => '', |
588 |
|
line => $self->{line_prev}, |
589 |
|
column => $self->{column_prev}, |
590 |
|
}; |
591 |
|
## $self->{nc} is intentionally left as is |
592 |
|
redo A; |
593 |
|
} |
594 |
|
} elsif (not $self->{is_xml} or $is_space->{$self->{nc}}) { |
595 |
!!!cp (23); |
!!!cp (23); |
596 |
!!!parse-error (type => 'bare stago', |
!!!parse-error (type => 'bare stago', |
597 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
598 |
column => $self->{column_prev}); |
column => $self->{column_prev}); |
599 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
600 |
|
$self->{s_kwd} = ''; |
601 |
## reconsume |
## reconsume |
602 |
|
|
603 |
!!!emit ({type => CHARACTER_TOKEN, data => '<', |
!!!emit ({type => CHARACTER_TOKEN, data => '<', |
606 |
}); |
}); |
607 |
|
|
608 |
redo A; |
redo A; |
609 |
|
} else { |
610 |
|
## XML5: "<:" is a parse error. |
611 |
|
!!!cp (23.1); |
612 |
|
$self->{ct} = {type => START_TAG_TOKEN, |
613 |
|
tag_name => chr ($self->{nc}), |
614 |
|
line => $self->{line_prev}, |
615 |
|
column => $self->{column_prev}}; |
616 |
|
$self->{state} = TAG_NAME_STATE; |
617 |
|
!!!next-input-character; |
618 |
|
redo A; |
619 |
} |
} |
620 |
} else { |
} else { |
621 |
die "$0: $self->{content_model} in tag open"; |
die "$0: $self->{content_model} in tag open"; |
624 |
## NOTE: The "close tag open state" in the spec is implemented as |
## NOTE: The "close tag open state" in the spec is implemented as |
625 |
## |CLOSE_TAG_OPEN_STATE| and |CDATA_RCDATA_CLOSE_TAG_STATE|. |
## |CLOSE_TAG_OPEN_STATE| and |CDATA_RCDATA_CLOSE_TAG_STATE|. |
626 |
|
|
627 |
|
## XML5: "end tag state". |
628 |
|
|
629 |
my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1); # "<"of"</" |
my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1); # "<"of"</" |
630 |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
631 |
if (defined $self->{last_stag_name}) { |
if (defined $self->{last_stag_name}) { |
632 |
$self->{state} = CDATA_RCDATA_CLOSE_TAG_STATE; |
$self->{state} = CDATA_RCDATA_CLOSE_TAG_STATE; |
633 |
$self->{s_kwd} = ''; |
$self->{kwd} = ''; |
634 |
## Reconsume. |
## Reconsume. |
635 |
redo A; |
redo A; |
636 |
} else { |
} else { |
638 |
## NOTE: See <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564>. |
## NOTE: See <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564>. |
639 |
!!!cp (28); |
!!!cp (28); |
640 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
641 |
|
$self->{s_kwd} = ''; |
642 |
## Reconsume. |
## Reconsume. |
643 |
!!!emit ({type => CHARACTER_TOKEN, data => '</', |
!!!emit ({type => CHARACTER_TOKEN, data => '</', |
644 |
line => $l, column => $c, |
line => $l, column => $c, |
667 |
!!!next-input-character; |
!!!next-input-character; |
668 |
redo A; |
redo A; |
669 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
|
!!!cp (31); |
|
670 |
!!!parse-error (type => 'empty end tag', |
!!!parse-error (type => 'empty end tag', |
671 |
line => $self->{line_prev}, ## "<" in "</>" |
line => $self->{line_prev}, ## "<" in "</>" |
672 |
column => $self->{column_prev} - 1); |
column => $self->{column_prev} - 1); |
673 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
674 |
!!!next-input-character; |
$self->{s_kwd} = ''; |
675 |
|
if ($self->{is_xml}) { |
676 |
|
!!!cp (31); |
677 |
|
## XML5: No parse error. |
678 |
|
|
679 |
|
## NOTE: This parser raises a parse error, since it supports |
680 |
|
## XML1, not XML5. |
681 |
|
|
682 |
|
## NOTE: A short end tag token. |
683 |
|
my $ct = {type => END_TAG_TOKEN, |
684 |
|
tag_name => '', |
685 |
|
line => $self->{line_prev}, |
686 |
|
column => $self->{column_prev} - 1, |
687 |
|
}; |
688 |
|
!!!next-input-character; |
689 |
|
!!!emit ($ct); |
690 |
|
} else { |
691 |
|
!!!cp (31.1); |
692 |
|
!!!next-input-character; |
693 |
|
} |
694 |
redo A; |
redo A; |
695 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
696 |
!!!cp (32); |
!!!cp (32); |
697 |
!!!parse-error (type => 'bare etago'); |
!!!parse-error (type => 'bare etago'); |
698 |
|
$self->{s_kwd} = ''; |
699 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
700 |
# reconsume |
# reconsume |
701 |
|
|
704 |
}); |
}); |
705 |
|
|
706 |
redo A; |
redo A; |
707 |
} else { |
} elsif (not $self->{is_xml} or |
708 |
|
$is_space->{$self->{nc}}) { |
709 |
!!!cp (33); |
!!!cp (33); |
710 |
!!!parse-error (type => 'bogus end tag'); |
!!!parse-error (type => 'bogus end tag', |
711 |
|
line => $self->{line_prev}, # "<" of "</" |
712 |
|
column => $self->{column_prev} - 1); |
713 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
714 |
$self->{ct} = {type => COMMENT_TOKEN, data => '', |
$self->{ct} = {type => COMMENT_TOKEN, data => '', |
715 |
line => $self->{line_prev}, # "<" of "</" |
line => $self->{line_prev}, # "<" of "</" |
722 |
## generated from the bogus end tag, as defined in the |
## generated from the bogus end tag, as defined in the |
723 |
## "bogus comment state" entry. |
## "bogus comment state" entry. |
724 |
redo A; |
redo A; |
725 |
|
} else { |
726 |
|
## XML5: "</:" is a parse error. |
727 |
|
!!!cp (30.1); |
728 |
|
$self->{ct} = {type => END_TAG_TOKEN, |
729 |
|
tag_name => chr ($self->{nc}), |
730 |
|
line => $l, column => $c}; |
731 |
|
$self->{state} = TAG_NAME_STATE; ## XML5: "end tag name state". |
732 |
|
!!!next-input-character; |
733 |
|
redo A; |
734 |
} |
} |
735 |
} elsif ($self->{state} == CDATA_RCDATA_CLOSE_TAG_STATE) { |
} elsif ($self->{state} == CDATA_RCDATA_CLOSE_TAG_STATE) { |
736 |
my $ch = substr $self->{last_stag_name}, length $self->{s_kwd}, 1; |
my $ch = substr $self->{last_stag_name}, length $self->{kwd}, 1; |
737 |
if (length $ch) { |
if (length $ch) { |
738 |
my $CH = $ch; |
my $CH = $ch; |
739 |
$ch =~ tr/a-z/A-Z/; |
$ch =~ tr/a-z/A-Z/; |
741 |
if ($nch eq $ch or $nch eq $CH) { |
if ($nch eq $ch or $nch eq $CH) { |
742 |
!!!cp (24); |
!!!cp (24); |
743 |
## Stay in the state. |
## Stay in the state. |
744 |
$self->{s_kwd} .= $nch; |
$self->{kwd} .= $nch; |
745 |
!!!next-input-character; |
!!!next-input-character; |
746 |
redo A; |
redo A; |
747 |
} else { |
} else { |
748 |
!!!cp (25); |
!!!cp (25); |
749 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
750 |
|
$self->{s_kwd} = ''; |
751 |
## Reconsume. |
## Reconsume. |
752 |
!!!emit ({type => CHARACTER_TOKEN, |
!!!emit ({type => CHARACTER_TOKEN, |
753 |
data => '</' . $self->{s_kwd}, |
data => '</' . $self->{kwd}, |
754 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
755 |
column => $self->{column_prev} - 1 - length $self->{s_kwd}, |
column => $self->{column_prev} - 1 - length $self->{kwd}, |
756 |
}); |
}); |
757 |
redo A; |
redo A; |
758 |
} |
} |
766 |
!!!cp (26); |
!!!cp (26); |
767 |
## Reconsume. |
## Reconsume. |
768 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
769 |
|
$self->{s_kwd} = ''; |
770 |
!!!emit ({type => CHARACTER_TOKEN, |
!!!emit ({type => CHARACTER_TOKEN, |
771 |
data => '</' . $self->{s_kwd}, |
data => '</' . $self->{kwd}, |
772 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
773 |
column => $self->{column_prev} - 1 - length $self->{s_kwd}, |
column => $self->{column_prev} - 1 - length $self->{kwd}, |
774 |
}); |
}); |
775 |
redo A; |
redo A; |
776 |
} else { |
} else { |
779 |
= {type => END_TAG_TOKEN, |
= {type => END_TAG_TOKEN, |
780 |
tag_name => $self->{last_stag_name}, |
tag_name => $self->{last_stag_name}, |
781 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
782 |
column => $self->{column_prev} - 1 - length $self->{s_kwd}}; |
column => $self->{column_prev} - 1 - length $self->{kwd}}; |
783 |
$self->{state} = TAG_NAME_STATE; |
$self->{state} = TAG_NAME_STATE; |
784 |
## Reconsume. |
## Reconsume. |
785 |
redo A; |
redo A; |
808 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
809 |
} |
} |
810 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
811 |
|
$self->{s_kwd} = ''; |
812 |
!!!next-input-character; |
!!!next-input-character; |
813 |
|
|
814 |
!!!emit ($self->{ct}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
841 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
842 |
} |
} |
843 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
844 |
|
$self->{s_kwd} = ''; |
845 |
# reconsume |
# reconsume |
846 |
|
|
847 |
!!!emit ($self->{ct}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
861 |
redo A; |
redo A; |
862 |
} |
} |
863 |
} elsif ($self->{state} == BEFORE_ATTRIBUTE_NAME_STATE) { |
} elsif ($self->{state} == BEFORE_ATTRIBUTE_NAME_STATE) { |
864 |
|
## XML5: "Tag attribute name before state". |
865 |
|
|
866 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
867 |
!!!cp (45); |
!!!cp (45); |
868 |
## Stay in the state |
## Stay in the state |
884 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
885 |
} |
} |
886 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
887 |
|
$self->{s_kwd} = ''; |
888 |
!!!next-input-character; |
!!!next-input-character; |
889 |
|
|
890 |
!!!emit ($self->{ct}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
922 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
923 |
} |
} |
924 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
925 |
|
$self->{s_kwd} = ''; |
926 |
# reconsume |
# reconsume |
927 |
|
|
928 |
!!!emit ($self->{ct}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
935 |
0x003D => 1, # = |
0x003D => 1, # = |
936 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
937 |
!!!cp (55); |
!!!cp (55); |
938 |
|
## XML5: Not a parse error. |
939 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
940 |
} else { |
} else { |
941 |
!!!cp (56); |
!!!cp (56); |
942 |
|
## XML5: ":" raises a parse error and is ignored. |
943 |
} |
} |
944 |
$self->{ca} |
$self->{ca} |
945 |
= {name => chr ($self->{nc}), |
= {name => chr ($self->{nc}), |
950 |
redo A; |
redo A; |
951 |
} |
} |
952 |
} elsif ($self->{state} == ATTRIBUTE_NAME_STATE) { |
} elsif ($self->{state} == ATTRIBUTE_NAME_STATE) { |
953 |
|
## XML5: "Tag attribute name state". |
954 |
|
|
955 |
my $before_leave = sub { |
my $before_leave = sub { |
956 |
if (exists $self->{ct}->{attributes} # start tag or end tag |
if (exists $self->{ct}->{attributes} # start tag or end tag |
957 |
->{$self->{ca}->{name}}) { # MUST |
->{$self->{ca}->{name}}) { # MUST |
962 |
!!!cp (58); |
!!!cp (58); |
963 |
$self->{ct}->{attributes}->{$self->{ca}->{name}} |
$self->{ct}->{attributes}->{$self->{ca}->{name}} |
964 |
= $self->{ca}; |
= $self->{ca}; |
965 |
|
$self->{ca}->{index} = ++$self->{ct}->{last_index}; |
966 |
} |
} |
967 |
}; # $before_leave |
}; # $before_leave |
968 |
|
|
979 |
!!!next-input-character; |
!!!next-input-character; |
980 |
redo A; |
redo A; |
981 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
982 |
|
if ($self->{is_xml}) { |
983 |
|
!!!cp (60.1); |
984 |
|
## XML5: Not a parse error. |
985 |
|
!!!parse-error (type => 'no attr value'); ## TODO: type |
986 |
|
} else { |
987 |
|
!!!cp (60.2); |
988 |
|
} |
989 |
|
|
990 |
$before_leave->(); |
$before_leave->(); |
991 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
992 |
!!!cp (61); |
!!!cp (61); |
1001 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1002 |
} |
} |
1003 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1004 |
|
$self->{s_kwd} = ''; |
1005 |
!!!next-input-character; |
!!!next-input-character; |
1006 |
|
|
1007 |
!!!emit ($self->{ct}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1016 |
!!!next-input-character; |
!!!next-input-character; |
1017 |
redo A; |
redo A; |
1018 |
} elsif ($self->{nc} == 0x002F) { # / |
} elsif ($self->{nc} == 0x002F) { # / |
1019 |
!!!cp (64); |
if ($self->{is_xml}) { |
1020 |
|
!!!cp (64); |
1021 |
|
## XML5: Not a parse error. |
1022 |
|
!!!parse-error (type => 'no attr value'); ## TODO: type |
1023 |
|
} else { |
1024 |
|
!!!cp (64.1); |
1025 |
|
} |
1026 |
|
|
1027 |
$before_leave->(); |
$before_leave->(); |
1028 |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
1029 |
!!!next-input-character; |
!!!next-input-character; |
1047 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1048 |
} |
} |
1049 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1050 |
|
$self->{s_kwd} = ''; |
1051 |
# reconsume |
# reconsume |
1052 |
|
|
1053 |
!!!emit ($self->{ct}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1057 |
if ($self->{nc} == 0x0022 or # " |
if ($self->{nc} == 0x0022 or # " |
1058 |
$self->{nc} == 0x0027) { # ' |
$self->{nc} == 0x0027) { # ' |
1059 |
!!!cp (69); |
!!!cp (69); |
1060 |
|
## XML5: Not a parse error. |
1061 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
1062 |
} else { |
} else { |
1063 |
!!!cp (70); |
!!!cp (70); |
1068 |
redo A; |
redo A; |
1069 |
} |
} |
1070 |
} elsif ($self->{state} == AFTER_ATTRIBUTE_NAME_STATE) { |
} elsif ($self->{state} == AFTER_ATTRIBUTE_NAME_STATE) { |
1071 |
|
## XML5: "Tag attribute name after state". |
1072 |
|
|
1073 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
1074 |
!!!cp (71); |
!!!cp (71); |
1075 |
## Stay in the state |
## Stay in the state |
1081 |
!!!next-input-character; |
!!!next-input-character; |
1082 |
redo A; |
redo A; |
1083 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
1084 |
|
if ($self->{is_xml}) { |
1085 |
|
!!!cp (72.1); |
1086 |
|
## XML5: Not a parse error. |
1087 |
|
!!!parse-error (type => 'no attr value'); ## TODO: type |
1088 |
|
} else { |
1089 |
|
!!!cp (72.2); |
1090 |
|
} |
1091 |
|
|
1092 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1093 |
!!!cp (73); |
!!!cp (73); |
1094 |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1105 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1106 |
} |
} |
1107 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1108 |
|
$self->{s_kwd} = ''; |
1109 |
!!!next-input-character; |
!!!next-input-character; |
1110 |
|
|
1111 |
!!!emit ($self->{ct}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1122 |
!!!next-input-character; |
!!!next-input-character; |
1123 |
redo A; |
redo A; |
1124 |
} elsif ($self->{nc} == 0x002F) { # / |
} elsif ($self->{nc} == 0x002F) { # / |
1125 |
!!!cp (77); |
if ($self->{is_xml}) { |
1126 |
|
!!!cp (77); |
1127 |
|
## XML5: Not a parse error. |
1128 |
|
!!!parse-error (type => 'no attr value'); ## TODO: type |
1129 |
|
} else { |
1130 |
|
!!!cp (77.1); |
1131 |
|
} |
1132 |
|
|
1133 |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
1134 |
!!!next-input-character; |
!!!next-input-character; |
1135 |
redo A; |
redo A; |
1150 |
} else { |
} else { |
1151 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1152 |
} |
} |
1153 |
|
$self->{s_kwd} = ''; |
1154 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1155 |
# reconsume |
# reconsume |
1156 |
|
|
1158 |
|
|
1159 |
redo A; |
redo A; |
1160 |
} else { |
} else { |
1161 |
|
if ($self->{is_xml}) { |
1162 |
|
!!!cp (78.1); |
1163 |
|
## XML5: Not a parse error. |
1164 |
|
!!!parse-error (type => 'no attr value'); ## TODO: type |
1165 |
|
} else { |
1166 |
|
!!!cp (78.2); |
1167 |
|
} |
1168 |
|
|
1169 |
if ($self->{nc} == 0x0022 or # " |
if ($self->{nc} == 0x0022 or # " |
1170 |
$self->{nc} == 0x0027) { # ' |
$self->{nc} == 0x0027) { # ' |
1171 |
!!!cp (78); |
!!!cp (78); |
1172 |
|
## XML5: Not a parse error. |
1173 |
!!!parse-error (type => 'bad attribute name'); |
!!!parse-error (type => 'bad attribute name'); |
1174 |
} else { |
} else { |
1175 |
!!!cp (82); |
!!!cp (82); |
1183 |
redo A; |
redo A; |
1184 |
} |
} |
1185 |
} elsif ($self->{state} == BEFORE_ATTRIBUTE_VALUE_STATE) { |
} elsif ($self->{state} == BEFORE_ATTRIBUTE_VALUE_STATE) { |
1186 |
|
## XML5: "Tag attribute value before state". |
1187 |
|
|
1188 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
1189 |
!!!cp (83); |
!!!cp (83); |
1190 |
## Stay in the state |
## Stay in the state |
1223 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1224 |
} |
} |
1225 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1226 |
|
$self->{s_kwd} = ''; |
1227 |
!!!next-input-character; |
!!!next-input-character; |
1228 |
|
|
1229 |
!!!emit ($self->{ct}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1247 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1248 |
} |
} |
1249 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1250 |
|
$self->{s_kwd} = ''; |
1251 |
## reconsume |
## reconsume |
1252 |
|
|
1253 |
!!!emit ($self->{ct}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1256 |
} else { |
} else { |
1257 |
if ($self->{nc} == 0x003D) { # = |
if ($self->{nc} == 0x003D) { # = |
1258 |
!!!cp (93); |
!!!cp (93); |
1259 |
|
## XML5: Not a parse error. |
1260 |
!!!parse-error (type => 'bad attribute value'); |
!!!parse-error (type => 'bad attribute value'); |
1261 |
|
} elsif ($self->{is_xml}) { |
1262 |
|
!!!cp (93.1); |
1263 |
|
## XML5: No parse error. |
1264 |
|
!!!parse-error (type => 'unquoted attr value'); ## TODO |
1265 |
} else { |
} else { |
1266 |
!!!cp (94); |
!!!cp (94); |
1267 |
} |
} |
1271 |
redo A; |
redo A; |
1272 |
} |
} |
1273 |
} elsif ($self->{state} == ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE) { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE) { |
1274 |
|
## XML5: "Tag attribute value double quoted state" and "DOCTYPE |
1275 |
|
## ATTLIST attribute value double quoted state". |
1276 |
|
|
1277 |
if ($self->{nc} == 0x0022) { # " |
if ($self->{nc} == 0x0022) { # " |
1278 |
!!!cp (95); |
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1279 |
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
!!!cp (95.1); |
1280 |
|
## XML5: "DOCTYPE ATTLIST name after state". |
1281 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1282 |
|
$self->{state} = AFTER_ATTLIST_ATTR_VALUE_QUOTED_STATE; |
1283 |
|
} else { |
1284 |
|
!!!cp (95); |
1285 |
|
## XML5: "Tag attribute name before state". |
1286 |
|
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
1287 |
|
} |
1288 |
!!!next-input-character; |
!!!next-input-character; |
1289 |
redo A; |
redo A; |
1290 |
} elsif ($self->{nc} == 0x0026) { # & |
} elsif ($self->{nc} == 0x0026) { # & |
1291 |
!!!cp (96); |
!!!cp (96); |
1292 |
|
## XML5: Not defined yet. |
1293 |
|
|
1294 |
## NOTE: In the spec, the tokenizer is switched to the |
## NOTE: In the spec, the tokenizer is switched to the |
1295 |
## "entity in attribute value state". In this implementation, the |
## "entity in attribute value state". In this implementation, the |
1296 |
## tokenizer is switched to the |ENTITY_STATE|, which is an |
## tokenizer is switched to the |ENTITY_STATE|, which is an |
1305 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1306 |
!!!cp (97); |
!!!cp (97); |
1307 |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1308 |
|
|
1309 |
|
$self->{state} = DATA_STATE; |
1310 |
|
$self->{s_kwd} = ''; |
1311 |
|
## reconsume |
1312 |
|
!!!emit ($self->{ct}); # start tag |
1313 |
|
redo A; |
1314 |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1315 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1316 |
if ($self->{ct}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1320 |
## NOTE: This state should never be reached. |
## NOTE: This state should never be reached. |
1321 |
!!!cp (99); |
!!!cp (99); |
1322 |
} |
} |
1323 |
|
|
1324 |
|
$self->{state} = DATA_STATE; |
1325 |
|
$self->{s_kwd} = ''; |
1326 |
|
## reconsume |
1327 |
|
!!!emit ($self->{ct}); # end tag |
1328 |
|
redo A; |
1329 |
|
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1330 |
|
## XML5: No parse error above; not defined yet. |
1331 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1332 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1333 |
|
## Reconsume. |
1334 |
|
!!!emit ($self->{ct}); # ATTLIST |
1335 |
|
redo A; |
1336 |
} else { |
} else { |
1337 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1338 |
} |
} |
|
$self->{state} = DATA_STATE; |
|
|
## reconsume |
|
|
|
|
|
!!!emit ($self->{ct}); # start tag or end tag |
|
|
|
|
|
redo A; |
|
1339 |
} else { |
} else { |
1340 |
!!!cp (100); |
## XML5 [ATTLIST]: Not defined yet. |
1341 |
|
if ($self->{is_xml} and $self->{nc} == 0x003C) { # < |
1342 |
|
!!!cp (100); |
1343 |
|
## XML5: Not a parse error. |
1344 |
|
!!!parse-error (type => 'lt in attr value'); ## TODO: type |
1345 |
|
} else { |
1346 |
|
!!!cp (100.1); |
1347 |
|
} |
1348 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1349 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1350 |
q["&], |
q["&<], |
1351 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1352 |
|
|
1353 |
## Stay in the state |
## Stay in the state |
1355 |
redo A; |
redo A; |
1356 |
} |
} |
1357 |
} elsif ($self->{state} == ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE) { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE) { |
1358 |
|
## XML5: "Tag attribute value single quoted state" and "DOCTYPE |
1359 |
|
## ATTLIST attribute value single quoted state". |
1360 |
|
|
1361 |
if ($self->{nc} == 0x0027) { # ' |
if ($self->{nc} == 0x0027) { # ' |
1362 |
!!!cp (101); |
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1363 |
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
!!!cp (101.1); |
1364 |
|
## XML5: "DOCTYPE ATTLIST name after state". |
1365 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1366 |
|
$self->{state} = AFTER_ATTLIST_ATTR_VALUE_QUOTED_STATE; |
1367 |
|
} else { |
1368 |
|
!!!cp (101); |
1369 |
|
## XML5: "Before attribute name state" (sic). |
1370 |
|
$self->{state} = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; |
1371 |
|
} |
1372 |
!!!next-input-character; |
!!!next-input-character; |
1373 |
redo A; |
redo A; |
1374 |
} elsif ($self->{nc} == 0x0026) { # & |
} elsif ($self->{nc} == 0x0026) { # & |
1375 |
!!!cp (102); |
!!!cp (102); |
1376 |
|
## XML5: Not defined yet. |
1377 |
|
|
1378 |
## NOTE: In the spec, the tokenizer is switched to the |
## NOTE: In the spec, the tokenizer is switched to the |
1379 |
## "entity in attribute value state". In this implementation, the |
## "entity in attribute value state". In this implementation, the |
1380 |
## tokenizer is switched to the |ENTITY_STATE|, which is an |
## tokenizer is switched to the |ENTITY_STATE|, which is an |
1389 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1390 |
!!!cp (103); |
!!!cp (103); |
1391 |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1392 |
|
|
1393 |
|
$self->{state} = DATA_STATE; |
1394 |
|
$self->{s_kwd} = ''; |
1395 |
|
## reconsume |
1396 |
|
!!!emit ($self->{ct}); # start tag |
1397 |
|
redo A; |
1398 |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1399 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1400 |
if ($self->{ct}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1404 |
## NOTE: This state should never be reached. |
## NOTE: This state should never be reached. |
1405 |
!!!cp (105); |
!!!cp (105); |
1406 |
} |
} |
1407 |
|
|
1408 |
|
$self->{state} = DATA_STATE; |
1409 |
|
$self->{s_kwd} = ''; |
1410 |
|
## reconsume |
1411 |
|
!!!emit ($self->{ct}); # end tag |
1412 |
|
redo A; |
1413 |
|
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1414 |
|
## XML5: No parse error above; not defined yet. |
1415 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1416 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1417 |
|
## Reconsume. |
1418 |
|
!!!emit ($self->{ct}); # ATTLIST |
1419 |
|
redo A; |
1420 |
} else { |
} else { |
1421 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1422 |
} |
} |
|
$self->{state} = DATA_STATE; |
|
|
## reconsume |
|
|
|
|
|
!!!emit ($self->{ct}); # start tag or end tag |
|
|
|
|
|
redo A; |
|
1423 |
} else { |
} else { |
1424 |
!!!cp (106); |
## XML5 [ATTLIST]: Not defined yet. |
1425 |
|
if ($self->{is_xml} and $self->{nc} == 0x003C) { # < |
1426 |
|
!!!cp (106); |
1427 |
|
## XML5: Not a parse error. |
1428 |
|
!!!parse-error (type => 'lt in attr value'); ## TODO: type |
1429 |
|
} else { |
1430 |
|
!!!cp (106.1); |
1431 |
|
} |
1432 |
$self->{ca}->{value} .= chr ($self->{nc}); |
$self->{ca}->{value} .= chr ($self->{nc}); |
1433 |
$self->{read_until}->($self->{ca}->{value}, |
$self->{read_until}->($self->{ca}->{value}, |
1434 |
q['&], |
q['&<], |
1435 |
length $self->{ca}->{value}); |
length $self->{ca}->{value}); |
1436 |
|
|
1437 |
## Stay in the state |
## Stay in the state |
1439 |
redo A; |
redo A; |
1440 |
} |
} |
1441 |
} elsif ($self->{state} == ATTRIBUTE_VALUE_UNQUOTED_STATE) { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_UNQUOTED_STATE) { |
1442 |
|
## XML5: "Tag attribute value unquoted state". |
1443 |
|
|
1444 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
1445 |
!!!cp (107); |
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1446 |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
!!!cp (107.1); |
1447 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1448 |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
1449 |
|
} else { |
1450 |
|
!!!cp (107); |
1451 |
|
## XML5: "Tag attribute name before state". |
1452 |
|
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
1453 |
|
} |
1454 |
!!!next-input-character; |
!!!next-input-character; |
1455 |
redo A; |
redo A; |
1456 |
} elsif ($self->{nc} == 0x0026) { # & |
} elsif ($self->{nc} == 0x0026) { # & |
1457 |
!!!cp (108); |
!!!cp (108); |
1458 |
|
|
1459 |
|
## XML5: Not defined yet. |
1460 |
|
|
1461 |
## NOTE: In the spec, the tokenizer is switched to the |
## NOTE: In the spec, the tokenizer is switched to the |
1462 |
## "entity in attribute value state". In this implementation, the |
## "entity in attribute value state". In this implementation, the |
1463 |
## tokenizer is switched to the |ENTITY_STATE|, which is an |
## tokenizer is switched to the |ENTITY_STATE|, which is an |
1471 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1472 |
!!!cp (109); |
!!!cp (109); |
1473 |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1474 |
|
|
1475 |
|
$self->{state} = DATA_STATE; |
1476 |
|
$self->{s_kwd} = ''; |
1477 |
|
!!!next-input-character; |
1478 |
|
!!!emit ($self->{ct}); # start tag |
1479 |
|
redo A; |
1480 |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1481 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1482 |
if ($self->{ct}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1486 |
## NOTE: This state should never be reached. |
## NOTE: This state should never be reached. |
1487 |
!!!cp (111); |
!!!cp (111); |
1488 |
} |
} |
1489 |
|
|
1490 |
|
$self->{state} = DATA_STATE; |
1491 |
|
$self->{s_kwd} = ''; |
1492 |
|
!!!next-input-character; |
1493 |
|
!!!emit ($self->{ct}); # end tag |
1494 |
|
redo A; |
1495 |
|
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1496 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1497 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1498 |
|
!!!next-input-character; |
1499 |
|
!!!emit ($self->{ct}); # ATTLIST |
1500 |
|
redo A; |
1501 |
} else { |
} else { |
1502 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1503 |
} |
} |
|
$self->{state} = DATA_STATE; |
|
|
!!!next-input-character; |
|
|
|
|
|
!!!emit ($self->{ct}); # start tag or end tag |
|
|
|
|
|
redo A; |
|
1504 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!parse-error (type => 'unclosed tag'); |
|
1505 |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
if ($self->{ct}->{type} == START_TAG_TOKEN) { |
1506 |
!!!cp (112); |
!!!cp (112); |
1507 |
|
!!!parse-error (type => 'unclosed tag'); |
1508 |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
$self->{last_stag_name} = $self->{ct}->{tag_name}; |
1509 |
|
|
1510 |
|
$self->{state} = DATA_STATE; |
1511 |
|
$self->{s_kwd} = ''; |
1512 |
|
## reconsume |
1513 |
|
!!!emit ($self->{ct}); # start tag |
1514 |
|
redo A; |
1515 |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{ct}->{type} == END_TAG_TOKEN) { |
1516 |
|
!!!parse-error (type => 'unclosed tag'); |
1517 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
1518 |
if ($self->{ct}->{attributes}) { |
if ($self->{ct}->{attributes}) { |
1519 |
!!!cp (113); |
!!!cp (113); |
1522 |
## NOTE: This state should never be reached. |
## NOTE: This state should never be reached. |
1523 |
!!!cp (114); |
!!!cp (114); |
1524 |
} |
} |
1525 |
|
|
1526 |
|
$self->{state} = DATA_STATE; |
1527 |
|
$self->{s_kwd} = ''; |
1528 |
|
## reconsume |
1529 |
|
!!!emit ($self->{ct}); # end tag |
1530 |
|
redo A; |
1531 |
|
} elsif ($self->{ct}->{type} == ATTLIST_TOKEN) { |
1532 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
1533 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
1534 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1535 |
|
## Reconsume. |
1536 |
|
!!!emit ($self->{ct}); # ATTLIST |
1537 |
|
redo A; |
1538 |
} else { |
} else { |
1539 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1540 |
} |
} |
|
$self->{state} = DATA_STATE; |
|
|
## reconsume |
|
|
|
|
|
!!!emit ($self->{ct}); # start tag or end tag |
|
|
|
|
|
redo A; |
|
1541 |
} else { |
} else { |
1542 |
if ({ |
if ({ |
1543 |
0x0022 => 1, # " |
0x0022 => 1, # " |
1545 |
0x003D => 1, # = |
0x003D => 1, # = |
1546 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
1547 |
!!!cp (115); |
!!!cp (115); |
1548 |
|
## XML5: Not a parse error. |
1549 |
!!!parse-error (type => 'bad attribute value'); |
!!!parse-error (type => 'bad attribute value'); |
1550 |
} else { |
} else { |
1551 |
!!!cp (116); |
!!!cp (116); |
1582 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1583 |
} |
} |
1584 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1585 |
|
$self->{s_kwd} = ''; |
1586 |
!!!next-input-character; |
!!!next-input-character; |
1587 |
|
|
1588 |
!!!emit ($self->{ct}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1610 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1611 |
} |
} |
1612 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1613 |
|
$self->{s_kwd} = ''; |
1614 |
## Reconsume. |
## Reconsume. |
1615 |
!!!emit ($self->{ct}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1616 |
redo A; |
redo A; |
1622 |
redo A; |
redo A; |
1623 |
} |
} |
1624 |
} elsif ($self->{state} == SELF_CLOSING_START_TAG_STATE) { |
} elsif ($self->{state} == SELF_CLOSING_START_TAG_STATE) { |
1625 |
|
## XML5: "Empty tag state". |
1626 |
|
|
1627 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
1628 |
if ($self->{ct}->{type} == END_TAG_TOKEN) { |
if ($self->{ct}->{type} == END_TAG_TOKEN) { |
1629 |
!!!cp ('124.2'); |
!!!cp ('124.2'); |
1643 |
} |
} |
1644 |
|
|
1645 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1646 |
|
$self->{s_kwd} = ''; |
1647 |
!!!next-input-character; |
!!!next-input-character; |
1648 |
|
|
1649 |
!!!emit ($self->{ct}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1665 |
} else { |
} else { |
1666 |
die "$0: $self->{ct}->{type}: Unknown token type"; |
die "$0: $self->{ct}->{type}: Unknown token type"; |
1667 |
} |
} |
1668 |
|
## XML5: "Tag attribute name before state". |
1669 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
1670 |
|
$self->{s_kwd} = ''; |
1671 |
## Reconsume. |
## Reconsume. |
1672 |
!!!emit ($self->{ct}); # start tag or end tag |
!!!emit ($self->{ct}); # start tag or end tag |
1673 |
redo A; |
redo A; |
1680 |
redo A; |
redo A; |
1681 |
} |
} |
1682 |
} elsif ($self->{state} == BOGUS_COMMENT_STATE) { |
} elsif ($self->{state} == BOGUS_COMMENT_STATE) { |
1683 |
## (only happen if PCDATA state) |
## XML5: "Bogus comment state" and "DOCTYPE bogus comment state". |
1684 |
|
|
1685 |
## NOTE: Unlike spec's "bogus comment state", this implementation |
## NOTE: Unlike spec's "bogus comment state", this implementation |
1686 |
## consumes characters one-by-one basis. |
## consumes characters one-by-one basis. |
1687 |
|
|
1688 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
1689 |
!!!cp (124); |
if ($self->{in_subset}) { |
1690 |
$self->{state} = DATA_STATE; |
!!!cp (123); |
1691 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1692 |
|
} else { |
1693 |
|
!!!cp (124); |
1694 |
|
$self->{state} = DATA_STATE; |
1695 |
|
$self->{s_kwd} = ''; |
1696 |
|
} |
1697 |
!!!next-input-character; |
!!!next-input-character; |
1698 |
|
|
1699 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
1700 |
redo A; |
redo A; |
1701 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
1702 |
!!!cp (125); |
if ($self->{in_subset}) { |
1703 |
$self->{state} = DATA_STATE; |
!!!cp (125.1); |
1704 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1705 |
|
} else { |
1706 |
|
!!!cp (125); |
1707 |
|
$self->{state} = DATA_STATE; |
1708 |
|
$self->{s_kwd} = ''; |
1709 |
|
} |
1710 |
## reconsume |
## reconsume |
1711 |
|
|
1712 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
1723 |
redo A; |
redo A; |
1724 |
} |
} |
1725 |
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
1726 |
## (only happen if PCDATA state) |
## XML5: "Markup declaration state". |
1727 |
|
|
1728 |
if ($self->{nc} == 0x002D) { # - |
if ($self->{nc} == 0x002D) { # - |
1729 |
!!!cp (133); |
!!!cp (133); |
1735 |
## ASCII case-insensitive. |
## ASCII case-insensitive. |
1736 |
!!!cp (130); |
!!!cp (130); |
1737 |
$self->{state} = MD_DOCTYPE_STATE; |
$self->{state} = MD_DOCTYPE_STATE; |
1738 |
$self->{s_kwd} = chr $self->{nc}; |
$self->{kwd} = chr $self->{nc}; |
1739 |
!!!next-input-character; |
!!!next-input-character; |
1740 |
redo A; |
redo A; |
1741 |
} elsif ((($self->{insertion_mode} & IN_FOREIGN_CONTENT_IM and |
} elsif ((($self->{insertion_mode} & IN_FOREIGN_CONTENT_IM and |
1744 |
$self->{nc} == 0x005B) { # [ |
$self->{nc} == 0x005B) { # [ |
1745 |
!!!cp (135.4); |
!!!cp (135.4); |
1746 |
$self->{state} = MD_CDATA_STATE; |
$self->{state} = MD_CDATA_STATE; |
1747 |
$self->{s_kwd} = '['; |
$self->{kwd} = '['; |
1748 |
!!!next-input-character; |
!!!next-input-character; |
1749 |
redo A; |
redo A; |
1750 |
} else { |
} else { |
1768 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1769 |
column => $self->{column_prev} - 2, |
column => $self->{column_prev} - 2, |
1770 |
}; |
}; |
1771 |
$self->{state} = COMMENT_START_STATE; |
$self->{state} = COMMENT_START_STATE; ## XML5: "comment state". |
1772 |
!!!next-input-character; |
!!!next-input-character; |
1773 |
redo A; |
redo A; |
1774 |
} else { |
} else { |
1794 |
0x0054, # T |
0x0054, # T |
1795 |
0x0059, # Y |
0x0059, # Y |
1796 |
0x0050, # P |
0x0050, # P |
1797 |
]->[length $self->{s_kwd}] or |
]->[length $self->{kwd}] or |
1798 |
$self->{nc} == [ |
$self->{nc} == [ |
1799 |
undef, |
undef, |
1800 |
0x006F, # o |
0x006F, # o |
1802 |
0x0074, # t |
0x0074, # t |
1803 |
0x0079, # y |
0x0079, # y |
1804 |
0x0070, # p |
0x0070, # p |
1805 |
]->[length $self->{s_kwd}]) { |
]->[length $self->{kwd}]) { |
1806 |
!!!cp (131); |
!!!cp (131); |
1807 |
## Stay in the state. |
## Stay in the state. |
1808 |
$self->{s_kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
1809 |
!!!next-input-character; |
!!!next-input-character; |
1810 |
redo A; |
redo A; |
1811 |
} elsif ((length $self->{s_kwd}) == 6 and |
} elsif ((length $self->{kwd}) == 6 and |
1812 |
($self->{nc} == 0x0045 or # E |
($self->{nc} == 0x0045 or # E |
1813 |
$self->{nc} == 0x0065)) { # e |
$self->{nc} == 0x0065)) { # e |
1814 |
!!!cp (129); |
if ($self->{is_xml} and |
1815 |
|
($self->{kwd} ne 'DOCTYP' or $self->{nc} == 0x0065)) { |
1816 |
|
!!!cp (129); |
1817 |
|
## XML5: case-sensitive. |
1818 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO |
1819 |
|
text => 'DOCTYPE', |
1820 |
|
line => $self->{line_prev}, |
1821 |
|
column => $self->{column_prev} - 5); |
1822 |
|
} else { |
1823 |
|
!!!cp (129.1); |
1824 |
|
} |
1825 |
$self->{state} = DOCTYPE_STATE; |
$self->{state} = DOCTYPE_STATE; |
1826 |
$self->{ct} = {type => DOCTYPE_TOKEN, |
$self->{ct} = {type => DOCTYPE_TOKEN, |
1827 |
quirks => 1, |
quirks => 1, |
1834 |
!!!cp (132); |
!!!cp (132); |
1835 |
!!!parse-error (type => 'bogus comment', |
!!!parse-error (type => 'bogus comment', |
1836 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1837 |
column => $self->{column_prev} - 1 - length $self->{s_kwd}); |
column => $self->{column_prev} - 1 - length $self->{kwd}); |
1838 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
1839 |
## Reconsume. |
## Reconsume. |
1840 |
$self->{ct} = {type => COMMENT_TOKEN, |
$self->{ct} = {type => COMMENT_TOKEN, |
1841 |
data => $self->{s_kwd}, |
data => $self->{kwd}, |
1842 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1843 |
column => $self->{column_prev} - 1 - length $self->{s_kwd}, |
column => $self->{column_prev} - 1 - length $self->{kwd}, |
1844 |
}; |
}; |
1845 |
redo A; |
redo A; |
1846 |
} |
} |
1851 |
'[CD' => 0x0041, # A |
'[CD' => 0x0041, # A |
1852 |
'[CDA' => 0x0054, # T |
'[CDA' => 0x0054, # T |
1853 |
'[CDAT' => 0x0041, # A |
'[CDAT' => 0x0041, # A |
1854 |
}->{$self->{s_kwd}}) { |
}->{$self->{kwd}}) { |
1855 |
!!!cp (135.1); |
!!!cp (135.1); |
1856 |
## Stay in the state. |
## Stay in the state. |
1857 |
$self->{s_kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
1858 |
!!!next-input-character; |
!!!next-input-character; |
1859 |
redo A; |
redo A; |
1860 |
} elsif ($self->{s_kwd} eq '[CDATA' and |
} elsif ($self->{kwd} eq '[CDATA' and |
1861 |
$self->{nc} == 0x005B) { # [ |
$self->{nc} == 0x005B) { # [ |
1862 |
!!!cp (135.2); |
if ($self->{is_xml} and |
1863 |
|
not $self->{tainted} and |
1864 |
|
@{$self->{open_elements} or []} == 0) { |
1865 |
|
!!!cp (135.2); |
1866 |
|
!!!parse-error (type => 'cdata outside of root element', |
1867 |
|
line => $self->{line_prev}, |
1868 |
|
column => $self->{column_prev} - 7); |
1869 |
|
$self->{tainted} = 1; |
1870 |
|
} else { |
1871 |
|
!!!cp (135.21); |
1872 |
|
} |
1873 |
|
|
1874 |
$self->{ct} = {type => CHARACTER_TOKEN, |
$self->{ct} = {type => CHARACTER_TOKEN, |
1875 |
data => '', |
data => '', |
1876 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1882 |
!!!cp (135.3); |
!!!cp (135.3); |
1883 |
!!!parse-error (type => 'bogus comment', |
!!!parse-error (type => 'bogus comment', |
1884 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1885 |
column => $self->{column_prev} - 1 - length $self->{s_kwd}); |
column => $self->{column_prev} - 1 - length $self->{kwd}); |
1886 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
1887 |
## Reconsume. |
## Reconsume. |
1888 |
$self->{ct} = {type => COMMENT_TOKEN, |
$self->{ct} = {type => COMMENT_TOKEN, |
1889 |
data => $self->{s_kwd}, |
data => $self->{kwd}, |
1890 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
1891 |
column => $self->{column_prev} - 1 - length $self->{s_kwd}, |
column => $self->{column_prev} - 1 - length $self->{kwd}, |
1892 |
}; |
}; |
1893 |
redo A; |
redo A; |
1894 |
} |
} |
1899 |
!!!next-input-character; |
!!!next-input-character; |
1900 |
redo A; |
redo A; |
1901 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
|
!!!cp (138); |
|
1902 |
!!!parse-error (type => 'bogus comment'); |
!!!parse-error (type => 'bogus comment'); |
1903 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
1904 |
|
!!!cp (138.1); |
1905 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1906 |
|
} else { |
1907 |
|
!!!cp (138); |
1908 |
|
$self->{state} = DATA_STATE; |
1909 |
|
$self->{s_kwd} = ''; |
1910 |
|
} |
1911 |
!!!next-input-character; |
!!!next-input-character; |
1912 |
|
|
1913 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
1914 |
|
|
1915 |
redo A; |
redo A; |
1916 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (139); |
|
1917 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
1918 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
1919 |
|
!!!cp (139.1); |
1920 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1921 |
|
} else { |
1922 |
|
!!!cp (139); |
1923 |
|
$self->{state} = DATA_STATE; |
1924 |
|
$self->{s_kwd} = ''; |
1925 |
|
} |
1926 |
## reconsume |
## reconsume |
1927 |
|
|
1928 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
1943 |
!!!next-input-character; |
!!!next-input-character; |
1944 |
redo A; |
redo A; |
1945 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
|
!!!cp (142); |
|
1946 |
!!!parse-error (type => 'bogus comment'); |
!!!parse-error (type => 'bogus comment'); |
1947 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
1948 |
|
!!!cp (142.1); |
1949 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1950 |
|
} else { |
1951 |
|
!!!cp (142); |
1952 |
|
$self->{state} = DATA_STATE; |
1953 |
|
$self->{s_kwd} = ''; |
1954 |
|
} |
1955 |
!!!next-input-character; |
!!!next-input-character; |
1956 |
|
|
1957 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
1958 |
|
|
1959 |
redo A; |
redo A; |
1960 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (143); |
|
1961 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
1962 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
1963 |
|
!!!cp (143.1); |
1964 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1965 |
|
} else { |
1966 |
|
!!!cp (143); |
1967 |
|
$self->{state} = DATA_STATE; |
1968 |
|
$self->{s_kwd} = ''; |
1969 |
|
} |
1970 |
## reconsume |
## reconsume |
1971 |
|
|
1972 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
1981 |
redo A; |
redo A; |
1982 |
} |
} |
1983 |
} elsif ($self->{state} == COMMENT_STATE) { |
} elsif ($self->{state} == COMMENT_STATE) { |
1984 |
|
## XML5: "Comment state" and "DOCTYPE comment state". |
1985 |
|
|
1986 |
if ($self->{nc} == 0x002D) { # - |
if ($self->{nc} == 0x002D) { # - |
1987 |
!!!cp (145); |
!!!cp (145); |
1988 |
$self->{state} = COMMENT_END_DASH_STATE; |
$self->{state} = COMMENT_END_DASH_STATE; |
1989 |
!!!next-input-character; |
!!!next-input-character; |
1990 |
redo A; |
redo A; |
1991 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (146); |
|
1992 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
1993 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
1994 |
|
!!!cp (146.1); |
1995 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
1996 |
|
} else { |
1997 |
|
!!!cp (146); |
1998 |
|
$self->{state} = DATA_STATE; |
1999 |
|
$self->{s_kwd} = ''; |
2000 |
|
} |
2001 |
## reconsume |
## reconsume |
2002 |
|
|
2003 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
2015 |
redo A; |
redo A; |
2016 |
} |
} |
2017 |
} elsif ($self->{state} == COMMENT_END_DASH_STATE) { |
} elsif ($self->{state} == COMMENT_END_DASH_STATE) { |
2018 |
|
## XML5: "Comment dash state" and "DOCTYPE comment dash state". |
2019 |
|
|
2020 |
if ($self->{nc} == 0x002D) { # - |
if ($self->{nc} == 0x002D) { # - |
2021 |
!!!cp (148); |
!!!cp (148); |
2022 |
$self->{state} = COMMENT_END_STATE; |
$self->{state} = COMMENT_END_STATE; |
2023 |
!!!next-input-character; |
!!!next-input-character; |
2024 |
redo A; |
redo A; |
2025 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (149); |
|
2026 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
2027 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
2028 |
|
!!!cp (149.1); |
2029 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2030 |
|
} else { |
2031 |
|
!!!cp (149); |
2032 |
|
$self->{state} = DATA_STATE; |
2033 |
|
$self->{s_kwd} = ''; |
2034 |
|
} |
2035 |
## reconsume |
## reconsume |
2036 |
|
|
2037 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
2045 |
redo A; |
redo A; |
2046 |
} |
} |
2047 |
} elsif ($self->{state} == COMMENT_END_STATE) { |
} elsif ($self->{state} == COMMENT_END_STATE) { |
2048 |
|
## XML5: "Comment end state" and "DOCTYPE comment end state". |
2049 |
|
|
2050 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
2051 |
!!!cp (151); |
if ($self->{in_subset}) { |
2052 |
$self->{state} = DATA_STATE; |
!!!cp (151.1); |
2053 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2054 |
|
} else { |
2055 |
|
!!!cp (151); |
2056 |
|
$self->{state} = DATA_STATE; |
2057 |
|
$self->{s_kwd} = ''; |
2058 |
|
} |
2059 |
!!!next-input-character; |
!!!next-input-character; |
2060 |
|
|
2061 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
2063 |
redo A; |
redo A; |
2064 |
} elsif ($self->{nc} == 0x002D) { # - |
} elsif ($self->{nc} == 0x002D) { # - |
2065 |
!!!cp (152); |
!!!cp (152); |
2066 |
|
## XML5: Not a parse error. |
2067 |
!!!parse-error (type => 'dash in comment', |
!!!parse-error (type => 'dash in comment', |
2068 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2069 |
column => $self->{column_prev}); |
column => $self->{column_prev}); |
2072 |
!!!next-input-character; |
!!!next-input-character; |
2073 |
redo A; |
redo A; |
2074 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (153); |
|
2075 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
2076 |
$self->{state} = DATA_STATE; |
if ($self->{in_subset}) { |
2077 |
|
!!!cp (153.1); |
2078 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2079 |
|
} else { |
2080 |
|
!!!cp (153); |
2081 |
|
$self->{state} = DATA_STATE; |
2082 |
|
$self->{s_kwd} = ''; |
2083 |
|
} |
2084 |
## reconsume |
## reconsume |
2085 |
|
|
2086 |
!!!emit ($self->{ct}); # comment |
!!!emit ($self->{ct}); # comment |
2088 |
redo A; |
redo A; |
2089 |
} else { |
} else { |
2090 |
!!!cp (154); |
!!!cp (154); |
2091 |
|
## XML5: Not a parse error. |
2092 |
!!!parse-error (type => 'dash in comment', |
!!!parse-error (type => 'dash in comment', |
2093 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2094 |
column => $self->{column_prev}); |
column => $self->{column_prev}); |
2105 |
redo A; |
redo A; |
2106 |
} else { |
} else { |
2107 |
!!!cp (156); |
!!!cp (156); |
2108 |
|
## XML5: Unless EOF, swith to the bogus comment state. |
2109 |
!!!parse-error (type => 'no space before DOCTYPE name'); |
!!!parse-error (type => 'no space before DOCTYPE name'); |
2110 |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
2111 |
## reconsume |
## reconsume |
2112 |
redo A; |
redo A; |
2113 |
} |
} |
2114 |
} elsif ($self->{state} == BEFORE_DOCTYPE_NAME_STATE) { |
} elsif ($self->{state} == BEFORE_DOCTYPE_NAME_STATE) { |
2115 |
|
## XML5: "DOCTYPE root name before state". |
2116 |
|
|
2117 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
2118 |
!!!cp (157); |
!!!cp (157); |
2119 |
## Stay in the state |
## Stay in the state |
2121 |
redo A; |
redo A; |
2122 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2123 |
!!!cp (158); |
!!!cp (158); |
2124 |
|
## XML5: No parse error. |
2125 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
2126 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2127 |
|
$self->{s_kwd} = ''; |
2128 |
!!!next-input-character; |
!!!next-input-character; |
2129 |
|
|
2130 |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
2134 |
!!!cp (159); |
!!!cp (159); |
2135 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
2136 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2137 |
|
$self->{s_kwd} = ''; |
2138 |
## reconsume |
## reconsume |
2139 |
|
|
2140 |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
!!!emit ($self->{ct}); # DOCTYPE (quirks) |
2141 |
|
|
2142 |
redo A; |
redo A; |
2143 |
|
} elsif ($self->{is_xml} and $self->{nc} == 0x005B) { # [ |
2144 |
|
!!!cp (159.1); |
2145 |
|
!!!parse-error (type => 'no DOCTYPE name'); |
2146 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2147 |
|
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2148 |
|
$self->{in_subset} = 1; |
2149 |
|
!!!next-input-character; |
2150 |
|
!!!emit ($self->{ct}); # DOCTYPE |
2151 |
|
redo A; |
2152 |
} else { |
} else { |
2153 |
!!!cp (160); |
!!!cp (160); |
2154 |
$self->{ct}->{name} = chr $self->{nc}; |
$self->{ct}->{name} = chr $self->{nc}; |
2158 |
redo A; |
redo A; |
2159 |
} |
} |
2160 |
} elsif ($self->{state} == DOCTYPE_NAME_STATE) { |
} elsif ($self->{state} == DOCTYPE_NAME_STATE) { |
2161 |
## ISSUE: Redundant "First," in the spec. |
## XML5: "DOCTYPE root name state". |
2162 |
|
|
2163 |
|
## ISSUE: Redundant "First," in the spec. |
2164 |
|
|
2165 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
2166 |
!!!cp (161); |
!!!cp (161); |
2167 |
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
2170 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2171 |
!!!cp (162); |
!!!cp (162); |
2172 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2173 |
|
$self->{s_kwd} = ''; |
2174 |
!!!next-input-character; |
!!!next-input-character; |
2175 |
|
|
2176 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2180 |
!!!cp (163); |
!!!cp (163); |
2181 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2182 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2183 |
|
$self->{s_kwd} = ''; |
2184 |
## reconsume |
## reconsume |
2185 |
|
|
2186 |
$self->{ct}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2187 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2188 |
|
|
2189 |
redo A; |
redo A; |
2190 |
|
} elsif ($self->{is_xml} and $self->{nc} == 0x005B) { # [ |
2191 |
|
!!!cp (163.1); |
2192 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2193 |
|
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2194 |
|
$self->{in_subset} = 1; |
2195 |
|
!!!next-input-character; |
2196 |
|
!!!emit ($self->{ct}); # DOCTYPE |
2197 |
|
redo A; |
2198 |
} else { |
} else { |
2199 |
!!!cp (164); |
!!!cp (164); |
2200 |
$self->{ct}->{name} |
$self->{ct}->{name} |
2204 |
redo A; |
redo A; |
2205 |
} |
} |
2206 |
} elsif ($self->{state} == AFTER_DOCTYPE_NAME_STATE) { |
} elsif ($self->{state} == AFTER_DOCTYPE_NAME_STATE) { |
2207 |
|
## XML5: Corresponding to XML5's "DOCTYPE root name after |
2208 |
|
## state", but implemented differently. |
2209 |
|
|
2210 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
2211 |
!!!cp (165); |
!!!cp (165); |
2212 |
## Stay in the state |
## Stay in the state |
2213 |
!!!next-input-character; |
!!!next-input-character; |
2214 |
redo A; |
redo A; |
2215 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2216 |
!!!cp (166); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2217 |
$self->{state} = DATA_STATE; |
!!!cp (166); |
2218 |
|
$self->{state} = DATA_STATE; |
2219 |
|
$self->{s_kwd} = ''; |
2220 |
|
} else { |
2221 |
|
!!!cp (166.1); |
2222 |
|
!!!parse-error (type => 'no md def'); ## TODO: type |
2223 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2224 |
|
} |
2225 |
|
|
2226 |
!!!next-input-character; |
!!!next-input-character; |
2227 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2228 |
redo A; |
redo A; |
2229 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2230 |
!!!cp (167); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2231 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!cp (167); |
2232 |
$self->{state} = DATA_STATE; |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2233 |
## reconsume |
$self->{state} = DATA_STATE; |
2234 |
|
$self->{s_kwd} = ''; |
2235 |
$self->{ct}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2236 |
!!!emit ($self->{ct}); # DOCTYPE |
} else { |
2237 |
|
!!!cp (167.12); |
2238 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
2239 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2240 |
|
} |
2241 |
|
|
2242 |
|
## Reconsume. |
2243 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2244 |
redo A; |
redo A; |
2245 |
} elsif ($self->{nc} == 0x0050 or # P |
} elsif ($self->{nc} == 0x0050 or # P |
2246 |
$self->{nc} == 0x0070) { # p |
$self->{nc} == 0x0070) { # p |
2247 |
|
!!!cp (167.1); |
2248 |
$self->{state} = PUBLIC_STATE; |
$self->{state} = PUBLIC_STATE; |
2249 |
$self->{s_kwd} = chr $self->{nc}; |
$self->{kwd} = chr $self->{nc}; |
2250 |
!!!next-input-character; |
!!!next-input-character; |
2251 |
redo A; |
redo A; |
2252 |
} elsif ($self->{nc} == 0x0053 or # S |
} elsif ($self->{nc} == 0x0053 or # S |
2253 |
$self->{nc} == 0x0073) { # s |
$self->{nc} == 0x0073) { # s |
2254 |
|
!!!cp (167.2); |
2255 |
$self->{state} = SYSTEM_STATE; |
$self->{state} = SYSTEM_STATE; |
2256 |
$self->{s_kwd} = chr $self->{nc}; |
$self->{kwd} = chr $self->{nc}; |
2257 |
!!!next-input-character; |
!!!next-input-character; |
2258 |
redo A; |
redo A; |
2259 |
|
## TODO: " and ' for ENTITY |
2260 |
|
} elsif ($self->{is_xml} and |
2261 |
|
$self->{ct}->{type} == DOCTYPE_TOKEN and |
2262 |
|
$self->{nc} == 0x005B) { # [ |
2263 |
|
!!!cp (167.3); |
2264 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2265 |
|
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2266 |
|
$self->{in_subset} = 1; |
2267 |
|
!!!next-input-character; |
2268 |
|
!!!emit ($self->{ct}); # DOCTYPE |
2269 |
|
redo A; |
2270 |
} else { |
} else { |
2271 |
!!!cp (180); |
!!!parse-error (type => 'string after DOCTYPE name'); ## TODO: type |
2272 |
!!!parse-error (type => 'string after DOCTYPE name'); |
|
2273 |
$self->{ct}->{quirks} = 1; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2274 |
|
!!!cp (180); |
2275 |
|
$self->{ct}->{quirks} = 1; |
2276 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2277 |
|
} else { |
2278 |
|
!!!cp (180.1); |
2279 |
|
$self->{state} = BOGUS_MD_STATE; |
2280 |
|
} |
2281 |
|
|
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
|
2282 |
!!!next-input-character; |
!!!next-input-character; |
2283 |
redo A; |
redo A; |
2284 |
} |
} |
2290 |
0x0042, # B |
0x0042, # B |
2291 |
0x004C, # L |
0x004C, # L |
2292 |
0x0049, # I |
0x0049, # I |
2293 |
]->[length $self->{s_kwd}] or |
]->[length $self->{kwd}] or |
2294 |
$self->{nc} == [ |
$self->{nc} == [ |
2295 |
undef, |
undef, |
2296 |
0x0075, # u |
0x0075, # u |
2297 |
0x0062, # b |
0x0062, # b |
2298 |
0x006C, # l |
0x006C, # l |
2299 |
0x0069, # i |
0x0069, # i |
2300 |
]->[length $self->{s_kwd}]) { |
]->[length $self->{kwd}]) { |
2301 |
!!!cp (175); |
!!!cp (175); |
2302 |
## Stay in the state. |
## Stay in the state. |
2303 |
$self->{s_kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
2304 |
!!!next-input-character; |
!!!next-input-character; |
2305 |
redo A; |
redo A; |
2306 |
} elsif ((length $self->{s_kwd}) == 5 and |
} elsif ((length $self->{kwd}) == 5 and |
2307 |
($self->{nc} == 0x0043 or # C |
($self->{nc} == 0x0043 or # C |
2308 |
$self->{nc} == 0x0063)) { # c |
$self->{nc} == 0x0063)) { # c |
2309 |
!!!cp (168); |
if ($self->{is_xml} and |
2310 |
|
($self->{kwd} ne 'PUBLI' or $self->{nc} == 0x0063)) { # c |
2311 |
|
!!!cp (168.1); |
2312 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
2313 |
|
text => 'PUBLIC', |
2314 |
|
line => $self->{line_prev}, |
2315 |
|
column => $self->{column_prev} - 4); |
2316 |
|
} else { |
2317 |
|
!!!cp (168); |
2318 |
|
} |
2319 |
$self->{state} = BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
$self->{state} = BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
2320 |
!!!next-input-character; |
!!!next-input-character; |
2321 |
redo A; |
redo A; |
2322 |
} else { |
} else { |
2323 |
!!!cp (169); |
!!!parse-error (type => 'string after DOCTYPE name', ## TODO: type |
|
!!!parse-error (type => 'string after DOCTYPE name', |
|
2324 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2325 |
column => $self->{column_prev} + 1 - length $self->{s_kwd}); |
column => $self->{column_prev} + 1 - length $self->{kwd}); |
2326 |
$self->{ct}->{quirks} = 1; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2327 |
|
!!!cp (169); |
2328 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
$self->{ct}->{quirks} = 1; |
2329 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2330 |
|
} else { |
2331 |
|
!!!cp (169.1); |
2332 |
|
$self->{state} = BOGUS_MD_STATE; |
2333 |
|
} |
2334 |
## Reconsume. |
## Reconsume. |
2335 |
redo A; |
redo A; |
2336 |
} |
} |
2342 |
0x0053, # S |
0x0053, # S |
2343 |
0x0054, # T |
0x0054, # T |
2344 |
0x0045, # E |
0x0045, # E |
2345 |
]->[length $self->{s_kwd}] or |
]->[length $self->{kwd}] or |
2346 |
$self->{nc} == [ |
$self->{nc} == [ |
2347 |
undef, |
undef, |
2348 |
0x0079, # y |
0x0079, # y |
2349 |
0x0073, # s |
0x0073, # s |
2350 |
0x0074, # t |
0x0074, # t |
2351 |
0x0065, # e |
0x0065, # e |
2352 |
]->[length $self->{s_kwd}]) { |
]->[length $self->{kwd}]) { |
2353 |
!!!cp (170); |
!!!cp (170); |
2354 |
## Stay in the state. |
## Stay in the state. |
2355 |
$self->{s_kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
2356 |
!!!next-input-character; |
!!!next-input-character; |
2357 |
redo A; |
redo A; |
2358 |
} elsif ((length $self->{s_kwd}) == 5 and |
} elsif ((length $self->{kwd}) == 5 and |
2359 |
($self->{nc} == 0x004D or # M |
($self->{nc} == 0x004D or # M |
2360 |
$self->{nc} == 0x006D)) { # m |
$self->{nc} == 0x006D)) { # m |
2361 |
!!!cp (171); |
if ($self->{is_xml} and |
2362 |
|
($self->{kwd} ne 'SYSTE' or $self->{nc} == 0x006D)) { # m |
2363 |
|
!!!cp (171.1); |
2364 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
2365 |
|
text => 'SYSTEM', |
2366 |
|
line => $self->{line_prev}, |
2367 |
|
column => $self->{column_prev} - 4); |
2368 |
|
} else { |
2369 |
|
!!!cp (171); |
2370 |
|
} |
2371 |
$self->{state} = BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
$self->{state} = BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
2372 |
!!!next-input-character; |
!!!next-input-character; |
2373 |
redo A; |
redo A; |
2374 |
} else { |
} else { |
2375 |
!!!cp (172); |
!!!parse-error (type => 'string after DOCTYPE name', ## TODO: type |
|
!!!parse-error (type => 'string after DOCTYPE name', |
|
2376 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
2377 |
column => $self->{column_prev} + 1 - length $self->{s_kwd}); |
column => $self->{column_prev} + 1 - length $self->{kwd}); |
2378 |
$self->{ct}->{quirks} = 1; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2379 |
|
!!!cp (172); |
2380 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
$self->{ct}->{quirks} = 1; |
2381 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2382 |
|
} else { |
2383 |
|
!!!cp (172.1); |
2384 |
|
$self->{state} = BOGUS_MD_STATE; |
2385 |
|
} |
2386 |
## Reconsume. |
## Reconsume. |
2387 |
redo A; |
redo A; |
2388 |
} |
} |
2405 |
!!!next-input-character; |
!!!next-input-character; |
2406 |
redo A; |
redo A; |
2407 |
} elsif ($self->{nc} eq 0x003E) { # > |
} elsif ($self->{nc} eq 0x003E) { # > |
|
!!!cp (184); |
|
2408 |
!!!parse-error (type => 'no PUBLIC literal'); |
!!!parse-error (type => 'no PUBLIC literal'); |
2409 |
|
|
2410 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2411 |
|
!!!cp (184); |
2412 |
|
$self->{state} = DATA_STATE; |
2413 |
|
$self->{s_kwd} = ''; |
2414 |
|
$self->{ct}->{quirks} = 1; |
2415 |
|
} else { |
2416 |
|
!!!cp (184.1); |
2417 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2418 |
|
} |
2419 |
|
|
2420 |
!!!next-input-character; |
!!!next-input-character; |
2421 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
$self->{ct}->{quirks} = 1; |
|
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2422 |
redo A; |
redo A; |
2423 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2424 |
!!!cp (185); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2425 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!cp (185); |
2426 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
2427 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2428 |
|
$self->{s_kwd} = ''; |
2429 |
|
$self->{ct}->{quirks} = 1; |
2430 |
|
} else { |
2431 |
|
!!!cp (185.1); |
2432 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
2433 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2434 |
|
} |
2435 |
|
|
2436 |
## reconsume |
## reconsume |
|
|
|
|
$self->{ct}->{quirks} = 1; |
|
2437 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2438 |
|
redo A; |
2439 |
|
} elsif ($self->{is_xml} and |
2440 |
|
$self->{ct}->{type} == DOCTYPE_TOKEN and |
2441 |
|
$self->{nc} == 0x005B) { # [ |
2442 |
|
!!!cp (186.1); |
2443 |
|
!!!parse-error (type => 'no PUBLIC literal'); |
2444 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2445 |
|
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2446 |
|
$self->{in_subset} = 1; |
2447 |
|
!!!next-input-character; |
2448 |
|
!!!emit ($self->{ct}); # DOCTYPE |
2449 |
redo A; |
redo A; |
2450 |
} else { |
} else { |
|
!!!cp (186); |
|
2451 |
!!!parse-error (type => 'string after PUBLIC'); |
!!!parse-error (type => 'string after PUBLIC'); |
|
$self->{ct}->{quirks} = 1; |
|
2452 |
|
|
2453 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2454 |
|
!!!cp (186); |
2455 |
|
$self->{ct}->{quirks} = 1; |
2456 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2457 |
|
} else { |
2458 |
|
!!!cp (186.2); |
2459 |
|
$self->{state} = BOGUS_MD_STATE; |
2460 |
|
} |
2461 |
|
|
2462 |
!!!next-input-character; |
!!!next-input-character; |
2463 |
redo A; |
redo A; |
2464 |
} |
} |
2469 |
!!!next-input-character; |
!!!next-input-character; |
2470 |
redo A; |
redo A; |
2471 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
|
!!!cp (188); |
|
2472 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
2473 |
|
|
2474 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2475 |
!!!next-input-character; |
!!!cp (188); |
2476 |
|
$self->{state} = DATA_STATE; |
2477 |
$self->{ct}->{quirks} = 1; |
$self->{s_kwd} = ''; |
2478 |
!!!emit ($self->{ct}); # DOCTYPE |
$self->{ct}->{quirks} = 1; |
2479 |
|
} else { |
2480 |
|
!!!cp (188.1); |
2481 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2482 |
|
} |
2483 |
|
|
2484 |
|
!!!next-input-character; |
2485 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2486 |
redo A; |
redo A; |
2487 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (189); |
|
2488 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
2489 |
|
|
2490 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2491 |
## reconsume |
!!!cp (189); |
2492 |
|
$self->{state} = DATA_STATE; |
2493 |
$self->{ct}->{quirks} = 1; |
$self->{s_kwd} = ''; |
2494 |
|
$self->{ct}->{quirks} = 1; |
2495 |
|
} else { |
2496 |
|
!!!cp (189.1); |
2497 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2498 |
|
} |
2499 |
|
|
2500 |
|
## Reconsume. |
2501 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
2502 |
redo A; |
redo A; |
2503 |
} else { |
} else { |
2504 |
!!!cp (190); |
!!!cp (190); |
2505 |
$self->{ct}->{pubid} # DOCTYPE |
$self->{ct}->{pubid} .= chr $self->{nc}; # DOCTYPE/ENTITY/NOTATION |
|
.= chr $self->{nc}; |
|
2506 |
$self->{read_until}->($self->{ct}->{pubid}, q[">], |
$self->{read_until}->($self->{ct}->{pubid}, q[">], |
2507 |
length $self->{ct}->{pubid}); |
length $self->{ct}->{pubid}); |
2508 |
|
|
2517 |
!!!next-input-character; |
!!!next-input-character; |
2518 |
redo A; |
redo A; |
2519 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
|
!!!cp (192); |
|
2520 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
2521 |
|
|
2522 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2523 |
!!!next-input-character; |
!!!cp (192); |
2524 |
|
$self->{state} = DATA_STATE; |
2525 |
$self->{ct}->{quirks} = 1; |
$self->{s_kwd} = ''; |
2526 |
!!!emit ($self->{ct}); # DOCTYPE |
$self->{ct}->{quirks} = 1; |
2527 |
|
} else { |
2528 |
|
!!!cp (192.1); |
2529 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2530 |
|
} |
2531 |
|
|
2532 |
|
!!!next-input-character; |
2533 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2534 |
redo A; |
redo A; |
2535 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (193); |
|
2536 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
2537 |
|
|
2538 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2539 |
|
!!!cp (193); |
2540 |
|
$self->{state} = DATA_STATE; |
2541 |
|
$self->{s_kwd} = ''; |
2542 |
|
$self->{ct}->{quirks} = 1; |
2543 |
|
} else { |
2544 |
|
!!!cp (193.1); |
2545 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2546 |
|
} |
2547 |
|
|
2548 |
## reconsume |
## reconsume |
2549 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
$self->{ct}->{quirks} = 1; |
|
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2550 |
redo A; |
redo A; |
2551 |
} else { |
} else { |
2552 |
!!!cp (194); |
!!!cp (194); |
2553 |
$self->{ct}->{pubid} # DOCTYPE |
$self->{ct}->{pubid} .= chr $self->{nc}; # DOCTYPE/ENTITY/NOTATION |
|
.= chr $self->{nc}; |
|
2554 |
$self->{read_until}->($self->{ct}->{pubid}, q['>], |
$self->{read_until}->($self->{ct}->{pubid}, q['>], |
2555 |
length $self->{ct}->{pubid}); |
length $self->{ct}->{pubid}); |
2556 |
|
|
2566 |
redo A; |
redo A; |
2567 |
} elsif ($self->{nc} == 0x0022) { # " |
} elsif ($self->{nc} == 0x0022) { # " |
2568 |
!!!cp (196); |
!!!cp (196); |
2569 |
$self->{ct}->{sysid} = ''; # DOCTYPE |
$self->{ct}->{sysid} = ''; # DOCTYPE/ENTITY/NOTATION |
2570 |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; |
2571 |
!!!next-input-character; |
!!!next-input-character; |
2572 |
redo A; |
redo A; |
2573 |
} elsif ($self->{nc} == 0x0027) { # ' |
} elsif ($self->{nc} == 0x0027) { # ' |
2574 |
!!!cp (197); |
!!!cp (197); |
2575 |
$self->{ct}->{sysid} = ''; # DOCTYPE |
$self->{ct}->{sysid} = ''; # DOCTYPE/ENTITY/NOTATION |
2576 |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; |
2577 |
!!!next-input-character; |
!!!next-input-character; |
2578 |
redo A; |
redo A; |
2579 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2580 |
!!!cp (198); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2581 |
$self->{state} = DATA_STATE; |
if ($self->{is_xml}) { |
2582 |
|
!!!cp (198.1); |
2583 |
|
!!!parse-error (type => 'no SYSTEM literal'); |
2584 |
|
} else { |
2585 |
|
!!!cp (198); |
2586 |
|
} |
2587 |
|
$self->{state} = DATA_STATE; |
2588 |
|
$self->{s_kwd} = ''; |
2589 |
|
} else { |
2590 |
|
if ($self->{ct}->{type} == NOTATION_TOKEN) { |
2591 |
|
!!!cp (198.2); |
2592 |
|
} else { |
2593 |
|
!!!cp (198.3); |
2594 |
|
!!!parse-error (type => 'no SYSTEM literal'); |
2595 |
|
} |
2596 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2597 |
|
} |
2598 |
|
|
2599 |
!!!next-input-character; |
!!!next-input-character; |
2600 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2601 |
redo A; |
redo A; |
2602 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2603 |
!!!cp (199); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2604 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!cp (199); |
2605 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
2606 |
$self->{state} = DATA_STATE; |
|
2607 |
|
$self->{state} = DATA_STATE; |
2608 |
|
$self->{s_kwd} = ''; |
2609 |
|
$self->{ct}->{quirks} = 1; |
2610 |
|
} else { |
2611 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
2612 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2613 |
|
} |
2614 |
|
|
2615 |
## reconsume |
## reconsume |
2616 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2617 |
$self->{ct}->{quirks} = 1; |
redo A; |
2618 |
|
} elsif ($self->{is_xml} and |
2619 |
|
$self->{ct}->{type} == DOCTYPE_TOKEN and |
2620 |
|
$self->{nc} == 0x005B) { # [ |
2621 |
|
!!!cp (200.1); |
2622 |
|
!!!parse-error (type => 'no SYSTEM literal'); |
2623 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2624 |
|
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2625 |
|
$self->{in_subset} = 1; |
2626 |
|
!!!next-input-character; |
2627 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
2628 |
redo A; |
redo A; |
2629 |
} else { |
} else { |
|
!!!cp (200); |
|
2630 |
!!!parse-error (type => 'string after PUBLIC literal'); |
!!!parse-error (type => 'string after PUBLIC literal'); |
|
$self->{ct}->{quirks} = 1; |
|
2631 |
|
|
2632 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2633 |
|
!!!cp (200); |
2634 |
|
$self->{ct}->{quirks} = 1; |
2635 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2636 |
|
} else { |
2637 |
|
!!!cp (200.2); |
2638 |
|
$self->{state} = BOGUS_MD_STATE; |
2639 |
|
} |
2640 |
|
|
2641 |
!!!next-input-character; |
!!!next-input-character; |
2642 |
redo A; |
redo A; |
2643 |
} |
} |
2660 |
!!!next-input-character; |
!!!next-input-character; |
2661 |
redo A; |
redo A; |
2662 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
|
!!!cp (204); |
|
2663 |
!!!parse-error (type => 'no SYSTEM literal'); |
!!!parse-error (type => 'no SYSTEM literal'); |
|
$self->{state} = DATA_STATE; |
|
2664 |
!!!next-input-character; |
!!!next-input-character; |
2665 |
|
|
2666 |
$self->{ct}->{quirks} = 1; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2667 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!cp (204); |
2668 |
|
$self->{state} = DATA_STATE; |
2669 |
|
$self->{s_kwd} = ''; |
2670 |
|
$self->{ct}->{quirks} = 1; |
2671 |
|
} else { |
2672 |
|
!!!cp (204.1); |
2673 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2674 |
|
} |
2675 |
|
|
2676 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2677 |
redo A; |
redo A; |
2678 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2679 |
!!!cp (205); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2680 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!cp (205); |
2681 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
2682 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2683 |
|
$self->{s_kwd} = ''; |
2684 |
|
$self->{ct}->{quirks} = 1; |
2685 |
|
} else { |
2686 |
|
!!!cp (205.1); |
2687 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
2688 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2689 |
|
} |
2690 |
|
|
2691 |
## reconsume |
## reconsume |
2692 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2693 |
|
redo A; |
2694 |
|
} elsif ($self->{is_xml} and |
2695 |
|
$self->{ct}->{type} == DOCTYPE_TOKEN and |
2696 |
|
$self->{nc} == 0x005B) { # [ |
2697 |
|
!!!cp (206.1); |
2698 |
|
!!!parse-error (type => 'no SYSTEM literal'); |
2699 |
|
|
2700 |
$self->{ct}->{quirks} = 1; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2701 |
|
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2702 |
|
$self->{in_subset} = 1; |
2703 |
|
!!!next-input-character; |
2704 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
2705 |
redo A; |
redo A; |
2706 |
} else { |
} else { |
|
!!!cp (206); |
|
2707 |
!!!parse-error (type => 'string after SYSTEM'); |
!!!parse-error (type => 'string after SYSTEM'); |
|
$self->{ct}->{quirks} = 1; |
|
2708 |
|
|
2709 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2710 |
|
!!!cp (206); |
2711 |
|
$self->{ct}->{quirks} = 1; |
2712 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2713 |
|
} else { |
2714 |
|
!!!cp (206.2); |
2715 |
|
$self->{state} = BOGUS_MD_STATE; |
2716 |
|
} |
2717 |
|
|
2718 |
!!!next-input-character; |
!!!next-input-character; |
2719 |
redo A; |
redo A; |
2720 |
} |
} |
2724 |
$self->{state} = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
$self->{state} = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
2725 |
!!!next-input-character; |
!!!next-input-character; |
2726 |
redo A; |
redo A; |
2727 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif (not $self->{is_xml} and $self->{nc} == 0x003E) { # > |
|
!!!cp (208); |
|
2728 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
2729 |
|
|
2730 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2731 |
|
!!!cp (208); |
2732 |
|
$self->{state} = DATA_STATE; |
2733 |
|
$self->{s_kwd} = ''; |
2734 |
|
$self->{ct}->{quirks} = 1; |
2735 |
|
} else { |
2736 |
|
!!!cp (208.1); |
2737 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2738 |
|
} |
2739 |
|
|
2740 |
!!!next-input-character; |
!!!next-input-character; |
2741 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
$self->{ct}->{quirks} = 1; |
|
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2742 |
redo A; |
redo A; |
2743 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (209); |
|
2744 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
2745 |
|
|
2746 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2747 |
|
!!!cp (209); |
2748 |
|
$self->{state} = DATA_STATE; |
2749 |
|
$self->{s_kwd} = ''; |
2750 |
|
$self->{ct}->{quirks} = 1; |
2751 |
|
} else { |
2752 |
|
!!!cp (209.1); |
2753 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2754 |
|
} |
2755 |
|
|
2756 |
## reconsume |
## reconsume |
2757 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
|
$self->{ct}->{quirks} = 1; |
|
|
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
|
2758 |
redo A; |
redo A; |
2759 |
} else { |
} else { |
2760 |
!!!cp (210); |
!!!cp (210); |
2761 |
$self->{ct}->{sysid} # DOCTYPE |
$self->{ct}->{sysid} .= chr $self->{nc}; # DOCTYPE/ENTITY/NOTATION |
|
.= chr $self->{nc}; |
|
2762 |
$self->{read_until}->($self->{ct}->{sysid}, q[">], |
$self->{read_until}->($self->{ct}->{sysid}, q[">], |
2763 |
length $self->{ct}->{sysid}); |
length $self->{ct}->{sysid}); |
2764 |
|
|
2772 |
$self->{state} = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
$self->{state} = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
2773 |
!!!next-input-character; |
!!!next-input-character; |
2774 |
redo A; |
redo A; |
2775 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif (not $self->{is_xml} and $self->{nc} == 0x003E) { # > |
2776 |
!!!cp (212); |
!!!cp (212); |
2777 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
2778 |
|
|
2779 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2780 |
|
$self->{s_kwd} = ''; |
2781 |
!!!next-input-character; |
!!!next-input-character; |
2782 |
|
|
2783 |
$self->{ct}->{quirks} = 1; |
$self->{ct}->{quirks} = 1; |
2785 |
|
|
2786 |
redo A; |
redo A; |
2787 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
|
!!!cp (213); |
|
2788 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
2789 |
|
|
2790 |
$self->{state} = DATA_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2791 |
## reconsume |
!!!cp (213); |
2792 |
|
$self->{state} = DATA_STATE; |
2793 |
$self->{ct}->{quirks} = 1; |
$self->{s_kwd} = ''; |
2794 |
!!!emit ($self->{ct}); # DOCTYPE |
$self->{ct}->{quirks} = 1; |
2795 |
|
} else { |
2796 |
|
!!!cp (213.1); |
2797 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2798 |
|
} |
2799 |
|
|
2800 |
|
## reconsume |
2801 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2802 |
redo A; |
redo A; |
2803 |
} else { |
} else { |
2804 |
!!!cp (214); |
!!!cp (214); |
2805 |
$self->{ct}->{sysid} # DOCTYPE |
$self->{ct}->{sysid} .= chr $self->{nc}; # DOCTYPE/ENTITY/NOTATION |
|
.= chr $self->{nc}; |
|
2806 |
$self->{read_until}->($self->{ct}->{sysid}, q['>], |
$self->{read_until}->($self->{ct}->{sysid}, q['>], |
2807 |
length $self->{ct}->{sysid}); |
length $self->{ct}->{sysid}); |
2808 |
|
|
2817 |
!!!next-input-character; |
!!!next-input-character; |
2818 |
redo A; |
redo A; |
2819 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2820 |
!!!cp (216); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2821 |
$self->{state} = DATA_STATE; |
!!!cp (216); |
2822 |
!!!next-input-character; |
$self->{state} = DATA_STATE; |
2823 |
|
$self->{s_kwd} = ''; |
2824 |
!!!emit ($self->{ct}); # DOCTYPE |
} else { |
2825 |
|
!!!cp (216.1); |
2826 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2827 |
|
} |
2828 |
|
|
2829 |
|
!!!next-input-character; |
2830 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2831 |
redo A; |
redo A; |
2832 |
|
## TODO: "NDATA" |
2833 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2834 |
!!!cp (217); |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2835 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!cp (217); |
2836 |
$self->{state} = DATA_STATE; |
!!!parse-error (type => 'unclosed DOCTYPE'); |
2837 |
## reconsume |
$self->{state} = DATA_STATE; |
2838 |
|
$self->{s_kwd} = ''; |
2839 |
|
$self->{ct}->{quirks} = 1; |
2840 |
|
} else { |
2841 |
|
!!!cp (217.1); |
2842 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
2843 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2844 |
|
} |
2845 |
|
|
2846 |
$self->{ct}->{quirks} = 1; |
## reconsume |
2847 |
|
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2848 |
|
redo A; |
2849 |
|
} elsif ($self->{is_xml} and |
2850 |
|
$self->{ct}->{type} == DOCTYPE_TOKEN and |
2851 |
|
$self->{nc} == 0x005B) { # [ |
2852 |
|
!!!cp (218.1); |
2853 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2854 |
|
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2855 |
|
$self->{in_subset} = 1; |
2856 |
|
!!!next-input-character; |
2857 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
|
|
|
2858 |
redo A; |
redo A; |
2859 |
} else { |
} else { |
|
!!!cp (218); |
|
2860 |
!!!parse-error (type => 'string after SYSTEM literal'); |
!!!parse-error (type => 'string after SYSTEM literal'); |
|
#$self->{ct}->{quirks} = 1; |
|
2861 |
|
|
2862 |
$self->{state} = BOGUS_DOCTYPE_STATE; |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2863 |
|
!!!cp (218); |
2864 |
|
#$self->{ct}->{quirks} = 1; |
2865 |
|
$self->{state} = BOGUS_DOCTYPE_STATE; |
2866 |
|
} else { |
2867 |
|
!!!cp (218.2); |
2868 |
|
$self->{state} = BOGUS_MD_STATE; |
2869 |
|
} |
2870 |
|
|
2871 |
!!!next-input-character; |
!!!next-input-character; |
2872 |
redo A; |
redo A; |
2873 |
} |
} |
2875 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
2876 |
!!!cp (219); |
!!!cp (219); |
2877 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2878 |
|
$self->{s_kwd} = ''; |
2879 |
!!!next-input-character; |
!!!next-input-character; |
2880 |
|
|
2881 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2882 |
|
|
2883 |
redo A; |
redo A; |
2884 |
|
} elsif ($self->{is_xml} and $self->{nc} == 0x005B) { # [ |
2885 |
|
!!!cp (220.1); |
2886 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2887 |
|
$self->{ct}->{has_internal_subset} = 1; # DOCTYPE |
2888 |
|
$self->{in_subset} = 1; |
2889 |
|
!!!next-input-character; |
2890 |
|
!!!emit ($self->{ct}); # DOCTYPE |
2891 |
|
redo A; |
2892 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2893 |
!!!cp (220); |
!!!cp (220); |
2894 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2895 |
|
$self->{s_kwd} = ''; |
2896 |
## reconsume |
## reconsume |
2897 |
|
|
2898 |
!!!emit ($self->{ct}); # DOCTYPE |
!!!emit ($self->{ct}); # DOCTYPE |
2901 |
} else { |
} else { |
2902 |
!!!cp (221); |
!!!cp (221); |
2903 |
my $s = ''; |
my $s = ''; |
2904 |
$self->{read_until}->($s, q[>], 0); |
$self->{read_until}->($s, q{>[}, 0); |
2905 |
|
|
2906 |
## Stay in the state |
## Stay in the state |
2907 |
!!!next-input-character; |
!!!next-input-character; |
2911 |
## NOTE: "CDATA section state" in the state is jointly implemented |
## NOTE: "CDATA section state" in the state is jointly implemented |
2912 |
## by three states, |CDATA_SECTION_STATE|, |CDATA_SECTION_MSE1_STATE|, |
## by three states, |CDATA_SECTION_STATE|, |CDATA_SECTION_MSE1_STATE|, |
2913 |
## and |CDATA_SECTION_MSE2_STATE|. |
## and |CDATA_SECTION_MSE2_STATE|. |
2914 |
|
|
2915 |
|
## XML5: "CDATA state". |
2916 |
|
|
2917 |
if ($self->{nc} == 0x005D) { # ] |
if ($self->{nc} == 0x005D) { # ] |
2918 |
!!!cp (221.1); |
!!!cp (221.1); |
2920 |
!!!next-input-character; |
!!!next-input-character; |
2921 |
redo A; |
redo A; |
2922 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2923 |
|
if ($self->{is_xml}) { |
2924 |
|
!!!cp (221.11); |
2925 |
|
!!!parse-error (type => 'no mse'); ## TODO: type |
2926 |
|
} else { |
2927 |
|
!!!cp (221.12); |
2928 |
|
} |
2929 |
|
|
2930 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2931 |
!!!next-input-character; |
$self->{s_kwd} = ''; |
2932 |
|
## Reconsume. |
2933 |
if (length $self->{ct}->{data}) { # character |
if (length $self->{ct}->{data}) { # character |
2934 |
!!!cp (221.2); |
!!!cp (221.2); |
2935 |
!!!emit ($self->{ct}); # character |
!!!emit ($self->{ct}); # character |
2952 |
|
|
2953 |
## ISSUE: "text tokens" in spec. |
## ISSUE: "text tokens" in spec. |
2954 |
} elsif ($self->{state} == CDATA_SECTION_MSE1_STATE) { |
} elsif ($self->{state} == CDATA_SECTION_MSE1_STATE) { |
2955 |
|
## XML5: "CDATA bracket state". |
2956 |
|
|
2957 |
if ($self->{nc} == 0x005D) { # ] |
if ($self->{nc} == 0x005D) { # ] |
2958 |
!!!cp (221.5); |
!!!cp (221.5); |
2959 |
$self->{state} = CDATA_SECTION_MSE2_STATE; |
$self->{state} = CDATA_SECTION_MSE2_STATE; |
2961 |
redo A; |
redo A; |
2962 |
} else { |
} else { |
2963 |
!!!cp (221.6); |
!!!cp (221.6); |
2964 |
|
## XML5: If EOF, "]" is not appended and changed to the data state. |
2965 |
$self->{ct}->{data} .= ']'; |
$self->{ct}->{data} .= ']'; |
2966 |
$self->{state} = CDATA_SECTION_STATE; |
$self->{state} = CDATA_SECTION_STATE; ## XML5: Stay in the state. |
2967 |
## Reconsume. |
## Reconsume. |
2968 |
redo A; |
redo A; |
2969 |
} |
} |
2970 |
} elsif ($self->{state} == CDATA_SECTION_MSE2_STATE) { |
} elsif ($self->{state} == CDATA_SECTION_MSE2_STATE) { |
2971 |
|
## XML5: "CDATA end state". |
2972 |
|
|
2973 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
2974 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
2975 |
|
$self->{s_kwd} = ''; |
2976 |
!!!next-input-character; |
!!!next-input-character; |
2977 |
if (length $self->{ct}->{data}) { # character |
if (length $self->{ct}->{data}) { # character |
2978 |
!!!cp (221.7); |
!!!cp (221.7); |
2992 |
!!!cp (221.11); |
!!!cp (221.11); |
2993 |
$self->{ct}->{data} .= ']]'; # character |
$self->{ct}->{data} .= ']]'; # character |
2994 |
$self->{state} = CDATA_SECTION_STATE; |
$self->{state} = CDATA_SECTION_STATE; |
2995 |
## Reconsume. |
## Reconsume. ## XML5: Emit. |
2996 |
redo A; |
redo A; |
2997 |
} |
} |
2998 |
} elsif ($self->{state} == ENTITY_STATE) { |
} elsif ($self->{state} == ENTITY_STATE) { |
3009 |
} elsif ($self->{nc} == 0x0023) { # # |
} elsif ($self->{nc} == 0x0023) { # # |
3010 |
!!!cp (999); |
!!!cp (999); |
3011 |
$self->{state} = ENTITY_HASH_STATE; |
$self->{state} = ENTITY_HASH_STATE; |
3012 |
$self->{s_kwd} = '#'; |
$self->{kwd} = '#'; |
3013 |
!!!next-input-character; |
!!!next-input-character; |
3014 |
redo A; |
redo A; |
3015 |
} elsif ((0x0041 <= $self->{nc} and |
} elsif ((0x0041 <= $self->{nc} and |
3019 |
!!!cp (998); |
!!!cp (998); |
3020 |
require Whatpm::_NamedEntityList; |
require Whatpm::_NamedEntityList; |
3021 |
$self->{state} = ENTITY_NAME_STATE; |
$self->{state} = ENTITY_NAME_STATE; |
3022 |
$self->{s_kwd} = chr $self->{nc}; |
$self->{kwd} = chr $self->{nc}; |
3023 |
$self->{entity__value} = $self->{s_kwd}; |
$self->{entity__value} = $self->{kwd}; |
3024 |
$self->{entity__match} = 0; |
$self->{entity__match} = 0; |
3025 |
!!!next-input-character; |
!!!next-input-character; |
3026 |
redo A; |
redo A; |
3040 |
if ($self->{prev_state} == DATA_STATE) { |
if ($self->{prev_state} == DATA_STATE) { |
3041 |
!!!cp (997); |
!!!cp (997); |
3042 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3043 |
|
$self->{s_kwd} = ''; |
3044 |
## Reconsume. |
## Reconsume. |
3045 |
!!!emit ({type => CHARACTER_TOKEN, data => '&', |
!!!emit ({type => CHARACTER_TOKEN, data => '&', |
3046 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
3051 |
!!!cp (996); |
!!!cp (996); |
3052 |
$self->{ca}->{value} .= '&'; |
$self->{ca}->{value} .= '&'; |
3053 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3054 |
|
$self->{s_kwd} = ''; |
3055 |
## Reconsume. |
## Reconsume. |
3056 |
redo A; |
redo A; |
3057 |
} |
} |
3060 |
$self->{nc} == 0x0058) { # X |
$self->{nc} == 0x0058) { # X |
3061 |
!!!cp (995); |
!!!cp (995); |
3062 |
$self->{state} = HEXREF_X_STATE; |
$self->{state} = HEXREF_X_STATE; |
3063 |
$self->{s_kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3064 |
!!!next-input-character; |
!!!next-input-character; |
3065 |
redo A; |
redo A; |
3066 |
} elsif (0x0030 <= $self->{nc} and |
} elsif (0x0030 <= $self->{nc} and |
3067 |
$self->{nc} <= 0x0039) { # 0..9 |
$self->{nc} <= 0x0039) { # 0..9 |
3068 |
!!!cp (994); |
!!!cp (994); |
3069 |
$self->{state} = NCR_NUM_STATE; |
$self->{state} = NCR_NUM_STATE; |
3070 |
$self->{s_kwd} = $self->{nc} - 0x0030; |
$self->{kwd} = $self->{nc} - 0x0030; |
3071 |
!!!next-input-character; |
!!!next-input-character; |
3072 |
redo A; |
redo A; |
3073 |
} else { |
} else { |
3082 |
if ($self->{prev_state} == DATA_STATE) { |
if ($self->{prev_state} == DATA_STATE) { |
3083 |
!!!cp (1019); |
!!!cp (1019); |
3084 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3085 |
|
$self->{s_kwd} = ''; |
3086 |
## Reconsume. |
## Reconsume. |
3087 |
!!!emit ({type => CHARACTER_TOKEN, |
!!!emit ({type => CHARACTER_TOKEN, |
3088 |
data => '&#', |
data => '&#', |
3094 |
!!!cp (993); |
!!!cp (993); |
3095 |
$self->{ca}->{value} .= '&#'; |
$self->{ca}->{value} .= '&#'; |
3096 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3097 |
|
$self->{s_kwd} = ''; |
3098 |
## Reconsume. |
## Reconsume. |
3099 |
redo A; |
redo A; |
3100 |
} |
} |
3103 |
if (0x0030 <= $self->{nc} and |
if (0x0030 <= $self->{nc} and |
3104 |
$self->{nc} <= 0x0039) { # 0..9 |
$self->{nc} <= 0x0039) { # 0..9 |
3105 |
!!!cp (1012); |
!!!cp (1012); |
3106 |
$self->{s_kwd} *= 10; |
$self->{kwd} *= 10; |
3107 |
$self->{s_kwd} += $self->{nc} - 0x0030; |
$self->{kwd} += $self->{nc} - 0x0030; |
3108 |
|
|
3109 |
## Stay in the state. |
## Stay in the state. |
3110 |
!!!next-input-character; |
!!!next-input-character; |
3120 |
# |
# |
3121 |
} |
} |
3122 |
|
|
3123 |
my $code = $self->{s_kwd}; |
my $code = $self->{kwd}; |
3124 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3125 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3126 |
if ($charref_map->{$code}) { |
if ($charref_map->{$code}) { |
3140 |
if ($self->{prev_state} == DATA_STATE) { |
if ($self->{prev_state} == DATA_STATE) { |
3141 |
!!!cp (992); |
!!!cp (992); |
3142 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3143 |
|
$self->{s_kwd} = ''; |
3144 |
## Reconsume. |
## Reconsume. |
3145 |
!!!emit ({type => CHARACTER_TOKEN, data => chr $code, |
!!!emit ({type => CHARACTER_TOKEN, data => chr $code, |
3146 |
|
has_reference => 1, |
3147 |
line => $l, column => $c, |
line => $l, column => $c, |
3148 |
}); |
}); |
3149 |
redo A; |
redo A; |
3152 |
$self->{ca}->{value} .= chr $code; |
$self->{ca}->{value} .= chr $code; |
3153 |
$self->{ca}->{has_reference} = 1; |
$self->{ca}->{has_reference} = 1; |
3154 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3155 |
|
$self->{s_kwd} = ''; |
3156 |
## Reconsume. |
## Reconsume. |
3157 |
redo A; |
redo A; |
3158 |
} |
} |
3163 |
# 0..9, A..F, a..f |
# 0..9, A..F, a..f |
3164 |
!!!cp (990); |
!!!cp (990); |
3165 |
$self->{state} = HEXREF_HEX_STATE; |
$self->{state} = HEXREF_HEX_STATE; |
3166 |
$self->{s_kwd} = 0; |
$self->{kwd} = 0; |
3167 |
## Reconsume. |
## Reconsume. |
3168 |
redo A; |
redo A; |
3169 |
} else { |
} else { |
3178 |
if ($self->{prev_state} == DATA_STATE) { |
if ($self->{prev_state} == DATA_STATE) { |
3179 |
!!!cp (1005); |
!!!cp (1005); |
3180 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3181 |
|
$self->{s_kwd} = ''; |
3182 |
## Reconsume. |
## Reconsume. |
3183 |
!!!emit ({type => CHARACTER_TOKEN, |
!!!emit ({type => CHARACTER_TOKEN, |
3184 |
data => '&' . $self->{s_kwd}, |
data => '&' . $self->{kwd}, |
3185 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
3186 |
column => $self->{column_prev} - length $self->{s_kwd}, |
column => $self->{column_prev} - length $self->{kwd}, |
3187 |
}); |
}); |
3188 |
redo A; |
redo A; |
3189 |
} else { |
} else { |
3190 |
!!!cp (989); |
!!!cp (989); |
3191 |
$self->{ca}->{value} .= '&' . $self->{s_kwd}; |
$self->{ca}->{value} .= '&' . $self->{kwd}; |
3192 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3193 |
|
$self->{s_kwd} = ''; |
3194 |
## Reconsume. |
## Reconsume. |
3195 |
redo A; |
redo A; |
3196 |
} |
} |
3199 |
if (0x0030 <= $self->{nc} and $self->{nc} <= 0x0039) { |
if (0x0030 <= $self->{nc} and $self->{nc} <= 0x0039) { |
3200 |
# 0..9 |
# 0..9 |
3201 |
!!!cp (1002); |
!!!cp (1002); |
3202 |
$self->{s_kwd} *= 0x10; |
$self->{kwd} *= 0x10; |
3203 |
$self->{s_kwd} += $self->{nc} - 0x0030; |
$self->{kwd} += $self->{nc} - 0x0030; |
3204 |
## Stay in the state. |
## Stay in the state. |
3205 |
!!!next-input-character; |
!!!next-input-character; |
3206 |
redo A; |
redo A; |
3207 |
} elsif (0x0061 <= $self->{nc} and |
} elsif (0x0061 <= $self->{nc} and |
3208 |
$self->{nc} <= 0x0066) { # a..f |
$self->{nc} <= 0x0066) { # a..f |
3209 |
!!!cp (1003); |
!!!cp (1003); |
3210 |
$self->{s_kwd} *= 0x10; |
$self->{kwd} *= 0x10; |
3211 |
$self->{s_kwd} += $self->{nc} - 0x0060 + 9; |
$self->{kwd} += $self->{nc} - 0x0060 + 9; |
3212 |
## Stay in the state. |
## Stay in the state. |
3213 |
!!!next-input-character; |
!!!next-input-character; |
3214 |
redo A; |
redo A; |
3215 |
} elsif (0x0041 <= $self->{nc} and |
} elsif (0x0041 <= $self->{nc} and |
3216 |
$self->{nc} <= 0x0046) { # A..F |
$self->{nc} <= 0x0046) { # A..F |
3217 |
!!!cp (1004); |
!!!cp (1004); |
3218 |
$self->{s_kwd} *= 0x10; |
$self->{kwd} *= 0x10; |
3219 |
$self->{s_kwd} += $self->{nc} - 0x0040 + 9; |
$self->{kwd} += $self->{nc} - 0x0040 + 9; |
3220 |
## Stay in the state. |
## Stay in the state. |
3221 |
!!!next-input-character; |
!!!next-input-character; |
3222 |
redo A; |
redo A; |
3233 |
# |
# |
3234 |
} |
} |
3235 |
|
|
3236 |
my $code = $self->{s_kwd}; |
my $code = $self->{kwd}; |
3237 |
my $l = $self->{line_prev}; |
my $l = $self->{line_prev}; |
3238 |
my $c = $self->{column_prev}; |
my $c = $self->{column_prev}; |
3239 |
if ($charref_map->{$code}) { |
if ($charref_map->{$code}) { |
3253 |
if ($self->{prev_state} == DATA_STATE) { |
if ($self->{prev_state} == DATA_STATE) { |
3254 |
!!!cp (988); |
!!!cp (988); |
3255 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3256 |
|
$self->{s_kwd} = ''; |
3257 |
## Reconsume. |
## Reconsume. |
3258 |
!!!emit ({type => CHARACTER_TOKEN, data => chr $code, |
!!!emit ({type => CHARACTER_TOKEN, data => chr $code, |
3259 |
|
has_reference => 1, |
3260 |
line => $l, column => $c, |
line => $l, column => $c, |
3261 |
}); |
}); |
3262 |
redo A; |
redo A; |
3265 |
$self->{ca}->{value} .= chr $code; |
$self->{ca}->{value} .= chr $code; |
3266 |
$self->{ca}->{has_reference} = 1; |
$self->{ca}->{has_reference} = 1; |
3267 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3268 |
|
$self->{s_kwd} = ''; |
3269 |
## Reconsume. |
## Reconsume. |
3270 |
redo A; |
redo A; |
3271 |
} |
} |
3272 |
} elsif ($self->{state} == ENTITY_NAME_STATE) { |
} elsif ($self->{state} == ENTITY_NAME_STATE) { |
3273 |
if (length $self->{s_kwd} < 30 and |
if (length $self->{kwd} < 30 and |
3274 |
## NOTE: Some number greater than the maximum length of entity name |
## NOTE: Some number greater than the maximum length of entity name |
3275 |
((0x0041 <= $self->{nc} and # a |
((0x0041 <= $self->{nc} and # a |
3276 |
$self->{nc} <= 0x005A) or # x |
$self->{nc} <= 0x005A) or # x |
3280 |
$self->{nc} <= 0x0039) or # 9 |
$self->{nc} <= 0x0039) or # 9 |
3281 |
$self->{nc} == 0x003B)) { # ; |
$self->{nc} == 0x003B)) { # ; |
3282 |
our $EntityChar; |
our $EntityChar; |
3283 |
$self->{s_kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3284 |
if (defined $EntityChar->{$self->{s_kwd}}) { |
if (defined $EntityChar->{$self->{kwd}}) { |
3285 |
if ($self->{nc} == 0x003B) { # ; |
if ($self->{nc} == 0x003B) { # ; |
3286 |
!!!cp (1020); |
!!!cp (1020); |
3287 |
$self->{entity__value} = $EntityChar->{$self->{s_kwd}}; |
$self->{entity__value} = $EntityChar->{$self->{kwd}}; |
3288 |
$self->{entity__match} = 1; |
$self->{entity__match} = 1; |
3289 |
!!!next-input-character; |
!!!next-input-character; |
3290 |
# |
# |
3291 |
} else { |
} else { |
3292 |
!!!cp (1021); |
!!!cp (1021); |
3293 |
$self->{entity__value} = $EntityChar->{$self->{s_kwd}}; |
$self->{entity__value} = $EntityChar->{$self->{kwd}}; |
3294 |
$self->{entity__match} = -1; |
$self->{entity__match} = -1; |
3295 |
## Stay in the state. |
## Stay in the state. |
3296 |
!!!next-input-character; |
!!!next-input-character; |
3318 |
if ($self->{prev_state} != DATA_STATE and # in attribute |
if ($self->{prev_state} != DATA_STATE and # in attribute |
3319 |
$self->{entity__match} < -1) { |
$self->{entity__match} < -1) { |
3320 |
!!!cp (1024); |
!!!cp (1024); |
3321 |
$data = '&' . $self->{s_kwd}; |
$data = '&' . $self->{kwd}; |
3322 |
# |
# |
3323 |
} else { |
} else { |
3324 |
!!!cp (1025); |
!!!cp (1025); |
3330 |
!!!cp (1026); |
!!!cp (1026); |
3331 |
!!!parse-error (type => 'bare ero', |
!!!parse-error (type => 'bare ero', |
3332 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
3333 |
column => $self->{column_prev} - length $self->{s_kwd}); |
column => $self->{column_prev} - length $self->{kwd}); |
3334 |
$data = '&' . $self->{s_kwd}; |
$data = '&' . $self->{kwd}; |
3335 |
# |
# |
3336 |
} |
} |
3337 |
|
|
3348 |
if ($self->{prev_state} == DATA_STATE) { |
if ($self->{prev_state} == DATA_STATE) { |
3349 |
!!!cp (986); |
!!!cp (986); |
3350 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3351 |
|
$self->{s_kwd} = ''; |
3352 |
## Reconsume. |
## Reconsume. |
3353 |
!!!emit ({type => CHARACTER_TOKEN, |
!!!emit ({type => CHARACTER_TOKEN, |
3354 |
data => $data, |
data => $data, |
3355 |
|
has_reference => $has_ref, |
3356 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
3357 |
column => $self->{column_prev} + 1 - length $self->{s_kwd}, |
column => $self->{column_prev} + 1 - length $self->{kwd}, |
3358 |
}); |
}); |
3359 |
redo A; |
redo A; |
3360 |
} else { |
} else { |
3362 |
$self->{ca}->{value} .= $data; |
$self->{ca}->{value} .= $data; |
3363 |
$self->{ca}->{has_reference} = 1 if $has_ref; |
$self->{ca}->{has_reference} = 1 if $has_ref; |
3364 |
$self->{state} = $self->{prev_state}; |
$self->{state} = $self->{prev_state}; |
3365 |
|
$self->{s_kwd} = ''; |
3366 |
|
## Reconsume. |
3367 |
|
redo A; |
3368 |
|
} |
3369 |
|
|
3370 |
|
## XML-only states |
3371 |
|
|
3372 |
|
} elsif ($self->{state} == PI_STATE) { |
3373 |
|
## XML5: "Pi state" and "DOCTYPE pi state". |
3374 |
|
|
3375 |
|
if ($is_space->{$self->{nc}} or |
3376 |
|
$self->{nc} == 0x003F or # ? |
3377 |
|
$self->{nc} == -1) { |
3378 |
|
## XML5: U+003F: "pi state": Same as "Anything else"; "DOCTYPE |
3379 |
|
## pi state": Switch to the "DOCTYPE pi after state". EOF: |
3380 |
|
## "DOCTYPE pi state": Parse error, switch to the "data |
3381 |
|
## state". |
3382 |
|
!!!parse-error (type => 'bare pio', ## TODO: type |
3383 |
|
line => $self->{line_prev}, |
3384 |
|
column => $self->{column_prev} |
3385 |
|
- 1 * ($self->{nc} != -1)); |
3386 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3387 |
|
## Reconsume. |
3388 |
|
$self->{ct} = {type => COMMENT_TOKEN, |
3389 |
|
data => '?', |
3390 |
|
line => $self->{line_prev}, |
3391 |
|
column => $self->{column_prev} |
3392 |
|
- 1 * ($self->{nc} != -1), |
3393 |
|
}; |
3394 |
|
redo A; |
3395 |
|
} else { |
3396 |
|
## XML5: "DOCTYPE pi state": Stay in the state. |
3397 |
|
$self->{ct} = {type => PI_TOKEN, |
3398 |
|
target => chr $self->{nc}, |
3399 |
|
data => '', |
3400 |
|
line => $self->{line_prev}, |
3401 |
|
column => $self->{column_prev} - 1, |
3402 |
|
}; |
3403 |
|
$self->{state} = PI_TARGET_STATE; |
3404 |
|
!!!next-input-character; |
3405 |
|
redo A; |
3406 |
|
} |
3407 |
|
} elsif ($self->{state} == PI_TARGET_STATE) { |
3408 |
|
if ($is_space->{$self->{nc}}) { |
3409 |
|
$self->{state} = PI_TARGET_AFTER_STATE; |
3410 |
|
!!!next-input-character; |
3411 |
|
redo A; |
3412 |
|
} elsif ($self->{nc} == -1) { |
3413 |
|
!!!parse-error (type => 'no pic'); ## TODO: type |
3414 |
|
if ($self->{in_subset}) { |
3415 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
3416 |
|
} else { |
3417 |
|
$self->{state} = DATA_STATE; |
3418 |
|
$self->{s_kwd} = ''; |
3419 |
|
} |
3420 |
## Reconsume. |
## Reconsume. |
3421 |
|
!!!emit ($self->{ct}); # pi |
3422 |
|
redo A; |
3423 |
|
} elsif ($self->{nc} == 0x003F) { # ? |
3424 |
|
$self->{state} = PI_AFTER_STATE; |
3425 |
|
!!!next-input-character; |
3426 |
|
redo A; |
3427 |
|
} else { |
3428 |
|
## XML5: typo ("tag name" -> "target") |
3429 |
|
$self->{ct}->{target} .= chr $self->{nc}; # pi |
3430 |
|
!!!next-input-character; |
3431 |
|
redo A; |
3432 |
|
} |
3433 |
|
} elsif ($self->{state} == PI_TARGET_AFTER_STATE) { |
3434 |
|
if ($is_space->{$self->{nc}}) { |
3435 |
|
## Stay in the state. |
3436 |
|
!!!next-input-character; |
3437 |
|
redo A; |
3438 |
|
} else { |
3439 |
|
$self->{state} = PI_DATA_STATE; |
3440 |
|
## Reprocess. |
3441 |
|
redo A; |
3442 |
|
} |
3443 |
|
} elsif ($self->{state} == PI_DATA_STATE) { |
3444 |
|
if ($self->{nc} == 0x003F) { # ? |
3445 |
|
$self->{state} = PI_DATA_AFTER_STATE; |
3446 |
|
!!!next-input-character; |
3447 |
|
redo A; |
3448 |
|
} elsif ($self->{nc} == -1) { |
3449 |
|
!!!parse-error (type => 'no pic'); ## TODO: type |
3450 |
|
if ($self->{in_subset}) { |
3451 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state" |
3452 |
|
} else { |
3453 |
|
$self->{state} = DATA_STATE; |
3454 |
|
$self->{s_kwd} = ''; |
3455 |
|
} |
3456 |
|
## Reprocess. |
3457 |
|
!!!emit ($self->{ct}); # pi |
3458 |
|
redo A; |
3459 |
|
} else { |
3460 |
|
$self->{ct}->{data} .= chr $self->{nc}; # pi |
3461 |
|
$self->{read_until}->($self->{ct}->{data}, q[?], |
3462 |
|
length $self->{ct}->{data}); |
3463 |
|
## Stay in the state. |
3464 |
|
!!!next-input-character; |
3465 |
|
## Reprocess. |
3466 |
|
redo A; |
3467 |
|
} |
3468 |
|
} elsif ($self->{state} == PI_AFTER_STATE) { |
3469 |
|
## XML5: Part of "Pi after state". |
3470 |
|
|
3471 |
|
if ($self->{nc} == 0x003E) { # > |
3472 |
|
if ($self->{in_subset}) { |
3473 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
3474 |
|
} else { |
3475 |
|
$self->{state} = DATA_STATE; |
3476 |
|
$self->{s_kwd} = ''; |
3477 |
|
} |
3478 |
|
!!!next-input-character; |
3479 |
|
!!!emit ($self->{ct}); # pi |
3480 |
|
redo A; |
3481 |
|
} elsif ($self->{nc} == 0x003F) { # ? |
3482 |
|
!!!parse-error (type => 'no s after target', ## TODO: type |
3483 |
|
line => $self->{line_prev}, |
3484 |
|
column => $self->{column_prev}); ## XML5: no error |
3485 |
|
$self->{ct}->{data} .= '?'; |
3486 |
|
$self->{state} = PI_DATA_AFTER_STATE; |
3487 |
|
!!!next-input-character; |
3488 |
|
redo A; |
3489 |
|
} else { |
3490 |
|
!!!parse-error (type => 'no s after target', ## TODO: type |
3491 |
|
line => $self->{line_prev}, |
3492 |
|
column => $self->{column_prev} |
3493 |
|
+ 1 * ($self->{nc} == -1)); ## XML5: no error |
3494 |
|
$self->{ct}->{data} .= '?'; ## XML5: not appended |
3495 |
|
$self->{state} = PI_DATA_STATE; |
3496 |
|
## Reprocess. |
3497 |
|
redo A; |
3498 |
|
} |
3499 |
|
} elsif ($self->{state} == PI_DATA_AFTER_STATE) { |
3500 |
|
## XML5: Same as "pi after state" and "DOCTYPE pi after state". |
3501 |
|
|
3502 |
|
if ($self->{nc} == 0x003E) { # > |
3503 |
|
if ($self->{in_subset}) { |
3504 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
3505 |
|
} else { |
3506 |
|
$self->{state} = DATA_STATE; |
3507 |
|
$self->{s_kwd} = ''; |
3508 |
|
} |
3509 |
|
!!!next-input-character; |
3510 |
|
!!!emit ($self->{ct}); # pi |
3511 |
|
redo A; |
3512 |
|
} elsif ($self->{nc} == 0x003F) { # ? |
3513 |
|
$self->{ct}->{data} .= '?'; |
3514 |
|
## Stay in the state. |
3515 |
|
!!!next-input-character; |
3516 |
|
redo A; |
3517 |
|
} else { |
3518 |
|
$self->{ct}->{data} .= '?'; ## XML5: not appended |
3519 |
|
$self->{state} = PI_DATA_STATE; |
3520 |
|
## Reprocess. |
3521 |
|
redo A; |
3522 |
|
} |
3523 |
|
|
3524 |
|
} elsif ($self->{state} == DOCTYPE_INTERNAL_SUBSET_STATE) { |
3525 |
|
if ($self->{nc} == 0x003C) { # < |
3526 |
|
$self->{state} = DOCTYPE_TAG_STATE; |
3527 |
|
!!!next-input-character; |
3528 |
|
redo A; |
3529 |
|
} elsif ($self->{nc} == 0x0025) { # % |
3530 |
|
## XML5: Not defined yet. |
3531 |
|
|
3532 |
|
## TODO: |
3533 |
|
!!!next-input-character; |
3534 |
|
redo A; |
3535 |
|
} elsif ($self->{nc} == 0x005D) { # ] |
3536 |
|
delete $self->{in_subset}; |
3537 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_AFTER_STATE; |
3538 |
|
!!!next-input-character; |
3539 |
|
redo A; |
3540 |
|
} elsif ($is_space->{$self->{nc}}) { |
3541 |
|
## Stay in the state. |
3542 |
|
!!!next-input-character; |
3543 |
|
redo A; |
3544 |
|
} elsif ($self->{nc} == -1) { |
3545 |
|
!!!parse-error (type => 'unclosed internal subset'); ## TODO: type |
3546 |
|
delete $self->{in_subset}; |
3547 |
|
$self->{state} = DATA_STATE; |
3548 |
|
$self->{s_kwd} = ''; |
3549 |
|
## Reconsume. |
3550 |
|
!!!emit ({type => END_OF_DOCTYPE_TOKEN}); |
3551 |
|
redo A; |
3552 |
|
} else { |
3553 |
|
unless ($self->{internal_subset_tainted}) { |
3554 |
|
## XML5: No parse error. |
3555 |
|
!!!parse-error (type => 'string in internal subset'); |
3556 |
|
$self->{internal_subset_tainted} = 1; |
3557 |
|
} |
3558 |
|
## Stay in the state. |
3559 |
|
!!!next-input-character; |
3560 |
|
redo A; |
3561 |
|
} |
3562 |
|
} elsif ($self->{state} == DOCTYPE_INTERNAL_SUBSET_AFTER_STATE) { |
3563 |
|
if ($self->{nc} == 0x003E) { # > |
3564 |
|
$self->{state} = DATA_STATE; |
3565 |
|
$self->{s_kwd} = ''; |
3566 |
|
!!!next-input-character; |
3567 |
|
!!!emit ({type => END_OF_DOCTYPE_TOKEN}); |
3568 |
|
redo A; |
3569 |
|
} elsif ($self->{nc} == -1) { |
3570 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
3571 |
|
$self->{state} = DATA_STATE; |
3572 |
|
$self->{s_kwd} = ''; |
3573 |
|
## Reconsume. |
3574 |
|
!!!emit ({type => END_OF_DOCTYPE_TOKEN}); |
3575 |
|
redo A; |
3576 |
|
} else { |
3577 |
|
## XML5: No parse error and stay in the state. |
3578 |
|
!!!parse-error (type => 'string after internal subset'); ## TODO: type |
3579 |
|
|
3580 |
|
$self->{state} = BOGUS_DOCTYPE_INTERNAL_SUBSET_AFTER_STATE; |
3581 |
|
!!!next-input-character; |
3582 |
|
redo A; |
3583 |
|
} |
3584 |
|
} elsif ($self->{state} == BOGUS_DOCTYPE_INTERNAL_SUBSET_AFTER_STATE) { |
3585 |
|
if ($self->{nc} == 0x003E) { # > |
3586 |
|
$self->{state} = DATA_STATE; |
3587 |
|
$self->{s_kwd} = ''; |
3588 |
|
!!!next-input-character; |
3589 |
|
!!!emit ({type => END_OF_DOCTYPE_TOKEN}); |
3590 |
|
redo A; |
3591 |
|
} elsif ($self->{nc} == -1) { |
3592 |
|
$self->{state} = DATA_STATE; |
3593 |
|
$self->{s_kwd} = ''; |
3594 |
|
## Reconsume. |
3595 |
|
!!!emit ({type => END_OF_DOCTYPE_TOKEN}); |
3596 |
|
redo A; |
3597 |
|
} else { |
3598 |
|
## Stay in the state. |
3599 |
|
!!!next-input-character; |
3600 |
|
redo A; |
3601 |
|
} |
3602 |
|
} elsif ($self->{state} == DOCTYPE_TAG_STATE) { |
3603 |
|
if ($self->{nc} == 0x0021) { # ! |
3604 |
|
$self->{state} = DOCTYPE_MARKUP_DECLARATION_OPEN_STATE; |
3605 |
|
!!!next-input-character; |
3606 |
|
redo A; |
3607 |
|
} elsif ($self->{nc} == 0x003F) { # ? |
3608 |
|
$self->{state} = PI_STATE; |
3609 |
|
!!!next-input-character; |
3610 |
|
redo A; |
3611 |
|
} elsif ($self->{nc} == -1) { |
3612 |
|
!!!parse-error (type => 'bare stago'); |
3613 |
|
$self->{state} = DATA_STATE; |
3614 |
|
$self->{s_kwd} = ''; |
3615 |
|
## Reconsume. |
3616 |
|
redo A; |
3617 |
|
} else { |
3618 |
|
!!!parse-error (type => 'bare stago', ## XML5: Not a parse error. |
3619 |
|
line => $self->{line_prev}, |
3620 |
|
column => $self->{column_prev}); |
3621 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3622 |
|
$self->{ct} = {type => COMMENT_TOKEN, |
3623 |
|
data => '', |
3624 |
|
}; ## NOTE: Will be discarded. |
3625 |
|
!!!next-input-character; |
3626 |
|
redo A; |
3627 |
|
} |
3628 |
|
} elsif ($self->{state} == DOCTYPE_MARKUP_DECLARATION_OPEN_STATE) { |
3629 |
|
## XML5: "DOCTYPE markup declaration state". |
3630 |
|
|
3631 |
|
if ($self->{nc} == 0x002D) { # - |
3632 |
|
$self->{state} = MD_HYPHEN_STATE; |
3633 |
|
!!!next-input-character; |
3634 |
|
redo A; |
3635 |
|
} elsif ($self->{nc} == 0x0045 or # E |
3636 |
|
$self->{nc} == 0x0065) { # e |
3637 |
|
$self->{state} = MD_E_STATE; |
3638 |
|
$self->{kwd} = chr $self->{nc}; |
3639 |
|
!!!next-input-character; |
3640 |
|
redo A; |
3641 |
|
} elsif ($self->{nc} == 0x0041 or # A |
3642 |
|
$self->{nc} == 0x0061) { # a |
3643 |
|
$self->{state} = MD_ATTLIST_STATE; |
3644 |
|
$self->{kwd} = chr $self->{nc}; |
3645 |
|
!!!next-input-character; |
3646 |
|
redo A; |
3647 |
|
} elsif ($self->{nc} == 0x004E or # N |
3648 |
|
$self->{nc} == 0x006E) { # n |
3649 |
|
$self->{state} = MD_NOTATION_STATE; |
3650 |
|
$self->{kwd} = chr $self->{nc}; |
3651 |
|
!!!next-input-character; |
3652 |
|
redo A; |
3653 |
|
} else { |
3654 |
|
# |
3655 |
|
} |
3656 |
|
|
3657 |
|
## XML5: No parse error. |
3658 |
|
!!!parse-error (type => 'bogus comment', |
3659 |
|
line => $self->{line_prev}, |
3660 |
|
column => $self->{column_prev} - 1); |
3661 |
|
## Reconsume. |
3662 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3663 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded. |
3664 |
|
redo A; |
3665 |
|
} elsif ($self->{state} == MD_E_STATE) { |
3666 |
|
if ($self->{nc} == 0x004E or # N |
3667 |
|
$self->{nc} == 0x006E) { # n |
3668 |
|
$self->{state} = MD_ENTITY_STATE; |
3669 |
|
$self->{kwd} .= chr $self->{nc}; |
3670 |
|
!!!next-input-character; |
3671 |
|
redo A; |
3672 |
|
} elsif ($self->{nc} == 0x004C or # L |
3673 |
|
$self->{nc} == 0x006C) { # l |
3674 |
|
## XML5: <!ELEMENT> not supported. |
3675 |
|
$self->{state} = MD_ELEMENT_STATE; |
3676 |
|
$self->{kwd} .= chr $self->{nc}; |
3677 |
|
!!!next-input-character; |
3678 |
|
redo A; |
3679 |
|
} else { |
3680 |
|
## XML5: No parse error. |
3681 |
|
!!!parse-error (type => 'bogus comment', |
3682 |
|
line => $self->{line_prev}, |
3683 |
|
column => $self->{column_prev} - 2 |
3684 |
|
+ 1 * ($self->{nc} == -1)); |
3685 |
|
## Reconsume. |
3686 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3687 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded |
3688 |
|
redo A; |
3689 |
|
} |
3690 |
|
} elsif ($self->{state} == MD_ENTITY_STATE) { |
3691 |
|
if ($self->{nc} == [ |
3692 |
|
undef, |
3693 |
|
undef, |
3694 |
|
0x0054, # T |
3695 |
|
0x0049, # I |
3696 |
|
0x0054, # T |
3697 |
|
]->[length $self->{kwd}] or |
3698 |
|
$self->{nc} == [ |
3699 |
|
undef, |
3700 |
|
undef, |
3701 |
|
0x0074, # t |
3702 |
|
0x0069, # i |
3703 |
|
0x0074, # t |
3704 |
|
]->[length $self->{kwd}]) { |
3705 |
|
## Stay in the state. |
3706 |
|
$self->{kwd} .= chr $self->{nc}; |
3707 |
|
!!!next-input-character; |
3708 |
|
redo A; |
3709 |
|
} elsif ((length $self->{kwd}) == 5 and |
3710 |
|
($self->{nc} == 0x0059 or # Y |
3711 |
|
$self->{nc} == 0x0079)) { # y |
3712 |
|
if ($self->{kwd} ne 'ENTIT' or $self->{nc} == 0x0079) { |
3713 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
3714 |
|
text => 'ENTITY', |
3715 |
|
line => $self->{line_prev}, |
3716 |
|
column => $self->{column_prev} - 4); |
3717 |
|
} |
3718 |
|
$self->{ct} = {type => GENERAL_ENTITY_TOKEN, name => '', |
3719 |
|
line => $self->{line_prev}, |
3720 |
|
column => $self->{column_prev} - 6}; |
3721 |
|
$self->{state} = DOCTYPE_MD_STATE; |
3722 |
|
!!!next-input-character; |
3723 |
|
redo A; |
3724 |
|
} else { |
3725 |
|
!!!parse-error (type => 'bogus comment', |
3726 |
|
line => $self->{line_prev}, |
3727 |
|
column => $self->{column_prev} - 1 |
3728 |
|
- (length $self->{kwd}) |
3729 |
|
+ 1 * ($self->{nc} == -1)); |
3730 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3731 |
|
## Reconsume. |
3732 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded |
3733 |
|
redo A; |
3734 |
|
} |
3735 |
|
} elsif ($self->{state} == MD_ELEMENT_STATE) { |
3736 |
|
if ($self->{nc} == [ |
3737 |
|
undef, |
3738 |
|
undef, |
3739 |
|
0x0045, # E |
3740 |
|
0x004D, # M |
3741 |
|
0x0045, # E |
3742 |
|
0x004E, # N |
3743 |
|
]->[length $self->{kwd}] or |
3744 |
|
$self->{nc} == [ |
3745 |
|
undef, |
3746 |
|
undef, |
3747 |
|
0x0065, # e |
3748 |
|
0x006D, # m |
3749 |
|
0x0065, # e |
3750 |
|
0x006E, # n |
3751 |
|
]->[length $self->{kwd}]) { |
3752 |
|
## Stay in the state. |
3753 |
|
$self->{kwd} .= chr $self->{nc}; |
3754 |
|
!!!next-input-character; |
3755 |
|
redo A; |
3756 |
|
} elsif ((length $self->{kwd}) == 6 and |
3757 |
|
($self->{nc} == 0x0054 or # T |
3758 |
|
$self->{nc} == 0x0074)) { # t |
3759 |
|
if ($self->{kwd} ne 'ELEMEN' or $self->{nc} == 0x0074) { |
3760 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
3761 |
|
text => 'ELEMENT', |
3762 |
|
line => $self->{line_prev}, |
3763 |
|
column => $self->{column_prev} - 5); |
3764 |
|
} |
3765 |
|
$self->{ct} = {type => ELEMENT_TOKEN, name => '', |
3766 |
|
line => $self->{line_prev}, |
3767 |
|
column => $self->{column_prev} - 6}; |
3768 |
|
$self->{state} = DOCTYPE_MD_STATE; |
3769 |
|
!!!next-input-character; |
3770 |
|
redo A; |
3771 |
|
} else { |
3772 |
|
!!!parse-error (type => 'bogus comment', |
3773 |
|
line => $self->{line_prev}, |
3774 |
|
column => $self->{column_prev} - 1 |
3775 |
|
- (length $self->{kwd}) |
3776 |
|
+ 1 * ($self->{nc} == -1)); |
3777 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3778 |
|
## Reconsume. |
3779 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded |
3780 |
|
redo A; |
3781 |
|
} |
3782 |
|
} elsif ($self->{state} == MD_ATTLIST_STATE) { |
3783 |
|
if ($self->{nc} == [ |
3784 |
|
undef, |
3785 |
|
0x0054, # T |
3786 |
|
0x0054, # T |
3787 |
|
0x004C, # L |
3788 |
|
0x0049, # I |
3789 |
|
0x0053, # S |
3790 |
|
]->[length $self->{kwd}] or |
3791 |
|
$self->{nc} == [ |
3792 |
|
undef, |
3793 |
|
0x0074, # t |
3794 |
|
0x0074, # t |
3795 |
|
0x006C, # l |
3796 |
|
0x0069, # i |
3797 |
|
0x0073, # s |
3798 |
|
]->[length $self->{kwd}]) { |
3799 |
|
## Stay in the state. |
3800 |
|
$self->{kwd} .= chr $self->{nc}; |
3801 |
|
!!!next-input-character; |
3802 |
|
redo A; |
3803 |
|
} elsif ((length $self->{kwd}) == 6 and |
3804 |
|
($self->{nc} == 0x0054 or # T |
3805 |
|
$self->{nc} == 0x0074)) { # t |
3806 |
|
if ($self->{kwd} ne 'ATTLIS' or $self->{nc} == 0x0074) { |
3807 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
3808 |
|
text => 'ATTLIST', |
3809 |
|
line => $self->{line_prev}, |
3810 |
|
column => $self->{column_prev} - 5); |
3811 |
|
} |
3812 |
|
$self->{ct} = {type => ATTLIST_TOKEN, name => '', |
3813 |
|
attrdefs => [], |
3814 |
|
line => $self->{line_prev}, |
3815 |
|
column => $self->{column_prev} - 6}; |
3816 |
|
$self->{state} = DOCTYPE_MD_STATE; |
3817 |
|
!!!next-input-character; |
3818 |
|
redo A; |
3819 |
|
} else { |
3820 |
|
!!!parse-error (type => 'bogus comment', |
3821 |
|
line => $self->{line_prev}, |
3822 |
|
column => $self->{column_prev} - 1 |
3823 |
|
- (length $self->{kwd}) |
3824 |
|
+ 1 * ($self->{nc} == -1)); |
3825 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3826 |
|
## Reconsume. |
3827 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded |
3828 |
|
redo A; |
3829 |
|
} |
3830 |
|
} elsif ($self->{state} == MD_NOTATION_STATE) { |
3831 |
|
if ($self->{nc} == [ |
3832 |
|
undef, |
3833 |
|
0x004F, # O |
3834 |
|
0x0054, # T |
3835 |
|
0x0041, # A |
3836 |
|
0x0054, # T |
3837 |
|
0x0049, # I |
3838 |
|
0x004F, # O |
3839 |
|
]->[length $self->{kwd}] or |
3840 |
|
$self->{nc} == [ |
3841 |
|
undef, |
3842 |
|
0x006F, # o |
3843 |
|
0x0074, # t |
3844 |
|
0x0061, # a |
3845 |
|
0x0074, # t |
3846 |
|
0x0069, # i |
3847 |
|
0x006F, # o |
3848 |
|
]->[length $self->{kwd}]) { |
3849 |
|
## Stay in the state. |
3850 |
|
$self->{kwd} .= chr $self->{nc}; |
3851 |
|
!!!next-input-character; |
3852 |
|
redo A; |
3853 |
|
} elsif ((length $self->{kwd}) == 7 and |
3854 |
|
($self->{nc} == 0x004E or # N |
3855 |
|
$self->{nc} == 0x006E)) { # n |
3856 |
|
if ($self->{kwd} ne 'NOTATIO' or $self->{nc} == 0x006E) { |
3857 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
3858 |
|
text => 'NOTATION', |
3859 |
|
line => $self->{line_prev}, |
3860 |
|
column => $self->{column_prev} - 6); |
3861 |
|
} |
3862 |
|
$self->{ct} = {type => NOTATION_TOKEN, name => '', |
3863 |
|
line => $self->{line_prev}, |
3864 |
|
column => $self->{column_prev} - 6}; |
3865 |
|
$self->{state} = DOCTYPE_MD_STATE; |
3866 |
|
!!!next-input-character; |
3867 |
|
redo A; |
3868 |
|
} else { |
3869 |
|
!!!parse-error (type => 'bogus comment', |
3870 |
|
line => $self->{line_prev}, |
3871 |
|
column => $self->{column_prev} - 1 |
3872 |
|
- (length $self->{kwd}) |
3873 |
|
+ 1 * ($self->{nc} == -1)); |
3874 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3875 |
|
## Reconsume. |
3876 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded |
3877 |
|
redo A; |
3878 |
|
} |
3879 |
|
} elsif ($self->{state} == DOCTYPE_MD_STATE) { |
3880 |
|
## XML5: "DOCTYPE ENTITY state", "DOCTYPE ATTLIST state", and |
3881 |
|
## "DOCTYPE NOTATION state". |
3882 |
|
|
3883 |
|
if ($is_space->{$self->{nc}}) { |
3884 |
|
## XML5: [NOTATION] Switch to the "DOCTYPE NOTATION identifier state". |
3885 |
|
$self->{state} = BEFORE_MD_NAME_STATE; |
3886 |
|
!!!next-input-character; |
3887 |
|
redo A; |
3888 |
|
} elsif ($self->{ct}->{type} == GENERAL_ENTITY_TOKEN and |
3889 |
|
$self->{nc} == 0x0025) { # % |
3890 |
|
## XML5: Switch to the "DOCTYPE bogus comment state". |
3891 |
|
!!!parse-error (type => 'no space before md name'); ## TODO: type |
3892 |
|
$self->{state} = DOCTYPE_ENTITY_PARAMETER_BEFORE_STATE; |
3893 |
|
!!!next-input-character; |
3894 |
|
redo A; |
3895 |
|
} elsif ($self->{nc} == -1) { |
3896 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
3897 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
3898 |
|
## Reconsume. |
3899 |
|
redo A; |
3900 |
|
} elsif ($self->{nc} == 0x003E) { # > |
3901 |
|
## XML5: Switch to the "DOCTYPE bogus comment state". |
3902 |
|
!!!parse-error (type => 'no md name'); ## TODO: type |
3903 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
3904 |
|
!!!next-input-character; |
3905 |
|
redo A; |
3906 |
|
} else { |
3907 |
|
## XML5: Switch to the "DOCTYPE bogus comment state". |
3908 |
|
!!!parse-error (type => 'no space before md name'); ## TODO: type |
3909 |
|
$self->{state} = BEFORE_MD_NAME_STATE; |
3910 |
|
redo A; |
3911 |
|
} |
3912 |
|
} elsif ($self->{state} == BEFORE_MD_NAME_STATE) { |
3913 |
|
## XML5: "DOCTYPE ENTITY parameter state", "DOCTYPE ENTITY type |
3914 |
|
## before state", "DOCTYPE ATTLIST name before state". |
3915 |
|
|
3916 |
|
if ($is_space->{$self->{nc}}) { |
3917 |
|
## Stay in the state. |
3918 |
|
!!!next-input-character; |
3919 |
|
redo A; |
3920 |
|
} elsif ($self->{ct}->{type} == GENERAL_ENTITY_TOKEN and |
3921 |
|
$self->{nc} == 0x0025) { # % |
3922 |
|
$self->{state} = DOCTYPE_ENTITY_PARAMETER_BEFORE_STATE; |
3923 |
|
!!!next-input-character; |
3924 |
|
redo A; |
3925 |
|
} elsif ($self->{nc} == 0x003E) { # > |
3926 |
|
## XML5: Same as "Anything else". |
3927 |
|
!!!parse-error (type => 'no md name'); ## TODO: type |
3928 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
3929 |
|
!!!next-input-character; |
3930 |
|
redo A; |
3931 |
|
} elsif ($self->{nc} == -1) { |
3932 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
3933 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
3934 |
|
## Reconsume. |
3935 |
|
redo A; |
3936 |
|
} else { |
3937 |
|
## XML5: [ATTLIST] Not defined yet. |
3938 |
|
$self->{ct}->{name} .= chr $self->{nc}; |
3939 |
|
$self->{state} = MD_NAME_STATE; |
3940 |
|
!!!next-input-character; |
3941 |
|
redo A; |
3942 |
|
} |
3943 |
|
} elsif ($self->{state} == DOCTYPE_ENTITY_PARAMETER_BEFORE_STATE) { |
3944 |
|
if ($is_space->{$self->{nc}}) { |
3945 |
|
## XML5: Switch to the "DOCTYPE ENTITY parameter state". |
3946 |
|
$self->{ct}->{type} = PARAMETER_ENTITY_TOKEN; |
3947 |
|
$self->{state} = BEFORE_MD_NAME_STATE; |
3948 |
|
!!!next-input-character; |
3949 |
|
redo A; |
3950 |
|
} elsif ($self->{nc} == 0x003E) { # > |
3951 |
|
## XML5: Same as "Anything else". |
3952 |
|
!!!parse-error (type => 'no md name'); ## TODO: type |
3953 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
3954 |
|
!!!next-input-character; |
3955 |
|
redo A; |
3956 |
|
} elsif ($self->{nc} == -1) { |
3957 |
|
!!!parse-error (type => 'unclosed md'); |
3958 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
3959 |
|
## Reconsume. |
3960 |
|
redo A; |
3961 |
|
} else { |
3962 |
|
## XML5: No parse error. |
3963 |
|
!!!parse-error (type => 'no space after ENTITY percent'); ## TODO: type |
3964 |
|
$self->{state} = BOGUS_COMMENT_STATE; |
3965 |
|
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded |
3966 |
|
## Reconsume. |
3967 |
|
redo A; |
3968 |
|
} |
3969 |
|
} elsif ($self->{state} == MD_NAME_STATE) { |
3970 |
|
## XML5: "DOCTYPE ENTITY name state" and "DOCTYPE ATTLIST name state". |
3971 |
|
|
3972 |
|
if ($is_space->{$self->{nc}}) { |
3973 |
|
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
3974 |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
3975 |
|
} elsif ($self->{ct}->{type} == ELEMENT_TOKEN) { |
3976 |
|
## TODO: ... |
3977 |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
3978 |
|
} else { # ENTITY/NOTATION |
3979 |
|
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
3980 |
|
} |
3981 |
|
!!!next-input-character; |
3982 |
|
redo A; |
3983 |
|
} elsif ($self->{nc} == 0x003E) { # > |
3984 |
|
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
3985 |
|
# |
3986 |
|
} else { |
3987 |
|
!!!parse-error (type => 'no md def'); ## TODO: type |
3988 |
|
} |
3989 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
3990 |
|
!!!next-input-character; |
3991 |
|
!!!emit ($self->{ct}); # ELEMENT/ENTITY/ATTLIST/NOTATION |
3992 |
|
redo A; |
3993 |
|
} elsif ($self->{nc} == -1) { |
3994 |
|
## XML5: [ATTLIST] No parse error. |
3995 |
|
!!!parse-error (type => 'unclosed md'); |
3996 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
3997 |
|
## Reconsume. |
3998 |
|
!!!emit ($self->{ct}); # ELEMENT/ENTITY/ATTLIST/NOTATION |
3999 |
|
redo A; |
4000 |
|
} else { |
4001 |
|
## XML5: [ATTLIST] Not defined yet. |
4002 |
|
$self->{ct}->{name} .= chr $self->{nc}; |
4003 |
|
## Stay in the state. |
4004 |
|
!!!next-input-character; |
4005 |
|
redo A; |
4006 |
|
} |
4007 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_NAME_AFTER_STATE) { |
4008 |
|
if ($is_space->{$self->{nc}}) { |
4009 |
|
## Stay in the state. |
4010 |
|
!!!next-input-character; |
4011 |
|
redo A; |
4012 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4013 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4014 |
|
!!!next-input-character; |
4015 |
|
!!!emit ($self->{ct}); # ATTLIST |
4016 |
|
redo A; |
4017 |
|
} elsif ($self->{nc} == -1) { |
4018 |
|
## XML5: No parse error. |
4019 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4020 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4021 |
|
!!!emit ($self->{ct}); |
4022 |
|
redo A; |
4023 |
|
} else { |
4024 |
|
## XML5: Not defined yet. |
4025 |
|
$self->{ca} = {name => chr ($self->{nc}), # attrdef |
4026 |
|
tokens => [], |
4027 |
|
line => $self->{line}, column => $self->{column}}; |
4028 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_NAME_STATE; |
4029 |
|
!!!next-input-character; |
4030 |
|
redo A; |
4031 |
|
} |
4032 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_NAME_STATE) { |
4033 |
|
if ($is_space->{$self->{nc}}) { |
4034 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_NAME_AFTER_STATE; |
4035 |
|
!!!next-input-character; |
4036 |
|
redo A; |
4037 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4038 |
|
## XML5: Same as "anything else". |
4039 |
|
!!!parse-error (type => 'no attr type'); ## TODO: type |
4040 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4041 |
|
!!!next-input-character; |
4042 |
|
!!!emit ($self->{ct}); # ATTLIST |
4043 |
|
redo A; |
4044 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4045 |
|
## XML5: Same as "anything else". |
4046 |
|
!!!parse-error (type => 'no space before paren'); ## TODO: type |
4047 |
|
$self->{state} = BEFORE_ALLOWED_TOKEN_STATE; |
4048 |
|
!!!next-input-character; |
4049 |
|
redo A; |
4050 |
|
} elsif ($self->{nc} == -1) { |
4051 |
|
## XML5: No parse error. |
4052 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4053 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4054 |
|
!!!next-input-character; |
4055 |
|
!!!emit ($self->{ct}); # ATTLIST |
4056 |
|
redo A; |
4057 |
|
} else { |
4058 |
|
## XML5: Not defined yet. |
4059 |
|
$self->{ca}->{name} .= chr $self->{nc}; |
4060 |
|
## Stay in the state. |
4061 |
|
!!!next-input-character; |
4062 |
|
redo A; |
4063 |
|
} |
4064 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_NAME_AFTER_STATE) { |
4065 |
|
if ($is_space->{$self->{nc}}) { |
4066 |
|
## Stay in the state. |
4067 |
|
!!!next-input-character; |
4068 |
|
redo A; |
4069 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4070 |
|
## XML5: Same as "anything else". |
4071 |
|
!!!parse-error (type => 'no attr type'); ## TODO: type |
4072 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4073 |
|
!!!next-input-character; |
4074 |
|
!!!emit ($self->{ct}); # ATTLIST |
4075 |
|
redo A; |
4076 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4077 |
|
## XML5: Same as "anything else". |
4078 |
|
$self->{state} = BEFORE_ALLOWED_TOKEN_STATE; |
4079 |
|
!!!next-input-character; |
4080 |
|
redo A; |
4081 |
|
} elsif ($self->{nc} == -1) { |
4082 |
|
## XML5: No parse error. |
4083 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4084 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4085 |
|
!!!next-input-character; |
4086 |
|
!!!emit ($self->{ct}); |
4087 |
|
redo A; |
4088 |
|
} else { |
4089 |
|
## XML5: Not defined yet. |
4090 |
|
$self->{ca}->{type} = chr $self->{nc}; |
4091 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_TYPE_STATE; |
4092 |
|
!!!next-input-character; |
4093 |
|
redo A; |
4094 |
|
} |
4095 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_TYPE_STATE) { |
4096 |
|
if ($is_space->{$self->{nc}}) { |
4097 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_TYPE_AFTER_STATE; |
4098 |
|
!!!next-input-character; |
4099 |
|
redo A; |
4100 |
|
} elsif ($self->{nc} == 0x0023) { # # |
4101 |
|
## XML5: Same as "anything else". |
4102 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4103 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_BEFORE_STATE; |
4104 |
|
!!!next-input-character; |
4105 |
|
redo A; |
4106 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4107 |
|
## XML5: Same as "anything else". |
4108 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4109 |
|
$self->{ca}->{value} = ''; |
4110 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4111 |
|
!!!next-input-character; |
4112 |
|
redo A; |
4113 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4114 |
|
## XML5: Same as "anything else". |
4115 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4116 |
|
$self->{ca}->{value} = ''; |
4117 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4118 |
|
!!!next-input-character; |
4119 |
|
redo A; |
4120 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4121 |
|
## XML5: Same as "anything else". |
4122 |
|
!!!parse-error (type => 'no attr default'); ## TODO: type |
4123 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4124 |
|
!!!next-input-character; |
4125 |
|
!!!emit ($self->{ct}); # ATTLIST |
4126 |
|
redo A; |
4127 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4128 |
|
## XML5: Same as "anything else". |
4129 |
|
!!!parse-error (type => 'no space before paren'); ## TODO: type |
4130 |
|
$self->{state} = BEFORE_ALLOWED_TOKEN_STATE; |
4131 |
|
!!!next-input-character; |
4132 |
|
redo A; |
4133 |
|
} elsif ($self->{nc} == -1) { |
4134 |
|
## XML5: No parse error. |
4135 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4136 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4137 |
|
!!!next-input-character; |
4138 |
|
!!!emit ($self->{ct}); |
4139 |
|
redo A; |
4140 |
|
} else { |
4141 |
|
## XML5: Not defined yet. |
4142 |
|
$self->{ca}->{type} .= chr $self->{nc}; |
4143 |
|
## Stay in the state. |
4144 |
|
!!!next-input-character; |
4145 |
|
redo A; |
4146 |
|
} |
4147 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_TYPE_AFTER_STATE) { |
4148 |
|
if ($is_space->{$self->{nc}}) { |
4149 |
|
## Stay in the state. |
4150 |
|
!!!next-input-character; |
4151 |
|
redo A; |
4152 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4153 |
|
## XML5: Same as "anything else". |
4154 |
|
$self->{state} = BEFORE_ALLOWED_TOKEN_STATE; |
4155 |
|
!!!next-input-character; |
4156 |
|
redo A; |
4157 |
|
} elsif ($self->{nc} == 0x0023) { # # |
4158 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_BEFORE_STATE; |
4159 |
|
!!!next-input-character; |
4160 |
|
redo A; |
4161 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4162 |
|
## XML5: Same as "anything else". |
4163 |
|
$self->{ca}->{value} = ''; |
4164 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4165 |
|
!!!next-input-character; |
4166 |
|
redo A; |
4167 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4168 |
|
## XML5: Same as "anything else". |
4169 |
|
$self->{ca}->{value} = ''; |
4170 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4171 |
|
!!!next-input-character; |
4172 |
|
redo A; |
4173 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4174 |
|
## XML5: Same as "anything else". |
4175 |
|
!!!parse-error (type => 'no attr default'); ## TODO: type |
4176 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4177 |
|
!!!next-input-character; |
4178 |
|
!!!emit ($self->{ct}); # ATTLIST |
4179 |
|
redo A; |
4180 |
|
} elsif ($self->{nc} == -1) { |
4181 |
|
## XML5: No parse error. |
4182 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4183 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4184 |
|
!!!next-input-character; |
4185 |
|
!!!emit ($self->{ct}); |
4186 |
|
redo A; |
4187 |
|
} else { |
4188 |
|
## XML5: Switch to the "DOCTYPE bogus comment state". |
4189 |
|
!!!parse-error (type => 'unquoted attr value'); ## TODO: type |
4190 |
|
$self->{ca}->{value} = ''; |
4191 |
|
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
4192 |
|
## Reconsume. |
4193 |
|
redo A; |
4194 |
|
} |
4195 |
|
} elsif ($self->{state} == BEFORE_ALLOWED_TOKEN_STATE) { |
4196 |
|
if ($is_space->{$self->{nc}}) { |
4197 |
|
## Stay in the state. |
4198 |
|
!!!next-input-character; |
4199 |
|
redo A; |
4200 |
|
} elsif ($self->{nc} == 0x007C) { # | |
4201 |
|
!!!parse-error (type => 'empty allowed token'); ## TODO: type |
4202 |
|
## Stay in the state. |
4203 |
|
!!!next-input-character; |
4204 |
|
redo A; |
4205 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
4206 |
|
!!!parse-error (type => 'empty allowed token'); ## TODO: type |
4207 |
|
$self->{state} = AFTER_ALLOWED_TOKENS_STATE; |
4208 |
|
!!!next-input-character; |
4209 |
|
redo A; |
4210 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4211 |
|
!!!parse-error (type => 'unclosed allowed tokens'); ## TODO: type |
4212 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4213 |
|
!!!next-input-character; |
4214 |
|
!!!emit ($self->{ct}); # ATTLIST |
4215 |
|
redo A; |
4216 |
|
} elsif ($self->{nc} == -1) { |
4217 |
|
## XML5: No parse error. |
4218 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4219 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4220 |
|
!!!next-input-character; |
4221 |
|
!!!emit ($self->{ct}); |
4222 |
|
redo A; |
4223 |
|
} else { |
4224 |
|
push @{$self->{ca}->{tokens}}, chr $self->{nc}; |
4225 |
|
$self->{state} = ALLOWED_TOKEN_STATE; |
4226 |
|
!!!next-input-character; |
4227 |
|
redo A; |
4228 |
|
} |
4229 |
|
} elsif ($self->{state} == ALLOWED_TOKEN_STATE) { |
4230 |
|
if ($is_space->{$self->{nc}}) { |
4231 |
|
$self->{state} = AFTER_ALLOWED_TOKEN_STATE; |
4232 |
|
!!!next-input-character; |
4233 |
|
redo A; |
4234 |
|
} elsif ($self->{nc} == 0x007C) { # | |
4235 |
|
$self->{state} = BEFORE_ALLOWED_TOKEN_STATE; |
4236 |
|
!!!next-input-character; |
4237 |
|
redo A; |
4238 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
4239 |
|
$self->{state} = AFTER_ALLOWED_TOKENS_STATE; |
4240 |
|
!!!next-input-character; |
4241 |
|
redo A; |
4242 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4243 |
|
!!!parse-error (type => 'unclosed allowed tokens'); ## TODO: type |
4244 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4245 |
|
!!!next-input-character; |
4246 |
|
!!!emit ($self->{ct}); # ATTLIST |
4247 |
|
redo A; |
4248 |
|
} elsif ($self->{nc} == -1) { |
4249 |
|
## XML5: No parse error. |
4250 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4251 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4252 |
|
!!!next-input-character; |
4253 |
|
!!!emit ($self->{ct}); |
4254 |
|
redo A; |
4255 |
|
} else { |
4256 |
|
$self->{ca}->{tokens}->[-1] .= chr $self->{nc}; |
4257 |
|
## Stay in the state. |
4258 |
|
!!!next-input-character; |
4259 |
|
redo A; |
4260 |
|
} |
4261 |
|
} elsif ($self->{state} == AFTER_ALLOWED_TOKEN_STATE) { |
4262 |
|
if ($is_space->{$self->{nc}}) { |
4263 |
|
## Stay in the state. |
4264 |
|
!!!next-input-character; |
4265 |
|
redo A; |
4266 |
|
} elsif ($self->{nc} == 0x007C) { # | |
4267 |
|
$self->{state} = BEFORE_ALLOWED_TOKEN_STATE; |
4268 |
|
!!!next-input-character; |
4269 |
|
redo A; |
4270 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
4271 |
|
$self->{state} = AFTER_ALLOWED_TOKENS_STATE; |
4272 |
|
!!!next-input-character; |
4273 |
|
redo A; |
4274 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4275 |
|
!!!parse-error (type => 'unclosed allowed tokens'); ## TODO: type |
4276 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4277 |
|
!!!next-input-character; |
4278 |
|
!!!emit ($self->{ct}); # ATTLIST |
4279 |
|
redo A; |
4280 |
|
} elsif ($self->{nc} == -1) { |
4281 |
|
## XML5: No parse error. |
4282 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4283 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4284 |
|
!!!next-input-character; |
4285 |
|
!!!emit ($self->{ct}); |
4286 |
|
redo A; |
4287 |
|
} else { |
4288 |
|
!!!parse-error (type => 'space in allowed token', ## TODO: type |
4289 |
|
line => $self->{line_prev}, |
4290 |
|
column => $self->{column_prev}); |
4291 |
|
$self->{ca}->{tokens}->[-1] .= ' ' . chr $self->{nc}; |
4292 |
|
$self->{state} = ALLOWED_TOKEN_STATE; |
4293 |
|
!!!next-input-character; |
4294 |
|
redo A; |
4295 |
|
} |
4296 |
|
} elsif ($self->{state} == AFTER_ALLOWED_TOKENS_STATE) { |
4297 |
|
if ($is_space->{$self->{nc}}) { |
4298 |
|
$self->{state} = BEFORE_ATTR_DEFAULT_STATE; |
4299 |
|
!!!next-input-character; |
4300 |
|
redo A; |
4301 |
|
} elsif ($self->{nc} == 0x0023) { # # |
4302 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4303 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_BEFORE_STATE; |
4304 |
|
!!!next-input-character; |
4305 |
|
redo A; |
4306 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4307 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4308 |
|
$self->{ca}->{value} = ''; |
4309 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4310 |
|
!!!next-input-character; |
4311 |
|
redo A; |
4312 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4313 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4314 |
|
$self->{ca}->{value} = ''; |
4315 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4316 |
|
!!!next-input-character; |
4317 |
|
redo A; |
4318 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4319 |
|
!!!parse-error (type => 'no attr default'); ## TODO: type |
4320 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4321 |
|
!!!next-input-character; |
4322 |
|
!!!emit ($self->{ct}); # ATTLIST |
4323 |
|
redo A; |
4324 |
|
} elsif ($self->{nc} == -1) { |
4325 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4326 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4327 |
|
!!!next-input-character; |
4328 |
|
!!!emit ($self->{ct}); |
4329 |
|
redo A; |
4330 |
|
} else { |
4331 |
|
!!!parse-error (type => 'unquoted attr value'); ## TODO: type |
4332 |
|
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
4333 |
|
## Reconsume. |
4334 |
|
redo A; |
4335 |
|
} |
4336 |
|
} elsif ($self->{state} == BEFORE_ATTR_DEFAULT_STATE) { |
4337 |
|
if ($is_space->{$self->{nc}}) { |
4338 |
|
## Stay in the state. |
4339 |
|
!!!next-input-character; |
4340 |
|
redo A; |
4341 |
|
} elsif ($self->{nc} == 0x0023) { # # |
4342 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_BEFORE_STATE; |
4343 |
|
!!!next-input-character; |
4344 |
|
redo A; |
4345 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4346 |
|
$self->{ca}->{value} = ''; |
4347 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4348 |
|
!!!next-input-character; |
4349 |
|
redo A; |
4350 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4351 |
|
$self->{ca}->{value} = ''; |
4352 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4353 |
|
!!!next-input-character; |
4354 |
|
redo A; |
4355 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4356 |
|
!!!parse-error (type => 'no attr default'); ## TODO: type |
4357 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4358 |
|
!!!next-input-character; |
4359 |
|
!!!emit ($self->{ct}); # ATTLIST |
4360 |
|
redo A; |
4361 |
|
} elsif ($self->{nc} == -1) { |
4362 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4363 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4364 |
|
!!!next-input-character; |
4365 |
|
!!!emit ($self->{ct}); |
4366 |
|
redo A; |
4367 |
|
} else { |
4368 |
|
!!!parse-error (type => 'unquoted attr value'); ## TODO: type |
4369 |
|
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
4370 |
|
## Reconsume. |
4371 |
|
redo A; |
4372 |
|
} |
4373 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_BEFORE_STATE) { |
4374 |
|
if ($is_space->{$self->{nc}}) { |
4375 |
|
## XML5: No parse error. |
4376 |
|
!!!parse-error (type => 'no default type'); ## TODO: type |
4377 |
|
$self->{state} = BOGUS_MD_STATE; |
4378 |
|
## Reconsume. |
4379 |
|
redo A; |
4380 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4381 |
|
## XML5: Same as "anything else". |
4382 |
|
$self->{ca}->{value} = ''; |
4383 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4384 |
|
!!!next-input-character; |
4385 |
|
redo A; |
4386 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4387 |
|
## XML5: Same as "anything else". |
4388 |
|
$self->{ca}->{value} = ''; |
4389 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4390 |
|
!!!next-input-character; |
4391 |
|
redo A; |
4392 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4393 |
|
## XML5: Same as "anything else". |
4394 |
|
!!!parse-error (type => 'no attr default'); ## TODO: type |
4395 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4396 |
|
!!!next-input-character; |
4397 |
|
!!!emit ($self->{ct}); # ATTLIST |
4398 |
|
redo A; |
4399 |
|
} elsif ($self->{nc} == -1) { |
4400 |
|
## XML5: No parse error. |
4401 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4402 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4403 |
|
!!!next-input-character; |
4404 |
|
!!!emit ($self->{ct}); |
4405 |
|
redo A; |
4406 |
|
} else { |
4407 |
|
$self->{ca}->{default} = chr $self->{nc}; |
4408 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_STATE; |
4409 |
|
!!!next-input-character; |
4410 |
|
redo A; |
4411 |
|
} |
4412 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_STATE) { |
4413 |
|
if ($is_space->{$self->{nc}}) { |
4414 |
|
$self->{state} = DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_AFTER_STATE; |
4415 |
|
!!!next-input-character; |
4416 |
|
redo A; |
4417 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4418 |
|
## XML5: Same as "anything else". |
4419 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4420 |
|
$self->{ca}->{value} = ''; |
4421 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4422 |
|
!!!next-input-character; |
4423 |
|
redo A; |
4424 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4425 |
|
## XML5: Same as "anything else". |
4426 |
|
!!!parse-error (type => 'no space before default value'); ## TODO: type |
4427 |
|
$self->{ca}->{value} = ''; |
4428 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4429 |
|
!!!next-input-character; |
4430 |
|
redo A; |
4431 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4432 |
|
## XML5: Same as "anything else". |
4433 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
4434 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4435 |
|
!!!next-input-character; |
4436 |
|
!!!emit ($self->{ct}); # ATTLIST |
4437 |
|
redo A; |
4438 |
|
} elsif ($self->{nc} == -1) { |
4439 |
|
## XML5: No parse error. |
4440 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4441 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
4442 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4443 |
|
!!!next-input-character; |
4444 |
|
!!!emit ($self->{ct}); |
4445 |
|
redo A; |
4446 |
|
} else { |
4447 |
|
$self->{ca}->{default} .= chr $self->{nc}; |
4448 |
|
## Stay in the state. |
4449 |
|
!!!next-input-character; |
4450 |
|
redo A; |
4451 |
|
} |
4452 |
|
} elsif ($self->{state} == DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_AFTER_STATE) { |
4453 |
|
if ($is_space->{$self->{nc}}) { |
4454 |
|
## Stay in the state. |
4455 |
|
!!!next-input-character; |
4456 |
|
redo A; |
4457 |
|
} elsif ($self->{nc} == 0x0022) { # " |
4458 |
|
$self->{ca}->{value} = ''; |
4459 |
|
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
4460 |
|
!!!next-input-character; |
4461 |
|
redo A; |
4462 |
|
} elsif ($self->{nc} == 0x0027) { # ' |
4463 |
|
$self->{ca}->{value} = ''; |
4464 |
|
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
4465 |
|
!!!next-input-character; |
4466 |
|
redo A; |
4467 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4468 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
4469 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4470 |
|
!!!next-input-character; |
4471 |
|
!!!emit ($self->{ct}); # ATTLIST |
4472 |
|
redo A; |
4473 |
|
} elsif ($self->{nc} == -1) { |
4474 |
|
## XML5: No parse error. |
4475 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4476 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
4477 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; ## XML5: "Data state". |
4478 |
|
!!!next-input-character; |
4479 |
|
!!!emit ($self->{ct}); |
4480 |
|
redo A; |
4481 |
|
} else { |
4482 |
|
## XML5: Not defined yet. |
4483 |
|
if ($self->{ca}->{default} eq 'FIXED') { |
4484 |
|
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
4485 |
|
} else { |
4486 |
|
push @{$self->{ct}->{attrdefs}}, $self->{ca}; |
4487 |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
4488 |
|
} |
4489 |
|
## Reconsume. |
4490 |
|
redo A; |
4491 |
|
} |
4492 |
|
} elsif ($self->{state} == AFTER_ATTLIST_ATTR_VALUE_QUOTED_STATE) { |
4493 |
|
if ($is_space->{$self->{nc}} or |
4494 |
|
$self->{nc} == -1 or |
4495 |
|
$self->{nc} == 0x003E) { # > |
4496 |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
4497 |
|
## Reconsume. |
4498 |
|
redo A; |
4499 |
|
} else { |
4500 |
|
!!!parse-error (type => 'no space before attr name'); ## TODO: type |
4501 |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
4502 |
|
## Reconsume. |
4503 |
|
redo A; |
4504 |
|
} |
4505 |
|
|
4506 |
|
} elsif ($self->{state} == BOGUS_MD_STATE) { |
4507 |
|
if ($self->{nc} == 0x003E) { # > |
4508 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4509 |
|
!!!next-input-character; |
4510 |
|
!!!emit ($self->{ct}); # ATTLIST/ENTITY/NOTATION |
4511 |
|
redo A; |
4512 |
|
} elsif ($self->{nc} == -1) { |
4513 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4514 |
|
## Reconsume. |
4515 |
|
!!!emit ($self->{ct}); # ATTLIST/ENTITY/NOTATION |
4516 |
|
redo A; |
4517 |
|
} else { |
4518 |
|
## Stay in the state. |
4519 |
|
!!!next-input-character; |
4520 |
redo A; |
redo A; |
4521 |
} |
} |
4522 |
} else { |
} else { |
4529 |
|
|
4530 |
1; |
1; |
4531 |
## $Date$ |
## $Date$ |
4532 |
|
|