Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Improve longname handling for routine and regexes, allow "infix:<...>…
Browse files Browse the repository at this point in the history
…" names.
  • Loading branch information
pmichaud committed Dec 2, 2009
1 parent 3173f73 commit 530da42
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/NQP/Actions.pm
Expand Up @@ -30,7 +30,17 @@ sub sigiltype($sigil) {
method TOP($/) { make $<comp_unit>.ast; }

method deflongname($/) {
make $<sym> ?? ~$<identifier> ~ ':sym<' ~ ~$<sym>[0] ~ '>' !! ~$/;
make $<colonpair>
?? ~$<identifier> ~ ':' ~ $<colonpair>[0].ast.named
~ '<' ~ colonpair_str($<colonpair>[0].ast) ~ '>'
!! ~$/;
# make $<sym> ?? ~$<identifier> ~ ':sym<' ~ ~$<sym>[0] ~ '>' !! ~$/;
}

sub colonpair_str($ast) {
PAST::Op.ACCEPTS($ast)
?? pir::join(' ', $ast.list)
!! $ast.value;
}

method comp_unit($/) {
Expand Down Expand Up @@ -619,6 +629,7 @@ method circumfix:sym<[ ]>($/) {
}

method circumfix:sym<ang>($/) { make $<quote_EXPR>.ast; }
method circumfix:sym<« »>($/) { make $<quote_EXPR>.ast; }

method circumfix:sym<{ }>($/) {
make +$<pblock><blockoid><statementlist><statement> > 0
Expand Down
4 changes: 2 additions & 2 deletions src/NQP/Grammar.pm
Expand Up @@ -18,8 +18,7 @@ token identifier { <ident> }
token name { <identifier> ** '::' }

token deflongname {
<identifier>
[ ':sym<' $<sym>=[<-[>]>*] '>' | ':sym«' $<sym>=[<-[»]>*] '»' ]?
<identifier> <colonpair>?
}

token ENDSTMT {
Expand Down Expand Up @@ -391,6 +390,7 @@ token quote_escape:sym<{ }> { <?[{]> <?quotemod_check('c')> <block> }
token circumfix:sym<( )> { '(' <.ws> <EXPR>? ')' }
token circumfix:sym<[ ]> { '[' <.ws> <EXPR>? ']' }
token circumfix:sym<ang> { <?[<]> <quote_EXPR: ':q', ':w'> }
token circumfix:sym<« »> { <?[«]> <quote_EXPR: ':qq', ':w'> }
token circumfix:sym<{ }> { <?[{]> <pblock> }
token circumfix:sym<sigil> { <sigil> '(' ~ ')' <semilist> }

Expand Down

0 comments on commit 530da42

Please sign in to comment.