@weshell/chess.js 0.0.0-stage → 1.0.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 (51) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +87 -2
  3. package/dist/attack.d.ts +32 -0
  4. package/dist/attack.d.ts.map +1 -0
  5. package/dist/attack.js +103 -0
  6. package/dist/attack.js.map +1 -0
  7. package/dist/board.d.ts +33 -0
  8. package/dist/board.d.ts.map +1 -0
  9. package/dist/board.js +49 -0
  10. package/dist/board.js.map +1 -0
  11. package/dist/chess.d.ts +232 -0
  12. package/dist/chess.d.ts.map +1 -0
  13. package/dist/chess.js +1335 -0
  14. package/dist/chess.js.map +1 -0
  15. package/dist/fen.d.ts +38 -0
  16. package/dist/fen.d.ts.map +1 -0
  17. package/dist/fen.js +308 -0
  18. package/dist/fen.js.map +1 -0
  19. package/dist/hash.d.ts +34 -0
  20. package/dist/hash.d.ts.map +1 -0
  21. package/dist/hash.js +98 -0
  22. package/dist/hash.js.map +1 -0
  23. package/dist/index.d.ts +3 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +2 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/move.d.ts +55 -0
  28. package/dist/move.d.ts.map +1 -0
  29. package/dist/move.js +79 -0
  30. package/dist/move.js.map +1 -0
  31. package/dist/movegen.d.ts +34 -0
  32. package/dist/movegen.d.ts.map +1 -0
  33. package/dist/movegen.js +242 -0
  34. package/dist/movegen.js.map +1 -0
  35. package/dist/node.d.ts +8 -0
  36. package/dist/node.d.ts.map +1 -0
  37. package/dist/node.js +2 -0
  38. package/dist/node.js.map +1 -0
  39. package/dist/notation.d.ts +33 -0
  40. package/dist/notation.d.ts.map +1 -0
  41. package/dist/notation.js +257 -0
  42. package/dist/notation.js.map +1 -0
  43. package/dist/pgn.d.ts +12 -0
  44. package/dist/pgn.d.ts.map +1 -0
  45. package/dist/pgn.js +1347 -0
  46. package/dist/pgn.js.map +1 -0
  47. package/dist/types.d.ts +118 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +237 -0
  50. package/dist/types.js.map +1 -0
  51. package/package.json +45 -4
