From: Mike Taylor Date: Thu, 23 Dec 2004 10:24:11 +0000 (+0000) Subject: Support, testing and changelog for multi-word terms quoted by {curly brackets} X-Git-Url: http://git.indexdata.com/?p=perl-pqf.git;a=commitdiff_plain;h=7cced0e025e85ed6b8cf92866a2580fd4b46d209 Support, testing and changelog for multi-word terms quoted by {curly brackets} --- diff --git a/Changes b/Changes index fbc2712..502de9d 100644 --- a/Changes +++ b/Changes @@ -1,16 +1,18 @@ -$Id: Changes,v 1.7 2004-12-22 17:55:24 mike Exp $ +$Id: Changes,v 1.8 2004-12-23 10:24:11 mike Exp $ Revision history for Perl extension Net::Z3950::PQF. 0.03 (IN PROGRESS) - Net::Z3950::PQF::TermNode and Net::Z3950::PQF::BooleanNode are now subclasses of Net::Z3950::PQF::BooleanNode as - documented. - - Test script "t/1-node.t" now tests subclassness. - - Support for Rset nodes. - - Test script "t/1-node.t" now tests Rset nodes. - - Support for parsing @set. - - Test script "t/2-parser.t" now tests @set queries. + documented. Test script "t/1-node.t" now tests subclass + relationships. + - Support for Rset nodes. Test script "t/1-node.t" now tests + Rset nodes. + - Support for parsing @set. Test script "t/2-parser.t" now + tests @set queries. + - Handle multi-word terms enclosed in {curly brackets}. Test + script "t/2-parser.t" tests this. 0.02 Fri Dec 17 17:17:47 GMT 2004 - Write the code! First functional version. @@ -21,10 +23,9 @@ Revision history for Perl extension Net::Z3950::PQF. ### Still to do: - Correct handling of double-quoted terms, so that backslash can - protect embedded double quotes. - Handle multi-word terms enclosed in {curly brackets} - Support for creating and rendering ProxNode. - Support for parsing @prox. - Support for parsing @term. + - Correct handling of double-quoted terms, so that backslash + can protect embedded double quotes. + - Support for creating and rendering ProxNode. + - Support for parsing @prox. + - Support for parsing @term. diff --git a/lib/Net/Z3950/PQF.pm b/lib/Net/Z3950/PQF.pm index eb1a8fe..3c78a7f 100644 --- a/lib/Net/Z3950/PQF.pm +++ b/lib/Net/Z3950/PQF.pm @@ -1,4 +1,4 @@ -# $Id: PQF.pm,v 1.6 2004-12-20 09:46:58 mike Exp $ +# $Id: PQF.pm,v 1.7 2004-12-23 10:24:12 mike Exp $ package Net::Z3950::PQF; @@ -115,13 +115,19 @@ sub _parse { my $this = shift(); my($attrset, $attrhash) = @_; + $this->{text} =~ s/^\s+//; + ### This rather nasty hack for quoted terms doesn't recognised # backslash-quoted embedded double quotes. - $this->{text} =~ s/^\s+//; if ($this->{text} =~ s/^"(.*?)"//) { return $this->_leaf('term', $1, $attrhash); } + # Also recognise multi-word terms enclosed in {curly braces} + if ($this->{text} =~ s/^{(.*?)}//) { + return $this->_leaf('term', $1, $attrhash); + } + my $word = $this->_word(); if ($word eq '@attrset') { $attrset = $this->_word(); diff --git a/t/2-parser.t b/t/2-parser.t index 7480199..ca07498 100644 --- a/t/2-parser.t +++ b/t/2-parser.t @@ -1,4 +1,4 @@ -# $Id: 2-parser.t,v 1.3 2004-12-20 09:46:58 mike Exp $ +# $Id: 2-parser.t,v 1.4 2004-12-23 10:24:12 mike Exp $ use strict; use warnings; @@ -12,6 +12,8 @@ BEGIN { "term: brian" ], [ '"brian kernighan"', "term: brian kernighan" ], + [ '{brian kernighan}', + "term: brian kernighan" ], [ '@attr 1=1003 brian', "term: brian\n\tattr: bib-1 1=1003" ], [ '@attr 1=1003 "brian"',