| | 38 | } |
| | 39 | sub 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 | } |
| 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 | } |
| | 85 | sub 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 | } |
| | 95 | sub args { |
| | 96 | my $m = shift; |
| | 97 | return [map {EXPR($_->{EXPR})} @{$m->{arglist}}]; |