chordsheetjs 6.1.0 → 6.3.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 (42) hide show
  1. package/README.md +481 -572
  2. package/lib/bundle.js +15393 -0
  3. package/lib/index.js +6290 -216
  4. package/lib/index.js.map +1 -0
  5. package/lib/main.d.ts +1095 -0
  6. package/lib/main.d.ts.map +1 -0
  7. package/package.json +43 -21
  8. package/.husky/pre-commit +0 -5
  9. package/lib/chord.js +0 -496
  10. package/lib/chord_sheet/chord_lyrics_pair.js +0 -80
  11. package/lib/chord_sheet/chord_pro/composite.js +0 -54
  12. package/lib/chord_sheet/chord_pro/evaluation_error.js +0 -58
  13. package/lib/chord_sheet/chord_pro/literal.js +0 -42
  14. package/lib/chord_sheet/chord_pro/ternary.js +0 -126
  15. package/lib/chord_sheet/comment.js +0 -55
  16. package/lib/chord_sheet/line.js +0 -207
  17. package/lib/chord_sheet/metadata.js +0 -216
  18. package/lib/chord_sheet/paragraph.js +0 -88
  19. package/lib/chord_sheet/song.js +0 -531
  20. package/lib/chord_sheet/tag.js +0 -359
  21. package/lib/chord_sheet_serializer.js +0 -278
  22. package/lib/constants.js +0 -54
  23. package/lib/formatter/chord_pro_formatter.js +0 -184
  24. package/lib/formatter/html_div_formatter.js +0 -130
  25. package/lib/formatter/html_formatter.js +0 -44
  26. package/lib/formatter/html_table_formatter.js +0 -154
  27. package/lib/formatter/templates/html_div_formatter.js +0 -544
  28. package/lib/formatter/templates/html_table_formatter.js +0 -731
  29. package/lib/formatter/text_formatter.js +0 -184
  30. package/lib/helpers.js +0 -56
  31. package/lib/key.js +0 -386
  32. package/lib/normalize_mappings/enharmonic-normalize.js +0 -124
  33. package/lib/normalize_mappings/generate-suffix-normalize-mapping.js +0 -36
  34. package/lib/normalize_mappings/suffix-normalize-mapping.js +0 -914
  35. package/lib/note.js +0 -264
  36. package/lib/parser/chord_pro_parser.js +0 -64
  37. package/lib/parser/chord_pro_peg_parser.js +0 -2069
  38. package/lib/parser/chord_sheet_parser.js +0 -175
  39. package/lib/parser/parser_warning.js +0 -62
  40. package/lib/parser/ultimate_guitar_parser.js +0 -154
  41. package/lib/template_helpers.js +0 -98
  42. package/lib/utilities.js +0 -110
