Browse files

Merge pull request #189 from timo/heredoc_tabs

make sure that tabs in heredocs get properly dedented.
  • Loading branch information...
2 parents 09953c2 + e8320df commit 33403622a6d20cf3b5936dbfd46037039bf1f4cb @moritz moritz committed Aug 5, 2013
Showing with 14 additions and 1 deletion.
  1. +14 −1 src/Perl6/Actions.nqp
View
15 src/Perl6/Actions.nqp
@@ -14,7 +14,20 @@ role STDActions {
method trim_heredoc($doc, $stop, $origast) {
$origast.pop();
$origast.pop();
- my int $indent := -nqp::chars($stop.MATCH<ws>.Str);
+
+ my str $ws := $stop.MATCH<ws>.Str;
+ my int $actualchars := nqp::chars($ws);
+ my int $indent := -$actualchars;
+
+ my int $tabstop := $*W.find_symbol(['$?TABSTOP']);
+ my int $checkidx := 0;
+ while $checkidx < $actualchars {
+ if nqp::substr($ws, $checkidx, 1) eq "\t" {
+ $indent := $indent - ($tabstop - 1);
+ }
+ $checkidx := $checkidx + 1;
+ }
+
my $docast := $doc.MATCH.ast;
if $docast.has_compile_time_value {
my $dedented := nqp::unbox_s($docast.compile_time_value.indent($indent));

0 comments on commit 3340362

Please sign in to comment.