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

Commit

Permalink
[nqp]: Add interpolation of scalars into double-quoted strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 31, 2009
1 parent 1e17347 commit dcee671
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/NQP/Actions.pm
Expand Up @@ -548,6 +548,8 @@ method quote:sym<Q:PIR>($/) {
:node($/) );
}

method quote_escape:sym<$>($/) { make $<variable>.ast; }

## Operators

method nulltermish($/) {
Expand Down
2 changes: 2 additions & 0 deletions src/NQP/Grammar.pm
Expand Up @@ -292,6 +292,8 @@ token quote:sym<qq> { 'qq' <![(]> <.ws> <quote_EXPR: ':qq'> }
token quote:sym<Q> { 'Q' <![(]> <.ws> <quote_EXPR> }
token quote:sym<Q:PIR> { 'Q:PIR' <.ws> <quote_EXPR> }

token quote_escape:sym<$> { <?[$]> <?quotemod_check('s')> <variable> }

token circumfix:sym<( )> { '(' <.ws> <EXPR> ')' }
token circumfix:sym<ang> { <?[<]> <quote_EXPR: ':q', ':w'> }
token circumfix:sym<{ }> { <?[{]> <pblock> }
Expand Down
11 changes: 11 additions & 0 deletions t/nqp/38-quotes.t
@@ -0,0 +1,11 @@
#! nqp

# interpolating quotes

plan(2);

my $abc := 'abc';

ok( "xxx$abc" eq 'xxxabc', "basic scalar interpolation" );

ok( qq{xxx $abc zzz} eq 'xxx abc zzz', 'basic qq{} interpolation' );

0 comments on commit dcee671

Please sign in to comment.