passing text by reference and other questions...

[email protected] (Marco Baringer)
Newsgroups perl.recdescent
Message-ID <[email protected]>
RecDescent.pm.diff (text/x-patch, 1.6 KB)
--- /Library/Perl/Parse/RecDescent.pm	Fri Jan 19 19:02:51 2001
+++ RecDescent.pm	Sun Feb 10 14:04:55 2002
@@ -1777,7 +1777,7 @@
 my $COMMITMK		= '\G\s*<commit>';
 my $UNCOMMITMK		= '\G\s*<uncommit>';
 my $QUOTELIKEMK		= '\G\s*<perl_quotelike>';
-my $CODEBLOCKMK		= '\G\s*<perl_codeblock>';
+my $CODEBLOCKMK		= '\G\s*<perl_codeblock(:.*?)?(?<!\\\\)>';
 my $VARIABLEMK		= '\G\s*<perl_variable>';
 my $NOCHECKMK		= '\G\s*<nocheck>';
 my $AUTOTREEMK		= '\G\s*<autotree>';
@@ -1943,11 +1943,22 @@
 			elsif ($grammar =~ m/$CODEBLOCKMK/gco)
 			{
 				_parse("an perl codeblock marker", $aftererror,$line);
+                                my $delimiter = "undef";
+                                my $directive;
+                                if ($1) {
+                                    $directive = "<perl_codeblock$1>";
+                                    $delimiter = $1;
+                                    $delimiter =~ s/\A://;
+                                    $delimiter =~ s/((?<!\\).)/\\$1/g;
+                                    $delimiter = "\"" . $delimiter . "\"";
+                                } else {
+                                    $directive = "<perl_codeblock>";
+                                }
 				$item = new Parse::RecDescent::Directive(
-					'Text::Balanced::extract_codeblock($text,undef,$skip);
-					', $lookahead,$line,"<perl_codeblock>");
+					"Text::Balanced::extract_codeblock(\$text,$delimiter,\$skip);
+					", $lookahead,$line,$directive);
 				$prod and $prod->additem($item)
-				      or  _no_rule("<perl_codeblock>",$line);
+				      or  _no_rule($directive,$line);
 			}
 			elsif ($grammar =~ m/$VARIABLEMK/gco)
 			{
Simple.pm.diff (text/x-patch, 563 B)
--- /Library/Perl/Filter/Simple.pm	Fri Nov 23 20:48:49 2001
+++ Simple.pm	Sun Feb 10 15:07:55 2002
@@ -111,6 +111,11 @@
 				  map { ref $_ ? $;.pack('N',$count++).$; : $_ }
 				      @pieces;
 			@pieces = grep { ref $_ } @pieces;
+                        local *show = sub {
+                            my $text = shift;
+                            $text =~ s/$extractor/${$pieces[unpack('N',$1)]}/g;
+                            return $text;
+                        };
 		        $transform->(@_);
 			s/$extractor/${$pieces[unpack('N',$1)]}/g;
 		     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.