Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement <&foo: $arg> and <&foo($arg)>.
We don't parse quite so liberally as STD does here, mostly because it
seems like a great way to have to do a bunch of more fragile analysis
without obviously implementing anything else from the design.
  • Loading branch information
jnthn committed Apr 28, 2015
1 parent a5f38ae commit 8782513
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
26 changes: 19 additions & 7 deletions src/Perl6/Actions.nqp
Expand Up @@ -7754,13 +7754,25 @@ class Perl6::RegexActions is QRegex::P6Regex::Actions does STDActions {
}

method assertion:sym<var>($/) {
make QAST::Regex.new( QAST::NodeList.new(
QAST::SVal.new( :value('INTERPOLATE') ),
$<var>.ast,
QAST::IVal.new( :value(%*RX<i> ?? 1 !! 0) ),
QAST::IVal.new( :value($*SEQ ?? 1 !! 0) ),
QAST::IVal.new( :value(1) ) ),
:rxtype<subrule>, :subtype<method>, :node($/));
if $<arglist> {
my $ast := make QAST::Regex.new(
QAST::NodeList.new(
QAST::SVal.new( :value('CALL_SUBRULE') ),
$<var>.ast ),
:rxtype<subrule>, :subtype<method>, :node($/));
for @($<arglist>.ast) {
$ast[0].push($_);
}
} else {
make QAST::Regex.new(
QAST::NodeList.new(
QAST::SVal.new( :value('INTERPOLATE') ),
$<var>.ast,
QAST::IVal.new( :value(%*RX<i> ?? 1 !! 0) ),
QAST::IVal.new( :value($*SEQ ?? 1 !! 0) ),
QAST::IVal.new( :value(1) ) ),
:rxtype<subrule>, :subtype<method>, :node($/));
}
}

method assertion:sym<name>($/) {
Expand Down
7 changes: 6 additions & 1 deletion src/Perl6/Grammar.nqp
Expand Up @@ -5012,7 +5012,12 @@ grammar Perl6::RegexGrammar is QRegex::P6Regex::Grammar does STD does CursorPack
}

token assertion:sym<var> {
<?sigil> <var=.LANG('MAIN', 'term:sym<variable>')>
| <?[&]> <var=.LANG('MAIN', 'term:sym<variable>')>
[
| ':' <arglist>
| '(' <arglist> ')'
]?
| <?sigil> <var=.LANG('MAIN', 'term:sym<variable>')>
}

token assertion:sym<~~> {
Expand Down
4 changes: 4 additions & 0 deletions src/core/Cursor.pm
Expand Up @@ -259,6 +259,10 @@ my class Cursor does NQPCursorRole {
}
}

method CALL_SUBRULE($rule, |c) {
$rule(self, |c)
}

method DYNQUANT_LIMITS($mm) {
if nqp::istype($mm,Range) {
die 'Range minimum in quantifier (**) cannot be +Inf' if $mm.min == Inf;
Expand Down

0 comments on commit 8782513

Please sign in to comment.