diff --git a/lib/Perl6/P5Actions.pm b/lib/Perl6/P5Actions.pm index 4d2f263..d62aea0 100644 --- a/lib/Perl6/P5Actions.pm +++ b/lib/Perl6/P5Actions.pm @@ -6,6 +6,11 @@ use Perl6::Ops; use QRegex; use QAST; +sub p5disect_longname( $longname ) { + $longname := nqp::list(); + $*W.disect_longname( $longname ) +} + my role STDActions { method quibble($/) { make $.ast; @@ -203,30 +208,10 @@ class Perl6::P5Actions is HLL::Actions does STDActions { } method deflongname($/) { -# if $ { -# my $name := ~$; -# if $[0] { -# $name := $name ~ ':'; -# } -# if $[0] { -# $name := $name ~ ~$[0]; -# } -# if $[0] -> $cf { -# if $cf -> $op_name { -# $name := $name ~ '<' ~ $*W.colonpair_nibble_to_str($/, $op_name) ~ '>'; -# } -# else { -# $name := $name ~ '<>'; -# } -# } -# make $name; -# } -# else { - make $*W.disect_deflongname($/).name( - :dba("$*IN_DECL declaration"), - :decl, - ); -# } + make p5disect_longname($/).name( + :dba("$*IN_DECL declaration"), + :decl, + ); } # Turn $code into "for lines() { $code }" @@ -453,9 +438,9 @@ class Perl6::P5Actions is HLL::Actions does STDActions { make $.ast; } -# method pod_configuration($/) { -# make Perl6::Pod::make_config($/); -# } + method pod_configuration($/) { + make Perl6::Pod::make_config($/); + } method pod_block:sym($/) { make Perl6::Pod::any_block($/); @@ -987,7 +972,7 @@ class Perl6::P5Actions is HLL::Actions does STDActions { method package_declarator:sym($/) { my $past := QAST::Stmts.new(:node($/)); my $name_past := $ - ?? $*W.disect_longname($).name_past() + ?? p5disect_longname($).name_past() !! $[0].ast; $past.push(QAST::Op.new( @@ -1224,30 +1209,10 @@ class Perl6::P5Actions is HLL::Actions does STDActions { } # method colonpair($/) { -# if $*key { -# if $ { -# make make_pair($*key, $.ast); -# } -# elsif $*value ~~ NQPMatch { -# my $val_ast := $*value.ast; -# if $val_ast.isa(QAST::Stmts) && +@($val_ast) == 1 { -# $val_ast := $val_ast[0]; -# } -# make make_pair($*key, $val_ast); -# } -# else { -# make make_pair($*key, QAST::Op.new( -# :op('p6bool'), -# QAST::IVal.new( :value($*value) ) -# )); -# } -# } -# elsif $ { -# make $.ast; -# } -# else { -# make $*value.ast; -# } +# make make_pair($*key, QAST::Op.new( +# :op('p6bool'), +# QAST::IVal.new( :value($*value) ) +# )); # } # method colonpair_variable($/) { @@ -1343,7 +1308,7 @@ class Perl6::P5Actions is HLL::Actions does STDActions { else { my $indirect; if $ && $ { - my $longname := $*W.disect_longname($); + my $longname := p5disect_longname($); if $longname.contains_indirect_lookup() { if $*IN_DECL { $*W.throw($/, ['X', 'Syntax', 'Variable', 'IndirectDeclaration']); @@ -2408,16 +2373,16 @@ class Perl6::P5Actions is HLL::Actions does STDActions { ); } my %sig_info; - if $ { - %sig_info := $[0].ast; - } - else { +# if $ { +# %sig_info := $[0].ast; +# } +# else { %sig_info := $block ?? $block !! []; - } +# } my @params := %sig_info; set_default_parameter_type(@params, 'Any'); - my $signature := create_signature_object($ ?? $[0] !! $/, %sig_info, $block); + my $signature := create_signature_object($/, %sig_info, $block); add_signature_binding_code($block, $signature, @params); # Finish code object, associating it with the routine body. @@ -2611,12 +2576,12 @@ class Perl6::P5Actions is HLL::Actions does STDActions { 0 } -# method onlystar($/) { -# my $BLOCK := $*CURPAD; -# $BLOCK.push(QAST::Op.new( :op('p6multidispatch') )); -# $BLOCK.node($/); -# make $BLOCK; -# } + method onlystar($/) { + my $BLOCK := $*CURPAD; + $BLOCK.push(QAST::Op.new( :op('p6multidispatch') )); + $BLOCK.node($/); + make $BLOCK; + } method regex_declarator:sym($/, $key?) { make $.ast; @@ -2727,7 +2692,7 @@ class Perl6::P5Actions is HLL::Actions does STDActions { # Get, or find, enumeration base type and create type object with # correct base type. - my $longname := $ ?? $*W.disect_longname($) !! 0; + my $longname := $ ?? p5disect_longname($) !! 0; my $name := $ ?? $longname.name() !! $; my $type_obj; @@ -2874,7 +2839,7 @@ class Perl6::P5Actions is HLL::Actions does STDActions { QAST::Op.new( :op('p6bool'), QAST::IVal.new( :value(1) ) )); # Create the meta-object. - my $longname := $ ?? $*W.disect_longname($[0]) !! 0; + my $longname := $ ?? p5disect_longname($[0]) !! 0; my $subset := $ ?? $*W.create_subset(%*HOW, $refinee, $refinement, :name($longname.name())) !! $*W.create_subset(%*HOW, $refinee, $refinement); @@ -2965,9 +2930,9 @@ class Perl6::P5Actions is HLL::Actions does STDActions { make $.ast; } - method multisig($/) { - make $.ast; - } +# method multisig($/) { +# make $.ast; +# } method fakesignature($/) { my $fake_pad := $*W.pop_lexpad(); @@ -3227,16 +3192,6 @@ class Perl6::P5Actions is HLL::Actions does STDActions { $/.CURSOR.panic("Type " ~ ~$ ~ " cannot be used as a nominal type on a parameter"); } -# for ($ ?? $ !! $) { -# if $_ { -# if $_.Str eq 'D' { -# %*PARAM_INFO := 1; -# } -# elsif $_.Str eq 'U' { -# %*PARAM_INFO := 1; -# } -# } -# } } } elsif $ { @@ -3348,7 +3303,6 @@ class Perl6::P5Actions is HLL::Actions does STDActions { } method trait($/) { -# make $ ?? $.ast !! $.ast; make $.ast; } @@ -3376,7 +3330,7 @@ class Perl6::P5Actions is HLL::Actions does STDActions { # If we have a type name then we need to dispatch with that type; otherwise # we need to dispatch with it as a named argument. - my @name := $*W.disect_longname($).components(); + my @name := p5disect_longname($).components(); if $*W.is_name(@name) { my $trait := $*W.find_symbol(@name); make -> $declarand { @@ -3481,7 +3435,7 @@ class Perl6::P5Actions is HLL::Actions does STDActions { # runs after CHECK time. my $past := $.ast; if $ { - my @parts := $*W.disect_longname($).components(); + my @parts := p5disect_longname($).components(); my $name := @parts.pop; if @parts { my $methpkg := $*W.find_symbol(@parts); @@ -3524,7 +3478,7 @@ class Perl6::P5Actions is HLL::Actions does STDActions { if $ { # May just be .foo, but could also be .Foo::bar. Also handle the # macro-ish cases. - my @parts := $*W.disect_longname($).components(); + my @parts := p5disect_longname($).components(); my $name := @parts.pop; if +@parts { $past.unshift($*W.symbol_lookup(@parts, $/)); @@ -3895,9 +3849,9 @@ class Perl6::P5Actions is HLL::Actions does STDActions { make $.ast; } -# method term:sym($/) { -# make QAST::Op.new( :op('p6multidispatchlex') ); -# } + method term:sym($/) { + make QAST::Op.new( :op('p6multidispatchlex') ); + } method args($/) { my $past; @@ -4246,22 +4200,6 @@ class Perl6::P5Actions is HLL::Actions does STDActions { } } if $key eq 'POSTFIX' { - # If may be an adverb. -# if $ { -# my $target := $past := $/[0].ast; -# if nqp::istype($target, QAST::Op) && $target.op eq 'p6type' { -# $target := $target[0]; -# } -# unless nqp::istype($target, QAST::Op) && ($target.op eq 'call' || $target.op eq 'callmethod') { -# $/.CURSOR.panic("You can't adverb that"); -# } -# my $cpast := $.ast; -# $cpast[2].named(compile_time_value_str($cpast[1], 'LHS of pair', $/)); -# $target.push($cpast[2]); -# make $past; -# return 1; -# } - # Method calls may be to a foreign language, and thus return # values may need type mapping into Perl 6 land. $past.unshift($/[0].ast); @@ -5007,7 +4945,7 @@ class Perl6::P5Actions is HLL::Actions does STDActions { # GenericHOW, though whether/how it's used depends on context. if $ { if nqp::substr(~$, 0, 2) ne '::' { - my $longname := $*W.disect_longname($); + my $longname := p5disect_longname($); my $type := $*W.find_symbol($longname.type_name_parts('type name')); if $ { $type := $*W.parameterize_type($type, $, $/); diff --git a/lib/Perl6/P5Grammar.pm b/lib/Perl6/P5Grammar.pm index e3eed46..b4f431a 100644 --- a/lib/Perl6/P5Grammar.pm +++ b/lib/Perl6/P5Grammar.pm @@ -2,7 +2,6 @@ use QRegex; use NQPP6QRegex; use NQPP5QRegex; use Perl6::P5Actions; -use Perl6::P5World; use Perl6::Pod; # XXX do we need that? role startstop5[$start,$stop] { @@ -307,7 +306,6 @@ role STD5 { } grammar Perl6::P5Grammar is HLL::Grammar does STD5 { - # use DEBUG; # method TOP ($STOP = 0) { @@ -1654,7 +1652,7 @@ grammar Perl6::P5Grammar is HLL::Grammar does STD5 { { unless $*SCOPE { $*SCOPE := 'our'; } } [ - [ { $longname := $*W.disect_longname($[0]); } ]? + [ { $longname := p5disect_longname($[0]); } ]? <.newlex> [ :dba('generic role') @@ -1897,7 +1895,7 @@ grammar Perl6::P5Grammar is HLL::Grammar does STD5 { :my $*DECLARAND := $*W.stub_code_object('Sub'); <.newlex> - [ '(' ')' ]? + #[ '(' ')' ]? * { $*IN_DECL := 0; } @@ -2254,7 +2252,7 @@ grammar Perl6::P5Grammar is HLL::Grammar does STD5 { token longname { } - + token name { [ | * @@ -2699,9 +2697,9 @@ grammar Perl6::P5Grammar is HLL::Grammar does STD5 { token unitstopper { $ } - method balanced ($start,$stop) { self.mixin( Perl6::P5Grammar::startstop[$start,$stop] ); } - method unbalanced ($stop) { self.mixin( Perl6::P5Grammar::stop[$stop] ); } - method unitstop ($stop) { self.mixin( Perl6::P5Grammar::unitstop[$stop] ); } + method balanced ($start,$stop) { self.mixin( Perl6::P5Grammar::startstop5[$start,$stop] ); } + method unbalanced ($stop) { self.mixin( Perl6::P5Grammar::stop5[$stop] ); } + method unitstop ($stop) { self.mixin( Perl6::P5Grammar::unitstop5[$stop] ); } token charname { [ @@ -3568,7 +3566,7 @@ grammar Perl6::P5Grammar is HLL::Grammar does STD5 { token term:sym { :my $*longname; - { say("token term:sym longname:" ~ ~$); $*longname := $*W.disect_longname($) } + { say("token term:sym longname:" ~ ~$); $*longname := p5disect_longname($) } [ || .Str, 0, 2) eq '::' || $*W.is_name($*longname.components()) }> <.unsp>?