Skip to content

Instantly share code, notes, and snippets.

@MasterDuke17
Created March 30, 2025 01:00
Show Gist options
  • Save MasterDuke17/0b0d6085c2c3ce5dfcbebfcd0c15fe9d to your computer and use it in GitHub Desktop.
Save MasterDuke17/0b0d6085c2c3ce5dfcbebfcd0c15fe9d to your computer and use it in GitHub Desktop.
diff --git src/Raku/Grammar.nqp src/Raku/Grammar.nqp
index 015499038..d85ddee5d 100644
--- src/Raku/Grammar.nqp
+++ src/Raku/Grammar.nqp
@@ -3691,10 +3691,10 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
| $<sigil>=['$'] $<desigilname>=[<[/_!¢]>]
# $0
- | <sigil> $<index>=[\d+]
+ | <sigil> $<index>=[\d+] #[<?{ $*IN_DECL }> <.typed-panic: 'X::Syntax::Variable::Numeric'>]?
# $<foo>
- | <sigil> <?[<]> <postcircumfix>
+ | <sigil> <?[<]> <postcircumfix> #[<?{ $*IN_DECL }> <.typed-panic('X::Syntax::Variable::Match')>]?
# 👍
| $<desigilname>=<.sigilless-variable>
@@ -3954,20 +3954,12 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
: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
- ]
+ <variable>
{
$*IN-DECL := '';
$*LEFTSIGIL := self.leading-char unless $*LEFTSIGIL;
- $sigil := $<sigil> ?? $<sigil>.Str !! "";
- $*VARIABLE-NAME := $<sigil> ~ $<twigil> ~ $<desigilname>;
+ $sigil := $<variable><sigil> ?? $<variable><sigil>.Str !! "";
+ $*VARIABLE-NAME := $sigil ~ $<variable><twigil> ~ $<variable><desigilname>;
$/.add-variable($*VARIABLE-NAME);
}
[
@@ -4003,7 +3995,7 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
<.ws> <.constraint-where> <.ws> <EXPR('j')>
{ $where := $<EXPR>.ast }
]?
- <.stub-variable($/, $where)>
+ <.stub-variable($<variable>, $where)>
[
[
<?{ $*VARIABLE.is-attribute }>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment