MyParsePP/Lexer.pm

filter: Statementstmt 65.7% 424 / 645 Branchbran 42.9% 141 / 328 Conditioncond 33.3% 50 / 150 MC/DCmcdc 21.8% 19 / 87 Subroutinesub 90.9% 80 / 88 Podpod 0.0% 0 / 28 totaltotal 53.8% 714 / 1326 SCAR 84.2
CC
216
Cov
55%
MYSQLlex
4642.3
int_token
230.0
get_text
213.4
CRAP 4534.8
↑ Summary MyParsePP/Parser.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 6 require Exporter;
18 6 @ISA = qw(Exporter);
19 6 @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 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 7 ▶use DBIx::MyParsePP::Symbols;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 6 ▶use DBIx::MyParsePP::Charsets;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 6 ▶use DBIx::MyParsePP::Token;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 6 ▶use constant CTYPE_U => 01; # Uppercase
Subroutine BEGIN: called CC=1 SCAR=0.0
29 6 ▶use constant CTYPE_L => 02; # Lowercase
Subroutine BEGIN: called CC=1 SCAR=0.0
30 6 ▶use constant CTYPE_NMR => 04; # Numeral (digit)
Subroutine BEGIN: called CC=1 SCAR=0.0
31 6 ▶use constant CTYPE_SPC => 010; # Spacing character
Subroutine BEGIN: called CC=1 SCAR=0.0
32 6 ▶use constant CTYPE_PNT => 020; # Punctuation
Subroutine BEGIN: called CC=1 SCAR=0.0
33 6 ▶use constant CTYPE_CTR => 040; # Control character
Subroutine BEGIN: called CC=1 SCAR=0.0
34 6 ▶use constant CTYPE_B => 0100; # Blank
Subroutine BEGIN: called CC=1 SCAR=0.0
35 6 ▶use constant CTYPE_X => 0200; # heXadecimal digit
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 6 ▶use constant LEXER_STRING => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 6 ▶use constant LEXER_CHARSET => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 6 ▶use constant LEXER_VERSION => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 6 ▶use constant LEXER_SQL_MODE => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 6 ▶use constant LEXER_OPTIONS => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 6 ▶use constant LEXER_CLIENT_CAPABILITIES => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 6 ▶use constant LEXER_STMT_PREPARE_MODE => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 6 ▶use constant LEXER_PTR => 7;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 6 ▶use constant LEXER_TOK_START => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 6 ▶use constant LEXER_TOKENS => 9;
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 6 ▶use constant LEXER_YYLINENO => 10;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 6 ▶use constant LEXER_NEXT_STATE => 11;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 6 ▶use constant LEXER_IN_COMMENT => 12;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 6 ▶use constant LEXER_FOUND_SEMICOLON => 13;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 6 ▶use constant LEXER_SAFE_TO_CACHE_QUERY => 14;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 6 ▶use constant LEXER_SERVER_STATUS => 15;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 6 ▶use constant LEXER_CTYPE => 16;
Subroutine BEGIN: called CC=1 SCAR=0.0
57  
58  
59 6 ▶use constant OPTION_FOUND_COMMENT => 1 << 15;
Subroutine BEGIN: called CC=1 SCAR=0.0
60 6 ▶use constant CLIENT_MULTI_STATEMENTS => 1 << 16;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 6 ▶use constant SERVER_MORE_RESULTS_EXISTS => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 6 ▶use constant NAMES_SEP_CHAR => '\377';
Subroutine BEGIN: called CC=1 SCAR=0.0
63  
64  
65 6 ▶use constant MODE_PIPES_AS_CONCAT => 2; # USE ME!
Subroutine BEGIN: called CC=1 SCAR=0.0
66 6 ▶use constant MODE_ANSI_QUOTES => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
67 6 ▶use constant MODE_IGNORE_SPACE => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 6 ▶use constant MODE_MYSQL323 => 65536;
Subroutine BEGIN: called CC=1 SCAR=0.0
69 6 ▶use constant MODE_MYSQL40 => MODE_MYSQL323 * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
70 6 ▶use constant MODE_ANSI => MODE_MYSQL40 * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
71 6 ▶use constant MODE_NO_AUTO_VALUE_ON_ZERO => MODE_ANSI * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
72 6 ▶use constant MODE_NO_BACKSLASH_ESCAPES => MODE_NO_AUTO_VALUE_ON_ZERO * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
73 6 ▶use constant MODE_STRICT_TRANS_TABLES => MODE_NO_BACKSLASH_ESCAPES * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
74 6 ▶use constant MODE_STRICT_ALL_TABLES => MODE_STRICT_TRANS_TABLES * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
75 6 ▶use constant MODE_NO_ZERO_IN_DATE => MODE_STRICT_ALL_TABLES * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 6 ▶use constant MODE_NO_ZERO_DATE => MODE_NO_ZERO_IN_DATE * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
77 6 ▶use constant MODE_INVALID_DATES => MODE_NO_ZERO_DATE * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 6 ▶use constant MODE_ERROR_FOR_DIVISION_BY_ZERO => MODE_INVALID_DATES * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
79 6 ▶use constant MODE_TRADITIONAL => MODE_ERROR_FOR_DIVISION_BY_ZERO * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 6 ▶use constant MODE_NO_AUTO_CREATE_USER => MODE_TRADITIONAL * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
81 6 ▶use constant MODE_HIGH_NOT_PRECEDENCE => MODE_NO_AUTO_CREATE_USER * 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
82  
83 6 my %state_maps;
84 my %ident_maps;
85  
86 6 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 6 1;
96  
97 sub new {
98 11 ▶ my $class = shift;
Subroutine new: called CC=9 SCAR=22.6
Pod undocumented
99 11 my $lexer = bless([], $class);
100  
101 11 my $max_arg = (scalar(@_) / 2) - 1;
102  
103 11 foreach my $i (0..$max_arg) {
104 66 ▶ if (exists $args{$_[$i * 2]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{$_[$i * 2]}) { } 66 0 66
105 66 $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 11 $lexer->[LEXER_STRING] = $lexer->[LEXER_STRING]."\0";
112 11 $lexer->[LEXER_YYLINENO] = 1;
113 11 $lexer->[LEXER_TOK_START] = 0;
114 11 $lexer->[LEXER_PTR] = 0;
115 11 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START';
116  
117 11 ▶ $lexer->[LEXER_CLIENT_CAPABILITIES] = CLIENT_MULTI_STATEMENTS if not defined $lexer->[LEXER_CLIENT_CAPABILITIES];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lexer->[5] 11 0 11
118 11 ▶ $lexer->[LEXER_STMT_PREPARE_MODE] = 0 if not defined $lexer->[LEXER_STMT_PREPARE_MODE];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lexer->[6] 11 0 11
119 11 ▶ $lexer->[LEXER_SQL_MODE] = 0 if not defined $lexer->[LEXER_SQL_MODE]; # CHECKME
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lexer->[3] 10 1 11
120  
121 11 ▶ $lexer->[LEXER_VERSION] = '50045' if not defined $lexer->[LEXER_VERSION];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lexer->[2] 9 2 11
122 11 ▶ $lexer->[LEXER_CHARSET] = 'ascii' if not defined $lexer->[LEXER_CHARSET]; # FIXME
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lexer->[1] 11 0 11
123  
124 11 my $charset_uc = ucfirst($lexer->[LEXER_CHARSET]);
125 6 ▶ 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 11 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 11 11
131 0 print STDERR "DBIx::MyParsePP::Lexer->new() failed: $@\n";
132 0 return undef;
133 }
134  
135 11 $lexer->[LEXER_TOKENS] = [];
136  
137 11 $lexer->init_state_maps($lexer->[LEXER_CHARSET]);
138  
139 11 return $lexer;
140
141 }
142  
143 sub getLine {
144 1 ▶ return $_[0]->[LEXER_YYLINENO];
Subroutine getLine: called CC=1 SCAR=0.0
Pod undocumented
145 }
146  
147 sub line {
148 0 ▶ return $_[0]->[LEXER_YYLINENO];
Subroutine line: not called CC=1 SCAR=6.9
Pod undocumented
149 }
150  
151 sub pos {
152 0 ▶ return $_[0]->[LEXER_PTR];
Subroutine pos: not called CC=1 SCAR=6.9
Pod undocumented
153 }
154  
155 sub getPos {
156 1 ▶ return $_[0]->[LEXER_PTR];
Subroutine getPos: called CC=1 SCAR=0.0
Pod undocumented
157 }
158  
159 sub getTokens {
160 1 ▶ return $_[0]->[LEXER_TOKENS];
Subroutine getTokens: called CC=1 SCAR=0.0
Pod undocumented
161 }
162  
163 sub tokens {
164 0 ▶ return $_[0]->[LEXER_TOKENS];
Subroutine tokens: not called CC=1 SCAR=6.9
Pod undocumented
165 }
166  
167 4134 ▶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 374 ▶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 508 ▶sub yyUnget { $_[0]->[LEXER_PTR]-- };
Subroutine yyUnget: called CC=1 SCAR=0.0
Pod undocumented
172 94 ▶sub yySkip { $_[0]->[LEXER_PTR]++ };
Subroutine yySkip: called CC=1 SCAR=0.0
Pod undocumented
173 132 ▶sub yyLength { ($_[0]->[LEXER_PTR] - $_[0]->[LEXER_TOK_START]) - 1 };
Subroutine yyLength: called CC=1 SCAR=0.0
Pod undocumented
174  
175 sub yylex {
176 732 ▶ my $lexer = shift;
Subroutine yylex: called CC=3 SCAR=11.0
Pod undocumented
177 732 my @res = $lexer->MYSQLlex();
178 732 ▶ if (($res[0] eq '0') && ($res[1] eq '0')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res[0] eq '0' and $res[1] eq '0') { } 9 723 732
Condition66%2/3
$res[0] eq 0 and $res[1] eq 0
!ll&&!rl&&r
72309
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 9 return (undef, ''); # EOF
180 } else {
181 723 my $token = DBIx::MyParsePP::Token->new(@res);
182 723 push @{$lexer->[LEXER_TOKENS]}, $token;
183 723 return ($res[0], $token);
184 }
185 }
186  
187 sub MYSQLlex {
188 732 ▶ my $lexer = shift;
Subroutine MYSQLlex: called CC=156 SCAR=84.4
Pod undocumented
189  
190 732 my $string = $lexer->[LEXER_STRING];
191 732 my $state_map = $state_maps{$lexer->[LEXER_CHARSET]};
192 732 my $ident_map = $ident_maps{$lexer->[LEXER_CHARSET]};
193
194 732 my $c = 0;
195 732 my @token;
196 my $result_state;
197 732 my $state;
198  
199 732 $lexer->[LEXER_TOK_START] = $lexer->[LEXER_PTR];
200  
201  
202 732 $state = $lexer->[LEXER_NEXT_STATE];
203 732 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_OPERATOR_OR_IDENT';
204  
205 732 my $char = substr($string, $lexer->[LEXER_PTR], 1);
206  
207 732 for (;;) {
208 785 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($state eq "MY_LEX_OPERATOR_OR_IDENT" or $state eq "MY_LEX_START") 530 255 785
Condition100%3/3
$state eq "MY_LEX_OPERATOR_OR_IDENT" or $state eq "MY_LEX_START"
l!l&&r!l&&!r
234296255
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 530 ▶ 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") 915 530 1445
213 915 ▶ $lexer->[LEXER_YYLINENO]++ if $c == ord("\n");
Branch: 1 branch
BranchTrueFalseTotal
if $c == 10 105 810 915
214 }
215 530 $lexer->[LEXER_TOK_START] = $lexer->[LEXER_PTR] - 1;
216 530 $state = $state_map->[$c];
217 }
218
219 785 ▶ if ($state eq 'MY_LEX_ESCAPE') {
Branch: 1 branch
BranchTrueFalseTotal
if ($state eq "MY_LEX_ESCAPE") 0 785 785
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 785 ▶ if (
Branch: 4 branches
BranchTrueFalseTotal
if ($state eq 'MY_LEX_ESCAPE' or $state eq 'MY_LEX_CHAR' or $state eq 'MY_LEX_SKIP') { } 106 679 785
elsif ($state eq 'MY_LEX_IDENT_OR_NCHAR') { } 4 675 679
elsif ($state eq 'MY_LEX_IDENT_OR_HEX') { } 0 675 675
elsif ($state eq 'MY_LEX_IDENT_OR_BIN') { } 4 671 675
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
1060679
$state eq "MY_LEX_ESCAPE" or $state eq "MY_LEX_CHAR"
l!l&&r!l&&!r
0106679
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 106 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 45 and $lexer->yyPeek == 45 and $lexer->my_isspace($lexer->yyPeek2) || $lexer->my_iscntrl($lexer->yyPeek2)) 0 106 106
Condition33%3/9
$c == 45 and $lexer->yyPeek == 45 and $lexer->my_isspace($lexer->yyPeek2) || $lexer->my_iscntrl($lexer->yyPeek2)
!ll&&!rl&&r
10600
$c == 45 and $lexer->yyPeek == 45
!ll&&!rl&&r
10510
$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 106 $lexer->[LEXER_PTR] = $lexer->[LEXER_TOK_START];
240 106 my $lex_str = substr($string, $lexer->[LEXER_PTR], 1);
241 106 $c = $lexer->yyGet();
242
243 106 ▶ $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START' if $c != ord (')');
Branch: 1 branch
BranchTrueFalseTotal
if $c != 41 78 28 106
244  
245 106 ▶ if ($c == ord(',')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c == 44) { } 38 68 106
elsif ($c == 63 and not $$ident_map[$lexer->yyPeek]) { } 0 136 136
246 38 $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
6800
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 106 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 4 ▶ if ($lexer->yyPeek() == ord("'")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->yyPeek == 39) 0 4 4
271 0 $state = 'MY_LEX_BIN_NUMBER';
272 0 next;
273 }
274 }
275  
276 675 ▶ 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') { } 298 377 675
elsif ($state eq 'MY_LEX_IDENT_SEP') { } 107 270 377
elsif ($state eq 'MY_LEX_NUMBER_IDENT') { } 27 243 270
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
4294377
$state eq "MY_LEX_IDENT_OR_HEX" or $state eq "MY_LEX_IDENT_OR_BIN"
l!l&&r!l&&!r
04671
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 298 my $start;
282 ## FIXME - multibyte
283  
284 298 ▶ for ($result_state = $c; $ident_map->[$c = $lexer->yyGet()]; $result_state |= $c) {};
Branch: 1 branch
BranchTrueFalseTotal
if ($$ident_map[$c = $lexer->yyGet]) 828 298 1126
285
286 298 ▶ $result_state = $result_state & 0x80 ? 'IDENT_QUOTED' : 'IDENT';
Branch: 1 branch
BranchTrueFalseTotal
$result_state & 128 ? : 0 298 298
287  
288 298 my $length = $lexer->[LEXER_PTR] - $lexer->[LEXER_TOK_START] - 1;
289 298 $start = $lexer->[LEXER_PTR];
290  
291 298 ▶ if ($lexer->[LEXER_SQL_MODE] & MODE_IGNORE_SPACE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->[3] & 8) 0 298 298
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 298 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($start == $lexer->[7] and $c == 46 and $$ident_map[$lexer->yyPeek]) { } 103 195 298
Condition83%5/6
$start == $lexer->[7] and $c == 46 and $$ident_map[$lexer->yyPeek]
!ll&&!rl&&r
1941103
$start == $lexer->[7] and $c == 46
!ll&&!rl&&r
0194104
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 195 $lexer->yyUnget();
303 195 ▶ if (@token = $lexer->find_keyword($length, $c == ord('('))) {
Branch: 1 branch
BranchTrueFalseTotal
if (@token = $lexer->find_keyword($length, $c == 40)) 138 57 195
304 138 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START';
305 138 return @token;
306 }
307 57 $lexer->yySkip();
308 }
309 160 my $lex_str = $lexer->get_token($length);
310  
311 160 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (substr($lex_str, 0, 1) eq "_" and exists $$DBIx::MyParsePP::Charsets::charsets{substr $lex_str, 1}) 0 160 160
Condition33%1/3
substr($lex_str, 0, 1) eq "_" and exists $$DBIx::MyParsePP::Charsets::charsets{substr $lex_str, 1}
!ll&&!rl&&r
16000
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 160 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 243 ▶ if ($state eq 'MY_LEX_IDENT_START') {
Branch: 3 branches
BranchTrueFalseTotal
if ($state eq 'MY_LEX_IDENT_START') { } 105 138 243
elsif ($state eq 'MY_LEX_USER_VARIABLE_DELIMITER') { } 0 138 138
elsif ($state eq 'MY_LEX_INT_OR_REAL') { } 27 111 138
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 0 my $double_quotes = 0;
388 0 my $quote_char = $c;
389 0 $lexer->[LEXER_TOK_START] = $lexer->[LEXER_PTR];
390 0 ▶ while ($c = $lexer->yyGet()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c = $lexer->yyGet) 0 0 0
391 0 my $var_length = $lexer->my_mbcharlen($c);
392 0 ▶ if ($var_length == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($var_length == 1) 0 0 0
393 0 ▶ last if $c == ord(NAMES_SEP_CHAR);
Branch: 1 branch
BranchTrueFalseTotal
if $c == 92 0 0 0
394 0 ▶ if ($c == $quote_char) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == $quote_char) 0 0 0
395 0 ▶ last if $lexer->yyPeek() != $quote_char;
Branch: 1 branch
BranchTrueFalseTotal
if $lexer->yyPeek != $quote_char 0 0 0
396 0 $c = $lexer->yyGet();
397 0 $double_quotes++;
398 0 next;
399 }
400 }
401 }
402 # MULTIBYTE!!
403  
404 0 my $lex_str;
405
406 0 ▶ if ($double_quotes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($double_quotes) { } 0 0 0
407 0 $lex_str = $lexer->get_quoted_token($lexer->yyLength() - $double_quotes, $quote_char);
408 } else {
409 0 $lex_str = $lexer->get_token($lexer->yyLength());
410 }
411
412 0 ▶ $lexer->yySkip() if $c == $quote_char;
Branch: 1 branch
BranchTrueFalseTotal
if $c == $quote_char 0 0 0
413 0 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START';
414 0 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 111 ▶ if (
Branch: 7 branches
BranchTrueFalseTotal
if ($state eq 'MY_LEX_INT_OR_REAL' or $state eq 'MY_LEX_REAL') { } 0 111 111
elsif ($state eq 'MY_LEX_HEX_NUMBER') { } 0 111 111
elsif ($state eq 'MY_LEX_BIN_NUMBER') { } 0 111 111
elsif ($state eq 'MY_LEX_CMP_OP') { } 48 63 111
elsif ($state eq 'MY_LEX_LONG_CMP_OP') { } 0 63 63
elsif ($state eq 'MY_LEX_BOOL') { } 2 61 63
elsif ($state eq 'MY_LEX_STRING_OR_DELIMITER') { } 4 57 61
Condition33%1/3
$state eq "MY_LEX_INT_OR_REAL" or $state eq "MY_LEX_REAL"
l!l&&r!l&&!r
00111
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 48 ▶ 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 47 48
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
1047
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 48 ▶ 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)) 48 0 48
482 48 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_START';
483 48 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 61 ▶ if (
Branch: 6 branches
BranchTrueFalseTotal
if ($state eq 'MY_LEX_STRING_OR_DELIMITER' or $state eq 'MY_LEX_STRING') { } 19 42 61
elsif ($state eq 'MY_LEX_COMMENT') { } 0 42 42
elsif ($state eq 'MY_LEX_LONG_COMMENT') { } 17 25 42
elsif ($state eq 'MY_LEX_END_LONG_COMMENT') { } 3 22 25
elsif ($state eq 'MY_LEX_SET_VAR') { } 0 22 22
elsif ($state eq 'MY_LEX_SEMICOLON') { } 1 21 22
Condition100%3/3
$state eq "MY_LEX_STRING_OR_DELIMITER" or $state eq "MY_LEX_STRING"
l!l&&r!l&&!r
41542
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
Condition50%3/6
$lexer->[7] != length($string) - 1 and ($c = $lexer->yyGet != 42) || $lexer->yyPeek != 47
!ll&&!rl&&r
04620
$c = $lexer->yyGet != 42 or $lexer->yyPeek != 47
l!l&&r!l&&!r
447015
MC/DC0%0/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 table25%1/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 21 ▶ if (
Branch: 7 branches
BranchTrueFalseTotal
if ($state eq 'MY_LEX_SEMICOLON' or $state eq 'MY_LEX_EOL') { } 10 11 21
elsif ($state eq 'MY_LEX_END') { } 9 2 11
elsif ($state eq 'MY_LEX_REAL_OR_POINT') { } 2 0 2
elsif ($state eq 'MY_LEX_USER_END') { } 0 0 0
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
01011
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 10 ▶ if ($lexer->[LEXER_PTR] >= length($string) - 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->[7] >= length($string) - 1) 10 0 10
609 10 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_END';
610 10 return ('END_OF_INPUT','');
611 }
612 0 $state = 'MY_LEX_CHAR';
613 0 next;
614 } elsif ($state eq 'MY_LEX_END') {
615 9 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_END';
616 9 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 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($$state_map[$lexer->yyPeek] eq 'MY_LEX_STRING' or $$state_map[$lexer->yyPeek] eq 'MY_LEX_USER_VARIABLE_DELIMITER' or $$state_map[$lexer->yyPeek] eq 'MY_LEX_STRING_OR_DELIMITER') { } 0 0 0
elsif ($$state_map[$lexer->yyPeek] eq 'MY_LEX_USER_END') { } 0 0 0
Condition0%0/6
$$state_map[$lexer->yyPeek] eq "MY_LEX_STRING" or $$state_map[$lexer->yyPeek] eq "MY_LEX_USER_VARIABLE_DELIMITER" or $$state_map[$lexer->yyPeek] eq "MY_LEX_STRING_OR_DELIMITER"
l!l&&r!l&&!r
000
$$state_map[$lexer->yyPeek] eq "MY_LEX_STRING" or $$state_map[$lexer->yyPeek] eq "MY_LEX_USER_VARIABLE_DELIMITER"
l!l&&r!l&&!r
000
MC/DC0%0/3
$$state_map[$lexer->yyPeek] eq "MY_LEX_STRING" or $$state_map[$lexer->yyPeek] eq "MY_LEX_USER_VARIABLE_DELIMITER" 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_USER_VARIABLE_DELIMITER" $$state_map[$lexer->yyPeek] eq "MY_LEX_STRING_OR_DELIMITER"
Truth table0%0/4
A or B or C
A= $$state_map[$lexer->yyPeek] eq "MY_LEX_STRING"B= $$state_map[$lexer->yyPeek] eq "MY_LEX_USER_VARIABLE_DELIMITER"C= $$state_map[$lexer->yyPeek] eq "MY_LEX_STRING_OR_DELIMITER"
ABCresult
1XX1
01X1
0011
0000
627 ($state_map->[$lexer->yyPeek()] eq 'MY_LEX_STRING') ||
628 ($state_map->[$lexer->yyPeek()] eq 'MY_LEX_USER_VARIABLE_DELIMITER') ||
629 ($state_map->[$lexer->yyPeek()] eq 'MY_LEX_STRING_OR_DELIMITER')
630 ) {
631 0 next;
632 } elsif ($state_map->[$lexer->yyPeek()] eq 'MY_LEX_USER_END') {
633 0 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_SYSTEM_VAR';
634 } else {
635 0 $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_HOSTNAME';
636 }
637 0 my $lex_str = substr($string, $lexer->[LEXER_PTR], 1);
638 0 return ('@', $lex_str);
639 } elsif ($state eq 'MY_LEX_HOSTNAME') {
640 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
641 0 my $lex_str = $lexer->get_token($lexer->yyLength());
642 0 return ('LEX_HOSTNAME', $lex_str);
643 } elsif ($state eq 'MY_LEX_SYSTEM_VAR') {
644 0 my $lex_str = substr($string, $lexer->[LEXER_PTR], 1);
645 0 $lexer->yySkip();
646 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
647 0 return ('@', $lex_str);
648 } elsif ($state eq 'MY_LEX_IDENT_OR_KEYWORD') {
649 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
650 0 ▶ $result_state = $result_state & 0x80 ? 'IDENT_QUOTED' : 'IDENT';
Branch: 1 branch
BranchTrueFalseTotal
$result_state & 128 ? : 0 0 0
651  
652 0 ▶ $lexer->[LEXER_NEXT_STATE] = 'MY_LEX_IDENT_SEP' if $c == ord('.');
Branch: 1 branch
BranchTrueFalseTotal
if $c == 46 0 0 0
653
654 0 my $length = ($lexer->[LEXER_PTR] - $lexer->[LEXER_TOK_START]) - 1;
655 0 ▶ return ('ABORT_SYM','ABORT_SYM') if $length == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $length == 0 0 0 0
656 0 ▶ if (@token = $lexer->find_keyword($length, 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@token = $lexer->find_keyword($length, 0)) 0 0 0
657 0 $lexer->yyUnget();
658 0 return @token;
659 }
660 0 my $lex_str = $lexer->get_token($length);
661 0 return ($result_state, $lex_str);
662 }
663 }
664 }
665  
666 sub init_state_maps {
667  
668 11 ▶ my $lexer = shift;
Subroutine init_state_maps: called CC=8 SCAR=20.8
Pod undocumented
669  
670 11 ▶ return if exists $state_maps{$lexer->[LEXER_CHARSET]};
Branch: 1 branch
BranchTrueFalseTotal
if exists $state_maps{$lexer->[1]} 5 6 11
671  
672 6 my @state_map;
673 my @ident_map;
674  
675 6 ▶ for (my $i = 0; $i < 256; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 256) 1536 6 1542
676 1536 ▶ if ($lexer->my_isalpha($i)) {
Branch: 3 branches
BranchTrueFalseTotal
if ($lexer->my_isalpha($i)) { } 312 1224 1536
elsif ($lexer->my_isdigit($i)) { } 60 1164 1224
elsif ($lexer->my_isspace($i)) { } 36 1128 1164
677 312 $state_map[$i] = 'MY_LEX_IDENT';
678 } elsif ($lexer->my_isdigit($i)) {
679 60 $state_map[$i] = 'MY_LEX_NUMBER_IDENT';
680 # FIXME MULTI-BYTE
681 } elsif ($lexer->my_isspace($i)) {
682 36 $state_map[$i] = 'MY_LEX_SKIP';
683 } else {
684 1128 $state_map[$i] = 'MY_LEX_CHAR';
685 }
686 }
687  
688 6 $state_map[ord('_')] = $state_map[ord('$')] = 'MY_LEX_IDENT';
689 6 $state_map[ord("'")] = 'MY_LEX_STRING';
690 6 $state_map[ord('.')] = 'MY_LEX_REAL_OR_POINT';
691  
692 6 $state_map[ord('>')] = $state_map[ord('=')] = $state_map[ord('!')] = 'MY_LEX_CMP_OP';
693 6 $state_map[ord('<')] = 'MY_LEX_LONG_CMP_OP';
694 6 $state_map[ord('&')] = $state_map[ord('|')] = 'MY_LEX_BOOL';
695 6 $state_map[ord('#')] = 'MY_LEX_COMMENT';
696 6 $state_map[ord(';')] = 'MY_LEX_SEMICOLON';
697 6 $state_map[ord(':')] = 'MY_LEX_SET_VAR';
698 6 $state_map[0] = 'MY_LEX_EOL';
699 6 $state_map[ord("\\")] = 'MY_LEX_ESCAPE';
700 6 $state_map[ord('/')] = 'MY_LEX_LONG_COMMENT';
701 6 $state_map[ord('*')] = 'MY_LEX_END_LONG_COMMENT';
702 6 $state_map[ord('@')] = 'MY_LEX_USER_END';
703 6 $state_map[ord('`')] = 'MY_LEX_USER_VARIABLE_DELIMITER';
704 6 $state_map[ord('"')] = 'MY_LEX_STRING_OR_DELIMITER';
705  
706 6 ▶ for (my $i=0; $i < 256 ; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 256) 1536 6 1542
707 1536 ▶ $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
324601152
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
708 }
709  
710 6 $state_map[ord('x')] = $state_map[ord('X')] = 'MY_LEX_IDENT_OR_HEX';
711 6 $state_map[ord('b')] = $state_map[ord('B')] = 'MY_LEX_IDENT_OR_BIN';
712 6 $state_map[ord('n')] = $state_map[ord('N')] = 'MY_LEX_IDENT_OR_NCHAR';
713  
714 6 $state_maps{$lexer->[LEXER_CHARSET]} = \@state_map;
715 6 $ident_maps{$lexer->[LEXER_CHARSET]} = \@ident_map;
716 }
717  
718  
719 0 ▶sub my_mbcharlen { 1 };
Subroutine my_mbcharlen: not called CC=1 SCAR=6.9
Pod undocumented
720  
721 1536 ▶sub my_isalpha { $_[0]->[LEXER_CTYPE]->[$_[1] + 1] & (CTYPE_U | CTYPE_L) }
Subroutine my_isalpha: called CC=1 SCAR=0.0
Pod undocumented
722  
723 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
724  
725 0 ▶sub my_isxdigit { $_[0]->[LEXER_CTYPE]->[$_[1] + 1] & CTYPE_X }
Subroutine my_isxdigit: not called CC=1 SCAR=6.9
Pod undocumented
726  
727 1260 ▶sub my_isdigit { $_[0]->[LEXER_CTYPE]->[$_[1] + 1] & CTYPE_NMR }
Subroutine my_isdigit: called CC=1 SCAR=0.0
Pod undocumented
728  
729 1164 ▶sub my_isspace { $_[0]->[LEXER_CTYPE]->[$_[1] + 1] & CTYPE_SPC }
Subroutine my_isspace: called CC=1 SCAR=0.0
Pod undocumented
730  
731 0 ▶sub my_iscntrl { $_[0]->[LEXER_CTYPE]->[$_[1] + 1] & CTYPE_CTR }
Subroutine my_iscntrl: not called CC=1 SCAR=6.9
Pod undocumented
732  
733 sub get_text {
734 19 ▶ my $lexer = shift;
Subroutine get_text: called CC=22 SCAR=53.6
Pod undocumented
735 19 my $string = $lexer->[LEXER_STRING];
736 19 my $sep = $lexer->yyGetLast();
737 19 my $found_escape = 0;
738 19 ▶ while ($lexer->[LEXER_PTR] != length($lexer->[LEXER_STRING]) - 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexer->[7] != length($lexer->[0]) - 1) 90 0 90
739 90 my $c = $lexer->yyGet();
740 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
741 ($c == ord("\\")) &&
742 (!($lexer->[LEXER_SQL_MODE] & MODE_NO_BACKSLASH_ESCAPES))
743 ) {
744 0 $found_escape = 1;
745 0 ▶ return undef if $lexer->[LEXER_PTR] == length($lexer->[LEXER_STRING]);
Branch: 1 branch
BranchTrueFalseTotal
if $lexer->[7] == length $lexer->[0] 0 0 0
746 0 $lexer->yySkip();
747 } elsif ($c == $sep) {
748 19 ▶ if ($c == $lexer->yyGet()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == $lexer->yyGet) { } 0 19 19
749 0 $found_escape = 1;
750 0 next;
751 } else {
752 19 $lexer->yyUnget();
753 }
754
755 19 my ($str, $end, $start);
756  
757 19 $str = $lexer->[LEXER_TOK_START] + 1;
758 19 $end = $lexer->[LEXER_PTR] - 1;
759  
760 19 my $to;
761  
762 19 ▶ if (!$found_escape) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $found_escape) { } 19 0 19
763 19 my $yytoklen = $end - $str; # CHANGED
764 19 ▶ if ($yytoklen > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($yytoklen > 0) { } 19 0 19
765 19 return substr($lexer->[LEXER_STRING], $str, $yytoklen);
766 } else {
767 0 return '';
768 }
769 } else {
770 0 my $new_str = ''; # ADDED
771 0 ▶ for ($to = $start; $str != $end; $str++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str != $end) 0 0 0
772 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
773 (!($lexer->[LEXER_SQL_MODE] & MODE_NO_BACKSLASH_ESCAPES)) &&
774 (substr($string, $str, 1) eq "\\") &&
775 ($str + 1 != $end)
776 ) {
777 0 my $prev_str = substr($string, ++$str, 1);
778 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
779 0 substr($new_str, $to++, 1) = "\n";
780 0 next;
781 } elsif ($prev_str eq 't') {
782 0 substr($new_str, $to++, 1) = "\t";
783 0 next;
784 } elsif ($prev_str eq 'r') {
785 0 substr($new_str, $to++, 1) = "\r";
786 0 next;
787 } elsif ($prev_str eq 'b') {
788 0 substr($new_str, $to++, 1) = "\b";
789 0 next;
790 } elsif ($prev_str eq '0') {
791 0 substr($new_str, $to++, 1) = "\0";
792 0 next;
793 } elsif ($prev_str eq 'Z') {
794 0 substr($new_str, $to++, 1) = "\032";
795 0 next;
796 ▶ } 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
797 ($prev_str eq '_') ||
798 ($prev_str eq '%')
799 ) {
800 0 substr($new_str, $to++, 1) = "\\";
801 0 substr($new_str, $to++, 1) = $prev_str; # Added
802 } else {
803 0 substr($new_str, $to++, 1) = $prev_str;
804 }
805 } elsif (substr($string, $str, 1) eq $sep) {
806 0 substr($new_str, $to++, 1) = substr($string, $str++, 1);
807 } else {
808 0 substr($new_str, $to++, 1) = substr($string, $str, 1);
809 }
810 }
811 0 return $new_str;
812 }
813 0 return substr($string, $start, ($to - $start));
814 }
815 }
816 0 return undef;
817 }
818  
819 sub get_token {
820 292 ▶ my ($lexer, $length) = @_;
Subroutine get_token: called CC=1 SCAR=0.0
Pod undocumented
821 292 $lexer->yyUnget();
822 292 return substr($lexer->[LEXER_STRING], $lexer->[LEXER_TOK_START], $length);
823 }
824  
825 6 ▶use constant LONG_STR => "2147483647";
Subroutine BEGIN: called CC=1 SCAR=0.0
826 6 ▶use constant LONG_LEN => 10;
Subroutine BEGIN: called CC=1 SCAR=0.0
827 6 ▶use constant SIGNED_LONG_STR => "-2147483648";
Subroutine BEGIN: called CC=1 SCAR=0.0
828 6 ▶use constant LONGLONG_STR => "9223372036854775807";
Subroutine BEGIN: called CC=1 SCAR=0.0
829 6 ▶use constant LONGLONG_LEN => 19;
Subroutine BEGIN: called CC=1 SCAR=0.0
830 6 ▶use constant SIGNED_LONGLONG_STR => "-9223372036854775808";
Subroutine BEGIN: called CC=1 SCAR=0.0
831 6 ▶use constant SIGNED_LONGLONG_LEN => 19;
Subroutine BEGIN: called CC=1 SCAR=0.0
832 6 ▶use constant UNSIGNED_LONGLONG_STR => "18446744073709551615";
Subroutine BEGIN: called CC=1 SCAR=0.0
833 6 ▶use constant UNSIGNED_LONGLONG_LEN => 20;
Subroutine BEGIN: called CC=1 SCAR=0.0
834  
835 sub int_token {
836 27 ▶ my ($lexer, $token) = @_;
Subroutine int_token: called CC=16 SCAR=54.4
Pod undocumented
837
838 27 ▶ if (length($token) < LONG_LEN) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $token < 10) 27 0 27
839 27 return ("NUM", $token);
840 }
841  
842 0 my $neg = 0;
843  
844 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
845 0 $token = substr($token, 1);
846 } elsif (substr($token, 0, 1) eq '-') {
847 0 $token = substr($token, 1);
848 0 $neg = 1;
849 }
850  
851 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
852 (substr($token, 0, 1) eq '0') &&
853 (length($token) > 0)
854 ) {
855 0 $token = substr($token, 1);
856 }
857  
858 0 ▶ if (length($token) < LONG_LEN) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $token < 10) 0 0 0
859 0 return ("NUM", $token);
860 }
861  
862 0 my ($smaller, $bigger);
863 0 my $cmp;
864  
865 0 ▶ if ($neg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($neg) { } 0 0 0
866 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
867 0 $cmp = SIGNED_LONG_STR + 1;
868 0 $smaller = 'NUM';
869 0 $bigger = 'LONG_NUM';
870 } elsif (length($token) < SIGNED_LONGLONG_LEN) {
871 0 return ('LONG_NUM', $token);
872 } elsif (length($token) > SIGNED_LONGLONG_LEN) {
873 0 return ('DECIMAL_SYM', $token);
874 } else {
875 0 $cmp = SIGNED_LONGLONG_STR + 1;
876 0 $smaller = 'LONG_NUM';
877 0 $bigger = 'DECIMAL_NUM';
878 }
879 } else {
880 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
881 0 $cmp = LONG_STR;
882 0 $smaller = 'NUM';
883 0 $bigger = 'LONG_NUM';
884 } elsif (length($token) < LONGLONG_LEN) {
885 0 return('LONG_NUM', $token);
886 } elsif (length($token) > LONGLONG_LEN) {
887 0 ▶ if (length($token) > UNSIGNED_LONGLONG_LEN) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $token > 20) 0 0 0
888 0 return ('DECIMAL_NUM', $token);
889 }
890 0 $cmp = UNSIGNED_LONGLONG_STR;
891 0 $smaller = 'ULONGLONG_NUM';
892 0 $bigger = 'DECIMAL_NUM';
893 } else {
894 0 $cmp = LONGLONG_STR;
895 0 $smaller = 'LONG_NUM';
896 0 $bigger = 'ULONGLONG_NUM';
897 }
898 }
899
900 0 ▶ return $token > $cmp ? ($bigger, $token) : ($smaller, $token);
Branch: 1 branch
BranchTrueFalseTotal
$token > $cmp ? : 0 0 0
901 }
902  
903 sub find_keyword {
904 245 ▶ my ($lexer, $length, $function) = @_;
Subroutine find_keyword: called CC=8 SCAR=20.9
Pod undocumented
905 245 my $keyword = substr($lexer->[LEXER_STRING], $lexer->[LEXER_TOK_START], $length);
906  
907 245 my $symbol;
908 245 ▶ if ($function) {
Branch: 1 branch
BranchTrueFalseTotal
if ($function) { } 8 237 245
909 8 $symbol = $DBIx::MyParsePP::Symbols::functions->{uc($keyword)};
910 8 ▶ $symbol = $DBIx::MyParsePP::Symbols::symbols->{uc($keyword)} if not defined $symbol;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $symbol 1 7 8
911 } else {
912 237 $symbol = $DBIx::MyParsePP::Symbols::symbols->{uc($keyword)};
913 }
914  
915 245 ▶ return () if not defined $symbol;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $symbol 57 188 245
916
917 188 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($symbol eq "NOT_SYM" and $lexer->[3] & 536870912) 0 188 188
Condition66%2/3
$symbol eq "NOT_SYM" and $lexer->[3] & 536870912
!ll&&!rl&&r
18710
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
918 ($symbol eq 'NOT_SYM') &&
919 ($lexer->[LEXER_SQL_MODE] & MODE_HIGH_NOT_PRECEDENCE)
920 ) {
921 0 $symbol = 'NOT2_SYM';
922 }
923  
924 188 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($symbol eq "OR_OR_SYM" and $lexer->[3] & 2) 1 187 188
Condition100%3/3
$symbol eq "OR_OR_SYM" and $lexer->[3] & 2
!ll&&!rl&&r
18611
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
925 ($symbol eq 'OR_OR_SYM') &&
926 ($lexer->[LEXER_SQL_MODE] & MODE_PIPES_AS_CONCAT)
927 ) {
928 1 $symbol = 'OR2_SYM';
929 }
930  
931 188 return ($symbol, $keyword);
932 }
933  
934 6 1;
935  
936  
937 __END__
↑ Summary MyParsePP/Parser.pm »