line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Search::Query; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
35427
|
use warnings; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
331
|
|
4
|
8
|
|
|
8
|
|
45
|
use strict; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
307
|
|
5
|
8
|
|
|
8
|
|
3432
|
use Search::Query::Parser; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
370
|
|
6
|
8
|
|
|
8
|
|
70
|
use Carp; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
571
|
|
7
|
8
|
|
|
8
|
|
49
|
use File::Find; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
449
|
|
8
|
8
|
|
|
8
|
|
43
|
use File::Spec; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
279
|
|
9
|
8
|
|
|
8
|
|
54
|
use Data::Dump qw( dump ); |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
465
|
|
10
|
|
|
|
|
|
|
use Module::Pluggable |
11
|
8
|
|
|
|
|
70
|
search_path => ['Search::Query::Dialect'], |
12
|
8
|
|
|
8
|
|
5621
|
sub_name => 'dialects'; |
|
8
|
|
|
|
|
75903
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.305'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Search::Query - polyglot query parsing |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Search::Query; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $parser = Search::Query->parser(); |
25
|
|
|
|
|
|
|
my $query = $parser->parse('+hello -world now'); |
26
|
|
|
|
|
|
|
print $query; # same as print $query->stringify; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This class provides documentation and class methods. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Search::Query started as a fork of the excellent Search::QueryParser module |
35
|
|
|
|
|
|
|
and was then rewritten to provide support for alternate query dialects. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 METHODS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 parser |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Returns a Search::Query::Parser object. See the documentation |
42
|
|
|
|
|
|
|
for L for supported query syntax and how |
43
|
|
|
|
|
|
|
to customize the Parser. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub parser { |
48
|
6
|
|
|
6
|
1
|
3941
|
my $class = shift; |
49
|
6
|
|
|
|
|
115
|
return Search::Query::Parser->new(@_); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 get_query_class( I ) |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Returns a Search::Query::Dialect-based class name corresponding |
55
|
|
|
|
|
|
|
to I. I defaults to 'Native'. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub get_query_class { |
60
|
28
|
|
|
28
|
1
|
49
|
my $class = shift; |
61
|
28
|
50
|
|
|
|
102
|
my $name = shift or croak "query_class name required"; |
62
|
|
|
|
|
|
|
|
63
|
28
|
100
|
|
|
|
127
|
return $name if $name =~ m/^Search::Query::Dialect::/; |
64
|
|
|
|
|
|
|
|
65
|
18
|
|
|
|
|
106
|
for my $dialect ( $class->dialects ) { |
66
|
46
|
100
|
|
|
|
51285
|
if ( $dialect =~ m/::$name$/i ) { |
67
|
18
|
|
|
|
|
1200
|
eval "require $dialect"; |
68
|
18
|
50
|
|
|
|
94
|
croak $@ if $@; |
69
|
18
|
|
|
|
|
105
|
return $dialect; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
croak "No such Dialect available: $name"; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 get_dialect( I ) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Alias for get_query_class(). |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
*get_dialect = \&get_query_class; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHOR |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Peter Karman, C<< >> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 BUGS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
91
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
92
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SUPPORT |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
perldoc Search::Query |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
You can also look for information at: |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over 4 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * CPAN Ratings |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * Search CPAN |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
L |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=back |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This module started as a fork of Search::QueryParser by |
127
|
|
|
|
|
|
|
Laurent Dami. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Copyright 2010 Peter Karman. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
134
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
135
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; # End of Search::Query |