Benchmark-Perl-Formance-Cargo

 view release on metacpan or  search on metacpan

share/P6STD/viv  view on Meta::CPAN

#!/usr/bin/env perl

=head1 NAME

viv - The STD.pm6 command line multitool

=head1 SYNOPSIS

viv [options] [file...]

 -e --evaluate TEXT          Use code from the command line
    --thaw                   Input is a --freeze dump, not Perl 6
 -o --output FILE            Send result to FILE, not stdout
    --noperl6lib             Disable use of the PERL6LIB variable
    --symlroot DIR           Use DIR as parsed module cache
    --concise                Pretty-print the parse tree (default)
 -c --check                  Just check syntax
    --freeze                 Generate Storable dump of parse tree
 -y --yaml                   Generate YAML parse tree
 -5 --p5                     Translate to Perl 5 syntax
 -6 --p6                     Translate back to Perl 6
    --psq                    Translate to Perlesque syntax
 -s --stab                   Include symbol table in output
 -m --match                  Include match tree in output
    --no-indent              Disable indentation of output
 -l --log                    Be verbose while generating output
 -k --keep-going             Don't stop if error found during output phase
    --compile-setting FILE   Preparse a CORE.setting file
    --help                   This message

=cut

use strict;
use 5.010;
use warnings FATAL => 'all';

use List::Util qw/sum min/;

use utf8;
use YAML::XS; # An attempt to replace this with YAML::Syck passed the
              # tests but produced a different output format that
              # confused some calling programs.  For example, anchors
              # are usually numbers ascending from 1, and they became
              # disjoint sets of descending numbers.  Also, empty
              # sequences shown as [] became followed by an empty line.
              # See also: YAML::Syck in package VAST::package_def below.
use Encode;
use Scalar::Util 'blessed', 'refaddr';
use Storable;
use Try::Tiny;

our $OPT_match = 0;
our $OPT_log = 0;
our $OPT_stab = 0;
our $OPT_thaw = 0;
our $OPT_keep_going = 0;
our $OPT_compile_setting = 0;
our $OPT_output_file = undef;
my $PROG = '';
our $ORIG;
my $U = 0;
my @did_ws;

my @context;
$::MULTINESS = '';
# XXX STD Global trait tables simulate inheritance
local $::PROTOENDSYM = {};
local $::PROTOSIG = {};

BEGIN {
    # Let's say you have a tricky optimization that breaks the build.  You want
    # to know exactly which rewrite is culpable?  Try bisecting with
    # VIV_OPTLIMIT, after wrapping the rewrite in if (DARE_TO_OPTIMIZE).
    my $optlimit = $ENV{VIV_OPTLIMIT};
    if (defined $optlimit) {
        *DARE_TO_OPTIMIZE = Sub::Name::subname(DARE_TO_OPTIMIZE => sub {
                $optlimit-- > 0
        });
    } else {
        constant->import(DARE_TO_OPTIMIZE => 1);
    }
}

our $OPT_output = 'concise';

use FindBin;
use File::Spec;
use Getopt::Long 2.34 'HelpMessage';

my ($boot, $symlroot);
{
    no warnings;
    $CursorBase::NOPERL6LIB;
}

my $r = GetOptions(
    "evaluate|e=s" => sub { $PROG .= Encode::decode_utf8($_[1]) . "\n" },
    "boot"         => \$boot,
    "noperl6lib"   => \$CursorBase::NOPERL6LIB,
    "symlroot"     => \$symlroot,
    "concise"      => sub { $OPT_output = 'concise' },
    "yaml|y"       => sub { $OPT_output = 'yaml' },
    "output|o=s"   => \$OPT_output_file,
    "p5|5"         => sub { $OPT_output = 'p5' },
    "p6|6"         => sub { $OPT_output = 'p6' },
    "psq"          => sub { $OPT_output = 'psq' },
    "freeze"       => sub { $OPT_output = 'store' },
    "check|c"      => sub { $OPT_output = 'none' },
    "stab|s"       => \$OPT_stab,
    "log|l"        => \$OPT_log,



( run in 0.676 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )