25 |
$class->use or die $@; |
$class->use or die $@; |
26 |
my $parser = $class->new; |
my $parser = $class->new; |
27 |
|
|
28 |
|
my @error; |
29 |
|
$parser->onerror (sub { |
30 |
|
my %args = @_; |
31 |
|
my $r = '<li>'; |
32 |
|
if ($args{level} eq 'w') { |
33 |
|
$r .= '<strong>Warning</strong>: '; |
34 |
|
} else { |
35 |
|
$r .= '<strong>Error</strong>: '; |
36 |
|
} |
37 |
|
|
38 |
|
$r .= htescape sprintf $args{type}, @{$args{args}}; |
39 |
|
|
40 |
|
$r .= ': <code>'; |
41 |
|
$r .= htescape substr ${$args{valueref}}, 0, $args{pos_start}; |
42 |
|
$r .= '<mark>'; |
43 |
|
$r .= htescape substr ${$args{valueref}}, |
44 |
|
$args{pos_start}, $args{pos_end} - $args{pos_start}; |
45 |
|
$r .= '</mark>'; |
46 |
|
$r .= htescape substr ${$args{valueref}}, $args{pos_end}; |
47 |
|
$r .= '</code></li>'; |
48 |
|
|
49 |
|
push @error, $r; |
50 |
|
}); |
51 |
|
|
52 |
eval { |
eval { |
53 |
$parser->parse ($regexp); |
$parser->parse ($regexp); |
54 |
}; |
}; |
65 |
|
|
66 |
<p>Input: <code>], $eregexp, q[</code></p> |
<p>Input: <code>], $eregexp, q[</code></p> |
67 |
|
|
68 |
<p>Error: ], htescape ($parser->errmsg); |
<p>Error: |
69 |
|
<ul>]; |
70 |
|
print join '', @error; |
71 |
|
print q[</ul>]; |
72 |
|
|
73 |
exit; |
exit; |
74 |
} |
} |
75 |
|
|
89 |
|
|
90 |
<p>Input: <code>], $eregexp, q[</code></p>]; |
<p>Input: <code>], $eregexp, q[</code></p>]; |
91 |
|
|
92 |
|
if (@error) { |
93 |
|
print q[<ul>]; |
94 |
|
print join '', @error; |
95 |
|
print q[</ul>]; |
96 |
|
} |
97 |
|
|
98 |
while ($v->has_regexp_node) { |
while ($v->has_regexp_node) { |
99 |
my ($g, $index) = $v->next_graph; |
my ($g, $index) = $v->next_graph; |
100 |
|
|