package/dist/pgn.js ADDED
@@ -0,0 +1,1347 @@
1
+ // @generated by Peggy 4.2.0.
2
+ //
3
+ // https://peggyjs.org/
4
+ function rootNode(comment) {
5
+ return comment !== null ? { comment, variations: [] } : { variations: [] };
6
+ }
7
+ function node(move, suffix, nag, comment, variations) {
8
+ const node = { move, variations };
9
+ if (suffix) {
10
+ node.suffix = suffix;
11
+ }
12
+ if (nag) {
13
+ node.nag = nag;
14
+ }
15
+ if (comment !== null) {
16
+ node.comment = comment;
17
+ }
18
+ return node;
19
+ }
20
+ function lineToTree(...nodes) {
21
+ const [root, ...rest] = nodes;
22
+ let parent = root;
23
+ for (const child of rest) {
24
+ if (child !== null) {
25
+ parent.variations = [child, ...child.variations];
26
+ child.variations = [];
27
+ parent = child;
28
+ }
29
+ }
30
+ return root;
31
+ }
32
+ function pgn(headers, game) {
33
+ if (game.marker && game.marker.comment) {
34
+ let node = game.root;
35
+ while (true) {
36
+ const next = node.variations[0];
37
+ if (!next) {
38
+ node.comment = game.marker.comment;
39
+ break;
40
+ }
41
+ node = next;
42
+ }
43
+ }
44
+ return {
45
+ headers,
46
+ root: game.root,
47
+ result: (game.marker && game.marker.result) ?? undefined
48
+ };
49
+ }
50
+ function peg$subclass(child, parent) {
51
+ function C() { this.constructor = child; }
52
+ C.prototype = parent.prototype;
53
+ child.prototype = new C();
54
+ }
55
+ function peg$SyntaxError(message, expected, found, location) {
56
+ var self = Error.call(this, message);
57
+ // istanbul ignore next Check is a necessary evil to support older environments
58
+ if (Object.setPrototypeOf) {
59
+ Object.setPrototypeOf(self, peg$SyntaxError.prototype);
60
+ }
61
+ self.expected = expected;
62
+ self.found = found;
63
+ self.location = location;
64
+ self.name = "SyntaxError";
65
+ return self;
66
+ }
67
+ peg$subclass(peg$SyntaxError, Error);
68
+ function peg$padEnd(str, targetLength, padString) {
69
+ padString = padString || " ";
70
+ if (str.length > targetLength) {
71
+ return str;
72
+ }
73
+ targetLength -= str.length;
74
+ padString += padString.repeat(targetLength);
75
+ return str + padString.slice(0, targetLength);
76
+ }
77
+ peg$SyntaxError.prototype.format = function (sources) {
78
+ var str = "Error: " + this.message;
79
+ if (this.location) {
80
+ var src = null;
81
+ var k;
82
+ for (k = 0; k < sources.length; k++) {
83
+ if (sources[k].source === this.location.source) {
84
+ src = sources[k].text.split(/\r\n|\n|\r/g);
85
+ break;
86
+ }
87
+ }
88
+ var s = this.location.start;
89
+ var offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
90
+ ? this.location.source.offset(s)
91
+ : s;
92
+ var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
93
+ if (src) {
94
+ var e = this.location.end;
95
+ var filler = peg$padEnd("", offset_s.line.toString().length, ' ');
96
+ var line = src[s.line - 1];
97
+ var last = s.line === e.line ? e.column : line.length + 1;
98
+ var hatLen = (last - s.column) || 1;
99
+ str += "\n --> " + loc + "\n"
100
+ + filler + " |\n"
101
+ + offset_s.line + " | " + line + "\n"
102
+ + filler + " | " + peg$padEnd("", s.column - 1, ' ')
103
+ + peg$padEnd("", hatLen, "^");
104
+ }
105
+ else {
106
+ str += "\n at " + loc;
107
+ }
108
+ }
109
+ return str;
110
+ };
111
+ peg$SyntaxError.buildMessage = function (expected, found) {
112
+ var DESCRIBE_EXPECTATION_FNS = {
113
+ literal: function (expectation) {
114
+ return "\"" + literalEscape(expectation.text) + "\"";
115
+ },
116
+ class: function (expectation) {
117
+ var escapedParts = expectation.parts.map(function (part) {
118
+ return Array.isArray(part)
119
+ ? classEscape(part[0]) + "-" + classEscape(part[1])
120
+ : classEscape(part);
121
+ });
122
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
123
+ },
124
+ any: function () {
125
+ return "any character";
126
+ },
127
+ end: function () {
128
+ return "end of input";
129
+ },
130
+ other: function (expectation) {
131
+ return expectation.description;
132
+ }
133
+ };
134
+ function hex(ch) {
135
+ return ch.charCodeAt(0).toString(16).toUpperCase();
136
+ }
137
+ function literalEscape(s) {
138
+ return s
139
+ .replace(/\\/g, "\\\\")
140
+ .replace(/"/g, "\\\"")
141
+ .replace(/\0/g, "\\0")
142
+ .replace(/\t/g, "\\t")
143
+ .replace(/\n/g, "\\n")
144
+ .replace(/\r/g, "\\r")
145
+ .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
146
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
147
+ }
148
+ function classEscape(s) {
149
+ return s
150
+ .replace(/\\/g, "\\\\")
151
+ .replace(/\]/g, "\\]")
152
+ .replace(/\^/g, "\\^")
153
+ .replace(/-/g, "\\-")
154
+ .replace(/\0/g, "\\0")
155
+ .replace(/\t/g, "\\t")
156
+ .replace(/\n/g, "\\n")
157
+ .replace(/\r/g, "\\r")
158
+ .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
159
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
160
+ }
161
+ function describeExpectation(expectation) {
162
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
163
+ }
164
+ function describeExpected(expected) {
165
+ var descriptions = expected.map(describeExpectation);
166
+ var i, j;
167
+ descriptions.sort();
168
+ if (descriptions.length > 0) {
169
+ for (i = 1, j = 1; i < descriptions.length; i++) {
170
+ if (descriptions[i - 1] !== descriptions[i]) {
171
+ descriptions[j] = descriptions[i];
172
+ j++;
173
+ }
174
+ }
175
+ descriptions.length = j;
176
+ }
177
+ switch (descriptions.length) {
178
+ case 1:
179
+ return descriptions[0];
180
+ case 2:
181
+ return descriptions[0] + " or " + descriptions[1];
182
+ default:
183
+ return descriptions.slice(0, -1).join(", ")
184
+ + ", or "
185
+ + descriptions[descriptions.length - 1];
186
+ }
187
+ }
188
+ function describeFound(found) {
189
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
190
+ }
191
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
192
+ };
193
+ function peg$parse(input, options) {
194
+ options = options !== undefined ? options : {};
195
+ var peg$FAILED = {};
196
+ var peg$source = options.grammarSource;
197
+ var peg$startRuleFunctions = { pgn: peg$parsepgn };
198
+ var peg$startRuleFunction = peg$parsepgn;
199
+ var peg$c0 = "[";
200
+ var peg$c1 = "\"";
201
+ var peg$c2 = "]";
202
+ var peg$c3 = ".";
203
+ var peg$c4 = "O-O-O";
204
+ var peg$c5 = "O-O";
205
+ var peg$c6 = "0-0-0";
206
+ var peg$c7 = "0-0";
207
+ var peg$c8 = "$";
208
+ var peg$c9 = "{";
209
+ var peg$c10 = "}";
210
+ var peg$c11 = ";";
211
+ var peg$c12 = "(";
212
+ var peg$c13 = ")";
213
+ var peg$c14 = "1-0";
214
+ var peg$c15 = "0-1";
215
+ var peg$c16 = "1/2-1/2";
216
+ var peg$c17 = "*";
217
+ var peg$r0 = /^[a-zA-Z]/;
218
+ var peg$r1 = /^[^"]/;
219
+ var peg$r2 = /^[0-9]/;
220
+ var peg$r3 = /^[.]/;
221
+ var peg$r4 = /^[a-zA-Z1-8\-=]/;
222
+ var peg$r5 = /^[+#]/;
223
+ var peg$r6 = /^[!?]/;
224
+ var peg$r7 = /^[^}]/;
225
+ var peg$r8 = /^[^\r\n]/;
226
+ var peg$r9 = /^[ \t\r\n]/;
227
+ var peg$e0 = peg$otherExpectation("tag pair");
228
+ var peg$e1 = peg$literalExpectation("[", false);
229
+ var peg$e2 = peg$literalExpectation("\"", false);
230
+ var peg$e3 = peg$literalExpectation("]", false);
231
+ var peg$e4 = peg$otherExpectation("tag name");
232
+ var peg$e5 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false);
233
+ var peg$e6 = peg$otherExpectation("tag value");
234
+ var peg$e7 = peg$classExpectation(["\""], true, false);
235
+ var peg$e8 = peg$otherExpectation("move number");
236
+ var peg$e9 = peg$classExpectation([["0", "9"]], false, false);
237
+ var peg$e10 = peg$literalExpectation(".", false);
238
+ var peg$e11 = peg$classExpectation(["."], false, false);
239
+ var peg$e12 = peg$otherExpectation("standard algebraic notation");
240
+ var peg$e13 = peg$literalExpectation("O-O-O", false);
241
+ var peg$e14 = peg$literalExpectation("O-O", false);
242
+ var peg$e15 = peg$literalExpectation("0-0-0", false);
243
+ var peg$e16 = peg$literalExpectation("0-0", false);
244
+ var peg$e17 = peg$classExpectation([["a", "z"], ["A", "Z"], ["1", "8"], "-", "="], false, false);
245
+ var peg$e18 = peg$classExpectation(["+", "#"], false, false);
246
+ var peg$e19 = peg$otherExpectation("suffix annotation");
247
+ var peg$e20 = peg$classExpectation(["!", "?"], false, false);
248
+ var peg$e21 = peg$otherExpectation("NAG");
249
+ var peg$e22 = peg$literalExpectation("$", false);
250
+ var peg$e23 = peg$otherExpectation("brace comment");
251
+ var peg$e24 = peg$literalExpectation("{", false);
252
+ var peg$e25 = peg$classExpectation(["}"], true, false);
253
+ var peg$e26 = peg$literalExpectation("}", false);
254
+ var peg$e27 = peg$otherExpectation("rest of line comment");
255
+ var peg$e28 = peg$literalExpectation(";", false);
256
+ var peg$e29 = peg$classExpectation(["\r", "\n"], true, false);
257
+ var peg$e30 = peg$otherExpectation("variation");
258
+ var peg$e31 = peg$literalExpectation("(", false);
259
+ var peg$e32 = peg$literalExpectation(")", false);
260
+ var peg$e33 = peg$otherExpectation("game termination marker");
261
+ var peg$e34 = peg$literalExpectation("1-0", false);
262
+ var peg$e35 = peg$literalExpectation("0-1", false);
263
+ var peg$e36 = peg$literalExpectation("1/2-1/2", false);
264
+ var peg$e37 = peg$literalExpectation("*", false);
265
+ var peg$e38 = peg$otherExpectation("whitespace");
266
+ var peg$e39 = peg$classExpectation([" ", "\t", "\r", "\n"], false, false);
267
+ var peg$f0 = function (headers, game) { return pgn(headers, game); };
268
+ var peg$f1 = function (tagPairs) { return Object.fromEntries(tagPairs); };
269
+ var peg$f2 = function (tagName, tagValue) { return [tagName, tagValue]; };
270
+ var peg$f3 = function (root, marker) { return { root, marker }; };
271
+ var peg$f4 = function (comment, moves) { return lineToTree(rootNode(comment), ...moves.flat()); };
272
+ var peg$f5 = function (san, suffix, nag, comment, variations) { return node(san, suffix, nag, comment, variations); };
273
+ var peg$f6 = function (nag) { return nag; };
274
+ var peg$f7 = function (comment) { return comment.replace(/[\r\n]+/g, " "); };
275
+ var peg$f8 = function (comment) { return comment.trim(); };
276
+ var peg$f9 = function (line) { return line; };
277
+ var peg$f10 = function (result, comment) { return { result, comment }; };
278
+ var peg$currPos = options.peg$currPos | 0;
279
+ var peg$savedPos = peg$currPos;
280
+ var peg$posDetailsCache = [{ line: 1, column: 1 }];
281
+ var peg$maxFailPos = peg$currPos;
282
+ var peg$maxFailExpected = options.peg$maxFailExpected || [];
283
+ var peg$silentFails = options.peg$silentFails | 0;
284
+ var peg$result;
285
+ if (options.startRule) {
286
+ if (!(options.startRule in peg$startRuleFunctions)) {
287
+ throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
288
+ }
289
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
290
+ }
291
+ function text() {
292
+ return input.substring(peg$savedPos, peg$currPos);
293
+ }
294
+ function offset() {
295
+ return peg$savedPos;
296
+ }
297
+ function range() {
298
+ return {
299
+ source: peg$source,
300
+ start: peg$savedPos,
301
+ end: peg$currPos
302
+ };
303
+ }
304
+ function location() {
305
+ return peg$computeLocation(peg$savedPos, peg$currPos);
306
+ }
307
+ function expected(description, location) {
308
+ location = location !== undefined
309
+ ? location
310
+ : peg$computeLocation(peg$savedPos, peg$currPos);
311
+ throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location);
312
+ }
313
+ function error(message, location) {
314
+ location = location !== undefined
315
+ ? location
316
+ : peg$computeLocation(peg$savedPos, peg$currPos);
317
+ throw peg$buildSimpleError(message, location);
318
+ }
319
+ function peg$literalExpectation(text, ignoreCase) {
320
+ return { type: "literal", text: text, ignoreCase: ignoreCase };
321
+ }
322
+ function peg$classExpectation(parts, inverted, ignoreCase) {
323
+ return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
324
+ }
325
+ function peg$anyExpectation() {
326
+ return { type: "any" };
327
+ }
328
+ function peg$endExpectation() {
329
+ return { type: "end" };
330
+ }
331
+ function peg$otherExpectation(description) {
332
+ return { type: "other", description: description };
333
+ }
334
+ function peg$computePosDetails(pos) {
335
+ var details = peg$posDetailsCache[pos];
336
+ var p;
337
+ if (details) {
338
+ return details;
339
+ }
340
+ else {
341
+ if (pos >= peg$posDetailsCache.length) {
342
+ p = peg$posDetailsCache.length - 1;
343
+ }
344
+ else {
345
+ p = pos;
346
+ while (!peg$posDetailsCache[--p]) { }
347
+ }
348
+ details = peg$posDetailsCache[p];
349
+ details = {
350
+ line: details.line,
351
+ column: details.column
352
+ };
353
+ while (p < pos) {
354
+ if (input.charCodeAt(p) === 10) {
355
+ details.line++;
356
+ details.column = 1;
357
+ }
358
+ else {
359
+ details.column++;
360
+ }
361
+ p++;
362
+ }
363
+ peg$posDetailsCache[pos] = details;
364
+ return details;
365
+ }
366
+ }
367
+ function peg$computeLocation(startPos, endPos, offset) {
368
+ var startPosDetails = peg$computePosDetails(startPos);
369
+ var endPosDetails = peg$computePosDetails(endPos);
370
+ var res = {
371
+ source: peg$source,
372
+ start: {
373
+ offset: startPos,
374
+ line: startPosDetails.line,
375
+ column: startPosDetails.column
376
+ },
377
+ end: {
378
+ offset: endPos,
379
+ line: endPosDetails.line,
380
+ column: endPosDetails.column
381
+ }
382
+ };
383
+ if (offset && peg$source && (typeof peg$source.offset === "function")) {
384
+ res.start = peg$source.offset(res.start);
385
+ res.end = peg$source.offset(res.end);
386
+ }
387
+ return res;
388
+ }
389
+ function peg$fail(expected) {
390
+ if (peg$currPos < peg$maxFailPos) {
391
+ return;
392
+ }
393
+ if (peg$currPos > peg$maxFailPos) {
394
+ peg$maxFailPos = peg$currPos;
395
+ peg$maxFailExpected = [];
396
+ }
397
+ peg$maxFailExpected.push(expected);
398
+ }
399
+ function peg$buildSimpleError(message, location) {
400
+ return new peg$SyntaxError(message, null, null, location);
401
+ }
402
+ function peg$buildStructuredError(expected, found, location) {
403
+ return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
404
+ }
405
+ function peg$parsepgn() {
406
+ var s0, s1, s2;
407
+ s0 = peg$currPos;
408
+ s1 = peg$parsetagPairSection();
409
+ s2 = peg$parsemoveTextSection();
410
+ peg$savedPos = s0;
411
+ s0 = peg$f0(s1, s2);
412
+ return s0;
413
+ }
414
+ function peg$parsetagPairSection() {
415
+ var s0, s1, s2;
416
+ s0 = peg$currPos;
417
+ s1 = [];
418
+ s2 = peg$parsetagPair();
419
+ while (s2 !== peg$FAILED) {
420
+ s1.push(s2);
421
+ s2 = peg$parsetagPair();
422
+ }
423
+ s2 = peg$parse_();
424
+ peg$savedPos = s0;
425
+ s0 = peg$f1(s1);
426
+ return s0;
427
+ }
428
+ function peg$parsetagPair() {
429
+ var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
430
+ peg$silentFails++;
431
+ s0 = peg$currPos;
432
+ s1 = peg$parse_();
433
+ if (input.charCodeAt(peg$currPos) === 91) {
434
+ s2 = peg$c0;
435
+ peg$currPos++;
436
+ }
437
+ else {
438
+ s2 = peg$FAILED;
439
+ if (peg$silentFails === 0) {
440
+ peg$fail(peg$e1);
441
+ }
442
+ }
443
+ if (s2 !== peg$FAILED) {
444
+ s3 = peg$parse_();
445
+ s4 = peg$parsetagName();
446
+ if (s4 !== peg$FAILED) {
447
+ s5 = peg$parse_();
448
+ if (input.charCodeAt(peg$currPos) === 34) {
449
+ s6 = peg$c1;
450
+ peg$currPos++;
451
+ }
452
+ else {
453
+ s6 = peg$FAILED;
454
+ if (peg$silentFails === 0) {
455
+ peg$fail(peg$e2);
456
+ }
457
+ }
458
+ if (s6 !== peg$FAILED) {
459
+ s7 = peg$parsetagValue();
460
+ if (input.charCodeAt(peg$currPos) === 34) {
461
+ s8 = peg$c1;
462
+ peg$currPos++;
463
+ }
464
+ else {
465
+ s8 = peg$FAILED;
466
+ if (peg$silentFails === 0) {
467
+ peg$fail(peg$e2);
468
+ }
469
+ }
470
+ if (s8 !== peg$FAILED) {
471
+ s9 = peg$parse_();
472
+ if (input.charCodeAt(peg$currPos) === 93) {
473
+ s10 = peg$c2;
474
+ peg$currPos++;
475
+ }
476
+ else {
477
+ s10 = peg$FAILED;
478
+ if (peg$silentFails === 0) {
479
+ peg$fail(peg$e3);
480
+ }
481
+ }
482
+ if (s10 !== peg$FAILED) {
483
+ peg$savedPos = s0;
484
+ s0 = peg$f2(s4, s7);
485
+ }
486
+ else {
487
+ peg$currPos = s0;
488
+ s0 = peg$FAILED;
489
+ }
490
+ }
491
+ else {
492
+ peg$currPos = s0;
493
+ s0 = peg$FAILED;
494
+ }
495
+ }
496
+ else {
497
+ peg$currPos = s0;
498
+ s0 = peg$FAILED;
499
+ }
500
+ }
501
+ else {
502
+ peg$currPos = s0;
503
+ s0 = peg$FAILED;
504
+ }
505
+ }
506
+ else {
507
+ peg$currPos = s0;
508
+ s0 = peg$FAILED;
509
+ }
510
+ peg$silentFails--;
511
+ if (s0 === peg$FAILED) {
512
+ s1 = peg$FAILED;
513
+ if (peg$silentFails === 0) {
514
+ peg$fail(peg$e0);
515
+ }
516
+ }
517
+ return s0;
518
+ }
519
+ function peg$parsetagName() {
520
+ var s0, s1, s2;
521
+ peg$silentFails++;
522
+ s0 = peg$currPos;
523
+ s1 = [];
524
+ s2 = input.charAt(peg$currPos);
525
+ if (peg$r0.test(s2)) {
526
+ peg$currPos++;
527
+ }
528
+ else {
529
+ s2 = peg$FAILED;
530
+ if (peg$silentFails === 0) {
531
+ peg$fail(peg$e5);
532
+ }
533
+ }
534
+ if (s2 !== peg$FAILED) {
535
+ while (s2 !== peg$FAILED) {
536
+ s1.push(s2);
537
+ s2 = input.charAt(peg$currPos);
538
+ if (peg$r0.test(s2)) {
539
+ peg$currPos++;
540
+ }
541
+ else {
542
+ s2 = peg$FAILED;
543
+ if (peg$silentFails === 0) {
544
+ peg$fail(peg$e5);
545
+ }
546
+ }
547
+ }
548
+ }
549
+ else {
550
+ s1 = peg$FAILED;
551
+ }
552
+ if (s1 !== peg$FAILED) {
553
+ s0 = input.substring(s0, peg$currPos);
554
+ }
555
+ else {
556
+ s0 = s1;
557
+ }
558
+ peg$silentFails--;
559
+ if (s0 === peg$FAILED) {
560
+ s1 = peg$FAILED;
561
+ if (peg$silentFails === 0) {
562
+ peg$fail(peg$e4);
563
+ }
564
+ }
565
+ return s0;
566
+ }
567
+ function peg$parsetagValue() {
568
+ var s0, s1, s2;
569
+ peg$silentFails++;
570
+ s0 = peg$currPos;
571
+ s1 = [];
572
+ s2 = input.charAt(peg$currPos);
573
+ if (peg$r1.test(s2)) {
574
+ peg$currPos++;
575
+ }
576
+ else {
577
+ s2 = peg$FAILED;
578
+ if (peg$silentFails === 0) {
579
+ peg$fail(peg$e7);
580
+ }
581
+ }
582
+ while (s2 !== peg$FAILED) {
583
+ s1.push(s2);
584
+ s2 = input.charAt(peg$currPos);
585
+ if (peg$r1.test(s2)) {
586
+ peg$currPos++;
587
+ }
588
+ else {
589
+ s2 = peg$FAILED;
590
+ if (peg$silentFails === 0) {
591
+ peg$fail(peg$e7);
592
+ }
593
+ }
594
+ }
595
+ s0 = input.substring(s0, peg$currPos);
596
+ peg$silentFails--;
597
+ s1 = peg$FAILED;
598
+ if (peg$silentFails === 0) {
599
+ peg$fail(peg$e6);
600
+ }
601
+ return s0;
602
+ }
603
+ function peg$parsemoveTextSection() {
604
+ var s0, s1, s2, s3, s4;
605
+ s0 = peg$currPos;
606
+ s1 = peg$parseline();
607
+ s2 = peg$parse_();
608
+ s3 = peg$parsegameTerminationMarker();
609
+ if (s3 === peg$FAILED) {
610
+ s3 = null;
611
+ }
612
+ s4 = peg$parse_();
613
+ peg$savedPos = s0;
614
+ s0 = peg$f3(s1, s3);
615
+ return s0;
616
+ }
617
+ function peg$parseline() {
618
+ var s0, s1, s2, s3;
619
+ s0 = peg$currPos;
620
+ s1 = peg$parsecomment();
621
+ if (s1 === peg$FAILED) {
622
+ s1 = null;
623
+ }
624
+ s2 = [];
625
+ s3 = peg$parsemove();
626
+ while (s3 !== peg$FAILED) {
627
+ s2.push(s3);
628
+ s3 = peg$parsemove();
629
+ }
630
+ peg$savedPos = s0;
631
+ s0 = peg$f4(s1, s2);
632
+ return s0;
633
+ }
634
+ function peg$parsemove() {
635
+ var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
636
+ s0 = peg$currPos;
637
+ s1 = peg$parse_();
638
+ s2 = peg$parsemoveNumber();
639
+ if (s2 === peg$FAILED) {
640
+ s2 = null;
641
+ }
642
+ s3 = peg$parse_();
643
+ s4 = peg$parsesan();
644
+ if (s4 !== peg$FAILED) {
645
+ s5 = peg$parsesuffixAnnotation();
646
+ if (s5 === peg$FAILED) {
647
+ s5 = null;
648
+ }
649
+ s6 = [];
650
+ s7 = peg$parsenag();
651
+ while (s7 !== peg$FAILED) {
652
+ s6.push(s7);
653
+ s7 = peg$parsenag();
654
+ }
655
+ s7 = peg$parse_();
656
+ s8 = peg$parsecomment();
657
+ if (s8 === peg$FAILED) {
658
+ s8 = null;
659
+ }
660
+ s9 = [];
661
+ s10 = peg$parsevariation();
662
+ while (s10 !== peg$FAILED) {
663
+ s9.push(s10);
664
+ s10 = peg$parsevariation();
665
+ }
666
+ peg$savedPos = s0;
667
+ s0 = peg$f5(s4, s5, s6, s8, s9);
668
+ }
669
+ else {
670
+ peg$currPos = s0;
671
+ s0 = peg$FAILED;
672
+ }
673
+ return s0;
674
+ }
675
+ function peg$parsemoveNumber() {
676
+ var s0, s1, s2, s3, s4, s5;
677
+ peg$silentFails++;
678
+ s0 = peg$currPos;
679
+ s1 = [];
680
+ s2 = input.charAt(peg$currPos);
681
+ if (peg$r2.test(s2)) {
682
+ peg$currPos++;
683
+ }
684
+ else {
685
+ s2 = peg$FAILED;
686
+ if (peg$silentFails === 0) {
687
+ peg$fail(peg$e9);
688
+ }
689
+ }
690
+ while (s2 !== peg$FAILED) {
691
+ s1.push(s2);
692
+ s2 = input.charAt(peg$currPos);
693
+ if (peg$r2.test(s2)) {
694
+ peg$currPos++;
695
+ }
696
+ else {
697
+ s2 = peg$FAILED;
698
+ if (peg$silentFails === 0) {
699
+ peg$fail(peg$e9);
700
+ }
701
+ }
702
+ }
703
+ if (input.charCodeAt(peg$currPos) === 46) {
704
+ s2 = peg$c3;
705
+ peg$currPos++;
706
+ }
707
+ else {
708
+ s2 = peg$FAILED;
709
+ if (peg$silentFails === 0) {
710
+ peg$fail(peg$e10);
711
+ }
712
+ }
713
+ if (s2 !== peg$FAILED) {
714
+ s3 = peg$parse_();
715
+ s4 = [];
716
+ s5 = input.charAt(peg$currPos);
717
+ if (peg$r3.test(s5)) {
718
+ peg$currPos++;
719
+ }
720
+ else {
721
+ s5 = peg$FAILED;
722
+ if (peg$silentFails === 0) {
723
+ peg$fail(peg$e11);
724
+ }
725
+ }
726
+ while (s5 !== peg$FAILED) {
727
+ s4.push(s5);
728
+ s5 = input.charAt(peg$currPos);
729
+ if (peg$r3.test(s5)) {
730
+ peg$currPos++;
731
+ }
732
+ else {
733
+ s5 = peg$FAILED;
734
+ if (peg$silentFails === 0) {
735
+ peg$fail(peg$e11);
736
+ }
737
+ }
738
+ }
739
+ s1 = [s1, s2, s3, s4];
740
+ s0 = s1;
741
+ }
742
+ else {
743
+ peg$currPos = s0;
744
+ s0 = peg$FAILED;
745
+ }
746
+ peg$silentFails--;
747
+ if (s0 === peg$FAILED) {
748
+ s1 = peg$FAILED;
749
+ if (peg$silentFails === 0) {
750
+ peg$fail(peg$e8);
751
+ }
752
+ }
753
+ return s0;
754
+ }
755
+ function peg$parsesan() {
756
+ var s0, s1, s2, s3, s4, s5;
757
+ peg$silentFails++;
758
+ s0 = peg$currPos;
759
+ s1 = peg$currPos;
760
+ if (input.substr(peg$currPos, 5) === peg$c4) {
761
+ s2 = peg$c4;
762
+ peg$currPos += 5;
763
+ }
764
+ else {
765
+ s2 = peg$FAILED;
766
+ if (peg$silentFails === 0) {
767
+ peg$fail(peg$e13);
768
+ }
769
+ }
770
+ if (s2 === peg$FAILED) {
771
+ if (input.substr(peg$currPos, 3) === peg$c5) {
772
+ s2 = peg$c5;
773
+ peg$currPos += 3;
774
+ }
775
+ else {
776
+ s2 = peg$FAILED;
777
+ if (peg$silentFails === 0) {
778
+ peg$fail(peg$e14);
779
+ }
780
+ }
781
+ if (s2 === peg$FAILED) {
782
+ if (input.substr(peg$currPos, 5) === peg$c6) {
783
+ s2 = peg$c6;
784
+ peg$currPos += 5;
785
+ }
786
+ else {
787
+ s2 = peg$FAILED;
788
+ if (peg$silentFails === 0) {
789
+ peg$fail(peg$e15);
790
+ }
791
+ }
792
+ if (s2 === peg$FAILED) {
793
+ if (input.substr(peg$currPos, 3) === peg$c7) {
794
+ s2 = peg$c7;
795
+ peg$currPos += 3;
796
+ }
797
+ else {
798
+ s2 = peg$FAILED;
799
+ if (peg$silentFails === 0) {
800
+ peg$fail(peg$e16);
801
+ }
802
+ }
803
+ if (s2 === peg$FAILED) {
804
+ s2 = peg$currPos;
805
+ s3 = input.charAt(peg$currPos);
806
+ if (peg$r0.test(s3)) {
807
+ peg$currPos++;
808
+ }
809
+ else {
810
+ s3 = peg$FAILED;
811
+ if (peg$silentFails === 0) {
812
+ peg$fail(peg$e5);
813
+ }
814
+ }
815
+ if (s3 !== peg$FAILED) {
816
+ s4 = [];
817
+ s5 = input.charAt(peg$currPos);
818
+ if (peg$r4.test(s5)) {
819
+ peg$currPos++;
820
+ }
821
+ else {
822
+ s5 = peg$FAILED;
823
+ if (peg$silentFails === 0) {
824
+ peg$fail(peg$e17);
825
+ }
826
+ }
827
+ if (s5 !== peg$FAILED) {
828
+ while (s5 !== peg$FAILED) {
829
+ s4.push(s5);
830
+ s5 = input.charAt(peg$currPos);
831
+ if (peg$r4.test(s5)) {
832
+ peg$currPos++;
833
+ }
834
+ else {
835
+ s5 = peg$FAILED;
836
+ if (peg$silentFails === 0) {
837
+ peg$fail(peg$e17);
838
+ }
839
+ }
840
+ }
841
+ }
842
+ else {
843
+ s4 = peg$FAILED;
844
+ }
845
+ if (s4 !== peg$FAILED) {
846
+ s3 = [s3, s4];
847
+ s2 = s3;
848
+ }
849
+ else {
850
+ peg$currPos = s2;
851
+ s2 = peg$FAILED;
852
+ }
853
+ }
854
+ else {
855
+ peg$currPos = s2;
856
+ s2 = peg$FAILED;
857
+ }
858
+ }
859
+ }
860
+ }
861
+ }
862
+ if (s2 !== peg$FAILED) {
863
+ s3 = input.charAt(peg$currPos);
864
+ if (peg$r5.test(s3)) {
865
+ peg$currPos++;
866
+ }
867
+ else {
868
+ s3 = peg$FAILED;
869
+ if (peg$silentFails === 0) {
870
+ peg$fail(peg$e18);
871
+ }
872
+ }
873
+ if (s3 === peg$FAILED) {
874
+ s3 = null;
875
+ }
876
+ s2 = [s2, s3];
877
+ s1 = s2;
878
+ }
879
+ else {
880
+ peg$currPos = s1;
881
+ s1 = peg$FAILED;
882
+ }
883
+ if (s1 !== peg$FAILED) {
884
+ s0 = input.substring(s0, peg$currPos);
885
+ }
886
+ else {
887
+ s0 = s1;
888
+ }
889
+ peg$silentFails--;
890
+ if (s0 === peg$FAILED) {
891
+ s1 = peg$FAILED;
892
+ if (peg$silentFails === 0) {
893
+ peg$fail(peg$e12);
894
+ }
895
+ }
896
+ return s0;
897
+ }
898
+ function peg$parsesuffixAnnotation() {
899
+ var s0, s1, s2;
900
+ peg$silentFails++;
901
+ s0 = peg$currPos;
902
+ s1 = [];
903
+ s2 = input.charAt(peg$currPos);
904
+ if (peg$r6.test(s2)) {
905
+ peg$currPos++;
906
+ }
907
+ else {
908
+ s2 = peg$FAILED;
909
+ if (peg$silentFails === 0) {
910
+ peg$fail(peg$e20);
911
+ }
912
+ }
913
+ while (s2 !== peg$FAILED) {
914
+ s1.push(s2);
915
+ if (s1.length >= 2) {
916
+ s2 = peg$FAILED;
917
+ }
918
+ else {
919
+ s2 = input.charAt(peg$currPos);
920
+ if (peg$r6.test(s2)) {
921
+ peg$currPos++;
922
+ }
923
+ else {
924
+ s2 = peg$FAILED;
925
+ if (peg$silentFails === 0) {
926
+ peg$fail(peg$e20);
927
+ }
928
+ }
929
+ }
930
+ }
931
+ if (s1.length < 1) {
932
+ peg$currPos = s0;
933
+ s0 = peg$FAILED;
934
+ }
935
+ else {
936
+ s0 = s1;
937
+ }
938
+ peg$silentFails--;
939
+ if (s0 === peg$FAILED) {
940
+ s1 = peg$FAILED;
941
+ if (peg$silentFails === 0) {
942
+ peg$fail(peg$e19);
943
+ }
944
+ }
945
+ return s0;
946
+ }
947
+ function peg$parsenag() {
948
+ var s0, s1, s2, s3, s4, s5;
949
+ peg$silentFails++;
950
+ s0 = peg$currPos;
951
+ s1 = peg$parse_();
952
+ if (input.charCodeAt(peg$currPos) === 36) {
953
+ s2 = peg$c8;
954
+ peg$currPos++;
955
+ }
956
+ else {
957
+ s2 = peg$FAILED;
958
+ if (peg$silentFails === 0) {
959
+ peg$fail(peg$e22);
960
+ }
961
+ }
962
+ if (s2 !== peg$FAILED) {
963
+ s3 = peg$currPos;
964
+ s4 = [];
965
+ s5 = input.charAt(peg$currPos);
966
+ if (peg$r2.test(s5)) {
967
+ peg$currPos++;
968
+ }
969
+ else {
970
+ s5 = peg$FAILED;
971
+ if (peg$silentFails === 0) {
972
+ peg$fail(peg$e9);
973
+ }
974
+ }
975
+ if (s5 !== peg$FAILED) {
976
+ while (s5 !== peg$FAILED) {
977
+ s4.push(s5);
978
+ s5 = input.charAt(peg$currPos);
979
+ if (peg$r2.test(s5)) {
980
+ peg$currPos++;
981
+ }
982
+ else {
983
+ s5 = peg$FAILED;
984
+ if (peg$silentFails === 0) {
985
+ peg$fail(peg$e9);
986
+ }
987
+ }
988
+ }
989
+ }
990
+ else {
991
+ s4 = peg$FAILED;
992
+ }
993
+ if (s4 !== peg$FAILED) {
994
+ s3 = input.substring(s3, peg$currPos);
995
+ }
996
+ else {
997
+ s3 = s4;
998
+ }
999
+ if (s3 !== peg$FAILED) {
1000
+ peg$savedPos = s0;
1001
+ s0 = peg$f6(s3);
1002
+ }
1003
+ else {
1004
+ peg$currPos = s0;
1005
+ s0 = peg$FAILED;
1006
+ }
1007
+ }
1008
+ else {
1009
+ peg$currPos = s0;
1010
+ s0 = peg$FAILED;
1011
+ }
1012
+ peg$silentFails--;
1013
+ if (s0 === peg$FAILED) {
1014
+ s1 = peg$FAILED;
1015
+ if (peg$silentFails === 0) {
1016
+ peg$fail(peg$e21);
1017
+ }
1018
+ }
1019
+ return s0;
1020
+ }
1021
+ function peg$parsecomment() {
1022
+ var s0;
1023
+ s0 = peg$parsebraceComment();
1024
+ if (s0 === peg$FAILED) {
1025
+ s0 = peg$parserestOfLineComment();
1026
+ }
1027
+ return s0;
1028
+ }
1029
+ function peg$parsebraceComment() {
1030
+ var s0, s1, s2, s3, s4;
1031
+ peg$silentFails++;
1032
+ s0 = peg$currPos;
1033
+ if (input.charCodeAt(peg$currPos) === 123) {
1034
+ s1 = peg$c9;
1035
+ peg$currPos++;
1036
+ }
1037
+ else {
1038
+ s1 = peg$FAILED;
1039
+ if (peg$silentFails === 0) {
1040
+ peg$fail(peg$e24);
1041
+ }
1042
+ }
1043
+ if (s1 !== peg$FAILED) {
1044
+ s2 = peg$currPos;
1045
+ s3 = [];
1046
+ s4 = input.charAt(peg$currPos);
1047
+ if (peg$r7.test(s4)) {
1048
+ peg$currPos++;
1049
+ }
1050
+ else {
1051
+ s4 = peg$FAILED;
1052
+ if (peg$silentFails === 0) {
1053
+ peg$fail(peg$e25);
1054
+ }
1055
+ }
1056
+ while (s4 !== peg$FAILED) {
1057
+ s3.push(s4);
1058
+ s4 = input.charAt(peg$currPos);
1059
+ if (peg$r7.test(s4)) {
1060
+ peg$currPos++;
1061
+ }
1062
+ else {
1063
+ s4 = peg$FAILED;
1064
+ if (peg$silentFails === 0) {
1065
+ peg$fail(peg$e25);
1066
+ }
1067
+ }
1068
+ }
1069
+ s2 = input.substring(s2, peg$currPos);
1070
+ if (input.charCodeAt(peg$currPos) === 125) {
1071
+ s3 = peg$c10;
1072
+ peg$currPos++;
1073
+ }
1074
+ else {
1075
+ s3 = peg$FAILED;
1076
+ if (peg$silentFails === 0) {
1077
+ peg$fail(peg$e26);
1078
+ }
1079
+ }
1080
+ if (s3 !== peg$FAILED) {
1081
+ peg$savedPos = s0;
1082
+ s0 = peg$f7(s2);
1083
+ }
1084
+ else {
1085
+ peg$currPos = s0;
1086
+ s0 = peg$FAILED;
1087
+ }
1088
+ }
1089
+ else {
1090
+ peg$currPos = s0;
1091
+ s0 = peg$FAILED;
1092
+ }
1093
+ peg$silentFails--;
1094
+ if (s0 === peg$FAILED) {
1095
+ s1 = peg$FAILED;
1096
+ if (peg$silentFails === 0) {
1097
+ peg$fail(peg$e23);
1098
+ }
1099
+ }
1100
+ return s0;
1101
+ }
1102
+ function peg$parserestOfLineComment() {
1103
+ var s0, s1, s2, s3, s4;
1104
+ peg$silentFails++;
1105
+ s0 = peg$currPos;
1106
+ if (input.charCodeAt(peg$currPos) === 59) {
1107
+ s1 = peg$c11;
1108
+ peg$currPos++;
1109
+ }
1110
+ else {
1111
+ s1 = peg$FAILED;
1112
+ if (peg$silentFails === 0) {
1113
+ peg$fail(peg$e28);
1114
+ }
1115
+ }
1116
+ if (s1 !== peg$FAILED) {
1117
+ s2 = peg$currPos;
1118
+ s3 = [];
1119
+ s4 = input.charAt(peg$currPos);
1120
+ if (peg$r8.test(s4)) {
1121
+ peg$currPos++;
1122
+ }
1123
+ else {
1124
+ s4 = peg$FAILED;
1125
+ if (peg$silentFails === 0) {
1126
+ peg$fail(peg$e29);
1127
+ }
1128
+ }
1129
+ while (s4 !== peg$FAILED) {
1130
+ s3.push(s4);
1131
+ s4 = input.charAt(peg$currPos);
1132
+ if (peg$r8.test(s4)) {
1133
+ peg$currPos++;
1134
+ }
1135
+ else {
1136
+ s4 = peg$FAILED;
1137
+ if (peg$silentFails === 0) {
1138
+ peg$fail(peg$e29);
1139
+ }
1140
+ }
1141
+ }
1142
+ s2 = input.substring(s2, peg$currPos);
1143
+ peg$savedPos = s0;
1144
+ s0 = peg$f8(s2);
1145
+ }
1146
+ else {
1147
+ peg$currPos = s0;
1148
+ s0 = peg$FAILED;
1149
+ }
1150
+ peg$silentFails--;
1151
+ if (s0 === peg$FAILED) {
1152
+ s1 = peg$FAILED;
1153
+ if (peg$silentFails === 0) {
1154
+ peg$fail(peg$e27);
1155
+ }
1156
+ }
1157
+ return s0;
1158
+ }
1159
+ function peg$parsevariation() {
1160
+ var s0, s1, s2, s3, s4, s5;
1161
+ peg$silentFails++;
1162
+ s0 = peg$currPos;
1163
+ s1 = peg$parse_();
1164
+ if (input.charCodeAt(peg$currPos) === 40) {
1165
+ s2 = peg$c12;
1166
+ peg$currPos++;
1167
+ }
1168
+ else {
1169
+ s2 = peg$FAILED;
1170
+ if (peg$silentFails === 0) {
1171
+ peg$fail(peg$e31);
1172
+ }
1173
+ }
1174
+ if (s2 !== peg$FAILED) {
1175
+ s3 = peg$parseline();
1176
+ if (s3 !== peg$FAILED) {
1177
+ s4 = peg$parse_();
1178
+ if (input.charCodeAt(peg$currPos) === 41) {
1179
+ s5 = peg$c13;
1180
+ peg$currPos++;
1181
+ }
1182
+ else {
1183
+ s5 = peg$FAILED;
1184
+ if (peg$silentFails === 0) {
1185
+ peg$fail(peg$e32);
1186
+ }
1187
+ }
1188
+ if (s5 !== peg$FAILED) {
1189
+ peg$savedPos = s0;
1190
+ s0 = peg$f9(s3);
1191
+ }
1192
+ else {
1193
+ peg$currPos = s0;
1194
+ s0 = peg$FAILED;
1195
+ }
1196
+ }
1197
+ else {
1198
+ peg$currPos = s0;
1199
+ s0 = peg$FAILED;
1200
+ }
1201
+ }
1202
+ else {
1203
+ peg$currPos = s0;
1204
+ s0 = peg$FAILED;
1205
+ }
1206
+ peg$silentFails--;
1207
+ if (s0 === peg$FAILED) {
1208
+ s1 = peg$FAILED;
1209
+ if (peg$silentFails === 0) {
1210
+ peg$fail(peg$e30);
1211
+ }
1212
+ }
1213
+ return s0;
1214
+ }
1215
+ function peg$parsegameTerminationMarker() {
1216
+ var s0, s1, s2, s3;
1217
+ peg$silentFails++;
1218
+ s0 = peg$currPos;
1219
+ if (input.substr(peg$currPos, 3) === peg$c14) {
1220
+ s1 = peg$c14;
1221
+ peg$currPos += 3;
1222
+ }
1223
+ else {
1224
+ s1 = peg$FAILED;
1225
+ if (peg$silentFails === 0) {
1226
+ peg$fail(peg$e34);
1227
+ }
1228
+ }
1229
+ if (s1 === peg$FAILED) {
1230
+ if (input.substr(peg$currPos, 3) === peg$c15) {
1231
+ s1 = peg$c15;
1232
+ peg$currPos += 3;
1233
+ }
1234
+ else {
1235
+ s1 = peg$FAILED;
1236
+ if (peg$silentFails === 0) {
1237
+ peg$fail(peg$e35);
1238
+ }
1239
+ }
1240
+ if (s1 === peg$FAILED) {
1241
+ if (input.substr(peg$currPos, 7) === peg$c16) {
1242
+ s1 = peg$c16;
1243
+ peg$currPos += 7;
1244
+ }
1245
+ else {
1246
+ s1 = peg$FAILED;
1247
+ if (peg$silentFails === 0) {
1248
+ peg$fail(peg$e36);
1249
+ }
1250
+ }
1251
+ if (s1 === peg$FAILED) {
1252
+ if (input.charCodeAt(peg$currPos) === 42) {
1253
+ s1 = peg$c17;
1254
+ peg$currPos++;
1255
+ }
1256
+ else {
1257
+ s1 = peg$FAILED;
1258
+ if (peg$silentFails === 0) {
1259
+ peg$fail(peg$e37);
1260
+ }
1261
+ }
1262
+ }
1263
+ }
1264
+ }
1265
+ if (s1 !== peg$FAILED) {
1266
+ s2 = peg$parse_();
1267
+ s3 = peg$parsecomment();
1268
+ if (s3 === peg$FAILED) {
1269
+ s3 = null;
1270
+ }
1271
+ peg$savedPos = s0;
1272
+ s0 = peg$f10(s1, s3);
1273
+ }
1274
+ else {
1275
+ peg$currPos = s0;
1276
+ s0 = peg$FAILED;
1277
+ }
1278
+ peg$silentFails--;
1279
+ if (s0 === peg$FAILED) {
1280
+ s1 = peg$FAILED;
1281
+ if (peg$silentFails === 0) {
1282
+ peg$fail(peg$e33);
1283
+ }
1284
+ }
1285
+ return s0;
1286
+ }
1287
+ function peg$parse_() {
1288
+ var s0, s1;
1289
+ peg$silentFails++;
1290
+ s0 = [];
1291
+ s1 = input.charAt(peg$currPos);
1292
+ if (peg$r9.test(s1)) {
1293
+ peg$currPos++;
1294
+ }
1295
+ else {
1296
+ s1 = peg$FAILED;
1297
+ if (peg$silentFails === 0) {
1298
+ peg$fail(peg$e39);
1299
+ }
1300
+ }
1301
+ while (s1 !== peg$FAILED) {
1302
+ s0.push(s1);
1303
+ s1 = input.charAt(peg$currPos);
1304
+ if (peg$r9.test(s1)) {
1305
+ peg$currPos++;
1306
+ }
1307
+ else {
1308
+ s1 = peg$FAILED;
1309
+ if (peg$silentFails === 0) {
1310
+ peg$fail(peg$e39);
1311
+ }
1312
+ }
1313
+ }
1314
+ peg$silentFails--;
1315
+ s1 = peg$FAILED;
1316
+ if (peg$silentFails === 0) {
1317
+ peg$fail(peg$e38);
1318
+ }
1319
+ return s0;
1320
+ }
1321
+ peg$result = peg$startRuleFunction();
1322
+ if (options.peg$library) {
1323
+ return /** @type {any} */ ({
1324
+ peg$result,
1325
+ peg$currPos,
1326
+ peg$FAILED,
1327
+ peg$maxFailExpected,
1328
+ peg$maxFailPos
1329
+ });
1330
+ }
1331
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
1332
+ return peg$result;
1333
+ }
1334
+ else {
1335
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
1336
+ peg$fail(peg$endExpectation());
1337
+ }
1338
+ throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length
1339
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
1340
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
1341
+ }
1342
+ }
1343
+ const peg$allowedStartRules = [
1344
+ "pgn"
1345
+ ];
1346
+ export { peg$allowedStartRules as StartRules, peg$SyntaxError as SyntaxError, peg$parse as parse };
1347
+ //# sourceMappingURL=pgn.js.map