Subject: | HOP::Parser breaks when using HOP::Stream 0.02 |
When using HOP::Stream, 0.02 HOP::Parser 0.01 does not pass its test suite
because of the change from arrays to blessed arrays.
The attached patch seems to correct the problem. Although, it would
probably be better to export is_node() in HOP::Stream and use that for
test in look_for(). The patch as submitted does not require any changes
to HOP::Stream and should work with both HOP::Stream 0.02 and
HOP::Stream 0.01
-r
Subject: | parse.patch |
diff -ur HOP-Parser-0.01/lib/HOP/Parser.pm HOP-Parser-0.01.new/lib/HOP/Parser.pm
--- HOP-Parser-0.01/lib/HOP/Parser.pm 2005-10-28 20:19:15.000000000 -0400
+++ HOP-Parser-0.01.new/lib/HOP/Parser.pm 2008-07-03 08:21:56.000000000 -0400
@@ -4,7 +4,7 @@
use strict;
use base 'Exporter';
-use HOP::Stream qw/drop tail head/;
+use HOP::Stream qw/drop tail head node/;
our %N;
@@ -211,6 +211,8 @@
$wanted = [$wanted] unless ref $wanted;
my $parser = parser {
my $input = shift;
+ $input = node(@$input) if ref($input) eq 'ARRAY';
+
unless ( defined $input ) {
die [ 'TOKEN', $input, $wanted ];
}
@@ -231,7 +233,8 @@
# Otherwise, the AoA stream might just return an aref for
# the tail instead of an AoA. This breaks things
my $tail = tail($input);
- if ( 'ARRAY' eq ref $tail && 'ARRAY' ne ref $tail->[0] ) {
+ if ( ('HOP::Stream' eq ref $tail && 'HOP::Stream' ne ref $tail->[0]) ||
+ ('ARRAY' eq ref $tail && 'ARRAY' ne ref $tail->[0]) ) {
$tail = [$tail];
}
return ( $wanted_value, $tail );
Only in HOP-Parser-0.01.new/lib/HOP: .Parser.pm.swp