Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
clean up misleading P5 special var warnings
Remove the tests for rare variables, especially those that will become
syntax errors anyway, like $) and friends.  This also allows us to parse
bare sigils as rvalues, so we don't have to distinguish ($a,*,$c) = ...
from my ($a,$,$c) = ... anymore.  That is, if you use a bare $ as an
rvalue, we'll simply declare an anonymous variable for you now.  If we
make the declarator default to 'state', it might even be useful as $++.
  • Loading branch information
TimToady committed Aug 28, 2014
1 parent 3ce25ec commit ce26312
Showing 1 changed file with 15 additions and 47 deletions.
62 changes: 15 additions & 47 deletions src/Perl6/Grammar.nqp
Expand Up @@ -1785,13 +1785,13 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
}

token special_variable:sym<$~> {
<sym> <?before \s | ',' | '=' <terminator> >
<sym> <?before \h* '='>
<.obs('$~ variable', 'Form module')>
}

token special_variable:sym<$`> {
<sym> <?before \s | ',' | <terminator> >
<.obs('$` variable', 'explicit pattern before <(')>
<.obs('$` variable', '$/.prematch')>
}

token special_variable:sym<$@> {
Expand All @@ -1813,14 +1813,14 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
<.obs('$$ variable', '$*PID')>
}
token special_variable:sym<$%> {
<sym> <!before \w | '(' | <sigil> >
<sym> <?before \h* '='>
<.obs('$% variable', 'Form module')>
}

# TODO: $^X and other "caret" variables

token special_variable:sym<$^> {
<sym> <?before \s | ',' | '=' | <terminator> >
<sym> <?before \h* '='>
<.obs('$^ variable', 'Form module')>
}

Expand All @@ -1830,22 +1830,12 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
}

token special_variable:sym<$*> {
<sym> <?before \s | ',' | '=' | <terminator> >
<sym> <?before \h* '='>
<.obs('$* variable', '^^ and $$')>
}

token special_variable:sym<$)> {
<sym> <?{ $*GOAL ne ')' }> <?before \s | ',' | <terminator> >
<.obs('$) variable', '$*EGID')>
}

token special_variable:sym<$-> {
<sym> <?before \s | ',' | '=' | <terminator> >
<.obs('$- variable', 'Form module')>
}

token special_variable:sym<$=> {
<sym> <?before \s | ',' | '=' | <terminator> >
<sym> <?before \h+ '='>
<.obs('$= variable', 'Form module')>
}

Expand Down Expand Up @@ -1899,63 +1889,41 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
<.obs('%- variable', '.from method')>
}

token special_variable:sym<$+> {
<sym> <?before \s | ',' | <terminator> >
<.obs('$+ variable', 'Form module')>
}

token special_variable:sym<$[> {
<sym> <?before \s | ',' | '=' | <terminator> >
<.obs('$[ variable', 'user-defined array indices')>
}

token special_variable:sym<$]> {
<sym> <?before \s | ',' | <terminator> >
<.obs('$] variable', '$*PERL_VERSION')>
}

token special_variable:sym<$\\> {
'$\\' <?before \s | ',' | '=' | <terminator> >
<.obs('$\\ variable', "the filehandle's :ors attribute")>
}

token special_variable:sym<$|> {
<sym> <?before \s | ',' | '=' | <terminator> >
<sym> <?before \h* '='>
<.obs('$| variable', ':autoflush on open')>
}

token special_variable:sym<$:> {
<sym> <?[\x20\t\n\],=)}]>
<sym> <?before \h* '='>
<.obs('$: variable', 'Form module')>
}

token special_variable:sym<$;> {
<sym> <?before \s | ',' | '=' | <terminator> >
<sym> <?before \h* '='>
<.obs('$; variable', 'real multidimensional hashes')>
}

token special_variable:sym<$'> { #'
<sym> <?before \s | ',' | <terminator> >
<.obs('$' ~ "'" ~ 'variable', "explicit pattern after )\x3E")>
<.obs('$' ~ "'" ~ 'variable', "$/.postmatch")>
}

# TODO: $"
token special_variable:sym<$"> {
<sym> <?before \h* '='>
<.obs('$" variable', '.join() method')>
}

token special_variable:sym<$,> {
<sym> <?before \h* <[ = , ; ? : ! ) \] } ]> >
<sym> <?before \h* '='>
<.obs('$, variable', ".join() method")>
}

token special_variable:sym['$<'] {
<sym> <?before \h* <[ = , ; ? : ! ) \] } ]> <!before \S* '>'> >
<.obs('$< variable', '$*UID')>
}

token special_variable:sym«\$>» {
<sym> {} <?before \s | ',' | <terminator> >
<.obs('$> variable', '$*EUID')>
}

token special_variable:sym<$.> {
<sym> {} <?before \s | ',' | <terminator> >
<.obs('$. variable', "the filehandle's .line method")>
Expand Down

0 comments on commit ce26312

Please sign in to comment.