| 1 | package AutoCode::AttributeType; | ||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | 5 | ▶ | use AutoCode::Root; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 5 | 5 | our @ISA=qw(AutoCode::Root); | |||||||||||||||||||||
| 6 | |||||||||||||||||||||||
| 7 | 5 | ▶ | use AutoCode::AccessorMaker( | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 8 | 5 | '$'=>[qw(string context category content required)] | |||||||||||||||||||||
| 9 | 5 | ); | |||||||||||||||||||||
| 10 | |||||||||||||||||||||||
| 11 | 5 | our $PRIMITIVE_TYPE='cvidft'; | |||||||||||||||||||||
| 12 | |||||||||||||||||||||||
| 13 | 0 | ▶ | sub _initialize { | ||||||||||||||||||||
|
Subroutine
_initialize: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||
| 14 | 0 | my ($self, @args)=@_; | |||||||||||||||||||||
| 15 | 0 | my ($string)= $self->_rearrange([qw(string)], @args); | |||||||||||||||||||||
| 16 | 0 | ▶ | defined $string or $self->throw("string is definitely required"); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 17 | 0 | $self->string($string); | |||||||||||||||||||||
| 18 | 0 | $self->_classify_self; | |||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||
| 20 | |||||||||||||||||||||||
| 21 | 0 | ▶ | sub _classify_self { | ||||||||||||||||||||
|
Subroutine
_classify_self: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 22 | 0 | my $self=shift; | |||||||||||||||||||||
| 23 | 0 | my $string = $self->string; | |||||||||||||||||||||
| 24 | 0 | my ($context, $category, $content, $required)=$self->_classify($string); | |||||||||||||||||||||
| 25 | 0 | $self->context($context); | |||||||||||||||||||||
| 26 | 0 | $self->catogory($category); | |||||||||||||||||||||
| 27 | 0 | $self->content($content); | |||||||||||||||||||||
| 28 | 0 | $self->required($required); | |||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||
| 30 | |||||||||||||||||||||||
| 31 | 39 | ▶ | sub classify { | ||||||||||||||||||||
|
Subroutine
classify: called CC=6 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||
| 32 | 39 | my ($self, $string)=@_; | |||||||||||||||||||||
| 33 | |||||||||||||||||||||||
| 34 | 39 | ▶ | $self->throw("[$string] must start with [%@\$]") | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 35 | unless $string =~ s/^([\%\@\$])//; | ||||||||||||||||||||||
| 36 | 39 | my $context=$1; | |||||||||||||||||||||
| 37 | 39 | my $required=$string=~s/\!$//; | |||||||||||||||||||||
| 38 | |||||||||||||||||||||||
| 39 | 39 | my ($category, $content); | |||||||||||||||||||||
| 40 | 39 | local $_=$string; | |||||||||||||||||||||
| 41 | 39 | ▶ | if(/^$/){ | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 42 | 24 | ($category, $content)=('P', 'v255'); # Default | |||||||||||||||||||||
| 43 | }elsif(/^([$PRIMITIVE_TYPE])(([\+\^]?[\d]+)(\.\d+)?)?(U?)$/){ | ||||||||||||||||||||||
| 44 | 0 | ($category, $content)=('P', $string); | |||||||||||||||||||||
| 45 | }elsif(/^\{([^}]+)\}$/){ | ||||||||||||||||||||||
| 46 | 0 | ($category, $content)=('E', $1); | |||||||||||||||||||||
| 47 | }elsif(/^([_A-Z]\w+)$/){ | ||||||||||||||||||||||
| 48 | 15 | ($category, $content)=('M', $1); | |||||||||||||||||||||
| 49 | }else{ | ||||||||||||||||||||||
| 50 | 0 | $self->throw("[$string] does not match any kind of pattern"); | |||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||
| 52 | 39 | return ($context, $category, $content, $required); | |||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||
| 54 | |||||||||||||||||||||||
| 55 | 5 | 1; | |||||||||||||||||||||