blib/lib/DDC/PP/yyqlexer.pm

filter: Statementstmt 62.3% 205 / 329 Branchbran 64.3% 188 / 292 Conditioncond 56.1% 23 / 41 MC/DCmcdc 37.5% 9 / 24 Subroutinesub 78.5% 22 / 28 Podpod 0.0% 0 / 20 totaltotal 60.9% 447 / 734 CC 163 SCAR 60.1
CC
163
Cov
63%
yylex
614.8
dummylex
56.0
fromFile
20.0
CRAP 409.0
« blib/lib/DDC/Client.pm ↑ Summary blib/lib/DDC/Format/Text.pm »
1 ##-*- Mode: CPerl -*-
2  
3 ## File: DDC::::yyqlexer.pm
4 ## Author: Bryan Jurish <moocow@cpan.org>
5 ## Description:
6 ## + lexer for ddc queries (formerly DDC::Query::yylexer)
7 ## + last updated for ddc v2.1.15
8 ##======================================================================
9  
10 package DDC::PP::yyqlexer;
11 20 ▶use 5.010; ##-- we need at least v5.10.0 for /p regex modifier
Subroutine BEGIN: called CC=1 SCAR=0.0
12 20 ▶use Encode qw(encode_utf8 decode_utf8);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 20 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 20 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 20 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 ##======================================================================
19 ## Globals etc.
20 20 our @ISA = qw();
21  
22 ##----------------------------------------------------------------------
23 ## Globals: regexes for Parse::Lex lexer token regexes
24  
25 ## %DEF
26 ## + common shared regex definitions
27 20 our (%DEF);
28 20 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
29 ##-- adapted from ddc-2.1.1/src/ConcordLib/yyQLexer.l ; extra escapes needed for backslashes ('\\' -> '\\\\')
30  
31 ##-- whitespace
32 20 $DEF{ws} = '[ \t\n\r\f\x0b]';
33  
34 ##-- integer boundary characters
35 20 $DEF{int_boundary} = '[ \t\n\r\f\x0b\0&|!?^%,:;#*=~(){}<>\[\]\/\\\\\'\".$@_+-]';
36  
37 ##-- bareword symbols
38 20 $DEF{symbol_cfirst} = '[^ \t\n\r\f\x0b\0&|!?^%,:;#*=~(){}<>\[\]\\\\\/\'\".$@]';
39 20 $DEF{symbol_crest} = '[^ \t\n\r\f\x0b\0&|!?^%,:;#*=~(){}<>\[\]\\\\\/\'\"]';
40 20 $DEF{symbol_cescape} = '(?:\\\\.)';
41 20 $DEF{symbol_text} = "(?:$DEF{symbol_cescape}|$DEF{symbol_cfirst})(?:$DEF{symbol_cescape}|$DEF{symbol_crest})*";
42  
43 ##-- subcorpus symbols (ddc >= v2.2.0; also allow '!' here)
44 20 $DEF{corpus_cfirst} = '[^ \t\n\r\f\v\0&|?^%,:;#=~(){}<>\[\]\\\'\"$@]';
45 20 $DEF{corpus_crest} = '[^ \t\n\r\f\v\0&|?^%,:;#=~(){}<>\[\]\\\'\"]';
46 20 $DEF{corpus_text} = "(?:$DEF{symbol_cescape}|$DEF{corpus_cfirst})(?:$DEF{symbol_cescape}|$DEF{corpus_crest})*";
47  
48 ##-- bareword index names (underscore and digits ok, but no '.', '-', or '+')
49 20 $DEF{index_char} = '[^ \t\n\r\f\x0b\0&|!?^%,:;#*=~(){}<>\[\]\\\\/\'\".$@+-]';
50 20 $DEF{index_name} = "(?:$DEF{index_char}|$DEF{symbol_cescape})+";
51  
52 ##-- single-quoted symbols
53 20 $DEF{sq_text} = "(?:[^\']|$DEF{symbol_cescape})*";
54  
55 ##-- bareword dates (>= 4 digits of year, otherwise breaks {count(...) #by[$w=1-1]})
56 20 $DEF{date_bare} = "[+-]?[0-9]{4,}(-[0-9]{1,2}){1,2}";
57  
58 ##-- regexes
59 20 $DEF{regex_text} = "(?:(?:\\\\.)|[^\\\\/])*";
60 20 $DEF{regex_modifier} = '[dgimsx]';
61  
62 ##-- comments
63 20 $DEF{comment_text} = "(?:\\\\.|[^\\]])*";
64  
65 ##-- compile patterns
66 20 foreach (keys %DEF) {
67 #print STDERR __PACKAGE__, ": compiling regex macro: $_ ~ /$DEF{$_}/\n";
68 320 $DEF{$_} = qr/$DEF{$_}/;
69 }
70 }
71  
72 ##======================================================================
73 ## $lex = $CLASS_OR_OBJ->new(%args)
74 ## + abstract constructor
75 ## + %$lex, %args:
76 ## {
77 ## src => $name, ##-- source name
78 ## fh => $srcfh, ##-- source filehandle
79 ## bufr => \$buf, ##-- source buffer (string reference)
80 ## bufp => $pos, ##-- current pos() in source buffer
81 ## buf => $buf, ##-- local buffer (for filehandle input)
82 ## state => $q, ##-- symbolic state name (default: 'INITIAL')
83 ## stack => \@stack, ##-- state stack
84 ##
85 ## ##-- utf-8 or byte mode?
86 ## utf8 => $bool, ##-- whether to use utf8 or byte-mode (default: true (non-compatible but handy))
87 ##
88 ## ##-- runtime data
89 ## yytext => $text, ##-- current text
90 ## yytype => $type, ##-- current token type
91 ## yylineno => $line, ##-- current source line (file input only)
92 ## }
93 15 ▶sub new {
Subroutine new: called CC=2 SCAR=7.6
Pod undocumented
94 15 my $that = shift;
95 15 ▶ my $lex = bless({
Condition33%1/3
ref $that || $that
l!l&&r!l&&!r
0150
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table33%1/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
96 src =>undef,
97 fh =>undef,
98 bufr =>undef,
99 bufp =>undef,
100 buf =>undef,
101 utf8 =>1,
102 state => 'INITIAL',
103 stack => [],
104  
105 yytext=>undef,
106 yytype=>undef,
107 yylineno=>undef,
108  
109 ##-- lexer comment retention hacks
110 comments=>[],
111  
112 ##-- user args
113 @_
114 },
115 ref($that)||$that
116 );
117 15 return $lex;
118 }
119  
120 ## $lex = $lex->clear()
121 ## + clear lexer buffer, source, etc
122 422 ▶sub clear {
Subroutine clear: called CC=1 SCAR=0.0
Pod undocumented
123 422 my $lex = shift;
124 422 delete @$lex{qw(src fh bufr bufp buf yytext yytype yylineno)};
125 422 $lex->{state} = 'INITIAL';
126 422 @{$lex->{stack}} = qw();
127 422 @{$lex->{comments}} = qw();
128 422 $lex->{yyDtrsPos} = 0;
129 422 $lex->{yyDtrsLen} = 0;
130 422 delete $lex->{_cmtbuf};
131 422 return $lex;
132 }
133 20 ▶BEGIN { *reset = *close = \&clear; }
Subroutine BEGIN: called CC=1 SCAR=0.0
134  
135 ##======================================================================
136 ## I/O
137  
138 ## $lex = $lex->from($which,$src, %opts)
139 ## + $which is one of qw(fh file string)
140 ## + $src is the actual source (default: 'string')
141 211 ▶sub from {
Subroutine from: called CC=3 SCAR=11.4
Pod undocumented
142 211 my ($lex,$which,$src,%opts) = @_;
143 211 ▶ return $lex->fromFh($src,%opts) if ($which eq 'fh');
Branch: 1 branch
BranchTrueFalseTotal
if $which eq "fh" 0 211 211
144 211 ▶ return $lex->fromFile($src,%opts) if ($which eq 'file');
Branch: 1 branch
BranchTrueFalseTotal
if $which eq "file" 0 211 211
145 211 return $lex->fromString($src,%opts);
146 }
147  
148 ## $lex = $lex->fromFile($filename_or_handle,%opts)
149 0 ▶sub fromFile {
Subroutine fromFile: not called CC=4 SCAR=30.0
Pod undocumented
150 0 my ($lex,$file,%opts) = @_;
151 0 ▶ return $lex->fromFh($file,%opts) if (ref($file));
Branch: 1 branch
BranchTrueFalseTotal
if ref $file 0 0 0
152 0 ▶ my $fh = IO::File->new("<$file")
Branch: 1 branch
BranchTrueFalseTotal
my $fh = "IO::File"->new("<$file") or confess("cannot open '${file}' for read: $!") 0 0 0
153 or confess("cannot open '$file' for read: $!");
154 0 ▶ binmode($fh,':encoding(utf8)') if ($lex->{utf8});
Branch: 1 branch
BranchTrueFalseTotal
if $lex->{"utf8"} 0 0 0
155 0 return $lex->fromFh($fh,src=>"file \`$file'",%opts);
156 }
157  
158 20 our $FH_SLURP=0; ##-- DEBUG: slurp whole files instead of line-wise input
159  
160 ## $lex = $lex->fromFh($fh,%opts)
161 ## + uses native $fh encoding
162 0 ▶sub fromFh {
Subroutine fromFh: not called CC=3 SCAR=24.8
Pod undocumented
163 0 my ($lex,$fh,%opts) = @_;
164 0 ▶ if ($FH_SLURP) {
Branch: 1 branch
BranchTrueFalseTotal
if ($DDC::PP::yyqlexer::FH_SLURP) 0 0 0
165 ##-- always use string mode
166 0 local $/=undef;
167 0 my $buf = $fh->getline;
168 0 $fh->close();
169 0 return $lex->fromString(\$buf,src=>"filehandle \`$fh'",%opts);
170 }
171 ##-- line-wise buffering
172 0 $lex->clear();
173 0 @$lex{keys %opts} = values(%opts);
174 0 $lex->{fh} = $fh;
175 0 $lex->{buf} = undef;
176 0 $lex->{bufr} = \$lex->{buf};
177 0 $lex->{bufp} = 0;
178 0 ▶ $lex->{src} = "filehandle \`$fh'" if (!defined($lex->{src}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lex->{"src"} 0 0 0
179 0 return $lex;
180 }
181  
182 ## $lex = $lex->fromString($str,%opts)
183 ## $lex = $lex->fromString(\$str,%opts)
184 211 ▶sub fromString {
Subroutine fromString: called CC=9 SCAR=29.5
Pod undocumented
185 211 my ($lex,$str,%opts) = @_;
186 211 $lex->clear();
187 211 ▶ if (ref($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $str) { } 211 0 211
188 211 $lex->{bufr} = $str;
189 211 ▶ $lex->{src} = "buffer \`$str'" if (!defined($lex->{src}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lex->{"src"} 211 0 211
190 } else {
191 0 $lex->{bufr} = \$str;
192 0 ▶ $lex->{src} = "string \`$str'" if (!defined($lex->{src}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lex->{"src"} 0 0 0
193 }
194 211 $lex->{bufp} = 0;
195 211 $lex->{yylineno} = 0;
196  
197 ##-- utf8 checks
198 211 ▶ if ($lex->{utf8} && !utf8::is_utf8(${$lex->{bufr}})) {
Branch: 2 branches
BranchTrueFalseTotal
if ($lex->{'utf8'} and not utf8::is_utf8(${$$lex{'bufr'};})) { } 211 0 211
elsif (not $lex->{'utf8'} and utf8::is_utf8(${$$lex{'bufr'};})) { } 0 0 0
Condition33%1/3
$lex->{"utf8"} and not utf8::is_utf8(${$$lex{"bufr"};})
!ll&&!rl&&r
00211
MC/DC0%0/2
$lex->{"utf8"} and not utf8::is_utf8(${$$lex{"bufr"};})
$lex->{"utf8"} not utf8::is_utf8(${$$lex{"bufr"};})
Truth table33%1/3
A and not(B)
A= $lex->{"utf8"}B= not utf8::is_utf8(${$$lex{"bufr"};})
ABresult
0X0
100
111
199 ##-- lexer:utf8, string:bytes --> assume string is utf8-encoded
200 211 ▶ ${$lex->{bufr}} = decode_utf8(${$lex->{bufr}}) if (!utf8::is_utf8(${$lex->{bufr}}));
Branch: 1 branch
BranchTrueFalseTotal
unless utf8::is_utf8(${$$lex{"bufr"};}) 211 0 211
201 }
202 0 ▶ elsif (!$lex->{utf8} && utf8::is_utf8(${$lex->{bufr}})) {
Condition0%0/3
not $lex->{"utf8"} and utf8::is_utf8(${$$lex{"bufr"};})
!ll&&!rl&&r
000
MC/DC0%0/2
not $lex->{"utf8"} and utf8::is_utf8(${$$lex{"bufr"};})
not $lex->{"utf8"} utf8::is_utf8(${$$lex{"bufr"};})
Truth table0%0/3
not(A) and B
A= not $lex->{"utf8"}B= utf8::is_utf8(${$$lex{"bufr"};})
ABresult
0X0
100
111
203 ##-- lexer:bytes, string:utf8 --> encode as utf8 octets
204 0 ${$lex->{bufr}} = encode_utf8(${$lex->{bufr}});
205 }
206  
207 211 return $lex;
208 }
209  
210 ##======================================================================
211 ## Utilities
212  
213 ## $bool = $lex->eof()
214 ## + true iff at end-of-file
215 1151 ▶sub eof {
Subroutine eof: called CC=2 SCAR=7.6
Pod undocumented
216 1151 ▶ return $FH_SLURP ? $_[0]->eob() : !$_[0]->getmore();
Branch: 1 branch
BranchTrueFalseTotal
$DDC::PP::yyqlexer::FH_SLURP ? : 0 1151 1151
217 }
218  
219 ## $bool = $lex->eob()
220 ## + true at end-of-buffer
221 1151 ▶sub eob {
Subroutine eob: called CC=4 SCAR=14.6
Pod undocumented
222 1151 ▶ return (!$_[0]{bufr} || !${$_[0]{bufr}} || ($_[0]{bufp}||0) >= length(${$_[0]{bufr}}));
Condition62%5/8
!($_[0]{'bufr'} && ${$_[0]{'bufr'};}) || ($_[0]{'bufp'} || 0) >= length ${$_[0]{'bufr'};}
l!l&&r!l&&!r
0209942
$_[0]{'bufr'} && ${$_[0]{'bufr'};}
!ll&&!rl&&r
001151
$_[0]{'bufp'} || 0
l!l
940211
MC/DC33%1/3
!($_[0]{'bufr'} && ${$_[0]{'bufr'};}) || ($_[0]{'bufp'} || 0) >= length ${$_[0]{'bufr'};}
$_[0]{'bufr'} ${$_[0]{'bufr'};} $_[0]{'bufp'}
Truth table50%2/4
not(A && B) || C
A= $_[0]{'bufr'}B= ${$_[0]{'bufr'};}C= $_[0]{'bufp'}
ABCresult
0XX1
10X1
1111
1100
223 }
224  
225 ## $bufr_or_undef = $lex->getmore()
226 ## + returns true iff there is still data in the buffer
227 1151 ▶sub getmore {
Subroutine getmore: called CC=4 SCAR=19.4
Pod undocumented
228 1151 ▶ return $_[0]{bufr} if (!$_[0]->eob());
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->eob 942 209 1151
229 209 ▶ if (defined($_[0]{fh})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]{"fh"}) 0 209 209
230 0 $_[0]{bufp} = 0;
231 0 $_[0]{buf} = $_[0]{fh}->getline;
232 0 $_[0]{bufr} = \$_[0]{buf};
233 0 $_[0]{yylineno} = $_[0]{fh}->input_line_number;
234 0 ▶ return defined($_[0]{buf}) ? $_[0]{bufr} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0]{'buf'} ? : 0 0 0
235 }
236 209 return undef;
237 }
238  
239 ##======================================================================
240 ## Runtime lexer accessors
241  
242 ## $yytext = $lex->yytext
243 ## + always defined; otherwise using $lex->{yytext} is faster
244 2 ▶sub yytext { return defined($_[0]{yytext}) ? $_[0]{yytext} : ''; }
Subroutine yytext: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0]{'yytext'} ? : 2 0 2
245  
246 ## $yytype = $lex->yytype
247 ## + always defined; otherwise using $lex->{yytype} is faster
248 2 ▶sub yytype { return defined($_[0]{yytype}) ? $_[0]{yytype} : '__EOF__'; }
Subroutine yytype: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0]{'yytype'} ? : 2 0 2
249  
250 ## $line = $lex->yylineno()
251 ## + returns current line number
252 2 ▶sub yylineno {
Subroutine yylineno: called CC=1 SCAR=0.0
Pod undocumented
253 2 return $_[0]{yylineno};
254 }
255  
256 ## $pos = $lex->yycolumn()
257 ## + return column at which current token starts (if any)
258 0 ▶sub yycolumn {
Subroutine yycolumn: not called CC=3 SCAR=24.8
Pod undocumented
259 0 ▶ return ($_[0]{bufp}||0) - (defined($_[0]{yytext}) ? length($_[0]{yytext}) : 0);
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0]{'yytext'} ? : 0 0 0
Condition0%0/2
$_[0]{'bufp'} || 0
l!l
00
MC/DC0%0/1
$_[0]{'bufp'} || 0
$_[0]{'bufp'}
Truth table0%0/2
A
A= $_[0]{'bufp'}
Aresult
11
00
260 }
261  
262 ## $pos = $lex->yypos()
263 ## + return byte position in current line (or input string)
264 102 ▶sub yypos {
Subroutine yypos: called CC=2 SCAR=7.6
Pod undocumented
265 102 ▶ return ($_[0]{bufp}||0);
Condition50%1/2
$_[0]{'bufp'} || 0
l!l
1020
MC/DC0%0/1
$_[0]{'bufp'} || 0
$_[0]{'bufp'}
Truth table50%1/2
A
A= $_[0]{'bufp'}
Aresult
11
00
266 }
267  
268 ## $string = $lex->yyerror(@msg)
269 ## + create a helpful error message
270 0 ▶sub yyerror {
Subroutine yyerror: not called CC=1 SCAR=6.9
Pod undocumented
271 0 my $lex = shift;
272 0 confess(ref($lex).": error in ".$lex->yywhere().join('',@_));
273 }
274  
275 ## $string = $lex->yywhere()
276 ## + location string used by yyerror()
277 0 ▶sub yywhere {
Subroutine yywhere: not called CC=3 SCAR=24.8
Pod undocumented
278 0 my $lex = shift;
279 return ("$lex->{src} at "
280 .(defined($lex->{fh}) ? ("line $lex->{yylineno}, ") : '')
281 ."column ".$lex->yycolumn
282 0 ▶ .", near ".(defined($lex->{yytext}) ? "\`$lex->{yytext}\'" : '__EOF__')
Branch: 2 branches
BranchTrueFalseTotal
defined $lex->{'fh'} ? : 0 0 0
defined $lex->{'yytext'} ? : 0 0 0
283 );
284 }
285  
286 ## $q = $lex->yypushq($new_state)
287 19 ▶sub yypushq {
Subroutine yypushq: called CC=1 SCAR=0.0
Pod undocumented
288 19 my ($lex,$qnew) = @_;
289 19 push(@{$lex->{stack}},$lex->{state});
290 19 return $lex->{state} = $qnew;
291 }
292  
293 ## $q = $lex->yypopq()
294 29 ▶sub yypopq {
Subroutine yypopq: called CC=2 SCAR=6.9
Pod undocumented
295 29 my $lex = shift;
296 29 ▶ return $lex->{state} = pop(@{$lex->{stack}}) || 'INITIAL';
Condition100%2/2
pop @{$$lex{'stack'};} || 'INITIAL'
l!l
1910
MC/DC100%1/1
pop @{$$lex{'stack'};} || 'INITIAL'
pop @{$$lex{'stack'};}
Truth table100%2/2
A
A= pop @{$$lex{'stack'};}
Aresult
11
00
297 }
298  
299 ##======================================================================
300 ## Runtime lexer routines
301  
302 ## ($typ,$text) = $lex->yylex()
303 ## + get next token from input stream
304 1125 ▶sub yylex {
Subroutine yylex: called CC=125 SCAR=64.2
Pod undocumented
305 1125 my $lex = shift;
306 1125 my ($bufr,$type,$text,$match,@part);
307 #use re 'eval'; ##-- dangerous!
308 LEXBUF:
309 1125 ▶ while (!$lex->eof()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($lex->eof) 942 209 1151
310 942 $bufr = $lex->{bufr};
311 942 pos($$bufr) = $lex->{bufp};
312  
313 LEXSKIP:
314 ##------------------------------------
315 ## LEXSKIP: main lexer loop
316 942 while (1) {
317 1345 $type = $text = $match = undef;
318 1345 @part = qw();
319  
320 ##------------------------
321 1345 ▶ if ($lex->{state} eq 'INITIAL' || $lex->{state} eq 'Q_MATCHID') {
Branch: 7 branches
BranchTrueFalseTotal
if ($lex->{'state'} eq 'INITIAL' or $lex->{'state'} eq 'Q_MATCHID') { } 1213 132 1345
elsif ($lex->{'state'} eq 'Q_CORPORA') { } 86 46 132
elsif ($lex->{'state'} eq 'Q_COMMENT') { } 38 8 46
elsif ($lex->{'state'} eq 'Q_DATE') { } 2 6 8
elsif ($lex->{'state'} eq 'Q_REGREP') { } 2 4 6
elsif ($lex->{'state'} eq 'Q_REGOPT') { } 0 4 4
elsif ($lex->{'state'} eq 'Q_XPIPE') { } 4 0 4
Condition100%3/3
$lex->{"state"} eq "INITIAL" or $lex->{"state"} eq "Q_MATCHID"
l!l&&r!l&&!r
117340132
MC/DC100%2/2
$lex->{"state"} eq "INITIAL" or $lex->{"state"} eq "Q_MATCHID"
$lex->{"state"} eq "INITIAL" $lex->{"state"} eq "Q_MATCHID"
Truth table100%3/3
A or B
A= $lex->{"state"} eq "INITIAL"B= $lex->{"state"} eq "Q_MATCHID"
ABresult
1X1
011
000
322  
323 ##-- end-of-file (should be first pattern)
324 1213 ▶ if ($$bufr =~ m/\G\z/) { $type = '__EOF__'; }
Branch: 84 branches
BranchTrueFalseTotal
if ($$bufr =~ /\G\z/) { } 26 1187 1213
elsif ($$bufr =~ /\G\#:[^\n]*/ps) { } 22 1165 1187
elsif ($$bufr =~ /\G\#\[/p) { } 19 1146 1165
elsif ($$bufr =~ /\G\&\&/p) { } 21 1125 1146
elsif ($$bufr =~ /\G\|\|/p) { } 2 1123 1125
elsif ($$bufr =~ /\Gnear/ip) { } 0 1123 1123
elsif ($$bufr =~ /\G(?:\!=|\&\!=|\&=\s*\!|\!with|with(?:out|\s*\!))/ip) { } 2 1121 1123
elsif ($$bufr =~ /\G(?:\|=|withor|orwith|wor)/ip) { } 2 1119 1121
elsif ($$bufr =~ /\G(?:\&=|with)/ip) { } 2 1117 1119
elsif ($$bufr =~ /\Gcount/ip) { } 28 1089 1117
elsif ($$bufr =~ /\Gkeys/ip) { } 0 1089 1089
elsif ($$bufr =~ /\G(?:file|doc)_?id/ip) { } 0 1089 1089
elsif ($$bufr =~ /\G(?:file|doc)_?(?:name)?/ip) { } 2 1087 1089
elsif ($$bufr =~ /\Gdate/ip) { } 2 1085 1087
elsif ($$bufr =~ /\G\#(?:comment|cmt)/ip) { } 17 1068 1085
elsif ($$bufr =~ /\G\#(?:(?:co?n?te?xt?|n))/ip) { } 2 1066 1068
elsif ($$bufr =~ /\G\#(?:with)?in/ip) { } 2 1064 1066
elsif ($$bufr =~ /\G\#(?:sep(?:arate)?|nojoin)(?:_hits)?/ip) { } 3 1061 1064
elsif ($$bufr =~ /\G\#(?:nosep(?:arate)?|join)(?:_hits)?/ip) { } 0 1061 1061
elsif ($$bufr =~ /\G\#(?:is_|has_)?date/ip) { } 4 1057 1061
elsif ($$bufr =~ /\G\#has(?:_field)?/ip) { } 2 1055 1057
elsif ($$bufr =~ /\G\#file(?:_?)names/ip) { } 0 1055 1055
elsif ($$bufr =~ /\G\#debug_rank/ip) { } 0 1055 1055
elsif ($$bufr =~ /\G\#(?:greater|de?sc)(?:_by)?_rank/ip) { } 0 1055 1055
elsif ($$bufr =~ /\G\#(?:less|asc)(?:_by)?_rank/ip) { } 0 1055 1055
elsif ($$bufr =~ /\G\#(?:greater|de?sc)(?:_by)?_date/ip) { } 0 1055 1055
elsif ($$bufr =~ /\G\#(?:less|asc)(?:_by)?_date/ip) { } 10 1045 1055
elsif ($$bufr =~ /\G\#(?:greater|de?sc)(?:_by)?_size/ip) { } 0 1045 1045
elsif ($$bufr =~ /\G\#(?:less|asc)(?:_by)?_size/ip) { } 0 1045 1045
elsif ($$bufr =~ /\G\#(?:is_|has_)?size/ip) { } 0 1045 1045
elsif ($$bufr =~ /\G\#(?:(?:less|asc)_(?:by_)?)?left/ip) { } 0 1045 1045
elsif ($$bufr =~ /\G\#(?:(?:greater|de?sc)_(?:by_)?)left/ip) { } 0 1045 1045
elsif ($$bufr =~ /\G\#(?:(?:less|asc)_(?:by_)?)?right/ip) { } 0 1045 1045
elsif ($$bufr =~ /\G\#(?:(?:greater|de?sc)_(?:by_)?)right/ip) { } 0 1045 1045
elsif ($$bufr =~ /\G\#(?:(?:less|asc)_(?:by_)?)?mid(?:dle)?/ip) { } 0 1045 1045
elsif ($$bufr =~ /\G\#(?:(?:greater|de?sc)_(?:by_)?)mid(?:dle)?/ip) { } 0 1045 1045
elsif ($$bufr =~ /\G\#(?:(?:less|asc)(?:_by)?_key)/ip) { } 2 1043 1045
elsif ($$bufr =~ /\G\#(?:(?:greater|de?sc)(?:_by)?_key)/ip) { } 0 1043 1043
elsif ($$bufr =~ /\G\#(?:(?:less|asc)(?:_by)?_(?:count|val(?:ue)?))/ip) { } 0 1043 1043
elsif ($$bufr =~ /\G\#(?:(?:greater|de?sc)(?:_by)?_(?:count|val(?:ue)?))/ip) { } 2 1041 1043
elsif ($$bufr =~ /\G\#(?:less|asc)(?:_by)?/ip) { } 0 1041 1041
elsif ($$bufr =~ /\G\#(?:greater|de?sc)(?:_by)?/ip) { } 0 1041 1041
elsif ($$bufr =~ /\G\#prune(?:_less|_asc)?(?:_by)?/ip) { } 4 1037 1041
elsif ($$bufr =~ /\G\#prune(?:_greater|_de?sc)(?:_by)?/ip) { } 0 1037 1037
elsif ($$bufr =~ /\G\#rand(?:om)?/ip) { } 0 1037 1037
elsif ($$bufr =~ /\G\#by/ip) { } 28 1009 1037
elsif ($$bufr =~ /\G\#samp(?:le)?/ip) { } 2 1007 1009
elsif ($$bufr =~ /\G\#clim(?:it)?/ip) { } 0 1007 1007
elsif ($$bufr =~ m[\G\!/($DDC::PP::yyqlexer::DEF{'regex_text'})/(?=$DDC::PP::yyqlexer::DEF{'regex_modifier'})]op) { } 0 1007 1007
elsif ($$bufr =~ m[\G\!/($DDC::PP::yyqlexer::DEF{'regex_text'})/]op) { } 0 1007 1007
elsif ($$bufr =~ m[\G/($DDC::PP::yyqlexer::DEF{'regex_text'})/(?=$DDC::PP::yyqlexer::DEF{'regex_modifier'})]op) { } 0 1007 1007
elsif ($$bufr =~ m[\G/($DDC::PP::yyqlexer::DEF{'regex_text'})/]op) { } 11 996 1007
elsif ($$bufr =~ m[\Gs/($DDC::PP::yyqlexer::DEF{'regex_text'})/]op) { } 2 994 996
elsif ($$bufr =~ /\G#=/p) { } 2 992 994
elsif ($$bufr =~ /\G#</p) { } 0 992 992
elsif ($$bufr =~ /\G#>/p) { } 0 992 992
elsif ($$bufr =~ /\G\$\./p) { } 0 992 992
elsif ($$bufr =~ /\G\:\{/p) { } 0 992 992
elsif ($$bufr =~ /\G\@\{/p) { } 4 988 992
elsif ($$bufr =~ /\G\*\{/p) { } 0 988 988
elsif ($$bufr =~ /\G\}\*/p) { } 0 988 988
elsif ($$bufr =~ m[\G[!.,;=\@%^#~/]]p) { } 78 910 988
elsif ($$bufr =~ /\G[\[\]{}()<>]/p) { } 172 738 910
elsif ($$bufr =~ /\G\"/p) { } 4 734 738
elsif ($$bufr =~ /\G\:/p) { } 34 700 734
elsif ($$bufr =~ /\G\*\'($DDC::PP::yyqlexer::DEF{'sq_text'})\'\*/op) { } 0 700 700
elsif ($$bufr =~ /\G\'($DDC::PP::yyqlexer::DEF{'sq_text'})\'\*/op) { } 2 698 700
elsif ($$bufr =~ /\G\*\'($DDC::PP::yyqlexer::DEF{'sq_text'})\'/op) { } 0 698 698
elsif ($$bufr =~ /\G\*($DDC::PP::yyqlexer::DEF{'symbol_text'})\*/op) { } 0 698 698
elsif ($$bufr =~ /\G($DDC::PP::yyqlexer::DEF{'symbol_text'})\*/op) { } 2 696 698
elsif ($$bufr =~ /\G\*($DDC::PP::yyqlexer::DEF{'symbol_text'})/op) { } 0 696 696
elsif ($$bufr =~ /\G\$($DDC::PP::yyqlexer::DEF{'index_name'})/op) { } 24 672 696
elsif ($$bufr =~ /\G\$'($DDC::PP::yyqlexer::DEF{'index_name'})'/op) { } 0 672 672
elsif ($$bufr =~ /m\G\$/p) { } 0 672 672
elsif ($$bufr =~ /\G\*/p) { } 0 672 672
elsif ($$bufr =~ /\G\|/p) { } 4 668 672
elsif ($$bufr =~ /\G\'($DDC::PP::yyqlexer::DEF{'sq_text'})\'/op) { } 43 625 668
elsif ($lex->{'state'} eq 'INITIAL' and $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{'symbol_text'}/op) { } 285 340 625
elsif ($lex->{'state'} ne 'INITIAL' and $$bufr =~ /\G[\+\-]?[0-9]+(?=$DDC::PP::yyqlexer::DEF{'int_boundary'})/op) { } 14 326 340
elsif ($lex->{'state'} ne 'INITIAL' and $$bufr =~ /\G[\+\-]?[0-9]+\z/p) { } 26 300 326
elsif ($lex->{'state'} ne 'INITIAL' and $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{'date_bare'}(?=$DDC::PP::yyqlexer::DEF{'int_boundary'})/op) { } 0 300 300
elsif ($lex->{'state'} ne 'INITIAL' and $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{'date_bare'}\z/op) { } 0 300 300
elsif ($$bufr =~ /\G\s+/p) { } 300 0 300
elsif ($$bufr =~ /\G./p) { } 0 0 0
325  
326 ##-- comments
327 22 elsif ($$bufr =~ m/\G\#:[^\n]*/sp) { $type='__SKIP__'; push(@{$lex->{comments}},${^MATCH}."\n"); }
328 19 elsif ($$bufr =~ m/\G\#\[/p) { $type='__SKIP__'; $lex->{_cmtbuf}=${^MATCH}; $lex->yypushq('Q_COMMENT'); }
329  
330 ##-- operators
331 21 elsif ($$bufr =~ m/\G\&\&/p) { $type = 'OP_BOOL_AND'; }
332 2 elsif ($$bufr =~ m/\G\|\|/p) { $type = 'OP_BOOL_OR'; }
333 0 elsif ($$bufr =~ m/\Gnear/pi) { $type = 'NEAR'; }
334 2 elsif ($$bufr =~ m/\G(?:\!=|\&\!=|\&=\s*\!|\!with|with(?:out|\s*\!))/pi) { $type = 'WITHOUT'; }
335 2 elsif ($$bufr =~ m/\G(?:\|=|withor|orwith|wor)/pi) { $type = 'WITHOR'; }
336 2 elsif ($$bufr =~ m/\G(?:\&=|with)/pi) { $type = 'WITH'; }
337 28 elsif ($$bufr =~ m/\Gcount/pi) { $type = 'COUNT'; }
338 0 elsif ($$bufr =~ m/\Gkeys/pi) { $type = 'KEYS'; }
339  
340 ##-- count-by keywords
341 0 elsif ($$bufr =~ m/\G(?:file|doc)_?id/pi) { $type = 'KW_FILEID'; }
342 2 elsif ($$bufr =~ m/\G(?:file|doc)_?(?:name)?/pi) { $type = 'KW_FILENAME'; }
343 2 elsif ($$bufr =~ m/\Gdate/pi) { $type = 'KW_DATE'; $lex->{state}='Q_DATE' }
344  
345 ##-- query operators
346 17 elsif ($$bufr =~ m/\G\#(?:comment|cmt)/pi) { $type = 'KW_COMMENT'; }
347 2 elsif ($$bufr =~ m/\G\#(?:(?:co?n?te?xt?|n))/pi) { $type = 'CNTXT'; }
348 2 elsif ($$bufr =~ m/\G\#(?:with)?in/pi) { $type = 'WITHIN'; }
349 3 elsif ($$bufr =~ m/\G\#(?:sep(?:arate)?|nojoin)(?:_hits)?/pi) { $type = 'SEPARATE_HITS'; }
350 0 elsif ($$bufr =~ m/\G\#(?:nosep(?:arate)?|join)(?:_hits)?/pi) { $type = 'NOSEPARATE_HITS'; }
351 4 elsif ($$bufr =~ m/\G\#(?:is_|has_)?date/pi) { $type = 'IS_DATE'; }
352 2 elsif ($$bufr =~ m/\G\#has(?:_field)?/pi) { $type = 'HAS_FIELD'; }
353 0 elsif ($$bufr =~ m/\G\#file(?:_?)names/pi) { $type = 'FILENAMES_ONLY'; }
354 0 elsif ($$bufr =~ m/\G\#debug_rank/pi) { $type = 'DEBUG_RANK'; }
355 0 elsif ($$bufr =~ m/\G\#(?:greater|de?sc)(?:_by)?_rank/pi) { $type = 'GREATER_BY_RANK'; }
356 0 elsif ($$bufr =~ m/\G\#(?:less|asc)(?:_by)?_rank/pi) { $type = 'LESS_BY_RANK'; }
357 0 elsif ($$bufr =~ m/\G\#(?:greater|de?sc)(?:_by)?_date/pi) { $type = 'GREATER_BY_DATE'; }
358 10 elsif ($$bufr =~ m/\G\#(?:less|asc)(?:_by)?_date/pi) { $type = 'LESS_BY_DATE'; }
359 0 elsif ($$bufr =~ m/\G\#(?:greater|de?sc)(?:_by)?_size/pi) { $type = 'GREATER_BY_SIZE'; }
360 0 elsif ($$bufr =~ m/\G\#(?:less|asc)(?:_by)?_size/pi) { $type = 'LESS_BY_SIZE'; }
361 0 elsif ($$bufr =~ m/\G\#(?:is_|has_)?size/pi) { $type = 'IS_SIZE'; }
362 0 elsif ($$bufr =~ m/\G\#(?:(?:less|asc)_(?:by_)?)?left/pi) { $type = 'LESS_BY_LEFT'; }
363 0 elsif ($$bufr =~ m/\G\#(?:(?:greater|de?sc)_(?:by_)?)left/pi) { $type = 'GREATER_BY_LEFT'; }
364 0 elsif ($$bufr =~ m/\G\#(?:(?:less|asc)_(?:by_)?)?right/pi) { $type = 'LESS_BY_RIGHT'; }
365 0 elsif ($$bufr =~ m/\G\#(?:(?:greater|de?sc)_(?:by_)?)right/pi) { $type = 'GREATER_BY_RIGHT'; }
366 0 elsif ($$bufr =~ m/\G\#(?:(?:less|asc)_(?:by_)?)?mid(?:dle)?/pi) { $type = 'LESS_BY_MIDDLE'; }
367 0 elsif ($$bufr =~ m/\G\#(?:(?:greater|de?sc)_(?:by_)?)mid(?:dle)?/pi) { $type = 'GREATER_BY_MIDDLE'; }
368 2 elsif ($$bufr =~ m/\G\#(?:(?:less|asc)(?:_by)?_key)/pi) { $type = 'LESS_BY_KEY'; }
369 0 elsif ($$bufr =~ m/\G\#(?:(?:greater|de?sc)(?:_by)?_key)/pi) { $type = 'GREATER_BY_KEY'; }
370 0 elsif ($$bufr =~ m/\G\#(?:(?:less|asc)(?:_by)?_(?:count|val(?:ue)?))/pi) { $type = 'LESS_BY_COUNT'; }
371 2 elsif ($$bufr =~ m/\G\#(?:(?:greater|de?sc)(?:_by)?_(?:count|val(?:ue)?))/pi) { $type = 'GREATER_BY_COUNT'; }
372 0 elsif ($$bufr =~ m/\G\#(?:less|asc)(?:_by)?/pi) { $type = 'LESS_BY'; }
373 0 elsif ($$bufr =~ m/\G\#(?:greater|de?sc)(?:_by)?/pi) { $type = 'GREATER_BY'; }
374 4 elsif ($$bufr =~ m/\G\#prune(?:_less|_asc)?(?:_by)?/pi) { $type = 'PRUNE_ASC'; }
375 0 elsif ($$bufr =~ m/\G\#prune(?:_greater|_de?sc)(?:_by)?/pi) { $type = 'PRUNE_DESC'; }
376 0 elsif ($$bufr =~ m/\G\#rand(?:om)?/pi) { $type = 'RANDOM'; }
377 28 elsif ($$bufr =~ m/\G\#by/pi) { $type = 'BY'; }
378 2 elsif ($$bufr =~ m/\G\#samp(?:le)?/pi) { $type = 'SAMPLE'; }
379 0 elsif ($$bufr =~ m/\G\#clim(?:it)?/pi) { $type = 'CLIMIT'; }
380  
381 ##-- regexes
382 0 elsif ($$bufr =~ m/\G\!\/($DEF{regex_text})\/(?=$DEF{regex_modifier})/po) { $type='NEG_REGEX'; $text=$1; $lex->{state}='Q_REGOPT'; }
383 0 elsif ($$bufr =~ m/\G\!\/($DEF{regex_text})\//po) { $type='NEG_REGEX'; $text=$1; }
384 0 elsif ($$bufr =~ m/\G\/($DEF{regex_text})\/(?=$DEF{regex_modifier})/po) { $type='REGEX'; $text=$1; $lex->{state}='Q_REGOPT'; }
385 11 elsif ($$bufr =~ m/\G\/($DEF{regex_text})\//po) { $type='REGEX'; $text=$1; }
386 2 elsif ($$bufr =~ m/\Gs\/($DEF{regex_text})\//po) { $type='REGEX_SEARCH'; $text=$1; $lex->{state}='Q_REGREP'; }
387  
388 ##-- punctutation & special characters
389 2 elsif ($$bufr =~ m/\G#=/p) { $type = 'HASH_EQUAL'; } ##-- hash+equal: exact distance
390 0 elsif ($$bufr =~ m/\G#</p) { $type = 'HASH_LESS'; } ##-- hash+less: max distance
391 0 elsif ($$bufr =~ m/\G#>/p) { $type = 'HASH_GREATER'; } ##-- hash+greater: min distance
392 0 elsif ($$bufr =~ m/\G\$\./p) { $type = 'DOLLAR_DOT'; } ##-- positional anchor pseudo-index
393 0 elsif ($$bufr =~ m/\G\:\{/p) { $type = 'COLON_LBRACE'; } ##-- theusaurus-query operator
394 4 elsif ($$bufr =~ m/\G\@\{/p) { $type = 'AT_LBRACE'; } ##-- literal-set operator
395 0 elsif ($$bufr =~ m/\G\*\{/p) { $type = 'STAR_LBRACE'; } ##-- prefix-set opener
396 0 elsif ($$bufr =~ m/\G\}\*/p) { $type = 'RBRACE_STAR'; } ##-- suffix-set closer
397 78 elsif ($$bufr =~ m/\G[!.,;=@%^#~\/]/p) { $type = ${^MATCH}; } ##-- single-char punctuation operators
398 172 elsif ($$bufr =~ m/\G[\[\]{}()<>]/p) { $type = ${^MATCH}; } ##-- parentheses
399 4 elsif ($$bufr =~ m/\G\"/p) { $type = ${^MATCH}; } ##-- double-quotes
400  
401 ##-- subcorpus path-lists
402 34 elsif ($$bufr =~ m/\G\:/p) { $type = ${^MATCH}; $lex->{yyDtrsPos}=$lex->yypos(); $lex->{state}='Q_CORPORA'; }
403  
404 ##-- truncated symbols
405 0 elsif ($$bufr =~ m/\G\*\'($DEF{sq_text})\'\*/po) { $type='INFIX'; $text=$1; } ##-- dual-truncated quoted string (infix symbol)
406 2 elsif ($$bufr =~ m/\G\'($DEF{sq_text})\'\*/po) { $type='PREFIX'; $text=$1; } ##-- right-truncated quoted string (prefix symbol)
407 0 elsif ($$bufr =~ m/\G\*\'($DEF{sq_text})\'/po) { $type='SUFFIX'; $text=$1; } ##-- left-truncated quoted string (suffix symbol)
408  
409 0 elsif ($$bufr =~ m/\G\*($DEF{symbol_text})\*/po) { $type='INFIX'; $text=$1; } ##-- dual-truncated bareword (infix symbol)
410 2 elsif ($$bufr =~ m/\G($DEF{symbol_text})\*/po) { $type='PREFIX'; $text=$1; } ##-- right-truncated bareword (prefix symbol)
411 0 elsif ($$bufr =~ m/\G\*($DEF{symbol_text})/po) { $type='SUFFIX'; $text=$1; } ##-- left-truncated bareword (suffix symbol)
412  
413 ##-- index names (special handling to allow count(foo) #by[$w-1]
414 24 elsif ($$bufr =~ m/\G\$($DEF{index_name})/po) { $type='INDEX'; $text=$1; }
415 0 elsif ($$bufr =~ m/\G\$'($DEF{index_name})'/po) { $type='INDEX'; $text=$1; }
416 0 elsif ($$bufr =~ /m\G\$/p) { $type='$'; }
417  
418 ##-- numeric tokens (handled below with symbols for perl lexer w/o longest-match)
419  
420 ##-- single-term wildcard
421 0 elsif ($$bufr =~ m/\G\*/p) { $type = '*'; }
422  
423 ##-- term expander pipelines
424 4 elsif ($$bufr =~ m/\G\|/p) { $lex->{state}='Q_XPIPE'; $type='__SKIP__'; }
425  
426 ##-- symbols: quoted
427 elsif ($$bufr =~ m/\G\'($DEF{sq_text})\'/po) {
428 43 $text = $1;
429 43 ▶ if ($text =~ m/^[\+\-]?[0-9]+\z/) { $type='INTEGER'; }
Branch: 2 branches
BranchTrueFalseTotal
if ($text =~ /^[\+\-]?[0-9]+\z/) { } 10 33 43
elsif ($text =~ /^[0-9-]+\z/) { } 6 27 33
430 6 elsif ($text =~ m/^[0-9-]+\z/) { $type='DATE'; }
431 27 else { $type='SYMBOL'; }
432 }
433 ##-- symbols: barewords
434 ▶ elsif ($lex->{state} eq 'INITIAL' && $$bufr =~ m/\G$DEF{symbol_text}/po) {
Condition100%3/3
$lex->{"state"} eq "INITIAL" and $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{"symbol_text"}/op
!ll&&!rl&&r
40300285
MC/DC100%2/2
$lex->{"state"} eq "INITIAL" and $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{"symbol_text"}/op
$lex->{"state"} eq "INITIAL" $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{"symbol_text"}/op
Truth table100%3/3
A and B
A= $lex->{"state"} eq "INITIAL"B= $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{"symbol_text"}/op
ABresult
0X0
100
111
435 285 $text = ${^MATCH};
436 285 $match = ${^MATCH};
437 285 ▶ if ($text =~ m/^[\+\-]?[0-9]+\z/) { $type='INTEGER'; }
Branch: 2 branches
BranchTrueFalseTotal
if ($text =~ /^[\+\-]?[0-9]+\z/) { } 40 245 285
elsif ($text =~ /^[0-9-]+\z/) { } 6 239 245
438 6 elsif ($text =~ m/^[0-9-]+\z/) { $type='DATE'; }
439 239 else { $type='SYMBOL'; }
440 }
441 ##-- barewords: integers and dates (Q_MATCHID)
442 14 ▶ elsif ($lex->{state} ne 'INITIAL' && $$bufr =~ m/\G[\+\-]?[0-9]+(?=$DEF{int_boundary})/po) { $type='INTEGER'; }
Condition100%3/3
$lex->{"state"} ne "INITIAL" and $$bufr =~ /\G[\+\-]?[0-9]+(?=$DDC::PP::yyqlexer::DEF{"int_boundary"})/op
!ll&&!rl&&r
3002614
MC/DC100%2/2
$lex->{"state"} ne "INITIAL" and $$bufr =~ /\G[\+\-]?[0-9]+(?=$DDC::PP::yyqlexer::DEF{"int_boundary"})/op
$lex->{"state"} ne "INITIAL" $$bufr =~ /\G[\+\-]?[0-9]+(?=$DDC::PP::yyqlexer::DEF{"int_boundary"})/op
Truth table100%3/3
A and B
A= $lex->{"state"} ne "INITIAL"B= $$bufr =~ /\G[\+\-]?[0-9]+(?=$DDC::PP::yyqlexer::DEF{"int_boundary"})/op
ABresult
0X0
100
111
443 26 ▶ elsif ($lex->{state} ne 'INITIAL' && $$bufr =~ m/\G[\+\-]?[0-9]+\z/p) { $type='INTEGER'; }
Condition66%2/3
$lex->{"state"} ne "INITIAL" and $$bufr =~ /\G[\+\-]?[0-9]+\z/p
!ll&&!rl&&r
300026
MC/DC50%1/2
$lex->{"state"} ne "INITIAL" and $$bufr =~ /\G[\+\-]?[0-9]+\z/p
$lex->{"state"} ne "INITIAL" $$bufr =~ /\G[\+\-]?[0-9]+\z/p
Truth table66%2/3
A and B
A= $lex->{"state"} ne "INITIAL"B= $$bufr =~ /\G[\+\-]?[0-9]+\z/p
ABresult
0X0
100
111
444  
445 0 ▶ elsif ($lex->{state} ne 'INITIAL' && $$bufr =~ m/\G$DEF{date_bare}(?=$DEF{int_boundary})/po) { $type='DATE'; }
Condition33%1/3
$lex->{"state"} ne "INITIAL" and $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{"date_bare"}(?=$DDC::PP::yyqlexer::DEF{"int_boundary"})/op
!ll&&!rl&&r
30000
MC/DC0%0/2
$lex->{"state"} ne "INITIAL" and $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{"date_bare"}(?=$DDC::PP::yyqlexer::DEF{"int_boundary"})/op
$lex->{"state"} ne "INITIAL" $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{"date_bare"}(?=$DDC::PP::yyqlexer::DEF{"int_boundary"})/op
Truth table33%1/3
A and B
A= $lex->{"state"} ne "INITIAL"B= $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{"date_bare"}(?=$DDC::PP::yyqlexer::DEF{"int_boundary"})/op
ABresult
0X0
100
111
446 0 ▶ elsif ($lex->{state} ne 'INITIAL' && $$bufr =~ m/\G$DEF{date_bare}\z/po) { $type='DATE'; }
Condition33%1/3
$lex->{"state"} ne "INITIAL" and $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{"date_bare"}\z/op
!ll&&!rl&&r
30000
MC/DC0%0/2
$lex->{"state"} ne "INITIAL" and $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{"date_bare"}\z/op
$lex->{"state"} ne "INITIAL" $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{"date_bare"}\z/op
Truth table33%1/3
A and B
A= $lex->{"state"} ne "INITIAL"B= $$bufr =~ /\G$DDC::PP::yyqlexer::DEF{"date_bare"}\z/op
ABresult
0X0
100
111
447  
448 ##-- misc
449 300 elsif ($$bufr =~ m/\G\s+/p) { $type = '__SKIP__'; }
450 #elsif ($$bufr =~ m/\G./p) { $type = 'SYMBOL'; }
451 0 elsif ($$bufr =~ m/\G./p) { $type = '__ERROR__'; }
452  
453 1213 ▶ $match = ${^MATCH} if (!defined($match));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $match 928 285 1213
454 }
455 ##------------------------
456 elsif ($lex->{state} eq 'Q_CORPORA') {
457 86 ▶ if ($$bufr =~ m/\G$DEF{corpus_text}/p) { $type='SYMBOL'; }
Branch: 4 branches
BranchTrueFalseTotal
if ($$bufr =~ /\G$DDC::PP::yyqlexer::DEF{'corpus_text'}/p) { } 28 58 86
elsif ($$bufr =~ /\G\'($DDC::PP::yyqlexer::DEF{'sq_text'})\'/op) { } 22 36 58
elsif ($$bufr =~ /\G\,/p) { } 18 18 36
elsif ($$bufr =~ /\G\s+/p) { } 8 10 18
458 22 elsif ($$bufr =~ m/\G\'($DEF{sq_text})\'/po) { $type='SYMBOL'; $text=$1; }
459 18 elsif ($$bufr =~ m/\G\,/p) { $type=${^MATCH}; }
460 8 elsif ($$bufr =~ m/\G\s+/p) { $type='__SKIP__'; }
461 10 else { $type='__SKIP__'; $lex->yypopq(); }
462  
463 86 $match = ${^MATCH};
464 86 ▶ $lex->{yyDtrsLen} = $lex->yypos()-$lex->{yyDtrsPos} if ($type ne '__SKIP__');
Branch: 1 branch
BranchTrueFalseTotal
if $type ne "__SKIP__" 68 18 86
465 }
466 ##------------------------
467 elsif ($lex->{state} eq 'Q_COMMENT') {
468 38 ▶ if ($$bufr =~ m/\G\]/p) {
Branch: 2 branches
BranchTrueFalseTotal
if ($$bufr =~ /\G\]/p) { } 19 19 38
elsif ($$bufr =~ /\G$DDC::PP::yyqlexer::DEF{'comment_text'}/ps) { } 19 0 19
469 19 $type='__SKIP__';
470 19 $lex->{_cmtbuf} .= ${^MATCH};
471 19 push(@{$lex->{comments}}, $lex->{_cmtbuf});
472 19 delete $lex->{_cmtbuf};
473 19 $lex->yypopq();
474 }
475 19 elsif ($$bufr =~ m/\G$DEF{comment_text}/sp) { $type='__SKIP__'; $lex->{_cmtbuf} .= ${^MATCH}; }
476 0 else { $type='__ERROR__'; }
477  
478 38 $match = ${^MATCH};
479 }
480 ##------------------------
481 elsif ($lex->{state} eq 'Q_DATE') {
482 0 ▶ if ($$bufr =~ m/^\s+/) { $type = '__SKIP__'; }
Branch: 2 branches
BranchTrueFalseTotal
if ($$bufr =~ /^\s+/) { } 0 2 2
elsif ($$bufr =~ m[^/]) { } 0 2 2
483 0 elsif ($$bufr =~ m/^\//) { $type = '/'; $lex->{state}='INITIAL'; }
484 2 else { $lex->{state}='INITIAL'; $type='__SKIP__'; }
485  
486 2 $match = ${^MATCH};
487 }
488 ##------------------------
489 elsif ($lex->{state} eq 'Q_REGREP') {
490 0 ▶ if ($$bufr =~ m/\G($DEF{regex_text})\/(?=$DEF{regex_modifier})/po) { $type='REGEX_REPLACE'; $text=$1; $lex->{state}='Q_REGOPT'; }
Branch: 2 branches
BranchTrueFalseTotal
if ($$bufr =~ m[\G($DDC::PP::yyqlexer::DEF{'regex_text'})/(?=$DDC::PP::yyqlexer::DEF{'regex_modifier'})]op) { } 0 2 2
elsif ($$bufr =~ m[\G($DDC::PP::yyqlexer::DEF{'regex_text'})/]op) { } 2 0 2
491 2 elsif ($$bufr =~ m/\G($DEF{regex_text})\//po) { $type='REGEX_REPLACE'; $text=$1; $lex->{state}='INITIAL'; }
492  
493 2 $match = ${^MATCH};
494 }
495 ##------------------------
496 elsif ($lex->{state} eq 'Q_REGOPT') {
497 0 ▶ if ($$bufr =~ m/\G$DEF{regex_modifier}+/po) { $type='REGOPT'; }
Branch: 1 branch
BranchTrueFalseTotal
if ($$bufr =~ /\G$DDC::PP::yyqlexer::DEF{'regex_modifier'}+/op) { } 0 0 0
498 0 else { $type='__SKIP__'; }
499 0 $lex->{state} = 'INITIAL';
500  
501 0 $match = ${^MATCH};
502 }
503 ##------------------------
504 elsif ($lex->{state} eq 'Q_XPIPE') {
505 0 ▶ if ($$bufr =~ m/\G\s+/p) { $type = '__SKIP__'; } ##-- whitespace: skip
Branch: 4 branches
BranchTrueFalseTotal
if ($$bufr =~ /\G\s+/p) { } 0 4 4
elsif ($$bufr =~ /\G\-/p) { } 0 4 4
elsif ($$bufr =~ /\G\'($DDC::PP::yyqlexer::DEF{'sq_text'})\'/op) { } 0 4 4
elsif ($$bufr =~ /\G$DDC::PP::yyqlexer::DEF{'symbol_text'}/op) { } 4 0 4
506 0 elsif ($$bufr =~ m/\G\-/p) { $lex->{state}='INITIAL'; $type='EXPANDER'; }
507 0 elsif ($$bufr =~ m/\G\'($DEF{sq_text})\'/po) { $lex->{state}='INITIAL'; $type='EXPANDER'; $text=$1; }
508 4 elsif ($$bufr =~ m/\G$DEF{symbol_text}/po) { $lex->{state}='INITIAL'; $type='EXPANDER'; }
509 #elsif ($$bufr =~ m/\G\z/p) { $lex->{state}='INITIAL'; $type='EXPANDER'; }
510 0 else { $lex->{state}='INITIAL'; $type='EXPANDER'; $text=''; }
511  
512 4 $match = ${^MATCH};
513 }
514 ##------------------------
515 ## END perl-ification of flex sources
516  
517 ##-- guts
518 1345 ▶ $text = $match if (!defined($text));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $text 952 393 1345
519 1345 ▶ $lex->{bufp} += length($match) if (defined($match));
Branch: 1 branch
BranchTrueFalseTotal
if defined $match 1307 38 1345
520  
521 1345 pos($$bufr) = $lex->{bufp};
522 1345 ▶ return if (!defined($type));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 1345 1345
523  
524 1345 ▶ next LEXSKIP if ($type eq '__SKIP__');
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "__SKIP__" 403 942 1345
525 942 ▶ next LEXBUF if ($type eq '__EOF__');
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "__EOF__" 26 916 942
526 #elsif ($type eq '__ERROR__') {
527 # return $lex->yyerror();
528 #}
529 916 return @$lex{qw(yytype yytext)} = ($type,$text);
530 }
531 }
532 209 return @$lex{qw(yytype yytext)} = ('__EOF__',undef);
533 }
534  
535 ##======================================================================
536 ## Testing: dummy lexing
537  
538 ## undef = $lex->dummylex(@from_whatever)
539 0 ▶sub dummylex {
Subroutine dummylex: not called CC=7 SCAR=40.3
Pod undocumented
540 0 my $lex = shift;
541 0 $lex->reset();
542 0 $lex->from(@_);
543 0 my ($type,$text);
544 TOKEN:
545 0 while(1) {
546 0 ($type,$text) = $lex->yylex();
547 print("-" x 64, "\n",
548 ">> Line: ", $lex->yylineno, ", Pos: ", $lex->yypos, "\n",
549 0 ▶ ">> State: ", (defined($lex->{state}) ? $lex->{state} : '(undef)'), "\n",
Branch: 3 branches
BranchTrueFalseTotal
defined $lex->{'state'} ? : 0 0 0
defined $type ? : 0 0 0
defined $text ? : 0 0 0
550 ">> Type: ", (defined($type) ? $type : '(undef)'), "\n",
551 ">> Text: ", (defined($text) ? $text : '(undef)'), "\n",
552 );
553 0 ▶ if (!defined($type)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $type) 0 0 0
554 0 warn(":: undef type!");
555 0 return;
556 }
557 0 ▶ if ($type eq '__ERROR__') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "__ERROR__") 0 0 0
558 0 print(":: ERROR DETECTED\n");
559 0 $lex->yyerror();
560 }
561 0 ▶ last if ($type eq '__EOF__');
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "__EOF__" 0 0 0
562 }
563 }
564  
565  
566 20 1; ##-- be happy
567  
568 __END__
« blib/lib/DDC/Client.pm ↑ Summary blib/lib/DDC/Format/Text.pm »