MyParsePP/Lexer.pm

filter: Statementstmt 68.7% 444 / 646 Branchbran 46.9% 155 / 330 Conditioncond 35.3% 52 / 147 MC/DCmcdc 23.2% 20 / 86 Subroutinesub 92.0% 81 / 88 Podpod 0.0% 0 / 28 totaltotal 56.7% 752 / 1325 CC 216 SCAR 74.9
CC
216
Cov
58%
MYSQLlex
3438.8
int_token
230.0
get_text
213.4
CRAP 1781.5
↑ Summary MyParsePP/Token.pm »
1 # This program is free software; you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation; version 2 of the License.
4  
5 # This program is distributed in the hope that it will be useful,
6 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 # GNU General Public License for more details.
9 #
10 # You should have received a copy of the GNU General Public License
11 # along with this program; if not, write to the Free Software
12 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13  
14 # Based on code Copyright (C) 2000-2006 MySQL AB
15  
16 package DBIx::MyParsePP::Lexer;
17 8 require Exporter;
18 8 @ISA = qw(Exporter);
19 8 @EXPORT = qw(MODE_PIPES_AS_CONCAT MODE_ANSI_QUOTES MODE_IGNORE_SPACE MODE_NO_BACKSLASH_ESCAPES
20 CLIENT_MULTI_STATEMENTS MODE_HIGH_NOT_PRECEDENCE);
21  
22 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 9 ▶use DBIx::MyParsePP::Symbols;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 8 ▶use DBIx::MyParsePP::Charsets;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 8 ▶use DBIx::MyParsePP::Token;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 8 ▶use constant CTYPE_U => 01; # Uppercase
Subroutine BEGIN: called CC=1 SCAR=0.0
29 8 ▶use constant CTYPE_L => 02; # Lowercase
Subroutine BEGIN: called CC=1 SCAR=0.0
30 8 ▶use constant CTYPE_NMR => 04; # Numeral (digit)
Subroutine BEGIN: called CC=1 SCAR=0.0
31 8 ▶use constant CTYPE_SPC => 010; # Spacing character
Subroutine BEGIN: called CC=1 SCAR=0.0
32 8 ▶use constant CTYPE_PNT => 020; # Punctuation
Subroutine BEGIN: called CC=1 SCAR=0.0
33 8 ▶use constant CTYPE_CTR => 040; # Control character
Subroutine BEGIN: called CC=1 SCAR=0.0
34 8 ▶use constant CTYPE_B => 0100; # Blank
Subroutine BEGIN: called CC=1 SCAR=0.0
35 8 ▶use constant CTYPE_X => 0200; # heXadecimal digit
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 8 ▶use constant LEXER_STRING => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 8 ▶use constant LEXER_CHARSET => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 8 ▶use constant LEXER_VERSION => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 8 ▶use constant LEXER_SQL_MODE => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 8 ▶use constant LEXER_OPTIONS => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 8 ▶use constant LEXER_CLIENT_CAPABILITIES => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 8 ▶use constant LEXER_STMT_PREPARE_MODE => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 8 ▶use constant LEXER_PTR => 7;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 8 ▶use constant LEXER_TOK_START => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 8 ▶use constant LEXER_TOKENS => 9;
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 8 ▶use constant LEXER_YYLINENO => 10;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 8 ▶use constant LEXER_NEXT_STATE => 11;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 8 ▶use constant LEXER_IN_COMMENT => 12;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 8 ▶use constant LEXER_FOUND_SEMICOLON => 13;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 8 ▶use constant LEXER_SAFE_TO_CACHE_QUERY => 14;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 8 ▶use constant LEXER_SERVER_STATUS => 15;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 8 ▶use constant LEXER_CTYPE => 16;
Subroutine BEGIN: called CC=1 SCAR=0.0
57  
58  
59 8 ▶use constant OPTION_FOUND_COMMENT => 1 << 15;
Subroutine BEGIN: called CC=1 SCAR=0.0
60 8 ▶use constant CLIENT_MULTI_STATEMENTS => 1 << 16;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 8 ▶use constant SERVER_MORE_RESULTS_EXISTS => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 8 ▶use constant NAMES_SEP_CHAR => '\377';
Subroutine BEGIN: called CC=1 SCAR=0.0
63  
64  
65 8 ▶use constant MODE_PIPES_AS_CONCAT => 2; # USE ME!
Subroutine BEGIN: called CC=1 SCAR=0.0
66 8 ▶use constant MODE_ANSI_QUOTES => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
67 8 ▶use constant MODE_IGNORE_SPACE => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 8 ▶use constant MODE_MYSQL323 => 65536;
Subroutine BEGIN: called CC=1 SCAR=0.0
69 8 ▶use constant MODE_MYSQL40 => MODE_MYSQL323 * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
70 8 ▶use constant MODE_ANSI => MODE_MYSQL40 * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
71 8 ▶use constant MODE_NO_AUTO_VALUE_ON_ZERO => MODE_ANSI * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
72 8 ▶use constant MODE_NO_BACKSLASH_ESCAPES => MODE_NO_AUTO_VALUE_ON_ZERO * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
73 8 ▶use constant MODE_STRICT_TRANS_TABLES => MODE_NO_BACKSLASH_ESCAPES * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
74 8 ▶use constant MODE_STRICT_ALL_TABLES => MODE_STRICT_TRANS_TABLES * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
75 8 ▶use constant MODE_NO_ZERO_IN_DATE => MODE_STRICT_ALL_TABLES * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 8 ▶use constant MODE_NO_ZERO_DATE => MODE_NO_ZERO_IN_DATE * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
77 8 ▶use constant MODE_INVALID_DATES => MODE_NO_ZERO_DATE * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 8 ▶use constant MODE_ERROR_FOR_DIVISION_BY_ZERO => MODE_INVALID_DATES * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
79 8 ▶use constant MODE_TRADITIONAL => MODE_ERROR_FOR_DIVISION_BY_ZERO * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 8 ▶use constant MODE_NO_AUTO_CREATE_USER => MODE_TRADITIONAL * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
81 8 ▶use constant MODE_HIGH_NOT_PRECEDENCE => MODE_NO_AUTO_CREATE_USER * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
82  
83 8 my %state_maps;
84 my %ident_maps;
85  
86 8 my %args = (
87 string => LEXER_STRING,
88 charset => LEXER_CHARSET,
89 client_capabilities => LEXER_CLIENT_CAPABILITIES,
90 stmt_prepare_mode => LEXER_STMT_PREPARE_MODE,
91 sql_mode => LEXER_SQL_MODE,
92 version => LEXER_VERSION
93 );
94  
95 8 1;
96  
97 14 ▶sub new {
Subroutine new: called CC=9 SCAR=22.6
Pod undocumented
98 14 my $class = shift;
99 14 my $lexer = bless([], $class);
100  
101 14 my $max_arg = (scalar(@_) / 2) - 1;
102  
103 14 foreach my $i (0..$max_arg) {
104 84 ▶ if (exists $args{$_[$i * 2]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{$_[$i * 2]}) { } 84 0 84
105 84 $lexer->[$args{$_[$i * 2]}] = $_[$i * 2 + 1];
106 } else {
107 0 warn("Unkown argument '$_[$i * 2]' to DBIx::MyParsePP::Lexer->new()");
108 }
109 }
110  
111 14 $lexer->[LEXER_STRING] = $lexer->[LEXER_STRING]."\0";
112 14 $lexer->[LEXER_YYLINENO] = 1;
113 14 $lexer->[LEXER_TOK_START] = 0;
114 14 $lexer->[LEXER_PTR] = 0;
115 14 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START';
116  
117 14 ▶ $lexer->[LEXER_CLIENT_CAPABILITIES] = CLIENT_MULTI_STATEMENTS if not defined $lexer->[LEXER_CLIENT_CAPABILITIES];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lexer->[5] 14 0 14
118 14 ▶ $lexer->[LEXER_STMT_PREPARE_MODE] = 0 if not defined $lexer->[LEXER_STMT_PREPARE_MODE];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lexer->[6] 14 0 14
119 14 ▶ $lexer->[LEXER_SQL_MODE] = 0 if not defined $lexer->[LEXER_SQL_MODE]; # CHECKME
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lexer->[3] 13 1 14
120  
121 14 ▶ $lexer->[LEXER_VERSION] = '50045' if not defined $lexer->[LEXER_VERSION];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lexer->[2] 12 2 14
122 14 ▶ $lexer->[LEXER_CHARSET] = 'ascii' if not defined $lexer->[LEXER_CHARSET]; # FIXME
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lexer->[1] 14 0 14
123  
124 14 my $charset_uc = ucfirst($lexer->[LEXER_CHARSET]);
125 8 ▶ eval('
Subroutine BEGIN: called CC=1 SCAR=0.0
126 use DBIx::MyParsePP::'.$charset_uc.';
127 $lexer->[LEXER_CTYPE] = $DBIx::MyParsePP::'.$charset_uc.'::ctype;
128 ');
129  
130 14 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 14 14
131 0 print STDERR "DBIx::MyParsePP::Lexer->new() failed: $@\n";
132 0 return undef;
133 }
134  
135 14 $lexer->[LEXER_TOKENS] = [];
136  
137 14 $lexer->init_state_maps($lexer->[LEXER_CHARSET]);
138  
139 14 return $lexer;
140
141 }
142  
143 1 ▶sub getLine {
Subroutine getLine: called CC=1 SCAR=0.0
Pod undocumented
144 1 return $_[0]->[LEXER_YYLINENO];
145 }
146  
147 0 ▶sub line {
Subroutine line: not called CC=1 SCAR=6.9
Pod undocumented
148 0 return $_[0]->[LEXER_YYLINENO];
149 }
150  
151 0 ▶sub pos {
Subroutine pos: not called CC=1 SCAR=6.9
Pod undocumented
152 0 return $_[0]->[LEXER_PTR];
153 }
154  
155 1 ▶sub getPos {
Subroutine getPos: called CC=1 SCAR=0.0
Pod undocumented
156 1 return $_[0]->[LEXER_PTR];
157 }
158  
159 1 ▶sub getTokens {
Subroutine getTokens: called CC=1 SCAR=0.0
Pod undocumented
160 1 return $_[0]->[LEXER_TOKENS];
161 }
162  
163 0 ▶sub tokens {
Subroutine tokens: not called CC=1 SCAR=6.9
Pod undocumented
164 0 return $_[0]->[LEXER_TOKENS];
165 }
166  
167 4359 ▶sub yyGet { return ord(substr($_[0]->[LEXER_STRING], $_[0]->[LEXER_PTR]++, 1)) };
Subroutine yyGet: called CC=1 SCAR=0.0
Pod undocumented
168 19 ▶sub yyGetLast { ord(substr($_[0]->[LEXER_STRING], $_[0]->[LEXER_PTR] - 1, 1)) };
Subroutine yyGetLast: called CC=1 SCAR=0.0
Pod undocumented
169 388 ▶sub yyPeek { ord(substr($_[0]->[LEXER_STRING], $_[0]->[LEXER_PTR], 1)) };
Subroutine yyPeek: called CC=1 SCAR=0.0
Pod undocumented
170 0 ▶sub yyPeek2 { ord(substr($_[0]->[LEXER_STRING], $_[0]->[LEXER_PTR] + 1, 1)) };
Subroutine yyPeek2: not called CC=1 SCAR=6.9
Pod undocumented
171 554 ▶sub yyUnget { $_[0]->[LEXER_PTR]-- };
Subroutine yyUnget: called CC=1 SCAR=0.0
Pod undocumented
172 109 ▶sub yySkip { $_[0]->[LEXER_PTR]++ };
Subroutine yySkip: called CC=1 SCAR=0.0
Pod undocumented
173 135 ▶sub yyLength { ($_[0]->[LEXER_PTR] - $_[0]->[LEXER_TOK_START]) - 1 };
Subroutine yyLength: called CC=1 SCAR=0.0
Pod undocumented
174  
175 781 ▶sub yylex {
Subroutine yylex: called CC=3 SCAR=11.0
Pod undocumented
176 781 my $lexer = shift;
177 781 my @res = $lexer->MYSQLlex();
178 781 ▶ if (($res[0] eq '0') && ($res[1] eq '0')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res[0] eq '0' and $res[1] eq '0') { } 12 769 781
Condition66%2/3
$res[0] eq 0 and $res[1] eq 0
!ll&&!rl&&r
769012
MC/DC50%1/2
$res[0] eq 0 and $res[1] eq 0
$res[0] eq 0 $res[1] eq 0
Truth table66%2/3
A and B
A= $res[0] eq 0B= $res[1] eq 0
ABresult
0X0
100
111
179 12 return (undef, ''); # EOF
180 } else {
181 769 my $token = DBIx::MyParsePP::Token->new(@res);
182 769 push @{$lexer->[LEXER_TOKENS]}, $token;
183 769 return ($res[0], $token);
184 }
185 }
186  
187 781 ▶sub MYSQLlex {
Subroutine MYSQLlex: called CC=156 SCAR=81.4
Pod undocumented
188 781 my $lexer = shift;
189  
190 781 my $string = $lexer->[LEXER_STRING];
191 781 my $state_map = $state_maps{$lexer->[LEXER_CHARSET]};
192 781 my $ident_map = $ident_maps{$lexer->[LEXER_CHARSET]};
193
194 781 my $c = 0;
195 781 my @token;
196 my $result_state;
197 781 my $state;
198  
199 781 $lexer->[LEXER_TOK_START] = $lexer->[LEXER_PTR];
200  
201  
202 781 $state = $lexer->[LEXER_NEXT_STATE];
203 781 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_OPERATOR_OR_IDENT';
204  
205 781 my $char = substr($string, $lexer->[LEXER_PTR], 1);
206  
207 781 for (;;) {
208 834 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($state eq "MY_LEX_OPERATOR_OR_IDENT" or $state eq "MY_LEX_START") 576 258 834
Condition100%3/3
$state eq "MY_LEX_OPERATOR_OR_IDENT" or $state eq "MY_LEX_START"
l!l&&r!l&&!r
248328258
MC/DC100%2/2
$state eq "MY_LEX_OPERATOR_OR_IDENT" or $state eq "MY_LEX_START"
$state eq "MY_LEX_OPERATOR_OR_IDENT" $state eq "MY_LEX_START"
Truth table100%3/3
A or B
A= $state eq "MY_LEX_OPERATOR_OR_IDENT"B= $state eq "MY_LEX_START"
ABresult
1X1
011
000
209 ($state eq 'MY_LEX_OPERATOR_OR_IDENT') ||
210 ($state eq 'MY_LEX_START')
211 ) {
212 576 ▶ for ($c = $lexer->yyGet(); $state_map->[$c] eq 'MY_LEX_SKIP'; $c = $lexer->yyGet()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state_map->[$c] eq "MY_LEX_SKIP") 941 576 1517
213 941 ▶ $lexer->[LEXER_YYLINENO]++ if $c == ord("\n");
Branch: 1 branch
BranchTrueFalseTotal
if $c == 10 105 836 941
214 }
215 576 $lexer->[LEXER_TOK_START] = $lexer->[LEXER_PTR] - 1;
216 576 $state = $state_map->[$c];
217 }
218
219 834 ▶ if ($state eq 'MY_LEX_ESCAPE') {
Branch: 1 branch
BranchTrueFalseTotal
if ($state eq "MY_LEX_ESCAPE") 0 834 834
220 0 ▶ return ("NULL_SYM","NULL") if $lexer->yyGet() == ord('N');
Branch: 1 branch
BranchTrueFalseTotal
if $lexer->yyGet == 78 0 0 0
221 }
222
223 834 ▶ if (
Branch: 4 branches
BranchTrueFalseTotal
if ($state eq 'MY_LEX_ESCAPE' or $state eq 'MY_LEX_CHAR' or $state eq 'MY_LEX_SKIP') { } 112 722 834
elsif ($state eq 'MY_LEX_IDENT_OR_NCHAR') { } 4 718 722
elsif ($state eq 'MY_LEX_IDENT_OR_HEX') { } 0 718 718
elsif ($state eq 'MY_LEX_IDENT_OR_BIN') { } 7 711 718
Condition66%4/6
$state eq "MY_LEX_ESCAPE" or $state eq "MY_LEX_CHAR" or $state eq "MY_LEX_SKIP"
l!l&&r!l&&!r
1120722
$state eq "MY_LEX_ESCAPE" or $state eq "MY_LEX_CHAR"
l!l&&r!l&&!r
0112722
MC/DC33%1/3
$state eq "MY_LEX_ESCAPE" or $state eq "MY_LEX_CHAR" or $state eq "MY_LEX_SKIP"
$state eq "MY_LEX_ESCAPE" $state eq "MY_LEX_CHAR" $state eq "MY_LEX_SKIP"
Truth table50%2/4
A or B or C
A= $state eq "MY_LEX_ESCAPE"B= $state eq "MY_LEX_CHAR"C= $state eq "MY_LEX_SKIP"
ABCresult
1XX1
01X1
0011
0000
224 ($state eq 'MY_LEX_ESCAPE') ||
225 ($state eq 'MY_LEX_CHAR') ||
226 ($state eq 'MY_LEX_SKIP')
227 ) {
228 112 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 45 and $lexer->yyPeek == 45 and $lexer->my_isspace($lexer->yyPeek2) || $lexer->my_iscntrl($lexer->yyPeek2)) 0 112 112
Condition33%3/9
$c == 45 and $lexer->yyPeek == 45 and $lexer->my_isspace($lexer->yyPeek2) || $lexer->my_iscntrl($lexer->yyPeek2)
!ll&&!rl&&r
11200
$c == 45 and $lexer->yyPeek == 45
!ll&&!rl&&r
11110
$lexer->my_isspace($lexer->yyPeek2) or $lexer->my_iscntrl($lexer->yyPeek2)
l!l&&r!l&&!r
000
MC/DC0%0/4
$c == 45 and $lexer->yyPeek == 45 and $lexer->my_isspace($lexer->yyPeek2) || $lexer->my_iscntrl($lexer->yyPeek2)
$c == 45 $lexer->yyPeek == 45 $lexer->my_isspace($lexer->yyPeek2) $lexer->my_iscntrl($lexer->yyPeek2)
Truth table40%2/5
A and B and C or D
A= $c == 45B= $lexer->yyPeek == 45C= $lexer->my_isspace($lexer->yyPeek2)D= $lexer->my_iscntrl($lexer->yyPeek2)
ABCDresult
0XXX0
10XX0
11000
111X1
11011
229 ($c == ord('-')) &&
230 ($lexer->yyPeek() == ord('-')) &&
231 (
232 ($lexer->my_isspace($lexer->yyPeek2())) ||
233 ($lexer->my_iscntrl($lexer->yyPeek2()))
234 )
235 ) {
236 0 $state = 'MY_LEX_COMMENT';
237 0 next;
238 }
239 112 $lexer->[LEXER_PTR] = $lexer->[LEXER_TOK_START];
240 112 my $lex_str = substr($string, $lexer->[LEXER_PTR], 1);
241 112 $c = $lexer->yyGet();
242
243 112 ▶ $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START' if $c != ord (')');
Branch: 1 branch
BranchTrueFalseTotal
if $c != 41 82 30 112
244  
245 112 ▶ if ($c == ord(',')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c == 44) { } 40 72 112
elsif ($c == 63 and not $$ident_map[$lexer->yyPeek]) { } 0 144 144
246 40 $lexer->[LEXER_TOK_START] = $lexer->[LEXER_PTR];
247 ▶ } elsif (($c == ord('?')) && (!$ident_map->[$lexer->yyPeek()])) { # CHANGED
Condition33%1/3
$c == 63 and not $$ident_map[$lexer->yyPeek]
!ll&&!rl&&r
7200
MC/DC0%0/2
$c == 63 and not $$ident_map[$lexer->yyPeek]
$c == 63 not $$ident_map[$lexer->yyPeek]
Truth table33%1/3
A and not(B)
A= $c == 63B= not $$ident_map[$lexer->yyPeek]
ABresult
0X0
100
111
248 0 return ("PARAM_MARKER","?");
249 }
250 112 return (chr($c), $lex_str);
251 } elsif ($state eq 'MY_LEX_IDENT_OR_NCHAR') {
252 4 ▶ if ($lexer->yyPeek() != ord("'")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->yyPeek != 39) 4 0 4
253 4 $state = 'MY_LEX_IDENT';
254 4 next;
255 }
256 0 $lexer->[LEXER_TOK_START]++;
257 0 $lexer->yySkip();
258 0 my $lex_str;
259 0 ▶ if (!defined ($lex_str = $lexer->get_text())) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined($lex_str = $lexer->get_text)) 0 0 0
260 0 $state = 'MY_LEX_CHAR';
261 0 next;
262 }
263 0 return ('NCHAR_STRING',$lex_str);
264 } elsif ($state eq 'MY_LEX_IDENT_OR_HEX') {
265 0 ▶ if ($lexer->yyPeek() == ord("'")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->yyPeek == 39) 0 0 0
266 0 $state = 'MY_LEX_BIN_NUMBER';
267 0 next;
268 }
269 } elsif ($state eq 'MY_LEX_IDENT_OR_BIN') {
270 7 ▶ if ($lexer->yyPeek() == ord("'")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->yyPeek == 39) 0 7 7
271 0 $state = 'MY_LEX_BIN_NUMBER';
272 0 next;
273 }
274 }
275  
276 718 ▶ if (
Branch: 3 branches
BranchTrueFalseTotal
if ($state eq 'MY_LEX_IDENT_OR_HEX' or $state eq 'MY_LEX_IDENT_OR_BIN' or $state eq 'MY_LEX_IDENT') { } 329 389 718
elsif ($state eq 'MY_LEX_IDENT_SEP') { } 107 282 389
elsif ($state eq 'MY_LEX_NUMBER_IDENT') { } 27 255 282
Condition83%5/6
$state eq "MY_LEX_IDENT_OR_HEX" or $state eq "MY_LEX_IDENT_OR_BIN" or $state eq "MY_LEX_IDENT"
l!l&&r!l&&!r
7322389
$state eq "MY_LEX_IDENT_OR_HEX" or $state eq "MY_LEX_IDENT_OR_BIN"
l!l&&r!l&&!r
07711
MC/DC66%2/3
$state eq "MY_LEX_IDENT_OR_HEX" or $state eq "MY_LEX_IDENT_OR_BIN" or $state eq "MY_LEX_IDENT"
$state eq "MY_LEX_IDENT_OR_HEX" $state eq "MY_LEX_IDENT_OR_BIN" $state eq "MY_LEX_IDENT"
Truth table75%3/4
A or B or C
A= $state eq "MY_LEX_IDENT_OR_HEX"B= $state eq "MY_LEX_IDENT_OR_BIN"C= $state eq "MY_LEX_IDENT"
ABCresult
1XX1
01X1
0011
0000
277 ($state eq 'MY_LEX_IDENT_OR_HEX') ||
278 ($state eq 'MY_LEX_IDENT_OR_BIN') ||
279 ($state eq 'MY_LEX_IDENT')
280 ) {
281 329 my $start;
282 ## FIXME - multibyte
283  
284 329 ▶ for ($result_state = $c; $ident_map->[$c = $lexer->yyGet()]; $result_state |= $c) {};
Branch: 1 branch
BranchTrueFalseTotal
if ($$ident_map[$c = $lexer->yyGet]) 924 329 1253
285
286 329 ▶ $result_state = $result_state & 0x80 ? 'IDENT_QUOTED' : 'IDENT';
Branch: 1 branch
BranchTrueFalseTotal
$result_state & 128 ? : 0 329 329
287  
288 329 my $length = $lexer->[LEXER_PTR] - $lexer->[LEXER_TOK_START] - 1;
289 329 $start = $lexer->[LEXER_PTR];
290  
291 329 ▶ if ($lexer->[LEXER_SQL_MODE] & MODE_IGNORE_SPACE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->[3] & 8) 0 329 329
292 0 ▶ for(; $state_map->[$c] eq 'MY_LEX_SKIP'; $c = $lexer->yyGet()) {};
Branch: 1 branch
BranchTrueFalseTotal
if ($state_map->[$c] eq "MY_LEX_SKIP") 0 0 0
293 }
294  
295 329 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($start == $lexer->[7] and $c == 46 and $$ident_map[$lexer->yyPeek]) { } 103 226 329
Condition83%5/6
$start == $lexer->[7] and $c == 46 and $$ident_map[$lexer->yyPeek]
!ll&&!rl&&r
2251103
$start == $lexer->[7] and $c == 46
!ll&&!rl&&r
0225104
MC/DC66%2/3
$start == $lexer->[7] and $c == 46 and $$ident_map[$lexer->yyPeek]
$start == $lexer->[7] $c == 46 $$ident_map[$lexer->yyPeek]
Truth table75%3/4
A and B and C
A= $start == $lexer->[7]B= $c == 46C= $$ident_map[$lexer->yyPeek]
ABCresult
0XX0
10X0
1100
1111
296 ($start == $lexer->[LEXER_PTR]) &&
297 ($c == ord('.')) &&
298 ($ident_map->[$lexer->yyPeek()])
299 ) {
300 103 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_IDENT_SEP';
301 } else {
302 226 $lexer->yyUnget();
303 226 ▶ if (@token = $lexer->find_keyword($length, $c == ord('('))) {
Branch: 1 branch
BranchTrueFalseTotal
if (@token = $lexer->find_keyword($length, $c == 40)) 157 69 226
304 157 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START';
305 157 return @token;
306 }
307 69 $lexer->yySkip();
308 }
309 172 my $lex_str = $lexer->get_token($length);
310  
311 172 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (substr($lex_str, 0, 1) eq "_" and exists $$DBIx::MyParsePP::Charsets::charsets{substr $lex_str, 1}) 0 172 172
Condition33%1/3
substr($lex_str, 0, 1) eq "_" and exists $$DBIx::MyParsePP::Charsets::charsets{substr $lex_str, 1}
!ll&&!rl&&r
17200
MC/DC0%0/2
substr($lex_str, 0, 1) eq "_" and exists $$DBIx::MyParsePP::Charsets::charsets{substr $lex_str, 1}
substr($lex_str, 0, 1) eq "_" exists $$DBIx::MyParsePP::Charsets::charsets{substr $lex_str, 1}
Truth table33%1/3
A and B
A= substr($lex_str, 0, 1) eq "_"B= exists $$DBIx::MyParsePP::Charsets::charsets{substr $lex_str, 1}
ABresult
0X0
100
111
312 (substr($lex_str,0,1) eq '_') &&
313 (exists $DBIx::MyParsePP::Charsets::charsets->{substr($lex_str,1)})
314 ) {
315 0 return ('UNDERSCORE_CHARSET', substr($lex_str,1));
316 }
317  
318 172 return($result_state, $lex_str);
319 } elsif ($state eq 'MY_LEX_IDENT_SEP') {
320 107 my $lex_str = substr($string, $lexer->[LEXER_PTR], 1);
321 107 $c = $lexer->yyGet();
322 107 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_IDENT_START';
323 107 ▶ if (!$ident_map->[$lexer->yyPeek()]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($$ident_map[$lexer->yyPeek]) 2 105 107
324 2 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START';
325 }
326 107 return (chr($c), $lex_str);
327 } elsif ($state eq 'MY_LEX_NUMBER_IDENT') {
328 27 ▶ while ($lexer->my_isdigit($c = $lexer->yyGet())) {} ;
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->my_isdigit($c = $lexer->yyGet)) 5 27 32
329 27 ▶ if (!$ident_map->[$c]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ident_map->[$c]) 27 0 27
330 27 $state = 'MY_LEX_INT_OR_REAL';
331 27 next;
332 }
333 0 ▶ if (($c == ord('e')) || ($c == ord('E'))) {
Branch: 3 branches
BranchTrueFalseTotal
if ($c == 101 or $c == 69) { } 0 0 0
elsif ($c == 120 and $lexer->[7] - $lexer->[8] == 2 and substr($string, $lexer->[8], 1) eq '0') { } 0 0 0
elsif ($c == 98 and $lexer->[7] - $lexer->[8] == 2 and substr($string, $lexer->[8], 1) eq '0') { } 0 0 0
Condition0%0/3
$c == 101 or $c == 69
l!l&&r!l&&!r
000
MC/DC0%0/2
$c == 101 or $c == 69
$c == 101 $c == 69
Truth table0%0/3
A or B
A= $c == 101B= $c == 69
ABresult
1X1
011
000
334 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->my_isdigit($lexer->yyPeek) or $c = $lexer->yyGet == 43 or $c == 45) 0 0 0
Condition0%0/6
$lexer->my_isdigit($lexer->yyPeek) or $c = $lexer->yyGet == 43 or $c == 45
l!l&&r!l&&!r
000
$lexer->my_isdigit($lexer->yyPeek) or $c = $lexer->yyGet == 43
l!l&&r!l&&!r
000
MC/DC0%0/3
$lexer->my_isdigit($lexer->yyPeek) or $c = $lexer->yyGet == 43 or $c == 45
$lexer->my_isdigit($lexer->yyPeek) $c = $lexer->yyGet == 43 $c == 45
Truth table0%0/4
A or B or C
A= $lexer->my_isdigit($lexer->yyPeek)B= $c = $lexer->yyGet == 43C= $c == 45
ABCresult
1XX1
01X1
0011
0000
335 ($lexer->my_isdigit($lexer->yyPeek())) ||
336 ($c = $lexer->yyGet() == ord('+')) ||
337 ($c == ord('-'))
338 ) {
339 0 ▶ if ($lexer->my_isdigit($lexer->yyPeek())) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->my_isdigit($lexer->yyPeek)) 0 0 0
340 0 $lexer->yySkip();
341 0 ▶ while ($lexer->my_isdigit($lexer->yyGet())) {};
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->my_isdigit($lexer->yyGet)) 0 0 0
342 0 my $lex_str = $lexer->get_token($lexer->yyLength());
343 0 return ('FLOAT_NUM', $lex_str);
344 }
345 }
346 0 $lexer->yyUnget();
347 ▶ } elsif (
Condition0%0/6
$c == 120 and $lexer->[7] - $lexer->[8] == 2 and substr($string, $lexer->[8], 1) eq 0
!ll&&!rl&&r
000
$c == 120 and $lexer->[7] - $lexer->[8] == 2
!ll&&!rl&&r
000
MC/DC0%0/3
$c == 120 and $lexer->[7] - $lexer->[8] == 2 and substr($string, $lexer->[8], 1) eq 0
$c == 120 $lexer->[7] - $lexer->[8] == 2 substr($string, $lexer->[8], 1) eq 0
Truth table0%0/4
A and B and C
A= $c == 120B= $lexer->[7] - $lexer->[8] == 2C= substr($string, $lexer->[8], 1) eq 0
ABCresult
0XX0
10X0
1100
1111
348 ($c == ord('x')) &&
349 ($lexer->[LEXER_PTR] - $lexer->[LEXER_TOK_START] == 2) &&
350 (substr($string, $lexer->[LEXER_TOK_START], 1) eq '0')
351 ) {
352 0 ▶ while($lexer->my_isxdigit($c = $lexer->yyGet())) {};
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->my_isxdigit($c = $lexer->yyGet)) 0 0 0
353 0 ▶ if (($lexer->[LEXER_PTR] - $lexer->[LEXER_TOK_START]) >= 4 && (!$ident_map->[$c])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->[7] - $lexer->[8] >= 4 and not $ident_map->[$c]) 0 0 0
Condition0%0/3
$lexer->[7] - $lexer->[8] >= 4 and not $ident_map->[$c]
!ll&&!rl&&r
000
MC/DC0%0/2
$lexer->[7] - $lexer->[8] >= 4 and not $ident_map->[$c]
$lexer->[7] - $lexer->[8] >= 4 not $ident_map->[$c]
Truth table0%0/3
A and not(B)
A= $lexer->[7] - $lexer->[8] >= 4B= not $ident_map->[$c]
ABresult
0X0
100
111
354 0 my $lex_str = $lexer->get_token($lexer->yyLength());
355 0 $lex_str = substr($lex_str, 2);
356 0 return ('HEX_NUM', $lex_str);
357 }
358 0 $lexer->yyUnget();
359 ▶ } elsif (
Condition0%0/6
$c == 98 and $lexer->[7] - $lexer->[8] == 2 and substr($string, $lexer->[8], 1) eq 0
!ll&&!rl&&r
000
$c == 98 and $lexer->[7] - $lexer->[8] == 2
!ll&&!rl&&r
000
MC/DC0%0/3
$c == 98 and $lexer->[7] - $lexer->[8] == 2 and substr($string, $lexer->[8], 1) eq 0
$c == 98 $lexer->[7] - $lexer->[8] == 2 substr($string, $lexer->[8], 1) eq 0
Truth table0%0/4
A and B and C
A= $c == 98B= $lexer->[7] - $lexer->[8] == 2C= substr($string, $lexer->[8], 1) eq 0
ABCresult
0XX0
10X0
1100
1111
360 ($c == ord('b')) &&
361 ($lexer->[LEXER_PTR] - $lexer->[LEXER_TOK_START] == 2) &&
362 (substr($string, $lexer->[LEXER_TOK_START], 1) eq '0')
363 ) {
364 0 ▶ while($lexer->my_isxdigit($c = $lexer->yyGet())) {};
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->my_isxdigit($c = $lexer->yyGet)) 0 0 0
365 0 ▶ if (($lexer->[LEXER_PTR] - $lexer->[LEXER_TOK_START]) >= 4 && (!$ident_map->[$c])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->[7] - $lexer->[8] >= 4 and not $ident_map->[$c]) 0 0 0
Condition0%0/3
$lexer->[7] - $lexer->[8] >= 4 and not $ident_map->[$c]
!ll&&!rl&&r
000
MC/DC0%0/2
$lexer->[7] - $lexer->[8] >= 4 and not $ident_map->[$c]
$lexer->[7] - $lexer->[8] >= 4 not $ident_map->[$c]
Truth table0%0/3
A and not(B)
A= $lexer->[7] - $lexer->[8] >= 4B= not $ident_map->[$c]
ABresult
0X0
100
111
366 0 my $lex_str = $lexer->get_token($lexer->yyLength());
367 0 $lex_str = substr($lex_str, 2);
368 0 return ('BIN_NUM', $lex_str);
369 }
370 0 $lexer->yyUnget();
371 }
372 }
373  
374 255 ▶ if ($state eq 'MY_LEX_IDENT_START') {
Branch: 3 branches
BranchTrueFalseTotal
if ($state eq 'MY_LEX_IDENT_START') { } 105 150 255
elsif ($state eq 'MY_LEX_USER_VARIABLE_DELIMITER') { } 3 147 150
elsif ($state eq 'MY_LEX_INT_OR_REAL') { } 27 120 147
375 105 $result_state = 'IDENT';
376 # FIXME multibyte
377 105 ▶ for ($result_state = 0; $ident_map->[$c = $lexer->yyGet()]; $result_state |= $c) {};
Branch: 1 branch
BranchTrueFalseTotal
if ($$ident_map[$c = $lexer->yyGet]) 642 105 747
378 105 ▶ $result_state = $result_state & 0x80 ? 'IDENT_QUOTED' : 'IDENT';
Branch: 1 branch
BranchTrueFalseTotal
$result_state & 128 ? : 0 105 105
379  
380 105 ▶ if (($c == ord('.')) && ($ident_map->[$lexer->yyPeek()])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 46 and $$ident_map[$lexer->yyPeek]) 2 103 105
Condition100%3/3
$c == 46 and $$ident_map[$lexer->yyPeek]
!ll&&!rl&&r
10212
MC/DC100%2/2
$c == 46 and $$ident_map[$lexer->yyPeek]
$c == 46 $$ident_map[$lexer->yyPeek]
Truth table100%3/3
A and B
A= $c == 46B= $$ident_map[$lexer->yyPeek]
ABresult
0X0
100
111
381 2 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_IDENT_SEP';
382 }
383  
384 105 my $lex_str = $lexer->get_token($lexer->yyLength());
385 105 return($result_state, $lex_str);
386 } elsif ($state eq 'MY_LEX_USER_VARIABLE_DELIMITER') {
387 3 my $double_quotes = 0;
388 3 my $quote_char = $c;
389 3 $lexer->[LEXER_TOK_START] = $lexer->[LEXER_PTR];
390 3 ▶ while ($c = $lexer->yyGet()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c = $lexer->yyGet) 20 0 20
391 20 my $var_length = $lexer->my_mbcharlen($c);
392 20 ▶ if ($var_length == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($var_length == 1) 20 0 20
393 20 ▶ last if $c == ord(NAMES_SEP_CHAR);
Branch: 1 branch
BranchTrueFalseTotal
if $c == 92 0 20 20
394 20 ▶ if ($c == $quote_char) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == $quote_char) 3 17 20
395 3 ▶ last if $lexer->yyPeek() != $quote_char;
Branch: 1 branch
BranchTrueFalseTotal
if $lexer->yyPeek != $quote_char 3 0 3
396 0 $c = $lexer->yyGet();
397 0 $double_quotes++;
398 0 next;
399 }
400 }
401 }
402 # MULTIBYTE!!
403  
404 3 my $lex_str;
405
406 3 ▶ if ($double_quotes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($double_quotes) { } 0 3 3
407 0 $lex_str = $lexer->get_quoted_token($lexer->yyLength() - $double_quotes, $quote_char);
408 } else {
409 3 $lex_str = $lexer->get_token($lexer->yyLength());
410 }
411
412 3 ▶ $lexer->yySkip() if $c == $quote_char;
Branch: 1 branch
BranchTrueFalseTotal
if $c == $quote_char 3 0 3
413 3 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START';
414 3 return ('IDENT_QUOTED', $lex_str);
415 } elsif ($state eq 'MY_LEX_INT_OR_REAL') {
416 27 ▶ if ($c != ord ('.')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c != 46) 27 0 27
417 27 my $lex_str = $lexer->get_token($lexer->yyLength());
418 27 return $lexer->int_token($lex_str);
419 }
420 }
421  
422 120 ▶ if (
Branch: 7 branches
BranchTrueFalseTotal
if ($state eq 'MY_LEX_INT_OR_REAL' or $state eq 'MY_LEX_REAL') { } 0 120 120
elsif ($state eq 'MY_LEX_HEX_NUMBER') { } 0 120 120
elsif ($state eq 'MY_LEX_BIN_NUMBER') { } 0 120 120
elsif ($state eq 'MY_LEX_CMP_OP') { } 50 70 120
elsif ($state eq 'MY_LEX_LONG_CMP_OP') { } 0 70 70
elsif ($state eq 'MY_LEX_BOOL') { } 2 68 70
elsif ($state eq 'MY_LEX_STRING_OR_DELIMITER') { } 4 64 68
Condition33%1/3
$state eq "MY_LEX_INT_OR_REAL" or $state eq "MY_LEX_REAL"
l!l&&r!l&&!r
00120
MC/DC0%0/2
$state eq "MY_LEX_INT_OR_REAL" or $state eq "MY_LEX_REAL"
$state eq "MY_LEX_INT_OR_REAL" $state eq "MY_LEX_REAL"
Truth table33%1/3
A or B
A= $state eq "MY_LEX_INT_OR_REAL"B= $state eq "MY_LEX_REAL"
ABresult
1X1
011
000
423 ($state eq 'MY_LEX_INT_OR_REAL') ||
424 ($state eq 'MY_LEX_REAL')
425 ) {
426 0 ▶ while ($lexer->my_isdigit($c = $lexer->yyGet())) {};
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->my_isdigit($c = $lexer->yyGet)) 0 0 0
427 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 101 or $c == 69) 0 0 0
Condition0%0/3
$c == 101 or $c == 69
l!l&&r!l&&!r
000
MC/DC0%0/2
$c == 101 or $c == 69
$c == 101 $c == 69
Truth table0%0/3
A or B
A= $c == 101B= $c == 69
ABresult
1X1
011
000
428 ($c == ord('e')) ||
429 ($c == ord('E'))
430 ) {
431 0 $c = $lexer->yyGet();
432 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 43 or $c == 45) 0 0 0
Condition0%0/3
$c == 43 or $c == 45
l!l&&r!l&&!r
000
MC/DC0%0/2
$c == 43 or $c == 45
$c == 43 $c == 45
Truth table0%0/3
A or B
A= $c == 43B= $c == 45
ABresult
1X1
011
000
433 ($c == ord('+')) ||
434 ($c == ord('-'))
435 ) {
436 0 $c = $lexer->yyGet();
437 }
438
439 0 ▶ if (!$lexer->my_isdigit($c)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($lexer->my_isdigit($c)) 0 0 0
440 0 $state = 'MY_LEX_CHAR';
441 0 next;
442 }
443  
444 0 ▶ while ($lexer->my_isdigit($lexer->yyGet())) {};
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->my_isdigit($lexer->yyGet)) 0 0 0
445
446 0 my $lex_str = $lexer->get_token($lexer->yyLength());
447 0 return ('FLOAT_NUM', $lex_str);
448 }
449
450 0 my $lex_str = $lexer->get_token($lexer->yyLength());
451 0 return ('DECIMAL_NUM', $lex_str);
452 } elsif ($state eq 'MY_LEX_HEX_NUMBER') {
453 0 $lexer->yyGet();
454 0 ▶ while ($lexer->my_isdigit($lexer->yyGet())) {};
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->my_isdigit($lexer->yyGet)) 0 0 0
455 0 my $length = $lexer->[LEXER_PTR] - $lexer->[LEXER_TOK_START];
456 0 ▶ if (!($length & 1) || ($c != ord ("'"))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $length & 1 or $c != 39) 0 0 0
Condition0%0/3
not $length & 1 or $c != 39
l!l&&r!l&&!r
000
MC/DC0%0/2
not $length & 1 or $c != 39
not $length & 1 $c != 39
Truth table0%0/3
not(A) or B
A= not $length & 1B= $c != 39
ABresult
1X1
011
000
457 0 return ('ABORT_SYM','ABORT_SYM');
458 }
459 0 $lexer->yyGet();
460 0 my $lex_str = $lexer->get_token($length);
461 0 $lex_str = substr($lex_str, 2, length($lex_str) - 3);
462 0 return ('HEX_NUM', $lex_str);
463 } elsif ($state eq 'MY_LEX_BIN_NUMBER') {
464 0 $lexer->yyGet();
465 0 ▶ while (($c = $lexer->yyGet()) == ord('0') || $c == ord ('1')) {};
Branch: 1 branch
BranchTrueFalseTotal
if (($c = $lexer->yyGet) == 48 or $c == 49) 0 0 0
Condition0%0/3
($c = $lexer->yyGet) == 48 or $c == 49
l!l&&r!l&&!r
000
MC/DC0%0/2
($c = $lexer->yyGet) == 48 or $c == 49
($c = $lexer->yyGet) == 48 $c == 49
Truth table0%0/3
A or B
A= ($c = $lexer->yyGet) == 48B= $c == 49
ABresult
1X1
011
000
466 0 my $length = $lexer->[LEXER_PTR] - $lexer->[LEXER_TOK_START];
467 0 ▶ if ($c != ord("'")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c != 39) 0 0 0
468 0 return ('ABORT_SYM','ABORT_SYM');
469 }
470 0 $lexer->yyGet();
471 0 my $lex_str = $lexer->get_token($length);
472 0 $lex_str = substr($lex_str, 2, length($lex_str) - 3);
473 0 return ('BIN_NUM', $lex_str);
474 } elsif ($state eq 'MY_LEX_CMP_OP') {
475 50 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($$state_map[$lexer->yyPeek] eq "MY_LEX_CMP_OP" or $$state_map[$lexer->yyPeek] eq "MY_LEX_LONG_CMP_OP") 1 49 50
Condition66%2/3
$$state_map[$lexer->yyPeek] eq "MY_LEX_CMP_OP" or $$state_map[$lexer->yyPeek] eq "MY_LEX_LONG_CMP_OP"
l!l&&r!l&&!r
1049
MC/DC50%1/2
$$state_map[$lexer->yyPeek] eq "MY_LEX_CMP_OP" or $$state_map[$lexer->yyPeek] eq "MY_LEX_LONG_CMP_OP"
$$state_map[$lexer->yyPeek] eq "MY_LEX_CMP_OP" $$state_map[$lexer->yyPeek] eq "MY_LEX_LONG_CMP_OP"
Truth table66%2/3
A or B
A= $$state_map[$lexer->yyPeek] eq "MY_LEX_CMP_OP"B= $$state_map[$lexer->yyPeek] eq "MY_LEX_LONG_CMP_OP"
ABresult
1X1
011
000
476 ($state_map->[$lexer->yyPeek()] eq 'MY_LEX_CMP_OP') ||
477 ($state_map->[$lexer->yyPeek()] eq 'MY_LEX_LONG_CMP_OP')
478 ) {
479 1 $lexer->yySkip();
480 }
481 50 ▶ if (@token = $lexer->find_keyword($lexer->[LEXER_PTR] - $lexer->[LEXER_TOK_START], 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@token = $lexer->find_keyword($lexer->[7] - $lexer->[8], 0)) 50 0 50
482 50 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START';
483 50 return @token; # ADDED
484 }
485 0 $state = 'MY_LEX_CHAR';
486 0 next;
487 } elsif ($state eq 'MY_LEX_LONG_CMP_OP') {
488 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($$state_map[$lexer->yyPeek] eq "MY_LEX_CMP_OP" or $$state_map[$lexer->yyPeek] eq "MY_LEX_LONG_CMP_OP") 0 0 0
Condition0%0/3
$$state_map[$lexer->yyPeek] eq "MY_LEX_CMP_OP" or $$state_map[$lexer->yyPeek] eq "MY_LEX_LONG_CMP_OP"
l!l&&r!l&&!r
000
MC/DC0%0/2
$$state_map[$lexer->yyPeek] eq "MY_LEX_CMP_OP" or $$state_map[$lexer->yyPeek] eq "MY_LEX_LONG_CMP_OP"
$$state_map[$lexer->yyPeek] eq "MY_LEX_CMP_OP" $$state_map[$lexer->yyPeek] eq "MY_LEX_LONG_CMP_OP"
Truth table0%0/3
A or B
A= $$state_map[$lexer->yyPeek] eq "MY_LEX_CMP_OP"B= $$state_map[$lexer->yyPeek] eq "MY_LEX_LONG_CMP_OP"
ABresult
1X1
011
000
489 ($state_map->[$lexer->yyPeek()] eq 'MY_LEX_CMP_OP') ||
490 ($state_map->[$lexer->yyPeek()] eq 'MY_LEX_LONG_CMP_OP')
491 ) {
492 0 $lexer->yySkip();
493 0 ▶ if ($state_map->[$lexer->yyPeek()] eq 'MY_LEX_CMP_OP') {
Branch: 1 branch
BranchTrueFalseTotal
if ($$state_map[$lexer->yyPeek] eq "MY_LEX_CMP_OP") 0 0 0
494 0 $lexer->yySkip();
495 }
496 }
497 0 ▶ if (@token = $lexer->find_keyword($lexer->[LEXER_PTR] - $lexer->[LEXER_TOK_START], 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@token = $lexer->find_keyword($lexer->[7] - $lexer->[8], 0)) 0 0 0
498 0 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START';
499 0 return @token;
500 }
501 0 $state = 'MY_LEX_CHAR';
502 0 next;
503 } elsif ($state eq 'MY_LEX_BOOL') {
504 2 ▶ if ($c != $lexer->yyPeek()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c != $lexer->yyPeek) 0 2 2
505 0 $state = 'MY_LEX_CHAR';
506 0 next;
507 }
508 2 $lexer->yySkip();
509 2 @token = $lexer->find_keyword(2, 0);
510 2 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START';
511 2 return @token;
512 } elsif ($state eq 'MY_LEX_STRING_OR_DELIMITER') {
513 4 ▶ if ($lexer->[LEXER_SQL_MODE] & MODE_ANSI_QUOTES) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->[3] & 4) 0 4 4
514 0 $state = 'MY_LEX_USER_VARIABLE_DELIMITER';
515 0 next;
516 }
517 }
518
519 68 ▶ if (
Branch: 6 branches
BranchTrueFalseTotal
if ($state eq 'MY_LEX_STRING_OR_DELIMITER' or $state eq 'MY_LEX_STRING') { } 19 49 68
elsif ($state eq 'MY_LEX_COMMENT') { } 0 49 49
elsif ($state eq 'MY_LEX_LONG_COMMENT') { } 17 32 49
elsif ($state eq 'MY_LEX_END_LONG_COMMENT') { } 3 29 32
elsif ($state eq 'MY_LEX_SET_VAR') { } 0 29 29
elsif ($state eq 'MY_LEX_SEMICOLON') { } 1 28 29
Condition100%3/3
$state eq "MY_LEX_STRING_OR_DELIMITER" or $state eq "MY_LEX_STRING"
l!l&&r!l&&!r
41549
MC/DC100%2/2
$state eq "MY_LEX_STRING_OR_DELIMITER" or $state eq "MY_LEX_STRING"
$state eq "MY_LEX_STRING_OR_DELIMITER" $state eq "MY_LEX_STRING"
Truth table100%3/3
A or B
A= $state eq "MY_LEX_STRING_OR_DELIMITER"B= $state eq "MY_LEX_STRING"
ABresult
1X1
011
000
520 ($state eq 'MY_LEX_STRING_OR_DELIMITER') ||
521 ($state eq 'MY_LEX_STRING')
522 ) {
523 19 my $lex_str;
524 19 ▶ if (!defined ($lex_str = $lexer->get_text())) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined($lex_str = $lexer->get_text)) 0 19 19
525 0 $state = 'MY_LEX_CHAR';
526 0 next;
527 }
528 19 return ('TEXT_STRING', $lex_str);
529 } elsif ($state eq 'MY_LEX_COMMENT') {
530 0 $lexer->[LEXER_OPTIONS] |= OPTION_FOUND_COMMENT;
531 0 ▶ while (($c = $lexer->yyGet()) != ord("\n") && $c) {};
Branch: 1 branch
BranchTrueFalseTotal
if (($c = $lexer->yyGet) != 10 and $c) 0 0 0
Condition0%0/3
($c = $lexer->yyGet) != 10 and $c
!ll&&!rl&&r
000
MC/DC0%0/2
($c = $lexer->yyGet) != 10 and $c
($c = $lexer->yyGet) != 10 $c
Truth table0%0/3
A and B
A= ($c = $lexer->yyGet) != 10B= $c
ABresult
0X0
100
111
532 0 $lexer->yyUnget();
533 0 $state = 'MY_LEX_START';
534 0 next;
535 } elsif ($state eq 'MY_LEX_LONG_COMMENT') {
536 17 ▶ if ($lexer->yyPeek() != ord('*')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->yyPeek != 42) 1 16 17
537 1 $state = 'MY_LEX_CHAR';
538 1 next;
539 }
540 16 $lexer->yySkip();
541 16 $lexer->[LEXER_OPTIONS] |= OPTION_FOUND_COMMENT;
542 16 ▶ if ($lexer->yyPeek() == ord('!')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->yyPeek == 33) 2 14 16
543 2 $lexer->yySkip();
544 2 my $version = $lexer->[LEXER_VERSION];
545 2 $state = 'MY_LEX_START';
546 2 ▶ if ($lexer->my_isdigit($lexer->yyPeek())) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->my_isdigit($lexer->yyPeek)) 2 0 2
547 2 $version = substr($string, $lexer->[LEXER_PTR], 5);
548 2 $lexer->[LEXER_PTR] += 5; # FIXME for version numbers different from 5 characters
549 }
550  
551 2 ▶ if ($version <= $lexer->[LEXER_VERSION]){
Branch: 1 branch
BranchTrueFalseTotal
if ($version <= $lexer->[2]) 1 1 2
552 1 $lexer->[LEXER_IN_COMMENT] = 1;
553 1 next;
554 }
555 }
556  
557 15 ▶ while (
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->[7] != length($string) - 1 and ($c = $lexer->yyGet != 42) || $lexer->yyPeek != 47) 447 15 462
Condition66%4/6
$lexer->[7] != length($string) - 1 and ($c = $lexer->yyGet != 42) || $lexer->yyPeek != 47
!ll&&!rl&&r
015447
$c = $lexer->yyGet != 42 or $lexer->yyPeek != 47
l!l&&r!l&&!r
447015
MC/DC33%1/3
$lexer->[7] != length($string) - 1 and ($c = $lexer->yyGet != 42) || $lexer->yyPeek != 47
$lexer->[7] != length($string) - 1 $c = $lexer->yyGet != 42 $lexer->yyPeek != 47
Truth table50%2/4
A and B or C
A= $lexer->[7] != length($string) - 1B= $c = $lexer->yyGet != 42C= $lexer->yyPeek != 47
ABCresult
0XX0
1000
11X1
1011
558 ($lexer->[LEXER_PTR] != length($string) - 1) &&
559 (
560 ($c = $lexer->yyGet() != ord('*')) ||
561 ($lexer->yyPeek() != ord('/'))
562 )
563 ) {
564 447 ▶ $lexer->[LEXER_YYLINENO]++ if $c == ord("\n");
Branch: 1 branch
BranchTrueFalseTotal
if $c == 10 0 447 447
565 }
566
567 15 ▶ $lexer->yySkip() if $lexer->[LEXER_PTR] != length($string) - 1;
Branch: 1 branch
BranchTrueFalseTotal
if $lexer->[7] != length($string) - 1 15 0 15
568  
569 15 $state = 'MY_LEX_START';
570 15 next;
571 } elsif ($state eq 'MY_LEX_END_LONG_COMMENT') {
572 3 ▶ if ($lexer->[LEXER_IN_COMMENT] && $lexer->yyPeek() == ord('/')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->[12] and $lexer->yyPeek == 47) { } 1 2 3
Condition66%2/3
$lexer->[12] and $lexer->yyPeek == 47
!ll&&!rl&&r
201
MC/DC50%1/2
$lexer->[12] and $lexer->yyPeek == 47
$lexer->[12] $lexer->yyPeek == 47
Truth table66%2/3
A and B
A= $lexer->[12]B= $lexer->yyPeek == 47
ABresult
0X0
100
111
573 1 $lexer->yySkip();
574 1 $lexer->[LEXER_IN_COMMENT] = 0;
575 1 $state = 'MY_LEX_START';
576 } else {
577 2 $state = 'MY_LEX_CHAR';
578 }
579 3 next;
580 } elsif ($state eq 'MY_LEX_SET_VAR') {
581 0 ▶ if ($lexer->yyPeek() != ord ('=')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->yyPeek != 61) 0 0 0
582 0 $state = 'MY_LEX_CHAR';
583 0 next;
584 }
585 0 $lexer->yySkip();
586 0 return('SET_VAR','SET_VAR');
587 } elsif ($state eq 'MY_LEX_SEMICOLON') {
588 1 ▶ if ($lexer->yyPeek()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->yyPeek) 1 0 1
589 1 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->[5] & 65536 and not $lexer->[6]) 1 0 1
Condition33%1/3
$lexer->[5] & 65536 and not $lexer->[6]
!ll&&!rl&&r
001
MC/DC0%0/2
$lexer->[5] & 65536 and not $lexer->[6]
$lexer->[5] & 65536 not $lexer->[6]
Truth table33%1/3
A and not(B)
A= $lexer->[5] & 65536B= not $lexer->[6]
ABresult
0X0
100
111
590 ($lexer->[LEXER_CLIENT_CAPABILITIES] & CLIENT_MULTI_STATEMENTS) &&
591 (!$lexer->[LEXER_STMT_PREPARE_MODE])
592 ) {
593 1 $lexer->[LEXER_SAFE_TO_CACHE_QUERY] = 0;
594 1 $lexer->[LEXER_FOUND_SEMICOLON] = $lexer->[LEXER_PTR];
595 1 $lexer->[LEXER_SERVER_STATUS] |= SERVER_MORE_RESULTS_EXISTS;
596 1 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_END';
597 1 return ('END_OF_INPUT','');
598 }
599 0 $state = 'MY_LEX_CHAR';
600 0 next;
601 }
602 }
603
604 28 ▶ if (
Branch: 7 branches
BranchTrueFalseTotal
if ($state eq 'MY_LEX_SEMICOLON' or $state eq 'MY_LEX_EOL') { } 13 15 28
elsif ($state eq 'MY_LEX_END') { } 12 3 15
elsif ($state eq 'MY_LEX_REAL_OR_POINT') { } 2 1 3
elsif ($state eq 'MY_LEX_USER_END') { } 1 0 1
elsif ($state eq 'MY_LEX_HOSTNAME') { } 0 0 0
elsif ($state eq 'MY_LEX_SYSTEM_VAR') { } 0 0 0
elsif ($state eq 'MY_LEX_IDENT_OR_KEYWORD') { } 0 0 0
Condition66%2/3
$state eq "MY_LEX_SEMICOLON" or $state eq "MY_LEX_EOL"
l!l&&r!l&&!r
01315
MC/DC50%1/2
$state eq "MY_LEX_SEMICOLON" or $state eq "MY_LEX_EOL"
$state eq "MY_LEX_SEMICOLON" $state eq "MY_LEX_EOL"
Truth table66%2/3
A or B
A= $state eq "MY_LEX_SEMICOLON"B= $state eq "MY_LEX_EOL"
ABresult
1X1
011
000
605 ($state eq 'MY_LEX_SEMICOLON') ||
606 ($state eq 'MY_LEX_EOL')
607 ) {
608 13 ▶ if ($lexer->[LEXER_PTR] >= length($string) - 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->[7] >= length($string) - 1) 13 0 13
609 13 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_END';
610 13 return ('END_OF_INPUT','');
611 }
612 0 $state = 'MY_LEX_CHAR';
613 0 next;
614 } elsif ($state eq 'MY_LEX_END') {
615 12 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_END';
616 12 return (0,0);
617 } elsif ($state eq 'MY_LEX_REAL_OR_POINT') {
618 2 ▶ if ($lexer->my_isdigit($lexer->yyPeek())) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->my_isdigit($lexer->yyPeek)) { } 0 2 2
619 0 $state = 'MY_LEX_REAL';
620 } else {
621 2 $state = 'MY_LEX_IDENT_SEP';
622 2 $lexer->yyUnget();
623 }
624 2 next;
625 } elsif ($state eq 'MY_LEX_USER_END') {
626 1 ▶ if (
Branch: 3 branches
BranchTrueFalseTotal
if ($$state_map[$lexer->yyPeek] eq 'MY_LEX_STRING' or $$state_map[$lexer->yyPeek] eq 'MY_LEX_STRING_OR_DELIMITER') { } 0 1 1
elsif ($$state_map[$lexer->yyPeek] eq 'MY_LEX_USER_END') { } 0 1 1
elsif ($$state_map[$lexer->yyPeek] eq 'MY_LEX_USER_VARIABLE_DELIMITER') { } 1 0 1
Condition33%1/3
$$state_map[$lexer->yyPeek] eq "MY_LEX_STRING" or $$state_map[$lexer->yyPeek] eq "MY_LEX_STRING_OR_DELIMITER"
l!l&&r!l&&!r
001
MC/DC0%0/2
$$state_map[$lexer->yyPeek] eq "MY_LEX_STRING" or $$state_map[$lexer->yyPeek] eq "MY_LEX_STRING_OR_DELIMITER"
$$state_map[$lexer->yyPeek] eq "MY_LEX_STRING" $$state_map[$lexer->yyPeek] eq "MY_LEX_STRING_OR_DELIMITER"
Truth table33%1/3
A or B
A= $$state_map[$lexer->yyPeek] eq "MY_LEX_STRING"B= $$state_map[$lexer->yyPeek] eq "MY_LEX_STRING_OR_DELIMITER"
ABresult
1X1
011
000
627 ($state_map->[$lexer->yyPeek()] eq 'MY_LEX_STRING') ||
628 ($state_map->[$lexer->yyPeek()] eq 'MY_LEX_STRING_OR_DELIMITER')
629 ) {
630 0 next;
631 } elsif ($state_map->[$lexer->yyPeek()] eq 'MY_LEX_USER_END') {
632 0 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_SYSTEM_VAR';
633 } elsif ($state_map->[$lexer->yyPeek()] eq 'MY_LEX_USER_VARIABLE_DELIMITER') {
634 1 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START';
635 } else {
636 0 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_HOSTNAME'; # could be replaced by 'MY_LEX_START' for homogeneity
637 }
638 1 my $lex_str = substr($string, $lexer->[LEXER_PTR], 1);
639 1 return ('@', $lex_str);
640 } elsif ($state eq 'MY_LEX_HOSTNAME') {
641 0 ▶ for ($c = $lexer->yyGet(); $lexer->my_isalnum($c) || $c == ord('.') || $c == ord('_') || $c == ord('$'); $c = $lexer->yyGet()) {};
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->my_isalnum($c) or $c == 46 or $c == 95 or $c == 36) 0 0 0
Condition0%0/9
$lexer->my_isalnum($c) or $c == 46 or $c == 95 or $c == 36
l!l&&r!l&&!r
000
$lexer->my_isalnum($c) or $c == 46 or $c == 95
l!l&&r!l&&!r
000
$lexer->my_isalnum($c) or $c == 46
l!l&&r!l&&!r
000
MC/DC0%0/4
$lexer->my_isalnum($c) or $c == 46 or $c == 95 or $c == 36
$lexer->my_isalnum($c) $c == 46 $c == 95 $c == 36
Truth table0%0/5
A or B or C or D
A= $lexer->my_isalnum($c)B= $c == 46C= $c == 95D= $c == 36
ABCDresult
1XXX1
01XX1
001X1
00011
00000
642 0 my $lex_str = $lexer->get_token($lexer->yyLength());
643 0 return ('LEX_HOSTNAME', $lex_str);
644 } elsif ($state eq 'MY_LEX_SYSTEM_VAR') {
645 0 my $lex_str = substr($string, $lexer->[LEXER_PTR], 1);
646 0 $lexer->yySkip();
647 0 ▶ $lexer->[LEXER_NEXT_STATE] = $state_map->[$lexer->yyPeek()] eq 'MY_LEX_USER_VARIABLE_DELIMITER' ? 'MY_LEX_OPERATOR_OR_IDENT' : 'MY_LEX_IDENT_OR_KEYWORD';
Branch: 1 branch
BranchTrueFalseTotal
$$state_map[$lexer->yyPeek] eq 'MY_LEX_USER_VARIABLE_DELIMITER' ? : 0 0 0
648 0 return ('@', $lex_str);
649 } elsif ($state eq 'MY_LEX_IDENT_OR_KEYWORD') {
650 0 ▶ for ($result_state = 0; $ident_map->[$c = $lexer->yyGet()]; $result_state |= $c) {};
Branch: 1 branch
BranchTrueFalseTotal
if ($$ident_map[$c = $lexer->yyGet]) 0 0 0
651 0 ▶ $result_state = $result_state & 0x80 ? 'IDENT_QUOTED' : 'IDENT';
Branch: 1 branch
BranchTrueFalseTotal
$result_state & 128 ? : 0 0 0
652  
653 0 ▶ $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_IDENT_SEP' if $c == ord('.');
Branch: 1 branch
BranchTrueFalseTotal
if $c == 46 0 0 0
654
655 0 my $length = ($lexer->[LEXER_PTR] - $lexer->[LEXER_TOK_START]) - 1;
656 0 ▶ return ('ABORT_SYM','ABORT_SYM') if $length == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $length == 0 0 0 0
657 0 ▶ if (@token = $lexer->find_keyword($length, 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@token = $lexer->find_keyword($length, 0)) 0 0 0
658 0 $lexer->yyUnget();
659 0 return @token;
660 }
661 0 my $lex_str = $lexer->get_token($length);
662 0 return ($result_state, $lex_str);
663 }
664 }
665 }
666  
667 14 ▶sub init_state_maps {
Subroutine init_state_maps: called CC=8 SCAR=20.8
Pod undocumented
668  
669 14 my $lexer = shift;
670  
671 14 ▶ return if exists $state_maps{$lexer->[LEXER_CHARSET]};
Branch: 1 branch
BranchTrueFalseTotal
if exists $state_maps{$lexer->[1]} 6 8 14
672  
673 8 my @state_map;
674 my @ident_map;
675  
676 8 ▶ for (my $i = 0; $i < 256; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 256) 2048 8 2056
677 2048 ▶ if ($lexer->my_isalpha($i)) {
Branch: 3 branches
BranchTrueFalseTotal
if ($lexer->my_isalpha($i)) { } 416 1632 2048
elsif ($lexer->my_isdigit($i)) { } 80 1552 1632
elsif ($lexer->my_isspace($i)) { } 48 1504 1552
678 416 $state_map[$i] = 'MY_LEX_IDENT';
679 } elsif ($lexer->my_isdigit($i)) {
680 80 $state_map[$i] = 'MY_LEX_NUMBER_IDENT';
681 # FIXME MULTI-BYTE
682 } elsif ($lexer->my_isspace($i)) {
683 48 $state_map[$i] = 'MY_LEX_SKIP';
684 } else {
685 1504 $state_map[$i] = 'MY_LEX_CHAR';
686 }
687 }
688  
689 8 $state_map[ord('_')] = $state_map[ord('$')] = 'MY_LEX_IDENT';
690 8 $state_map[ord("'")] = 'MY_LEX_STRING';
691 8 $state_map[ord('.')] = 'MY_LEX_REAL_OR_POINT';
692  
693 8 $state_map[ord('>')] = $state_map[ord('=')] = $state_map[ord('!')] = 'MY_LEX_CMP_OP';
694 8 $state_map[ord('<')] = 'MY_LEX_LONG_CMP_OP';
695 8 $state_map[ord('&')] = $state_map[ord('|')] = 'MY_LEX_BOOL';
696 8 $state_map[ord('#')] = 'MY_LEX_COMMENT';
697 8 $state_map[ord(';')] = 'MY_LEX_SEMICOLON';
698 8 $state_map[ord(':')] = 'MY_LEX_SET_VAR';
699 8 $state_map[0] = 'MY_LEX_EOL';
700 8 $state_map[ord("\\")] = 'MY_LEX_ESCAPE';
701 8 $state_map[ord('/')] = 'MY_LEX_LONG_COMMENT';
702 8 $state_map[ord('*')] = 'MY_LEX_END_LONG_COMMENT';
703 8 $state_map[ord('@')] = 'MY_LEX_USER_END';
704 8 $state_map[ord('`')] = 'MY_LEX_USER_VARIABLE_DELIMITER';
705 8 $state_map[ord('"')] = 'MY_LEX_STRING_OR_DELIMITER';
706  
707 8 ▶ for (my $i=0; $i < 256 ; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 256) 2048 8 2056
708 2048 ▶ $ident_map[$i] = ($state_map[$i] eq 'MY_LEX_IDENT') || ($state_map[$i] eq 'MY_LEX_NUMBER_IDENT');
Condition100%3/3
$state_map[$i] eq 'MY_LEX_IDENT' || $state_map[$i] eq 'MY_LEX_NUMBER_IDENT'
l!l&&r!l&&!r
432801536
MC/DC100%2/2
$state_map[$i] eq 'MY_LEX_IDENT' || $state_map[$i] eq 'MY_LEX_NUMBER_IDENT'
$state_map[$i] eq 'MY_LEX_IDENT' $state_map[$i] eq 'MY_LEX_NUMBER_IDENT'
Truth table100%3/3
A || B
A= $state_map[$i] eq 'MY_LEX_IDENT'B= $state_map[$i] eq 'MY_LEX_NUMBER_IDENT'
ABresult
1X1
011
000
709 }
710  
711 8 $state_map[ord('x')] = $state_map[ord('X')] = 'MY_LEX_IDENT_OR_HEX';
712 8 $state_map[ord('b')] = $state_map[ord('B')] = 'MY_LEX_IDENT_OR_BIN';
713 8 $state_map[ord('n')] = $state_map[ord('N')] = 'MY_LEX_IDENT_OR_NCHAR';
714  
715 8 $state_maps{$lexer->[LEXER_CHARSET]} = \@state_map;
716 8 $ident_maps{$lexer->[LEXER_CHARSET]} = \@ident_map;
717 }
718  
719  
720 20 ▶sub my_mbcharlen { 1 };
Subroutine my_mbcharlen: called CC=1 SCAR=0.0
Pod undocumented
721  
722 2048 ▶sub my_isalpha { $_[0]->[LEXER_CTYPE]->[$_[1] + 1] & (CTYPE_U | CTYPE_L) }
Subroutine my_isalpha: called CC=1 SCAR=0.0
Pod undocumented
723  
724 0 ▶sub my_isalnum { $_[0]->[LEXER_CTYPE]->[$_[1] + 1] & (CTYPE_U | CTYPE_L | CTYPE_NMR) }
Subroutine my_isalnum: not called CC=1 SCAR=6.9
Pod undocumented
725  
726 0 ▶sub my_isxdigit { $_[0]->[LEXER_CTYPE]->[$_[1] + 1] & CTYPE_X }
Subroutine my_isxdigit: not called CC=1 SCAR=6.9
Pod undocumented
727  
728 1668 ▶sub my_isdigit { $_[0]->[LEXER_CTYPE]->[$_[1] + 1] & CTYPE_NMR }
Subroutine my_isdigit: called CC=1 SCAR=0.0
Pod undocumented
729  
730 1552 ▶sub my_isspace { $_[0]->[LEXER_CTYPE]->[$_[1] + 1] & CTYPE_SPC }
Subroutine my_isspace: called CC=1 SCAR=0.0
Pod undocumented
731  
732 0 ▶sub my_iscntrl { $_[0]->[LEXER_CTYPE]->[$_[1] + 1] & CTYPE_CTR }
Subroutine my_iscntrl: not called CC=1 SCAR=6.9
Pod undocumented
733  
734 19 ▶sub get_text {
Subroutine get_text: called CC=22 SCAR=53.6
Pod undocumented
735 19 my $lexer = shift;
736 19 my $string = $lexer->[LEXER_STRING];
737 19 my $sep = $lexer->yyGetLast();
738 19 my $found_escape = 0;
739 19 ▶ while ($lexer->[LEXER_PTR] != length($lexer->[LEXER_STRING]) - 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->[7] != length($lexer->[0]) - 1) 90 0 90
740 90 my $c = $lexer->yyGet();
741 90 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($c == 92 and not $lexer->[3] & 1048576) { } 0 90 90
elsif ($c == $sep) { } 19 71 90
Condition33%1/3
$c == 92 and not $lexer->[3] & 1048576
!ll&&!rl&&r
9000
MC/DC0%0/2
$c == 92 and not $lexer->[3] & 1048576
$c == 92 not $lexer->[3] & 1048576
Truth table33%1/3
A and not(B)
A= $c == 92B= not $lexer->[3] & 1048576
ABresult
0X0
100
111
742 ($c == ord("\\")) &&
743 (!($lexer->[LEXER_SQL_MODE] & MODE_NO_BACKSLASH_ESCAPES))
744 ) {
745 0 $found_escape = 1;
746 0 ▶ return undef if $lexer->[LEXER_PTR] == length($lexer->[LEXER_STRING]);
Branch: 1 branch
BranchTrueFalseTotal
if $lexer->[7] == length $lexer->[0] 0 0 0
747 0 $lexer->yySkip();
748 } elsif ($c == $sep) {
749 19 ▶ if ($c == $lexer->yyGet()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == $lexer->yyGet) { } 0 19 19
750 0 $found_escape = 1;
751 0 next;
752 } else {
753 19 $lexer->yyUnget();
754 }
755
756 19 my ($str, $end, $start);
757  
758 19 $str = $lexer->[LEXER_TOK_START] + 1;
759 19 $end = $lexer->[LEXER_PTR] - 1;
760  
761 19 my $to;
762  
763 19 ▶ if (!$found_escape) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $found_escape) { } 19 0 19
764 19 my $yytoklen = $end - $str; # CHANGED
765 19 ▶ if ($yytoklen > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($yytoklen > 0) { } 19 0 19
766 19 return substr($lexer->[LEXER_STRING], $str, $yytoklen);
767 } else {
768 0 return '';
769 }
770 } else {
771 0 my $new_str = ''; # ADDED
772 0 ▶ for ($to = $start; $str != $end; $str++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str != $end) 0 0 0
773 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if (not $lexer->[3] & 1048576 and substr($string, $str, 1) eq '\\' and $str + 1 != $end) { } 0 0 0
elsif (substr($string, $str, 1) eq $sep) { } 0 0 0
Condition0%0/6
not $lexer->[3] & 1048576 and substr($string, $str, 1) eq "\\" and $str + 1 != $end
!ll&&!rl&&r
000
not $lexer->[3] & 1048576 and substr($string, $str, 1) eq "\\"
!ll&&!rl&&r
000
MC/DC0%0/3
not $lexer->[3] & 1048576 and substr($string, $str, 1) eq "\\" and $str + 1 != $end
not $lexer->[3] & 1048576 substr($string, $str, 1) eq "\\" $str + 1 != $end
Truth table0%0/4
not(A) and B and C
A= not $lexer->[3] & 1048576B= substr($string, $str, 1) eq "\\"C= $str + 1 != $end
ABCresult
0XX0
10X0
1100
1111
774 (!($lexer->[LEXER_SQL_MODE] & MODE_NO_BACKSLASH_ESCAPES)) &&
775 (substr($string, $str, 1) eq "\\") &&
776 ($str + 1 != $end)
777 ) {
778 0 my $prev_str = substr($string, ++$str, 1);
779 0 ▶ if ($prev_str eq 'n') {
Branch: 7 branches
BranchTrueFalseTotal
if ($prev_str eq 'n') { } 0 0 0
elsif ($prev_str eq 't') { } 0 0 0
elsif ($prev_str eq 'r') { } 0 0 0
elsif ($prev_str eq 'b') { } 0 0 0
elsif ($prev_str eq '0') { } 0 0 0
elsif ($prev_str eq 'Z') { } 0 0 0
elsif ($prev_str eq '_' or $prev_str eq '%') { } 0 0 0
780 0 substr($new_str, $to++, 1) = "\n";
781 0 next;
782 } elsif ($prev_str eq 't') {
783 0 substr($new_str, $to++, 1) = "\t";
784 0 next;
785 } elsif ($prev_str eq 'r') {
786 0 substr($new_str, $to++, 1) = "\r";
787 0 next;
788 } elsif ($prev_str eq 'b') {
789 0 substr($new_str, $to++, 1) = "\b";
790 0 next;
791 } elsif ($prev_str eq '0') {
792 0 substr($new_str, $to++, 1) = "\0";
793 0 next;
794 } elsif ($prev_str eq 'Z') {
795 0 substr($new_str, $to++, 1) = "\032";
796 0 next;
797 ▶ } elsif (
Condition0%0/3
$prev_str eq "_" or $prev_str eq "%"
l!l&&r!l&&!r
000
MC/DC0%0/2
$prev_str eq "_" or $prev_str eq "%"
$prev_str eq "_" $prev_str eq "%"
Truth table0%0/3
A or B
A= $prev_str eq "_"B= $prev_str eq "%"
ABresult
1X1
011
000
798 ($prev_str eq '_') ||
799 ($prev_str eq '%')
800 ) {
801 0 substr($new_str, $to++, 1) = "\\";
802 0 substr($new_str, $to++, 1) = $prev_str; # Added
803 } else {
804 0 substr($new_str, $to++, 1) = $prev_str;
805 }
806 } elsif (substr($string, $str, 1) eq $sep) {
807 0 substr($new_str, $to++, 1) = substr($string, $str++, 1);
808 } else {
809 0 substr($new_str, $to++, 1) = substr($string, $str, 1);
810 }
811 }
812 0 return $new_str;
813 }
814 0 return substr($string, $start, ($to - $start));
815 }
816 }
817 0 return undef;
818 }
819  
820 307 ▶sub get_token {
Subroutine get_token: called CC=1 SCAR=0.0
Pod undocumented
821 307 my ($lexer, $length) = @_;
822 307 $lexer->yyUnget();
823 307 return substr($lexer->[LEXER_STRING], $lexer->[LEXER_TOK_START], $length);
824 }
825  
826 8 ▶use constant LONG_STR => "2147483647";
Subroutine BEGIN: called CC=1 SCAR=0.0
827 8 ▶use constant LONG_LEN => 10;
Subroutine BEGIN: called CC=1 SCAR=0.0
828 8 ▶use constant SIGNED_LONG_STR => "-2147483648";
Subroutine BEGIN: called CC=1 SCAR=0.0
829 8 ▶use constant LONGLONG_STR => "9223372036854775807";
Subroutine BEGIN: called CC=1 SCAR=0.0
830 8 ▶use constant LONGLONG_LEN => 19;
Subroutine BEGIN: called CC=1 SCAR=0.0
831 8 ▶use constant SIGNED_LONGLONG_STR => "-9223372036854775808";
Subroutine BEGIN: called CC=1 SCAR=0.0
832 8 ▶use constant SIGNED_LONGLONG_LEN => 19;
Subroutine BEGIN: called CC=1 SCAR=0.0
833 8 ▶use constant UNSIGNED_LONGLONG_STR => "18446744073709551615";
Subroutine BEGIN: called CC=1 SCAR=0.0
834 8 ▶use constant UNSIGNED_LONGLONG_LEN => 20;
Subroutine BEGIN: called CC=1 SCAR=0.0
835  
836 27 ▶sub int_token {
Subroutine int_token: called CC=16 SCAR=54.4
Pod undocumented
837 27 my ($lexer, $token) = @_;
838
839 27 ▶ if (length($token) < LONG_LEN) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $token < 10) 27 0 27
840 27 return ("NUM", $token);
841 }
842  
843 0 my $neg = 0;
844  
845 0 ▶ if (substr($token, 0, 1) eq '+') {
Branch: 2 branches
BranchTrueFalseTotal
if (substr($token, 0, 1) eq '+') { } 0 0 0
elsif (substr($token, 0, 1) eq '-') { } 0 0 0
846 0 $token = substr($token, 1);
847 } elsif (substr($token, 0, 1) eq '-') {
848 0 $token = substr($token, 1);
849 0 $neg = 1;
850 }
851  
852 0 ▶ while (
Branch: 1 branch
BranchTrueFalseTotal
if (substr($token, 0, 1) eq 0 and length $token > 0) 0 0 0
Condition0%0/3
substr($token, 0, 1) eq 0 and length $token > 0
!ll&&!rl&&r
000
MC/DC0%0/2
substr($token, 0, 1) eq 0 and length $token > 0
substr($token, 0, 1) eq 0 length $token > 0
Truth table0%0/3
A and B
A= substr($token, 0, 1) eq 0B= length $token > 0
ABresult
0X0
100
111
853 (substr($token, 0, 1) eq '0') &&
854 (length($token) > 0)
855 ) {
856 0 $token = substr($token, 1);
857 }
858  
859 0 ▶ if (length($token) < LONG_LEN) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $token < 10) 0 0 0
860 0 return ("NUM", $token);
861 }
862  
863 0 my ($smaller, $bigger);
864 0 my $cmp;
865  
866 0 ▶ if ($neg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($neg) { } 0 0 0
867 0 ▶ if (length($token) == LONG_LEN) {
Branch: 3 branches
BranchTrueFalseTotal
if (length $token == 10) { } 0 0 0
elsif (length $token < 19) { } 0 0 0
elsif (length $token > 19) { } 0 0 0
868 0 $cmp = SIGNED_LONG_STR + 1;
869 0 $smaller = 'NUM';
870 0 $bigger = 'LONG_NUM';
871 } elsif (length($token) < SIGNED_LONGLONG_LEN) {
872 0 return ('LONG_NUM', $token);
873 } elsif (length($token) > SIGNED_LONGLONG_LEN) {
874 0 return ('DECIMAL_SYM', $token);
875 } else {
876 0 $cmp = SIGNED_LONGLONG_STR + 1;
877 0 $smaller = 'LONG_NUM';
878 0 $bigger = 'DECIMAL_NUM';
879 }
880 } else {
881 0 ▶ if (length($token) == LONGLONG_LEN) {
Branch: 3 branches
BranchTrueFalseTotal
if (length $token == 19) { } 0 0 0
elsif (length $token < 19) { } 0 0 0
elsif (length $token > 19) { } 0 0 0
882 0 $cmp = LONG_STR;
883 0 $smaller = 'NUM';
884 0 $bigger = 'LONG_NUM';
885 } elsif (length($token) < LONGLONG_LEN) {
886 0 return('LONG_NUM', $token);
887 } elsif (length($token) > LONGLONG_LEN) {
888 0 ▶ if (length($token) > UNSIGNED_LONGLONG_LEN) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $token > 20) 0 0 0
889 0 return ('DECIMAL_NUM', $token);
890 }
891 0 $cmp = UNSIGNED_LONGLONG_STR;
892 0 $smaller = 'ULONGLONG_NUM';
893 0 $bigger = 'DECIMAL_NUM';
894 } else {
895 0 $cmp = LONGLONG_STR;
896 0 $smaller = 'LONG_NUM';
897 0 $bigger = 'ULONGLONG_NUM';
898 }
899 }
900
901 0 ▶ return $token > $cmp ? ($bigger, $token) : ($smaller, $token);
Branch: 1 branch
BranchTrueFalseTotal
$token > $cmp ? : 0 0 0
902 }
903  
904 278 ▶sub find_keyword {
Subroutine find_keyword: called CC=8 SCAR=20.9
Pod undocumented
905 278 my ($lexer, $length, $function) = @_;
906 278 my $keyword = substr($lexer->[LEXER_STRING], $lexer->[LEXER_TOK_START], $length);
907  
908 278 my $symbol;
909 278 ▶ if ($function) {
Branch: 1 branch
BranchTrueFalseTotal
if ($function) { } 10 268 278
910 10 $symbol = $DBIx::MyParsePP::Symbols::functions->{uc($keyword)};
911 10 ▶ $symbol = $DBIx::MyParsePP::Symbols::symbols->{uc($keyword)} if not defined $symbol;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $symbol 3 7 10
912 } else {
913 268 $symbol = $DBIx::MyParsePP::Symbols::symbols->{uc($keyword)};
914 }
915  
916 278 ▶ return () if not defined $symbol;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $symbol 69 209 278
917
918 209 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($symbol eq "NOT_SYM" and $lexer->[3] & 536870912) 0 209 209
Condition66%2/3
$symbol eq "NOT_SYM" and $lexer->[3] & 536870912
!ll&&!rl&&r
20810
MC/DC0%0/2
$symbol eq "NOT_SYM" and $lexer->[3] & 536870912
$symbol eq "NOT_SYM" $lexer->[3] & 536870912
Truth table66%2/3
A and B
A= $symbol eq "NOT_SYM"B= $lexer->[3] & 536870912
ABresult
0X0
100
111
919 ($symbol eq 'NOT_SYM') &&
920 ($lexer->[LEXER_SQL_MODE] & MODE_HIGH_NOT_PRECEDENCE)
921 ) {
922 0 $symbol = 'NOT2_SYM';
923 }
924  
925 209 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($symbol eq "OR_OR_SYM" and $lexer->[3] & 2) 1 208 209
Condition100%3/3
$symbol eq "OR_OR_SYM" and $lexer->[3] & 2
!ll&&!rl&&r
20711
MC/DC100%2/2
$symbol eq "OR_OR_SYM" and $lexer->[3] & 2
$symbol eq "OR_OR_SYM" $lexer->[3] & 2
Truth table100%3/3
A and B
A= $symbol eq "OR_OR_SYM"B= $lexer->[3] & 2
ABresult
0X0
100
111
926 ($symbol eq 'OR_OR_SYM') &&
927 ($lexer->[LEXER_SQL_MODE] & MODE_PIPES_AS_CONCAT)
928 ) {
929 1 $symbol = 'OR2_SYM';
930 }
931  
932 209 return ($symbol, $keyword);
933 }
934  
935 8 1;
936  
937  
938 __END__
↑ Summary MyParsePP/Token.pm »