New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
first pass at interpolated namespaces #163
Comments
From @jeffhorwitzI wanted some feedback on this patch before I apply it. It implements ::($ns)::foo() It can most certainly be refactored to work with more test cases by someone -jeff |
From @jeffhorwitzrakudo-interpns.patchIndex: languages/perl6/src/builtins/misc.pir
===================================================================
--- languages/perl6/src/builtins/misc.pir (revision 29098)
+++ languages/perl6/src/builtins/misc.pir (working copy)
@@ -12,6 +12,19 @@
.return($P0)
.end
+.sub 'resolve_sym'
+ .param string ns
+ .param string name
+ .param pmc args :slurpy
+ .local pmc sym
+ .local pmc nskey
+
+ nskey = split '::', ns
+ sym = get_hll_global nskey, name
+
+ .return(sym)
+.end
+
# Local Variables:
# mode: pir
# fill-column: 100
Index: languages/perl6/src/parser/actions.pm
===================================================================
--- languages/perl6/src/parser/actions.pm (revision 29098)
+++ languages/perl6/src/parser/actions.pm (working copy)
@@ -1930,6 +1930,27 @@
$past := build_call( $( $<semilist> ) );
$past.name( ~$<ident> );
}
+ # call sub with an interpolated namespace
+ # right now we only support this exact form: ::($ns)::name()
+ elsif $key eq 'interpolated func args' {
+ my $resolve_past := PAST::Op.new(
+ :name('resolve_sym'),
+ :pasttype('call'),
+ :node($/)
+ );
+ $resolve_past.unshift(PAST::Val.new(
+ :value( ~$<interpolated_name><name><ident>[0] )
+ ));
+ $resolve_past.unshift(
+ $( $<interpolated_name><interpolated_ident>[0]<EXPR> )
+ );
+ $past := build_call( $( $<semilist> ) );
+ $past.unshift($resolve_past);
+
+ # build_call will set 'name' for us. we reset that to undef so the
+ # sub call invokes the first PAST argument ($resolve_past) instead
+ $past.name(undef);
+ }
elsif $key eq 'listop args' {
$past := build_call( $( $<arglist> ) );
$past.name( ~$<ident> );
Index: languages/perl6/src/parser/grammar.pg
===================================================================
--- languages/perl6/src/parser/grammar.pg (revision 29098)
+++ languages/perl6/src/parser/grammar.pg (working copy)
@@ -517,6 +517,8 @@
[
| 'VAR(' <variable> ')' {*} #= VAR
| <typename> {*} #= typename
+ | <interpolated_name> <.unsp>? '.'?
+ '(' <semilist> ')' {*} #= interpolated func args
| <ident=named_0ary>
[
| <.unsp>? '.'? '(' <semilist> ')' {*} #= func args
@@ -604,10 +606,10 @@
}
token circumfix {
- | '(' <statementlist> ')' {*} #= ( )
- | '[' <statementlist> ']' {*} #= [ ]
- | <?before '{' | <lambda> > <pblock> {*} #= { }
- | <sigil> '(' <semilist> ')' {*} #= $( )
+ | '(' <statementlist> ')' {*} #= ( )
+ | '[' <statementlist> ']' {*} #= [ ]
+ | <?before '{' | <lambda> > <pblock> {*} #= { }
+ | <sigil=variable_sigil> '(' <semilist> ')' {*} #= $( )
}
token variable {
@@ -619,6 +621,8 @@
token sigil { '$' | '@' | '%' | '&' | '::' }
+token variable_sigil { '$' | '@' | '%' }
+
token twigil { <[.!^:*+?=]> }
token name {
@@ -718,6 +722,14 @@
{*}
}
+token interpolated_name {
+ [ '::' <interpolated_ident> ]+ '::' <name>
+}
+
+token interpolated_ident {
+ <?after '::' > '(' <EXPR> ')'
+}
+
token name {
<ident> [ '::' <ident> ]*
{*}
|
From @cokeOn Tue Jul 08 10:35:02 2008, jhorwitz wrote:
Jeff - really sorry about the delay on the reply here. =-) This patch will no longer cleanly apply. I'm going to go ahead and close this ticket. I hesitate to suggest supplying a new patch, but if you do, I promise to bug pmichaud & jnthn -- |
The RT System itself - Status changed from 'new' to 'open' |
@coke - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#56700 (status was 'rejected')
Searchable as RT56700$
The text was updated successfully, but these errors were encountered: