Return-Path: Delivered-To: apmail-incubator-lucene-net-commits-archive@locus.apache.org Received: (qmail 53774 invoked from network); 25 Jun 2008 02:52:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Jun 2008 02:52:59 -0000 Received: (qmail 74008 invoked by uid 500); 25 Jun 2008 02:53:00 -0000 Delivered-To: apmail-incubator-lucene-net-commits-archive@incubator.apache.org Received: (qmail 73984 invoked by uid 500); 25 Jun 2008 02:53:00 -0000 Mailing-List: contact lucene-net-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@incubator.apache.org Delivered-To: mailing list lucene-net-commits@incubator.apache.org Received: (qmail 73975 invoked by uid 99); 25 Jun 2008 02:53:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Jun 2008 19:53:00 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Jun 2008 02:52:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 511802388A06; Tue, 24 Jun 2008 19:51:49 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r671403 - in /incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser: CharStream.cs MultiFieldQueryParser.cs Package.html ParseException.cs QueryParser.JJ QueryParser.cs QueryParserTokenManager.cs Token.cs TokenMgrError.cs Date: Wed, 25 Jun 2008 02:51:48 -0000 To: lucene-net-commits@incubator.apache.org From: aroush@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080625025149.511802388A06@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: aroush Date: Tue Jun 24 19:51:48 2008 New Revision: 671403 URL: http://svn.apache.org/viewvc?rev=671403&view=rev Log: Release: Apache Lucene.Net.2.3.1 build 001 "Alpha" Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/CharStream.cs incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/MultiFieldQueryParser.cs incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/Package.html incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/ParseException.cs incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParser.JJ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParser.cs incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParserTokenManager.cs incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/Token.cs incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/TokenMgrError.cs Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/CharStream.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/CharStream.cs?rev=671403&r1=671402&r2=671403&view=diff ============================================================================== --- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/CharStream.cs (original) +++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/CharStream.cs Tue Jun 24 19:51:48 2008 @@ -55,7 +55,7 @@ /// Returns the line number of the character last read. /// /// - /// + /// /// int GetLine(); Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/MultiFieldQueryParser.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/MultiFieldQueryParser.cs?rev=671403&r1=671402&r2=671403&view=diff ============================================================================== --- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/MultiFieldQueryParser.cs (original) +++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/MultiFieldQueryParser.cs Tue Jun 24 19:51:48 2008 @@ -29,16 +29,14 @@ /// A QueryParser which constructs queries to search multiple fields. /// + /// /// - /// Kelvin Tan, Daniel Naber - /// - /// $Revision: 472959 $ + /// $Revision: 564236 $ /// public class MultiFieldQueryParser : QueryParser { - - private System.String[] fields; - private System.Collections.IDictionary boosts; + protected internal System.String[] fields; + protected internal System.Collections.IDictionary boosts; /// Creates a MultiFieldQueryParser. /// Allows passing of a map with term to Boost, and the boost to apply to each term. @@ -90,7 +88,7 @@ ///

In other words, all the query's terms must appear, but it doesn't matter in /// what fields they appear.

