Permalink
Browse files

Allow $/ in subrule arg lists

  • Loading branch information...
1 parent e7c2875 commit 5f8e944c142d62e9653375a1fa1311ab20c4195d @sorear committed Oct 23, 2010
Showing with 32 additions and 16 deletions.
  1. +19 −14 src/Niecza/Actions.pm
  2. +10 −0 test2.pl
  3. +3 −2 v6/TODO
View
@@ -762,22 +762,27 @@ sub assertion__S_name { my ($cl, $M) = @_;
"Qualified method calls NYI");
if ($M->{assertion}[0]) {
$M->{_ast} = $M->{assertion}[0]{_ast};
+ } elsif ($name eq 'sym') {
+ $M->{_ast} = RxOp::Sym->new;
+ return;
+ } elsif ($name eq 'before') {
+ $M->{_ast} = RxOp::Before->new(zyg => [$M->{nibbler}[0]{_ast}]);
+ return;
+ } elsif (!$M->{nibbler}[0] && !$M->{arglist}[0]) {
+ $M->{_ast} = RxOp::Subrule->new(method => $name);
} else {
- if ($name eq 'sym') {
- $M->{_ast} = RxOp::Sym->new;
- return;
- } elsif ($name eq 'before') {
- $M->{_ast} = RxOp::Before->new(zyg => [$M->{nibbler}[0]{_ast}]);
- return;
- }
+ my $args = $M->{nibbler}[0] ?
+ [ $cl->op_for_regex($M, $M->{nibbler}[0]{_ast}) ] :
+ $M->{arglist}[0]{_ast};
- if ($M->{nibbler}[0]) {
- $M->{_ast} = RxOp::Subrule->new(method => $name,
- arglist => [ $cl->op_for_regex($M, $M->{nibbler}[0]{_ast}) ]);
- } else {
- my $args = ($M->{arglist}[0] ? $M->{arglist}[0]{_ast} : []);
- $M->{_ast} = RxOp::Subrule->new(arglist => $args, method => $name);
- }
+ my $callop = Op::CallMethod->new(
+ receiver => Op::Lexical->new(name => ''),
+ name => $name,
+ args => $args);
+
+ my $regex = $cl->transparent($M, $callop, sig => Sig->simple(''));
+
+ $M->{_ast} = RxOp::Subrule->new(regex => $regex);
}
$M->{_ast} = $cl->rxcapturize($M, $name, $M->{_ast});
}
View
@@ -58,6 +58,16 @@
ok "abcabc" ~~ /^ (\w+) $0 $/, '$/ in variable refs functional';
ok "abcabc" ~~ /^ (\w+) "$0" $/, '$/ in substrings functional';
+
+ (grammar {
+ method moo($cap) { is $cap<cap>, "hi", '$/ from subrule args works'; @( self, ) }
+ token TOP { $<cap>={"hi"} <moo($/)> }
+ }).parse("");
+
+ #ok (grammar {
+ # method moo() { self }
+ # regex TOP { <.moo> }
+ #}).parse(""), "simply returning self from a regex works";
}
# {
View
@@ -4,10 +4,10 @@ Cursor.mixin
Parcel.LISTSTORE
Highwater stuff
Audit nibble
-self in regexes
$/ and $¢ in subrule argument lists
<after>
token { $param-role-var }
+Fix simply returning self from a method
NOT NEEDED FOR #phasers:
Cursor.canonicalize_name
@@ -20,7 +20,6 @@ Cursor.gettrait
Cursor.load_lex
Cursor.add_categorical
Action methods
-Make sure / (\w+) $0 / works
Non-string parameterized role arguments
DONE:
@@ -41,9 +40,11 @@ defined($thing)
:delete
:exists
$*FOO as a parameter
+self in regexes
func(|($key => $value))
gt, lt, leg, etc
$*GOAL handling
+Make sure / (\w+) $0 / works
Hash.keys &keys
Hash.LISTSTORE
infix:<x>

0 comments on commit 5f8e944

Please sign in to comment.