Show
Ignore:
Timestamp:
07/27/08 16:19:34 (6 months ago)
Author:
fglock
Message:

[v6.pm] smartmatch fixes

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • perl5/Pugs-Compiler-Perl6/lib/Pugs/Emitter/Perl6/Perl5.pm

    r21564 r21569  
    2727        $s = $n->{$_} if exists $n->{$_}; 
    2828    } 
    29  
     29     
    3030    #print "get: $s\n"; 
    31  
     31     
    3232    if  (  defined $s 
    3333        && $s =~ /\$\? .* POSITION $/x 
     
    174174    return "q!$n!" unless $n =~ /[!]/; 
    175175    return "q^$n^" unless $n =~ /[\^]/; 
     176    die "can't quote string [$n]"; 
     177} 
     178 
     179sub _emit_qr { 
     180    my $n = $_[0]; 
     181    return "qr($n)" unless $n =~ /[()]/; 
     182    return "qr{$n}" unless $n =~ /[{}]/; 
     183    return "qr[$n]" unless $n =~ /[\[\]]/; 
     184    return "qr!$n!" unless $n =~ /[!]/; 
     185    return "qr^$n^" unless $n =~ /[\^]/; 
    176186    die "can't quote string [$n]"; 
    177187} 
     
    10211031 
    10221032    if ( exists $n->{rx} ) { 
    1023         return 'qr{'.$n->{rx}{rx}.'}' if $n->{rx}{options}{perl5}; 
     1033        return _emit_qr( $n->{rx}{rx} ) if $n->{rx}{options}{perl5}; 
     1034        return _emit_qr( $n->{rx}{rx} )  # TODO: perl6rx\n"; 
    10241035    } 
    10251036 
     
    10681079                    exp1 => { scalar => '$_' }, 
    10691080                    exp2 => $n->{exp1}, 
    1070                     op1   => { op => '~~' }, 
     1081                    op1   => '~~', 
    10711082                    fixity => 'infix', 
    10721083                } 
     
    14591470        } 
    14601471        if ( my $rx = $n->{exp2}{rx} ) { 
    1461             if ( !$rx->{options}{perl5} ) { 
     1472            if ( !$rx->{options}{perl5} && !$rx->{options}{p5} ) { 
    14621473                my $regex = $rx->{rx}; 
    14631474                # XXX: hack for /$pattern/