Changeset 10025

Show
Ignore:
Timestamp:
04/18/06 18:42:09 (3 years ago)
Author:
fglock
Message:

PG-P6 - the AST nodes are more regular

Location:
misc/pX/Common
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • misc/pX/Common/Pugs-Compiler-Precedence/lib/Pugs/Grammar/Precedence.pm

    r9967 r10025  
    3535    postfix_non =>        
    3636        "exp 'name'         \n" . 
    37         "\t{ \$_[0]->{out}= {op1 => 'name', exp1 => \$_[1],} }",  
     37        "\t{ \$_[0]->{out}= {op1 => \$_[2], exp1 => \$_[1],} }",  
    3838    postcircumfix_non =>  
    3939        "exp 'name' exp 'name2' \n" . 
     
    4141    infix_left =>         
    4242        "exp 'name' exp     \n" . 
    43         "\t{ \$_[0]->{out}= {op1 => 'name', exp1 => \$_[1], exp2 => \$_[3],} }",  
     43        "\t{ \$_[0]->{out}= {op1 => \$_[2], exp1 => \$_[1], exp2 => \$_[3],} }",  
    4444    infix_non =>          
    4545        "exp 'name' exp     \n" . 
    46         "\t{ \$_[0]->{out}= {op1 => 'name', exp1 => \$_[1], exp2 => \$_[3],} }",  
     46        "\t{ \$_[0]->{out}= {op1 => \$_[2], exp1 => \$_[1], exp2 => \$_[3],} }",  
    4747    ternary_non =>        
    4848        "exp 'name' exp 'name2' exp \n" . 
  • misc/pX/Common/Pugs-Grammar-Perl6/lib/Pugs/Grammar/Expression.pm

    r10017 r10025  
    117117        my $t; 
    118118        if ( exists $ast->{stmt} ) { 
    119             $t = [ $ast->{stmt} => $ast ] 
     119 
     120            if ( $ast->{stmt} eq 'if' or $ast->{stmt} eq 'unless' ) { 
     121                $t = [ 'IF' => $ast ] 
     122            } 
     123            else { 
     124                $t = [ $ast->{stmt} => $ast ] 
     125            } 
    120126        } 
    121127        elsif ( exists $ast->{op} ) { 
  • misc/pX/Common/Pugs-Grammar-Perl6/lib/Pugs/Grammar/Infix.pm

    r10018 r10025  
    191191    ); 
    192192 
    193     __PACKAGE__->add_rule(  
    194         name => 'if', 
     193    # experimental 
     194    __PACKAGE__->add_rule(  
     195        name => 'IF', 
    195196        assoc => 'non', 
    196197        precedence => 'tighter', 
  • misc/pX/Common/Pugs-Grammar-Perl6/lib/Pugs/Grammar/Operator.pm

    r10018 r10025  
    3131 
    3232stmt:   
    33       'if' exp '{' exp '}'  
    34         { $_[0]->{out}= { 'if' => { exp => $_[2], then => $_[4] } } } 
    35     | 'if' exp '{' exp '}' else '{' exp '}' 
    36         { $_[0]->{out}= { 'if' => { exp => $_[2], then => $_[4], else => $_[8] } } } 
    37          
    38     | exp 'if' exp  
    39         { $_[0]->{out}= { 'if' => { exp => $_[3], then => $_[1], } } } 
     33      IF exp '{' exp '}'  
     34        { $_[0]->{out}= { op1 => $_[1], exp1 => $_[2], exp2 => $_[4] } } 
     35    | IF exp '{' exp '}' 'else' '{' exp '}' 
     36        { $_[0]->{out}= { op1 => $_[1], exp1 => $_[2], exp2 => $_[4], exp3 => $_[8] } } 
    4037 
    41     | 'unless' exp '{' exp '}'  
    42         { $_[0]->{out}= { 'unless' => { exp => $_[2], then => $_[4] } } } 
    43     | 'unless' exp '{' exp '}' else '{' exp '}' 
    44         { $_[0]->{out}= { 'unless' => { exp => $_[2], then => $_[4], else => $_[8] } } } 
    45          
    4638    | 'for' exp '{' exp '}' 
    47         { $_[0]->{out}= { 'for' => { exp => $_[2], block => $_[4], } } } 
     39        { $_[0]->{out}= { op1 => $_[1], exp1 => $_[2], exp2 => $_[4], } } 
    4840         
    4941    | 'sub' BAREWORD             attr '{' exp '}'  
  • misc/pX/Common/Pugs-Grammar-Perl6/lib/Pugs/Grammar/Prefix.pm

    r10018 r10025  
    111111        assoc => 'non', 
    112112        precedence => 'equal', 
    113         other => 'infix:<if>', 
     113        other => 'infix:<IF>', 
    114114    ); 
    115115 
  • misc/pX/Common/Pugs-Grammar-Perl6/test.pl

    r10018 r10025  
    8484my $x = do 1 if 2; 
    8585 
     86say(3 if 4);    # wrong? 
     87(4 if 5) + (6 if 7);   # wrong? 
     88 
     89#1 if 2 if 3; 
     90 
    86911; 
    8792PERL6