|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   Copyright (C) 1999 Eric Bohlman, Loic Dachary  | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   This program is free software; you can redistribute it and/or modify it  | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   under the terms of the GNU General Public License as published by the  | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   Free Software Foundation; either version 2, or (at your option) any  | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   later version.  You may also use, redistribute and/or modify it  | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   under the terms of the Artistic License supplied with your Perl  | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   distribution  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   This program is distributed in the hope that it will be useful,  | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   but WITHOUT ANY WARRANTY; without even the implied warranty of  | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   GNU General Public License for more details.  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   You should have received a copy of the GNU General Public License  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   along with this program; if not, write to the Free Software  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.   | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Text::Query::BuildSimpleString;  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 BEGIN {  | 
| 
23
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
98
 | 
   require 5.005;  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
26
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
10
 | 
 use strict;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
73
 | 
    | 
| 
27
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
11
 | 
 use re qw/eval/;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
78
 | 
    | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
29
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
10
 | 
 use vars qw(@ISA);  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
90
 | 
    | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
31
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
943
 | 
 use Text::Query::Build;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1217
 | 
    | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 @ISA = qw(Text::Query::Build);  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub build_init {  | 
| 
36
 | 
11
 | 
 
 | 
 
 | 
  
11
  
 | 
  
1
  
 | 
16
 | 
     my($self) = @_;  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
38
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
16
 | 
     $self->{'ws'} = 0;  | 
| 
39
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
34
 | 
     $self->{'mc'} = 0;  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub build_literal {  | 
| 
43
 | 
16
 | 
 
 | 
 
 | 
  
16
  
 | 
  
1
  
 | 
27
 | 
     my($self, $t) = @_;  | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
45
 | 
16
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
48
 | 
     $self->{'weight'} = ($t =~ s/\((\d+)\)$//) ? $1 : 1;  | 
| 
46
 | 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
25
 | 
     $self->{'m'} = 0;  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
48
 | 
16
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
46
 | 
     warn("build_literal 0 = $t") if($self->{-verbose} > 1);  | 
| 
49
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
50
 | 
16
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
44
 | 
     if(!$self->{parseopts}{-regexp}) {  | 
| 
51
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
24
 | 
 	$t=quotemeta($t);  | 
| 
52
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
25
 | 
 	$t=~s/\\\*/\\w*/g;  | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }   | 
| 
54
 | 
16
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
50
 | 
     $t =~ s/\\? +/\\s+/g if(!$self->{parseopts}{-litspace});  | 
| 
55
 | 
16
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
43
 | 
     $t = "\\b$t\\b" if($self->{parseopts}{-whole});  | 
| 
56
 | 
16
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
43
 | 
     $t = "(?:$t)" if($self->{parseopts}{-regexp});  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
58
 | 
16
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
40
 | 
     warn("build_literal 1 = $t") if($self->{-verbose} > 1);  | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
60
 | 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
92
 | 
     return $t;  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
62
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       | 
| 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub build_forbiden {  | 
| 
64
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
  
1
  
 | 
2
 | 
     my($self, $t) = @_;  | 
| 
65
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
66
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
     $self->{'m'} = (~0);  | 
| 
67
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
68
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     return $t;  | 
| 
69
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
70
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub build_mandatory {  | 
| 
72
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
  
1
  
 | 
5
 | 
     my($self, $t) = @_;  | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
74
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
     $self->{'m'} = 1 << $self->{'mc'};  | 
| 
75
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
     $self->{'mc'} += 1;  | 
| 
76
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
     $self->{'ws'} |= $self->{'m'};  | 
| 
77
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
78
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
     return $t;  | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub build_expression_finish {  | 
| 
82
 | 
16
 | 
 
 | 
 
 | 
  
16
  
 | 
  
1
  
 | 
26
 | 
     my($self, $t) = @_;  | 
| 
83
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
84
 | 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
107
 | 
     return sprintf("%s(?{[%d,%d]})", $t, ~($self->{'m'}), $self->{'weight'});  | 
| 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
86
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
87
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub build_expression {  | 
| 
88
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
  
1
  
 | 
7
 | 
     my($self, $l, $r) = @_;  | 
| 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
90
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
25
 | 
     return "$l|$r";  | 
| 
91
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
92
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
93
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub build_final_expression {  | 
| 
94
 | 
11
 | 
 
 | 
 
 | 
  
11
  
 | 
  
1
  
 | 
17
 | 
   my ($self,$t)=@_;  | 
| 
95
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
96
 | 
11
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
31
 | 
   croak("match count > 31") if($self->{'mc'} > 31);  | 
| 
97
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
98
 | 
11
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
41
 | 
   $t = ($self->{parseopts}{-case} ? '' : '(?i)') . $t;  | 
| 
99
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
100
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1279
 | 
   $self->{matchstring} = qr/$t/s;  | 
| 
101
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
102
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
94
 | 
   return [ $self->{matchstring}, $self->{'ws'} ];  | 
| 
103
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
104
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
105
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
106
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |