Skip to content

Commit f90a081

Browse files
committed
Fix interaction of action methods and ::(...).
This gets custom circumfixes working again in categorically-better.
1 parent d3b8c89 commit f90a081

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/NQP/Grammar.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ grammar NQP::Grammar is HLL::Grammar {
562562
{
563563
%*RX<s> := $<sym> eq 'rule';
564564
%*RX<r> := $<sym> eq 'token' || $<sym> eq 'rule';
565-
%*RX<name> := $<deflongname>.ast if $<deflongname>;
565+
%*RX<name> := $<deflongname> ?? $<deflongname>.ast !! "!!LATENAME!!" ~ ~$<latename>;
566566
}
567567
'{'<p6regex=.LANG('Regex','nibbler')>'}'<?ENDSTMT>
568568
]

src/QAST/Compiler.nqp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,11 @@ class QAST::Compiler is HLL::Compiler {
13221322
my $name := self.escape($node.name());
13231323
$ops.push_pirop('callmethod', '"!cursor_pass"', %*REG<cur>, %*REG<pos>, $name, |@backtrack);
13241324
}
1325+
elsif +@($node) == 1 {
1326+
my $dynname := self.coerce(self.as_post($node[0]), 'S');
1327+
$ops.push($dynname);
1328+
$ops.push_pirop('callmethod', '"!cursor_pass"', %*REG<cur>, %*REG<pos>, $dynname, |@backtrack);
1329+
}
13251330
else {
13261331
$ops.push_pirop('callmethod', '"!cursor_pass"', %*REG<cur>, %*REG<pos>, |@backtrack);
13271332
}

src/QRegex/P6Regex/Actions.nqp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,17 @@ class QRegex::P6Regex::Actions is HLL::Actions {
565565
$qast := QAST::Regex.new( :rxtype<concat>,
566566
QAST::Regex.new( :rxtype<scan> ),
567567
$qast,
568-
($anon ??
569-
QAST::Regex.new( :rxtype<pass> ) !!
570-
QAST::Regex.new( :rxtype<pass>, :name(%*RX<name>) )));
568+
($anon
569+
?? QAST::Regex.new( :rxtype<pass> )
570+
!! (nqp::substr(%*RX<name>, 0, 12) ne '!!LATENAME!!'
571+
?? QAST::Regex.new( :rxtype<pass>, :name(%*RX<name>) )
572+
!! QAST::Regex.new( :rxtype<pass>,
573+
QAST::Var.new(
574+
:name(nqp::substr(%*RX<name>, 12)),
575+
:scope('lexical')
576+
)
577+
)
578+
)));
571579
$block.push($qast);
572580

573581
$block;

0 commit comments

Comments
 (0)