Skip to content

Commit

Permalink
RakuAST: a fake infix is in fact an adverb
Browse files Browse the repository at this point in the history
So rename fields / methods / dynvars from being fake infixy, to
being an adverb, which better describes why this is needed.
  • Loading branch information
lizmat committed Sep 1, 2023
1 parent b5e9f6f commit 57b92f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/Raku/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ class Raku::Actions is HLL::Actions does Raku::CommonActions {
}
elsif $KEY eq 'POSTFIX' {
if $<colonpair> {
if $*FAKE-INFIX-FOUND && (nqp::istype($/[0].ast, Nodify('ColonPair')) || nqp::istype($/[0].ast, Nodify('ColonPairs'))) {
if $*ADVERB-AS-INFIX && (nqp::istype($/[0].ast, Nodify('ColonPair')) || nqp::istype($/[0].ast, Nodify('ColonPairs'))) {
self.attach: $/, Nodify('ColonPairs').new($/[0].ast, $<colonpair>.ast);
}
else {
Expand Down Expand Up @@ -1246,7 +1246,7 @@ class Raku::Actions is HLL::Actions does Raku::CommonActions {
}

method infixish($/) {
return 0 if $<fake-infix>;
return 0 if $<adverb-as-infix>;

my $ast;
if $<infix> {
Expand Down
27 changes: 14 additions & 13 deletions src/Raku/Grammar.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,8 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
self.actions.comp-unit-prologue($/); # set the above variables
}
:my $*IN-TYPENAME; # fallback for inside typename flag
:my $*FAKE-INFIX-FOUND; # fallback for fake infix handling
:my $*IN-TYPENAME; # fallback for inside typename flag
:my $*ADVERB-AS-INFIX; # fallback for fake infix handling
:my @*LEADING-DOC := []; # temp storage leading declarator doc
:my $*DECLARAND; # target for trailing declarator doc
Expand Down Expand Up @@ -1474,7 +1474,7 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
self.EXPR-reduce(@termstack, @opstack);
}
if nqp::isnull(nqp::atkey(%inO, 'fake')) {
if nqp::isnull(nqp::atkey(%inO, 'adverb')) {
$more_infix := 0;
}
else {
Expand Down Expand Up @@ -1601,6 +1601,7 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
my %conditional := nqp::hash('prec', 'j=', 'assoc', 'right', 'dba', 'conditional', 'fiddly', 1, 'thunky', '.tt');
my %conditional_ff := nqp::hash('prec', 'j=', 'assoc', 'right', 'dba', 'conditional', 'fiddly', 1, 'thunky', 'tt');
my %item_assignment := nqp::hash('prec', 'i=', 'assoc', 'right', 'dba', 'item assignment');
my %adverb := nqp::hash('prec', 'i=', 'assoc', 'unary', 'adverb', 1, 'dba', 'adverb');
my %list_assignment := nqp::hash('prec', 'i=', 'assoc', 'right', 'dba', 'list assignment', 'sub', 'e=', 'fiddly', 1);
my %loose_unary := nqp::hash('prec', 'h=', 'assoc', 'unary', 'dba', 'loose unary');
my %comma := nqp::hash('prec', 'g=', 'assoc', 'list', 'dba', 'comma', 'nextterm', 'nulltermish');
Expand All @@ -1620,17 +1621,17 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
self;
}
token infixish($in_meta = nqp::getlexdyn('$*IN-META')) {
:my $*IN-META := $in_meta;
token infixish($IN-META = nqp::getlexdyn('$*IN-META')) {
:my $*IN-META := $IN-META;
:my $*OPER;
<!stdstopper>
<!infixstopper>
:dba('infix')
[
| <!{ $*IN_REDUCE }>
<colonpair>
<fake-infix>
{ $*OPER := $<fake-infix> }
<adverb-as-infix>
{ $*OPER := $<adverb-as-infix> }
| [
| :dba('bracketed infix')
Expand Down Expand Up @@ -1670,9 +1671,9 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
{ nqp::bindattr_i($<OPER>, NQPMatch, '$!pos', $*OPER.pos) }
}
token fake-infix {
<O(|%item_assignment, :assoc<unary>, :fake<1>, :dba<adverb>)>
{ $*FAKE-INFIX-FOUND := 1 }
token adverb-as-infix {
<O(|%adverb)>
{ $*ADVERB-AS-INFIX := 1 }
}
regex infixstopper {
Expand Down Expand Up @@ -2350,7 +2351,7 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
proto token circumfix {*}
token circumfix:sym<( )> {
:my $*FAKE-INFIX-FOUND := 0;
:my $*ADVERB-AS-INFIX := 0;
:dba('parenthesized expression')
'(' ~ ')' <semilist>
}
Expand All @@ -2361,7 +2362,7 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
}
token circumfix:sym<{ }> {
:my $*FAKE-INFIX-FOUND := 0;
:my $*ADVERB-AS-INFIX := 0;
<?[{]> <pointy-block>
{ $*BORG<block> := $<pointy-block> }
}
Expand Down Expand Up @@ -3825,7 +3826,7 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
token args($*INVOCANT_OK = 0) {
:my $*INVOCANT;
:my $*GOAL := '';
:my $*FAKE-INFIX-FOUND := 0;
:my $*ADVERB-AS-INFIX := 0;
:dba('argument list')
[
| '(' ~ ')' <semiarglist>
Expand Down

0 comments on commit 57b92f0

Please sign in to comment.