From 5094077aeddbbce19902fbcc3b63bbefedd18650 Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Tue, 6 Apr 2010 21:28:57 +0200 Subject: [PATCH] port most "Unsupported use of $weird variable" from STD.pm. TimToady++ for coming up with them in the first place I'm not yet convinced they all work (for example I couldn't trigger the one for $@, although the regex seems pretty obvious), but all in all it looks like a net win. --- src/Perl6/Grammar.pm | 191 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) diff --git a/src/Perl6/Grammar.pm b/src/Perl6/Grammar.pm index 05f66a9e89c..bb51eee5160 100644 --- a/src/Perl6/Grammar.pm +++ b/src/Perl6/Grammar.pm @@ -524,6 +524,196 @@ token colonpair { ] } +proto token special_variable { <...> } + +token special_variable:sym<$!{ }> { + '$!{' .*? '}' + <.obs('${ ... } or %! variable', 'smart match against $!')> +} + +token special_variable:sym<$~> { + > + <.obs('$~ variable', 'Form module')> +} + +token special_variable:sym<$`> { + > + <.obs('$` variable', 'explicit pattern before <(')> +} + +token special_variable:sym<$@> { + + <.obs('$@ variable as eval error', '$!')> +} + +# TODO: use actual variable in error message +token special_variable:sym<$#> { + + [ + || \w+ <.obs('$#variable', '@variable.end')> + || <.obs('$# variable', '.fmt')> + ] +} + +token special_variable:sym<$$> { + > + <.obs('$$ variable', '$*PID')> +} +token special_variable:sym<$%> { + + <.obs('$% variable', 'Form module')> +} + +# TODO: $^X and other "caret" variables + +token special_variable:sym<$^> { + > + <.obs('$^ variable', 'Form module')> +} + +token special_variable:sym<$&> { + > + <.obs('$& variable', '$/ or $()')> +} + +token special_variable:sym<$*> { + > + <.obs('$* variable', '^^ and $$')> +} + +token special_variable:sym<$)> { + > + <.obs('$) variable', '$*EGID')> +} + +token special_variable:sym<$-> { + > + <.obs('$- variable', 'Form module')> +} + +token special_variable:sym<$=> { + > + <.obs('$= variable', 'Form module')> +} + +token special_variable:sym<@+> { + > + <.obs('@+ variable', '.to method')> +} + +token special_variable:sym<%+> { + > + <.obs('%+ variable', '.to method')> +} + +token special_variable:sym<$+[ ]> { + '$+[' + <.obs('@+ variable', '.to method')> +} + +token special_variable:sym<@+[ ]> { + '@+[' + <.obs('@+ variable', '.to method')> +} + +token special_variable:sym<@+{ }> { + '@+{' + <.obs('%+ variable', '.to method')> +} + +token special_variable:sym<@-> { + > + <.obs('@- variable', '.from method')> +} + +token special_variable:sym<%-> { + > + <.obs('%- variable', '.from method')> +} + +token special_variable:sym<$-[ ]> { + '$-[' + <.obs('@- variable', '.from method')> +} + +token special_variable:sym<@-[ ]> { + '@-[' + <.obs('@- variable', '.from method')> +} + +token special_variable:sym<%-{ }> { + '@-{' + <.obs('%- variable', '.from method')> +} + +token special_variable:sym<$+> { + > + <.obs('$+ variable', 'Form module')> +} + +token special_variable:sym<$[> { + > + <.obs('$[ variable', 'user-defined array indices')> +} + +token special_variable:sym<$]> { + > + <.obs('$] variable', '$*PERL_VERSION')> +} + +token special_variable:sym<$\\> { + > + <.obs('$\\ variable', "the filehandle's :ors attribute")> +} + +token special_variable:sym<$|> { + > + <.obs('$| variable', ':autoflush on open')> +} + +token special_variable:sym<$:> { + > + <.obs('$: variable', 'Form module')> +} + +token special_variable:sym<$;> { + > + <.obs('$; variable', 'real multidimensional hashes')> +} + +token special_variable:sym<$'> { #' + > + <.obs('$' ~ "'" ~ 'variable', "explicit pattern after )\x3E")> +} + +# TODO: $" + +token special_variable:sym<$,> { + > + <.obs('$, variable', ".join() method")> +} + +token special_variable:sym['$<'] { + ' > + <.obs('$< variable', '$*UID')> +} + +token special_variable:sym«\$>» { + > + <.obs('$> variable', '$*EUID')> +} + +token special_variable:sym<$.> { + > + <.obs('$. variable', "the filehandle's .line method")> +} + +token special_variable:sym<$?> { + > + <.obs('$? variable as child error', '$!')> +} + + token desigilname { [ # | @@ -539,6 +729,7 @@ token variable { }> {} [ | ? + | | $=[\d+] | | $=['$'] $=[<[/_!]>]