Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simplify ;; parsing in signature handling
Fixes #125502, already has a test
  • Loading branch information
lizmat committed Jun 28, 2015
1 parent 8e82716 commit 24236f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/Perl6/Actions.nqp
Expand Up @@ -3809,20 +3809,15 @@ Compilation unit '$file' contained the following violations:
my %signature;
my @parameter_infos;
my int $param_idx := 0;
my int $multi_invocant := 1;
for $<parameter> {
my %info := $_.ast;
%info<is_multi_invocant> := $multi_invocant;
my $sep := @*seps[$param_idx];
if ~$sep eq ':' {
if $param_idx != 0 {
$*W.throw($/, 'X::Syntax::Signature::InvocantMarker')
}
%info<is_invocant> := 1;
}
elsif ~$sep eq ';;' {
$multi_invocant := 0;
}
@parameter_infos.push(%info);
$param_idx := $param_idx + 1;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Perl6/Grammar.nqp
Expand Up @@ -2583,8 +2583,8 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
'' $<sep>=[','|':'|';;'|';'] {
if $<sep> eq ';;' {
$/.CURSOR.panic("Can only specify ';;' once in a signature")
if $*seen_semicoloncolon;
$*seen_semicoloncolon := 1;
if $*multi_invocant == 0;
$*multi_invocant := 0;
}
@*seps.push($<sep>);
}
Expand All @@ -2609,7 +2609,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token signature {
:my $*IN_DECL := 'sig';
:my $*zone := 'posreq';
:my $*seen_semicoloncolon := 0;
:my $*multi_invocant := 1;
:my @*seps := nqp::list();
:my $*INVOCANT_OK := 1;
<.ws>
Expand Down Expand Up @@ -2695,6 +2695,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
$*zone := 'var';
}

%*PARAM_INFO<is_multi_invocant> := $*multi_invocant;
%*PARAM_INFO<node> := $/;
}
}
Expand Down

0 comments on commit 24236f4

Please sign in to comment.