Changeset 22541

Show
Ignore:
Timestamp:
10/08/08 20:23:05 (6 weeks ago)
Author:
pmurias
Message:

[mildew] added some ast creation helpers, because the Moose constructors are too verbose

Location:
v6/mildew
Files:
1 added
1 removed
1 modified

Legend:

Unmodified
Added
Removed
  • v6/mildew/mildew

    r22526 r22541  
    55use STD; 
    66use AST; 
     7use AST::Helpers; 
    78use DumpMatch; 
    89use utf8; 
     
    3233    confess 'unimplemented' 
    3334} 
    34 sub integer { 
     35sub integer_ { 
    3536    my $m = shift; 
    3637    #XXX non-base 10 
    37     AST::IntegerConstant->new(value=>$m->text); 
     38    integer $m->text; 
    3839} 
    3940sub scope_declarator { 
     
    4344            if (my $var_decl = $decl->{variable_declarator}) { 
    4445                AST::Call->new( 
    45                     identifier => AST::StringConstant->new(value=>'STORE'), 
     46                    identifier => string 'STORE', 
    4647                    capture => AST::Capture->new( 
    4748                        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=>[]) 
     49                            identifier => string 'postcircumfix:{ }', 
     50                            capture => AST::Capture->new(invocant=>reg 'scope',positional=>[string $m->text],named=>[]) 
    5051                        ), 
    5152                        positional => [ 
    5253                            AST::Call->new( 
    53                                 identifier => AST::StringConstant->new(value=>'new'), 
    54                                 invocant => AST::Reg->new(name=>'$Scalar'), 
     54                                identifier => string 'new', 
     55                                invocant => reg '$Scalar', 
    5556                            ) 
    5657                        ] 
     
    8788    if ($m->{identifier} && $m->{args}) { 
    8889        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=>[]), 
     90            identifier=>string 'lookup', 
     91            capture=>AST::Capture->new(invocant=>reg 'scope',positional=>[string '&'.$m->{identifier}->text],named=>[]), 
    9192        ); 
    92         AST::Call->new(identifier=>AST::StringConstant->new(value=>'postcircumfix:( )'),capture=>AST::Capture->new(invocant=>$func,positional=>args($m->{args}))); 
     93        AST::Call->new(identifier=>string 'postcircumfix:( )',capture=>AST::Capture->new(invocant=>$func,positional=>args($m->{args}))); 
    9394    } 
    9495} 
     
    99100sub routine_def { 
    100101    my $m = shift; 
    101     AST::Call->new(identifier=>AST::StringConstant->new(value => 'new'), 
     102    AST::Call->new(identifier=>string 'new', 
    102103        capture => AST::Capture->new( 
    103             invocant => AST::Reg->new(name=>'Code'), 
     104            invocant => reg 'Code', 
    104105            positional => [], 
    105106            named => [ 
    106                 AST::StringConstant->new(value=>'mold') => block($m->{block}), 
    107                 AST::StringConstant->new(value=>'outer') => AST::Reg->new(name=>'$scope') 
     107                string 'mold' => block($m->{block}), 
     108                string 'outer' => reg '$scope' 
    108109            ] 
    109110        ), 
     
    130131    #XXX 
    131132    my $text = $m->{nibble}->text; 
    132     AST::StringConstant->new(value=>$text); 
     133    string $text; 
    133134} 
    134135sub number { 
    135136    my $m = shift; 
    136137    if ($m->{integer}) { 
    137         integer($m->{integer}); 
     138        integer_($m->{integer}); 
    138139    } else { 
    139140        XXX; 
     
    143144    my $m = shift; 
    144145    AST::Call->new( 
    145         identifier=>AST::StringConstant->new(value=>'lookup'), 
    146         capture=>AST::Capture->new(invocant=>AST::Reg->new(name=>'scope'),positional=>[AST::StringConstant->new(value=>$m->text)],named=>[]), 
     146        identifier=>string 'lookup', 
     147        capture=>AST::Capture->new(invocant=>reg 'scope',positional=>[string $m->text],named=>[]), 
    147148    ); 
    148149} 
     
    166167sub FETCH { 
    167168    my $arg = shift; 
    168     AST::Call->new(capture=>AST::Capture->new(invocant=>$arg),identifier=>AST::StringConstant->new(value=>'FETCH')); 
     169    AST::Call->new(capture=>AST::Capture->new(invocant=>$arg),identifier=>string 'FETCH'); 
    169170} 
    170171sub methodop { 
     
    173174        my $pos0 = $m->{in}[0]{semilist}{statement}[0]; 
    174175        AST::Call->new( 
    175             identifier=>AST::StringConstant->new(value=>$m->{longname}->text), 
     176            identifier=>string $m->{longname}->text, 
    176177            capture=>AST::Capture->new(invocant=>FETCH($noun),positional=>[FETCH(EXPR($pos0->{EXPR}))],named=>[]), 
    177178