Changeset 21632 for perl5

Show
Ignore:
Timestamp:
07/30/08 14:26:09 (5 months ago)
Author:
fglock
Message:

[v6.pm] more operators

Location:
perl5/Pugs-Compiler-Perl6/lib/Pugs
Files:
2 modified

Legend:

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

    r21621 r21632  
    661661    if ( exists $n->{op1} && $n->{op1} eq 'call' ) { 
    662662        #warn "call: ",Dumper $n; 
     663 
     664        if ( exists $n->{sub}{code} && exists $n->{param} && exists $n->{param}{op1} && $n->{param}{op1} eq 'call' ) { 
     665            # &infix<=>.(...) 
     666            my $fixity = $n->{sub}{code}; 
     667            my $operator = $n->{param}{sub}{single_quoted}; 
     668            if ( $fixity && $operator && exists $n->{param}{param}{exp1} ) { 
     669                $fixity =~ s/^&//; 
     670                print Dumper( $n->{param}{param} ); 
     671                return _emit( 
     672                    { 
     673                      'exp1' => $n->{param}{param}{exp1}{list}[0], 
     674                      'exp2' => $n->{param}{param}{exp1}{list}[1], 
     675                      'fixity' => $fixity, 
     676                      'op1' => $operator, 
     677                    }                 
     678                ); 
     679            } 
     680        } 
     681        if ( exists $n->{sub}{bareword} && exists $n->{param} && exists $n->{param}{op1} && $n->{param}{op1} eq 'call' ) { 
     682            # infix<=>(...) 
     683            my $fixity = $n->{sub}{bareword}; 
     684            my $operator = $n->{param}{sub}{single_quoted}; 
     685            if ( $fixity && $operator && exists $n->{param}{param}{exp1} ) { 
     686                $fixity =~ s/^&//; 
     687                print Dumper( $n->{param}{param} ); 
     688                return _emit( 
     689                    { 
     690                      'exp1' => $n->{param}{param}{exp1}{list}[0], 
     691                      'exp2' => $n->{param}{param}{exp1}{list}[1], 
     692                      'fixity' => $fixity, 
     693                      'op1' => $operator, 
     694                    }                 
     695                ); 
     696            } 
     697        } 
    663698 
    664699        if ($n->{sub}{scalar} || $n->{sub}{exp1} || $n->{sub}{statement}) { 
     
    14301465        return _emit( $n->{exp1} ) . ' .= ' . _emit_str( $n->{exp2} ); 
    14311466    } 
     1467    if ( $n->{op1} eq '+&=' ) { 
     1468        return _emit( $n->{exp1} ) . ' &= ' . _emit_str( $n->{exp2} ); 
     1469    } 
     1470    if ( $n->{op1} eq '+|=' ) { 
     1471        return _emit( $n->{exp1} ) . ' |= ' . _emit_str( $n->{exp2} ); 
     1472    } 
     1473    if ( $n->{op1} eq '+^=' ) { 
     1474        return _emit( $n->{exp1} ) . ' ^= ' . _emit_str( $n->{exp2} ); 
     1475    } 
     1476 
     1477    if ( $n->{op1} eq '~&=' ) { 
     1478        return 
     1479             'do { my $_V6_TMP1 = "" . ' . _emit( $n->{exp1} ) . '; '  
     1480                . _emit( $n->{exp1} ) . ' = $_V6_TMP1 & ( "" . ' . _emit( $n->{exp2} )  
     1481            . ' ); } '; 
     1482    } 
     1483    if ( $n->{op1} eq '~|=' ) { 
     1484        return 
     1485             'do { my $_V6_TMP1 = "" . ' . _emit( $n->{exp1} ) . '; '  
     1486                . _emit( $n->{exp1} ) . ' = $_V6_TMP1 | ( "" . ' . _emit( $n->{exp2} )  
     1487            . ' ); } '; 
     1488    } 
     1489    if ( $n->{op1} eq '~^=' ) { 
     1490        return 
     1491             'do { my $_V6_TMP1 = "" . ' . _emit( $n->{exp1} ) . '; '  
     1492                . _emit( $n->{exp1} ) . ' = $_V6_TMP1 ^ ( "" . ' . _emit( $n->{exp2} )  
     1493            . ' ); } '; 
     1494    } 
     1495 
     1496    if ( $n->{op1} eq '?&=' ) { 
     1497        return 
     1498             'do { my $_V6_TMP1 = ' . _emit( $n->{exp1} ) . '; '  
     1499                . _emit( $n->{exp1} ) . ' = ( $_V6_TMP1 && ' . _emit( $n->{exp2} )  
     1500            . ' ) ? 1 : 0; } '; 
     1501    } 
     1502    if ( $n->{op1} eq '?|=' ) { 
     1503        return 
     1504             'do { my $_V6_TMP1 = ' . _emit( $n->{exp1} ) . '; '  
     1505                . _emit( $n->{exp1} ) . ' = ( $_V6_TMP1 || ' . _emit( $n->{exp2} )  
     1506            . ' ) ? 1 : 0; } '; 
     1507    } 
     1508    if ( $n->{op1} eq '?^=' ) { 
     1509        return 
     1510             'do { my $_V6_TMP1 = ' . _emit( $n->{exp1} ) . '; '  
     1511                . _emit( $n->{exp1} ) . ' = ( $_V6_TMP1 xor ' . _emit( $n->{exp2} )  
     1512            . ' ) ? 1 : 0; } '; 
     1513    } 
     1514 
     1515    if ( $n->{op1} eq '+<=' ) { 
     1516        return _emit( $n->{exp1} ) . ' <= ' . _emit_str( $n->{exp2} ); 
     1517    } 
     1518    if ( $n->{op1} eq '+>=' ) { 
     1519        return _emit( $n->{exp1} ) . ' >= ' . _emit_str( $n->{exp2} ); 
     1520    } 
     1521 
     1522    if ( $n->{op1} eq '~<=' ) { 
     1523        return _emit( $n->{exp1} ) . ' le ' . _emit_str( $n->{exp2} ); 
     1524    } 
     1525    if ( $n->{op1} eq '~>=' ) { 
     1526        return _emit( $n->{exp1} ) . ' ge ' . _emit_str( $n->{exp2} ); 
     1527    } 
     1528 
     1529    if ( $n->{op1} eq '^^=' ) { 
     1530        # XXX 
     1531        return _emit( $n->{exp1} ) . ' ^= ' . _emit_str( $n->{exp2} ); 
     1532    } 
    14321533    if ( $n->{op1} eq '//'  || 
    14331534         $n->{op1} eq 'orelse' ) { 
  • perl5/Pugs-Compiler-Perl6/lib/Pugs/Grammar/Infix.pm

    r21601 r21632  
    111111    ); 
    112112    __PACKAGE__->add_same_precedence_ops({ assoc => 'right'}, qw( 
    113         = := ::= => += -=  
     113        = := ::= => += -= +>= +<= ~>= ~<=  
    114114        *= **=  
    115115        /= //=