mittens 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/Gemfile +7 -0
  4. data/LICENSE.txt +30 -0
  5. data/README.md +62 -0
  6. data/Rakefile +21 -0
  7. data/ext/mittens/ext.c +96 -0
  8. data/ext/mittens/extconf.rb +12 -0
  9. data/lib/mittens/version.rb +3 -0
  10. data/lib/mittens.rb +7 -0
  11. data/mittens.gemspec +22 -0
  12. data/vendor/snowball/.gitignore +26 -0
  13. data/vendor/snowball/.travis.yml +112 -0
  14. data/vendor/snowball/AUTHORS +27 -0
  15. data/vendor/snowball/CONTRIBUTING.rst +216 -0
  16. data/vendor/snowball/COPYING +29 -0
  17. data/vendor/snowball/GNUmakefile +742 -0
  18. data/vendor/snowball/NEWS +754 -0
  19. data/vendor/snowball/README.rst +37 -0
  20. data/vendor/snowball/ada/README.md +74 -0
  21. data/vendor/snowball/ada/generate/generate.adb +83 -0
  22. data/vendor/snowball/ada/generate.gpr +21 -0
  23. data/vendor/snowball/ada/src/stemmer.adb +620 -0
  24. data/vendor/snowball/ada/src/stemmer.ads +219 -0
  25. data/vendor/snowball/ada/src/stemwords.adb +70 -0
  26. data/vendor/snowball/ada/stemmer_config.gpr +83 -0
  27. data/vendor/snowball/ada/stemwords.gpr +21 -0
  28. data/vendor/snowball/algorithms/arabic.sbl +558 -0
  29. data/vendor/snowball/algorithms/armenian.sbl +301 -0
  30. data/vendor/snowball/algorithms/basque.sbl +149 -0
  31. data/vendor/snowball/algorithms/catalan.sbl +202 -0
  32. data/vendor/snowball/algorithms/danish.sbl +93 -0
  33. data/vendor/snowball/algorithms/dutch.sbl +164 -0
  34. data/vendor/snowball/algorithms/english.sbl +229 -0
  35. data/vendor/snowball/algorithms/finnish.sbl +197 -0
  36. data/vendor/snowball/algorithms/french.sbl +254 -0
  37. data/vendor/snowball/algorithms/german.sbl +139 -0
  38. data/vendor/snowball/algorithms/german2.sbl +145 -0
  39. data/vendor/snowball/algorithms/greek.sbl +701 -0
  40. data/vendor/snowball/algorithms/hindi.sbl +323 -0
  41. data/vendor/snowball/algorithms/hungarian.sbl +241 -0
  42. data/vendor/snowball/algorithms/indonesian.sbl +192 -0
  43. data/vendor/snowball/algorithms/irish.sbl +149 -0
  44. data/vendor/snowball/algorithms/italian.sbl +202 -0
  45. data/vendor/snowball/algorithms/kraaij_pohlmann.sbl +240 -0
  46. data/vendor/snowball/algorithms/lithuanian.sbl +373 -0
  47. data/vendor/snowball/algorithms/lovins.sbl +208 -0
  48. data/vendor/snowball/algorithms/nepali.sbl +92 -0
  49. data/vendor/snowball/algorithms/norwegian.sbl +80 -0
  50. data/vendor/snowball/algorithms/porter.sbl +139 -0
  51. data/vendor/snowball/algorithms/portuguese.sbl +218 -0
  52. data/vendor/snowball/algorithms/romanian.sbl +236 -0
  53. data/vendor/snowball/algorithms/russian.sbl +221 -0
  54. data/vendor/snowball/algorithms/serbian.sbl +2379 -0
  55. data/vendor/snowball/algorithms/spanish.sbl +230 -0
  56. data/vendor/snowball/algorithms/swedish.sbl +72 -0
  57. data/vendor/snowball/algorithms/tamil.sbl +405 -0
  58. data/vendor/snowball/algorithms/turkish.sbl +470 -0
  59. data/vendor/snowball/algorithms/yiddish.sbl +460 -0
  60. data/vendor/snowball/charsets/ISO-8859-2.sbl +98 -0
  61. data/vendor/snowball/charsets/KOI8-R.sbl +74 -0
  62. data/vendor/snowball/charsets/cp850.sbl +130 -0
  63. data/vendor/snowball/compiler/analyser.c +1547 -0
  64. data/vendor/snowball/compiler/driver.c +615 -0
  65. data/vendor/snowball/compiler/generator.c +1748 -0
  66. data/vendor/snowball/compiler/generator_ada.c +1702 -0
  67. data/vendor/snowball/compiler/generator_csharp.c +1322 -0
  68. data/vendor/snowball/compiler/generator_go.c +1278 -0
  69. data/vendor/snowball/compiler/generator_java.c +1313 -0
  70. data/vendor/snowball/compiler/generator_js.c +1316 -0
  71. data/vendor/snowball/compiler/generator_pascal.c +1387 -0
  72. data/vendor/snowball/compiler/generator_python.c +1337 -0
  73. data/vendor/snowball/compiler/generator_rust.c +1295 -0
  74. data/vendor/snowball/compiler/header.h +418 -0
  75. data/vendor/snowball/compiler/space.c +286 -0
  76. data/vendor/snowball/compiler/syswords.h +86 -0
  77. data/vendor/snowball/compiler/syswords2.h +13 -0
  78. data/vendor/snowball/compiler/tokeniser.c +567 -0
  79. data/vendor/snowball/csharp/.gitignore +8 -0
  80. data/vendor/snowball/csharp/Snowball/Algorithms/.gitignore +1 -0
  81. data/vendor/snowball/csharp/Snowball/Among.cs +108 -0
  82. data/vendor/snowball/csharp/Snowball/AssemblyInfo.cs +36 -0
  83. data/vendor/snowball/csharp/Snowball/Stemmer.cs +660 -0
  84. data/vendor/snowball/csharp/Stemwords/App.config +6 -0
  85. data/vendor/snowball/csharp/Stemwords/Program.cs +114 -0
  86. data/vendor/snowball/doc/TODO +12 -0
  87. data/vendor/snowball/doc/libstemmer_c_README +148 -0
  88. data/vendor/snowball/doc/libstemmer_csharp_README +53 -0
  89. data/vendor/snowball/doc/libstemmer_java_README +67 -0
  90. data/vendor/snowball/doc/libstemmer_js_README +48 -0
  91. data/vendor/snowball/doc/libstemmer_python_README +113 -0
  92. data/vendor/snowball/examples/stemwords.c +204 -0
  93. data/vendor/snowball/go/README.md +55 -0
  94. data/vendor/snowball/go/among.go +16 -0
  95. data/vendor/snowball/go/env.go +403 -0
  96. data/vendor/snowball/go/stemwords/generate.go +68 -0
  97. data/vendor/snowball/go/stemwords/main.go +68 -0
  98. data/vendor/snowball/go/util.go +34 -0
  99. data/vendor/snowball/iconv.py +50 -0
  100. data/vendor/snowball/include/libstemmer.h +78 -0
  101. data/vendor/snowball/java/org/tartarus/snowball/Among.java +29 -0
  102. data/vendor/snowball/java/org/tartarus/snowball/SnowballProgram.java +381 -0
  103. data/vendor/snowball/java/org/tartarus/snowball/SnowballStemmer.java +8 -0
  104. data/vendor/snowball/java/org/tartarus/snowball/TestApp.java +75 -0
  105. data/vendor/snowball/javascript/base-stemmer.js +294 -0
  106. data/vendor/snowball/javascript/stemwords.js +106 -0
  107. data/vendor/snowball/libstemmer/libstemmer_c.in +96 -0
  108. data/vendor/snowball/libstemmer/mkalgorithms.pl +90 -0
  109. data/vendor/snowball/libstemmer/mkmodules.pl +267 -0
  110. data/vendor/snowball/libstemmer/modules.txt +63 -0
  111. data/vendor/snowball/libstemmer/test.c +34 -0
  112. data/vendor/snowball/pascal/.gitignore +4 -0
  113. data/vendor/snowball/pascal/SnowballProgram.pas +430 -0
  114. data/vendor/snowball/pascal/generate.pl +23 -0
  115. data/vendor/snowball/pascal/stemwords-template.dpr +78 -0
  116. data/vendor/snowball/python/MANIFEST.in +7 -0
  117. data/vendor/snowball/python/create_init.py +54 -0
  118. data/vendor/snowball/python/setup.cfg +6 -0
  119. data/vendor/snowball/python/setup.py +81 -0
  120. data/vendor/snowball/python/snowballstemmer/among.py +13 -0
  121. data/vendor/snowball/python/snowballstemmer/basestemmer.py +323 -0
  122. data/vendor/snowball/python/stemwords.py +101 -0
  123. data/vendor/snowball/python/testapp.py +28 -0
  124. data/vendor/snowball/runtime/api.c +58 -0
  125. data/vendor/snowball/runtime/api.h +32 -0
  126. data/vendor/snowball/runtime/header.h +61 -0
  127. data/vendor/snowball/runtime/utilities.c +513 -0
  128. data/vendor/snowball/rust/Cargo.toml +7 -0
  129. data/vendor/snowball/rust/build.rs +55 -0
  130. data/vendor/snowball/rust/rust-pre-1.27-compat.patch +30 -0
  131. data/vendor/snowball/rust/src/main.rs +102 -0
  132. data/vendor/snowball/rust/src/snowball/algorithms/mod.rs +2 -0
  133. data/vendor/snowball/rust/src/snowball/among.rs +6 -0
  134. data/vendor/snowball/rust/src/snowball/mod.rs +6 -0
  135. data/vendor/snowball/rust/src/snowball/snowball_env.rs +421 -0
  136. data/vendor/snowball/tests/stemtest.c +95 -0
  137. metadata +178 -0
