/[suikacvs]/webroot/regexp/visualizer/regexp.cgi
Suika

Diff of /webroot/regexp/visualizer/regexp.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by wakaba, Mon Dec 8 12:21:26 2008 UTC revision 1.5 by wakaba, Tue Dec 9 02:41:39 2008 UTC
# Line 25  use UNIVERSAL::require; Line 25  use UNIVERSAL::require;
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  };  };
# Line 41  if ($parser->errnum) { Line 65  if ($parser->errnum) {
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    
# Line 61  print q[<html lang="en" xmlns="http://ww Line 89  print q[<html lang="en" xmlns="http://ww
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    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24