[Templates-cvs] cvs commit: TT3/benchmark/lib/Scanner/TT3 Null.pm
cvs@template-toolkit.org
cvs@template-toolkit.org
Fri, 19 Dec 2003 12:08:27 +0000
cvs 03/12/19 12:08:26
Added: benchmark/lib/Scanner/TT3 Null.pm
Log:
added benchmark files
Revision Changes Path
1.1 TT3/benchmark/lib/Scanner/TT3/Null.pm
Index: Null.pm
===================================================================
# scanner which does nothing more than run the regular expression from
# the TT3 scanner
package Scanner::TT3::Null;
use Template::TT3::Scanner;
use base qw( Template::TT3::Scanner );
use vars qw( $DEBUG );
use strict;
use warnings;
sub scan {
my ($self, $text, $handler) = @_;
my $textref = ref $text ? $text : \$text;
my $end;
$self->{ reset } = 0;
my $line = 1;
my $size = 0;
SCAN_FOR_TAGS: {
my ($tagmap, $regex, $regexen) = @$self{ qw( tagmap regex regexen ) };
last SCAN_FOR_TAGS unless $regex;
while ($$textref =~ /$regex/cg) {
my $start = $2;
my $tag = $tagmap->{ $start } || die "no tag for $start\n";
if (defined ($end = $tag->{ end }) && length($end)) {
my $regex = $tag->{ end_regex } ||= do {
$end = ref $end eq 'Regexp' ? $end : quotemeta($end);
qr/ \G (.*?) ($end) /sox;
};
return $self->error("no closing tag to match $start")
unless $$textref =~ /$regex/gc;
}
}
}
if ($$textref =~ / \G (.+) /sx) {
}
return 1;
}
1;