177 |
sub DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_STATE () { 82 } |
sub DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_STATE () { 82 } |
178 |
sub DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_AFTER_STATE () { 83 } |
sub DOCTYPE_ATTLIST_ATTRIBUTE_DECLARATION_AFTER_STATE () { 83 } |
179 |
sub AFTER_ATTLIST_ATTR_VALUE_QUOTED_STATE () { 84 } |
sub AFTER_ATTLIST_ATTR_VALUE_QUOTED_STATE () { 84 } |
180 |
sub BOGUS_MD_STATE () { 85 } |
sub BEFORE_NDATA_STATE () { 85 } |
181 |
|
sub NDATA_STATE () { 86 } |
182 |
|
sub AFTER_NDATA_STATE () { 87 } |
183 |
|
sub BEFORE_NOTATION_NAME_STATE () { 88 } |
184 |
|
sub NOTATION_NAME_STATE () { 89 } |
185 |
|
sub DOCTYPE_ENTITY_VALUE_DOUBLE_QUOTED_STATE () { 90 } |
186 |
|
sub DOCTYPE_ENTITY_VALUE_SINGLE_QUOTED_STATE () { 91 } |
187 |
|
sub ENTITY_VALUE_ENTITY_STATE () { 92 } |
188 |
|
sub AFTER_ELEMENT_NAME_STATE () { 93 } |
189 |
|
sub BEFORE_ELEMENT_CONTENT_STATE () { 94 } |
190 |
|
sub CONTENT_KEYWORD_STATE () { 95 } |
191 |
|
sub AFTER_CM_GROUP_OPEN_STATE () { 96 } |
192 |
|
sub CM_ELEMENT_NAME_STATE () { 97 } |
193 |
|
sub AFTER_CM_ELEMENT_NAME_STATE () { 98 } |
194 |
|
sub AFTER_CM_GROUP_CLOSE_STATE () { 99 } |
195 |
|
sub AFTER_MD_DEF_STATE () { 100 } |
196 |
|
sub BOGUS_MD_STATE () { 101 } |
197 |
|
|
198 |
## Tree constructor state constants (see Whatpm::HTML for the full |
## Tree constructor state constants (see Whatpm::HTML for the full |
199 |
## list and descriptions) |
## list and descriptions) |
2272 |
$self->{kwd} = chr $self->{nc}; |
$self->{kwd} = chr $self->{nc}; |
2273 |
!!!next-input-character; |
!!!next-input-character; |
2274 |
redo A; |
redo A; |
2275 |
## TODO: " and ' for ENTITY |
} elsif ($self->{nc} == 0x0022 and # " |
2276 |
|
($self->{ct}->{type} == GENERAL_ENTITY_TOKEN or |
2277 |
|
$self->{ct}->{type} == PARAMETER_ENTITY_TOKEN)) { |
2278 |
|
!!!cp (167.21); |
2279 |
|
$self->{state} = DOCTYPE_ENTITY_VALUE_DOUBLE_QUOTED_STATE; |
2280 |
|
$self->{ct}->{value} = ''; # ENTITY |
2281 |
|
!!!next-input-character; |
2282 |
|
redo A; |
2283 |
|
} elsif ($self->{nc} == 0x0027 and # ' |
2284 |
|
($self->{ct}->{type} == GENERAL_ENTITY_TOKEN or |
2285 |
|
$self->{ct}->{type} == PARAMETER_ENTITY_TOKEN)) { |
2286 |
|
!!!cp (167.22); |
2287 |
|
$self->{state} = DOCTYPE_ENTITY_VALUE_SINGLE_QUOTED_STATE; |
2288 |
|
$self->{ct}->{value} = ''; # ENTITY |
2289 |
|
!!!next-input-character; |
2290 |
|
redo A; |
2291 |
} elsif ($self->{is_xml} and |
} elsif ($self->{is_xml} and |
2292 |
$self->{ct}->{type} == DOCTYPE_TOKEN and |
$self->{ct}->{type} == DOCTYPE_TOKEN and |
2293 |
$self->{nc} == 0x005B) { # [ |
$self->{nc} == 0x005B) { # [ |
2843 |
} |
} |
2844 |
} elsif ($self->{state} == AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE) { |
} elsif ($self->{state} == AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE) { |
2845 |
if ($is_space->{$self->{nc}}) { |
if ($is_space->{$self->{nc}}) { |
2846 |
!!!cp (215); |
if ($self->{ct}->{type} == GENERAL_ENTITY_TOKEN) { |
2847 |
## Stay in the state |
!!!cp (215.1); |
2848 |
|
$self->{state} = BEFORE_NDATA_STATE; |
2849 |
|
} else { |
2850 |
|
!!!cp (215); |
2851 |
|
## Stay in the state |
2852 |
|
} |
2853 |
!!!next-input-character; |
!!!next-input-character; |
2854 |
redo A; |
redo A; |
2855 |
} elsif ($self->{nc} == 0x003E) { # > |
} elsif ($self->{nc} == 0x003E) { # > |
2865 |
!!!next-input-character; |
!!!next-input-character; |
2866 |
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
!!!emit ($self->{ct}); # DOCTYPE/ENTITY/NOTATION |
2867 |
redo A; |
redo A; |
2868 |
## TODO: "NDATA" |
} elsif ($self->{ct}->{type} == GENERAL_ENTITY_TOKEN and |
2869 |
|
($self->{nc} == 0x004E or # N |
2870 |
|
$self->{nc} == 0x006E)) { # n |
2871 |
|
!!!cp (216.2); |
2872 |
|
!!!parse-error (type => 'no space before NDATA'); ## TODO: type |
2873 |
|
$self->{state} = NDATA_STATE; |
2874 |
|
$self->{kwd} = chr $self->{nc}; |
2875 |
|
!!!next-input-character; |
2876 |
|
redo A; |
2877 |
} elsif ($self->{nc} == -1) { |
} elsif ($self->{nc} == -1) { |
2878 |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
if ($self->{ct}->{type} == DOCTYPE_TOKEN) { |
2879 |
!!!cp (217); |
!!!cp (217); |
2915 |
!!!next-input-character; |
!!!next-input-character; |
2916 |
redo A; |
redo A; |
2917 |
} |
} |
2918 |
|
} elsif ($self->{state} == BEFORE_NDATA_STATE) { |
2919 |
|
if ($is_space->{$self->{nc}}) { |
2920 |
|
!!!cp (218.3); |
2921 |
|
## Stay in the state. |
2922 |
|
!!!next-input-character; |
2923 |
|
redo A; |
2924 |
|
} elsif ($self->{nc} == 0x003E) { # > |
2925 |
|
!!!cp (218.4); |
2926 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2927 |
|
!!!next-input-character; |
2928 |
|
!!!emit ($self->{ct}); # ENTITY |
2929 |
|
redo A; |
2930 |
|
} elsif ($self->{nc} == 0x004E or # N |
2931 |
|
$self->{nc} == 0x006E) { # n |
2932 |
|
!!!cp (218.5); |
2933 |
|
$self->{state} = NDATA_STATE; |
2934 |
|
$self->{kwd} = chr $self->{nc}; |
2935 |
|
!!!next-input-character; |
2936 |
|
redo A; |
2937 |
|
} elsif ($self->{nc} == -1) { |
2938 |
|
!!!cp (218.6); |
2939 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
2940 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
2941 |
|
## reconsume |
2942 |
|
!!!emit ($self->{ct}); # ENTITY |
2943 |
|
redo A; |
2944 |
|
} else { |
2945 |
|
!!!cp (218.7); |
2946 |
|
!!!parse-error (type => 'string after SYSTEM literal'); |
2947 |
|
$self->{state} = BOGUS_MD_STATE; |
2948 |
|
!!!next-input-character; |
2949 |
|
redo A; |
2950 |
|
} |
2951 |
} elsif ($self->{state} == BOGUS_DOCTYPE_STATE) { |
} elsif ($self->{state} == BOGUS_DOCTYPE_STATE) { |
2952 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
2953 |
!!!cp (219); |
!!!cp (219); |
3078 |
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
3079 |
$self->{entity_add} => 1, |
$self->{entity_add} => 1, |
3080 |
}->{$self->{nc}}) { |
}->{$self->{nc}}) { |
3081 |
!!!cp (1001); |
if ($self->{is_xml}) { |
3082 |
|
!!!cp (1001.1); |
3083 |
|
!!!parse-error (type => 'bare ero', |
3084 |
|
line => $self->{line_prev}, |
3085 |
|
column => $self->{column_prev} |
3086 |
|
+ ($self->{nc} == -1 ? 1 : 0)); |
3087 |
|
} else { |
3088 |
|
!!!cp (1001); |
3089 |
|
## No error |
3090 |
|
} |
3091 |
## Don't consume |
## Don't consume |
|
## No error |
|
3092 |
## Return nothing. |
## Return nothing. |
3093 |
# |
# |
3094 |
} elsif ($self->{nc} == 0x0023) { # # |
} elsif ($self->{nc} == 0x0023) { # # |
3097 |
$self->{kwd} = '#'; |
$self->{kwd} = '#'; |
3098 |
!!!next-input-character; |
!!!next-input-character; |
3099 |
redo A; |
redo A; |
3100 |
} elsif ((0x0041 <= $self->{nc} and |
} elsif ($self->{is_xml} or |
3101 |
|
(0x0041 <= $self->{nc} and |
3102 |
$self->{nc} <= 0x005A) or # A..Z |
$self->{nc} <= 0x005A) or # A..Z |
3103 |
(0x0061 <= $self->{nc} and |
(0x0061 <= $self->{nc} and |
3104 |
$self->{nc} <= 0x007A)) { # a..z |
$self->{nc} <= 0x007A)) { # a..z |
3142 |
redo A; |
redo A; |
3143 |
} |
} |
3144 |
} elsif ($self->{state} == ENTITY_HASH_STATE) { |
} elsif ($self->{state} == ENTITY_HASH_STATE) { |
3145 |
if ($self->{nc} == 0x0078 or # x |
if ($self->{nc} == 0x0078) { # x |
|
$self->{nc} == 0x0058) { # X |
|
3146 |
!!!cp (995); |
!!!cp (995); |
3147 |
$self->{state} = HEXREF_X_STATE; |
$self->{state} = HEXREF_X_STATE; |
3148 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3149 |
!!!next-input-character; |
!!!next-input-character; |
3150 |
redo A; |
redo A; |
3151 |
|
} elsif ($self->{nc} == 0x0058) { # X |
3152 |
|
!!!cp (995.1); |
3153 |
|
if ($self->{is_xml}) { |
3154 |
|
!!!parse-error (type => 'uppercase hcro'); ## TODO: type |
3155 |
|
} |
3156 |
|
$self->{state} = HEXREF_X_STATE; |
3157 |
|
$self->{kwd} .= chr $self->{nc}; |
3158 |
|
!!!next-input-character; |
3159 |
|
redo A; |
3160 |
} elsif (0x0030 <= $self->{nc} and |
} elsif (0x0030 <= $self->{nc} and |
3161 |
$self->{nc} <= 0x0039) { # 0..9 |
$self->{nc} <= 0x0039) { # 0..9 |
3162 |
!!!cp (994); |
!!!cp (994); |
3364 |
redo A; |
redo A; |
3365 |
} |
} |
3366 |
} elsif ($self->{state} == ENTITY_NAME_STATE) { |
} elsif ($self->{state} == ENTITY_NAME_STATE) { |
3367 |
if (length $self->{kwd} < 30 and |
if ((0x0041 <= $self->{nc} and # a |
3368 |
## NOTE: Some number greater than the maximum length of entity name |
$self->{nc} <= 0x005A) or # x |
3369 |
((0x0041 <= $self->{nc} and # a |
(0x0061 <= $self->{nc} and # a |
3370 |
$self->{nc} <= 0x005A) or # x |
$self->{nc} <= 0x007A) or # z |
3371 |
(0x0061 <= $self->{nc} and # a |
(0x0030 <= $self->{nc} and # 0 |
3372 |
$self->{nc} <= 0x007A) or # z |
$self->{nc} <= 0x0039) or # 9 |
3373 |
(0x0030 <= $self->{nc} and # 0 |
$self->{nc} == 0x003B or # ; |
3374 |
$self->{nc} <= 0x0039) or # 9 |
($self->{is_xml} and |
3375 |
$self->{nc} == 0x003B)) { # ; |
not ($is_space->{$self->{nc}} or |
3376 |
|
{ |
3377 |
|
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
3378 |
|
$self->{entity_add} => 1, |
3379 |
|
}->{$self->{nc}}))) { |
3380 |
our $EntityChar; |
our $EntityChar; |
3381 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3382 |
if (defined $EntityChar->{$self->{kwd}}) { |
if (defined $EntityChar->{$self->{kwd}} or |
3383 |
|
$self->{ge}->{$self->{kwd}}) { |
3384 |
if ($self->{nc} == 0x003B) { # ; |
if ($self->{nc} == 0x003B) { # ; |
3385 |
!!!cp (1020); |
if (defined $self->{ge}->{$self->{kwd}}) { |
3386 |
$self->{entity__value} = $EntityChar->{$self->{kwd}}; |
if ($self->{ge}->{$self->{kwd}}->{only_text}) { |
3387 |
|
!!!cp (1020.1); |
3388 |
|
$self->{entity__value} = $self->{ge}->{$self->{kwd}}->{value}; |
3389 |
|
} else { |
3390 |
|
if (defined $self->{ge}->{$self->{kwd}}->{notation}) { |
3391 |
|
!!!cp (1020.2); |
3392 |
|
!!!parse-error (type => 'unparsed entity', ## TODO: type |
3393 |
|
value => $self->{kwd}); |
3394 |
|
} else { |
3395 |
|
!!!cp (1020.3); |
3396 |
|
} |
3397 |
|
$self->{entity__value} = '&' . $self->{kwd}; ## TODO: expand |
3398 |
|
} |
3399 |
|
} else { |
3400 |
|
if ($self->{is_xml}) { |
3401 |
|
!!!cp (1020.4); |
3402 |
|
!!!parse-error (type => 'entity not declared', ## TODO: type |
3403 |
|
value => $self->{kwd}, |
3404 |
|
level => { |
3405 |
|
'amp;' => $self->{level}->{warn}, |
3406 |
|
'quot;' => $self->{level}->{warn}, |
3407 |
|
'lt;' => $self->{level}->{warn}, |
3408 |
|
'gt;' => $self->{level}->{warn}, |
3409 |
|
'apos;' => $self->{level}->{warn}, |
3410 |
|
}->{$self->{kwd}} || |
3411 |
|
$self->{level}->{must}); |
3412 |
|
} else { |
3413 |
|
!!!cp (1020); |
3414 |
|
} |
3415 |
|
$self->{entity__value} = $EntityChar->{$self->{kwd}}; |
3416 |
|
} |
3417 |
$self->{entity__match} = 1; |
$self->{entity__match} = 1; |
3418 |
!!!next-input-character; |
!!!next-input-character; |
3419 |
# |
# |
3659 |
## XML5: Not defined yet. |
## XML5: Not defined yet. |
3660 |
|
|
3661 |
## TODO: |
## TODO: |
3662 |
|
|
3663 |
|
if (not $self->{stop_processing} and |
3664 |
|
not $self->{document}->xml_standalone) { |
3665 |
|
!!!parse-error (type => 'stop processing', ## TODO: type |
3666 |
|
level => $self->{level}->{info}); |
3667 |
|
$self->{stop_processing} = 1; |
3668 |
|
} |
3669 |
|
|
3670 |
!!!next-input-character; |
!!!next-input-character; |
3671 |
redo A; |
redo A; |
3672 |
} elsif ($self->{nc} == 0x005D) { # ] |
} elsif ($self->{nc} == 0x005D) { # ] |
3769 |
$self->{state} = MD_HYPHEN_STATE; |
$self->{state} = MD_HYPHEN_STATE; |
3770 |
!!!next-input-character; |
!!!next-input-character; |
3771 |
redo A; |
redo A; |
3772 |
} elsif ($self->{nc} == 0x0045) { # E |
} elsif ($self->{nc} == 0x0045 or # E |
3773 |
|
$self->{nc} == 0x0065) { # e |
3774 |
$self->{state} = MD_E_STATE; |
$self->{state} = MD_E_STATE; |
3775 |
$self->{kwd} = chr $self->{nc}; |
$self->{kwd} = chr $self->{nc}; |
3776 |
!!!next-input-character; |
!!!next-input-character; |
3777 |
redo A; |
redo A; |
3778 |
} elsif ($self->{nc} == 0x0041) { # A |
} elsif ($self->{nc} == 0x0041 or # A |
3779 |
|
$self->{nc} == 0x0061) { # a |
3780 |
$self->{state} = MD_ATTLIST_STATE; |
$self->{state} = MD_ATTLIST_STATE; |
3781 |
$self->{kwd} = chr $self->{nc}; |
$self->{kwd} = chr $self->{nc}; |
3782 |
!!!next-input-character; |
!!!next-input-character; |
3783 |
redo A; |
redo A; |
3784 |
} elsif ($self->{nc} == 0x004E) { # N |
} elsif ($self->{nc} == 0x004E or # N |
3785 |
|
$self->{nc} == 0x006E) { # n |
3786 |
$self->{state} = MD_NOTATION_STATE; |
$self->{state} = MD_NOTATION_STATE; |
3787 |
$self->{kwd} = chr $self->{nc}; |
$self->{kwd} = chr $self->{nc}; |
3788 |
!!!next-input-character; |
!!!next-input-character; |
3800 |
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded. |
$self->{ct} = {type => COMMENT_TOKEN, data => ''}; ## Will be discarded. |
3801 |
redo A; |
redo A; |
3802 |
} elsif ($self->{state} == MD_E_STATE) { |
} elsif ($self->{state} == MD_E_STATE) { |
3803 |
if ($self->{nc} == 0x004E) { # N |
if ($self->{nc} == 0x004E or # N |
3804 |
|
$self->{nc} == 0x006E) { # n |
3805 |
$self->{state} = MD_ENTITY_STATE; |
$self->{state} = MD_ENTITY_STATE; |
3806 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3807 |
!!!next-input-character; |
!!!next-input-character; |
3808 |
redo A; |
redo A; |
3809 |
} elsif ($self->{nc} == 0x004C) { # L |
} elsif ($self->{nc} == 0x004C or # L |
3810 |
|
$self->{nc} == 0x006C) { # l |
3811 |
## XML5: <!ELEMENT> not supported. |
## XML5: <!ELEMENT> not supported. |
3812 |
$self->{state} = MD_ELEMENT_STATE; |
$self->{state} = MD_ELEMENT_STATE; |
3813 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3825 |
redo A; |
redo A; |
3826 |
} |
} |
3827 |
} elsif ($self->{state} == MD_ENTITY_STATE) { |
} elsif ($self->{state} == MD_ENTITY_STATE) { |
3828 |
if ($self->{nc} == { |
if ($self->{nc} == [ |
3829 |
'EN' => 0x0054, # T |
undef, |
3830 |
'ENT' => 0x0049, # I |
undef, |
3831 |
'ENTI' => 0x0054, # T |
0x0054, # T |
3832 |
}->{$self->{kwd}}) { |
0x0049, # I |
3833 |
|
0x0054, # T |
3834 |
|
]->[length $self->{kwd}] or |
3835 |
|
$self->{nc} == [ |
3836 |
|
undef, |
3837 |
|
undef, |
3838 |
|
0x0074, # t |
3839 |
|
0x0069, # i |
3840 |
|
0x0074, # t |
3841 |
|
]->[length $self->{kwd}]) { |
3842 |
## Stay in the state. |
## Stay in the state. |
3843 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3844 |
!!!next-input-character; |
!!!next-input-character; |
3845 |
redo A; |
redo A; |
3846 |
} elsif ($self->{kwd} eq 'ENTIT' and |
} elsif ((length $self->{kwd}) == 5 and |
3847 |
$self->{nc} == 0x0059) { # Y |
($self->{nc} == 0x0059 or # Y |
3848 |
$self->{ct} = {type => GENERAL_ENTITY_TOKEN, name => '', text => '', |
$self->{nc} == 0x0079)) { # y |
3849 |
|
if ($self->{kwd} ne 'ENTIT' or $self->{nc} == 0x0079) { |
3850 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
3851 |
|
text => 'ENTITY', |
3852 |
|
line => $self->{line_prev}, |
3853 |
|
column => $self->{column_prev} - 4); |
3854 |
|
} |
3855 |
|
$self->{ct} = {type => GENERAL_ENTITY_TOKEN, name => '', |
3856 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
3857 |
column => $self->{column_prev} - 6}; |
column => $self->{column_prev} - 6}; |
3858 |
$self->{state} = DOCTYPE_MD_STATE; |
$self->{state} = DOCTYPE_MD_STATE; |
3870 |
redo A; |
redo A; |
3871 |
} |
} |
3872 |
} elsif ($self->{state} == MD_ELEMENT_STATE) { |
} elsif ($self->{state} == MD_ELEMENT_STATE) { |
3873 |
if ($self->{nc} == { |
if ($self->{nc} == [ |
3874 |
'EL' => 0x0045, # E |
undef, |
3875 |
'ELE' => 0x004D, # M |
undef, |
3876 |
'ELEM' => 0x0045, # E |
0x0045, # E |
3877 |
'ELEME' => 0x004E, # N |
0x004D, # M |
3878 |
}->{$self->{kwd}}) { |
0x0045, # E |
3879 |
|
0x004E, # N |
3880 |
|
]->[length $self->{kwd}] or |
3881 |
|
$self->{nc} == [ |
3882 |
|
undef, |
3883 |
|
undef, |
3884 |
|
0x0065, # e |
3885 |
|
0x006D, # m |
3886 |
|
0x0065, # e |
3887 |
|
0x006E, # n |
3888 |
|
]->[length $self->{kwd}]) { |
3889 |
## Stay in the state. |
## Stay in the state. |
3890 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3891 |
!!!next-input-character; |
!!!next-input-character; |
3892 |
redo A; |
redo A; |
3893 |
} elsif ($self->{kwd} eq 'ELEMEN' and |
} elsif ((length $self->{kwd}) == 6 and |
3894 |
$self->{nc} == 0x0054) { # T |
($self->{nc} == 0x0054 or # T |
3895 |
|
$self->{nc} == 0x0074)) { # t |
3896 |
|
if ($self->{kwd} ne 'ELEMEN' or $self->{nc} == 0x0074) { |
3897 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
3898 |
|
text => 'ELEMENT', |
3899 |
|
line => $self->{line_prev}, |
3900 |
|
column => $self->{column_prev} - 5); |
3901 |
|
} |
3902 |
$self->{ct} = {type => ELEMENT_TOKEN, name => '', |
$self->{ct} = {type => ELEMENT_TOKEN, name => '', |
3903 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
3904 |
column => $self->{column_prev} - 6}; |
column => $self->{column_prev} - 7}; |
3905 |
$self->{state} = DOCTYPE_MD_STATE; |
$self->{state} = DOCTYPE_MD_STATE; |
3906 |
!!!next-input-character; |
!!!next-input-character; |
3907 |
redo A; |
redo A; |
3917 |
redo A; |
redo A; |
3918 |
} |
} |
3919 |
} elsif ($self->{state} == MD_ATTLIST_STATE) { |
} elsif ($self->{state} == MD_ATTLIST_STATE) { |
3920 |
if ($self->{nc} == { |
if ($self->{nc} == [ |
3921 |
'A' => 0x0054, # T |
undef, |
3922 |
'AT' => 0x0054, # T |
0x0054, # T |
3923 |
'ATT' => 0x004C, # L |
0x0054, # T |
3924 |
'ATTL' => 0x0049, # I |
0x004C, # L |
3925 |
'ATTLI' => 0x0053, # S |
0x0049, # I |
3926 |
}->{$self->{kwd}}) { |
0x0053, # S |
3927 |
|
]->[length $self->{kwd}] or |
3928 |
|
$self->{nc} == [ |
3929 |
|
undef, |
3930 |
|
0x0074, # t |
3931 |
|
0x0074, # t |
3932 |
|
0x006C, # l |
3933 |
|
0x0069, # i |
3934 |
|
0x0073, # s |
3935 |
|
]->[length $self->{kwd}]) { |
3936 |
## Stay in the state. |
## Stay in the state. |
3937 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3938 |
!!!next-input-character; |
!!!next-input-character; |
3939 |
redo A; |
redo A; |
3940 |
} elsif ($self->{kwd} eq 'ATTLIS' and |
} elsif ((length $self->{kwd}) == 6 and |
3941 |
$self->{nc} == 0x0054) { # T |
($self->{nc} == 0x0054 or # T |
3942 |
|
$self->{nc} == 0x0074)) { # t |
3943 |
|
if ($self->{kwd} ne 'ATTLIS' or $self->{nc} == 0x0074) { |
3944 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
3945 |
|
text => 'ATTLIST', |
3946 |
|
line => $self->{line_prev}, |
3947 |
|
column => $self->{column_prev} - 5); |
3948 |
|
} |
3949 |
$self->{ct} = {type => ATTLIST_TOKEN, name => '', |
$self->{ct} = {type => ATTLIST_TOKEN, name => '', |
3950 |
attrdefs => [], |
attrdefs => [], |
3951 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
3952 |
column => $self->{column_prev} - 6}; |
column => $self->{column_prev} - 7}; |
3953 |
$self->{state} = DOCTYPE_MD_STATE; |
$self->{state} = DOCTYPE_MD_STATE; |
3954 |
!!!next-input-character; |
!!!next-input-character; |
3955 |
redo A; |
redo A; |
3965 |
redo A; |
redo A; |
3966 |
} |
} |
3967 |
} elsif ($self->{state} == MD_NOTATION_STATE) { |
} elsif ($self->{state} == MD_NOTATION_STATE) { |
3968 |
if ($self->{nc} == { |
if ($self->{nc} == [ |
3969 |
'N' => 0x004F, # O |
undef, |
3970 |
'NO' => 0x0054, # T |
0x004F, # O |
3971 |
'NOT' => 0x0041, # A |
0x0054, # T |
3972 |
'NOTA' => 0x0054, # T |
0x0041, # A |
3973 |
'NOTAT' => 0x0049, # I |
0x0054, # T |
3974 |
'NOTATI' => 0x004F, # O |
0x0049, # I |
3975 |
}->{$self->{kwd}}) { |
0x004F, # O |
3976 |
|
]->[length $self->{kwd}] or |
3977 |
|
$self->{nc} == [ |
3978 |
|
undef, |
3979 |
|
0x006F, # o |
3980 |
|
0x0074, # t |
3981 |
|
0x0061, # a |
3982 |
|
0x0074, # t |
3983 |
|
0x0069, # i |
3984 |
|
0x006F, # o |
3985 |
|
]->[length $self->{kwd}]) { |
3986 |
## Stay in the state. |
## Stay in the state. |
3987 |
$self->{kwd} .= chr $self->{nc}; |
$self->{kwd} .= chr $self->{nc}; |
3988 |
!!!next-input-character; |
!!!next-input-character; |
3989 |
redo A; |
redo A; |
3990 |
} elsif ($self->{kwd} eq 'NOTATIO' and |
} elsif ((length $self->{kwd}) == 7 and |
3991 |
$self->{nc} == 0x004E) { # N |
($self->{nc} == 0x004E or # N |
3992 |
|
$self->{nc} == 0x006E)) { # n |
3993 |
|
if ($self->{kwd} ne 'NOTATIO' or $self->{nc} == 0x006E) { |
3994 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
3995 |
|
text => 'NOTATION', |
3996 |
|
line => $self->{line_prev}, |
3997 |
|
column => $self->{column_prev} - 6); |
3998 |
|
} |
3999 |
$self->{ct} = {type => NOTATION_TOKEN, name => '', |
$self->{ct} = {type => NOTATION_TOKEN, name => '', |
4000 |
line => $self->{line_prev}, |
line => $self->{line_prev}, |
4001 |
column => $self->{column_prev} - 6}; |
column => $self->{column_prev} - 8}; |
4002 |
$self->{state} = DOCTYPE_MD_STATE; |
$self->{state} = DOCTYPE_MD_STATE; |
4003 |
!!!next-input-character; |
!!!next-input-character; |
4004 |
redo A; |
redo A; |
4110 |
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
if ($self->{ct}->{type} == ATTLIST_TOKEN) { |
4111 |
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
4112 |
} elsif ($self->{ct}->{type} == ELEMENT_TOKEN) { |
} elsif ($self->{ct}->{type} == ELEMENT_TOKEN) { |
4113 |
## TODO: ... |
$self->{state} = AFTER_ELEMENT_NAME_STATE; |
|
$self->{state} = DOCTYPE_ATTLIST_NAME_AFTER_STATE; |
|
4114 |
} else { # ENTITY/NOTATION |
} else { # ENTITY/NOTATION |
4115 |
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
4116 |
} |
} |
4638 |
## Reconsume. |
## Reconsume. |
4639 |
redo A; |
redo A; |
4640 |
} |
} |
4641 |
|
} elsif ($self->{state} == NDATA_STATE) { |
4642 |
|
## ASCII case-insensitive |
4643 |
|
if ($self->{nc} == [ |
4644 |
|
undef, |
4645 |
|
0x0044, # D |
4646 |
|
0x0041, # A |
4647 |
|
0x0054, # T |
4648 |
|
]->[length $self->{kwd}] or |
4649 |
|
$self->{nc} == [ |
4650 |
|
undef, |
4651 |
|
0x0064, # d |
4652 |
|
0x0061, # a |
4653 |
|
0x0074, # t |
4654 |
|
]->[length $self->{kwd}]) { |
4655 |
|
!!!cp (172.2); |
4656 |
|
## Stay in the state. |
4657 |
|
$self->{kwd} .= chr $self->{nc}; |
4658 |
|
!!!next-input-character; |
4659 |
|
redo A; |
4660 |
|
} elsif ((length $self->{kwd}) == 4 and |
4661 |
|
($self->{nc} == 0x0041 or # A |
4662 |
|
$self->{nc} == 0x0061)) { # a |
4663 |
|
if ($self->{kwd} ne 'NDAT' or $self->{nc} == 0x0061) { # a |
4664 |
|
!!!cp (172.3); |
4665 |
|
!!!parse-error (type => 'lowercase keyword', ## TODO: type |
4666 |
|
text => 'NDATA', |
4667 |
|
line => $self->{line_prev}, |
4668 |
|
column => $self->{column_prev} - 4); |
4669 |
|
} else { |
4670 |
|
!!!cp (172.4); |
4671 |
|
} |
4672 |
|
$self->{state} = AFTER_NDATA_STATE; |
4673 |
|
!!!next-input-character; |
4674 |
|
redo A; |
4675 |
|
} else { |
4676 |
|
!!!parse-error (type => 'string after literal', ## TODO: type |
4677 |
|
line => $self->{line_prev}, |
4678 |
|
column => $self->{column_prev} + 1 |
4679 |
|
- length $self->{kwd}); |
4680 |
|
!!!cp (172.5); |
4681 |
|
$self->{state} = BOGUS_MD_STATE; |
4682 |
|
## Reconsume. |
4683 |
|
redo A; |
4684 |
|
} |
4685 |
|
} elsif ($self->{state} == AFTER_NDATA_STATE) { |
4686 |
|
if ($is_space->{$self->{nc}}) { |
4687 |
|
$self->{state} = BEFORE_NOTATION_NAME_STATE; |
4688 |
|
!!!next-input-character; |
4689 |
|
redo A; |
4690 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4691 |
|
!!!parse-error (type => 'no notation name'); ## TODO: type |
4692 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4693 |
|
!!!next-input-character; |
4694 |
|
!!!emit ($self->{ct}); # ENTITY |
4695 |
|
redo A; |
4696 |
|
} elsif ($self->{nc} == -1) { |
4697 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4698 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4699 |
|
!!!next-input-character; |
4700 |
|
!!!emit ($self->{ct}); # ENTITY |
4701 |
|
redo A; |
4702 |
|
} else { |
4703 |
|
!!!parse-error (type => 'string after literal', ## TODO: type |
4704 |
|
line => $self->{line_prev}, |
4705 |
|
column => $self->{column_prev} + 1 |
4706 |
|
- length $self->{kwd}); |
4707 |
|
$self->{state} = BOGUS_MD_STATE; |
4708 |
|
## Reconsume. |
4709 |
|
redo A; |
4710 |
|
} |
4711 |
|
} elsif ($self->{state} == BEFORE_NOTATION_NAME_STATE) { |
4712 |
|
if ($is_space->{$self->{nc}}) { |
4713 |
|
## Stay in the state. |
4714 |
|
!!!next-input-character; |
4715 |
|
redo A; |
4716 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4717 |
|
!!!parse-error (type => 'no notation name'); ## TODO: type |
4718 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4719 |
|
!!!next-input-character; |
4720 |
|
!!!emit ($self->{ct}); # ENTITY |
4721 |
|
redo A; |
4722 |
|
} elsif ($self->{nc} == -1) { |
4723 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4724 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4725 |
|
!!!next-input-character; |
4726 |
|
!!!emit ($self->{ct}); # ENTITY |
4727 |
|
redo A; |
4728 |
|
} else { |
4729 |
|
$self->{ct}->{notation} = chr $self->{nc}; # ENTITY |
4730 |
|
$self->{state} = NOTATION_NAME_STATE; |
4731 |
|
!!!next-input-character; |
4732 |
|
redo A; |
4733 |
|
} |
4734 |
|
} elsif ($self->{state} == NOTATION_NAME_STATE) { |
4735 |
|
if ($is_space->{$self->{nc}}) { |
4736 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
4737 |
|
!!!next-input-character; |
4738 |
|
redo A; |
4739 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4740 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4741 |
|
!!!next-input-character; |
4742 |
|
!!!emit ($self->{ct}); # ENTITY |
4743 |
|
redo A; |
4744 |
|
} elsif ($self->{nc} == -1) { |
4745 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4746 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4747 |
|
!!!next-input-character; |
4748 |
|
!!!emit ($self->{ct}); # ENTITY |
4749 |
|
redo A; |
4750 |
|
} else { |
4751 |
|
$self->{ct}->{notation} .= chr $self->{nc}; # ENTITY |
4752 |
|
## Stay in the state. |
4753 |
|
!!!next-input-character; |
4754 |
|
redo A; |
4755 |
|
} |
4756 |
|
} elsif ($self->{state} == DOCTYPE_ENTITY_VALUE_DOUBLE_QUOTED_STATE) { |
4757 |
|
if ($self->{nc} == 0x0022) { # " |
4758 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
4759 |
|
!!!next-input-character; |
4760 |
|
redo A; |
4761 |
|
} elsif ($self->{nc} == 0x0026) { # & |
4762 |
|
$self->{prev_state} = $self->{state}; |
4763 |
|
$self->{state} = ENTITY_VALUE_ENTITY_STATE; |
4764 |
|
$self->{entity_add} = 0x0022; # " |
4765 |
|
!!!next-input-character; |
4766 |
|
redo A; |
4767 |
|
## TODO: % |
4768 |
|
} elsif ($self->{nc} == -1) { |
4769 |
|
!!!parse-error (type => 'unclosed entity value'); ## TODO: type |
4770 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4771 |
|
## Reconsume. |
4772 |
|
!!!emit ($self->{ct}); # ENTITY |
4773 |
|
redo A; |
4774 |
|
} else { |
4775 |
|
$self->{ct}->{value} .= chr $self->{nc}; # ENTITY |
4776 |
|
!!!next-input-character; |
4777 |
|
redo A; |
4778 |
|
} |
4779 |
|
} elsif ($self->{state} == DOCTYPE_ENTITY_VALUE_SINGLE_QUOTED_STATE) { |
4780 |
|
if ($self->{nc} == 0x0027) { # ' |
4781 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
4782 |
|
!!!next-input-character; |
4783 |
|
redo A; |
4784 |
|
} elsif ($self->{nc} == 0x0026) { # & |
4785 |
|
$self->{prev_state} = $self->{state}; |
4786 |
|
$self->{state} = ENTITY_VALUE_ENTITY_STATE; |
4787 |
|
$self->{entity_add} = 0x0027; # ' |
4788 |
|
!!!next-input-character; |
4789 |
|
redo A; |
4790 |
|
## TODO: % |
4791 |
|
} elsif ($self->{nc} == -1) { |
4792 |
|
!!!parse-error (type => 'unclosed entity value'); ## TODO: type |
4793 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4794 |
|
## Reconsume. |
4795 |
|
!!!emit ($self->{ct}); # ENTITY |
4796 |
|
redo A; |
4797 |
|
} else { |
4798 |
|
$self->{ct}->{value} .= chr $self->{nc}; # ENTITY |
4799 |
|
!!!next-input-character; |
4800 |
|
redo A; |
4801 |
|
} |
4802 |
|
} elsif ($self->{state} == ENTITY_VALUE_ENTITY_STATE) { |
4803 |
|
if ($is_space->{$self->{nc}} or |
4804 |
|
{ |
4805 |
|
0x003C => 1, 0x0026 => 1, -1 => 1, # <, & |
4806 |
|
$self->{entity_add} => 1, |
4807 |
|
}->{$self->{nc}}) { |
4808 |
|
!!!parse-error (type => 'bare ero', |
4809 |
|
line => $self->{line_prev}, |
4810 |
|
column => $self->{column_prev} |
4811 |
|
+ ($self->{nc} == -1 ? 1 : 0)); |
4812 |
|
## Don't consume |
4813 |
|
## Return nothing. |
4814 |
|
# |
4815 |
|
} elsif ($self->{nc} == 0x0023) { # # |
4816 |
|
$self->{ca} = $self->{ct}; |
4817 |
|
$self->{state} = ENTITY_HASH_STATE; |
4818 |
|
$self->{kwd} = '#'; |
4819 |
|
!!!next-input-character; |
4820 |
|
redo A; |
4821 |
|
} else { |
4822 |
|
# |
4823 |
|
} |
4824 |
|
|
4825 |
|
$self->{ct}->{value} .= '&'; |
4826 |
|
$self->{state} = $self->{prev_state}; |
4827 |
|
## Reconsume. |
4828 |
|
redo A; |
4829 |
|
} elsif ($self->{state} == AFTER_ELEMENT_NAME_STATE) { |
4830 |
|
if ($is_space->{$self->{nc}}) { |
4831 |
|
$self->{state} = BEFORE_ELEMENT_CONTENT_STATE; |
4832 |
|
!!!next-input-character; |
4833 |
|
redo A; |
4834 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4835 |
|
$self->{state} = AFTER_CM_GROUP_OPEN_STATE; |
4836 |
|
$self->{ct}->{content} = ['(']; |
4837 |
|
$self->{group_depth} = 1; |
4838 |
|
!!!next-input-character; |
4839 |
|
redo A; |
4840 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4841 |
|
!!!parse-error (type => 'no md def'); ## TODO: type |
4842 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4843 |
|
!!!next-input-character; |
4844 |
|
!!!emit ($self->{ct}); # ELEMENT |
4845 |
|
redo A; |
4846 |
|
} elsif ($self->{nc} == -1) { |
4847 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4848 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4849 |
|
!!!next-input-character; |
4850 |
|
!!!emit ($self->{ct}); # ELEMENT |
4851 |
|
redo A; |
4852 |
|
} else { |
4853 |
|
$self->{ct}->{content} = [chr $self->{nc}]; |
4854 |
|
$self->{state} = CONTENT_KEYWORD_STATE; |
4855 |
|
!!!next-input-character; |
4856 |
|
redo A; |
4857 |
|
} |
4858 |
|
} elsif ($self->{state} == CONTENT_KEYWORD_STATE) { |
4859 |
|
if ($is_space->{$self->{nc}}) { |
4860 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
4861 |
|
!!!next-input-character; |
4862 |
|
redo A; |
4863 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4864 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4865 |
|
!!!next-input-character; |
4866 |
|
!!!emit ($self->{ct}); # ELEMENT |
4867 |
|
redo A; |
4868 |
|
} elsif ($self->{nc} == -1) { |
4869 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4870 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4871 |
|
!!!next-input-character; |
4872 |
|
!!!emit ($self->{ct}); # ELEMENT |
4873 |
|
redo A; |
4874 |
|
} else { |
4875 |
|
$self->{ct}->{content}->[-1] .= chr $self->{nc}; # ELEMENT |
4876 |
|
## Stay in the state. |
4877 |
|
!!!next-input-character; |
4878 |
|
redo A; |
4879 |
|
} |
4880 |
|
} elsif ($self->{state} == AFTER_CM_GROUP_OPEN_STATE) { |
4881 |
|
if ($is_space->{$self->{nc}}) { |
4882 |
|
## Stay in the state. |
4883 |
|
!!!next-input-character; |
4884 |
|
redo A; |
4885 |
|
} elsif ($self->{nc} == 0x0028) { # ( |
4886 |
|
$self->{group_depth}++; |
4887 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
4888 |
|
## Stay in the state. |
4889 |
|
!!!next-input-character; |
4890 |
|
redo A; |
4891 |
|
} elsif ($self->{nc} == 0x007C or # | |
4892 |
|
$self->{nc} == 0x002C) { # , |
4893 |
|
!!!parse-error (type => 'empty element name'); ## TODO: type |
4894 |
|
## Stay in the state. |
4895 |
|
!!!next-input-character; |
4896 |
|
redo A; |
4897 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
4898 |
|
!!!parse-error (type => 'empty element name'); ## TODO: type |
4899 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
4900 |
|
$self->{group_depth}--; |
4901 |
|
$self->{state} = AFTER_CM_GROUP_CLOSE_STATE; |
4902 |
|
!!!next-input-character; |
4903 |
|
redo A; |
4904 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4905 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
4906 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
4907 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4908 |
|
!!!next-input-character; |
4909 |
|
!!!emit ($self->{ct}); # ELEMENT |
4910 |
|
redo A; |
4911 |
|
} elsif ($self->{nc} == -1) { |
4912 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4913 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
4914 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4915 |
|
!!!next-input-character; |
4916 |
|
!!!emit ($self->{ct}); # ELEMENT |
4917 |
|
redo A; |
4918 |
|
} else { |
4919 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
4920 |
|
$self->{state} = CM_ELEMENT_NAME_STATE; |
4921 |
|
!!!next-input-character; |
4922 |
|
redo A; |
4923 |
|
} |
4924 |
|
} elsif ($self->{state} == CM_ELEMENT_NAME_STATE) { |
4925 |
|
if ($is_space->{$self->{nc}}) { |
4926 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
4927 |
|
!!!next-input-character; |
4928 |
|
redo A; |
4929 |
|
} elsif ($self->{nc} == 0x002A or # * |
4930 |
|
$self->{nc} == 0x002B or # + |
4931 |
|
$self->{nc} == 0x003F) { # ? |
4932 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
4933 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
4934 |
|
!!!next-input-character; |
4935 |
|
redo A; |
4936 |
|
} elsif ($self->{nc} == 0x007C or # | |
4937 |
|
$self->{nc} == 0x002C) { # , |
4938 |
|
push @{$self->{ct}->{content}}, $self->{nc} == 0x007C ? ' | ' : ', '; |
4939 |
|
$self->{state} = AFTER_CM_GROUP_OPEN_STATE; |
4940 |
|
!!!next-input-character; |
4941 |
|
redo A; |
4942 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
4943 |
|
$self->{group_depth}--; |
4944 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
4945 |
|
$self->{state} = AFTER_CM_GROUP_CLOSE_STATE; |
4946 |
|
!!!next-input-character; |
4947 |
|
redo A; |
4948 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4949 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
4950 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
4951 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4952 |
|
!!!next-input-character; |
4953 |
|
!!!emit ($self->{ct}); # ELEMENT |
4954 |
|
redo A; |
4955 |
|
} elsif ($self->{nc} == -1) { |
4956 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4957 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
4958 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4959 |
|
!!!next-input-character; |
4960 |
|
!!!emit ($self->{ct}); # ELEMENT |
4961 |
|
redo A; |
4962 |
|
} else { |
4963 |
|
$self->{ct}->{content}->[-1] .= chr $self->{nc}; |
4964 |
|
## Stay in the state. |
4965 |
|
!!!next-input-character; |
4966 |
|
redo A; |
4967 |
|
} |
4968 |
|
} elsif ($self->{state} == AFTER_CM_ELEMENT_NAME_STATE) { |
4969 |
|
if ($is_space->{$self->{nc}}) { |
4970 |
|
## Stay in the state. |
4971 |
|
!!!next-input-character; |
4972 |
|
redo A; |
4973 |
|
} elsif ($self->{nc} == 0x007C or # | |
4974 |
|
$self->{nc} == 0x002C) { # , |
4975 |
|
push @{$self->{ct}->{content}}, $self->{nc} == 0x007C ? ' | ' : ', '; |
4976 |
|
$self->{state} = AFTER_CM_GROUP_OPEN_STATE; |
4977 |
|
!!!next-input-character; |
4978 |
|
redo A; |
4979 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
4980 |
|
$self->{group_depth}--; |
4981 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
4982 |
|
$self->{state} = AFTER_CM_GROUP_CLOSE_STATE; |
4983 |
|
!!!next-input-character; |
4984 |
|
redo A; |
4985 |
|
} elsif ($self->{nc} == 0x003E) { # > |
4986 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
4987 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
4988 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4989 |
|
!!!next-input-character; |
4990 |
|
!!!emit ($self->{ct}); # ELEMENT |
4991 |
|
redo A; |
4992 |
|
} elsif ($self->{nc} == -1) { |
4993 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
4994 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
4995 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
4996 |
|
!!!next-input-character; |
4997 |
|
!!!emit ($self->{ct}); # ELEMENT |
4998 |
|
redo A; |
4999 |
|
} else { |
5000 |
|
!!!parse-error (type => 'after element name'); ## TODO: type |
5001 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5002 |
|
$self->{state} = BOGUS_MD_STATE; |
5003 |
|
!!!next-input-character; |
5004 |
|
redo A; |
5005 |
|
} |
5006 |
|
} elsif ($self->{state} == AFTER_CM_GROUP_CLOSE_STATE) { |
5007 |
|
if ($is_space->{$self->{nc}}) { |
5008 |
|
if ($self->{group_depth}) { |
5009 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5010 |
|
} else { |
5011 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
5012 |
|
} |
5013 |
|
!!!next-input-character; |
5014 |
|
redo A; |
5015 |
|
} elsif ($self->{nc} == 0x002A or # * |
5016 |
|
$self->{nc} == 0x002B or # + |
5017 |
|
$self->{nc} == 0x003F) { # ? |
5018 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5019 |
|
if ($self->{group_depth}) { |
5020 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5021 |
|
} else { |
5022 |
|
$self->{state} = AFTER_MD_DEF_STATE; |
5023 |
|
} |
5024 |
|
!!!next-input-character; |
5025 |
|
redo A; |
5026 |
|
} elsif ($self->{nc} == 0x0029) { # ) |
5027 |
|
if ($self->{group_depth}) { |
5028 |
|
$self->{group_depth}--; |
5029 |
|
push @{$self->{ct}->{content}}, chr $self->{nc}; |
5030 |
|
## Stay in the state. |
5031 |
|
!!!next-input-character; |
5032 |
|
redo A; |
5033 |
|
} else { |
5034 |
|
!!!parse-error (type => 'string after md def'); ## TODO: type |
5035 |
|
$self->{state} = BOGUS_MD_STATE; |
5036 |
|
## Reconsume. |
5037 |
|
redo A; |
5038 |
|
} |
5039 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5040 |
|
if ($self->{group_depth}) { |
5041 |
|
!!!parse-error (type => 'unclosed cm group'); ## TODO: type |
5042 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5043 |
|
} |
5044 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5045 |
|
!!!next-input-character; |
5046 |
|
!!!emit ($self->{ct}); # ELEMENT |
5047 |
|
redo A; |
5048 |
|
} elsif ($self->{nc} == -1) { |
5049 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5050 |
|
push @{$self->{ct}->{content}}, (')') x $self->{group_depth}; |
5051 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5052 |
|
!!!next-input-character; |
5053 |
|
!!!emit ($self->{ct}); # ELEMENT |
5054 |
|
redo A; |
5055 |
|
} else { |
5056 |
|
if ($self->{group_depth}) { |
5057 |
|
$self->{state} = AFTER_CM_ELEMENT_NAME_STATE; |
5058 |
|
} else { |
5059 |
|
!!!parse-error (type => 'string after md def'); ## TODO: type |
5060 |
|
$self->{state} = BOGUS_MD_STATE; |
5061 |
|
} |
5062 |
|
## Reconsume. |
5063 |
|
redo A; |
5064 |
|
} |
5065 |
|
} elsif ($self->{state} == AFTER_MD_DEF_STATE) { |
5066 |
|
if ($is_space->{$self->{nc}}) { |
5067 |
|
## Stay in the state. |
5068 |
|
!!!next-input-character; |
5069 |
|
redo A; |
5070 |
|
} elsif ($self->{nc} == 0x003E) { # > |
5071 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5072 |
|
!!!next-input-character; |
5073 |
|
!!!emit ($self->{ct}); # ENTITY/ELEMENT |
5074 |
|
redo A; |
5075 |
|
} elsif ($self->{nc} == -1) { |
5076 |
|
!!!parse-error (type => 'unclosed md'); ## TODO: type |
5077 |
|
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
5078 |
|
!!!next-input-character; |
5079 |
|
!!!emit ($self->{ct}); # ENTITY/ELEMENT |
5080 |
|
redo A; |
5081 |
|
} else { |
5082 |
|
!!!parse-error (type => 'string after md def'); ## TODO: type |
5083 |
|
$self->{state} = BOGUS_MD_STATE; |
5084 |
|
## Reconsume. |
5085 |
|
redo A; |
5086 |
|
} |
5087 |
} elsif ($self->{state} == BOGUS_MD_STATE) { |
} elsif ($self->{state} == BOGUS_MD_STATE) { |
5088 |
if ($self->{nc} == 0x003E) { # > |
if ($self->{nc} == 0x003E) { # > |
5089 |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |
$self->{state} = DOCTYPE_INTERNAL_SUBSET_STATE; |