Benchmark-Perl-Formance-Cargo
view release on metacpan or search on metacpan
share/P6STD/CursorBase.pmc view on Meta::CPAN
#
# Copyright 2008-2010, Larry Wall
#
# You may copy this software under the terms of the Artistic License,
# version 2.0 or later.
use strict;
use warnings;
no warnings 'recursion';
use utf8;
use NAME;
use Stash;
use RE_ast;
#use Carp::Always;
use File::Spec ();
use File::Basename ();
use File::ShareDir ();
use File::Path ();
use Config;
my $TRIE = 1;
my $STORABLE = 1;
use feature 'say', 'state';
require 'mangle.pl';
our $CTX = '';
BEGIN {
$::DEBUG //= 0 + ($ENV{STD5DEBUG} // 0);
}
our $DEBUG;
use constant DEBUG => $::DEBUG;
our %LEXERS; # per language, the cache of lexers, keyed by rule identity
our %FATECACHE; # fates we've already turned into linked lists
my %lexer_cache = ();
sub ::fatestr { my $f = shift;
my $text = '';
while ($f) {
$text .= $f->[1] . " " . $f->[2];
$text .= ' ' if $f = $f->[0];
}
$text;
}
use DEBUG;
sub ::deb {
print ::LOG @_, "\n";
}
package CursorBase;
use Carp;
use File::Copy;
use YAML::XS;
use Storable;
use Encode;
use Scalar::Util 'refaddr';
use Try::Tiny;
use Term::ANSIColor;
our $BLUE = color 'blue';
our $GREEN = color 'green';
our $CYAN = color 'cyan';
our $MAGENTA = color 'magenta';
our $YELLOW = color 'yellow';
our $RED = color 'red';
our $CLEAR = color 'clear';
use LazyMap qw(lazymap eager);
use constant DEBUG => $::DEBUG;
our $REGEXES = { ALL => [] };
BEGIN {
require Moose;
# this prevents us from inheriting from Moose::Object, which saves a
# good 20 seconds on DESTROY/DEMOLISHALL
Moose::Meta::Class->create('CursorBase');
}
our $data_dir;
BEGIN {
# 2 possibilities:
# * STD is installed. CursorBase will be in the system @INC somewhere,
# with nothing but other modules besides it. Use File::ShareDir.
# * STD is being used in place. uniprops will be in the same dir as
# CursorBase.pm
# yes, the INC entry always uses forward slashes and ends in .pm, always
my $path = __PACKAGE__;
$path =~ s#::#/#g;
$data_dir = File::Basename::dirname($INC{"$path.pm"});
if (! -e File::Spec->catfile($data_dir, "uniprops")) {
$data_dir = File::ShareDir::dist_dir('STD');
}
}
$::PERL6HERE = $ENV{PERL6HERE} // 'â';
Encode::_utf8_on($::PERL6HERE);
binmode(STDIN, ":utf8");
binmode(STDERR, ":utf8");
binmode(STDOUT, ":utf8");
BEGIN {
if ($^P || !DEBUG) {
open(::LOG, ">&1") or die "Cannot create $0.log: $!";
}
else {
open(::LOG, ">$0.log") or die "Cannot create $0.log: $!";
}
binmode(::LOG, ":utf8");
}
#############################################################
# Cursor Accessors
#############################################################
sub _PARAMS {} # overridden in parametric role packages
( run in 4.290 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )