Skip to content

Commit

Permalink
Start parsing @A[3;3] syntax.
Browse files Browse the repository at this point in the history
Also tighten things up a bit with regard to shapes; we now only permit
{...} shapes on a % sigil'd thing and [...] shapes and an @ sigil'd
thing. Anything else is considered reserved for the future.
  • Loading branch information
jnthn committed Sep 9, 2015
1 parent fe5ef83 commit ae65104
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Perl6/Grammar.nqp
Expand Up @@ -2405,18 +2405,19 @@ grammar Perl6::Grammar is HLL::Grammar does STD {

token variable_declarator {
:my $*IN_DECL := 'variable';
:my $sigil;
<variable>
{
$*VARIABLE := $<variable>.Str;
$/.CURSOR.add_variable($*VARIABLE);
$sigil := nqp::substr($*VARIABLE, 0, 1);
$*IN_DECL := '';
}
[
<.unsp>?
$<shape>=[
| '(' ~ ')' <signature>
{
my $sigil := nqp::substr($*VARIABLE, 0, 1);
if $sigil eq '&' {
self.typed_sorry('X::Syntax::Reserved',
reserved => '() shape syntax in routine declarations',
Expand All @@ -2436,8 +2437,12 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
reserved => '() shape syntax in variable declarations');
}
}
| :dba('shape definition') '[' ~ ']' <semilist> <.NYI: "Shaped variable declarations">
| :dba('shape definition') '[' ~ ']' <semilist>
{ $sigil ne '@' && self.typed_sorry('X::Syntax::Reserved',
reserved => '[] shape syntax with the ' ~ $sigil ~ ' sigil') }
| :dba('shape definition') '{' ~ '}' <semilist>
{ $sigil ne '%' && self.typed_sorry('X::Syntax::Reserved',
reserved => '{} shape syntax with the ' ~ $sigil ~ ' sigil') }
| <?[<]> <postcircumfix> <.NYI: "Shaped variable declarations">
]+
]?
Expand Down

0 comments on commit ae65104

Please sign in to comment.