diff --git a/src/NQP/Actions.pm b/src/NQP/Actions.pm index b0eff31..9c2c51a 100644 --- a/src/NQP/Actions.pm +++ b/src/NQP/Actions.pm @@ -179,6 +179,7 @@ method term:sym($/) { make $.ast; } method term:sym($/) { make $.ast; } method term:sym($/) { make $.ast; } method term:sym($/) { make $.ast; } +method term:sym($/) { make $.ast; } method colonpair($/) { my $past := $ @@ -347,7 +348,7 @@ method parameter($/) { } $past.viviself( $[0].ast ); } - if $past.viviself { @BLOCK[0].arity( +@BLOCK[0].arity + 1 ); } + unless $past.viviself { @BLOCK[0].arity( +@BLOCK[0].arity + 1 ); } make $past; } diff --git a/src/NQP/Grammar.pm b/src/NQP/Grammar.pm index 620401e..e038852 100644 --- a/src/NQP/Grammar.pm +++ b/src/NQP/Grammar.pm @@ -94,11 +94,18 @@ token xblock { } token pblock { - [ || <.panic: 'Missing block'> ] - <.newpad> - + | <.lambda> + <.newpad> + + + | + <.newpad> + + | <.panic: 'Missing block'> } +token lambda { '->' | '<->' } + token block { [ || <.panic: 'Missing block'> ] <.newpad> @@ -180,6 +187,7 @@ token term:sym { } token term:sym { } token term:sym { } token term:sym { } +token term:sym { } token colonpair { ':' @@ -368,6 +376,9 @@ token nulltermish { | } +token infixish { } +token infixstopper { } + token postcircumfix:sym<[ ]> { '[' <.ws> ']' @@ -401,7 +412,7 @@ token infix:sym<**> { ')> } token prefix:sym<+> { ')> } token prefix:sym<~> { ')> } -token prefix:sym<-> { ')> } +token prefix:sym<-> { ]> ')> } token prefix:sym { ')> } token prefix:sym { ')> } diff --git a/t/nqp/39-pointy.t b/t/nqp/39-pointy.t new file mode 100644 index 0000000..4c4f36d --- /dev/null +++ b/t/nqp/39-pointy.t @@ -0,0 +1,18 @@ +#! nqp + +plan(6); + +my $count := 1; + +my $x := -> $a, $b { ok($a == $count++, $b); } + +$x(1, 'basic pointy block'); + +my $y := -> $a, $b = 2 { ok($b == $count++, $a); } + +$y('pointy block with optional'); + +$y('pointy block with optional + arg', 3); + +for <4 pointy4 5 pointy5 6 pointy6> -> $a, $b { ok($a == $count++, $b); } +