[Cpan-forum-commit] rev 50 - in trunk: . lib/CPAN/Forum

svn at pti.co.il svn at pti.co.il
Tue Feb 1 22:30:13 IST 2005


Author: gabor
Date: 2005-02-01 22:30:12 +0200 (Tue, 01 Feb 2005)
New Revision: 50

Modified:
   trunk/lib/CPAN/Forum/Markup.pm
   trunk/parse.pl
Log:
use the newly built in parser in the testing script as well

Modified: trunk/lib/CPAN/Forum/Markup.pm
===================================================================
--- trunk/lib/CPAN/Forum/Markup.pm	2005-02-01 20:25:21 UTC (rev 49)
+++ trunk/lib/CPAN/Forum/Markup.pm	2005-02-01 20:30:12 UTC (rev 50)
@@ -36,10 +36,15 @@
 	return $self;
 }
 
+sub parser {
+	my ($self) = @_;
+	return Parse::RecDescent->new($self->{grammar});
+}
+
 sub posting_process {
 	my ($self, $text) = @_;
 
-	my $parser = new Parse::RecDescent ($self->{grammar});
+	my $parser = $self->parser;
 	if (not $parser) {
 		warn "Bad Grammar\n";
 		return;

Modified: trunk/parse.pl
===================================================================
--- trunk/parse.pl	2005-02-01 20:25:21 UTC (rev 49)
+++ trunk/parse.pl	2005-02-01 20:30:12 UTC (rev 50)
@@ -1,39 +1,15 @@
 #!/usr/bin/perl
 use strict;
 use warnings;
-use CGI qw();
 
-
 # this script is only used to prepare the new parser behind the system.
 # It will be deleted once it is deployed
 
-use Parse::RecDescent;
+use lib "lib";
+use CPAN::Forum::Markup;
+my $markup = CPAN::Forum::Markup->new();
+my $parser = $markup->parser;
 
-my $grammar = q {
-	entry      : chunk(s) eodata                  { $item[1] }
-	chunk      : marked_html | marked_code        { $item[1] }
-
-	marked_html: html(s)                          { qq(<div class="text">) . join("", @{$item[1]}) . qq(</div>); }
-	html       : text                             { $item[1] } 
-	           | open_b text close_b              { join "", @item[1..$#item] }
-	           | open_i text close_i              { join "", @item[1..$#item] }
-	open_b     : m{<b>}
-	close_b    : m{</b>}
-	open_i     : m{<i>}
-	close_i    : m{</i>}
-	text       : m{[\t\n -;=?-~]+}                {$item[1] }
-
-	marked_code: open_code code close_code        { join("", @item[1..$#item]) }
-	open_code  : m{<code>}                        { qq(<div class="code">) }
-	close_code : m{</code>}                       { qq(</div>) }
-	code       : m{[\t\n -~]+?(?=</code>)}        { CGI::escapeHTML($item[1]) }
-
-	eodata     : m{^\Z}
-};
-
-$Parse::RecDescent::skip = '';
-my $parser = new Parse::RecDescent ($grammar) or die "Bad Grammar\n";
-
 my $code = q(
 #!/usr/bin/perl
 



More information about the Cpan-forum-commit mailing list