From d7767e07a398a0e180cf6e491c1b40fec2f6259f Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Thu, 4 Feb 2010 13:52:41 -0600 Subject: [PATCH] faster macro processor using perl 5.10 features --- lib/WebGUI/Macro.pm | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/WebGUI/Macro.pm b/lib/WebGUI/Macro.pm index be83d07bf..c73bf1356 100644 --- a/lib/WebGUI/Macro.pm +++ b/lib/WebGUI/Macro.pm @@ -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 )