Permalink
Browse files

Implement <&foo(ARGS)> syntax

  • Loading branch information...
1 parent bca1172 commit b37bff86b51b9124aa16716d81e1eeccc76ae407 @sorear committed Dec 17, 2011
Showing with 16 additions and 4 deletions.
  1. +1 −1 docs/TODO.S05
  2. +11 −3 src/niecza
  3. +4 −0 test2.pl
View
@@ -24,7 +24,7 @@ All line numbers are relative to c4882a67. Also, deliberate discrepencies.)
(1253) No handling of formal parameters in LTM
(1258) No {*} and funky proto handling in general
(1276) Declarativeness of constants is insufficiently general
-(1461) Arguments in <&foo(2)> not handled; STD parses EXPR but only this legal
+(1461) DISCUSS: STD parses EXPR in assertion:variable, why?
(1507) No support for indirect <::($name)> calls
Also, nice fossil.
(1585) <[ z..a ]> not treated as compile error DISCUSS
View
@@ -227,9 +227,17 @@ method assertion:name ($/) {
method assertion:variable ($/) {
given substr($/,0,1) {
when '&' {
- make ::RxOp::Subrule.new(|node($/), regex =>
- ::Op::CallSub.new(|node($/), invocant => $<variable>.ast,
- positionals => [ ::Op::MakeCursor.new(|node($/)) ]));
+ if $<variable>.ast ~~ ::Op::CallSub {
+ make ::RxOp::Subrule.new(|node($/), regex =>
+ ::Op::CallSub.new(|node($/),
+ invocant => $<variable>.ast.invocant,
+ args => [ ::Op::MakeCursor.new(|node($/)),
+ @( $<variable>.ast.args ) ]));
+ } else {
+ make ::RxOp::Subrule.new(|node($/), regex =>
+ ::Op::CallSub.new(|node($/), invocant => $<variable>.ast,
+ positionals => [ ::Op::MakeCursor.new(|node($/)) ]));
+ }
}
when '$' {
make ::RxOp::ListPrim.new(type => 'scalar_asn',
View
@@ -53,6 +53,10 @@
my regex alpha { . }
is ("4e" ~~ /<.alpha>/), "e", "leading dot forces method interpretation";
}
+
+ my regex two($x) { $x $x }
+ is ("xfoofoox" ~~ /<two("foo")>/), "foofoo", "calling lexical regexes like <two> with args works";
+ is ("xfoofoox" ~~ /<&two("foo")>/), "foofoo", "calling lexical regexes like <&two> with args works";
}
{

0 comments on commit b37bff8

Please sign in to comment.