From 84d3fc7ed4fdb160d08b130340b4561c9049c2a5 Mon Sep 17 00:00:00 2001 From: miker Date: Mon, 11 Feb 2008 20:47:11 +0000 Subject: [PATCH] adde Parse::RecDescent stubbing for future use git-svn-id: svn://svn.open-ils.org/ILS/trunk@8723 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Storage/FTS.pm | 24 +++++++++++++++++++ .../src/support-scripts/settings-tester.pl | 1 + 2 files changed, 25 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/FTS.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/FTS.pm index c20edf2f6e..d9c4ee452d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/FTS.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/FTS.pm @@ -4,6 +4,9 @@ my $log = 'OpenSRF::Utils::Logger'; #------------------------------------------------------------------------------- package OpenILS::Application::Storage::FTS; use OpenSRF::Utils::Logger qw/:level/; +use Parser::RecDescent; + +my $_default_grammar_parser = new Parse::RecDescent ( join '', () ); sub compile { @@ -32,6 +35,7 @@ sub compile { 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 @@ sub decompose { $log->debug("Stripped search term string is [$term]",DEBUG); + my $parsetree = $parser->search_expression( $term ); my @words = $term =~ /\b((?{ 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 @@ package Class::DBI; } 1; + +__DATA__ + + +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*/ + diff --git a/Open-ILS/src/support-scripts/settings-tester.pl b/Open-ILS/src/support-scripts/settings-tester.pl index 90c4e5317a..1f733838ef 100755 --- a/Open-ILS/src/support-scripts/settings-tester.pl +++ b/Open-ILS/src/support-scripts/settings-tester.pl @@ -331,3 +331,4 @@ Text::CSV Text::CSV_XS Spreadsheet::WriteExcel::Big Tie::IxHash +Parse::RecDescent -- 2.43.2