| 1 | 20 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | package YAMLScript::RT; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 20 | ▶ | use Lingy::RT; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 20 | ▶ | use base 'Lingy::RT'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 20 | ▶ | use YAMLScript::Lingy; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 20 | ▶ | use YAMLScript::Common; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 20 | ▶ | use YAMLScript::Core; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 20 | ▶ | use YAMLScript::Reader; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 20 | ▶ | use YAMLScript::ReadLine; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 20 | ▶ | use constant LANG => 'YAMLScript'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 20 | ▶ | use constant reader_class => 'YAMLScript::Reader'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 20 | ▶ | use constant RL => YAMLScript::ReadLine->new; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 20 | ▶ | use constant repl_intro_command => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 20 | q<(println (str *LANG* " " (yamlscript-version) " [" *HOST* "]\n"))>; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 19 | ▶ | sub class_names { | ||||||||||||||||||||||||||
|
Subroutine
class_names: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | [ | ||||||||||||||||||||||||||||
| 22 | 19 | @{Lingy::RT::class_names()}, | |||||||||||||||||||||||||||
| 23 | 'Lingy::RT', | ||||||||||||||||||||||||||||
| 24 | 'YAMLScript::Core', | ||||||||||||||||||||||||||||
| 25 | ]; | ||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 20 | my $reader; | |||||||||||||||||||||||||||
| 29 | 10 | ▶ | sub reader { $reader } | ||||||||||||||||||||||||||
|
Subroutine
reader: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 20 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | 20 | my $self = shift; | |||||||||||||||||||||||||||
| 33 | 20 | $self->SUPER::init(@_); | |||||||||||||||||||||||||||
| 34 | 20 | $reader = $self->require_new($self->reader_class); | |||||||||||||||||||||||||||
| 35 | 20 | $self->rep(q< (use 'YAMLScript.Core) >); | |||||||||||||||||||||||||||
| 36 | 20 | return $self; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 20 | ▶ | sub core_namespace { | ||||||||||||||||||||||||||
|
Subroutine
core_namespace: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | 20 | my $self = shift; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 20 | my $ns = $self->SUPER::core_namespace(@_); | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 20 | $YAMLScript::VERSION =~ /^(\d+)\.(\d+)\.(\d+)$/; | |||||||||||||||||||||||||||
| 45 | 20 | $self->rep(" | |||||||||||||||||||||||||||
| 46 | (def *yamlscript-version* | ||||||||||||||||||||||||||||
| 47 | { | ||||||||||||||||||||||||||||
| 48 | :major $1 | ||||||||||||||||||||||||||||
| 49 | :minor $2 | ||||||||||||||||||||||||||||
| 50 | :incremental $3 | ||||||||||||||||||||||||||||
| 51 | :qualifier nil | ||||||||||||||||||||||||||||
| 52 | }) | ||||||||||||||||||||||||||||
| 53 | "); | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 20 | return $ns; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 5648 | ▶ | sub is_lingy_class { | ||||||||||||||||||||||||||
|
Subroutine
is_lingy_class: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 59 | 5648 | my ($self, $class) = @_; | |||||||||||||||||||||||||||
| 60 | 5648 | ▶ | $class->isa(CLASS) or $class =~ /^(?:Lingy|YAMLScript)::\w/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | # TODO Find cleaner way to override 'require' to support .ys files. | ||||||||||||||||||||||||||||
| 65 | 20 | ▶ | use Lingy::RT; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 66 | package Lingy::RT; | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 20 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 20 | ▶ | sub require { | ||||||||||||||||||||||||||
|
Subroutine
require: called CC=9 SCAR=23.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 71 | outer: | ||||||||||||||||||||||||||||
| 72 | 20 | for my $spec (@_) { | |||||||||||||||||||||||||||
| 73 | 20 | ▶ | err "'require' only works with symbols" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | unless ref($spec) eq SYMBOL; | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 20 | ▶ | return nil if $Lingy::Main::ns{$$spec}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 20 | my $name = $$spec; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 20 | my $path = $name; | |||||||||||||||||||||||||||
| 81 | 20 | $path =~ s/^lingy\.lang\./Lingy./; | |||||||||||||||||||||||||||
| 82 | 20 | $path =~ s/^lingy\./Lingy./; | |||||||||||||||||||||||||||
| 83 | 20 | $path =~ s/^ys\./YAMLScript./; | |||||||||||||||||||||||||||
| 84 | 20 | my $module = $path; | |||||||||||||||||||||||||||
| 85 | 20 | $path =~ s/\./\//g; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 20 | for my $inc (@INC) { | |||||||||||||||||||||||||||
| 88 | 30 | $inc =~ s{^([^/.])}{./$1}; | |||||||||||||||||||||||||||
| 89 | 30 | my $inc_path = "$inc/$path"; | |||||||||||||||||||||||||||
| 90 | 30 | ▶ | if (-f "$inc_path.ly" or | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
-f "$inc_path.ly" or -f "$inc_path.ys"
MC/DC50%1/2
-f "$inc_path.ly" or -f "$inc_path.ys"
-f "$inc_path.ly"
-f "$inc_path.ys"
Truth table66%2/3
A or B
A= -f "$inc_path.ly"B= -f "$inc_path.ys"
| |||||||||||||||||||||||||||||
| 91 | -f "$inc_path.ys" | ||||||||||||||||||||||||||||
| 92 | ) { | ||||||||||||||||||||||||||||
| 93 | 20 | ▶ | if (-f "$inc_path.ly") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 20 | my $ns = RT->current_ns; | |||||||||||||||||||||||||||
| 95 | 20 | RT->rep(qq< (load-file "$inc_path.ly") >); | |||||||||||||||||||||||||||
| 96 | 20 | $ns->current; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | 20 | ▶ | if (-f "$inc_path.ys") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 0 | my $ns = RT->current_ns; | |||||||||||||||||||||||||||
| 100 | 0 | RT->rep(qq< (load-file "$inc_path.ys") >); | |||||||||||||||||||||||||||
| 101 | 0 | $ns->current; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | 20 | next outer; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | 0 | err "Can't find library for (require '$name)"; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | 20 | return nil; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 20 | 1; | |||||||||||||||||||||||||||