Changeset 22526

Show
Ignore:
Timestamp:
10/07/08 19:20:00 (6 weeks ago)
Author:
pmurias
Message:

[mildew] say "Hello World" compiles correctly

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • v6/mildew/mildew

    r22500 r22526  
    1414use Carp 'confess'; 
    1515 
     16$::ACTIONS = 'Actions'; 
     17{package Actions; 
     18    our $AUTOLOAD; 
     19    sub AUTOLOAD { 
     20        my $self=shift; 
     21        my $match=shift; 
     22        if ($AUTOLOAD =~ /^Actions::scope_declarator.*my/) { 
     23            warn "action $AUTOLOAD\n"; 
     24            $match->{''} = 'my'; 
     25        } 
     26    } 
     27} 
    1628my ($debug,$file); 
    1729GetOptions("file=s"=>\$file,"debug"=>\$debug); 
     
    2436    #XXX non-base 10 
    2537    AST::IntegerConstant->new(value=>$m->text); 
     38} 
     39sub scope_declarator { 
     40    my $m = shift; 
     41    if ($m->{''} eq 'my') { 
     42        if (my $decl = $m->{scoped}{declarator}) { 
     43            if (my $var_decl = $decl->{variable_declarator}) { 
     44                AST::Call->new( 
     45                    identifier => AST::StringConstant->new(value=>'STORE'), 
     46                    capture => AST::Capture->new( 
     47                        invocant => AST::Call->new( 
     48                            identifier => AST::StringConstant->new(value=>'postcircumfix:{ }'), 
     49                            capture => AST::Capture->new(invocant=>AST::Reg->new(name=>'scope'),positional=>[AST::StringConstant->new(value=>$m->text)],named=>[]) 
     50                        ), 
     51                        positional => [ 
     52                            AST::Call->new( 
     53                                identifier => AST::StringConstant->new(value=>'new'), 
     54                                invocant => AST::Reg->new(name=>'$Scalar'), 
     55                            ) 
     56                        ] 
     57                    ), 
     58                ); 
     59            } 
     60        } 
     61    } else { 
     62        XXX; 
     63    } 
    2664} 
    2765sub noun { 
     
    3775            XXX; 
    3876        } 
    39     } else { 
    40         XXX; 
    41     } 
     77    } elsif ($m->{term}) { 
     78        term($m->{term}); 
     79    } elsif ($m->{scope_declarator}) { 
     80        scope_declarator($m->{scope_declarator}); 
     81    } else { 
     82        XXX; 
     83    } 
     84} 
     85sub term { 
     86    my $m = shift; 
     87    if ($m->{identifier} && $m->{args}) { 
     88        my $func = AST::Call->new( 
     89            identifier=>AST::StringConstant->new(value=>'lookup'), 
     90            capture=>AST::Capture->new(invocant=>AST::Reg->new(name=>'scope'),positional=>[AST::StringConstant->new(value=>'&'.$m->{identifier}->text)],named=>[]), 
     91        ); 
     92        AST::Call->new(identifier=>AST::StringConstant->new(value=>'postcircumfix:( )'),capture=>AST::Capture->new(invocant=>$func,positional=>args($m->{args}))); 
     93    } 
     94} 
     95sub args { 
     96    my $m = shift; 
     97    return [map {EXPR($_->{EXPR})} @{$m->{arglist}}]; 
    4298} 
    4399sub routine_def { 
     
    62118    if ($m->{number}) { 
    63119        number($m->{number}); 
    64     } if ($m->{quote}) { 
     120    } elsif ($m->{quote}) { 
    65121        quote($m->{quote}); 
     122    } else { 
     123        warn Dump($m->{number}); 
     124        warn Dump($m); 
     125        XXX; 
    66126    } 
    67127} 
     
    76136    if ($m->{integer}) { 
    77137        integer($m->{integer}); 
     138    } else { 
     139        XXX; 
    78140    } 
    79141}