@@ -0,0 +1,660 @@
1
+ // Copyright (c) 2001, Dr Martin Porter
2
+ // Copyright (c) 2002, Richard Boulton
3
+ // Copyright (c) 2015, Cesar Souza
4
+ // Copyright (c) 2018, Olly Betts
5
+ // All rights reserved.
6
+ //
7
+ // Redistribution and use in source and binary forms, with or without
8
+ // modification, are permitted provided that the following conditions are met:
9
+ //
10
+ // * Redistributions of source code must retain the above copyright notice,
11
+ // * this list of conditions and the following disclaimer.
12
+ // * Redistributions in binary form must reproduce the above copyright
13
+ // * notice, this list of conditions and the following disclaimer in the
14
+ // * documentation and/or other materials provided with the distribution.
15
+ // * Neither the name of the copyright holders nor the names of its contributors
16
+ // * may be used to endorse or promote products derived from this software
17
+ // * without specific prior written permission.
18
+ //
19
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
23
+ // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ namespace Snowball
31
+ {
32
+ using System;
33
+ using System.Linq;
34
+ using System.Text;
35
+
36
+ /// <summary>
37
+ /// Class holding current state.
38
+ /// </summary>
39
+ ///
40
+ public class Env
41
+ {
42
+ /// <summary>
43
+ /// Initializes a new instance of the <see cref="Env"/> class.
44
+ /// </summary>
45
+ ///
46
+ protected Env()
47
+ {
48
+ }
49
+
50
+ /// <summary>
51
+ /// Gets the current string.
52
+ /// </summary>
53
+ ///
54
+ protected StringBuilder current;
55
+
56
+ /// <summary>
57
+ /// Current cursor position.
58
+ /// </summary>
59
+ ///
60
+ protected int cursor;
61
+
62
+ /// <summary>
63
+ /// Forward limit for inspecting the buffer.
64
+ /// </summary>
65
+ ///
66
+ protected int limit;
67
+
68
+ /// <summary>
69
+ /// Backward limit for inspecting the buffer.
70
+ /// </summary>
71
+ ///
72
+ protected int limit_backward;
73
+
74
+ /// <summary>
75
+ /// Starting bracket position.
76
+ /// </summary>
77
+ ///
78
+ protected int bra;
79
+
80
+ /// <summary>
81
+ /// Ending bracket position.
82
+ /// </summary>
83
+ ///
84
+ protected int ket;
85
+
86
+ /// <summary>
87
+ /// Copy another Env object.
88
+ /// </summary>
89
+ ///
90
+ public Env(Env other)
91
+ {
92
+ copy_from(other);
93
+ }
94
+
95
+ /// <summary>
96
+ /// Copy another Env object.
97
+ /// </summary>
98
+ ///
99
+ protected void copy_from(Env other)
100
+ {
101
+ current = other.current;
102
+ cursor = other.cursor;
103
+ limit = other.limit;
104
+ limit_backward = other.limit_backward;
105
+ bra = other.bra;
106
+ ket = other.ket;
107
+ }
108
+ }
109
+
110
+
111
+ /// <summary>
112
+ /// Base class for Snowball's stemmer algorithms.
113
+ /// </summary>
114
+ ///
115
+ public abstract class Stemmer : Env
116
+ {
117
+ /// <summary>
118
+ /// Initializes a new instance of the <see cref="Stemmer"/> class.
119
+ /// </summary>
120
+ ///
121
+ protected Stemmer()
122
+ {
123
+ current = new StringBuilder();
124
+ setBufferContents("");
125
+ }
126
+
127
+
128
+ /// <summary>
129
+ /// Calls the stemmer to process the next word.
130
+ /// </summary>
131
+ ///
132
+ protected abstract bool stem();
133
+
134
+
135
+ /// <summary>
136
+ /// Stems the buffer's contents.
137
+ /// </summary>
138
+ ///
139
+ public bool Stem()
140
+ {
141
+ return this.stem();
142
+ }
143
+
144
+ /// <summary>
145
+ /// Stems a given word.
146
+ /// </summary>
147
+ ///
148
+ /// <param name="word">The word to be stemmed.</param>
149
+ ///
150
+ /// <returns>The stemmed word.</returns>
151
+ ///
152
+ public string Stem(string word)
153
+ {
154
+ setBufferContents(word);
155
+ this.stem();
156
+ return current.ToString();
157
+ }
158
+
159
+
160
+ /// <summary>
161
+ /// Gets the current processing buffer.
162
+ /// </summary>
163
+ ///
164
+ public StringBuilder Buffer
165
+ {
166
+ get { return current; }
167
+ }
168
+
169
+ /// <summary>
170
+ /// Gets or sets the current word to be stemmed
171
+ /// or the stemmed word, if the stemmer has been
172
+ /// processed.
173
+ /// </summary>
174
+ ///
175
+ public string Current
176
+ {
177
+ get { return current.ToString(); }
178
+ set { setBufferContents(value); }
179
+ }
180
+
181
+ private void setBufferContents(string value)
182
+ {
183
+ current.Clear();
184
+ current.Insert(0, value);
185
+
186
+ cursor = 0;
187
+ limit = current.Length;
188
+ limit_backward = 0;
189
+ bra = cursor;
190
+ ket = limit;
191
+ }
192
+
193
+
194
+ /// <summary>
195
+ /// Determines whether the current character is
196
+ /// inside a given group of characters <c>s</c>.
197
+ /// </summary>
198
+ protected int in_grouping(string s, int min, int max, bool repeat)
199
+ {
200
+ do
201
+ {
202
+ if (cursor >= limit)
203
+ return -1;
204
+
205
+ char ch = current[cursor];
206
+ if (ch > max || ch < min)
207
+ return 1;
208
+
209
+ if (!s.Contains(ch))
210
+ return 1;
211
+
212
+ cursor++;
213
+ }
214
+ while (repeat);
215
+
216
+ return 0;
217
+ }
218
+
219
+ /// <summary>
220
+ /// Determines whether the current character is
221
+ /// inside a given group of characters <c>s</c>.
222
+ /// </summary>
223
+ protected int in_grouping_b(string s, int min, int max, bool repeat)
224
+ {
225
+ do
226
+ {
227
+ if (cursor <= limit_backward)
228
+ return -1;
229
+
230
+ char ch = current[cursor - 1];
231
+ if (ch > max || ch < min)
232
+ return 1;
233
+
234
+ if (!s.Contains(ch))
235
+ return 1;
236
+
237
+ cursor--;
238
+ } while (repeat);
239
+
240
+ return 0;
241
+ }
242
+
243
+ /// <summary>
244
+ /// Determines whether the current character is
245
+ /// outside a given group of characters <c>s</c>.
246
+ /// </summary>
247
+ protected int out_grouping(string s, int min, int max, bool repeat)
248
+ {
249
+ do
250
+ {
251
+ if (cursor >= limit)
252
+ return -1;
253
+
254
+ char ch = current[cursor];
255
+ if (ch > max || ch < min)
256
+ {
257
+ cursor++;
258
+ continue;
259
+ }
260
+
261
+ if (!s.Contains(ch))
262
+ {
263
+ cursor++;
264
+ continue;
265
+ }
266
+
267
+ return 1;
268
+
269
+ } while (repeat);
270
+
271
+ return 0;
272
+ }
273
+
274
+ /// <summary>
275
+ /// Determines whether the current character is
276
+ /// outside a given group of characters <c>s</c>.
277
+ /// </summary>
278
+ protected int out_grouping_b(string s, int min, int max, bool repeat)
279
+ {
280
+ do
281
+ {
282
+ if (cursor <= limit_backward)
283
+ return -1;
284
+
285
+ char ch = current[cursor - 1];
286
+ if (ch > max || ch < min)
287
+ {
288
+ cursor--;
289
+ continue;
290
+ }
291
+
292
+ if (!s.Contains(ch))
293
+ {
294
+ cursor--;
295
+ continue;
296
+ }
297
+
298
+ return 1;
299
+ }
300
+ while (repeat);
301
+
302
+ return 0;
303
+ }
304
+
305
+
306
+ /// <summary>
307
+ /// Determines if the current buffer contains the
308
+ /// string s, starting from the current position and
309
+ /// going forward.
310
+ /// </summary>
311
+ protected bool eq_s(String s)
312
+ {
313
+ if (limit - cursor < s.Length)
314
+ return false;
315
+
316
+ for (int i = 0; i != s.Length; i++)
317
+ {
318
+ if (current[cursor + i] != s[i])
319
+ return false;
320
+ }
321
+
322
+ cursor += s.Length;
323
+ return true;
324
+ }
325
+
326
+ /// <summary>
327
+ /// Determines if the current buffer contains the
328
+ /// string s, starting from the current position and
329
+ /// going backwards.
330
+ /// </summary>
331
+ protected bool eq_s_b(String s)
332
+ {
333
+ if (cursor - limit_backward < s.Length)
334
+ return false;
335
+
336
+ for (int i = 0; i != s.Length; i++)
337
+ {
338
+ if (current[cursor - s.Length + i] != s[i])
339
+ return false;
340
+ }
341
+
342
+ cursor -= s.Length;
343
+ return true;
344
+ }
345
+
346
+ /// <summary>
347
+ /// Determines if the current buffer contains the
348
+ /// string s, starting from the current position and
349
+ /// going backwards.
350
+ /// </summary>
351
+ protected bool eq_s_b(StringBuilder s)
352
+ {
353
+ if (cursor - limit_backward < s.Length)
354
+ return false;
355
+
356
+ for (int i = 0; i != s.Length; i++)
357
+ {
358
+ if (current[cursor - s.Length + i] != s[i])
359
+ return false;
360
+ }
361
+
362
+ cursor -= s.Length;
363
+ return true;
364
+ }
365
+
366
+
367
+ /// <summary>
368
+ /// Searches if the current buffer matches against one of the
369
+ /// amongs, starting from the current cursor position and going
370
+ /// forward.
371
+ /// </summary>
372
+ ///
373
+ protected int find_among(Among[] v)
374
+ {
375
+ int i = 0;
376
+ int j = v.Length;
377
+
378
+ int c = cursor;
379
+ int l = limit;
380
+
381
+ int common_i = 0;
382
+ int common_j = 0;
383
+
384
+ bool first_key_inspected = false;
385
+
386
+ while (true)
387
+ {
388
+ int k = i + ((j - i) >> 1);
389
+ int diff = 0;
390
+ int common = common_i < common_j ? common_i : common_j; // smaller
391
+
392
+ Among w = v[k];
393
+
394
+ for (int i2 = common; i2 < w.SearchString.Length; i2++)
395
+ {
396
+ if (c + common == l)
397
+ {
398
+ diff = -1;
399
+ break;
400
+ }
401
+
402
+ diff = current[c + common] - w.SearchString[i2];
403
+
404
+ if (diff != 0)
405
+ break;
406
+
407
+ common++;
408
+ }
409
+
410
+ if (diff < 0)
411
+ {
412
+ j = k;
413
+ common_j = common;
414
+ }
415
+ else
416
+ {
417
+ i = k;
418
+ common_i = common;
419
+ }
420
+
421
+ if (j - i <= 1)
422
+ {
423
+ if (i > 0)
424
+ break; // v->s has been inspected
425
+
426
+ if (j == i)
427
+ break; // only one item in v
428
+
429
+ // - but now we need to go round once more to get
430
+ // v->s inspected. This looks messy, but is actually
431
+ // the optimal approach.
432
+
433
+ if (first_key_inspected)
434
+ break;
435
+
436
+ first_key_inspected = true;
437
+ }
438
+ }
439
+
440
+ while (true)
441
+ {
442
+ Among w = v[i];
443
+
444
+ if (common_i >= w.SearchString.Length)
445
+ {
446
+ cursor = c + w.SearchString.Length;
447
+
448
+ if (w.Action == null)
449
+ return w.Result;
450
+
451
+ bool res = w.Action();
452
+ cursor = c + w.SearchString.Length;
453
+
454
+ if (res)
455
+ return w.Result;
456
+ }
457
+
458
+ i = w.MatchIndex;
459
+
460
+ if (i < 0)
461
+ return 0;
462
+ }
463
+ }
464
+
465
+ /// <summary>
466
+ /// Searches if the current buffer matches against one of the
467
+ /// amongs, starting from the current cursor position and going
468
+ /// backwards.
469
+ /// </summary>
470
+ ///
471
+ protected int find_among_b(Among[] v)
472
+ {
473
+ int i = 0;
474
+ int j = v.Length;
475
+
476
+ int c = cursor;
477
+ int lb = limit_backward;
478
+
479
+ int common_i = 0;
480
+ int common_j = 0;
481
+
482
+ bool first_key_inspected = false;
483
+
484
+ while (true)
485
+ {
486
+ int k = i + ((j - i) >> 1);
487
+ int diff = 0;
488
+ int common = common_i < common_j ? common_i : common_j;
489
+ Among w = v[k];
490
+
491
+ for (int i2 = w.SearchString.Length - 1 - common; i2 >= 0; i2--)
492
+ {
493
+ if (c - common == lb)
494
+ {
495
+ diff = -1;
496
+ break;
497
+ }
498
+
499
+ diff = current[c - 1 - common] - w.SearchString[i2];
500
+
501
+ if (diff != 0)
502
+ break;
503
+
504
+ common++;
505
+ }
506
+
507
+ if (diff < 0)
508
+ {
509
+ j = k;
510
+ common_j = common;
511
+ }
512
+ else
513
+ {
514
+ i = k;
515
+ common_i = common;
516
+ }
517
+
518
+ if (j - i <= 1)
519
+ {
520
+ if (i > 0)
521
+ break;
522
+
523
+ if (j == i)
524
+ break;
525
+
526
+ if (first_key_inspected)
527
+ break;
528
+
529
+ first_key_inspected = true;
530
+ }
531
+ }
532
+
533
+ while (true)
534
+ {
535
+ Among w = v[i];
536
+
537
+ if (common_i >= w.SearchString.Length)
538
+ {
539
+ cursor = c - w.SearchString.Length;
540
+
541
+ if (w.Action == null)
542
+ return w.Result;
543
+
544
+ bool res = w.Action();
545
+ cursor = c - w.SearchString.Length;
546
+
547
+ if (res)
548
+ return w.Result;
549
+ }
550
+
551
+ i = w.MatchIndex;
552
+
553
+ if (i < 0)
554
+ return 0;
555
+ }
556
+ }
557
+
558
+ /// <summary>
559
+ /// Replaces the characters between <c>c_bra</c>
560
+ /// and <c>c_ket</c> by the characters in s.
561
+ /// </summary>
562
+ ///
563
+ protected int replace_s(int c_bra, int c_ket, String s)
564
+ {
565
+ int adjustment = s.Length - (c_ket - c_bra);
566
+ Replace(current, c_bra, c_ket, s);
567
+ limit += adjustment;
568
+ if (cursor >= c_ket)
569
+ cursor += adjustment;
570
+ else if (cursor > c_bra)
571
+ cursor = c_bra;
572
+ return adjustment;
573
+ }
574
+
575
+ /// <summary>
576
+ /// Checks if a slicing can be done.
577
+ /// </summary>
578
+ protected void slice_check()
579
+ {
580
+ if (bra < 0 || bra > ket || ket > limit || limit > current.Length)
581
+ {
582
+ System.Diagnostics.Trace.WriteLine("faulty slice operation");
583
+ }
584
+ }
585
+
586
+ /// <summary>
587
+ /// Replaces the contents of the bracket with the string s.
588
+ /// </summary>
589
+ ///
590
+ /// <param name="s">The s.</param>
591
+ protected void slice_from(String s)
592
+ {
593
+ slice_check();
594
+ replace_s(bra, ket, s);
595
+ }
596
+
597
+ /// <summary>
598
+ /// Removes the current bracket contents.
599
+ /// </summary>
600
+ ///
601
+ protected void slice_del()
602
+ {
603
+ slice_from("");
604
+ }
605
+
606
+ /// <summary>
607
+ /// Replaces the contents of the bracket with the string s.
608
+ /// </summary>
609
+ ///
610
+ protected void insert(int c_bra, int c_ket, String s)
611
+ {
612
+ int adjustment = replace_s(c_bra, c_ket, s);
613
+ if (c_bra <= bra) bra += adjustment;
614
+ if (c_bra <= ket) ket += adjustment;
615
+ }
616
+
617
+ /// <summary>
618
+ /// Replaces the contents of the bracket with the string s.
619
+ /// </summary>
620
+ ///
621
+ protected void insert(int c_bra, int c_ket, StringBuilder s)
622
+ {
623
+ int adjustment = replace_s(c_bra, c_ket, s.ToString());
624
+ if (c_bra <= bra) bra += adjustment;
625
+ if (c_bra <= ket) ket += adjustment;
626
+ }
627
+
628
+ /// <summary>
629
+ /// Replaces the contents of the bracket with the string s.
630
+ /// </summary>
631
+ ///
632
+ protected void slice_to(StringBuilder s)
633
+ {
634
+ slice_check();
635
+ Replace(s, 0, s.Length, current.ToString(bra, ket - bra));
636
+ }
637
+
638
+ /// <summary>
639
+ /// Replaces the contents of the bracket with the string s.
640
+ /// </summary>
641
+ ///
642
+ protected void assign_to(StringBuilder s)
643
+ {
644
+ Replace(s, 0, s.Length, current.ToString(0, limit));
645
+ }
646
+
647
+
648
+
649
+ /// <summary>
650
+ /// Replaces a specific region of the buffer with another text.
651
+ /// </summary>
652
+ public static StringBuilder Replace(StringBuilder sb, int index, int length, string text)
653
+ {
654
+ sb.Remove(index, length - index);
655
+ sb.Insert(index, text);
656
+ return sb;
657
+ }
658
+
659
+ }
660
+ }
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <configuration>
3
+ <startup>
4
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5
+ </startup>
6
+ </configuration>