22 using Lucene.Net.Support;
24 namespace Lucene.Net.QueryParsers
47 public override System.String Message
51 if (!specialConstructor)
55 System.Text.StringBuilder expected =
new System.Text.StringBuilder();
57 for (
int i = 0; i < expectedTokenSequences.Length; i++)
59 if (maxSize < expectedTokenSequences[i].Length)
61 maxSize = expectedTokenSequences[i].Length;
63 for (
int j = 0; j < expectedTokenSequences[i].Length; j++)
65 expected.Append(tokenImage[expectedTokenSequences[i][j]]).Append(
' ');
67 if (expectedTokenSequences[i][expectedTokenSequences[i].Length - 1] != 0)
69 expected.Append(
"...");
71 expected.Append(eol).Append(
" ");
73 System.String retval =
"Encountered \"";
75 for (
int i = 0; i < maxSize; i++)
81 retval += tokenImage[0];
84 retval += (
" " + tokenImage[tok.
kind]);
86 retval += Add_escapes(tok.
image);
90 retval += (
"\" at line " + currentToken.next.beginLine +
", column " + currentToken.next.beginColumn);
91 retval += (
"." + eol);
92 if (expectedTokenSequences.Length == 1)
94 retval += (
"Was expecting:" + eol +
" ");
98 retval += (
"Was expecting one of:" + eol +
" ");
117 public ParseException(
Token currentTokenVal,
int[][] expectedTokenSequencesVal, System.String[] tokenImageVal):base(
"")
119 specialConstructor =
true;
120 currentToken = currentTokenVal;
121 expectedTokenSequences = expectedTokenSequencesVal;
122 tokenImage = tokenImageVal;
136 specialConstructor =
false;
142 specialConstructor =
false;
146 public ParseException(System.String message, System.Exception ex) : base(message, ex)
148 specialConstructor =
false;
155 protected internal bool specialConstructor;
176 protected internal System.String eol =
AppSettings.
Get(
"line.separator",
"\n");
182 protected internal virtual System.String Add_escapes(System.String str)
184 System.Text.StringBuilder retval =
new System.Text.StringBuilder();
186 for (
int i = 0; i < str.Length; i++)
195 retval.Append(
"\\b");
199 retval.Append(
"\\t");
203 retval.Append(
"\\n");
207 retval.Append(
"\\f");
211 retval.Append(
"\\r");
215 retval.Append(
"\\\"");
219 retval.Append(
"\\\'");
223 retval.Append(
"\\\\");
227 if ((ch = str[i]) < 0x20 || ch > 0x7e)
229 System.String s =
"0000" + System.Convert.ToString(ch, 16);
230 retval.Append(
"\\u" + s.Substring(s.Length - 4, (s.Length) - (s.Length - 4)));
240 return retval.ToString();