Skip to content

Commit

Permalink
Catch a few more special P5 variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Aug 21, 2013
1 parent bda4465 commit a24bf6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/Perl6/Grammar.nqp
Expand Up @@ -1773,7 +1773,10 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
| :dba('contextualizer') <sigil> '(' ~ ')' <semilist> [<?{ $*IN_DECL }> <.panic: "Cannot declare a contextualizer">]?
| $<sigil>=['$'] $<desigilname>=[<[/_!]>]
| <sigil> <?{ $*IN_DECL }>
| <!{ $*QSIGIL }> <.typed_panic: 'X::Syntax::SigilWithoutName'>
| <!{ $*QSIGIL }> {
$/.CURSOR.typed_panic( 'X::Syntax::Perl5Var',
name => nqp::substr(~$/.orig, $/.to - 1, 3 ) )
}
]
]
[ <?{ $<twigil> && $<twigil>[0] eq '.' }>
Expand Down
8 changes: 5 additions & 3 deletions src/core/Exception.pm
Expand Up @@ -908,12 +908,14 @@ my class X::Syntax::Perl5Var does X::Syntax {

'%-' => '.from method',
'%+' => '.to method',
'%!' => 'your time to implement this',
'%!' => 'your time to implement this in Perl6',
'%^H' => '$?FOO variables',
;
method message() {
"Unsupported use of {$.name} variable"
~ ( %m{$.name} ?? "; in Perl 6 please use {%m{$.name}}" !! '' );
my $v = ~($.name ~~ m/ <[ $ @ % & ]> [ \^ <[ A..Z ]> | \W ] /);
%m{$v}
?? "Unsupported use of {$v} variable; in Perl 6 please use {%m{$v}}"
!! 'Unknown Perl 5 like special variable not supported';
}
}
my class X::Syntax::SigilWithoutName does X::Syntax {
Expand Down

0 comments on commit a24bf6f

Please sign in to comment.