[open-ils-commits] r8723 - in trunk/Open-ILS/src: perlmods/OpenILS/Application/Storage support-scripts

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Feb 11 16:16:23 EST 2008


Author: miker
Date: 2008-02-11 15:47:11 -0500 (Mon, 11 Feb 2008)
New Revision: 8723

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/FTS.pm
   trunk/Open-ILS/src/support-scripts/settings-tester.pl
Log:
adde Parse::RecDescent stubbing for future use

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/FTS.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/FTS.pm	2008-02-11 20:38:26 UTC (rev 8722)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/FTS.pm	2008-02-11 20:47:11 UTC (rev 8723)
@@ -4,7 +4,10 @@
 #-------------------------------------------------------------------------------
 package OpenILS::Application::Storage::FTS;
 use OpenSRF::Utils::Logger qw/:level/;
+use Parser::RecDescent;
 
+my $_default_grammar_parser = new Parse::RecDescent ( join '', (<DATA>) );
+
 sub compile {
 
 	$log->debug("You must override me somewhere, or I will make searching really slow!!!!",ERROR);;
@@ -32,6 +35,7 @@
 sub decompose {
 	my $self = shift;
 	my $term = shift;
+	my $parser = shift || $_default_grammar_parser;
 
 	$term =~ s/:/ /go;
 	$term =~ s/\s+--\s+/ /go;
@@ -44,6 +48,7 @@
 
 	$log->debug("Stripped search term string is [$term]",DEBUG);
 
+	my $parsetree = $parser->search_expression( $term );
 	my @words = $term =~ /\b((?<!!)\w+)\b/go;
 	my @nots = $term =~ /\b(?<=!)(\w+)\b/go;
 
@@ -62,6 +67,7 @@
 	$self->{ fts_op } = 'ILIKE';
 	$self->{ fts_col } = $self->{ text_col } = 'value';
 	$self->{ raw } = $term;
+	$self->{ parsetree } = $parsetree;
 	$self->{ words } = \@words;
 	$self->{ nots } = \@nots;
 	$self->{ phrases } = \@parts;
@@ -215,3 +221,21 @@
 }
 
 1;
+
+__DATA__
+<autotree>
+
+search_expression: or_expr(s) | and_expr(s) | expr(s)
+or_expr: lexpr '||' rexpr
+and_expr: lexpr '&&' rexpr
+lexpr: expr
+rexpr: expr
+expr: phrase(s) | group(s) | word(s)
+joiner: '||' | '&&'
+phrase: '"' token(s) '"'
+group : '(' search_expression ')'
+word: numeric_range | negative_token | token
+negative_token: '-' .../\D+/ token
+token: /[-\w]+/
+numeric_range: /\d+-\d*/
+

Modified: trunk/Open-ILS/src/support-scripts/settings-tester.pl
===================================================================
--- trunk/Open-ILS/src/support-scripts/settings-tester.pl	2008-02-11 20:38:26 UTC (rev 8722)
+++ trunk/Open-ILS/src/support-scripts/settings-tester.pl	2008-02-11 20:47:11 UTC (rev 8723)
@@ -331,3 +331,4 @@
 Text::CSV_XS
 Spreadsheet::WriteExcel::Big
 Tie::IxHash
+Parse::RecDescent



More information about the open-ils-commits mailing list