1701
1701
if(defined $1) {
1702
1702
if(defined $2) {
1703
1703
DEBUG > 3 and print "Found complex start-text code \"$1\"\n";
1704
# signal that we're looking for simple unless we're in complex.
1706
# We're in complex already. It's just stuff.
1707
DEBUG > 4 and print " It's just stuff.\n";
1708
push @{ $lineage[-1] }, $1;
1710
# length of the necessary complex end-code string
1711
push @stack, length($2) + 1;
1712
push @lineage, [ substr($1,0,1), {}, ]; # new node object
1713
push @{ $lineage[-2] }, $lineage[-1];
1704
push @stack, length($2) + 1;
1705
# length of the necessary complex end-code string
1716
1707
DEBUG > 3 and print "Found simple start-text code \"$1\"\n";
1718
# We're in complex already. It's just stuff.
1719
DEBUG > 4 and print " It's just stuff.\n";
1720
push @{ $lineage[-1] }, $1;
1722
# signal that we're looking for simple.
1724
push @lineage, [ substr($1,0,1), {}, ]; # new node object
1725
push @{ $lineage[-2] }, $lineage[-1];
1708
push @stack, 0; # signal that we're looking for simple
1710
push @lineage, [ substr($1,0,1), {}, ]; # new node object
1711
push @{ $lineage[-2] }, $lineage[-1];
1728
1713
} elsif(defined $4) {
1729
1714
DEBUG > 3 and print "Found apparent complex end-text code \"$3$4\"\n";
1730
1715
# This is where it gets messy...
1829
1814
sub _stringify_lol { # the real recursor
1830
1815
my($lol, $to) = @_;
1832
1816
for(my $i = 2; $i < @$lol; ++$i) {
1833
1817
if( ref($lol->[$i] || '') and UNIVERSAL::isa($lol->[$i], 'ARRAY') ) {
1834
1818
_stringify_lol( $lol->[$i], $to); # recurse!