| 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package DBIx::MyParsePP::Token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use DBIx::MyParsePP::Symbols; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use constant TOKEN_TYPE => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use constant TOKEN_VALUE => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 769 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 769 | my ($class, $type, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 769 | my $token = bless([], $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 769 | $token->[TOKEN_TYPE] = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 769 | $token->[TOKEN_VALUE] = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 769 | return $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 147 | ▶ | sub value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 147 | return $_[0]->[TOKEN_VALUE]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 268 | ▶ | sub type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 268 | return $_[0]->[TOKEN_TYPE]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub getValue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getValue: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | return $_[0]->[TOKEN_VALUE]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub getType { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getType: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | return $_[0]->[TOKEN_TYPE]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub setType { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setType: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | $_[0]->[TOKEN_TYPE] = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub setValue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setValue: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $_[0]->[TOKEN_VALUE] = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 58 | ▶ | sub extract { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 58 | my $token = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 58 | foreach my $match (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 118 | ▶ | return $token if $token->type() eq $match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 54 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub extractInner { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extractInner: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $token = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return $token->extract(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | sub children { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
children: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # Shrinking has no effect on tokens, just return original token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 89 | ▶ | sub shrink { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shrink: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 89 | return $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 54 | ▶ | sub toString { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toString: called CC=16 SCAR=42.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 54 | my $token = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 54 | my $type = $token->type(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 54 | my $value = $token->value(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 54 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 54 | ▶ | if ($type eq 'NCHAR_STRING') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 13 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $result = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $result =~ s{\\}{\\\\}sgio; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $result =~ s{'}{\\'}sgio; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $result = "N'".$result."'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } elsif ($type eq 'IDENT_QUOTED') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | return '`'.$value.'` '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } elsif ($type eq 'GLOBAL_SYM') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | return $value; # No spaces | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } elsif ($type eq 'SET_VAR') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $result = ':='; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } elsif ($type eq 'BIN_NUM') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $result = "b'".$value."'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } elsif ($type eq 'HEX_NUM') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $result = ' 0x'.$value.' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } elsif ($type eq 'TEXT_STRING') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $result = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $result =~ s{\\}{\\\\}sgio; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $result =~ s{'}{\\'}sgio; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $result = "'".$result."'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } elsif ($type eq 'UNDERSCORE_CHARSET') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $result = '_'.$value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } elsif ($type eq '@') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | return '@'; # No leading space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ▶ | } elsif (($type eq 'IDENT') || ($type eq 'LEX_HOSTNAME')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$type eq "IDENT" or $type eq "LEX_HOSTNAME"
MC/DC50%1/2
$type eq "IDENT" or $type eq "LEX_HOSTNAME"
$type eq "IDENT"
$type eq "LEX_HOSTNAME"
Truth table66%2/3
A or B
A= $type eq "IDENT"B= $type eq "LEX_HOSTNAME"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 43 | return $value.' '; # No leading space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } elsif ($DBIx::MyParsePP::Symbols::functions->{uc($value)} eq $type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | return ' '.$value; # No trailing space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } elsif ($type eq '(') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | return $value.' '; # No leading space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ▶ | } elsif (($type eq '.') || ($type eq '*')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$type eq "." or $type eq "*"
MC/DC0%0/2
$type eq "." or $type eq "*"
$type eq "."
$type eq "*"
Truth table33%1/3
A or B
A= $type eq "."B= $type eq "*"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 11 | return $value; # No spaces around table.field, etc. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $result = ' '.$value.' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub print { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | return $_[0]->toString(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 46 | ▶ | sub isEqual { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isEqual: called CC=3 SCAR=13.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 46 | ▶ | return 0 if !$_[1]->isa( 'DBIx::MyParsePP::Token' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 46 | ▶ | return $_[0]->type() eq $_[1]->type() && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_[0]->type eq $_[1]->type && $_[0]->value eq $_[1]->value
MC/DC0%0/2
$_[0]->type eq $_[1]->type && $_[0]->value eq $_[1]->value
$_[0]->type eq $_[1]->type
$_[0]->value eq $_[1]->value
Truth table33%1/3
A && B
A= $_[0]->type eq $_[1]->typeB= $_[0]->value eq $_[1]->value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | $_[0]->value() eq $_[1]->value(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||