Browse files

Perlito5 - perl6 - refactor_range_operator wip

  • Loading branch information...
1 parent c022193 commit 794f0763ff0fe89a61696a9b0c97472aa3f27a52 @fglock committed Oct 16, 2013
Showing with 44 additions and 0 deletions.
  1. +8 −0 perlito5.pl
  2. +36 −0 src5/lib/Perlito5/Perl6/TreeGrammar.pm
View
8 perlito5.pl
@@ -12289,6 +12289,14 @@ package Perlito5::Perl6::TreeGrammar;
# use Data::Dumper
# use strict
# use Perlito5::TreeGrammar
+sub Perlito5::Perl6::TreeGrammar::refactor_range_operator {
+ die('Unimplemented');
+ my($class, $in) = @_;
+ Perlito5::TreeGrammar::render(['And' => ['Lookup' => 'code', ['Value' => 'infix:<..>']]->['Lookup' => 'arguments', ['And' => ['Index' => 0, ['And' => ['Ref' => 'Perlito5::AST::Val::Int']->['Lookup' => 'int', ['Value' => 0]]]], ['Index' => 1, ['Action' => sub {
+ $in{'name'} = 'p6:prefix:<^>';
+ shift(@{$in->{'arguments'}})
+ }]]]]], $in)
+}
sub Perlito5::Perl6::TreeGrammar::refactor_while_glob {
my($class, $in) = @_;
Perlito5::TreeGrammar::render(['Ref' => 'Perlito5::AST::While', ['Lookup' => 'cond', ['And' => ['Ref' => 'Perlito5::AST::Apply'], ['Lookup' => 'code', ['Value' => 'glob']], ['Action' => sub {
View
36 src5/lib/Perlito5/Perl6/TreeGrammar.pm
@@ -3,6 +3,42 @@ use Data::Dumper;
use strict;
use Perlito5::TreeGrammar;
+sub refactor_range_operator {
+ ...
+ my ($class, $in) = @_;
+ Perlito5::TreeGrammar::render(
+ [ And => [ Lookup => 'code', [ Value => 'infix:<..>' ] ]
+ [ Lookup => 'arguments',
+ [ And => [ Index => 0, [ And => [ Ref => 'Perlito5::AST::Val::Int' ]
+ [ Lookup => 'int', [ Value => 0 ] ]
+ ]
+ ], # first argument is 0
+ [ Index => 1,
+ # TODO 0..$#num to @num.keys
+ [ Action => sub {
+ $in{name} = 'p6:prefix:<^>';
+ shift @{ $in->{arguments} };
+ }
+ ],
+ ],
+ ]
+ ]
+ ],
+ $in
+ );
+
+ # if ( $code eq 'infix:<..>'
+ # && ref($self->{arguments}[0]) eq 'Perlito5::AST::Val::Int'
+ # && ref($self->{arguments}[1]) eq 'Perlito5::AST::Val::Int'
+ # && $self->{arguments}[0]{int} == 0
+ # )
+ # {
+ # # TODO - add formatting tags
+ # return '^' . ($self->{arguments}[1]{int} + 1)
+ # }
+
+}
+
sub refactor_while_glob {
my ($class, $in) = @_;
Perlito5::TreeGrammar::render(

0 comments on commit 794f076

Please sign in to comment.