Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
X::Syntax::Reserved
  • Loading branch information
moritz committed Feb 24, 2012
1 parent 1ccc79f commit 8a29c50
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
15 changes: 11 additions & 4 deletions src/Perl6/Grammar.pm
Expand Up @@ -1450,16 +1450,23 @@ grammar Perl6::Grammar is HLL::Grammar {
{
my $sigil := nqp::substr($var, 0, 1);
if $sigil eq '&' {
$/.CURSOR.panic("The () shape syntax in routine declarations is reserved (maybe use :() to declare a longname?)");
$*W.throw($/, 'X::Syntax::Reserved',
reserved => '() shape syntax in routine declarations',
instead => ' (maybe use :() to declare a longname?)'
);
}
elsif $sigil eq '@' {
$/.CURSOR.panic("The () shape syntax in array declarations is reserved");

$*W.throw($/, 'X::Syntax::Reserved',
reserved => '() shape syntax in array declarations');
}
elsif $sigil eq '%' {
$/.CURSOR.panic("The () shape syntax in hash declarations is reserved");
$*W.throw($/, 'X::Syntax::Reserved',
reserved => '() shape syntax in hash declarations');
}
else {
$/.CURSOR.panic("The () shape syntax in variable declarations is reserved");
$*W.throw($/, 'X::Syntax::Reserved',
reserved => '() shape syntax in variable declarations');
}
}
| '[' ~ ']' <semilist> <.panic: "Shaped variable declarations are not yet implemented">
Expand Down
10 changes: 8 additions & 2 deletions src/core/Exceptions.pm
Expand Up @@ -187,7 +187,13 @@ my class X::Syntax::Name::Null does X::Syntax {
}

my class X::Syntax::UnlessElse does X::Syntax {
method message() { 'unless does not take "else", please rewrite using "if"' }
method message() { '"unless" does not take "else", please rewrite using "if"' }
}

my class X::Syntax::Reserved does X::Syntax {
has $.reserved;
has $.instead = '';
method message() { "The $.reserved is reserved$.instead" }
}

my class X::Syntax::P5 does X::Syntax {
Expand All @@ -200,7 +206,7 @@ my class X::Syntax::NegatedPair does X::Syntax {

my class X::Syntax::Variable::Numeric does X::Syntax {
has $.what = 'variable';
method message() { "Cannot declare a numeric $.what" }
method message() { "Cannot declare a numeric variable" }

This comment has been minimized.

Copy link
@zhuomingliang

zhuomingliang Feb 24, 2012

Contributor

$.what is not used, maybe it's wrong here.

This comment has been minimized.

Copy link
@moritz

moritz Feb 24, 2012

Author Member

That part of the commit should have gone into the previous commit 1ccc79f

This comment has been minimized.

Copy link
@zhuomingliang

zhuomingliang Feb 24, 2012

Contributor

the previous commit throws "Cannot declare a numeric parameter", but method message() { "Cannot declare a numeric variable" } can't output "Cannot declare a numeric parameter".

}

my class X::Syntax::Variable::Match does X::Syntax {
Expand Down

0 comments on commit 8a29c50

Please sign in to comment.