| 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package DBIx::MyParsePP::Token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use DBIx::MyParsePP::Symbols; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use constant TOKEN_TYPE => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use constant TOKEN_VALUE => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 723 | ▶ | my ($class, $type, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 723 | my $token = bless([], $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 723 | $token->[TOKEN_TYPE] = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 723 | $token->[TOKEN_VALUE] = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 723 | return $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | sub value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 55 | ▶ | return $_[0]->[TOKEN_VALUE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | sub type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 176 | ▶ | return $_[0]->[TOKEN_TYPE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | sub getValue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | return $_[0]->[TOKEN_VALUE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getValue: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | sub getType { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | return $_[0]->[TOKEN_TYPE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getType: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | sub setType { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | $_[0]->[TOKEN_TYPE] = $_[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setType: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | sub setValue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | $_[0]->[TOKEN_VALUE] = $_[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setValue: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | sub extract { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 58 | ▶ | my $token = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | sub extractInner { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my $token = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extractInner: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return $token->extract(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | sub children { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | return (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
children: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # Shrinking has no effect on tokens, just return original token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | sub shrink { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 30 | ▶ | return $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shrink: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | sub toString { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 54 | ▶ | my $token = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toString: called CC=16 SCAR=42.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | sub print { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | return $_[0]->toString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||