From 70f4eb714edf0fe0167602a1b78385419ec6eb7e Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Tue, 6 Jul 2010 23:11:24 +0200 Subject: [PATCH] put AST generation for named assertions into a separate method --- src/Regex/P6Regex/Actions.pm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Regex/P6Regex/Actions.pm b/src/Regex/P6Regex/Actions.pm index 51ac397..c9d47fa 100644 --- a/src/Regex/P6Regex/Actions.pm +++ b/src/Regex/P6Regex/Actions.pm @@ -407,14 +407,7 @@ method assertion:sym($/) { ); } else { - $past := PAST::Regex.new( $name, :name($name), - :pasttype('subrule'), :subtype('capture'), :node($/) ); - if $ { - $past.push( buildsub($[0].ast) ); - } - elsif $ { - for $[0].ast.list { $past.push( $_ ); } - } + $past := self.named_assertion($/); } make $past; } @@ -586,3 +579,16 @@ method subrule_alias($past, $name) { else { $past.name($name); } $past.subtype('capture'); } + +method named_assertion($/) { + my $name := ~$; + my $past := PAST::Regex.new( $name, :name($name), + :pasttype('subrule'), :subtype('capture'), :node($/) ); + if $ { + $past.push( buildsub($[0].ast) ); + } + elsif $ { + for $[0].ast.list { $past.push( $_ ); } + } + $past; +}