| Text-Query documentation | Contained in the Text-Query distribution. |
Text::Query::Build - Base class for query builders
package Text::Query::BuildMy;
use Text::Query::Build;
use vars qw(@ISA);
@ISA = qw(Text::Query::Build);
This module provides a virtual base class for query builders.
Query builders are called by the parser logic. A given set of functions is provided by the builder to match a Boolean logic. All the methods return a scalar corresponding to the code that performs the specified options.
Parameters Q1 and Q2 are the same type of scalar as the return values.
Return a string that represent the last built expression. Two identical expressions should generate the same string. This is for testing purpose.
Called before building the expression. A chance to initialize object data.
Does any final processing to generate code to match a top-level expression. The return value is NOT necessarily of a type that can be passed to the other code-generation methods.
Generate code to match Q1 OR Q2
Generate any code needed to enclose an expression.
Generate code needed to match Q1 AND Q2. F will be true if this is the first
time this method is called in a sequence of several conjunctions.
Generate code needed to match Q1 NEAR Q2.
Generate code needed to match Q1 immediately followed by Q2.
Generate code needed to match NOT Q1.
Generate code to match Q1 as a literal.
Generate code to enter in the $scope query context.
Generate code needed to match Q1 in the $scope context.
Generate code to match Q1 (think + in AltaVista syntax).
Generate code to match NOT Q1 (think - in AltaVista syntax).
Text::Query(3)
Eric Bohlman (ebohlman@netcom.com)
Loic Dachary (loic@senga.org)
| Text-Query documentation | Contained in the Text-Query distribution. |
# # Copyright (C) 1999 Eric Bohlman, Loic Dachary # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2, or (at your option) any # later version. You may also use, redistribute and/or modify it # under the terms of the Artistic License supplied with your Perl # distribution # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # # # $Header: /usr/local/cvsroot/Text-Query/lib/Text/Query/Build.pm,v 1.3 1999/06/16 10:32:13 loic Exp $ # package Text::Query::Build; use strict; sub new { my $class=shift; my $self={}; bless $self,$class; $self->initialize(); return $self; } sub initialize { } sub matchstring { my($self) = @_; return $self->{matchstring}; } sub build_init { my ($self)=@_; } sub build_final_expression { my($self, $t1) = @_; return $self->{matchstring} = $t1; } sub build_expression { my($self, $l, $r) = @_; return "[ or $l $r ]"; } sub build_expression_finish { my($self, $l) = @_; return $l; } sub build_conj { my($self, $l, $r, $first) = @_; return "[ and $l $r ]"; } sub build_near { my($self, $l, $r) = @_; return "[ near $l $r ]"; } sub build_concat { my($self, $l, $r) = @_; return "[ concat $l $r ]"; } sub build_negation { my($self, $t) = @_; return "[ not $t ]"; } sub build_literal { my($self, $t) = @_; return "[ literal $t ]"; } sub build_scope_start { my($self) = @_; } sub build_scope_end { my($self, $scope, $t) = @_; return "[ scope '$scope->[0]' $t ]"; } sub build_mandatory { my($self, $t) = @_; return "[ mandatory $t ]"; } sub build_forbiden { my($self, $t) = @_; return "[ forbiden $t ]"; } 1;
# Local Variables: *** # mode: perl *** # End: ***