@@ -1,2069 +0,0 @@
1
- /*
2
- * Generated by PEG.js 0.10.0.
3
- *
4
- * http://pegjs.org/
5
- */
6
- "use strict";
7
-
8
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
-
10
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
-
12
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
-
14
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
15
-
16
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
-
18
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
19
-
20
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
21
-
22
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
23
-
24
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
25
-
26
- function peg$subclass(child, parent) {
27
- function ctor() {
28
- this.constructor = child;
29
- }
30
-
31
- ctor.prototype = parent.prototype;
32
- child.prototype = new ctor();
33
- }
34
-
35
- function peg$SyntaxError(message, expected, found, location) {
36
- this.message = message;
37
- this.expected = expected;
38
- this.found = found;
39
- this.location = location;
40
- this.name = "SyntaxError";
41
-
42
- if (typeof Error.captureStackTrace === "function") {
43
- Error.captureStackTrace(this, peg$SyntaxError);
44
- }
45
- }
46
-
47
- peg$subclass(peg$SyntaxError, Error);
48
-
49
- peg$SyntaxError.buildMessage = function (expected, found) {
50
- var DESCRIBE_EXPECTATION_FNS = {
51
- literal: function literal(expectation) {
52
- return "\"" + literalEscape(expectation.text) + "\"";
53
- },
54
- "class": function _class(expectation) {
55
- var escapedParts = "",
56
- i;
57
-
58
- for (i = 0; i < expectation.parts.length; i++) {
59
- escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]);
60
- }
61
-
62
- return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
63
- },
64
- any: function any(expectation) {
65
- return "any character";
66
- },
67
- end: function end(expectation) {
68
- return "end of input";
69
- },
70
- other: function other(expectation) {
71
- return expectation.description;
72
- }
73
- };
74
-
75
- function hex(ch) {
76
- return ch.charCodeAt(0).toString(16).toUpperCase();
77
- }
78
-
79
- function literalEscape(s) {
80
- return s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) {
81
- return '\\x0' + hex(ch);
82
- }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
83
- return '\\x' + hex(ch);
84
- });
85
- }
86
-
87
- function classEscape(s) {
88
- return s.replace(/\\/g, '\\\\').replace(/\]/g, '\\]').replace(/\^/g, '\\^').replace(/-/g, '\\-').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) {
89
- return '\\x0' + hex(ch);
90
- }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
91
- return '\\x' + hex(ch);
92
- });
93
- }
94
-
95
- function describeExpectation(expectation) {
96
- return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
97
- }
98
-
99
- function describeExpected(expected) {
100
- var descriptions = new Array(expected.length),
101
- i,
102
- j;
103
-
104
- for (i = 0; i < expected.length; i++) {
105
- descriptions[i] = describeExpectation(expected[i]);
106
- }
107
-
108
- descriptions.sort();
109
-
110
- if (descriptions.length > 0) {
111
- for (i = 1, j = 1; i < descriptions.length; i++) {
112
- if (descriptions[i - 1] !== descriptions[i]) {
113
- descriptions[j] = descriptions[i];
114
- j++;
115
- }
116
- }
117
-
118
- descriptions.length = j;
119
- }
120
-
121
- switch (descriptions.length) {
122
- case 1:
123
- return descriptions[0];
124
-
125
- case 2:
126
- return descriptions[0] + " or " + descriptions[1];
127
-
128
- default:
129
- return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
130
- }
131
- }
132
-
133
- function describeFound(found) {
134
- return found ? "\"" + literalEscape(found) + "\"" : "end of input";
135
- }
136
-
137
- return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
138
- };
139
-
140
- function peg$parse(input, options) {
141
- options = options !== void 0 ? options : {};
142
-
143
- var peg$FAILED = {},
144
- peg$startRuleFunctions = {
145
- ChordSheet: peg$parseChordSheet
146
- },
147
- peg$startRuleFunction = peg$parseChordSheet,
148
- peg$c0 = function peg$c0(lines, line) {
149
- return {
150
- type: "chordSheet",
151
- lines: [].concat(_toConsumableArray(lines), [line])
152
- };
153
- },
154
- peg$c1 = function peg$c1(line) {
155
- return line;
156
- },
157
- peg$c2 = function peg$c2(lyrics, tokens, chords, comment) {
158
- return {
159
- type: "line",
160
- items: [lyrics ? {
161
- type: "chordLyricsPair",
162
- chords: '',
163
- lyrics: lyrics
164
- } : null].concat(_toConsumableArray(tokens), [chords ? {
165
- type: "chordLyricsPair",
166
- chords: chords,
167
- lyrics: ''
168
- } : null, comment ? {
169
- type: "comment",
170
- comment: comment
171
- } : null]).filter(function (x) {
172
- return x;
173
- })
174
- };
175
- },
176
- peg$c3 = "#",
177
- peg$c4 = peg$literalExpectation("#", false),
178
- peg$c5 = /^[^\r\n]/,
179
- peg$c6 = peg$classExpectation(["\r", "\n"], true, false),
180
- peg$c7 = function peg$c7(comment) {
181
- return comment;
182
- },
183
- peg$c8 = function peg$c8(chords, lyrics) {
184
- return {
185
- type: "chordLyricsPair",
186
- chords: chords || '',
187
- lyrics: lyrics
188
- };
189
- },
190
- peg$c9 = function peg$c9(lyrics) {
191
- return lyrics.map(function (c) {
192
- return c["char"] || c;
193
- }).join("");
194
- },
195
- peg$c10 = "[",
196
- peg$c11 = peg$literalExpectation("[", false),
197
- peg$c12 = "]",
198
- peg$c13 = peg$literalExpectation("]", false),
199
- peg$c14 = function peg$c14(chords) {
200
- return chords.map(function (c) {
201
- return c["char"] || c;
202
- }).join("");
203
- },
204
- peg$c15 = /^[^\]\r\n]/,
205
- peg$c16 = peg$classExpectation(["]", "\r", "\n"], true, false),
206
- peg$c17 = "\\",
207
- peg$c18 = peg$literalExpectation("\\", false),
208
- peg$c19 = function peg$c19() {
209
- return {
210
- type: "char",
211
- "char": "\\"
212
- };
213
- },
214
- peg$c20 = function peg$c20() {
215
- return {
216
- type: "char",
217
- "char": "]"
218
- };
219
- },
220
- peg$c21 = function peg$c21(sequence) {
221
- return sequence;
222
- },
223
- peg$c22 = "%{",
224
- peg$c23 = peg$literalExpectation("%{", false),
225
- peg$c24 = "}",
226
- peg$c25 = peg$literalExpectation("}", false),
227
- peg$c26 = function peg$c26(variableName, valueTest, expressions) {
228
- return _objectSpread(_objectSpread({
229
- "type": "ternary",
230
- variable: variableName.length > 0 ? variableName : null,
231
- valueTest: valueTest
232
- }, expressions), {}, {
233
- location: location().start
234
- });
235
- },
236
- peg$c27 = "=",
237
- peg$c28 = peg$literalExpectation("=", false),
238
- peg$c29 = function peg$c29(testValue) {
239
- return testValue;
240
- },
241
- peg$c30 = "|",
242
- peg$c31 = peg$literalExpectation("|", false),
243
- peg$c32 = function peg$c32(trueExpression, falseExpression) {
244
- return {
245
- "type": "ternary",
246
- trueExpression: trueExpression,
247
- falseExpression: falseExpression,
248
- location: location().start
249
- };
250
- },
251
- peg$c33 = function peg$c33(falseExpression) {
252
- return falseExpression;
253
- },
254
- peg$c34 = /^[a-zA-Z0-9\-_]/,
255
- peg$c35 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "-", "_"], false, false),
256
- peg$c36 = function peg$c36() {
257
- return {
258
- type: "char",
259
- "char": "|"
260
- };
261
- },
262
- peg$c37 = function peg$c37() {
263
- return {
264
- type: "char",
265
- "char": "\x7d"
266
- };
267
- },
268
- peg$c38 = /^[^|[\]\\{}%#\r\n]/,
269
- peg$c39 = peg$classExpectation(["|", "[", "]", "\\", "{", "}", "%", "#", "\r", "\n"], true, false),
270
- peg$c40 = function peg$c40() {
271
- return {
272
- type: "char",
273
- "char": "["
274
- };
275
- },
276
- peg$c41 = "{",
277
- peg$c42 = peg$literalExpectation("{", false),
278
- peg$c43 = function peg$c43() {
279
- return {
280
- type: "char",
281
- "char": "\x7b"
282
- };
283
- },
284
- peg$c44 = "%",
285
- peg$c45 = peg$literalExpectation("%", false),
286
- peg$c46 = function peg$c46() {
287
- return {
288
- type: "char",
289
- "char": "%"
290
- };
291
- },
292
- peg$c47 = function peg$c47() {
293
- return {
294
- type: "char",
295
- "char": "#"
296
- };
297
- },
298
- peg$c48 = function peg$c48(tagName, tagColonWithValue) {
299
- return {
300
- type: "tag",
301
- name: tagName,
302
- value: tagColonWithValue,
303
- location: location().start
304
- };
305
- },
306
- peg$c49 = ":",
307
- peg$c50 = peg$literalExpectation(":", false),
308
- peg$c51 = function peg$c51(tagValue) {
309
- return tagValue.map(function (c) {
310
- return c["char"] || c;
311
- }).join('');
312
- },
313
- peg$c52 = /^[a-zA-Z\-_]/,
314
- peg$c53 = peg$classExpectation([["a", "z"], ["A", "Z"], "-", "_"], false, false),
315
- peg$c54 = /^[^}\\\r\n]/,
316
- peg$c55 = peg$classExpectation(["}", "\\", "\r", "\n"], true, false),
317
- peg$c56 = peg$otherExpectation("whitespace"),
318
- peg$c57 = /^[ \t\n\r]/,
319
- peg$c58 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false),
320
- peg$c59 = peg$otherExpectation("space"),
321
- peg$c60 = /^[ \t]/,
322
- peg$c61 = peg$classExpectation([" ", "\t"], false, false),
323
- peg$c62 = "\n",
324
- peg$c63 = peg$literalExpectation("\n", false),
325
- peg$c64 = "\r",
326
- peg$c65 = peg$literalExpectation("\r", false),
327
- peg$currPos = 0,
328
- peg$savedPos = 0,
329
- peg$posDetailsCache = [{
330
- line: 1,
331
- column: 1
332
- }],
333
- peg$maxFailPos = 0,
334
- peg$maxFailExpected = [],
335
- peg$silentFails = 0,
336
- peg$result;
337
-
338
- if ("startRule" in options) {
339
- if (!(options.startRule in peg$startRuleFunctions)) {
340
- throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
341
- }
342
-
343
- peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
344
- }
345
-
346
- function text() {
347
- return input.substring(peg$savedPos, peg$currPos);
348
- }
349
-
350
- function location() {
351
- return peg$computeLocation(peg$savedPos, peg$currPos);
352
- }
353
-
354
- function expected(description, location) {
355
- location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
356
- throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location);
357
- }
358
-
359
- function error(message, location) {
360
- location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
361
- throw peg$buildSimpleError(message, location);
362
- }
363
-
364
- function peg$literalExpectation(text, ignoreCase) {
365
- return {
366
- type: "literal",
367
- text: text,
368
- ignoreCase: ignoreCase
369
- };
370
- }
371
-
372
- function peg$classExpectation(parts, inverted, ignoreCase) {
373
- return {
374
- type: "class",
375
- parts: parts,
376
- inverted: inverted,
377
- ignoreCase: ignoreCase
378
- };
379
- }
380
-
381
- function peg$anyExpectation() {
382
- return {
383
- type: "any"
384
- };
385
- }
386
-
387
- function peg$endExpectation() {
388
- return {
389
- type: "end"
390
- };
391
- }
392
-
393
- function peg$otherExpectation(description) {
394
- return {
395
- type: "other",
396
- description: description
397
- };
398
- }
399
-
400
- function peg$computePosDetails(pos) {
401
- var details = peg$posDetailsCache[pos],
402
- p;
403
-
404
- if (details) {
405
- return details;
406
- } else {
407
- p = pos - 1;
408
-
409
- while (!peg$posDetailsCache[p]) {
410
- p--;
411
- }
412
-
413
- details = peg$posDetailsCache[p];
414
- details = {
415
- line: details.line,
416
- column: details.column
417
- };
418
-
419
- while (p < pos) {
420
- if (input.charCodeAt(p) === 10) {
421
- details.line++;
422
- details.column = 1;
423
- } else {
424
- details.column++;
425
- }
426
-
427
- p++;
428
- }
429
-
430
- peg$posDetailsCache[pos] = details;
431
- return details;
432
- }
433
- }
434
-
435
- function peg$computeLocation(startPos, endPos) {
436
- var startPosDetails = peg$computePosDetails(startPos),
437
- endPosDetails = peg$computePosDetails(endPos);
438
- return {
439
- start: {
440
- offset: startPos,
441
- line: startPosDetails.line,
442
- column: startPosDetails.column
443
- },
444
- end: {
445
- offset: endPos,
446
- line: endPosDetails.line,
447
- column: endPosDetails.column
448
- }
449
- };
450
- }
451
-
452
- function peg$fail(expected) {
453
- if (peg$currPos < peg$maxFailPos) {
454
- return;
455
- }
456
-
457
- if (peg$currPos > peg$maxFailPos) {
458
- peg$maxFailPos = peg$currPos;
459
- peg$maxFailExpected = [];
460
- }
461
-
462
- peg$maxFailExpected.push(expected);
463
- }
464
-
465
- function peg$buildSimpleError(message, location) {
466
- return new peg$SyntaxError(message, null, null, location);
467
- }
468
-
469
- function peg$buildStructuredError(expected, found, location) {
470
- return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
471
- }
472
-
473
- function peg$parseChordSheet() {
474
- var s0, s1, s2;
475
- s0 = peg$currPos;
476
- s1 = [];
477
- s2 = peg$parseLineWithNewline();
478
-
479
- while (s2 !== peg$FAILED) {
480
- s1.push(s2);
481
- s2 = peg$parseLineWithNewline();
482
- }
483
-
484
- if (s1 !== peg$FAILED) {
485
- s2 = peg$parseLine();
486
-
487
- if (s2 === peg$FAILED) {
488
- s2 = null;
489
- }
490
-
491
- if (s2 !== peg$FAILED) {
492
- peg$savedPos = s0;
493
- s1 = peg$c0(s1, s2);
494
- s0 = s1;
495
- } else {
496
- peg$currPos = s0;
497
- s0 = peg$FAILED;
498
- }
499
- } else {
500
- peg$currPos = s0;
501
- s0 = peg$FAILED;
502
- }
503
-
504
- return s0;
505
- }
506
-
507
- function peg$parseLineWithNewline() {
508
- var s0, s1, s2;
509
- s0 = peg$currPos;
510
- s1 = peg$parseLine();
511
-
512
- if (s1 !== peg$FAILED) {
513
- s2 = peg$parseNewLine();
514
-
515
- if (s2 !== peg$FAILED) {
516
- peg$savedPos = s0;
517
- s1 = peg$c1(s1);
518
- s0 = s1;
519
- } else {
520
- peg$currPos = s0;
521
- s0 = peg$FAILED;
522
- }
523
- } else {
524
- peg$currPos = s0;
525
- s0 = peg$FAILED;
526
- }
527
-
528
- return s0;
529
- }
530
-
531
- function peg$parseLine() {
532
- var s0, s1, s2, s3, s4, s5, s6;
533
- s0 = peg$currPos;
534
- s1 = peg$parseLyrics();
535
-
536
- if (s1 === peg$FAILED) {
537
- s1 = null;
538
- }
539
-
540
- if (s1 !== peg$FAILED) {
541
- s2 = [];
542
- s3 = peg$parseToken();
543
-
544
- while (s3 !== peg$FAILED) {
545
- s2.push(s3);
546
- s3 = peg$parseToken();
547
- }
548
-
549
- if (s2 !== peg$FAILED) {
550
- s3 = peg$parseChord();
551
-
552
- if (s3 === peg$FAILED) {
553
- s3 = null;
554
- }
555
-
556
- if (s3 !== peg$FAILED) {
557
- s4 = peg$parseComment();
558
-
559
- if (s4 === peg$FAILED) {
560
- s4 = null;
561
- }
562
-
563
- if (s4 !== peg$FAILED) {
564
- s5 = [];
565
- s6 = peg$parseSpace();
566
-
567
- while (s6 !== peg$FAILED) {
568
- s5.push(s6);
569
- s6 = peg$parseSpace();
570
- }
571
-
572
- if (s5 !== peg$FAILED) {
573
- peg$savedPos = s0;
574
- s1 = peg$c2(s1, s2, s3, s4);
575
- s0 = s1;
576
- } else {
577
- peg$currPos = s0;
578
- s0 = peg$FAILED;
579
- }
580
- } else {
581
- peg$currPos = s0;
582
- s0 = peg$FAILED;
583
- }
584
- } else {
585
- peg$currPos = s0;
586
- s0 = peg$FAILED;
587
- }
588
- } else {
589
- peg$currPos = s0;
590
- s0 = peg$FAILED;
591
- }
592
- } else {
593
- peg$currPos = s0;
594
- s0 = peg$FAILED;
595
- }
596
-
597
- return s0;
598
- }
599
-
600
- function peg$parseToken() {
601
- var s0;
602
- s0 = peg$parseTag();
603
-
604
- if (s0 === peg$FAILED) {
605
- s0 = peg$parseChordLyricsPair();
606
-
607
- if (s0 === peg$FAILED) {
608
- s0 = peg$parseMetaTernary();
609
- }
610
- }
611
-
612
- return s0;
613
- }
614
-
615
- function peg$parseComment() {
616
- var s0, s1, s2, s3, s4, s5;
617
- s0 = peg$currPos;
618
- s1 = peg$parseSpace();
619
-
620
- if (s1 === peg$FAILED) {
621
- s1 = null;
622
- }
623
-
624
- if (s1 !== peg$FAILED) {
625
- if (input.charCodeAt(peg$currPos) === 35) {
626
- s2 = peg$c3;
627
- peg$currPos++;
628
- } else {
629
- s2 = peg$FAILED;
630
-
631
- if (peg$silentFails === 0) {
632
- peg$fail(peg$c4);
633
- }
634
- }
635
-
636
- if (s2 !== peg$FAILED) {
637
- s3 = peg$currPos;
638
- s4 = [];
639
-
640
- if (peg$c5.test(input.charAt(peg$currPos))) {
641
- s5 = input.charAt(peg$currPos);
642
- peg$currPos++;
643
- } else {
644
- s5 = peg$FAILED;
645
-
646
- if (peg$silentFails === 0) {
647
- peg$fail(peg$c6);
648
- }
649
- }
650
-
651
- while (s5 !== peg$FAILED) {
652
- s4.push(s5);
653
-
654
- if (peg$c5.test(input.charAt(peg$currPos))) {
655
- s5 = input.charAt(peg$currPos);
656
- peg$currPos++;
657
- } else {
658
- s5 = peg$FAILED;
659
-
660
- if (peg$silentFails === 0) {
661
- peg$fail(peg$c6);
662
- }
663
- }
664
- }
665
-
666
- if (s4 !== peg$FAILED) {
667
- s3 = input.substring(s3, peg$currPos);
668
- } else {
669
- s3 = s4;
670
- }
671
-
672
- if (s3 !== peg$FAILED) {
673
- peg$savedPos = s0;
674
- s1 = peg$c7(s3);
675
- s0 = s1;
676
- } else {
677
- peg$currPos = s0;
678
- s0 = peg$FAILED;
679
- }
680
- } else {
681
- peg$currPos = s0;
682
- s0 = peg$FAILED;
683
- }
684
- } else {
685
- peg$currPos = s0;
686
- s0 = peg$FAILED;
687
- }
688
-
689
- return s0;
690
- }
691
-
692
- function peg$parseChordLyricsPair() {
693
- var s0, s1, s2, s3, s4;
694
- s0 = peg$currPos;
695
- s1 = peg$parseChord();
696
-
697
- if (s1 !== peg$FAILED) {
698
- s2 = peg$currPos;
699
- s3 = [];
700
- s4 = peg$parseLyrics();
701
-
702
- while (s4 !== peg$FAILED) {
703
- s3.push(s4);
704
- s4 = peg$parseLyrics();
705
- }
706
-
707
- if (s3 !== peg$FAILED) {
708
- s2 = input.substring(s2, peg$currPos);
709
- } else {
710
- s2 = s3;
711
- }
712
-
713
- if (s2 !== peg$FAILED) {
714
- peg$savedPos = s0;
715
- s1 = peg$c8(s1, s2);
716
- s0 = s1;
717
- } else {
718
- peg$currPos = s0;
719
- s0 = peg$FAILED;
720
- }
721
- } else {
722
- peg$currPos = s0;
723
- s0 = peg$FAILED;
724
- }
725
-
726
- return s0;
727
- }
728
-
729
- function peg$parseLyrics() {
730
- var s0, s1, s2;
731
- s0 = peg$currPos;
732
- s1 = [];
733
- s2 = peg$parseLyricsChar();
734
-
735
- if (s2 !== peg$FAILED) {
736
- while (s2 !== peg$FAILED) {
737
- s1.push(s2);
738
- s2 = peg$parseLyricsChar();
739
- }
740
- } else {
741
- s1 = peg$FAILED;
742
- }
743
-
744
- if (s1 !== peg$FAILED) {
745
- peg$savedPos = s0;
746
- s1 = peg$c9(s1);
747
- }
748
-
749
- s0 = s1;
750
- return s0;
751
- }
752
-
753
- function peg$parseChord() {
754
- var s0, s1, s2, s3, s4;
755
- s0 = peg$currPos;
756
- s1 = peg$currPos;
757
- peg$silentFails++;
758
- s2 = peg$parseEscape();
759
- peg$silentFails--;
760
-
761
- if (s2 === peg$FAILED) {
762
- s1 = void 0;
763
- } else {
764
- peg$currPos = s1;
765
- s1 = peg$FAILED;
766
- }
767
-
768
- if (s1 !== peg$FAILED) {
769
- if (input.charCodeAt(peg$currPos) === 91) {
770
- s2 = peg$c10;
771
- peg$currPos++;
772
- } else {
773
- s2 = peg$FAILED;
774
-
775
- if (peg$silentFails === 0) {
776
- peg$fail(peg$c11);
777
- }
778
- }
779
-
780
- if (s2 !== peg$FAILED) {
781
- s3 = [];
782
- s4 = peg$parseChordChar();
783
-
784
- while (s4 !== peg$FAILED) {
785
- s3.push(s4);
786
- s4 = peg$parseChordChar();
787
- }
788
-
789
- if (s3 !== peg$FAILED) {
790
- if (input.charCodeAt(peg$currPos) === 93) {
791
- s4 = peg$c12;
792
- peg$currPos++;
793
- } else {
794
- s4 = peg$FAILED;
795
-
796
- if (peg$silentFails === 0) {
797
- peg$fail(peg$c13);
798
- }
799
- }
800
-
801
- if (s4 !== peg$FAILED) {
802
- peg$savedPos = s0;
803
- s1 = peg$c14(s3);
804
- s0 = s1;
805
- } else {
806
- peg$currPos = s0;
807
- s0 = peg$FAILED;
808
- }
809
- } else {
810
- peg$currPos = s0;
811
- s0 = peg$FAILED;
812
- }
813
- } else {
814
- peg$currPos = s0;
815
- s0 = peg$FAILED;
816
- }
817
- } else {
818
- peg$currPos = s0;
819
- s0 = peg$FAILED;
820
- }
821
-
822
- return s0;
823
- }
824
-
825
- function peg$parseChordChar() {
826
- var s0, s1, s2, s3;
827
-
828
- if (peg$c15.test(input.charAt(peg$currPos))) {
829
- s0 = input.charAt(peg$currPos);
830
- peg$currPos++;
831
- } else {
832
- s0 = peg$FAILED;
833
-
834
- if (peg$silentFails === 0) {
835
- peg$fail(peg$c16);
836
- }
837
- }
838
-
839
- if (s0 === peg$FAILED) {
840
- s0 = peg$currPos;
841
- s1 = peg$parseEscape();
842
-
843
- if (s1 !== peg$FAILED) {
844
- s2 = peg$currPos;
845
-
846
- if (input.charCodeAt(peg$currPos) === 92) {
847
- s3 = peg$c17;
848
- peg$currPos++;
849
- } else {
850
- s3 = peg$FAILED;
851
-
852
- if (peg$silentFails === 0) {
853
- peg$fail(peg$c18);
854
- }
855
- }
856
-
857
- if (s3 !== peg$FAILED) {
858
- peg$savedPos = s2;
859
- s3 = peg$c19();
860
- }
861
-
862
- s2 = s3;
863
-
864
- if (s2 === peg$FAILED) {
865
- s2 = peg$currPos;
866
-
867
- if (input.charCodeAt(peg$currPos) === 93) {
868
- s3 = peg$c12;
869
- peg$currPos++;
870
- } else {
871
- s3 = peg$FAILED;
872
-
873
- if (peg$silentFails === 0) {
874
- peg$fail(peg$c13);
875
- }
876
- }
877
-
878
- if (s3 !== peg$FAILED) {
879
- peg$savedPos = s2;
880
- s3 = peg$c20();
881
- }
882
-
883
- s2 = s3;
884
- }
885
-
886
- if (s2 !== peg$FAILED) {
887
- peg$savedPos = s0;
888
- s1 = peg$c21(s2);
889
- s0 = s1;
890
- } else {
891
- peg$currPos = s0;
892
- s0 = peg$FAILED;
893
- }
894
- } else {
895
- peg$currPos = s0;
896
- s0 = peg$FAILED;
897
- }
898
- }
899
-
900
- return s0;
901
- }
902
-
903
- function peg$parseMetaTernary() {
904
- var s0, s1, s2, s3, s4, s5, s6, s7, s8;
905
- s0 = peg$currPos;
906
-
907
- if (input.substr(peg$currPos, 2) === peg$c22) {
908
- s1 = peg$c22;
909
- peg$currPos += 2;
910
- } else {
911
- s1 = peg$FAILED;
912
-
913
- if (peg$silentFails === 0) {
914
- peg$fail(peg$c23);
915
- }
916
- }
917
-
918
- if (s1 !== peg$FAILED) {
919
- s2 = peg$parse_();
920
-
921
- if (s2 !== peg$FAILED) {
922
- s3 = peg$currPos;
923
- s4 = peg$parseMetaVariableName();
924
-
925
- if (s4 === peg$FAILED) {
926
- s4 = null;
927
- }
928
-
929
- if (s4 !== peg$FAILED) {
930
- s3 = input.substring(s3, peg$currPos);
931
- } else {
932
- s3 = s4;
933
- }
934
-
935
- if (s3 !== peg$FAILED) {
936
- s4 = peg$parseMetaValueTest();
937
-
938
- if (s4 === peg$FAILED) {
939
- s4 = null;
940
- }
941
-
942
- if (s4 !== peg$FAILED) {
943
- s5 = peg$parse_();
944
-
945
- if (s5 !== peg$FAILED) {
946
- s6 = peg$parseMetaTernaryTrueFalseExpressions();
947
-
948
- if (s6 === peg$FAILED) {
949
- s6 = null;
950
- }
951
-
952
- if (s6 !== peg$FAILED) {
953
- s7 = peg$parse_();
954
-
955
- if (s7 !== peg$FAILED) {
956
- if (input.charCodeAt(peg$currPos) === 125) {
957
- s8 = peg$c24;
958
- peg$currPos++;
959
- } else {
960
- s8 = peg$FAILED;
961
-
962
- if (peg$silentFails === 0) {
963
- peg$fail(peg$c25);
964
- }
965
- }
966
-
967
- if (s8 !== peg$FAILED) {
968
- peg$savedPos = s0;
969
- s1 = peg$c26(s3, s4, s6);
970
- s0 = s1;
971
- } else {
972
- peg$currPos = s0;
973
- s0 = peg$FAILED;
974
- }
975
- } else {
976
- peg$currPos = s0;
977
- s0 = peg$FAILED;
978
- }
979
- } else {
980
- peg$currPos = s0;
981
- s0 = peg$FAILED;
982
- }
983
- } else {
984
- peg$currPos = s0;
985
- s0 = peg$FAILED;
986
- }
987
- } else {
988
- peg$currPos = s0;
989
- s0 = peg$FAILED;
990
- }
991
- } else {
992
- peg$currPos = s0;
993
- s0 = peg$FAILED;
994
- }
995
- } else {
996
- peg$currPos = s0;
997
- s0 = peg$FAILED;
998
- }
999
- } else {
1000
- peg$currPos = s0;
1001
- s0 = peg$FAILED;
1002
- }
1003
-
1004
- return s0;
1005
- }
1006
-
1007
- function peg$parseMetaValueTest() {
1008
- var s0, s1, s2, s3;
1009
- s0 = peg$currPos;
1010
-
1011
- if (input.charCodeAt(peg$currPos) === 61) {
1012
- s1 = peg$c27;
1013
- peg$currPos++;
1014
- } else {
1015
- s1 = peg$FAILED;
1016
-
1017
- if (peg$silentFails === 0) {
1018
- peg$fail(peg$c28);
1019
- }
1020
- }
1021
-
1022
- if (s1 !== peg$FAILED) {
1023
- s2 = peg$parse_();
1024
-
1025
- if (s2 !== peg$FAILED) {
1026
- s3 = peg$parseMetaTestValue();
1027
-
1028
- if (s3 !== peg$FAILED) {
1029
- peg$savedPos = s0;
1030
- s1 = peg$c29(s3);
1031
- s0 = s1;
1032
- } else {
1033
- peg$currPos = s0;
1034
- s0 = peg$FAILED;
1035
- }
1036
- } else {
1037
- peg$currPos = s0;
1038
- s0 = peg$FAILED;
1039
- }
1040
- } else {
1041
- peg$currPos = s0;
1042
- s0 = peg$FAILED;
1043
- }
1044
-
1045
- return s0;
1046
- }
1047
-
1048
- function peg$parseMetaTestValue() {
1049
- var s0, s1, s2;
1050
- s0 = peg$currPos;
1051
- s1 = [];
1052
- s2 = peg$parseChar();
1053
-
1054
- if (s2 !== peg$FAILED) {
1055
- while (s2 !== peg$FAILED) {
1056
- s1.push(s2);
1057
- s2 = peg$parseChar();
1058
- }
1059
- } else {
1060
- s1 = peg$FAILED;
1061
- }
1062
-
1063
- if (s1 !== peg$FAILED) {
1064
- s0 = input.substring(s0, peg$currPos);
1065
- } else {
1066
- s0 = s1;
1067
- }
1068
-
1069
- return s0;
1070
- }
1071
-
1072
- function peg$parseMetaTernaryTrueFalseExpressions() {
1073
- var s0, s1, s2, s3, s4, s5, s6;
1074
- s0 = peg$currPos;
1075
-
1076
- if (input.charCodeAt(peg$currPos) === 124) {
1077
- s1 = peg$c30;
1078
- peg$currPos++;
1079
- } else {
1080
- s1 = peg$FAILED;
1081
-
1082
- if (peg$silentFails === 0) {
1083
- peg$fail(peg$c31);
1084
- }
1085
- }
1086
-
1087
- if (s1 !== peg$FAILED) {
1088
- s2 = peg$parse_();
1089
-
1090
- if (s2 !== peg$FAILED) {
1091
- s3 = peg$parseMetaExpression();
1092
-
1093
- if (s3 !== peg$FAILED) {
1094
- s4 = peg$parse_();
1095
-
1096
- if (s4 !== peg$FAILED) {
1097
- s5 = peg$parseMetaTernaryFalseExpression();
1098
-
1099
- if (s5 === peg$FAILED) {
1100
- s5 = null;
1101
- }
1102
-
1103
- if (s5 !== peg$FAILED) {
1104
- s6 = peg$parse_();
1105
-
1106
- if (s6 !== peg$FAILED) {
1107
- peg$savedPos = s0;
1108
- s1 = peg$c32(s3, s5);
1109
- s0 = s1;
1110
- } else {
1111
- peg$currPos = s0;
1112
- s0 = peg$FAILED;
1113
- }
1114
- } else {
1115
- peg$currPos = s0;
1116
- s0 = peg$FAILED;
1117
- }
1118
- } else {
1119
- peg$currPos = s0;
1120
- s0 = peg$FAILED;
1121
- }
1122
- } else {
1123
- peg$currPos = s0;
1124
- s0 = peg$FAILED;
1125
- }
1126
- } else {
1127
- peg$currPos = s0;
1128
- s0 = peg$FAILED;
1129
- }
1130
- } else {
1131
- peg$currPos = s0;
1132
- s0 = peg$FAILED;
1133
- }
1134
-
1135
- return s0;
1136
- }
1137
-
1138
- function peg$parseMetaTernaryFalseExpression() {
1139
- var s0, s1, s2, s3;
1140
- s0 = peg$currPos;
1141
-
1142
- if (input.charCodeAt(peg$currPos) === 124) {
1143
- s1 = peg$c30;
1144
- peg$currPos++;
1145
- } else {
1146
- s1 = peg$FAILED;
1147
-
1148
- if (peg$silentFails === 0) {
1149
- peg$fail(peg$c31);
1150
- }
1151
- }
1152
-
1153
- if (s1 !== peg$FAILED) {
1154
- s2 = peg$parse_();
1155
-
1156
- if (s2 !== peg$FAILED) {
1157
- s3 = peg$parseMetaExpression();
1158
-
1159
- if (s3 !== peg$FAILED) {
1160
- peg$savedPos = s0;
1161
- s1 = peg$c33(s3);
1162
- s0 = s1;
1163
- } else {
1164
- peg$currPos = s0;
1165
- s0 = peg$FAILED;
1166
- }
1167
- } else {
1168
- peg$currPos = s0;
1169
- s0 = peg$FAILED;
1170
- }
1171
- } else {
1172
- peg$currPos = s0;
1173
- s0 = peg$FAILED;
1174
- }
1175
-
1176
- return s0;
1177
- }
1178
-
1179
- function peg$parseMetaVariableName() {
1180
- var s0, s1;
1181
- s0 = [];
1182
-
1183
- if (peg$c34.test(input.charAt(peg$currPos))) {
1184
- s1 = input.charAt(peg$currPos);
1185
- peg$currPos++;
1186
- } else {
1187
- s1 = peg$FAILED;
1188
-
1189
- if (peg$silentFails === 0) {
1190
- peg$fail(peg$c35);
1191
- }
1192
- }
1193
-
1194
- if (s1 !== peg$FAILED) {
1195
- while (s1 !== peg$FAILED) {
1196
- s0.push(s1);
1197
-
1198
- if (peg$c34.test(input.charAt(peg$currPos))) {
1199
- s1 = input.charAt(peg$currPos);
1200
- peg$currPos++;
1201
- } else {
1202
- s1 = peg$FAILED;
1203
-
1204
- if (peg$silentFails === 0) {
1205
- peg$fail(peg$c35);
1206
- }
1207
- }
1208
- }
1209
- } else {
1210
- s0 = peg$FAILED;
1211
- }
1212
-
1213
- return s0;
1214
- }
1215
-
1216
- function peg$parseMetaExpression() {
1217
- var s0, s1, s2, s3;
1218
- s0 = [];
1219
- s1 = peg$currPos;
1220
- s2 = [];
1221
- s3 = peg$parseChar();
1222
-
1223
- if (s3 !== peg$FAILED) {
1224
- while (s3 !== peg$FAILED) {
1225
- s2.push(s3);
1226
- s3 = peg$parseChar();
1227
- }
1228
- } else {
1229
- s2 = peg$FAILED;
1230
- }
1231
-
1232
- if (s2 !== peg$FAILED) {
1233
- s1 = input.substring(s1, peg$currPos);
1234
- } else {
1235
- s1 = s2;
1236
- }
1237
-
1238
- if (s1 === peg$FAILED) {
1239
- s1 = peg$parseMetaTernary();
1240
- }
1241
-
1242
- if (s1 !== peg$FAILED) {
1243
- while (s1 !== peg$FAILED) {
1244
- s0.push(s1);
1245
- s1 = peg$currPos;
1246
- s2 = [];
1247
- s3 = peg$parseChar();
1248
-
1249
- if (s3 !== peg$FAILED) {
1250
- while (s3 !== peg$FAILED) {
1251
- s2.push(s3);
1252
- s3 = peg$parseChar();
1253
- }
1254
- } else {
1255
- s2 = peg$FAILED;
1256
- }
1257
-
1258
- if (s2 !== peg$FAILED) {
1259
- s1 = input.substring(s1, peg$currPos);
1260
- } else {
1261
- s1 = s2;
1262
- }
1263
-
1264
- if (s1 === peg$FAILED) {
1265
- s1 = peg$parseMetaTernary();
1266
- }
1267
- }
1268
- } else {
1269
- s0 = peg$FAILED;
1270
- }
1271
-
1272
- return s0;
1273
- }
1274
-
1275
- function peg$parseLyricsChar() {
1276
- var s0, s1;
1277
- s0 = peg$parseChar();
1278
-
1279
- if (s0 === peg$FAILED) {
1280
- s0 = peg$currPos;
1281
-
1282
- if (input.charCodeAt(peg$currPos) === 93) {
1283
- s1 = peg$c12;
1284
- peg$currPos++;
1285
- } else {
1286
- s1 = peg$FAILED;
1287
-
1288
- if (peg$silentFails === 0) {
1289
- peg$fail(peg$c13);
1290
- }
1291
- }
1292
-
1293
- if (s1 !== peg$FAILED) {
1294
- peg$savedPos = s0;
1295
- s1 = peg$c20();
1296
- }
1297
-
1298
- s0 = s1;
1299
-
1300
- if (s0 === peg$FAILED) {
1301
- s0 = peg$currPos;
1302
-
1303
- if (input.charCodeAt(peg$currPos) === 124) {
1304
- s1 = peg$c30;
1305
- peg$currPos++;
1306
- } else {
1307
- s1 = peg$FAILED;
1308
-
1309
- if (peg$silentFails === 0) {
1310
- peg$fail(peg$c31);
1311
- }
1312
- }
1313
-
1314
- if (s1 !== peg$FAILED) {
1315
- peg$savedPos = s0;
1316
- s1 = peg$c36();
1317
- }
1318
-
1319
- s0 = s1;
1320
-
1321
- if (s0 === peg$FAILED) {
1322
- s0 = peg$currPos;
1323
-
1324
- if (input.charCodeAt(peg$currPos) === 125) {
1325
- s1 = peg$c24;
1326
- peg$currPos++;
1327
- } else {
1328
- s1 = peg$FAILED;
1329
-
1330
- if (peg$silentFails === 0) {
1331
- peg$fail(peg$c25);
1332
- }
1333
- }
1334
-
1335
- if (s1 !== peg$FAILED) {
1336
- peg$savedPos = s0;
1337
- s1 = peg$c37();
1338
- }
1339
-
1340
- s0 = s1;
1341
- }
1342
- }
1343
- }
1344
-
1345
- return s0;
1346
- }
1347
-
1348
- function peg$parseChar() {
1349
- var s0, s1, s2, s3;
1350
-
1351
- if (peg$c38.test(input.charAt(peg$currPos))) {
1352
- s0 = input.charAt(peg$currPos);
1353
- peg$currPos++;
1354
- } else {
1355
- s0 = peg$FAILED;
1356
-
1357
- if (peg$silentFails === 0) {
1358
- peg$fail(peg$c39);
1359
- }
1360
- }
1361
-
1362
- if (s0 === peg$FAILED) {
1363
- s0 = peg$currPos;
1364
- s1 = peg$parseEscape();
1365
-
1366
- if (s1 !== peg$FAILED) {
1367
- s2 = peg$currPos;
1368
-
1369
- if (input.charCodeAt(peg$currPos) === 92) {
1370
- s3 = peg$c17;
1371
- peg$currPos++;
1372
- } else {
1373
- s3 = peg$FAILED;
1374
-
1375
- if (peg$silentFails === 0) {
1376
- peg$fail(peg$c18);
1377
- }
1378
- }
1379
-
1380
- if (s3 !== peg$FAILED) {
1381
- peg$savedPos = s2;
1382
- s3 = peg$c19();
1383
- }
1384
-
1385
- s2 = s3;
1386
-
1387
- if (s2 === peg$FAILED) {
1388
- s2 = peg$currPos;
1389
-
1390
- if (input.charCodeAt(peg$currPos) === 124) {
1391
- s3 = peg$c30;
1392
- peg$currPos++;
1393
- } else {
1394
- s3 = peg$FAILED;
1395
-
1396
- if (peg$silentFails === 0) {
1397
- peg$fail(peg$c31);
1398
- }
1399
- }
1400
-
1401
- if (s3 !== peg$FAILED) {
1402
- peg$savedPos = s2;
1403
- s3 = peg$c36();
1404
- }
1405
-
1406
- s2 = s3;
1407
-
1408
- if (s2 === peg$FAILED) {
1409
- s2 = peg$currPos;
1410
-
1411
- if (input.charCodeAt(peg$currPos) === 91) {
1412
- s3 = peg$c10;
1413
- peg$currPos++;
1414
- } else {
1415
- s3 = peg$FAILED;
1416
-
1417
- if (peg$silentFails === 0) {
1418
- peg$fail(peg$c11);
1419
- }
1420
- }
1421
-
1422
- if (s3 !== peg$FAILED) {
1423
- peg$savedPos = s2;
1424
- s3 = peg$c40();
1425
- }
1426
-
1427
- s2 = s3;
1428
-
1429
- if (s2 === peg$FAILED) {
1430
- s2 = peg$currPos;
1431
-
1432
- if (input.charCodeAt(peg$currPos) === 93) {
1433
- s3 = peg$c12;
1434
- peg$currPos++;
1435
- } else {
1436
- s3 = peg$FAILED;
1437
-
1438
- if (peg$silentFails === 0) {
1439
- peg$fail(peg$c13);
1440
- }
1441
- }
1442
-
1443
- if (s3 !== peg$FAILED) {
1444
- peg$savedPos = s2;
1445
- s3 = peg$c20();
1446
- }
1447
-
1448
- s2 = s3;
1449
-
1450
- if (s2 === peg$FAILED) {
1451
- s2 = peg$currPos;
1452
-
1453
- if (input.charCodeAt(peg$currPos) === 123) {
1454
- s3 = peg$c41;
1455
- peg$currPos++;
1456
- } else {
1457
- s3 = peg$FAILED;
1458
-
1459
- if (peg$silentFails === 0) {
1460
- peg$fail(peg$c42);
1461
- }
1462
- }
1463
-
1464
- if (s3 !== peg$FAILED) {
1465
- peg$savedPos = s2;
1466
- s3 = peg$c43();
1467
- }
1468
-
1469
- s2 = s3;
1470
-
1471
- if (s2 === peg$FAILED) {
1472
- s2 = peg$currPos;
1473
-
1474
- if (input.charCodeAt(peg$currPos) === 125) {
1475
- s3 = peg$c24;
1476
- peg$currPos++;
1477
- } else {
1478
- s3 = peg$FAILED;
1479
-
1480
- if (peg$silentFails === 0) {
1481
- peg$fail(peg$c25);
1482
- }
1483
- }
1484
-
1485
- if (s3 !== peg$FAILED) {
1486
- peg$savedPos = s2;
1487
- s3 = peg$c37();
1488
- }
1489
-
1490
- s2 = s3;
1491
-
1492
- if (s2 === peg$FAILED) {
1493
- s2 = peg$currPos;
1494
-
1495
- if (input.charCodeAt(peg$currPos) === 37) {
1496
- s3 = peg$c44;
1497
- peg$currPos++;
1498
- } else {
1499
- s3 = peg$FAILED;
1500
-
1501
- if (peg$silentFails === 0) {
1502
- peg$fail(peg$c45);
1503
- }
1504
- }
1505
-
1506
- if (s3 !== peg$FAILED) {
1507
- peg$savedPos = s2;
1508
- s3 = peg$c46();
1509
- }
1510
-
1511
- s2 = s3;
1512
-
1513
- if (s2 === peg$FAILED) {
1514
- s2 = peg$currPos;
1515
-
1516
- if (input.charCodeAt(peg$currPos) === 35) {
1517
- s3 = peg$c3;
1518
- peg$currPos++;
1519
- } else {
1520
- s3 = peg$FAILED;
1521
-
1522
- if (peg$silentFails === 0) {
1523
- peg$fail(peg$c4);
1524
- }
1525
- }
1526
-
1527
- if (s3 !== peg$FAILED) {
1528
- peg$savedPos = s2;
1529
- s3 = peg$c47();
1530
- }
1531
-
1532
- s2 = s3;
1533
- }
1534
- }
1535
- }
1536
- }
1537
- }
1538
- }
1539
- }
1540
-
1541
- if (s2 !== peg$FAILED) {
1542
- peg$savedPos = s0;
1543
- s1 = peg$c21(s2);
1544
- s0 = s1;
1545
- } else {
1546
- peg$currPos = s0;
1547
- s0 = peg$FAILED;
1548
- }
1549
- } else {
1550
- peg$currPos = s0;
1551
- s0 = peg$FAILED;
1552
- }
1553
- }
1554
-
1555
- return s0;
1556
- }
1557
-
1558
- function peg$parseTag() {
1559
- var s0, s1, s2, s3, s4, s5, s6, s7;
1560
- s0 = peg$currPos;
1561
-
1562
- if (input.charCodeAt(peg$currPos) === 123) {
1563
- s1 = peg$c41;
1564
- peg$currPos++;
1565
- } else {
1566
- s1 = peg$FAILED;
1567
-
1568
- if (peg$silentFails === 0) {
1569
- peg$fail(peg$c42);
1570
- }
1571
- }
1572
-
1573
- if (s1 !== peg$FAILED) {
1574
- s2 = peg$parse_();
1575
-
1576
- if (s2 !== peg$FAILED) {
1577
- s3 = peg$currPos;
1578
- s4 = peg$parseTagName();
1579
-
1580
- if (s4 !== peg$FAILED) {
1581
- s3 = input.substring(s3, peg$currPos);
1582
- } else {
1583
- s3 = s4;
1584
- }
1585
-
1586
- if (s3 !== peg$FAILED) {
1587
- s4 = peg$parse_();
1588
-
1589
- if (s4 !== peg$FAILED) {
1590
- s5 = peg$parseTagColonWithValue();
1591
-
1592
- if (s5 === peg$FAILED) {
1593
- s5 = null;
1594
- }
1595
-
1596
- if (s5 !== peg$FAILED) {
1597
- s6 = peg$parse_();
1598
-
1599
- if (s6 !== peg$FAILED) {
1600
- if (input.charCodeAt(peg$currPos) === 125) {
1601
- s7 = peg$c24;
1602
- peg$currPos++;
1603
- } else {
1604
- s7 = peg$FAILED;
1605
-
1606
- if (peg$silentFails === 0) {
1607
- peg$fail(peg$c25);
1608
- }
1609
- }
1610
-
1611
- if (s7 !== peg$FAILED) {
1612
- peg$savedPos = s0;
1613
- s1 = peg$c48(s3, s5);
1614
- s0 = s1;
1615
- } else {
1616
- peg$currPos = s0;
1617
- s0 = peg$FAILED;
1618
- }
1619
- } else {
1620
- peg$currPos = s0;
1621
- s0 = peg$FAILED;
1622
- }
1623
- } else {
1624
- peg$currPos = s0;
1625
- s0 = peg$FAILED;
1626
- }
1627
- } else {
1628
- peg$currPos = s0;
1629
- s0 = peg$FAILED;
1630
- }
1631
- } else {
1632
- peg$currPos = s0;
1633
- s0 = peg$FAILED;
1634
- }
1635
- } else {
1636
- peg$currPos = s0;
1637
- s0 = peg$FAILED;
1638
- }
1639
- } else {
1640
- peg$currPos = s0;
1641
- s0 = peg$FAILED;
1642
- }
1643
-
1644
- return s0;
1645
- }
1646
-
1647
- function peg$parseTagColonWithValue() {
1648
- var s0, s1, s2, s3;
1649
- s0 = peg$currPos;
1650
-
1651
- if (input.charCodeAt(peg$currPos) === 58) {
1652
- s1 = peg$c49;
1653
- peg$currPos++;
1654
- } else {
1655
- s1 = peg$FAILED;
1656
-
1657
- if (peg$silentFails === 0) {
1658
- peg$fail(peg$c50);
1659
- }
1660
- }
1661
-
1662
- if (s1 !== peg$FAILED) {
1663
- s2 = peg$parse_();
1664
-
1665
- if (s2 !== peg$FAILED) {
1666
- s3 = peg$parseTagValue();
1667
-
1668
- if (s3 !== peg$FAILED) {
1669
- peg$savedPos = s0;
1670
- s1 = peg$c51(s3);
1671
- s0 = s1;
1672
- } else {
1673
- peg$currPos = s0;
1674
- s0 = peg$FAILED;
1675
- }
1676
- } else {
1677
- peg$currPos = s0;
1678
- s0 = peg$FAILED;
1679
- }
1680
- } else {
1681
- peg$currPos = s0;
1682
- s0 = peg$FAILED;
1683
- }
1684
-
1685
- return s0;
1686
- }
1687
-
1688
- function peg$parseTagName() {
1689
- var s0, s1;
1690
- s0 = [];
1691
-
1692
- if (peg$c52.test(input.charAt(peg$currPos))) {
1693
- s1 = input.charAt(peg$currPos);
1694
- peg$currPos++;
1695
- } else {
1696
- s1 = peg$FAILED;
1697
-
1698
- if (peg$silentFails === 0) {
1699
- peg$fail(peg$c53);
1700
- }
1701
- }
1702
-
1703
- if (s1 !== peg$FAILED) {
1704
- while (s1 !== peg$FAILED) {
1705
- s0.push(s1);
1706
-
1707
- if (peg$c52.test(input.charAt(peg$currPos))) {
1708
- s1 = input.charAt(peg$currPos);
1709
- peg$currPos++;
1710
- } else {
1711
- s1 = peg$FAILED;
1712
-
1713
- if (peg$silentFails === 0) {
1714
- peg$fail(peg$c53);
1715
- }
1716
- }
1717
- }
1718
- } else {
1719
- s0 = peg$FAILED;
1720
- }
1721
-
1722
- return s0;
1723
- }
1724
-
1725
- function peg$parseTagValue() {
1726
- var s0, s1;
1727
- s0 = [];
1728
- s1 = peg$parseTagValueChar();
1729
-
1730
- while (s1 !== peg$FAILED) {
1731
- s0.push(s1);
1732
- s1 = peg$parseTagValueChar();
1733
- }
1734
-
1735
- return s0;
1736
- }
1737
-
1738
- function peg$parseTagValueChar() {
1739
- var s0, s1, s2, s3;
1740
-
1741
- if (peg$c54.test(input.charAt(peg$currPos))) {
1742
- s0 = input.charAt(peg$currPos);
1743
- peg$currPos++;
1744
- } else {
1745
- s0 = peg$FAILED;
1746
-
1747
- if (peg$silentFails === 0) {
1748
- peg$fail(peg$c55);
1749
- }
1750
- }
1751
-
1752
- if (s0 === peg$FAILED) {
1753
- s0 = peg$currPos;
1754
- s1 = peg$parseEscape();
1755
-
1756
- if (s1 !== peg$FAILED) {
1757
- s2 = peg$currPos;
1758
-
1759
- if (input.charCodeAt(peg$currPos) === 92) {
1760
- s3 = peg$c17;
1761
- peg$currPos++;
1762
- } else {
1763
- s3 = peg$FAILED;
1764
-
1765
- if (peg$silentFails === 0) {
1766
- peg$fail(peg$c18);
1767
- }
1768
- }
1769
-
1770
- if (s3 !== peg$FAILED) {
1771
- peg$savedPos = s2;
1772
- s3 = peg$c19();
1773
- }
1774
-
1775
- s2 = s3;
1776
-
1777
- if (s2 === peg$FAILED) {
1778
- s2 = peg$currPos;
1779
-
1780
- if (input.charCodeAt(peg$currPos) === 125) {
1781
- s3 = peg$c24;
1782
- peg$currPos++;
1783
- } else {
1784
- s3 = peg$FAILED;
1785
-
1786
- if (peg$silentFails === 0) {
1787
- peg$fail(peg$c25);
1788
- }
1789
- }
1790
-
1791
- if (s3 !== peg$FAILED) {
1792
- peg$savedPos = s2;
1793
- s3 = peg$c37();
1794
- }
1795
-
1796
- s2 = s3;
1797
-
1798
- if (s2 === peg$FAILED) {
1799
- s2 = peg$currPos;
1800
-
1801
- if (input.charCodeAt(peg$currPos) === 123) {
1802
- s3 = peg$c41;
1803
- peg$currPos++;
1804
- } else {
1805
- s3 = peg$FAILED;
1806
-
1807
- if (peg$silentFails === 0) {
1808
- peg$fail(peg$c42);
1809
- }
1810
- }
1811
-
1812
- if (s3 !== peg$FAILED) {
1813
- peg$savedPos = s2;
1814
- s3 = peg$c43();
1815
- }
1816
-
1817
- s2 = s3;
1818
- }
1819
- }
1820
-
1821
- if (s2 !== peg$FAILED) {
1822
- peg$savedPos = s0;
1823
- s1 = peg$c21(s2);
1824
- s0 = s1;
1825
- } else {
1826
- peg$currPos = s0;
1827
- s0 = peg$FAILED;
1828
- }
1829
- } else {
1830
- peg$currPos = s0;
1831
- s0 = peg$FAILED;
1832
- }
1833
- }
1834
-
1835
- return s0;
1836
- }
1837
-
1838
- function peg$parse_() {
1839
- var s0, s1;
1840
- peg$silentFails++;
1841
- s0 = [];
1842
-
1843
- if (peg$c57.test(input.charAt(peg$currPos))) {
1844
- s1 = input.charAt(peg$currPos);
1845
- peg$currPos++;
1846
- } else {
1847
- s1 = peg$FAILED;
1848
-
1849
- if (peg$silentFails === 0) {
1850
- peg$fail(peg$c58);
1851
- }
1852
- }
1853
-
1854
- while (s1 !== peg$FAILED) {
1855
- s0.push(s1);
1856
-
1857
- if (peg$c57.test(input.charAt(peg$currPos))) {
1858
- s1 = input.charAt(peg$currPos);
1859
- peg$currPos++;
1860
- } else {
1861
- s1 = peg$FAILED;
1862
-
1863
- if (peg$silentFails === 0) {
1864
- peg$fail(peg$c58);
1865
- }
1866
- }
1867
- }
1868
-
1869
- peg$silentFails--;
1870
-
1871
- if (s0 === peg$FAILED) {
1872
- s1 = peg$FAILED;
1873
-
1874
- if (peg$silentFails === 0) {
1875
- peg$fail(peg$c56);
1876
- }
1877
- }
1878
-
1879
- return s0;
1880
- }
1881
-
1882
- function peg$parseSpace() {
1883
- var s0, s1;
1884
- peg$silentFails++;
1885
- s0 = [];
1886
-
1887
- if (peg$c60.test(input.charAt(peg$currPos))) {
1888
- s1 = input.charAt(peg$currPos);
1889
- peg$currPos++;
1890
- } else {
1891
- s1 = peg$FAILED;
1892
-
1893
- if (peg$silentFails === 0) {
1894
- peg$fail(peg$c61);
1895
- }
1896
- }
1897
-
1898
- if (s1 !== peg$FAILED) {
1899
- while (s1 !== peg$FAILED) {
1900
- s0.push(s1);
1901
-
1902
- if (peg$c60.test(input.charAt(peg$currPos))) {
1903
- s1 = input.charAt(peg$currPos);
1904
- peg$currPos++;
1905
- } else {
1906
- s1 = peg$FAILED;
1907
-
1908
- if (peg$silentFails === 0) {
1909
- peg$fail(peg$c61);
1910
- }
1911
- }
1912
- }
1913
- } else {
1914
- s0 = peg$FAILED;
1915
- }
1916
-
1917
- peg$silentFails--;
1918
-
1919
- if (s0 === peg$FAILED) {
1920
- s1 = peg$FAILED;
1921
-
1922
- if (peg$silentFails === 0) {
1923
- peg$fail(peg$c59);
1924
- }
1925
- }
1926
-
1927
- return s0;
1928
- }
1929
-
1930
- function peg$parseNewLine() {
1931
- var s0;
1932
- s0 = peg$parseCarriageReturn();
1933
-
1934
- if (s0 === peg$FAILED) {
1935
- s0 = peg$parseLineFeed();
1936
-
1937
- if (s0 === peg$FAILED) {
1938
- s0 = peg$parseCarriageReturnLineFeed();
1939
- }
1940
- }
1941
-
1942
- return s0;
1943
- }
1944
-
1945
- function peg$parseCarriageReturnLineFeed() {
1946
- var s0, s1, s2;
1947
- s0 = peg$currPos;
1948
- s1 = peg$parseCarriageReturn();
1949
-
1950
- if (s1 !== peg$FAILED) {
1951
- s2 = peg$parseLineFeed();
1952
-
1953
- if (s2 !== peg$FAILED) {
1954
- s1 = [s1, s2];
1955
- s0 = s1;
1956
- } else {
1957
- peg$currPos = s0;
1958
- s0 = peg$FAILED;
1959
- }
1960
- } else {
1961
- peg$currPos = s0;
1962
- s0 = peg$FAILED;
1963
- }
1964
-
1965
- return s0;
1966
- }
1967
-
1968
- function peg$parseLineFeed() {
1969
- var s0;
1970
-
1971
- if (input.charCodeAt(peg$currPos) === 10) {
1972
- s0 = peg$c62;
1973
- peg$currPos++;
1974
- } else {
1975
- s0 = peg$FAILED;
1976
-
1977
- if (peg$silentFails === 0) {
1978
- peg$fail(peg$c63);
1979
- }
1980
- }
1981
-
1982
- return s0;
1983
- }
1984
-
1985
- function peg$parseCarriageReturn() {
1986
- var s0;
1987
-
1988
- if (input.charCodeAt(peg$currPos) === 13) {
1989
- s0 = peg$c64;
1990
- peg$currPos++;
1991
- } else {
1992
- s0 = peg$FAILED;
1993
-
1994
- if (peg$silentFails === 0) {
1995
- peg$fail(peg$c65);
1996
- }
1997
- }
1998
-
1999
- return s0;
2000
- }
2001
-
2002
- function peg$parseEscape() {
2003
- var s0;
2004
-
2005
- if (input.charCodeAt(peg$currPos) === 92) {
2006
- s0 = peg$c17;
2007
- peg$currPos++;
2008
- } else {
2009
- s0 = peg$FAILED;
2010
-
2011
- if (peg$silentFails === 0) {
2012
- peg$fail(peg$c18);
2013
- }
2014
- }
2015
-
2016
- return s0;
2017
- }
2018
-
2019
- function peg$parsePound() {
2020
- var s0;
2021
-
2022
- if (input.charCodeAt(peg$currPos) === 35) {
2023
- s0 = peg$c3;
2024
- peg$currPos++;
2025
- } else {
2026
- s0 = peg$FAILED;
2027
-
2028
- if (peg$silentFails === 0) {
2029
- peg$fail(peg$c4);
2030
- }
2031
- }
2032
-
2033
- return s0;
2034
- }
2035
-
2036
- function peg$parsePercent() {
2037
- var s0;
2038
-
2039
- if (input.charCodeAt(peg$currPos) === 37) {
2040
- s0 = peg$c44;
2041
- peg$currPos++;
2042
- } else {
2043
- s0 = peg$FAILED;
2044
-
2045
- if (peg$silentFails === 0) {
2046
- peg$fail(peg$c45);
2047
- }
2048
- }
2049
-
2050
- return s0;
2051
- }
2052
-
2053
- peg$result = peg$startRuleFunction();
2054
-
2055
- if (peg$result !== peg$FAILED && peg$currPos === input.length) {
2056
- return peg$result;
2057
- } else {
2058
- if (peg$result !== peg$FAILED && peg$currPos < input.length) {
2059
- peg$fail(peg$endExpectation());
2060
- }
2061
-
2062
- throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
2063
- }
2064
- }
2065
-
2066
- module.exports = {
2067
- SyntaxError: peg$SyntaxError,
2068
- parse: peg$parse
2069
- };