Skip to content

Commit

Permalink
perl6 --output
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/trunk@2371 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
leo committed Oct 10, 2002
1 parent 3898587 commit 02c63c7
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions languages/perl6/perl6
Expand Up @@ -41,7 +41,7 @@ $LIBPA =~ s/\$\(A\)/$LIB/;
#
# imported meth's for Test::More
$TEST_IMPORT = 'skip is';

use vars '%OPT';

sub usage($) {
Expand Down Expand Up @@ -111,7 +111,7 @@ Parser options:
--trace set $::RD_TRACE (or construct trace-enabled parser)
--grammar NAME
use precompiled grammar NAME (default = Perl6grammar)
only useful when constructing parser:
--hitem keep track of %item hash
--force-grammar
Expand Down Expand Up @@ -163,6 +163,7 @@ GetOptions(\%OPT,qw{
warnings|w+
parrot-options|R=s
compile-pbc|C quick|q ignore-exitcode rm-exe shared
output|o=s
runpbc|r
optimize|O=s
pbc|B pasm|S imc|I
Expand Down Expand Up @@ -335,13 +336,21 @@ sub output_tree {
verbose(2, "compiling tree");
warnings(sub { P6C::IMCC::compile($x) }, $fw);
my $f = "$filebase.imc";
verbose(2, "Writing '$f'");
open(OOUT, '>&STDOUT');
open(STDOUT, ">$f");
if ($OPT{output} eq '-') {
verbose(2, "Writing to STDOUT");
$OPT{imc} = 1; # stop after pipeing output to imcc
}
else {
verbose(2, "Writing '$f'");
open(OOUT, '>&STDOUT');
open(STDOUT, ">$f");
}
warnings(sub { P6C::IMCC::emit() }, $fw);
close(STDOUT);
open(STDOUT, '>&OOUT');
close(OOUT);
if ($OPT{output} ne '-') {
close(STDOUT);
open(STDOUT, '>&OOUT');
close(OOUT);
}
return if ($OPT{imc});
push(@temp_files, $f);
pass2($f, $fw);
Expand Down Expand Up @@ -439,7 +448,12 @@ sub run {
if ($f eq '-') {
$filebase = 'a';
} else {
($filebase = $f) =~ s/\.[^.]*$//;
if ($OPT{output} && $OPT{output} ne '-') {
($filebase = $OPT{output}) =~ s/\.[^.]*$//;
}
else {
($filebase = $f) =~ s/\.[^.]*$//;
}
}
# special, clean all generated files
if ($OPT{clean}) {
Expand Down

0 comments on commit 02c63c7

Please sign in to comment.