Skip to content

Commit

Permalink
RakuAST: streamline postfix section of grammar
Browse files Browse the repository at this point in the history
- improve readability
- use $*DOTTY dynvar instead of less descriptive $*special
- use new X::QuoteWords::Missing::Closer class
- use more shortcuts to dynvars
- remove some lingering trailing whitespace
  • Loading branch information
lizmat committed Sep 6, 2023
1 parent 24c05ee commit 4fd3450
Show file tree
Hide file tree
Showing 2 changed files with 197 additions and 96 deletions.
28 changes: 15 additions & 13 deletions src/Raku/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ class Raku::Actions is HLL::Actions does Raku::CommonActions {
if ($/.pragma("STOPPER") // '') eq $sym {
$/.worry:
"Ambiguous use of $sym; use "
~ ($<sym> eq '>>' ?? '»' !! '>>')
~ ($sym eq '>>' ?? '»' !! '>>')
~ " instead to mean hyper, or insert whitespace before"
~ " $sym to mean a quote terminator (or use different delimiters?)";
}
Expand Down Expand Up @@ -1146,30 +1146,32 @@ class Raku::Actions is HLL::Actions does Raku::CommonActions {
method methodop($/) {
my $args := $<args> ?? $<args>.ast !! Nodify('ArgList').new();
if $<longname> {
if $*special {
my $longname := $<longname>.ast;
my $longname := $<longname>.ast;
my $name := $longname.canonicalize;

if $*DOTTY {
my $DOTTY := $*DOTTY;
unless $longname.is-identifier {
$/.dotty-non-ident($*special);
$/.dotty-non-ident($DOTTY);
}
my $name := $longname.canonicalize;
if $*special eq '!' {
self.attach: $/, Nodify('Call', 'PrivateMethod').new(:name($<longname>.ast), :$args);
if $DOTTY eq '!' {
self.attach: $/,Nodify('Call','PrivateMethod').new(:name($longname),:$args);
}
elsif $*special eq '.^' {
elsif $DOTTY eq '.^' {
self.attach: $/, Nodify('Call', 'MetaMethod').new(:$name, :$args);
}
elsif $*special eq '.?' {
elsif $DOTTY eq '.?' {
self.attach: $/, Nodify('Call', 'MaybeMethod').new(:$name, :$args);
}
elsif $*special eq '.&' {
self.attach: $/, Nodify('Call', 'VarMethod').new(:name($<longname>.ast), :$args);
elsif $DOTTY eq '.&' {
self.attach: $/, Nodify('Call', 'VarMethod').new(:name($longname), :$args);
}
else {
nqp::die("Missing compilation of $*special");
nqp::die("Missing compilation of $DOTTY");
}
}
else {
self.attach: $/, Nodify('Call', 'Method').new(:name($<longname>.ast), :$args);
self.attach: $/, Nodify('Call', 'Method').new(:name($longname), :$args);
}
}
elsif $<quote> {
Expand Down

0 comments on commit 4fd3450

Please sign in to comment.