Lucene.Net  3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties
TokenMgrError.cs
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 4.1 */
19 /* JavaCCOptions: */
20 
21 using System;
22 
23 namespace Lucene.Net.QueryParsers
24 {
25 
27  [Serializable]
28  public class TokenMgrError:System.ApplicationException
29  {
38  public override System.String Message
39  {
40  get
41  {
42  return base.Message;
43  }
44 
45  }
46 
47  /*
48  * Ordinals for various reasons why an Error of this type can be thrown.
49  */
50 
52  internal const int LEXICAL_ERROR = 0;
53 
55  internal const int STATIC_LEXER_ERROR = 1;
56 
58  internal const int INVALID_LEXICAL_STATE = 2;
59 
61  internal const int LOOP_DETECTED = 3;
62 
66  internal int errorCode;
67 
71  protected internal static System.String addEscapes(System.String str)
72  {
73  System.Text.StringBuilder retval = new System.Text.StringBuilder();
74  char ch;
75  for (int i = 0; i < str.Length; i++)
76  {
77  switch (str[i])
78  {
79 
80  case (char) (0):
81  continue;
82 
83  case '\b':
84  retval.Append("\\b");
85  continue;
86 
87  case '\t':
88  retval.Append("\\t");
89  continue;
90 
91  case '\n':
92  retval.Append("\\n");
93  continue;
94 
95  case '\f':
96  retval.Append("\\f");
97  continue;
98 
99  case '\r':
100  retval.Append("\\r");
101  continue;
102 
103  case '\"':
104  retval.Append("\\\"");
105  continue;
106 
107  case '\'':
108  retval.Append("\\\'");
109  continue;
110 
111  case '\\':
112  retval.Append("\\\\");
113  continue;
114 
115  default:
116  if ((ch = str[i]) < 0x20 || ch > 0x7e)
117  {
118  System.String s = "0000" + System.Convert.ToString(ch, 16);
119  retval.Append("\\u" + s.Substring(s.Length - 4, (s.Length) - (s.Length - 4)));
120  }
121  else
122  {
123  retval.Append(ch);
124  }
125  continue;
126 
127  }
128  }
129  return retval.ToString();
130  }
131 
143  protected internal static System.String LexicalError(bool EOFSeen, int lexState, int errorLine, int errorColumn, System.String errorAfter, char curChar)
144  {
145  return ("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen?"<EOF> ":("\"" + addEscapes(System.Convert.ToString(curChar)) + "\"") + " (" + (int) curChar + "), ") + "after : \"" + addEscapes(errorAfter) + "\"");
146  }
147 
148  /*
149  * Constructors of various flavors follow.
150  */
151 
153  public TokenMgrError()
154  {
155  }
156 
158  public TokenMgrError(System.String message, int reason):base(message)
159  {
160  errorCode = reason;
161  }
162 
164  public TokenMgrError(bool EOFSeen, int lexState, int errorLine, int errorColumn, System.String errorAfter, char curChar, int reason):this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason)
165  {
166  }
167  }
168  /* JavaCC - OriginalChecksum=1c94e13236c7e0121e49427992341ee3 (do not edit this line) */
169 }