[tapx-dev] [commit][281] Tidied parser logic a little
andy at hexten.net
andy at hexten.net
Sun Aug 19 15:18:39 BST 2007
Revision: 281
Author: andy
Date: 2007-08-19 15:18:39 +0100 (Sun, 19 Aug 2007)
Log Message:
-----------
Tidied parser logic a little
Modified Paths:
--------------
trunk/lib/TAP/Parser.pm
Modified: trunk/lib/TAP/Parser.pm
===================================================================
--- trunk/lib/TAP/Parser.pm 2007-08-19 14:17:45 UTC (rev 280)
+++ trunk/lib/TAP/Parser.pm 2007-08-19 14:18:39 UTC (rev 281)
@@ -233,9 +233,14 @@
sub next {
my $self = shift;
- my $result = $self->_next;
+ my $stream = $self->_stream;
+ my $result = eval { $self->_grammar->tokenize };
+ $self->_add_error($@) if $@;
+
if ( defined $result ) {
+ $self->_next_state($result);
+
my $code;
if ( $code = $self->_callback_for( $result->type ) ) {
$code->($result);
@@ -246,9 +251,15 @@
$self->_make_callback( 'ALL', $result );
# Echo TAP to spool file
- $self->_write_to_spool($result);
+ if ( my $spool = $self->_spool ) {
+ print $spool $result->raw, "\n";
+ }
}
else {
+ $self->exit( $stream->exit );
+ $self->wait( $stream->wait );
+ $self->_finish;
+
my $code;
if ( $code = $self->_callback_for('EOF') ) {
$code->($self);
@@ -258,12 +269,6 @@
return $result;
}
-sub _write_to_spool {
- my ( $self, $result ) = @_;
- my $spool = $self->_spool or return;
- print $spool $result->raw, "\n";
-}
-
##############################################################################
=head3 C<run>
@@ -970,25 +975,6 @@
push @{ $self->{failed} } => $num if !$test->is_ok;
}
-sub _next {
- my $self = shift;
- my $stream = $self->_stream;
-
- my $result = eval { $self->_grammar->tokenize };
- $self->_add_error($@) if $@;
-
- if ($result) {
- $self->_next_state($result);
- }
- else {
- $self->exit( $stream->exit );
- $self->wait( $stream->wait );
- $self->_finish;
- }
-
- return $result;
-}
-
my %states;
BEGIN {
More information about the tapx-dev
mailing list