Skip to content
Browse files

[Ratel] whitespace therapy

  • Loading branch information...
1 parent cb67b53 commit 511ea75671154cd2aaf228c2d1efd4667d6f7eac @masak committed Jun 9, 2010
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/Ratel.pm
View
9 lib/Ratel.pm
@@ -2,19 +2,26 @@ class Ratel {
has $.source;
has $.compiled;
has @.hunks;
+
method load(Str $filename) {
$.compile(slurp($filename));
}
+
method compile(Str $text) {
my $index = 0;
$!source = $text;
my $source = "%]$text[%";
@!hunks = $source.comb(/'%]' (.*?) '[%'/);
- $!compiled = $source.subst(/(['%]' | ^ ] .*? [ $ | '[%' ])/, {";\$.emit-hunk({$index++});"}, :g);
+ $!compiled
+ = $source.subst(/(['%]' | ^ ] .*? [ $ | '[%' ])/,
+ {";\$.emit-hunk({$index++});"},
+ :g);
}
+
method emit-hunk(Int $i) {
print @.hunks[$i][0];
}
+
method do(*%attrs) {
eval $.compiled;
}

0 comments on commit 511ea75

Please sign in to comment.
Something went wrong with that request. Please try again.