2 * Copyright 2004 The Apache Software Foundation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /* Generated By:JavaCC: Do not edit this line. QueryParser.java */
20 using Lucene
.Net
.Analysis
;
21 using Lucene
.Net
.Documents
;
22 using Term
= Lucene
.Net
.Index
.Term
;
23 using Lucene
.Net
.Search
;
24 using Searchable
= Lucene
.Net
.Search
.Searchable
;
25 using Parameter
= Lucene
.Net
.Util
.Parameter
;
27 namespace Lucene
.Net
.QueryParsers
30 /// <summary> This class is generated by JavaCC. The most important method is
31 /// {@link #Parse(String)}.
33 /// The syntax for query strings is as follows:
34 /// A Query is a series of clauses.
35 /// A clause may be prefixed by:
37 /// <li> a plus (<code>+</code>) or a minus (<code>-</code>) sign, indicating
38 /// that the clause is required or prohibited respectively; or
39 /// <li> a term followed by a colon, indicating the field to be searched.
40 /// This enables one to construct queries which search multiple fields.
43 /// A clause may be either:
45 /// <li> a term, indicating all the documents that contain this term; or
46 /// <li> a nested query, enclosed in parentheses. Note that this may be used
47 /// with a <code>+</code>/<code>-</code> prefix to require any of a set of
51 /// Thus, in BNF, the query grammar is:
53 /// Query ::= ( Clause )*
54 /// Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )
58 /// Examples of appropriately formatted queries can be found in the <a
59 /// href="http://lucene.apache.org/java/docs/queryparsersyntax.html">query syntax
60 /// documentation</a>.
63 /// <p>Note that QueryParser is <em>not</em> thread-safe.</p>
66 /// <author> Brian Goetz
68 /// <author> Peter Halacsy
70 /// <author> Tatu Saloranta
73 public class QueryParser
: QueryParserConstants
75 private void InitBlock()
77 fuzzyMinSim
= FuzzyQuery
.defaultMinSimilarity
;
78 fuzzyPrefixLength
= FuzzyQuery
.defaultPrefixLength
;
79 jj_2_rtns
= new JJCalls
[1];
80 jj_ls
= new LookaheadSuccess();
83 private const int CONJ_NONE
= 0;
84 private const int CONJ_AND
= 1;
85 private const int CONJ_OR
= 2;
87 private const int MOD_NONE
= 0;
88 private const int MOD_NOT
= 10;
89 private const int MOD_REQ
= 11;
91 /// <deprecated> use {@link #OR_OPERATOR} instead
93 public const int DEFAULT_OPERATOR_OR
= 0;
94 /// <deprecated> use {@link #AND_OPERATOR} instead
96 public const int DEFAULT_OPERATOR_AND
= 1;
98 // make it possible to call setDefaultOperator() without accessing
100 /// <summary>Alternative form of QueryParser.Operator.AND </summary>
101 public static readonly Operator AND_OPERATOR
= Operator
.AND
;
102 /// <summary>Alternative form of QueryParser.Operator.OR </summary>
103 public static readonly Operator OR_OPERATOR
= Operator
.OR
;
105 /// <summary>The actual operator that parser uses to combine query terms </summary>
106 private Operator operator_Renamed
= OR_OPERATOR
;
108 internal bool lowercaseExpandedTerms
= true;
110 internal Analyzer analyzer
;
111 internal System
.String field
;
112 internal int phraseSlop
= 0;
113 internal float fuzzyMinSim
;
114 internal int fuzzyPrefixLength
;
115 internal System
.Globalization
.CultureInfo locale
= System
.Threading
.Thread
.CurrentThread
.CurrentCulture
;
117 /// <summary>The default operator for parsing queries.
118 /// Use {@link QueryParser#setDefaultOperator} to change it.
121 public sealed class Operator
: Parameter
123 internal Operator(System
.String name
) : base(name
)
126 public static readonly Operator OR
= new Operator("OR");
127 public static readonly Operator AND
= new Operator("AND");
130 /// <summary>Parses a query string, returning a {@link Lucene.Net.search.Query}.</summary>
131 /// <param name="query"> the query string to be parsed.
133 /// <param name="field"> the default field for query terms.
135 /// <param name="analyzer"> used to find terms in the query text.
137 /// <throws> ParseException if the parsing fails </throws>
140 /// <deprecated> Use an instance of QueryParser and the {@link #Parse(String)} method instead.
142 static public Query
Parse(System
.String query
, System
.String field
, Analyzer analyzer
)
144 QueryParser parser
= new QueryParser(field
, analyzer
);
145 return parser
.Parse(query
);
148 /// <summary>Constructs a query parser.</summary>
149 /// <param name="f"> the default field for query terms.
151 /// <param name="a"> used to find terms in the query text.
153 public QueryParser(System
.String f
, Analyzer a
) : this(new FastCharStream(new System
.IO
.StringReader("")))
159 /// <summary>Parses a query string, returning a {@link Lucene.Net.search.Query}.</summary>
160 /// <param name="query"> the query string to be parsed.
162 /// <throws> ParseException if the parsing fails </throws>
163 public virtual Query
Parse(System
.String query
)
165 ReInit(new FastCharStream(new System
.IO
.StringReader(query
)));
170 catch (TokenMgrError tme
)
172 throw new ParseException(tme
.Message
);
174 catch (BooleanQuery
.TooManyClauses
)
176 throw new ParseException("Too many boolean clauses");
180 /// <returns> Returns the analyzer.
182 public virtual Analyzer
GetAnalyzer()
187 /// <returns> Returns the field.
189 public virtual System
.String
GetField()
194 /// <summary> Get the minimal similarity for fuzzy queries.</summary>
195 public virtual float GetFuzzyMinSim()
200 /// <summary> Set the minimum similarity for fuzzy queries.
203 public virtual void SetFuzzyMinSim(float fuzzyMinSim
)
205 this.fuzzyMinSim
= fuzzyMinSim
;
208 /// <summary> Get the prefix length for fuzzy queries. </summary>
209 /// <returns> Returns the fuzzyPrefixLength.
211 public virtual int GetFuzzyPrefixLength()
213 return fuzzyPrefixLength
;
216 /// <summary> Set the prefix length for fuzzy queries. Default is 0.</summary>
217 /// <param name="fuzzyPrefixLength">The fuzzyPrefixLength to set.
219 public virtual void SetFuzzyPrefixLength(int fuzzyPrefixLength
)
221 this.fuzzyPrefixLength
= fuzzyPrefixLength
;
224 /// <summary> Sets the default slop for phrases. If zero, then exact phrase matches
225 /// are required. Default value is zero.
227 public virtual void SetPhraseSlop(int phraseSlop
)
229 this.phraseSlop
= phraseSlop
;
232 /// <summary> Gets the default slop for phrases.</summary>
233 public virtual int GetPhraseSlop()
238 /// <summary> Sets the boolean operator of the QueryParser.
239 /// In default mode (<code>DEFAULT_OPERATOR_OR</code>) terms without any modifiers
240 /// are considered optional: for example <code>capital of Hungary</code> is equal to
241 /// <code>capital OR of OR Hungary</code>.<br/>
242 /// In <code>DEFAULT_OPERATOR_AND</code> terms are considered to be in conjuction: the
243 /// above mentioned query is parsed as <code>capital AND of AND Hungary</code>
245 /// <deprecated> use {@link #SetDefaultOperator(QueryParser.Operator)} instead
247 public virtual void SetOperator(int op
)
249 if (op
== DEFAULT_OPERATOR_AND
)
250 this.operator_Renamed
= AND_OPERATOR
;
251 else if (op
== DEFAULT_OPERATOR_OR
)
252 this.operator_Renamed
= OR_OPERATOR
;
254 throw new System
.ArgumentException("Unknown operator " + op
);
257 /// <summary> Sets the boolean operator of the QueryParser.
258 /// In default mode (<code>OR_OPERATOR</code>) terms without any modifiers
259 /// are considered optional: for example <code>capital of Hungary</code> is equal to
260 /// <code>capital OR of OR Hungary</code>.<br/>
261 /// In <code>AND_OPERATOR</code> mode terms are considered to be in conjuction: the
262 /// above mentioned query is parsed as <code>capital AND of AND Hungary</code>
264 public virtual void SetDefaultOperator(Operator op
)
266 this.operator_Renamed
= op
;
269 /// <summary> Gets implicit operator setting, which will be either DEFAULT_OPERATOR_AND
270 /// or DEFAULT_OPERATOR_OR.
272 /// <deprecated> use {@link #GetDefaultOperator()} instead
274 public virtual int GetOperator()
276 if (operator_Renamed
== AND_OPERATOR
)
277 return DEFAULT_OPERATOR_AND
;
278 else if (operator_Renamed
== OR_OPERATOR
)
279 return DEFAULT_OPERATOR_OR
;
282 throw new System
.SystemException("Unknown operator " + operator_Renamed
);
286 /// <summary> Gets implicit operator setting, which will be either AND_OPERATOR
289 public virtual Operator
GetDefaultOperator()
291 return operator_Renamed
;
294 /// <summary> Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically
295 /// lower-cased or not. Default is <code>true</code>.
297 /// <deprecated> use {@link #SetLowercaseExpandedTerms(boolean)} instead
299 public virtual void SetLowercaseWildcardTerms(bool lowercaseExpandedTerms
)
301 this.lowercaseExpandedTerms
= lowercaseExpandedTerms
;
304 /// <summary> Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically
305 /// lower-cased or not. Default is <code>true</code>.
307 public virtual void SetLowercaseExpandedTerms(bool lowercaseExpandedTerms
)
309 this.lowercaseExpandedTerms
= lowercaseExpandedTerms
;
312 /// <deprecated> use {@link #GetLowercaseExpandedTerms()} instead
314 public virtual bool GetLowercaseWildcardTerms()
316 return lowercaseExpandedTerms
;
319 /// <seealso cref="SetLowercaseExpandedTerms(boolean)">
321 public virtual bool GetLowercaseExpandedTerms()
323 return lowercaseExpandedTerms
;
326 /// <summary> Set locale used by date range parsing.</summary>
327 public virtual void SetLocale(System
.Globalization
.CultureInfo locale
)
329 this.locale
= locale
;
332 /// <summary> Returns current locale, allowing access by subclasses.</summary>
333 public virtual System
.Globalization
.CultureInfo
GetLocale()
338 protected internal virtual void AddClause(System
.Collections
.ArrayList clauses
, int conj
, int mods
, Query q
)
340 bool required
, prohibited
;
342 // If this term is introduced by AND, make the preceding term required,
343 // unless it's already prohibited
344 if (clauses
.Count
> 0 && conj
== CONJ_AND
)
346 BooleanClause c
= (BooleanClause
) clauses
[clauses
.Count
- 1];
347 if (!c
.IsProhibited())
348 c
.SetOccur(BooleanClause
.Occur
.MUST
);
351 if (clauses
.Count
> 0 && operator_Renamed
== AND_OPERATOR
&& conj
== CONJ_OR
)
353 // If this term is introduced by OR, make the preceding term optional,
354 // unless it's prohibited (that means we leave -a OR b but +a OR b-->a OR b)
355 // notice if the input is a OR b, first term is parsed as required; without
356 // this modification a OR b would parsed as +a OR b
357 BooleanClause c
= (BooleanClause
) clauses
[clauses
.Count
- 1];
358 if (!c
.IsProhibited())
359 c
.SetOccur(BooleanClause
.Occur
.SHOULD
);
362 // We might have been passed a null query; the term might have been
363 // filtered away by the analyzer.
367 if (operator_Renamed
== OR_OPERATOR
)
369 // We set REQUIRED if we're introduced by AND or +; PROHIBITED if
370 // introduced by NOT or -; make sure not to set both.
371 prohibited
= (mods
== MOD_NOT
);
372 required
= (mods
== MOD_REQ
);
373 if (conj
== CONJ_AND
&& !prohibited
)
380 // We set PROHIBITED if we're introduced by NOT or -; We set REQUIRED
381 // if not PROHIBITED and not introduced by OR
382 prohibited
= (mods
== MOD_NOT
);
383 required
= (!prohibited
&& conj
!= CONJ_OR
);
385 if (required
&& !prohibited
)
386 clauses
.Add(new BooleanClause(q
, BooleanClause
.Occur
.MUST
));
387 else if (!required
&& !prohibited
)
388 clauses
.Add(new BooleanClause(q
, BooleanClause
.Occur
.SHOULD
));
389 else if (!required
&& prohibited
)
390 clauses
.Add(new BooleanClause(q
, BooleanClause
.Occur
.MUST_NOT
));
392 throw new System
.SystemException("Clause cannot be both required and prohibited");
395 /// <summary> Note that parameter analyzer is ignored. Calls inside the parser always
396 /// use class member analyzer.
399 /// <exception cref="ParseException">throw in overridden method to disallow
401 /// <deprecated> use {@link #GetFieldQuery(String, String)}
403 protected internal virtual Query
GetFieldQuery(System
.String field
, Analyzer analyzer
, System
.String queryText
)
405 return GetFieldQuery(field
, queryText
);
408 /// <exception cref="ParseException">throw in overridden method to disallow
410 protected internal virtual Query
GetFieldQuery(System
.String field
, System
.String queryText
)
412 // Use the analyzer to get all the tokens, and then build a TermQuery,
413 // PhraseQuery, or nothing based on the term count
415 TokenStream source
= analyzer
.TokenStream(field
, new System
.IO
.StringReader(queryText
));
416 System
.Collections
.ArrayList v
= System
.Collections
.ArrayList
.Synchronized(new System
.Collections
.ArrayList(10));
417 Lucene
.Net
.Analysis
.Token t
;
418 int positionCount
= 0;
419 bool severalTokensAtSamePosition
= false;
427 catch (System
.IO
.IOException e
)
434 if (t
.GetPositionIncrement() != 0)
435 positionCount
+= t
.GetPositionIncrement();
437 severalTokensAtSamePosition
= true;
443 catch (System
.IO
.IOException e
)
450 else if (v
.Count
== 1)
452 t
= (Lucene
.Net
.Analysis
.Token
) v
[0];
453 return new TermQuery(new Term(field
, t
.TermText()));
457 if (severalTokensAtSamePosition
)
459 if (positionCount
== 1)
462 BooleanQuery q
= new BooleanQuery(true);
463 for (int i
= 0; i
< v
.Count
; i
++)
465 t
= (Lucene
.Net
.Analysis
.Token
) v
[i
];
466 TermQuery currentQuery
= new TermQuery(new Term(field
, t
.TermText()));
467 q
.Add(currentQuery
, BooleanClause
.Occur
.SHOULD
);
474 MultiPhraseQuery mpq
= new MultiPhraseQuery();
475 System
.Collections
.ArrayList multiTerms
= new System
.Collections
.ArrayList();
476 for (int i
= 0; i
< v
.Count
; i
++)
478 t
= (Lucene
.Net
.Analysis
.Token
) v
[i
];
479 if (t
.GetPositionIncrement() == 1 && multiTerms
.Count
> 0)
481 mpq
.Add((Term
[]) multiTerms
.ToArray(typeof(Term
)));
484 multiTerms
.Add(new Term(field
, t
.TermText()));
486 mpq
.Add((Term
[]) multiTerms
.ToArray(typeof(Term
)));
492 PhraseQuery q
= new PhraseQuery();
493 q
.SetSlop(phraseSlop
);
494 for (int i
= 0; i
< v
.Count
; i
++)
496 q
.Add(new Term(field
, ((Lucene
.Net
.Analysis
.Token
) v
[i
]).TermText()));
503 /// <summary> Note that parameter analyzer is ignored. Calls inside the parser always
504 /// use class member analyzer.
507 /// <exception cref="ParseException">throw in overridden method to disallow
509 /// <deprecated> use {@link #GetFieldQuery(String, String, int)}
511 protected internal virtual Query
GetFieldQuery(System
.String field
, Analyzer analyzer
, System
.String queryText
, int slop
)
513 return GetFieldQuery(field
, queryText
, slop
);
516 /// <summary> Base implementation delegates to {@link #GetFieldQuery(String,String)}.
517 /// This method may be overridden, for example, to return
518 /// a SpanNearQuery instead of a PhraseQuery.
521 /// <exception cref="ParseException">throw in overridden method to disallow
523 protected internal virtual Query
GetFieldQuery(System
.String field
, System
.String queryText
, int slop
)
525 Query query
= GetFieldQuery(field
, queryText
);
527 if (query
is PhraseQuery
)
529 ((PhraseQuery
) query
).SetSlop(slop
);
531 if (query
is MultiPhraseQuery
)
533 ((MultiPhraseQuery
) query
).SetSlop(slop
);
539 /// <summary> Note that parameter analyzer is ignored. Calls inside the parser always
540 /// use class member analyzer.
543 /// <exception cref="ParseException">throw in overridden method to disallow
545 /// <deprecated> use {@link #GetRangeQuery(String, String, String, boolean)}
547 protected internal virtual Query
GetRangeQuery(System
.String field
, Analyzer analyzer
, System
.String part1
, System
.String part2
, bool inclusive
)
549 return GetRangeQuery(field
, part1
, part2
, inclusive
);
552 /// <exception cref="ParseException">throw in overridden method to disallow
554 protected internal virtual Query
GetRangeQuery(System
.String field
, System
.String part1
, System
.String part2
, bool inclusive
)
556 if (lowercaseExpandedTerms
)
558 part1
= part1
.ToLower();
559 part2
= part2
.ToLower();
563 System
.DateTime d1
= System
.DateTime
.Parse(part1
, locale
);
564 System
.DateTime d2
= System
.DateTime
.Parse(part2
, locale
);
565 part1
= DateField
.DateToString(d1
);
566 part2
= DateField
.DateToString(d2
);
568 catch (System
.Exception e
)
572 return new RangeQuery(new Term(field
, part1
), new Term(field
, part2
), inclusive
);
575 /// <summary> Factory method for generating query, given a set of clauses.
576 /// By default creates a boolean query composed of clauses passed in.
578 /// Can be overridden by extending classes, to modify query being
582 /// <param name="clauses">Vector that contains {@link BooleanClause} instances
586 /// <returns> Resulting {@link Query} object.
588 /// <exception cref="ParseException">throw in overridden method to disallow
590 protected internal virtual Query
GetBooleanQuery(System
.Collections
.ArrayList clauses
)
592 return GetBooleanQuery(clauses
, false);
595 /// <summary> Factory method for generating query, given a set of clauses.
596 /// By default creates a boolean query composed of clauses passed in.
598 /// Can be overridden by extending classes, to modify query being
602 /// <param name="clauses">Vector that contains {@link BooleanClause} instances
605 /// <param name="disableCoord">true if coord scoring should be disabled.
608 /// <returns> Resulting {@link Query} object.
610 /// <exception cref="ParseException">throw in overridden method to disallow
612 protected internal virtual Query
GetBooleanQuery(System
.Collections
.ArrayList clauses
, bool disableCoord
)
614 BooleanQuery query
= new BooleanQuery(disableCoord
);
615 for (int i
= 0; i
< clauses
.Count
; i
++)
617 query
.Add((BooleanClause
) clauses
[i
]);
622 /// <summary> Factory method for generating a query. Called when parser
623 /// parses an input term token that contains one or more wildcard
624 /// characters (? and *), but is not a prefix term token (one
625 /// that has just a single * character at the end)
627 /// Depending on settings, prefix term may be lower-cased
628 /// automatically. It will not go through the default Analyzer,
629 /// however, since normal Analyzers are unlikely to work properly
630 /// with wildcard templates.
632 /// Can be overridden by extending classes, to provide custom handling for
633 /// wildcard queries, which may be necessary due to missing analyzer calls.
636 /// <param name="field">Name of the field query will use.
638 /// <param name="termStr">Term token that contains one or more wild card
639 /// characters (? or *), but is not simple prefix term
642 /// <returns> Resulting {@link Query} built for the term
644 /// <exception cref="ParseException">throw in overridden method to disallow
646 protected internal virtual Query
GetWildcardQuery(System
.String field
, System
.String termStr
)
648 if (lowercaseExpandedTerms
)
650 termStr
= termStr
.ToLower();
652 Term t
= new Term(field
, termStr
);
653 return new WildcardQuery(t
);
656 /// <summary> Factory method for generating a query (similar to
657 /// {@link #getWildcardQuery}). Called when parser parses an input term
658 /// token that uses prefix notation; that is, contains a single '*' wildcard
659 /// character as its last character. Since this is a special case
660 /// of generic wildcard term, and such a query can be optimized easily,
661 /// this usually results in a different query object.
663 /// Depending on settings, a prefix term may be lower-cased
664 /// automatically. It will not go through the default Analyzer,
665 /// however, since normal Analyzers are unlikely to work properly
666 /// with wildcard templates.
668 /// Can be overridden by extending classes, to provide custom handling for
669 /// wild card queries, which may be necessary due to missing analyzer calls.
672 /// <param name="field">Name of the field query will use.
674 /// <param name="termStr">Term token to use for building term for the query
675 /// (<b>without</b> trailing '*' character!)
678 /// <returns> Resulting {@link Query} built for the term
680 /// <exception cref="ParseException">throw in overridden method to disallow
682 protected internal virtual Query
GetPrefixQuery(System
.String field
, System
.String termStr
)
684 if (lowercaseExpandedTerms
)
686 termStr
= termStr
.ToLower();
688 Term t
= new Term(field
, termStr
);
689 return new PrefixQuery(t
);
692 /// <deprecated> use {@link #GetFuzzyQuery(String, String, float)}
694 protected internal virtual Query
GetFuzzyQuery(System
.String field
, System
.String termStr
)
696 return GetFuzzyQuery(field
, termStr
, fuzzyMinSim
);
699 /// <summary> Factory method for generating a query (similar to
700 /// {@link #getWildcardQuery}). Called when parser parses
701 /// an input term token that has the fuzzy suffix (~) appended.
704 /// <param name="field">Name of the field query will use.
706 /// <param name="termStr">Term token to use for building term for the query
709 /// <returns> Resulting {@link Query} built for the term
711 /// <exception cref="ParseException">throw in overridden method to disallow
713 protected internal virtual Query
GetFuzzyQuery(System
.String field
, System
.String termStr
, float minSimilarity
)
715 if (lowercaseExpandedTerms
)
717 termStr
= termStr
.ToLower();
719 Term t
= new Term(field
, termStr
);
720 return new FuzzyQuery(t
, minSimilarity
, fuzzyPrefixLength
);
723 /// <summary> Returns a String where the escape char has been
724 /// removed, or kept only once if there was a double escape.
726 private System
.String
DiscardEscapeChar(System
.String input
)
728 char[] caSource
= input
.ToCharArray();
729 char[] caDest
= new char[caSource
.Length
];
731 for (int i
= 0; i
< caSource
.Length
; i
++)
733 if ((caSource
[i
] != '\\') || (i
> 0 && caSource
[i
- 1] == '\\'))
735 caDest
[j
++] = caSource
[i
];
738 return new System
.String(caDest
, 0, j
);
741 /// <summary> Returns a String where those characters that QueryParser
742 /// expects to be escaped are escaped by a preceding <code>\</code>.
744 public static System
.String
Escape(System
.String s
)
746 System
.Text
.StringBuilder sb
= new System
.Text
.StringBuilder();
747 for (int i
= 0; i
< s
.Length
; i
++)
750 // NOTE: keep this in sync with _ESCAPED_CHAR below!
751 if (c
== '\\' || c
== '+' || c
== '-' || c
== '!' || c
== '(' || c
== ')' || c
== ':' || c
== '^' || c
== '[' || c
== ']' || c
== '\"' || c
== '{' || c == '}' || c
== '~' || c
== '*' || c
== '?')
757 return sb
.ToString();
760 /// <summary> Command line tool to test QueryParser, using {@link Lucene.Net.analysis.SimpleAnalyzer}.
762 /// <code>java Lucene.Net.queryParser.QueryParser <input></code>
765 public static void Main(System
.String
[] args
)
767 if (args
.Length
== 0)
769 System
.Console
.Out
.WriteLine("Usage: java Lucene.Net.queryParser.QueryParser <input>");
770 System
.Environment
.Exit(0);
772 QueryParser qp
= new QueryParser("field", new Lucene
.Net
.Analysis
.SimpleAnalyzer());
773 Query q
= qp
.Parse(args
[0]);
774 System
.Console
.Out
.WriteLine(q
.ToString("field"));
777 // * Query ::= ( Clause )*
778 // * Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )
779 public int Conjunction()
782 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
785 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.AND
:
786 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.OR
:
787 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
790 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.AND
:
791 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.AND
);
795 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.OR
:
796 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.OR
);
802 Jj_consume_token(- 1);
803 throw new ParseException();
818 throw new System
.ApplicationException("Missing return statement in function");
821 public int Modifiers()
824 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
827 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.NOT
:
828 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.PLUS
:
829 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.MINUS
:
830 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
833 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.PLUS
:
834 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.PLUS
);
838 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.MINUS
:
839 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.MINUS
);
843 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.NOT
:
844 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.NOT
);
850 Jj_consume_token(- 1);
851 throw new ParseException();
866 throw new System
.ApplicationException("Missing return statement in function");
869 public Query
Query(System
.String field
)
871 System
.Collections
.ArrayList clauses
= System
.Collections
.ArrayList
.Synchronized(new System
.Collections
.ArrayList(10));
872 Query q
, firstQuery
= null;
876 AddClause(clauses
, CONJ_NONE
, mods
, q
);
877 if (mods
== MOD_NONE
)
881 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
884 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.AND
:
885 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.OR
:
886 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.NOT
:
887 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.PLUS
:
888 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.MINUS
:
889 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.LPAREN
:
890 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.QUOTED
:
891 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.TERM
:
892 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.PREFIXTERM
:
893 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.WILDTERM
:
894 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_START
:
895 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_START
:
896 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.NUMBER
:
905 conj
= Conjunction();
908 AddClause(clauses
, conj
, mods
, q
);
913 if (clauses
.Count
== 1 && firstQuery
!= null)
922 return GetBooleanQuery(clauses
);
925 throw new System
.ApplicationException("Missing return statement in function");
928 public Query
Clause(System
.String field
)
931 Token fieldToken
= null, boost
= null;
934 fieldToken
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.TERM
);
935 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.COLON
);
936 field
= DiscardEscapeChar(fieldToken
.image
);
942 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
945 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.QUOTED
:
946 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.TERM
:
947 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.PREFIXTERM
:
948 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.WILDTERM
:
949 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_START
:
950 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_START
:
951 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.NUMBER
:
955 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.LPAREN
:
956 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.LPAREN
);
958 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RPAREN
);
959 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
962 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.CARAT
:
963 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.CARAT
);
964 boost
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.NUMBER
);
977 Jj_consume_token(- 1);
978 throw new ParseException();
983 float f
= (float) 1.0;
986 f
= (float) System
.Single
.Parse(boost
.image
);
989 catch (System
.Exception ignored
)
997 throw new System
.ApplicationException("Missing return statement in function");
1000 public Query
Term(System
.String field
)
1002 Token term
, boost
= null, fuzzySlop
= null, goop1
, goop2
;
1003 bool prefix
= false;
1004 bool wildcard
= false;
1006 bool rangein
= false;
1008 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1011 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.TERM
:
1012 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.PREFIXTERM
:
1013 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.WILDTERM
:
1014 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.NUMBER
:
1015 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1018 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.TERM
:
1019 term
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.TERM
);
1022 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.PREFIXTERM
:
1023 term
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.PREFIXTERM
);
1027 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.WILDTERM
:
1028 term
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.WILDTERM
);
1032 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.NUMBER
:
1033 term
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.NUMBER
);
1038 Jj_consume_token(- 1);
1039 throw new ParseException();
1042 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1045 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.FUZZY_SLOP
:
1046 fuzzySlop
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.FUZZY_SLOP
);
1056 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1059 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.CARAT
:
1060 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.CARAT
);
1061 boost
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.NUMBER
);
1062 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1065 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.FUZZY_SLOP
:
1066 fuzzySlop
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.FUZZY_SLOP
);
1079 jj_la1
[10] = jj_gen
;
1084 System
.String termImage
= DiscardEscapeChar(term
.image
);
1087 q
= GetWildcardQuery(field
, termImage
);
1091 q
= GetPrefixQuery(field
, DiscardEscapeChar(term
.image
.Substring(0, (term
.image
.Length
- 1) - (0))));
1095 float fms
= fuzzyMinSim
;
1098 fms
= (float) System
.Single
.Parse(fuzzySlop
.image
.Substring(1));
1100 catch (System
.Exception ignored
)
1103 if (fms
< 0.0f
|| fms
> 1.0f
)
1107 throw new ParseException("Minimum similarity for a FuzzyQuery has to be between 0.0f and 1.0f !");
1110 if (fms
== fuzzyMinSim
)
1111 q
= GetFuzzyQuery(field
, termImage
);
1113 q
= GetFuzzyQuery(field
, termImage
, fms
);
1117 q
= GetFieldQuery(field
, analyzer
, termImage
);
1121 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_START
:
1122 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_START
);
1123 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1126 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_GOOP
:
1127 goop1
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_GOOP
);
1130 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_QUOTED
:
1131 goop1
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_QUOTED
);
1135 jj_la1
[11] = jj_gen
;
1136 Jj_consume_token(- 1);
1137 throw new ParseException();
1140 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1143 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_TO
:
1144 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_TO
);
1148 jj_la1
[12] = jj_gen
;
1153 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1156 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_GOOP
:
1157 goop2
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_GOOP
);
1160 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_QUOTED
:
1161 goop2
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_QUOTED
);
1165 jj_la1
[13] = jj_gen
;
1166 Jj_consume_token(- 1);
1167 throw new ParseException();
1170 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_END
);
1171 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1174 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.CARAT
:
1175 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.CARAT
);
1176 boost
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.NUMBER
);
1180 jj_la1
[14] = jj_gen
;
1185 if (goop1
.kind
== Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_QUOTED
)
1187 goop1
.image
= goop1
.image
.Substring(1, (goop1
.image
.Length
- 1) - (1));
1191 goop1
.image
= DiscardEscapeChar(goop1
.image
);
1193 if (goop2
.kind
== Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEIN_QUOTED
)
1195 goop2
.image
= goop2
.image
.Substring(1, (goop2
.image
.Length
- 1) - (1));
1199 goop2
.image
= DiscardEscapeChar(goop2
.image
);
1201 q
= GetRangeQuery(field
, analyzer
, goop1
.image
, goop2
.image
, true);
1204 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_START
:
1205 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_START
);
1206 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1209 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_GOOP
:
1210 goop1
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_GOOP
);
1213 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_QUOTED
:
1214 goop1
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_QUOTED
);
1218 jj_la1
[15] = jj_gen
;
1219 Jj_consume_token(- 1);
1220 throw new ParseException();
1223 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1226 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_TO
:
1227 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_TO
);
1231 jj_la1
[16] = jj_gen
;
1236 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1239 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_GOOP
:
1240 goop2
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_GOOP
);
1243 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_QUOTED
:
1244 goop2
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_QUOTED
);
1248 jj_la1
[17] = jj_gen
;
1249 Jj_consume_token(- 1);
1250 throw new ParseException();
1253 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_END
);
1254 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1257 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.CARAT
:
1258 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.CARAT
);
1259 boost
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.NUMBER
);
1263 jj_la1
[18] = jj_gen
;
1268 if (goop1
.kind
== Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_QUOTED
)
1270 goop1
.image
= goop1
.image
.Substring(1, (goop1
.image
.Length
- 1) - (1));
1274 goop1
.image
= DiscardEscapeChar(goop1
.image
);
1276 if (goop2
.kind
== Lucene
.Net
.QueryParsers
.QueryParserConstants
.RANGEEX_QUOTED
)
1278 goop2
.image
= goop2
.image
.Substring(1, (goop2
.image
.Length
- 1) - (1));
1282 goop2
.image
= DiscardEscapeChar(goop2
.image
);
1285 q
= GetRangeQuery(field
, analyzer
, goop1
.image
, goop2
.image
, false);
1288 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.QUOTED
:
1289 term
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.QUOTED
);
1290 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1293 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.FUZZY_SLOP
:
1294 fuzzySlop
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.FUZZY_SLOP
);
1298 jj_la1
[19] = jj_gen
;
1303 switch ((jj_ntk
== - 1) ? Jj_ntk() : jj_ntk
)
1306 case Lucene
.Net
.QueryParsers
.QueryParserConstants
.CARAT
:
1307 Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.CARAT
);
1308 boost
= Jj_consume_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.NUMBER
);
1312 jj_la1
[20] = jj_gen
;
1319 if (fuzzySlop
!= null)
1323 s
= (int) System
.Single
.Parse(fuzzySlop
.image
.Substring(1));
1325 catch (System
.Exception ignored
)
1329 q
= GetFieldQuery(field
, analyzer
, term
.image
.Substring(1, (term
.image
.Length
- 1) - (1)), s
);
1333 jj_la1
[21] = jj_gen
;
1334 Jj_consume_token(- 1);
1335 throw new ParseException();
1340 float f
= (float) 1.0;
1343 f
= (float) System
.Single
.Parse(boost
.image
);
1345 catch (System
.Exception ignored
)
1347 /* Should this be handled somehow? (defaults to "no boost", if
1348 * boost number is invalid)
1352 // avoid boosting null queries, such as those caused by stop words
1362 throw new System
.ApplicationException("Missing return statement in function");
1365 private bool Jj_2_1(int xla
)
1367 jj_la
= xla
; jj_lastpos
= jj_scanpos
= token
;
1372 catch (LookaheadSuccess ls
)
1382 private bool Jj_3_1()
1384 if (Jj_scan_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.TERM
))
1386 if (Jj_scan_token(Lucene
.Net
.QueryParsers
.QueryParserConstants
.COLON
))
1391 public QueryParserTokenManager token_source
;
1392 public Token token
, jj_nt
;
1394 private Token jj_scanpos
, jj_lastpos
;
1396 public bool lookingAhead
= false;
1397 private bool jj_semLA
;
1399 private int[] jj_la1
= new int[22];
1400 private static uint[] jj_la1_0
;
1401 private static void Jj_la1_0()
1403 jj_la1_0
= new uint[]{0x180, 0x180, 0xe00, 0xe00, 0xfb1f80, 0x8000, 0xfb1000, 0x9a0000, 0x40000, 0x40000, 0x8000, 0xc000000, 0x1000000, 0xc000000, 0x8000, 0xc0000000, 0x10000000, 0xc0000000, 0x8000, 0x40000, 0x8000, 0xfb0000}
;
1405 private JJCalls
[] jj_2_rtns
;
1406 private bool jj_rescan
= false;
1407 private int jj_gc
= 0;
1409 public QueryParser(CharStream stream
)
1412 token_source
= new QueryParserTokenManager(stream
);
1413 token
= new Token();
1416 for (int i
= 0; i
< 22; i
++)
1418 for (int i
= 0; i
< jj_2_rtns
.Length
; i
++)
1419 jj_2_rtns
[i
] = new JJCalls();
1422 public virtual void ReInit(CharStream stream
)
1424 token_source
.ReInit(stream
);
1425 token
= new Token();
1428 for (int i
= 0; i
< 22; i
++)
1430 for (int i
= 0; i
< jj_2_rtns
.Length
; i
++)
1431 jj_2_rtns
[i
] = new JJCalls();
1434 public QueryParser(QueryParserTokenManager tm
)
1438 token
= new Token();
1441 for (int i
= 0; i
< 22; i
++)
1443 for (int i
= 0; i
< jj_2_rtns
.Length
; i
++)
1444 jj_2_rtns
[i
] = new JJCalls();
1447 public virtual void ReInit(QueryParserTokenManager tm
)
1450 token
= new Token();
1453 for (int i
= 0; i
< 22; i
++)
1455 for (int i
= 0; i
< jj_2_rtns
.Length
; i
++)
1456 jj_2_rtns
[i
] = new JJCalls();
1459 private Token
Jj_consume_token(int kind
)
1462 if ((oldToken
= token
).next
!= null)
1465 token
= token
.next
= token_source
.GetNextToken();
1467 if (token
.kind
== kind
)
1473 for (int i
= 0; i
< jj_2_rtns
.Length
; i
++)
1475 JJCalls c
= jj_2_rtns
[i
];
1488 throw GenerateParseException();
1492 private sealed class LookaheadSuccess
:System
.ApplicationException
1495 private LookaheadSuccess jj_ls
;
1496 private bool Jj_scan_token(int kind
)
1498 if (jj_scanpos
== jj_lastpos
)
1501 if (jj_scanpos
.next
== null)
1503 jj_lastpos
= jj_scanpos
= jj_scanpos
.next
= token_source
.GetNextToken();
1507 jj_lastpos
= jj_scanpos
= jj_scanpos
.next
;
1512 jj_scanpos
= jj_scanpos
.next
;
1516 int i
= 0; Token tok
= token
;
1517 while (tok
!= null && tok
!= jj_scanpos
)
1519 i
++; tok
= tok
.next
;
1522 Jj_add_error_token(kind
, i
);
1524 if (jj_scanpos
.kind
!= kind
)
1526 if (jj_la
== 0 && jj_scanpos
== jj_lastpos
)
1531 public Token
GetNextToken()
1533 if (token
.next
!= null)
1536 token
= token
.next
= token_source
.GetNextToken();
1542 public Token
GetToken(int index
)
1544 Token t
= lookingAhead
? jj_scanpos
: token
;
1545 for (int i
= 0; i
< index
; i
++)
1550 t
= t
.next
= token_source
.GetNextToken();
1555 private int Jj_ntk()
1557 if ((jj_nt
= token
.next
) == null)
1558 return (jj_ntk
= (token
.next
= token_source
.GetNextToken()).kind
);
1560 return (jj_ntk
= jj_nt
.kind
);
1563 private System
.Collections
.ArrayList jj_expentries
= System
.Collections
.ArrayList
.Synchronized(new System
.Collections
.ArrayList(10));
1564 private int[] jj_expentry
;
1565 private int jj_kind
= - 1;
1566 private int[] jj_lasttokens
= new int[100];
1567 private int jj_endpos
;
1569 private void Jj_add_error_token(int kind
, int pos
)
1573 if (pos
== jj_endpos
+ 1)
1575 jj_lasttokens
[jj_endpos
++] = kind
;
1577 else if (jj_endpos
!= 0)
1579 jj_expentry
= new int[jj_endpos
];
1580 for (int i
= 0; i
< jj_endpos
; i
++)
1582 jj_expentry
[i
] = jj_lasttokens
[i
];
1584 bool exists
= false;
1585 for (System
.Collections
.IEnumerator e
= jj_expentries
.GetEnumerator(); e
.MoveNext(); )
1587 int[] oldentry
= (int[]) (e
.Current
);
1588 if (oldentry
.Length
== jj_expentry
.Length
)
1591 for (int i
= 0; i
< jj_expentry
.Length
; i
++)
1593 if (oldentry
[i
] != jj_expentry
[i
])
1604 jj_expentries
.Add(jj_expentry
);
1606 jj_lasttokens
[(jj_endpos
= pos
) - 1] = kind
;
1610 public virtual ParseException
GenerateParseException()
1612 jj_expentries
.Clear();
1613 bool[] la1tokens
= new bool[32];
1614 for (int i
= 0; i
< 32; i
++)
1616 la1tokens
[i
] = false;
1620 la1tokens
[jj_kind
] = true;
1623 for (int i
= 0; i
< 22; i
++)
1625 if (jj_la1
[i
] == jj_gen
)
1627 for (int j
= 0; j
< 32; j
++)
1629 if ((jj_la1_0
[i
] & (1 << j
)) != 0)
1631 la1tokens
[j
] = true;
1636 for (int i
= 0; i
< 32; i
++)
1640 jj_expentry
= new int[1];
1642 jj_expentries
.Add(jj_expentry
);
1647 Jj_add_error_token(0, 0);
1648 int[][] exptokseq
= new int[jj_expentries
.Count
][];
1649 for (int i
= 0; i
< jj_expentries
.Count
; i
++)
1651 exptokseq
[i
] = (int[]) jj_expentries
[i
];
1653 return new ParseException(token
, exptokseq
, Lucene
.Net
.QueryParsers
.QueryParserConstants
.tokenImage
);
1656 public void Enable_tracing()
1660 public void Disable_tracing()
1664 private void Jj_rescan_token()
1667 for (int i
= 0; i
< 1; i
++)
1669 JJCalls p
= jj_2_rtns
[i
];
1674 jj_la
= p
.arg
; jj_lastpos
= jj_scanpos
= p
.first
;
1678 case 0: Jj_3_1(); break;
1688 private void Jj_save(int index
, int xla
)
1690 JJCalls p
= jj_2_rtns
[index
];
1691 while (p
.gen
> jj_gen
)
1695 p
= p
.next
= new JJCalls(); break;
1699 p
.gen
= jj_gen
+ xla
- jj_la
; p
.first
= token
; p
.arg
= xla
;
1702 internal sealed class JJCalls
1705 internal Token first
;
1707 internal JJCalls next
;
1709 static QueryParser()