/[suikacvs]/markup/html/whatpm/Whatpm/mkhtmlparser.pl
Suika

Contents of /markup/html/whatpm/Whatpm/mkhtmlparser.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Mon Mar 10 10:55:57 2008 UTC (16 years, 7 months ago) by wakaba
Branch: MAIN
Changes since 1.5: +3 -1 lines
File MIME type: text/plain
++ whatpm/Whatpm/ChangeLog	10 Mar 2008 10:55:36 -0000
2008-03-10  Wakaba  <wakaba@suika.fam.cx>

	* mkhtmlparser.pl: Set "level" parameter to parse errors.

	* HTML.pm.src: Code refined.

1 wakaba 1.1 #!/usr/bin/perl
2     use strict;
3    
4 wakaba 1.4 my $DEBUG = $ENV{DEBUG};
5    
6 wakaba 1.1 while (<>) {
7     s/!!!emit\b/return /;
8     s{!!!next-input-character;}{q{
9     if (@{$self->{char}}) {
10 wakaba 1.3 $self->{next_char} = shift @{$self->{char}};
11 wakaba 1.1 } else {
12 wakaba 1.3 $self->{set_next_char}->($self);
13 wakaba 1.1 }
14     }}ge;
15     s{!!!back-next-input-character\b}{q{unshift @{$self->{char}}, }}ge;
16     s{!!!parse-error;}{q{$self->{parse_error}->();}}ge;
17 wakaba 1.6 s{!!!parse-error\s*\(}{
18     q{$self->{parse_error}->(level => $self->{must_level}, }
19     }ge;
20 wakaba 1.1 s{!!!insert-element-t\s*\(([^(),]+),([^(),]+)\)\s*;}{qq{
21     {
22     my \$el;
23     !!!create-element (\$el, $1, $2);
24     \$insert->(\$el);
25 wakaba 1.2 push \@{\$self->{open_elements}}, [\$el, $1];
26 wakaba 1.1 }
27     }}ge;
28     s{!!!insert-element-t\s*\(([^(),]+)\)\s*;}{qq{
29     {
30     my \$el;
31     !!!create-element (\$el, $1);
32     \$insert->(\$el);
33 wakaba 1.2 push \@{\$self->{open_elements}}, [\$el, $1];
34 wakaba 1.1 }
35     }}ge;
36     s{!!!insert-element\s*\(([^(),]+),([^(),]+)\)\s*;}{qq{
37     {
38     my \$el;
39     !!!create-element (\$el, $1, $2);
40 wakaba 1.2 \$self->{open_elements}->[-1]->[0]->append_child (\$el);
41     push \@{\$self->{open_elements}}, [\$el, $1];
42 wakaba 1.1 }
43     }}ge;
44     s{!!!insert-element\s*\(([^(),]+)\)\s*;}{qq{
45     {
46     my \$el;
47     !!!create-element (\$el, $1);
48 wakaba 1.2 \$self->{open_elements}->[-1]->[0]->append_child (\$el);
49     push \@{\$self->{open_elements}}, [\$el, $1];
50 wakaba 1.1 }
51     }}ge;
52     s{!!!create-element\s*\(([^(),]+),([^(),]+)(?:,([^(),]+))?\)\s*;}{
53     my $r = qq{
54     $1 = \$self->{document}->create_element_ns
55     (q<http://www.w3.org/1999/xhtml>, [undef, $2]);
56     };
57     if (defined $3) {
58     $r .= qq{
59     for my \$attr_name (keys %{$3}) {
60     $1->set_attribute_ns (undef, [undef, \$attr_name],
61     $3 ->{\$attr_name}->{value});
62     }
63     };
64     }
65     $r;
66     }ge; # MUST
67     s{!!!next-token;}{q{$token = $self->_get_next_token;}}ge;
68     s{!!!back-token;}{q{unshift @{$self->{token}}, $token;}}ge;
69     s{!!!back-token\s*\(}{q{unshift @{$self->{token}}, (}}ge;
70 wakaba 1.4 s{!!!cp\s*\(\s*(\S+)\s*\)\s*;}{
71     $DEBUG ? qq{
72 wakaba 1.5 #print STDERR "$1, ";
73 wakaba 1.4 \$Whatpm::HTML::Debug::cp_pass->($1) if \$Whatpm::HTML::Debug::cp_pass;
74     BEGIN {
75     \$Whatpm::HTML::Debug::cp->{$1} = 1;
76     }
77     } : ''
78     }ge;
79 wakaba 1.1 print;
80     }

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24