#!/usr/bin/perl use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use FindBin; use lib qq[$FindBin::Bin/../lib]; use lib q[/home/wakaba/work/manakai2/lib]; use Message::CGI::Util qw/htescape/; use Encode; use Message::CGI::HTTP; my $cgi = Message::CGI::HTTP->new; my $regexp = decode 'utf-8', $cgi->get_parameter ('s') // ''; $regexp = '(?:)' unless length $regexp; my $eregexp = htescape $regexp; my $lang = $cgi->get_parameter ('l') // 'perl58'; my $class = $lang eq 'js' ? 'Regexp::Parser::JavaScript' : 'Regexp::Parser::Perl58'; use UNIVERSAL::require; $class->use or die $@; my $parser = $class->new; my @error; $parser->onerror (sub { my %args = @_; my $r = '
';
$r .= htescape substr ${$args{valueref}}, 0, $args{pos_start};
$r .= '';
$r .= htescape substr ${$args{valueref}},
$args{pos_start}, $args{pos_end} - $args{pos_start};
$r .= '';
$r .= htescape substr ${$args{valueref}}, $args{pos_end};
$r .= '
Input: ], $eregexp, q[
Error:
Input: ], $eregexp, q[