Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Canonicalize regex names properly so that they will properly particip…
…ate in protoregex dispatch and <sym> will get set properly.
  • Loading branch information
jnthn committed Jun 21, 2012
1 parent 61f6f14 commit d5f39a2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 17 additions & 5 deletions src/Perl6/Actions.pm
Expand Up @@ -173,9 +173,22 @@ class Perl6::Actions is HLL::Actions {
}

method deflongname($/) {
make $<colonpair>
?? ~$<name> ~ ':<' ~ ~$<colonpair>[0]<circumfix><quote_EXPR><quote_delimited><quote_atom>[0] ~ '>'
!! ~$<name>;
if $<colonpair> {
my $name := ~$<name>;
if $<colonpair>[0] {
$name := $name ~ ':';
}
if $<colonpair>[0]<identifier> {
$name := $name ~ ~$<colonpair>[0]<identifier>;
}
if $<colonpair>[0]<circumfix> {
$name := $name ~ '<' ~ ~$<colonpair>[0]<circumfix><quote_EXPR><quote_delimited><quote_atom>[0] ~ '>';
}
make $name;
}
else {
make ~$<name>;
}
}

# Turn $code into "for lines() { $code }"
Expand Down Expand Up @@ -2194,8 +2207,7 @@ class Perl6::Actions is HLL::Actions {

method regex_def($/) {
my $coderef;
my $name := ~$<deflongname>[0];
%*RX<name> := $name;
my $name := ~%*RX<name>;

my @params := $<signature> ?? $<signature>[0].ast !! [];
if $*MULTINESS eq 'proto' {
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/Grammar.pm
Expand Up @@ -1857,7 +1857,7 @@ grammar Perl6::Grammar is HLL::Grammar {
[
{ $*IN_DECL := '' }
<deflongname>?
{ if $<deflongname> { %*RX<name> := $<deflongname>[0].Str } }
{ if $<deflongname> { %*RX<name> := ~$<deflongname>[0].ast } }
<.newpad>
[ [ ':'?'(' <signature> ')'] | <trait> ]*
'{'[
Expand Down

0 comments on commit d5f39a2

Please sign in to comment.