Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix nested blocks, import more tests for that
  • Loading branch information
Tadeusz Sośnierz committed Jul 7, 2011
1 parent 75c79fb commit 13ce60f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
23 changes: 13 additions & 10 deletions src/Perl6/Actions.pm
Expand Up @@ -229,10 +229,16 @@ class Perl6::Actions is HLL::Actions {
make $child;
}

method pod_content:sym<block>($/) {
make $<pod_block>.ast;
}

method pod_block:sym<delimited>($/) {
make self.any_block($/);
}

method any_block($/) {
my $name := $*ST.add_constant('Str', 'str', $<type>.Str);
#say("LOL BLOCK: ", $<type>.Str);
#say(" CONTENTS: '", $/.Str, "'");
my @children := [];
for $<pod_content> {
# not trivial, for it can be either an array or a pod node
Expand All @@ -244,7 +250,6 @@ class Perl6::Actions is HLL::Actions {
@children.push($_);
}
} else {
#say("'", $_, "' became ", $_.ast);
@children.push($_.ast);
}
}
Expand All @@ -257,23 +262,21 @@ class Perl6::Actions is HLL::Actions {
:name($name<compile_time_value>),
:content($content<compile_time_value>),
);
#say("block, returning ", $past<compile_time_value>);
make $past<compile_time_value>;
return $past<compile_time_value>;
}

method pod_content:sym<text>($/) {
my @ret := [];
for $<pod_textcontent> {
my $past := $*ST.add_constant(
'Str', 'str', $_.ast
);
@ret.push($past<compile_time_value>);
@ret.push($_.ast);
}
make @ret;
}

method pod_textcontent:sym<regular>($/) {
make self.formatted_text($<text>.Str);
my $t := self.formatted_text($<text>.Str);
my $past := $*ST.add_constant('Str', 'str', $t);
make $past<compile_time_value>;
}

method formatted_text($a) {
Expand Down
12 changes: 11 additions & 1 deletion t/pod/01-delimited.t
Expand Up @@ -39,4 +39,14 @@ is $r.name, 'foo', 'name is ok';
is $r.content[0], "paragraph one", 'paragraphs ok, 1/2';
is $r.content[1], "paragraph two", 'paragraphs ok, 2/2';

done;
=begin something
=begin somethingelse
toot tooot!
=end somethingelse
=end something

$r = $POD[4];
is $r.name, 'something', 'parent name ok';
isa_ok $r.content[0], Pod__Block, "nested blocks work";
is $r.content[0].content[0], "toot tooot!", "and their content";
is $r.content[0].name, 'somethingelse', 'child name ok';done;

0 comments on commit 13ce60f

Please sign in to comment.