Changeset 22589 for misc

Show
Ignore:
Timestamp:
10/12/08 18:11:36 (3 months ago)
Author:
putter
Message:

[elfish/STD_blue] Update for elf_h.
[elf_h] eval_perl5 restored for rx_on_re (commit forgotten recently).

Location:
misc
Files:
1 removed
5 modified

Legend:

Unmodified
Added
Removed
  • misc/elf/elf_h

    r22560 r22589  
    288288      $res 
    289289    } 
     290  } 
     291  sub eval_perl5{ 
     292    my($p5,$env)=@_; 
     293    eval_runtime_code($p5,$env); 
    290294  } 
    291295  sub die{croak @_} 
     
    32283232\ \ \ \ \}\ 
    32293233\ \ \}\ 
     3234\ \ sub\ eval_perl5\{\ 
     3235\ \ \ \ my\(\$p5\,\$env\)\=\@_\;\ 
     3236\ \ \ \ eval_runtime_code\(\$p5\,\$env\)\;\ 
     3237\ \ \}\ 
    32303238\ \ sub\ die\{croak\ \@_\}\ 
    32313239\ \ sub\ exit\{CORE\:\:exit\(\@_\)\}\ 
  • misc/elf/elf_h_src/EmitSimpleP5.pm

    r22560 r22589  
    321321      $res 
    322322    } 
     323  } 
     324  sub eval_perl5{ 
     325    my($p5,$env)=@_; 
     326    eval_runtime_code($p5,$env); 
    323327  } 
    324328  sub die{croak @_} 
  • misc/elfish/STD_blue/IRx1_FromAST2_create.pl

    r22234 r22589  
    6969    my $rule = $m.rule; 
    7070    my $constructor = $.constructors{$rule}; 
    71     if ($constructor) { 
     71    if $constructor { 
    7272      $constructor.($m); 
    7373    } else { 
    74       die "Unknown rule: "~$rule~"\nIt needs to be added to ast_handlers.\n"; 
     74      my $g = $rule.re_groups('\A([^:]+):'); 
     75      if $g { $constructor = $.constructors{$g[0]} } 
     76      if $constructor { 
     77        $constructor.($m); 
     78      } else { 
     79        die "Unknown rule: "~$rule~"\nIt needs to be added to ast_handlers.\n"; 
     80      } 
    7581    } 
    7682  }; 
     
    106112  } 
    107113}; 
    108  
    109  
    110 if not($*ast2ir_0) { $*ast2ir_0 = IRx1_Build2.new.init; } 
    111 $*ast2ir_1 = IRx1_Build2.new.init; 
    112114 
    113115END_CODE 
     
    132134      }; 
    133135 
    134       method init { 
    135  
    136   END 
     136  END 
     137  my $init = ""; 
    137138 
    138139  my %seen; 
     
    142143    die "Saw an AST handler for '$name' twice!\n" if $seen{$name}++; 
    143144 
    144     $body =~ s{\s*=~\s*s/((?:[^\\\/]|\\.)*)/((?:[^\\\/]|\\.)*)/g;}{.re_gsub(rx:P5/$1/,"$2");}g; 
    145  
    146145    $body =~ s/\bir\(/irbuild_ir\(/g; 
    147146    $body =~ s/(\$m(?:<\w+>)+)/irbuild_ir($1)/g; 
    148147    $body =~ s/\$o((?:<\w+>)+)/\$m$1/g; 
    149     $body =~ s/<(\w+)>/.{'hash'}{'$1'}/g; 
     148    $body =~ s/<(\w+)>/.hash{'$1'}/g; 
    150149    $body =~ s/([A-Z]\w+\.new\w*)\(/IRx1::$1(\$m,/g; 
    151150    $body =~ s/\*text\*/(\$m.match_string)/g; 
     
    154153      $body = unindent(<<'      END',"  ").$body; 
    155154        my $key; 
    156         for $m.{'hash'}.keys { 
     155        for $m.hash.keys { 
    157156          if $_ ne 'match' { 
    158157            if $key { 
    159               die("Unexpectedly more than 1 field in NAME - dont know which to choose\n") 
     158              die("Unexpectedly more than 1 field - dont know which to choose\n") 
    160159            } 
    161160            $key = $_; 
    162161          } 
    163162        } 
    164         my $one = irbuild_ir($m.{'hash'}{$key}); 
     163        my $one = irbuild_ir($m.hash{$key}); 
    165164      END 
    166         $body =~ s/NAME/$name/; 
    167165    } 
    168166 
     167    my $fname = $name; 
     168    $fname =~ s/(\W)/"_".ord($1)/eg; 
    169169    $code .= "\n".unindent(<<"    END","    "); 
    170       \$.add_constructor('$name', sub (\$m) { 
     170      my \$construct_$fname = sub (\$m) { 
    171171        $body; 
    172       }); 
     172      }; 
    173173    END 
     174    $init .= "".unindent(<<"    END","    "); 
     175      \$.add_constructor('$name', \$construct_$fname); 
     176    END 
    174177 
    175178  } 
    176179  $code .= unindent(<<"  END"); 
     180    method init { 
     181 
     182  END 
     183  $code .= unindent(<<"  END"); 
     184      $init 
    177185      self; 
    178186    }; # end init 
    179   } 
     187  }; 
     188 
     189  END 
     190  $code .= unindent(<<'  END'); 
     191 
     192  if not($*ast2ir_0) { $*ast2ir_0 = IRx1_Build.new.init; } 
     193  $*ast2ir_1 = IRx1_Build.new.init; 
     194 
    180195  END 
    181196  open(F,">$file") or die $!; print F $code; close F; 
  • misc/elfish/STD_blue/Makefile

    r22234 r22589  
    11 
    22elfx:: 
    3         ELF_STD_RED_RUN=../../STD_red/STD_red_run ../../elf/elf_g -x -o ./elfx -I ../../elf/elf_g_src Elfx.pm 
     3        ../../elf/elf_h -x -o ./elfx -I ../../elf/elf_h_src -e 'use Elf_wo_main' IRx1_FromAST2.pm Parser2.pm -e elf_main 
  • misc/elfish/STD_blue/STD_blue_run

    r22586 r22589  
    144144  sub to_dump0 { 
    145145    my($o)=@_; 
     146    local $seen{$o} = $seen{$o}; 
    146147    if($seen{$o}++ > $max_repetition) { return "LOOP:$o"->to_dump0 } 
    147148    my $f = $o->{_from};