[svn:parrot] r48258 - in branches/tt1725_headerizer_documentation: lib/Parrot t/perl
jkeenan at svn.parrot.org
jkeenan at svn.parrot.org
Tue Aug 3 02:15:55 UTC 2010
Author: jkeenan
Date: Tue Aug 3 02:15:55 2010
New Revision: 48258
URL: https://trac.parrot.org/parrot/changeset/48258
Log:
A little refactoring as we get started writing tests.
Modified:
branches/tt1725_headerizer_documentation/lib/Parrot/Headerizer.pm
branches/tt1725_headerizer_documentation/t/perl/Parrot_Headerizer.t
Modified: branches/tt1725_headerizer_documentation/lib/Parrot/Headerizer.pm
==============================================================================
--- branches/tt1725_headerizer_documentation/lib/Parrot/Headerizer.pm Tue Aug 3 02:15:03 2010 (r48257)
+++ branches/tt1725_headerizer_documentation/lib/Parrot/Headerizer.pm Tue Aug 3 02:15:55 2010 (r48258)
@@ -2,6 +2,7 @@
# $Id$
package Parrot::Headerizer;
+use Data::Dumper;$Data::Dumper::Indent=1;
=head1 NAME
@@ -106,23 +107,26 @@
my $self = shift;
my $text = shift;
- # Only check the YACC C code if we find what looks like YACC file
- $text =~ s/%\{(.*)%\}.*/$1/sm;
-
- # Drop all text after HEADERIZER STOP
- $text =~ s{/\*\s*HEADERIZER STOP.+}{}s;
-
- # Strip blocks of comments
- $text =~ s{^/\*.*?\*/}{}mxsg;
-
- # Strip # compiler directives
- $text =~ s{^#(\\\n|.)*}{}mg;
-
- # Strip code blocks
- $text =~ s/^{.+?^}//msg;
-
- # Split on paragraphs
- my @funcs = split /\n{2,}/, $text;
+# # Only check the YACC C code if we find what looks like YACC file
+# $text =~ s/%\{(.*)%\}.*/$1/sm;
+#
+# # Drop all text after HEADERIZER STOP
+# $text =~ s{/\*\s*HEADERIZER STOP.+}{}s;
+#
+# # Strip blocks of comments
+# $text =~ s{^/\*.*?\*/}{}mxsg;
+#
+# # Strip # compiler directives
+# $text =~ s{^#(\\\n|.)*}{}mg;
+#
+# # Strip code blocks
+# $text =~ s/^{.+?^}//msg;
+#
+# # Split on paragraphs
+# my @funcs = split /\n{2,}/, $text;
+ my @funcs = _text2funcs( $text );
+print STDERR Dumper \@funcs;
+print STDERR "Saw ", scalar @funcs, " funcs\n";
# If it doesn't start in the left column, it's not a func
@funcs = grep { /^\S/ } @funcs;
@@ -351,6 +355,27 @@
return;
}
+sub _text2funcs {
+ my $text = shift;
+ # Only check the YACC C code if we find what looks like YACC file
+ $text =~ s/%\{(.*)%\}.*/$1/sm;
+
+ # Drop all text after HEADERIZER STOP
+ $text =~ s{/\*\s*HEADERIZER STOP.+}{}s;
+
+ # Strip blocks of comments
+ $text =~ s{^/\*.*?\*/}{}mxsg;
+
+ # Strip # compiler directives
+ $text =~ s{^#(\\\n|.)*}{}mg;
+
+ # Strip code blocks
+ $text =~ s/^{.+?^}//msg;
+
+ # Split on paragraphs
+ return split /\n{2,}/, $text;
+}
+
1;
# Local Variables:
Modified: branches/tt1725_headerizer_documentation/t/perl/Parrot_Headerizer.t
==============================================================================
--- branches/tt1725_headerizer_documentation/t/perl/Parrot_Headerizer.t Tue Aug 3 02:15:03 2010 (r48257)
+++ branches/tt1725_headerizer_documentation/t/perl/Parrot_Headerizer.t Tue Aug 3 02:15:55 2010 (r48258)
@@ -6,6 +6,8 @@
use warnings;
use lib qw( lib );
+use Cwd;
+use Parrot::Distribution;
use Test::More qw(no_plan); # tests => 26;
=head1 NAME
@@ -33,6 +35,13 @@
my @valid_macros = $headerizer->valid_macros();
ok( @valid_macros, 'sanity check: at least one valid macro exists' );
+my $DIST = Parrot::Distribution->new;
+my $cwd = cwd();
+my $path = qq|$cwd/t/perl/testlib/dummy_imcc.y|;
+my $buf = $DIST->slurp($path);
+#print STDERR $buf;
+my @function_decls = $headerizer->extract_function_declarations($buf);
+
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
More information about the parrot-commits
mailing list