From eb8fea816f55e895714c9c1062d3f90e2a999ef2 Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Tue, 12 Sep 2023 12:23:53 +0200 Subject: [PATCH] RakuAST: streamline special-variable tokens This is mostly about not needing to capture for the error message. --- src/Raku/Grammar.nqp | 62 +++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/src/Raku/Grammar.nqp b/src/Raku/Grammar.nqp index e76efc14f2e..1301532dc2f 100644 --- a/src/Raku/Grammar.nqp +++ b/src/Raku/Grammar.nqp @@ -2728,21 +2728,25 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common { } token coloncircumfix($front) { - # reset $*IN-DECL in case this colonpair is part of var we're + # Reset $*IN-DECL in case this colonpair is part of var we're # declaring, since colonpair might have other vars. Don't make those # think we're declaring them :my $*IN-DECL := ''; [ - | '<>' <.worry("Pair with <> really means an empty list, not null string; use :$front" ~ "('') to represent the null string,\n or :$front" ~ "() to represent the empty list more accurately")> - | {} + | '<>' + <.worry: "Pair with <> really means an empty list, not null string; use :$front" ~ "('') to represent the null string,\n or :$front" ~ "() to represent the empty list more accurately"> + + | {} + ] } token colonpair-variable { - {} + + {} [ - | ? - | $='<' '>' + | ? + | $='<' '>' ] } @@ -2757,38 +2761,38 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common { } token special-variable:sym<$`> { - > + <.sym> > <.obsvar('$`')> } token special-variable:sym<$@> { - <[ \s ; , ) ]> . + <.sym> <[ \s ; , ) ]> . <.obsvar('$@')> } token special-variable:sym<$#> { - + <.sym> {} <.obsvar('$#', ~$)> } token special-variable:sym<$$> { - \W + <.sym> \W <.obsvar('$$')> } token special-variable:sym<$&> { - > + <.sym> > <.obsvar('$&')> } token special-variable:sym<@+> { - > + <.sym> > <.obsvar('@+')> } token special-variable:sym<%+> { - > + <.sym> > <.obsvar('%+')> } @@ -2808,12 +2812,12 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common { } token special-variable:sym<@-> { - > + <.sym> > <.obsvar('@-')> } token special-variable:sym<%-> { - > + <.sym> > <.obsvar('%-')> } @@ -2833,7 +2837,7 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common { } token special-variable:sym<$/> { - > + <.sym> > <.obsvar('$/')> } @@ -2843,54 +2847,58 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common { } token special-variable:sym<$|> { - + <.sym> <.obsvar('$|')> } token special-variable:sym<$;> { - + <.sym> <.obsvar('$;')> } token special-variable:sym<$'> { #' - > + <.sym> > <.obsvar('$' ~ "'")> } token special-variable:sym<$"> { - + <.sym> <.obsvar('$"')> } token special-variable:sym<$,> { - + <.sym> <.obsvar('$,')> } token special-variable:sym<$.> { - {} + <.sym> {} <.obsvar('$.')> } token special-variable:sym<$?> { - {} + <.sym> {} <.obsvar('$?')> } token special-variable:sym<$]> { - {} + <.sym> {} <.obsvar('$]')> } regex special-variable:sym<${ }> { - '{' {} $=[.*?] '}' + + '{' + {} + $=[.*?] + '}' ~~ / [ '=>' | '⇒' ] || ':'<:alpha> || '|%' / }> ~~ / ^ \s* $ / }> .Str; - my $text := $.Str; - my $bad := $sigil ~ '{' ~ $text ~ '}'; + my $text := $.Str; + my $bad := $sigil ~ '{' ~ $text ~ '}'; if $text ~~ /^\d+$/ { $text := nqp::radix(10, $text, 0, 0)[0]; $text := $text - 1 if $text > 0;