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
implement 'make' and support '$/' a method parameter #690
Comments
From @chrisdolanThe attached patch brings Rakudo up to the level of NQP as a language To apply: |
From @chrisdolan0001-Implement-make-builtin-and-support-as-a-metho.patchFrom 1d13cb562cdfc58af42b51dbe5366428dce1dc22 Mon Sep 17 00:00:00 2001
From: Chris Dolan <chris@chrisdolan.net>
Date: Tue, 10 Feb 2009 21:11:05 -0600
Subject: [PATCH] Implement 'make' builtin and support '$/' as a method parameter
---
src/builtins/match.pir | 8 ++++++++
src/parser/actions.pm | 46 +++++++++++++++++++++++++++++-----------------
src/parser/grammar.pg | 4 ++--
3 files changed, 39 insertions(+), 19 deletions(-)
diff --git a/src/builtins/match.pir b/src/builtins/match.pir
index 775ae02..d94e817 100644
--- a/src/builtins/match.pir
+++ b/src/builtins/match.pir
@@ -25,6 +25,14 @@ src/builtins/match.pir - Perl6 builtins for smart matching
.tailcall x.'REJECTS'(topic)
.end
+.sub 'make'
+ .param pmc value
+ $P0 = getinterp
+ $P1 = $P0['lexpad';1]
+ $P2 = $P1['$/']
+ $P2.'result_object'(value)
+.end
+
=back
=cut
diff --git a/src/parser/actions.pm b/src/parser/actions.pm
index 63d86fd..e281112 100644
--- a/src/parser/actions.pm
+++ b/src/parser/actions.pm
@@ -1261,24 +1261,36 @@ method parameter($/) {
}
-method param_var($/) {
- my $sigil := ~$<sigil>;
- my $twigil := ~$<twigil>[0];
- if $sigil eq '&' { $sigil := ''; }
- my $name := $sigil ~ $twigil ~ ~$<identifier>;
- if $twigil eq '.' {
- $name := $sigil ~ '!' ~ $<identifier>;
- }
- elsif $twigil && $twigil ne '!' {
- $/.panic('Invalid twigil used in signature parameter.');
- }
- my $var := PAST::Var.new(
- :name($name),
- :scope('parameter'),
- :node($/)
- );
- $var<twigil> := $twigil;
- $var<itype> := container_itype( $<sigil> );
+method param_var($/, $key) {
+ my $name;
+ my $var;
+
+ if $key eq 'special_variable' {
+ # Treat $/, $_, etc. specially
+
+ $name := ~$/;
+ $var := PAST::Var.new( :node($/), :name($name), :scope('parameter') );
+
+ } else {
+ my $sigil := ~$<sigil>;
+ my $twigil := ~$<twigil>[0];
+ if $sigil eq '&' { $sigil := ''; }
+ $name := $sigil ~ $twigil ~ ~$<identifier>;
+ if $twigil eq '.' {
+ $name := $sigil ~ '!' ~ $<identifier>;
+ }
+ elsif $twigil && $twigil ne '!' {
+ $/.panic('Invalid twigil used in signature parameter.');
+ }
+ $var := PAST::Var.new(
+ :name($name),
+ :scope('parameter'),
+ :node($/)
+ );
+ $var<twigil> := $twigil;
+ $var<itype> := container_itype( $<sigil> );
+ }
+
# Declare symbol as lexical in current (signature) block.
# This is needed in case any post_constraints try to reference
# this new param_var.
diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg
index a182ade..c8c1639 100644
--- a/src/parser/grammar.pg
+++ b/src/parser/grammar.pg
@@ -480,8 +480,8 @@ rule post_constraint {
}
token param_var {
- <sigil> <twigil>? <identifier>
- {*}
+ | <sigil> <twigil>? <identifier> {*} #= identifier
+ | $<sym>=[ '$/' | '$!' | '$��' ] <!before \w> {*} #= special_variable
}
token parameter {
--
1.6.1
|
From @chrisdolanI intend to add some spec tests for this, too. |
From @pmichaudOn Tue Feb 10 19:24:41 2009, chris@chrisdolan.net wrote:
Now added in d44d19c. I chose a different approach for parsing Closing ticket, thanks! Pm |
The RT System itself - Status changed from 'new' to 'open' |
@pmichaud - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#63152 (status was 'resolved')
Searchable as RT63152$
The text was updated successfully, but these errors were encountered: