Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make sure =code and =for code take newlines and spaces
  • Loading branch information
Mouq committed Feb 20, 2014
1 parent a9cf04d commit c940e3f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/Perl6/Actions.nqp
Expand Up @@ -605,7 +605,10 @@ class Perl6::Actions is HLL::Actions does STDActions {

method pod_block:sym<paragraph_code>($/) {
my $config := $<pod_configuration>.ast;
my @t := Perl6::Pod::merge_twines($<pod_string>);
my @t := [];
for $<pod_line> {
nqp::splice(@t, $_.ast, +@t, 0);
}
my $twine := Perl6::Pod::serialize_array(@t).compile_time_value;
make Perl6::Pod::serialize_object(
'Pod::Block::Code', :content($twine),
Expand All @@ -626,13 +629,24 @@ class Perl6::Actions is HLL::Actions does STDActions {
}

method pod_block:sym<abbreviated_code>($/) {
my @t := Perl6::Pod::merge_twines($<pod_string>);
my @t := [];
for $<pod_line> {
nqp::splice(@t, $_.ast, +@t, 0);
}
my $twine := Perl6::Pod::serialize_array(@t).compile_time_value;
make Perl6::Pod::serialize_object(
'Pod::Block::Code', :content($twine)
).compile_time_value
}

method pod_line ($/) {
my @t := Perl6::Pod::merge_twines($<pod_string>);
@t.push($*W.add_constant(
'Str', 'str', ~$<pod_newline>
).compile_time_value);
make @t;
}

method pod_block:sym<end>($/) {
}

Expand Down
7 changes: 5 additions & 2 deletions src/Perl6/Grammar.nqp
Expand Up @@ -762,8 +762,9 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
$<spaces> = [ \h* ]
'=for' \h+ 'code' {}
:my $*POD_ALLOW_FCODES := 0;
:my $*POD_IN_CODE_BLOCK := 1;
<pod_configuration($<spaces>)> <pod_newline>
[ <!before \h* '=' \w> <pod_string> <pod_newline> ]+
[ <!before \h* '=' \w> <pod_line> ]*
}

token pod_block:sym<abbreviated> {
Expand Down Expand Up @@ -809,9 +810,11 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
:my $*POD_ALLOW_FCODES := 0;
:my $*POD_IN_CODE_BLOCK := 1;
<pod_configuration($<spaces>)> [\h*\n|\h+]
[ <!before \h* '=' \w> <pod_string> <pod_newline> ]+
[ <!before \h* '=' \w> <pod_line> ]*
}

token pod_line { <pod_string>**1 <pod_newline> }

token pod_newline {
\h* [ \n | $ ]
}
Expand Down

0 comments on commit c940e3f

Please sign in to comment.