Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MasterDuke17/f81a0a2cfe46be69de9c132e0c450783 to your computer and use it in GitHub Desktop.
Save MasterDuke17/f81a0a2cfe46be69de9c132e0c450783 to your computer and use it in GitHub Desktop.
diff --git src/Raku/Grammar.nqp src/Raku/Grammar.nqp
index 6ac245eb1..821864dd8 100644
--- src/Raku/Grammar.nqp
+++ src/Raku/Grammar.nqp
@@ -3945,25 +3945,29 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
self.typed-sorry('X::Syntax::Reserved', |%args);
}
+ token var-dec {
+ [
+ | <sigil> <twigil>? <desigilname>?
+
+ | $<sigil>=['$'] $<desigilname>=[<[/_!¢]>]
+
+ | $<desigilname>=<.sigilless-variable>
+
+ # TODO cases for when you declare something you're not allowed to
+ ]
+ }
+
token variable-declarator {
:my $*IN-DECL := 'variable';
:my $*VARIABLE;
:my $*VARIABLE-NAME;
:my $sigil;
- [
- | <sigil> <twigil>? <desigilname>?
-
- | $<sigil>=['$'] $<desigilname>=[<[/_!¢]>]
-
- | $<desigilname>=<.sigilless-variable>
-
- # TODO cases for when you declare something you're not allowed to
- ]
+ <var-dec>
{
$*IN-DECL := '';
$*LEFTSIGIL := self.leading-char unless $*LEFTSIGIL;
- $sigil := $<sigil> ?? $<sigil>.Str !! "";
- $*VARIABLE-NAME := $<sigil> ~ $<twigil> ~ $<desigilname>;
+ $sigil := $<var-dec><sigil> ?? $<var-dec><sigil>.Str !! "";
+ $*VARIABLE-NAME := $<var-dec><sigil> ~ $<var-dec><twigil> ~ $<var-dec><desigilname>;
$/.add-variable($*VARIABLE-NAME);
}
[
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment