faster macro processor using perl 5.10 features

This commit is contained in:
Graham Knop 2010-02-04 13:52:41 -06:00
parent 6d381a5c46
commit d7767e07a3

View file

@ -15,6 +15,7 @@ package WebGUI::Macro;
=cut
use strict;
use 5.010;
use WebGUI::Pluggable;
=head1 NAME
@ -42,24 +43,23 @@ These functions are available from this package:
=cut
#-------------------------------------------------------------------
my $parenthesis;
$parenthesis = qr{
\( # Start with '(',
(?: # Followed by
(?>\\[()]) # Escaped parenthesis
| # or
(?>[^()]) # Non-parenthesis
| # or
(??{ $parenthesis }) # a balanced parenthesis block
)* # zero or more times
\) # Ending with ')'
}x;
my $macro_re = qr{
(\^ # Start with carat
([-a-zA-Z0-9_@#/*]{1,64}) # And one or more non-macro characters -tagged-
((??{ $parenthesis })?) # a balanced parenthesis block
;) # End with a semicolon.
( # capture #1 - entire macro call
\^ # start with carat
([-a-zA-Z0-9_@#/*]{1,64}) # capture #2 - macro name
( # capture #3 - parenthesis
\( # start with open parenthesis
(?: # followed by
(?> [^()] ) # non-parenthesis
| # or
(?>\\[()]) # Escaped parenthesis
| # or
(?3) # a balanced parenthesis block (recursive)
)* # zero or more times
\) # ending with closing parenthesis
)?
; # End with a semicolon.
)
}msx;
=head2 filter ( html )