Author: jonathan
Date: Tue May 6 09:25:30 2008
New Revision: 27349
Modified:
trunk/languages/perl6/src/parser/actions.pm
trunk/languages/perl6/src/parser/grammar.pg
Log:
[rakudo] Refactor parsing of method calls to bring us somewhat closer to
STD.pm, as well as parsing various other call operators and private calls so we
can implement those.
Modified: trunk/languages/perl6/src/parser/actions.pm
==============================================================================
--- trunk/languages/perl6/src/parser/actions.pm (original)
+++ trunk/languages/perl6/src/parser/actions.pm Tue May 6 09:25:30 2008
@@ -698,13 +698,13 @@
$past := $($_);
# Check if it's an indirect call.
- if $_<methodop><variable> {
+ if $_<dotty><methodop><variable> {
# What to call supplied; need to put the invocant second.
my $meth := $past[0];
$past[0] := $term;
$past.unshift($meth);
}
- elsif $_<methodop><quote> {
+ elsif $_<dotty><methodop><quote> {
# First child is something that we evaluate to get the
# name. Replace it with PIR to call find_method on it.
my $meth_name := $past[0];
@@ -730,6 +730,13 @@
make $( $/{$key} );
}
+
+method dotty($/, $key) {
+ my $past := $( $<methodop> );
+ make $past;
+}
+
+
method methodop($/, $key) {
my $past;
@@ -744,8 +751,8 @@
$past.pasttype('callmethod');
$past.node($/);
- if $<ident> {
- $past.name(~$<ident>);
+ if $<name> {
+ $past.name(~$<name><ident>[0]);
}
elsif $<variable> {
$past.unshift( $( $<variable> ) );
@@ -834,7 +841,7 @@
)
);
}
- elsif $key eq 'methodop' {
+ elsif $key eq 'dotty' {
# Call on $_.
$past := $( $/{$key} );
$past.unshift(PAST::Var.new(
Modified: trunk/languages/perl6/src/parser/grammar.pg
==============================================================================
--- trunk/languages/perl6/src/parser/grammar.pg (original)
+++ trunk/languages/perl6/src/parser/grammar.pg Tue May 6 09:25:30 2008
@@ -84,6 +84,8 @@
[ \v | <.unv> ]*
}
+token unspacey { <.unsp>? }
+
token unv {
|| \h+
|| ^^ <.pod_comment>
@@ -440,24 +442,33 @@
token postfix {
<!afterws>
[
- | <methodop> {*} #= methodop
+ | <dotty> {*} #= dotty
| <postcircumfix> {*} #= postcircumfix
]
}
+token dotty {
+ [
+ | '.' <methodop> {*} #= .
+ | ('.' <[+*?=^:]>) <?unspacey> <methodop> {*} #= .*
+ | '!' <methodop> {*} #= !
+ ]
+}
+
+
token methodop {
- '.'
[
- | <ident>
+ | <name>
| <?before '$' | '@' > <variable>
- | <?before <[ ' " ]>> <quote>
-# { $<quote> ~~ /\W/ or .panic("Useless use of quotes") }
- ]
+ | <?before <[ ' " ]> > <quote>
+# { $<quote> ~~ /\W/ or .panic("Useless use of quotes") }
+ ] <.unsp>?
+
[
- | <.unsp>? '(' <semilist> ')' {*} #= semilist
- | ':' <?before \s> <arglist> {*} #= arglist
- | {*} #= null
+ | '.'? <.unsp>? '(' <semilist> ')' {*} #= semilist
+ | ':' <?before \s> <arglist> {*} #= arglist
+ | {*} #= null
]
}
@@ -481,7 +492,7 @@
| <circumfix> {*} #= circumfix
| <variable> {*} #= variable
| <subcall> {*} #= subcall
- | <methodop> {*} #= methodop
+ | <dotty> #= dotty
| <value> {*} #= value
| <capterm> {*} #= capterm
| <statement_prefix> {*} #= statement_prefix