| 1 | package Business::UDC; | ||||||||||
| 2 | |||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 7 | ▶ | use Business::UDC::Parser qw(parse); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 7 | ▶ | use English; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 7 | ▶ | use Error::Pure::Utils qw(err_get); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 7 | our $VERSION = 0.12; | |||||||||
| 11 | |||||||||||
| 12 | # Constructor. | ||||||||||
| 13 | 76 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 14 | 76 | my ($class, $source) = @_; | |||||||||
| 15 | |||||||||||
| 16 | # Create object. | ||||||||||
| 17 | 76 | my $self = bless { | |||||||||
| 18 | 'source' => $source, | ||||||||||
| 19 | '_ast' => undef, | ||||||||||
| 20 | '_error' => [], | ||||||||||
| 21 | '_tokens' => [], | ||||||||||
| 22 | '_valid' => 0, | ||||||||||
| 23 | }, $class; | ||||||||||
| 24 | |||||||||||
| 25 | 76 | my $res_hr = eval { | |||||||||
| 26 | 76 | parse($self->{'source'}); | |||||||||
| 27 | }; | ||||||||||
| 28 | 76 | ▶ | if ($EVAL_ERROR) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 32 | chomp $EVAL_ERROR; | |||||||||
| 30 | 32 | my ($error_hr) = err_get(1); | |||||||||
| 31 | 32 | my @err = @{$error_hr->{'msg'}}; | |||||||||
| 32 | 32 | $self->{'_error'} = \@err; | |||||||||
| 33 | } else { | ||||||||||
| 34 | 44 | $self->{'_ast'} = $res_hr->{'ast'}; | |||||||||
| 35 | 44 | $self->{'_tokens'} = $res_hr->{'tokens'}; | |||||||||
| 36 | 44 | $self->{'_valid'} = 1; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 76 | return $self; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 3 | ▶ | sub ast { | ||||||||
|
Subroutine
ast: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 43 | 3 | my $self = shift; | |||||||||
| 44 | |||||||||||
| 45 | 3 | return $self->{'_ast'}; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 13 | ▶ | sub error { | ||||||||
|
Subroutine
error: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 49 | 13 | my $self = shift; | |||||||||
| 50 | |||||||||||
| 51 | 13 | ▶ | return wantarray ? @{$self->{'_error'}} : $self->{'_error'}->[0]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 57 | ▶ | sub is_valid { | ||||||||
|
Subroutine
is_valid: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 55 | 57 | my $self = shift; | |||||||||
| 56 | |||||||||||
| 57 | 57 | return $self->{'_valid'}; | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 1 | ▶ | sub source { | ||||||||
|
Subroutine
source: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 61 | 1 | my $self = shift; | |||||||||
| 62 | |||||||||||
| 63 | 1 | return $self->{'source'}; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | sub tokens { | ||||||||
|
Subroutine
tokens: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 67 | 0 | my $self = shift; | |||||||||
| 68 | |||||||||||
| 69 | 0 | return $self->{'_tokens'}; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 7 | 1; | |||||||||
| 73 | |||||||||||
| 74 | __END__ | ||||||||||