31 current =
new System.Text.StringBuilder();
35 public abstract bool Stem();
38 public virtual void SetCurrent(System.String value)
41 current.Remove(0, current.Length);
42 current.Append(value);
44 limit = current.Length;
51 virtual public System.String GetCurrent()
53 string result = current.ToString();
60 current =
new StringBuilder();
65 protected internal System.Text.StringBuilder current;
67 protected internal int cursor;
68 protected internal int limit;
69 protected internal int limit_backward;
70 protected internal int bra;
71 protected internal int ket;
75 current = other.current;
76 cursor = other.cursor;
78 limit_backward = other.limit_backward;
83 protected internal virtual bool in_grouping(
char[] s,
int min,
int max)
87 char ch = current[cursor];
88 if (ch > max || ch < min)
91 if ((s[ch >> 3] & (0x1 << (ch & 0x7))) == 0)
97 protected internal virtual bool in_grouping_b(
char[] s,
int min,
int max)
99 if (cursor <= limit_backward)
101 char ch = current[cursor - 1];
102 if (ch > max || ch < min)
105 if ((s[ch >> 3] & (0x1 << (ch & 0x7))) == 0)
111 protected internal virtual bool out_grouping(
char[] s,
int min,
int max)
115 char ch = current[cursor];
116 if (ch > max || ch < min)
122 if ((s[ch >> 3] & (0x1 << (ch & 0x7))) == 0)
130 protected internal virtual bool out_grouping_b(
char[] s,
int min,
int max)
132 if (cursor <= limit_backward)
134 char ch = current[cursor - 1];
135 if (ch > max || ch < min)
141 if ((s[ch >> 3] & (0x1 << (ch & 0x7))) == 0)
149 protected internal virtual bool in_range(
int min,
int max)
153 char ch = current[cursor];
154 if (ch > max || ch < min)
160 protected internal virtual bool in_range_b(
int min,
int max)
162 if (cursor <= limit_backward)
164 char ch = current[cursor - 1];
165 if (ch > max || ch < min)
171 protected internal virtual bool out_range(
int min,
int max)
175 char ch = current[cursor];
176 if (!(ch > max || ch < min))
182 protected internal virtual bool out_range_b(
int min,
int max)
184 if (cursor <= limit_backward)
186 char ch = current[cursor - 1];
187 if (!(ch > max || ch < min))
193 protected internal virtual bool eq_s(
int s_size, System.String s)
195 if (limit - cursor < s_size)
198 for (i = 0; i != s_size; i++)
200 if (current[cursor + i] != s[i])
207 protected internal virtual bool eq_s_b(
int s_size, System.String s)
209 if (cursor - limit_backward < s_size)
212 for (i = 0; i != s_size; i++)
214 if (current[cursor - s_size + i] != s[i])
221 protected internal virtual bool eq_v(System.Text.StringBuilder s)
223 return eq_s(s.Length, s.ToString());
226 protected internal virtual bool eq_v_b(System.Text.StringBuilder s)
228 return eq_s_b(s.Length, s.ToString());
231 protected internal virtual int find_among(
Among[] v,
int v_size)
242 bool first_key_inspected =
false;
246 int k = i + ((j - i) >> 1);
248 int common = common_i < common_j?common_i:common_j;
251 for (i2 = common; i2 < w.s_size; i2++)
258 diff = current[c + common] - w.s[i2];
284 if (first_key_inspected)
286 first_key_inspected =
true;
292 if (common_i >= w.s_size)
294 cursor = c + w.s_size;
295 if (w.method == null)
300 System.Object resobj = w.method.Invoke(w.methodobject, (System.Object[])
new System.Object[0]);
302 res = resobj.ToString().Equals(
"true");
304 catch (System.Reflection.TargetInvocationException)
309 catch (System.UnauthorizedAccessException)
314 cursor = c + w.s_size;
325 protected internal virtual int find_among_b(
Among[] v,
int v_size)
331 int lb = limit_backward;
336 bool first_key_inspected =
false;
340 int k = i + ((j - i) >> 1);
342 int common = common_i < common_j?common_i:common_j;
345 for (i2 = w.s_size - 1 - common; i2 >= 0; i2--)
347 if (c - common == lb)
352 diff = current[c - 1 - common] - w.s[i2];
373 if (first_key_inspected)
375 first_key_inspected =
true;
381 if (common_i >= w.s_size)
383 cursor = c - w.s_size;
384 if (w.method == null)
390 System.Object resobj = w.method.Invoke(w.methodobject, (System.Object[])
new System.Object[0]);
392 res = resobj.ToString().Equals(
"true");
394 catch (System.Reflection.TargetInvocationException)
399 catch (System.UnauthorizedAccessException)
404 cursor = c - w.s_size;
417 protected internal virtual int replace_s(
int c_bra,
int c_ket, System.String s)
419 int adjustment = s.Length - (c_ket - c_bra);
420 if (current.Length > bra)
421 current.Replace(current.ToString(bra, ket - bra), s, bra, ket - bra);
426 cursor += adjustment;
427 else if (cursor > c_bra)
432 protected internal virtual void slice_check()
434 if (bra < 0 || bra > ket || ket > limit || limit > current.Length)
437 System.Console.Error.WriteLine(
"faulty slice operation");
447 protected internal virtual void slice_from(System.String s)
450 replace_s(bra, ket, s);
453 protected internal virtual void slice_from(System.Text.StringBuilder s)
455 slice_from(s.ToString());
458 protected internal virtual void slice_del()
463 protected internal virtual void insert(
int c_bra,
int c_ket, System.String s)
465 int adjustment = replace_s(c_bra, c_ket, s);
472 protected internal virtual void insert(
int c_bra,
int c_ket, System.Text.StringBuilder s)
474 insert(c_bra, c_ket, s.ToString());
478 protected internal virtual System.Text.StringBuilder slice_to(System.Text.StringBuilder s)
483 s.Remove(0, s.Length);
484 s.Append(current.ToString(bra, len));
488 protected internal virtual System.Text.StringBuilder assign_to(System.Text.StringBuilder s)
491 s.Remove(0, s.Length);
492 s.Append(current.ToString(0, limit));