Author: jonathan
Date: Wed Jan 14 09:50:46 2009
New Revision: 35535
Modified:
trunk/languages/perl6/src/parser/actions.pm
trunk/languages/perl6/src/parser/grammar.pg
Log:
[rakudo] Handle the case where we have something like multi foo(::T) { ... } or role Foo[::T] { ... }. Added an assertion that isn't in STD.pm, but makes things somewhat easier when building the AST (otherwise we'd get a bogus empty node in the Signature - maybe STD.pm avoids this in some other way, but I can't quite see how).
Modified: trunk/languages/perl6/src/parser/actions.pm
==============================================================================
--- trunk/languages/perl6/src/parser/actions.pm (original)
+++ trunk/languages/perl6/src/parser/actions.pm Wed Jan 14 09:50:46 2009
@@ -1120,6 +1120,18 @@
my $sigil := $<param_var><sigil>;
my $quant := $<quant>;
+ ## if it was type a type capture and nothing else, need to make a PAST::Var
+ unless $<param_var> {
+ unless $<type_constraint> == 1 {
+ $/.panic("Invalid signature; cannot have two consecutive parameter separators.");
+ }
+ our @?BLOCK;
+ my $name := ~$<type_constraint>[0];
+ $var := PAST::Var.new( :scope('parameter') );
+ $var.name($var.unique());
+ @?BLOCK[0].symbol( $var.name(), :scope('lexical') );
+ }
+
## handle slurpy and optional flags
if $quant eq '*' {
$var.slurpy( $sigil eq '@' || $sigil eq '%' );
Modified: trunk/languages/perl6/src/parser/grammar.pg
==============================================================================
--- trunk/languages/perl6/src/parser/grammar.pg (original)
+++ trunk/languages/perl6/src/parser/grammar.pg Wed Jan 14 09:50:46 2009
@@ -493,6 +493,11 @@
| $<named>=[':'?]
<param_var>
$<quant>=[ <[ ? ! ]>? ]
+ | <?{{
+ $I0 = match['type_constraint']
+ $I0 = $I0 > 0
+ .return ($I0)
+ }}> <?>
]
<trait>*
<post_constraint>*