///
- public MultiFieldQueryParser(System.String[] fields, Analyzer analyzer):base(null, analyzer) + public MultiFieldQueryParser(System.String[] fields, Analyzer analyzer) : base(null, analyzer) { this.fields = fields; } @@ -102,7 +100,7 @@ System.Collections.ArrayList clauses = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); for (int i = 0; i < fields.Length; i++) { - Query q = base.GetFieldQuery(fields[i], queryText); + Query q = GetFieldQuery(fields[i], queryText); if (q != null) { //If the user passes a map of boosts @@ -149,7 +147,7 @@ System.Collections.ArrayList clauses = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); for (int i = 0; i < fields.Length; i++) { - clauses.Add(new BooleanClause(base.GetFuzzyQuery(fields[i], termStr, minSimilarity), BooleanClause.Occur.SHOULD)); + clauses.Add(new BooleanClause(GetFuzzyQuery(fields[i], termStr, minSimilarity), BooleanClause.Occur.SHOULD)); } return GetBooleanQuery(clauses, true); } @@ -163,7 +161,7 @@ System.Collections.ArrayList clauses = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); for (int i = 0; i < fields.Length; i++) { - clauses.Add(new BooleanClause(base.GetPrefixQuery(fields[i], termStr), BooleanClause.Occur.SHOULD)); + clauses.Add(new BooleanClause(GetPrefixQuery(fields[i], termStr), BooleanClause.Occur.SHOULD)); } return GetBooleanQuery(clauses, true); } @@ -177,7 +175,7 @@ System.Collections.ArrayList clauses = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); for (int i = 0; i < fields.Length; i++) { - clauses.Add(new BooleanClause(base.GetWildcardQuery(fields[i], termStr), BooleanClause.Occur.SHOULD)); + clauses.Add(new BooleanClause(GetWildcardQuery(fields[i], termStr), BooleanClause.Occur.SHOULD)); } return GetBooleanQuery(clauses, true); } @@ -192,16 +190,13 @@ System.Collections.ArrayList clauses = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); for (int i = 0; i < fields.Length; i++) { - clauses.Add(new BooleanClause(base.GetRangeQuery(fields[i], part1, part2, inclusive), BooleanClause.Occur.SHOULD)); + clauses.Add(new BooleanClause(GetRangeQuery(fields[i], part1, part2, inclusive), BooleanClause.Occur.SHOULD)); } return GetBooleanQuery(clauses, true); } return base.GetRangeQuery(field, part1, part2, inclusive); } - - - /// Parses a query which searches on the fields specified. ///

/// If x fields are specified, this effectively constructs: @@ -230,12 +225,14 @@ { QueryParser qp = new QueryParser(fields[i], analyzer); Query q = qp.Parse(queries[i]); - bQuery.Add(q, BooleanClause.Occur.SHOULD); + if (q != null && (!(q is BooleanQuery) || ((BooleanQuery) q).GetClauses().Length > 0)) + { + bQuery.Add(q, BooleanClause.Occur.SHOULD); + } } return bQuery; } - ///

Parses a query, searching on the fields specified. /// Use this if you need to specify certain fields as required, /// and others as prohibited. @@ -279,12 +276,14 @@ { QueryParser qp = new QueryParser(fields[i], analyzer); Query q = qp.Parse(query); - bQuery.Add(q, flags[i]); + if (q != null && (!(q is BooleanQuery) || ((BooleanQuery) q).GetClauses().Length > 0)) + { + bQuery.Add(q, flags[i]); + } } return bQuery; } - /// Parses a query, searching on the fields specified. /// Use this if you need to specify certain fields as required, /// and others as prohibited. @@ -329,7 +328,10 @@ { QueryParser qp = new QueryParser(fields[i], analyzer); Query q = qp.Parse(queries[i]); - bQuery.Add(q, flags[i]); + if (q != null && (!(q is BooleanQuery) || ((BooleanQuery) q).GetClauses().Length > 0)) + { + bQuery.Add(q, flags[i]); + } } return bQuery; } Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/Package.html URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/Package.html?rev=671403&r1=671402&r2=671403&view=diff ============================================================================== --- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/Package.html (original) +++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/Package.html Tue Jun 24 19:51:48 2008 @@ -1,15 +1,15 @@ - - - - - - - -A simple query parser implemented with JavaCC. -

Note that JavaCC defines lots of public classes, methods and fields -that do not need to be public.  These clutter the documentation.  -Sorry. -

Note that because JavaCC defines a class named Token, Lucene.Net.Analysis.Token -must always be fully qualified in source code in this package. - - + + + + + + + +A simple query parser implemented with JavaCC. +

Note that JavaCC defines lots of public classes, methods and fields +that do not need to be public.  These clutter the documentation.  +Sorry. +

Note that because JavaCC defines a class named Token, org.apache.lucene.analysis.Token +must always be fully qualified in source code in this package. + + Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/ParseException.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/ParseException.cs?rev=671403&r1=671402&r2=671403&view=diff ============================================================================== --- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/ParseException.cs (original) +++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/ParseException.cs Tue Jun 24 19:51:48 2008 @@ -215,7 +215,7 @@ if ((ch = str[i]) < 0x20 || ch > 0x7e) { System.String s = "0000" + System.Convert.ToString(ch, 16); - retval.Append("\\u" + s.Substring(s.Length - 4, (s.Length) - (s.Length - 4))); + retval.Append("\\u").Append(s.Substring(s.Length - 4, (s.Length) - (s.Length - 4))); } else { Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParser.JJ URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/QueryParser.JJ?rev=671403&r1=671402&r2=671403&view=diff ============================================================================== --- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParser.JJ (original) +++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParser.JJ Tue Jun 24 19:51:48 2008 @@ -23,17 +23,17 @@ PARSER_BEGIN(QueryParser) -package Lucene.Net.QueryParsers; +package org.apache.lucene.queryParser; import java.util.Vector; import java.io.*; import java.text.*; import java.util.*; -import Lucene.Net.Index.Term; -import Lucene.Net.Analysis.*; -import Lucene.Net.Documents.*; -import Lucene.Net.Search.*; -import Lucene.Net.Util.Parameter; +import org.apache.lucene.index.Term; +import org.apache.lucene.analysis.*; +import org.apache.lucene.document.*; +import org.apache.lucene.search.*; +import org.apache.lucene.util.Parameter; /** * This class is generated by JavaCC. The most important method is @@ -77,7 +77,7 @@ * By default a date is converted into a search term using the deprecated * {@link DateField} for compatibility reasons. * To use the new {@link DateTools} to convert dates, a - * {@link DateTools.Resolution} has to be set. + * {@link org.apache.lucene.document.DateTools.Resolution} has to be set. *

*

* The date resolution that shall be used for RangeQueries can be set @@ -124,6 +124,7 @@ boolean lowercaseExpandedTerms = true; boolean useOldRangeQuery= false; boolean allowLeadingWildcard = false; + boolean enablePositionIncrements = false; Analyzer analyzer; String field; @@ -159,14 +160,16 @@ field = f; } - /** Parses a query string, returning a {@link Lucene.Net.Search.Query}. + /** Parses a query string, returning a {@link org.apache.lucene.search.Query}. * @param query the query string to be parsed. * @throws ParseException if the parsing fails */ public Query parse(String query) throws ParseException { ReInit(new FastCharStream(new StringReader(query))); try { - return Query(field); + // TopLevelQuery is a Query followed by the end-of-input (EOF) + Query res = TopLevelQuery(field); + return res!=null ? res : new BooleanQuery(); } catch (ParseException tme) { // rethrow to include the original query: @@ -242,22 +245,48 @@ /** - * Set to true to allow * and ? as the first character - * of a PrefixQuery and WildcardQuery. Note that this can produce very slow - * queries on big indexes. Default: false. + * Set to true to allow leading wildcard characters. + *

+ * When set, * or ? are allowed as + * the first character of a PrefixQuery and WildcardQuery. + * Note that this can produce very slow + * queries on big indexes. + *

+ * Default: false. */ public void setAllowLeadingWildcard(boolean allowLeadingWildcard) { this.allowLeadingWildcard = allowLeadingWildcard; } /** - * @see #setAllowLeadingWildcard + * @see #setAllowLeadingWildcard(boolean) */ public boolean getAllowLeadingWildcard() { return allowLeadingWildcard; } /** + * Set to true to enable position increments in result query. + *

+ * When set, result phrase and multi-phrase queries will + * be aware of position increments. + * Useful when e.g. a StopFilter increases the position increment of + * the token that follows an omitted token. + *

+ * Default: false. + */ + public void setEnablePositionIncrements(boolean enable) { + this.enablePositionIncrements = enable; + } + + /** + * @see #setEnablePositionIncrements(boolean) + */ + public boolean getEnablePositionIncrements() { + return enablePositionIncrements; + } + + /** * Sets the boolean operator of the QueryParser. * In default mode (OR_OPERATOR) terms without any modifiers * are considered optional: for example capital of Hungary is equal to @@ -345,7 +374,7 @@ /** * Sets the date resolution used by RangeQueries for a specific field. * - * @param field field for which the date resolution is to be set + * @param fieldName field for which the date resolution is to be set * @param dateResolution date resolution to set */ public void setDateResolution(String fieldName, DateTools.Resolution dateResolution) { @@ -446,7 +475,7 @@ TokenStream source = analyzer.tokenStream(field, new StringReader(queryText)); Vector v = new Vector(); - Lucene.Net.Analysis.Token t; + org.apache.lucene.analysis.Token t; int positionCount = 0; boolean severalTokensAtSamePosition = false; @@ -475,7 +504,7 @@ if (v.size() == 0) return null; else if (v.size() == 1) { - t = (Lucene.Net.Analysis.Token) v.elementAt(0); + t = (org.apache.lucene.analysis.Token) v.elementAt(0); return new TermQuery(new Term(field, t.termText())); } else { if (severalTokensAtSamePosition) { @@ -483,7 +512,7 @@ // no phrase query: BooleanQuery q = new BooleanQuery(true); for (int i = 0; i < v.size(); i++) { - t = (Lucene.Net.Analysis.Token) v.elementAt(i); + t = (org.apache.lucene.analysis.Token) v.elementAt(i); TermQuery currentQuery = new TermQuery( new Term(field, t.termText())); q.add(currentQuery, BooleanClause.Occur.SHOULD); @@ -495,27 +524,42 @@ MultiPhraseQuery mpq = new MultiPhraseQuery(); mpq.setSlop(phraseSlop); List multiTerms = new ArrayList(); + int position = -1; for (int i = 0; i < v.size(); i++) { - t = (Lucene.Net.Analysis.Token) v.elementAt(i); - if (t.getPositionIncrement() == 1 && multiTerms.size() > 0) { - mpq.add((Term[])multiTerms.toArray(new Term[0])); + t = (org.apache.lucene.analysis.Token) v.elementAt(i); + if (t.getPositionIncrement() > 0 && multiTerms.size() > 0) { + if (enablePositionIncrements) { + mpq.add((Term[])multiTerms.toArray(new Term[0]),position); + } else { + mpq.add((Term[])multiTerms.toArray(new Term[0])); + } multiTerms.clear(); } + position += t.getPositionIncrement(); multiTerms.add(new Term(field, t.termText())); } - mpq.add((Term[])multiTerms.toArray(new Term[0])); + if (enablePositionIncrements) { + mpq.add((Term[])multiTerms.toArray(new Term[0]),position); + } else { + mpq.add((Term[])multiTerms.toArray(new Term[0])); + } return mpq; } } else { - PhraseQuery q = new PhraseQuery(); - q.setSlop(phraseSlop); + PhraseQuery pq = new PhraseQuery(); + pq.setSlop(phraseSlop); + int position = -1; for (int i = 0; i < v.size(); i++) { - q.add(new Term(field, ((Lucene.Net.Analysis.Token) - v.elementAt(i)).termText())); - + t = (org.apache.lucene.analysis.Token) v.elementAt(i); + if (enablePositionIncrements) { + position += t.getPositionIncrement(); + pq.add(new Term(field, t.termText()),position); + } else { + pq.add(new Term(field, t.termText())); + } } - return q; + return pq; } } } @@ -632,9 +676,12 @@ protected Query getBooleanQuery(Vector clauses, boolean disableCoord) throws ParseException { + if (clauses.size()==0) { + return null; // all clause words were filtered away by the analyzer. + } BooleanQuery query = new BooleanQuery(disableCoord); for (int i = 0; i < clauses.size(); i++) { - query.add((BooleanClause)clauses.elementAt(i)); + query.add((BooleanClause)clauses.elementAt(i)); } return query; } @@ -818,10 +865,10 @@ StringBuffer sb = new StringBuffer(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); - // NOTE: keep this in sync with _ESCAPED_CHAR below! + // These characters are part of the query syntax and must be escaped if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~' - || c == '*' || c == '?') { + || c == '*' || c == '?' || c == '|' || c == '&') { sb.append('\\'); } sb.append(c); @@ -830,17 +877,17 @@ } /** - * Command line tool to test QueryParser, using {@link Lucene.Net.Analysis.SimpleAnalyzer}. + * Command line tool to test QueryParser, using {@link org.apache.lucene.analysis.SimpleAnalyzer}. * Usage:
- * java Lucene.Net.QueryParsers.QueryParser <input> + * java org.apache.lucene.queryParser.QueryParser <input> */ public static void main(String[] args) throws Exception { if (args.length == 0) { - System.out.println("Usage: java Lucene.Net.QueryParsers.QueryParser "); + System.out.println("Usage: java org.apache.lucene.queryParser.QueryParser "); System.exit(0); } QueryParser qp = new QueryParser("field", - new Lucene.Net.Analysis.SimpleAnalyzer()); + new org.apache.lucene.analysis.SimpleAnalyzer()); Query q = qp.parse(args[0]); System.out.println(q.toString("field")); } @@ -854,11 +901,10 @@ <*> TOKEN : { <#_NUM_CHAR: ["0"-"9"] > -// NOTE: keep this in sync with escape(String) above! -| <#_ESCAPED_CHAR: "\\" [ "\\", "+", "-", "!", "(", ")", ":", "^", - "[", "]", "\"", "{", "}", "~", "*", "?" ] > +// every character that follows a backslash is considered as an escaped character +| <#_ESCAPED_CHAR: "\\" ~[] > | <#_TERM_START_CHAR: ( ~[ " ", "\t", "\n", "\r", "+", "-", "!", "(", ")", ":", "^", - "[", "]", "\"", "{", "}", "~", "*", "?" ] + "[", "]", "\"", "{", "}", "~", "*", "?", "\\" ] | <_ESCAPED_CHAR> ) > | <#_TERM_CHAR: ( <_TERM_START_CHAR> | <_ESCAPED_CHAR> | "-" | "+" ) > | <#_WHITESPACE: ( " " | "\t" | "\n" | "\r") > @@ -879,10 +925,10 @@ | | | : Boost -| +| | (<_TERM_CHAR>)* > | )+ ( "." (<_NUM_CHAR>)+ )? )? > -| | "*") (<_TERM_CHAR>)* "*" > +| (<_TERM_CHAR>)* "*" ) > | | [ "*", "?" ]) (<_TERM_CHAR> | ( [ "*", "?" ] ))* > | : RangeIn | : RangeEx @@ -932,6 +978,18 @@ { return ret; } } +// This makes sure that there is no garbage after the query string +Query TopLevelQuery(String field) : +{ + Query q; +} +{ + q=Query(field) + { + return q; + } +} + Query Query(String field) : { Vector clauses = new Vector(); Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParser.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/QueryParser.cs?rev=671403&r1=671402&r2=671403&view=diff ============================================================================== --- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParser.cs (original) +++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParser.cs Tue Jun 24 19:51:48 2008 @@ -19,12 +19,12 @@ using System; +using Lucene.Net.Documents; using Term = Lucene.Net.Index.Term; +using Parameter = Lucene.Net.Util.Parameter; using Lucene.Net.Analysis; -using Lucene.Net.Documents; using Lucene.Net.Search; using Searchable = Lucene.Net.Search.Searchable; -using Parameter = Lucene.Net.Util.Parameter; namespace Lucene.Net.QueryParsers { @@ -70,7 +70,7 @@ /// By default a date is converted into a search term using the deprecated /// {@link DateField} for compatibility reasons. /// To use the new {@link DateTools} to convert dates, a - /// {@link DateTools.Resolution} has to be set. + /// {@link Lucene.Net.Documents.DateTools.Resolution} has to be set. ///

///

/// The date resolution that shall be used for RangeQueries can be set @@ -128,6 +128,7 @@ internal bool lowercaseExpandedTerms = true; internal bool useOldRangeQuery = false; internal bool allowLeadingWildcard = false; + internal bool enablePositionIncrements = false; internal Analyzer analyzer; internal System.String field; @@ -175,7 +176,9 @@ ReInit(new FastCharStream(new System.IO.StringReader(query))); try { - return Query(field); + // TopLevelQuery is a Query followed by the end-of-input (EOF) + Query res = TopLevelQuery(field); + return res != null ? res : new BooleanQuery(); } catch (ParseException tme) { @@ -251,22 +254,48 @@ } - ///

Set to true to allow * and ? as the first character - /// of a PrefixQuery and WildcardQuery. Note that this can produce very slow - /// queries on big indexes. Default: false. + /// Set to true to allow leading wildcard characters. + ///

+ /// When set, * or ? are allowed as + /// the first character of a PrefixQuery and WildcardQuery. + /// Note that this can produce very slow + /// queries on big indexes. + ///

+ /// Default: false. ///

public virtual void SetAllowLeadingWildcard(bool allowLeadingWildcard) { this.allowLeadingWildcard = allowLeadingWildcard; } - /// + /// /// public virtual bool GetAllowLeadingWildcard() { return allowLeadingWildcard; } + /// Set to true to enable position increments in result query. + ///

+ /// When set, result phrase and multi-phrase queries will + /// be aware of position increments. + /// Useful when e.g. a StopFilter increases the position increment of + /// the token that follows an omitted token. + ///

+ /// Default: false. + ///

+ public virtual void SetEnablePositionIncrements(bool enable) + { + this.enablePositionIncrements = enable; + } + + /// + /// + public virtual bool GetEnablePositionIncrements() + { + return enablePositionIncrements; + } + /// Sets the boolean operator of the QueryParser. /// In default mode (OR_OPERATOR) terms without any modifiers /// are considered optional: for example capital of Hungary is equal to @@ -319,7 +348,7 @@ } - /// + /// /// public virtual bool GetUseOldRangeQuery() { @@ -354,7 +383,7 @@ /// Sets the date resolution used by RangeQueries for a specific field. /// /// - /// field for which the date resolution is to be set + /// field for which the date resolution is to be set /// /// date resolution to set /// @@ -529,29 +558,55 @@ MultiPhraseQuery mpq = new MultiPhraseQuery(); mpq.SetSlop(phraseSlop); System.Collections.ArrayList multiTerms = new System.Collections.ArrayList(); + int position = - 1; for (int i = 0; i < v.Count; i++) { t = (Lucene.Net.Analysis.Token) v[i]; - if (t.GetPositionIncrement() == 1 && multiTerms.Count > 0) + if (t.GetPositionIncrement() > 0 && multiTerms.Count > 0) { - mpq.Add((Term[]) multiTerms.ToArray(typeof(Term))); + if (enablePositionIncrements) + { + mpq.Add((Term[])multiTerms.ToArray(typeof(Term)), position); + } + else + { + mpq.Add((Term[])multiTerms.ToArray(typeof(Term))); + } multiTerms.Clear(); } + position += t.GetPositionIncrement(); multiTerms.Add(new Term(field, t.TermText())); } - mpq.Add((Term[]) multiTerms.ToArray(typeof(Term))); + if (enablePositionIncrements) + { + mpq.Add((Term[])multiTerms.ToArray(typeof(Term)), position); + } + else + { + mpq.Add((Term[])multiTerms.ToArray(typeof(Term))); + } return mpq; } } else { - PhraseQuery q = new PhraseQuery(); - q.SetSlop(phraseSlop); + PhraseQuery pq = new PhraseQuery(); + pq.SetSlop(phraseSlop); + int position = - 1; for (int i = 0; i < v.Count; i++) { - q.Add(new Term(field, ((Lucene.Net.Analysis.Token) v[i]).TermText())); + t = (Lucene.Net.Analysis.Token) v[i]; + if (enablePositionIncrements) + { + position += t.GetPositionIncrement(); + pq.Add(new Term(field, t.TermText()), position); + } + else + { + pq.Add(new Term(field, t.TermText())); + } } - return q; + return pq; } } } @@ -562,7 +617,7 @@ /// a SpanNearQuery instead of a PhraseQuery. /// /// - /// ParseException throw in overridden method to disallow + /// throw in overridden method to disallow /// public virtual Query GetFieldQuery(System.String field, System.String queryText, int slop) { @@ -581,7 +636,7 @@ } - /// ParseException throw in overridden method to disallow + /// throw in overridden method to disallow /// public virtual Query GetRangeQuery(System.String field, System.String part1, System.String part2, bool inclusive) { @@ -666,7 +721,7 @@ /// /// Resulting {@link Query} object. /// - /// ParseException throw in overridden method to disallow + /// throw in overridden method to disallow /// public virtual Query GetBooleanQuery(System.Collections.ArrayList clauses) { @@ -692,6 +747,10 @@ /// public virtual Query GetBooleanQuery(System.Collections.ArrayList clauses, bool disableCoord) { + if (clauses.Count == 0) + { + return null; // all clause words were filtered away by the analyzer. + } BooleanQuery query = new BooleanQuery(disableCoord); for (int i = 0; i < clauses.Count; i++) { @@ -722,7 +781,7 @@ /// /// Resulting {@link Query} built for the term /// - /// ParseException throw in overridden method to disallow + /// throw in overridden method to disallow /// public virtual Query GetWildcardQuery(System.String field, System.String termStr) { @@ -765,7 +824,7 @@ /// /// Resulting {@link Query} built for the term /// - /// ParseException throw in overridden method to disallow + /// throw in overridden method to disallow /// public virtual Query GetPrefixQuery(System.String field, System.String termStr) { @@ -792,7 +851,7 @@ /// /// Resulting {@link Query} built for the term /// - /// ParseException throw in overridden method to disallow + /// throw in overridden method to disallow /// public virtual Query GetFuzzyQuery(System.String field, System.String termStr, float minSimilarity) { @@ -917,8 +976,8 @@ for (int i = 0; i < s.Length; i++) { char c = s[i]; - // NOTE: keep this in sync with _ESCAPED_CHAR below! - if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~' || c == '*' || c == '?') + // These characters are part of the query syntax and must be escaped + if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~' || c == '*' || c == '?' || c == '|' || c == '&') { sb.Append('\\'); } @@ -985,7 +1044,7 @@ if (true) return ret; } - throw new System.ApplicationException("Missing return statement in function"); + //// throw new System.ApplicationException("Missing return statement in function"); } public int Modifiers() @@ -1033,7 +1092,20 @@ if (true) return ret; } - throw new System.ApplicationException("Missing return statement in function"); + //// throw new System.ApplicationException("Missing return statement in function"); + } + + // This makes sure that there is no garbage after the query string + public Query TopLevelQuery(System.String field) + { + Query q; + q = Query(field); + Jj_consume_token(0); + { + if (true) + return q; + } + //// throw new System.ApplicationException("Missing return statement in function"); } public Query Query(System.String field) @@ -1093,7 +1165,7 @@ return GetBooleanQuery(clauses); } } - throw new System.ApplicationException("Missing return statement in function"); + //// throw new System.ApplicationException("Missing return statement in function"); } public Query Clause(System.String field) @@ -1102,7 +1174,7 @@ Token fieldToken = null, boost = null; if (Jj_2_1(2)) { - switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk) + switch ((jj_ntk == - 1) ? Jj_ntk() : jj_ntk) { case Lucene.Net.QueryParsers.QueryParserConstants.TERM: @@ -1184,7 +1256,7 @@ if (true) return q; } - throw new System.ApplicationException("Missing return statement in function"); + //// throw new System.ApplicationException("Missing return statement in function"); } public Query Term(System.String field) @@ -1536,7 +1608,7 @@ if (true) return q; } - throw new System.ApplicationException("Missing return statement in function"); + //// throw new System.ApplicationException("Missing return statement in function"); } private bool Jj_2_1(int xla) @@ -1556,15 +1628,6 @@ } } - private bool Jj_3R_3() - { - if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.STAR)) - return true; - if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.COLON)) - return true; - return false; - } - private bool Jj_3R_2() { if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.TERM)) @@ -1587,6 +1650,15 @@ return false; } + private bool Jj_3R_3() + { + if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.STAR)) + return true; + if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.COLON)) + return true; + return false; + } + public QueryParserTokenManager token_source; public Token token, jj_nt; private int jj_ntk; Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParserTokenManager.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/QueryParserTokenManager.cs?rev=671403&r1=671402&r2=671403&view=diff ============================================================================== --- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParserTokenManager.cs (original) +++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParserTokenManager.cs Tue Jun 24 19:51:48 2008 @@ -19,12 +19,12 @@ using System; +using Lucene.Net.Documents; using Term = Lucene.Net.Index.Term; +using Parameter = Lucene.Net.Util.Parameter; using Lucene.Net.Analysis; -using Lucene.Net.Documents; using Lucene.Net.Search; using Searchable = Lucene.Net.Search.Searchable; -using Parameter = Lucene.Net.Util.Parameter; namespace Lucene.Net.QueryParsers { @@ -89,7 +89,7 @@ return JjStopAtPos(0, 13); case (char) (42): - return JjStartNfaWithStates_3(0, 15, 37); + return JjStartNfaWithStates_3(0, 15, 36); case (char) (43): return JjStopAtPos(0, 10); @@ -154,7 +154,7 @@ { int[] nextStates; int startsAt = 0; - jjnewStateCnt = 37; + jjnewStateCnt = 36; int i = 1; jjstateSet[0] = startState; int j, kind = 0x7fffffff; @@ -164,27 +164,21 @@ ReInitRounds(); if (curChar < 64) { - ulong l = ((ulong) 1L) << curChar; -MatchLoop: + ulong l = (ulong) (1L << (int) curChar); + +//// MatchLoop: do { switch (jjstateSet[--i]) { - case 37: - if ((0xfbfffcf8ffffd9ffL & l) != (ulong) 0L) - { - if (kind > 21) - kind = 21; - JjCheckNAddTwoStates(33, 34); - } - if ((0x7bfff8f8ffffd9ffL & l) != (ulong) 0L) - JjCheckNAddStates(0, 2); - else if (curChar == 42) - { - if (kind > 20) - kind = 20; - } + case 36: + case 25: + if ((0xfbfffcf8ffffd9ffL & l) == (ulong) 0L) + break; + if (kind > 21) + kind = 21; + JjCheckNAddTwoStates(25, 26); break; case 0: @@ -192,7 +186,7 @@ { if (kind > 21) kind = 21; - JjCheckNAddTwoStates(33, 34); + JjCheckNAddTwoStates(25, 26); } else if ((0x100002600L & l) != (ulong) 0L) { @@ -200,19 +194,22 @@ kind = 6; } else if (curChar == 34) - JjCheckNAddTwoStates(15, 17); + JjCheckNAddStates(0, 2); else if (curChar == 33) { if (kind > 9) kind = 9; } - if ((0x7bffd4f8ffffd9ffL & l) != (ulong) 0L) - JjCheckNAddStates(0, 2); if ((0x7bffd0f8ffffd9ffL & l) != (ulong) 0L) { if (kind > 18) kind = 18; - JjCheckNAddTwoStates(20, 21); + JjCheckNAddStates(3, 7); + } + else if (curChar == 42) + { + if (kind > 20) + kind = 20; } if (curChar == 38) jjstateSet[jjnewStateCnt++] = 4; @@ -234,18 +231,14 @@ break; case 14: + case 16: if (curChar == 34) - JjCheckNAddTwoStates(15, 17); + JjCheckNAddStates(0, 2); break; case 15: if ((0xfffffffbffffffffL & l) != (ulong) 0L) - JjCheckNAddStates(3, 5); - break; - - case 16: - if (curChar == 34) - JjCheckNAddStates(3, 5); + JjCheckNAddStates(0, 2); break; case 18: @@ -253,93 +246,75 @@ kind = 17; break; - case 19: - if ((0x7bffd0f8ffffd9ffL & l) == (ulong) 0L) - break; - if (kind > 18) - kind = 18; - JjCheckNAddTwoStates(20, 21); - break; - case 20: - if ((0x7bfff8f8ffffd9ffL & l) == (ulong) 0L) + if ((0x3ff000000000000L & l) == (ulong) 0L) break; - if (kind > 18) - kind = 18; - JjCheckNAddTwoStates(20, 21); + if (kind > 19) + kind = 19; + JjAddStates(8, 9); break; - case 22: - if ((0x84002f0600000000L & l) == (ulong) 0L) - break; - if (kind > 18) - kind = 18; - JjCheckNAddTwoStates(20, 21); + case 21: + if (curChar == 46) + JjCheckNAdd(22); break; - case 24: + case 22: if ((0x3ff000000000000L & l) == (ulong) 0L) break; if (kind > 19) kind = 19; - JjAddStates(6, 7); + JjCheckNAdd(22); break; - case 25: - if (curChar == 46) - JjCheckNAdd(26); + case 23: + if (curChar == 42 && kind > 20) + kind = 20; break; - case 26: - if ((0x3ff000000000000L & l) == (ulong) 0L) + case 24: + if ((0xfbffd4f8ffffd9ffL & l) == (ulong) 0L) break; - if (kind > 19) - kind = 19; - JjCheckNAdd(26); + if (kind > 21) + kind = 21; + JjCheckNAddTwoStates(25, 26); break; case 27: - if ((0x7bffd4f8ffffd9ffL & l) != (ulong) 0L) - JjCheckNAddStates(0, 2); + if (kind > 21) + kind = 21; + JjCheckNAddTwoStates(25, 26); break; case 28: - if ((0x7bfff8f8ffffd9ffL & l) != (ulong) 0L) - JjCheckNAddStates(0, 2); + if ((0x7bffd0f8ffffd9ffL & l) == (ulong) 0L) + break; + if (kind > 18) + kind = 18; + JjCheckNAddStates(3, 7); break; case 29: - if (curChar == 42 && kind > 20) - kind = 20; + if ((0x7bfff8f8ffffd9ffL & l) == (ulong) 0L) + break; + if (kind > 18) + kind = 18; + JjCheckNAddTwoStates(29, 30); break; case 31: - if ((0x84002f0600000000L & l) != (ulong) 0L) - JjCheckNAddStates(0, 2); + if (kind > 18) + kind = 18; + JjCheckNAddTwoStates(29, 30); break; case 32: - if ((0xfbffd4f8ffffd9ffL & l) == (ulong) 0L) - break; - if (kind > 21) - kind = 21; - JjCheckNAddTwoStates(33, 34); - break; - - case 33: - if ((0xfbfffcf8ffffd9ffL & l) == (ulong) 0L) - break; - if (kind > 21) - kind = 21; - JjCheckNAddTwoStates(33, 34); + if ((0x7bfff8f8ffffd9ffL & l) != (ulong) 0L) + JjCheckNAddStates(10, 12); break; - case 35: - if ((0x84002f0600000000L & l) == (ulong) 0L) - break; - if (kind > 21) - kind = 21; - JjCheckNAddTwoStates(33, 34); + case 34: + JjCheckNAddStates(10, 12); break; default: break; @@ -350,52 +325,47 @@ } else if (curChar < 128) { - ulong l = ((ulong) 1L) << (curChar & 63); -MatchLoop1: + ulong l = ((ulong) 1L) << (curChar & 63); + +//// MatchLoop1: do { switch (jjstateSet[--i]) { - case 37: - if ((0x97ffffff97ffffffL & l) != (ulong) 0L) + case 36: + if ((0x97ffffff87ffffffL & l) != (ulong) 0L) { if (kind > 21) kind = 21; - JjCheckNAddTwoStates(33, 34); + JjCheckNAddTwoStates(25, 26); } - if ((0x97ffffff97ffffffL & l) != (ulong) 0L) - JjCheckNAddStates(0, 2); - if (curChar == 92) - JjCheckNAddTwoStates(31, 31); - if (curChar == 92) - JjCheckNAddTwoStates(35, 35); + else if (curChar == 92) + JjCheckNAddTwoStates(27, 27); break; case 0: - if ((0x97ffffff97ffffffL & l) != (ulong) 0L) + if ((0x97ffffff87ffffffL & l) != (ulong) 0L) { - if (kind > 21) - kind = 21; - JjCheckNAddTwoStates(33, 34); + if (kind > 18) + kind = 18; + JjCheckNAddStates(3, 7); } + else if (curChar == 92) + JjCheckNAddStates(13, 15); else if (curChar == 126) { if (kind > 19) kind = 19; - jjstateSet[jjnewStateCnt++] = 24; + jjstateSet[jjnewStateCnt++] = 20; } - if ((0x97ffffff97ffffffL & l) != (ulong) 0L) - JjCheckNAddStates(0, 2); - if ((0x97ffffff97ffffffL & l) != (ulong) 0L) + if ((0x97ffffff87ffffffL & l) != (ulong) 0L) { - if (kind > 18) - kind = 18; - JjCheckNAddTwoStates(20, 21); + if (kind > 21) + kind = 21; + JjCheckNAddTwoStates(25, 26); } - if (curChar == 92) - JjCheckNAddStates(8, 10); - else if (curChar == 78) + if (curChar == 78) jjstateSet[jjnewStateCnt++] = 11; else if (curChar == 124) jjstateSet[jjnewStateCnt++] = 8; @@ -456,7 +426,7 @@ break; case 15: - JjAddStates(3, 5); + JjAddStates(0, 2); break; case 17: @@ -465,43 +435,54 @@ break; case 19: - case 20: - if ((0x97ffffff97ffffffL & l) == (ulong) 0L) + if (curChar != 126) break; - if (kind > 18) - kind = 18; - JjCheckNAddTwoStates(20, 21); + if (kind > 19) + kind = 19; + jjstateSet[jjnewStateCnt++] = 20; break; - case 21: - if (curChar == 92) - JjCheckNAddTwoStates(22, 22); + case 24: + if ((0x97ffffff87ffffffL & l) == (ulong) 0L) + break; + if (kind > 21) + kind = 21; + JjCheckNAddTwoStates(25, 26); break; - case 22: - if ((0x6800000078000000L & l) == (ulong) 0L) + case 25: + if ((0x97ffffff87ffffffL & l) == (ulong) 0L) break; - if (kind > 18) - kind = 18; - JjCheckNAddTwoStates(20, 21); + if (kind > 21) + kind = 21; + JjCheckNAddTwoStates(25, 26); break; - case 23: - if (curChar != 126) - break; - if (kind > 19) - kind = 19; - jjstateSet[jjnewStateCnt++] = 24; + case 26: + if (curChar == 92) + JjCheckNAddTwoStates(27, 27); break; case 27: - if ((0x97ffffff97ffffffL & l) != (ulong) 0L) - JjCheckNAddStates(0, 2); + if (kind > 21) + kind = 21; + JjCheckNAddTwoStates(25, 26); break; case 28: - if ((0x97ffffff97ffffffL & l) != (ulong) 0L) - JjCheckNAddStates(0, 2); + if ((0x97ffffff87ffffffL & l) == (ulong) 0L) + break; + if (kind > 18) + kind = 18; + JjCheckNAddStates(3, 7); + break; + + case 29: + if ((0x97ffffff87ffffffL & l) == (ulong) 0L) + break; + if (kind > 18) + kind = 18; + JjCheckNAddTwoStates(29, 30); break; case 30: @@ -510,42 +491,28 @@ break; case 31: - if ((0x6800000078000000L & l) != 0L) - JjCheckNAddStates(0, 2); + if (kind > 18) + kind = 18; + JjCheckNAddTwoStates(29, 30); break; case 32: - if ((0x97ffffff97ffffffL & l) == (ulong) 0L) - break; - if (kind > 21) - kind = 21; - JjCheckNAddTwoStates(33, 34); + if ((0x97ffffff87ffffffL & l) != (ulong) 0L) + JjCheckNAddStates(10, 12); break; case 33: - if ((0x97ffffff97ffffffL & l) == (ulong) 0L) - break; - if (kind > 21) - kind = 21; - JjCheckNAddTwoStates(33, 34); + if (curChar == 92) + JjCheckNAddTwoStates(34, 34); break; case 34: - if (curChar == 92) - JjCheckNAddTwoStates(35, 35); + JjCheckNAddStates(10, 12); break; case 35: - if ((0x6800000078000000L & l) == (ulong) 0L) - break; - if (kind > 21) - kind = 21; - JjCheckNAddTwoStates(33, 34); - break; - - case 36: if (curChar == 92) - JjCheckNAddStates(8, 10); + JjCheckNAddStates(13, 15); break; default: break; @@ -560,79 +527,73 @@ int i1 = hiByte >> 6; ulong l1 = ((ulong) 1L) << (hiByte & 63); int i2 = (curChar & 0xff) >> 6; - ulong l2 = ((ulong) 1L) << (curChar & 63); -MatchLoop1: + ulong l2 = ((ulong) 1L) << (curChar & 63); + +//// MatchLoop1: do { switch (jjstateSet[--i]) { - case 37: - if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2)) - JjCheckNAddStates(0, 2); + case 36: + case 25: + case 27: + if (!JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2)) + break; + if (kind > 21) + kind = 21; + JjCheckNAddTwoStates(25, 26); + break; + + case 0: if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2)) { if (kind > 21) kind = 21; - JjCheckNAddTwoStates(33, 34); + JjCheckNAddTwoStates(25, 26); } - break; - - case 0: if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2)) { if (kind > 18) kind = 18; - JjCheckNAddTwoStates(20, 21); - } - if (JjCanMove_0(hiByte, i1, i2, l1, l2)) - JjCheckNAddStates(0, 2); - if (JjCanMove_0(hiByte, i1, i2, l1, l2)) - { - if (kind > 21) - kind = 21; - JjCheckNAddTwoStates(33, 34); + JjCheckNAddStates(3, 7); } break; case 15: if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2)) - JjAddStates(3, 5); + JjAddStates(0, 2); break; - case 19: - case 20: + case 24: if (!JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2)) break; - if (kind > 18) - kind = 18; - JjCheckNAddTwoStates(20, 21); - break; - - case 27: - if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2)) - JjCheckNAddStates(0, 2); + if (kind > 21) + kind = 21; + JjCheckNAddTwoStates(25, 26); break; case 28: - if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2)) - JjCheckNAddStates(0, 2); - break; - - case 32: if (!JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2)) break; - if (kind > 21) - kind = 21; - JjCheckNAddTwoStates(33, 34); + if (kind > 18) + kind = 18; + JjCheckNAddStates(3, 7); break; - case 33: - if (!JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2)) + case 29: + case 31: + if (!JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) 2)) break; - if (kind > 21) - kind = 21; - JjCheckNAddTwoStates(33, 34); + if (kind > 18) + kind = 18; + JjCheckNAddTwoStates(29, 30); + break; + + case 32: + case 34: + if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2)) + JjCheckNAddStates(10, 12); break; default: break; @@ -648,7 +609,7 @@ kind = 0x7fffffff; } ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 37 - (jjnewStateCnt = startsAt))) + if ((i = jjnewStateCnt) == (startsAt = 36 - (jjnewStateCnt = startsAt))) return curPos; try { @@ -690,7 +651,7 @@ { curChar = input_stream.ReadChar(); } - catch (System.IO.IOException) + catch (System.IO.IOException e) { return pos + 1; } @@ -718,7 +679,7 @@ { curChar = input_stream.ReadChar(); } - catch (System.IO.IOException) + catch (System.IO.IOException e) { JjStopStringLiteralDfa_1(0, (ulong) active0); return 1; @@ -751,8 +712,9 @@ ReInitRounds(); if (curChar < 64) { - ulong l = ((ulong) 1L) << curChar; -MatchLoop1: + ulong l = ((ulong) 1L) << curChar; + +//// MatchLoop1: do { switch (jjstateSet[--i]) @@ -781,12 +743,12 @@ case 2: if ((0xfffffffbffffffffL & l) != (ulong) 0L) - JjCheckNAddStates(11, 13); + JjCheckNAddStates(16, 18); break; case 3: if (curChar == 34) - JjCheckNAddStates(11, 13); + JjCheckNAddStates(16, 18); break; case 5: @@ -810,8 +772,9 @@ } else if (curChar < 128) { - ulong l = ((ulong) 1L) << (curChar & 63); -MatchLoop1: + ulong l = ((ulong) 1L) << (curChar & 63); + +/// MatchLoop1: do { switch (jjstateSet[--i]) @@ -827,7 +790,7 @@ break; case 2: - JjAddStates(11, 13); + JjAddStates(16, 18); break; case 4: @@ -847,8 +810,9 @@ int i1 = hiByte >> 6; ulong l1 = ((ulong) 1L) << (hiByte & 63); int i2 = (curChar & 0xff) >> 6; - ulong l2 = ((ulong) 1L) << (curChar & 63); -MatchLoop1: + ulong l2 = ((ulong) 1L) << (curChar & 63); + +//// MatchLoop1: do { switch (jjstateSet[--i]) @@ -865,7 +829,7 @@ case 2: if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2)) - JjAddStates(11, 13); + JjAddStates(16, 18); break; default: break; @@ -887,7 +851,7 @@ { curChar = input_stream.ReadChar(); } - catch (System.IO.IOException) + catch (System.IO.IOException e) { return curPos; } @@ -911,8 +875,9 @@ ReInitRounds(); if (curChar < 64) { - ulong l = ((ulong) 1L) << curChar; -MatchLoop1: + ulong l = ((ulong) 1L) << curChar; + +//// MatchLoop1: do { switch (jjstateSet[--i]) @@ -923,7 +888,7 @@ break; if (kind > 24) kind = 24; - JjAddStates(14, 15); + JjAddStates(19, 20); break; case 1: @@ -947,8 +912,9 @@ } else if (curChar < 128) { - ulong l = ((ulong) 1L) << (curChar & 63); -MatchLoop1: + ulong l = ((ulong) 1L) << (curChar & 63); + +//// MatchLoop1: do { switch (jjstateSet[--i]) @@ -966,8 +932,9 @@ int i1 = hiByte >> 6; ulong l1 = ((ulong) 1L) << (hiByte & 63); int i2 = (curChar & 0xff) >> 6; - ulong l2 = ((ulong) 1L) << (curChar & 63); -MatchLoop1: + ulong l2 = ((ulong) 1L) << (curChar & 63); + +//// MatchLoop1: do { switch (jjstateSet[--i]) @@ -1089,8 +1056,9 @@ ReInitRounds(); if (curChar < 64) { - ulong l = ((ulong) 1L) << curChar; -MatchLoop1: + ulong l = ((ulong) 1L) << curChar; + +//// MatchLoop1: do { switch (jjstateSet[--i]) @@ -1119,12 +1087,12 @@ case 2: if ((0xfffffffbffffffffL & l) != (ulong) 0L) - JjCheckNAddStates(11, 13); + JjCheckNAddStates(16, 18); break; case 3: if (curChar == 34) - JjCheckNAddStates(11, 13); + JjCheckNAddStates(16, 18); break; case 5: @@ -1148,8 +1116,9 @@ } else if (curChar < 128) { - ulong l = ((ulong) 1L) << (curChar & 63); -MatchLoop1: + ulong l = ((ulong) 1L) << (curChar & 63); + +//// MatchLoop1: do { switch (jjstateSet[--i]) @@ -1165,7 +1134,7 @@ break; case 2: - JjAddStates(11, 13); + JjAddStates(16, 18); break; case 4: @@ -1185,8 +1154,9 @@ int i1 = hiByte >> 6; ulong l1 = ((ulong) 1L) << (hiByte & 63); int i2 = (curChar & 0xff) >> 6; - ulong l2 = ((ulong) 1L) << (curChar & 63); -MatchLoop1: + ulong l2 = ((ulong) 1L) << (curChar & 63); + +//// MatchLoop1: do { switch (jjstateSet[--i]) @@ -1203,7 +1173,7 @@ case 2: if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2)) - JjAddStates(11, 13); + JjAddStates(16, 18); break; default: break; @@ -1231,7 +1201,7 @@ } } } - internal static readonly int[] jjnextStates = new int[]{28, 29, 30, 15, 17, 18, 24, 25, 22, 31, 35, 2, 4, 5, 0, 1}; + internal static readonly int[] jjnextStates = new int[]{15, 17, 18, 29, 32, 23, 33, 30, 20, 21, 32, 23, 33, 31, 34, 27, 2, 4, 5, 0, 1}; private static bool JjCanMove_0(int hiByte, int i1, int i2, ulong l1, ulong l2) { switch (hiByte) @@ -1253,8 +1223,8 @@ internal static readonly ulong[] jjtoToken = new ulong[]{0x1ffffff81L}; internal static readonly long[] jjtoSkip = new long[]{0x40L}; protected internal CharStream input_stream; - private uint[] jjrounds = new uint[37]; - private int[] jjstateSet = new int[74]; + private uint[] jjrounds = new uint[36]; + private int[] jjstateSet = new int[72]; protected internal char curChar; public QueryParserTokenManager(CharStream stream) { @@ -1276,7 +1246,7 @@ { int i; jjround = 0x80000001; - for (i = 37; i-- > 0; ) + for (i = 36; i-- > 0; ) jjrounds[i] = 0x80000000; } public virtual void ReInit(CharStream stream, int lexState) @@ -1294,7 +1264,7 @@ protected internal virtual Token JjFillToken() { - Token t = Token.newToken(jjmatchedKind); + Token t = Token.NewToken(jjmatchedKind); t.kind = jjmatchedKind; System.String im = jjstrLiteralImages[jjmatchedKind]; t.image = (im == null) ? input_stream.GetImage() : im; Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/Token.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/Token.cs?rev=671403&r1=671402&r2=671403&view=diff ============================================================================== --- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/Token.cs (original) +++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/Token.cs Tue Jun 24 19:51:48 2008 @@ -81,7 +81,7 @@ /// to the following switch statement. Then you can cast matchedToken /// variable to the appropriate type and use it in your lexical actions. ///
- public static Token newToken(int ofKind) + public static Token NewToken(int ofKind) { switch (ofKind) { Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/TokenMgrError.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/TokenMgrError.cs?rev=671403&r1=671402&r2=671403&view=diff ============================================================================== --- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/TokenMgrError.cs (original) +++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/TokenMgrError.cs Tue Jun 24 19:51:48 2008 @@ -113,7 +113,7 @@ if ((ch = str[i]) < 0x20 || ch > 0x7e) { System.String s = "0000" + System.Convert.ToString(ch, 16); - retval.Append("\\u" + s.Substring(s.Length - 4, (s.Length) - (s.Length - 4))); + retval.Append("\\u").Append(s.Substring(s.Length - 4, (s.Length) - (s.Length - 4))); } else { @@ -139,7 +139,7 @@ ///
protected internal static System.String LexicalError(bool EOFSeen, int lexState, int errorLine, int errorColumn, System.String errorAfter, char curChar) { - return ("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen?" ":("\"" + addEscapes(System.Convert.ToString(curChar)) + "\"") + " (" + (int) curChar + "), ") + "after : \"" + addEscapes(errorAfter) + "\""); + return ("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen ? " " : ("\"" + addEscapes(System.Convert.ToString(curChar)) + "\"") + " (" + (int) curChar + "), ") + "after : \"" + addEscapes(errorAfter) + "\""); } /*