Skip to content

Commit

Permalink
RakuAST: ready grammar/actions for translation, Part 8
Browse files Browse the repository at this point in the history
Instead of checking for literal strings such as "sub" or "method",
replace these by sub-classable tokens.

Part 8 covers the routine- section as found in
lib/RakuAST/Deparse/L10N/CORE.rakumod
  • Loading branch information
lizmat committed Sep 17, 2023
1 parent cdc7c1d commit 714f2f6
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Raku/Grammar.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,13 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
token prefix-so { so }
token prefix-temp { temp }
token routine-method { method }
token routine-sub { sub }
token routine-regex { regex }
token routine-rule { rule }
token routine-submethod { submethod }
token routine-token { token }
#-------------------------------------------------------------------------------
# Grammar entry point
Expand Down Expand Up @@ -3372,17 +3379,17 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
proto token routine-declarator {*}
token routine-declarator:sym<sub> {
<.sym>
<.routine-sub>
<.end-keyword>
<routine-def=.key-origin('routine-def', 'sub')>
}
token routine-declarator:sym<method> {
<.sym>
<.routine-method>
<.end-keyword>
<method-def=.key-origin('method-def', 'method')>
}
token routine-declarator:sym<submethod> {
<.sym>
<.routine-submethod>
<.end-keyword>
<method-def=.key-origin('method-def', 'submethod')>
}
Expand Down Expand Up @@ -3466,7 +3473,7 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
proto token regex-declarator {*}
token regex-declarator:sym<rule> {
<.sym>
<.routine-rule>
<.kok>
:my %*RX;
:my $*INTERPOLATE := 1;
Expand All @@ -3476,7 +3483,7 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
}
token regex-declarator:sym<token> {
<.sym>
<.routine-token>
<.kok>
:my %*RX;
:my $*INTERPOLATE := 1;
Expand All @@ -3485,7 +3492,7 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
}
token regex-declarator:sym<regex> {
<.sym>
<.routine-regex>
<.kok>
:my %*RX;
:my $*INTERPOLATE := 1;
Expand Down

0 comments on commit 714f2f6

Please sign in to comment.