@retorquere/bibtex-parser 8.0.7 → 8.0.8

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.
package/grammar.js DELETED
@@ -1,5020 +0,0 @@
1
- // @generated by Peggy 4.0.2.
2
- //
3
- // https://peggyjs.org/
4
-
5
- "use strict";
6
-
7
-
8
- function peg$subclass(child, parent) {
9
- function C() { this.constructor = child; }
10
- C.prototype = parent.prototype;
11
- child.prototype = new C();
12
- }
13
-
14
- function peg$SyntaxError(message, expected, found, location) {
15
- var self = Error.call(this, message);
16
- // istanbul ignore next Check is a necessary evil to support older environments
17
- if (Object.setPrototypeOf) {
18
- Object.setPrototypeOf(self, peg$SyntaxError.prototype);
19
- }
20
- self.expected = expected;
21
- self.found = found;
22
- self.location = location;
23
- self.name = "SyntaxError";
24
- return self;
25
- }
26
-
27
- peg$subclass(peg$SyntaxError, Error);
28
-
29
- function peg$padEnd(str, targetLength, padString) {
30
- padString = padString || " ";
31
- if (str.length > targetLength) { return str; }
32
- targetLength -= str.length;
33
- padString += padString.repeat(targetLength);
34
- return str + padString.slice(0, targetLength);
35
- }
36
-
37
- peg$SyntaxError.prototype.format = function(sources) {
38
- var str = "Error: " + this.message;
39
- if (this.location) {
40
- var src = null;
41
- var k;
42
- for (k = 0; k < sources.length; k++) {
43
- if (sources[k].source === this.location.source) {
44
- src = sources[k].text.split(/\r\n|\n|\r/g);
45
- break;
46
- }
47
- }
48
- var s = this.location.start;
49
- var offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
50
- ? this.location.source.offset(s)
51
- : s;
52
- var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
53
- if (src) {
54
- var e = this.location.end;
55
- var filler = peg$padEnd("", offset_s.line.toString().length, ' ');
56
- var line = src[s.line - 1];
57
- var last = s.line === e.line ? e.column : line.length + 1;
58
- var hatLen = (last - s.column) || 1;
59
- str += "\n --> " + loc + "\n"
60
- + filler + " |\n"
61
- + offset_s.line + " | " + line + "\n"
62
- + filler + " | " + peg$padEnd("", s.column - 1, ' ')
63
- + peg$padEnd("", hatLen, "^");
64
- } else {
65
- str += "\n at " + loc;
66
- }
67
- }
68
- return str;
69
- };
70
-
71
- peg$SyntaxError.buildMessage = function(expected, found) {
72
- var DESCRIBE_EXPECTATION_FNS = {
73
- literal: function(expectation) {
74
- return "\"" + literalEscape(expectation.text) + "\"";
75
- },
76
-
77
- class: function(expectation) {
78
- var escapedParts = expectation.parts.map(function(part) {
79
- return Array.isArray(part)
80
- ? classEscape(part[0]) + "-" + classEscape(part[1])
81
- : classEscape(part);
82
- });
83
-
84
- return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
85
- },
86
-
87
- any: function() {
88
- return "any character";
89
- },
90
-
91
- end: function() {
92
- return "end of input";
93
- },
94
-
95
- other: function(expectation) {
96
- return expectation.description;
97
- }
98
- };
99
-
100
- function hex(ch) {
101
- return ch.charCodeAt(0).toString(16).toUpperCase();
102
- }
103
-
104
- function literalEscape(s) {
105
- return s
106
- .replace(/\\/g, "\\\\")
107
- .replace(/"/g, "\\\"")
108
- .replace(/\0/g, "\\0")
109
- .replace(/\t/g, "\\t")
110
- .replace(/\n/g, "\\n")
111
- .replace(/\r/g, "\\r")
112
- .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
113
- .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
114
- }
115
-
116
- function classEscape(s) {
117
- return s
118
- .replace(/\\/g, "\\\\")
119
- .replace(/\]/g, "\\]")
120
- .replace(/\^/g, "\\^")
121
- .replace(/-/g, "\\-")
122
- .replace(/\0/g, "\\0")
123
- .replace(/\t/g, "\\t")
124
- .replace(/\n/g, "\\n")
125
- .replace(/\r/g, "\\r")
126
- .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
127
- .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
128
- }
129
-
130
- function describeExpectation(expectation) {
131
- return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
132
- }
133
-
134
- function describeExpected(expected) {
135
- var descriptions = expected.map(describeExpectation);
136
- var i, j;
137
-
138
- descriptions.sort();
139
-
140
- if (descriptions.length > 0) {
141
- for (i = 1, j = 1; i < descriptions.length; i++) {
142
- if (descriptions[i - 1] !== descriptions[i]) {
143
- descriptions[j] = descriptions[i];
144
- j++;
145
- }
146
- }
147
- descriptions.length = j;
148
- }
149
-
150
- switch (descriptions.length) {
151
- case 1:
152
- return descriptions[0];
153
-
154
- case 2:
155
- return descriptions[0] + " or " + descriptions[1];
156
-
157
- default:
158
- return descriptions.slice(0, -1).join(", ")
159
- + ", or "
160
- + descriptions[descriptions.length - 1];
161
- }
162
- }
163
-
164
- function describeFound(found) {
165
- return found ? "\"" + literalEscape(found) + "\"" : "end of input";
166
- }
167
-
168
- return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
169
- };
170
-
171
- function peg$parse(input, options) {
172
- options = options !== undefined ? options : {};
173
-
174
- var peg$FAILED = {};
175
- var peg$source = options.grammarSource;
176
-
177
- var peg$startRuleFunctions = { Bibliography: peg$parseBibliography };
178
- var peg$startRuleFunction = peg$parseBibliography;
179
-
180
- var peg$c0 = "@";
181
- var peg$c1 = "comment";
182
- var peg$c2 = "{";
183
- var peg$c3 = "}";
184
- var peg$c4 = "preamble";
185
- var peg$c5 = "string";
186
- var peg$c6 = ",";
187
- var peg$c7 = "\"";
188
- var peg$c8 = "\\begin{";
189
- var peg$c9 = "\\end{";
190
- var peg$c10 = "{\\";
191
- var peg$c11 = "\\";
192
- var peg$c12 = "$";
193
- var peg$c13 = "$$";
194
- var peg$c14 = "\\[";
195
- var peg$c15 = "\\]";
196
- var peg$c16 = "%";
197
- var peg$c17 = "\\\\";
198
- var peg$c18 = "newcommand";
199
- var peg$c19 = "\\left(";
200
- var peg$c20 = "\\right)";
201
- var peg$c21 = "url";
202
- var peg$c22 = "href";
203
- var peg$c23 = "\\verb";
204
- var peg$c24 = "begin";
205
- var peg$c25 = "end";
206
- var peg$c26 = "[";
207
- var peg$c27 = "]";
208
- var peg$c28 = "=";
209
- var peg$c29 = "#";
210
-
211
- var peg$r0 = /^[^\n\r]/;
212
- var peg$r1 = /^[\n\r]/;
213
- var peg$r2 = /^[^@]/;
214
- var peg$r3 = /^[^{}]/;
215
- var peg$r4 = /^[_A-Za-z]/;
216
- var peg$r5 = /^[({]/;
217
- var peg$r6 = /^[})]/;
218
- var peg$r7 = /^[^ \t\r\n,]/;
219
- var peg$r8 = /^[0-9A-Za-z!$&*+\-.\/:;<>?@[\\\]\^_`|~]/;
220
- var peg$r9 = /^[^{}"]/;
221
- var peg$r10 = /^[^\^_${}\\]/;
222
- var peg$r11 = /^[^\^_${}"\\]/;
223
- var peg$r12 = /^[0-9]/;
224
- var peg$r13 = /^[a-zA-Z0-9]/;
225
- var peg$r14 = /^[ij]/;
226
- var peg$r15 = /^[^\r\n]/;
227
- var peg$r16 = /^[_\^]/;
228
- var peg$r17 = /^[^A-Za-z0-9[\]\t\r\n]/;
229
- var peg$r18 = /^[A-Za-z]/;
230
- var peg$r19 = /^[^\]]/;
231
- var peg$r20 = /^[^ \t\^_${}\\]/;
232
- var peg$r21 = /^[a-zA-Z\-_]/;
233
- var peg$r22 = /^[a-zA-Z0-9\-&_:]/;
234
- var peg$r23 = /^['`"=~\^.]/;
235
- var peg$r24 = /^['`"=~\^.cbuvdrHk]/;
236
- var peg$r25 = /^[\r\n]/;
237
- var peg$r26 = /^[ \t]/;
238
- var peg$r27 = /^[ \t\n\r]/;
239
-
240
- var peg$e0 = peg$literalExpectation("@", false);
241
- var peg$e1 = peg$literalExpectation("comment", true);
242
- var peg$e2 = peg$classExpectation(["\n", "\r"], true, false);
243
- var peg$e3 = peg$classExpectation(["\n", "\r"], false, false);
244
- var peg$e4 = peg$classExpectation(["@"], true, false);
245
- var peg$e5 = peg$literalExpectation("{", false);
246
- var peg$e6 = peg$classExpectation(["{", "}"], true, false);
247
- var peg$e7 = peg$literalExpectation("}", false);
248
- var peg$e8 = peg$classExpectation(["_", ["A", "Z"], ["a", "z"]], false, false);
249
- var peg$e9 = peg$classExpectation(["(", "{"], false, false);
250
- var peg$e10 = peg$classExpectation(["}", ")"], false, false);
251
- var peg$e11 = peg$literalExpectation("preamble", true);
252
- var peg$e12 = peg$literalExpectation("string", true);
253
- var peg$e13 = peg$classExpectation([" ", "\t", "\r", "\n", ","], true, false);
254
- var peg$e14 = peg$literalExpectation(",", false);
255
- var peg$e15 = peg$classExpectation([["0", "9"], ["A", "Z"], ["a", "z"], "!", "$", "&", "*", "+", "-", ".", "/", ":", ";", "<", ">", "?", "@", "[", "\\", "]", "^", "_", "`", "|", "~"], false, false);
256
- var peg$e16 = peg$literalExpectation("\"", false);
257
- var peg$e17 = peg$classExpectation(["{", "}", "\""], true, false);
258
- var peg$e18 = peg$classExpectation(["^", "_", "$", "{", "}", "\\"], true, false);
259
- var peg$e19 = peg$classExpectation(["^", "_", "$", "{", "}", "\"", "\\"], true, false);
260
- var peg$e20 = peg$classExpectation([["0", "9"]], false, false);
261
- var peg$e21 = peg$literalExpectation("\\begin{", false);
262
- var peg$e22 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false);
263
- var peg$e23 = peg$literalExpectation("\\end{", false);
264
- var peg$e24 = peg$literalExpectation("{\\", false);
265
- var peg$e25 = peg$literalExpectation("\\", false);
266
- var peg$e26 = peg$classExpectation(["i", "j"], false, false);
267
- var peg$e27 = peg$literalExpectation("$", false);
268
- var peg$e28 = peg$literalExpectation("$$", false);
269
- var peg$e29 = peg$literalExpectation("\\[", false);
270
- var peg$e30 = peg$literalExpectation("\\]", false);
271
- var peg$e31 = peg$literalExpectation("%", false);
272
- var peg$e32 = peg$classExpectation(["\r", "\n"], true, false);
273
- var peg$e33 = peg$literalExpectation("\\\\", false);
274
- var peg$e34 = peg$classExpectation(["_", "^"], false, false);
275
- var peg$e35 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "[", "]", "\t", "\r", "\n"], true, false);
276
- var peg$e36 = peg$literalExpectation("newcommand", false);
277
- var peg$e37 = peg$literalExpectation("\\left(", false);
278
- var peg$e38 = peg$literalExpectation("\\right)", false);
279
- var peg$e39 = peg$literalExpectation("url", false);
280
- var peg$e40 = peg$literalExpectation("href", false);
281
- var peg$e41 = peg$literalExpectation("\\verb", false);
282
- var peg$e42 = peg$anyExpectation();
283
- var peg$e43 = peg$literalExpectation("begin", false);
284
- var peg$e44 = peg$literalExpectation("end", false);
285
- var peg$e45 = peg$classExpectation([["A", "Z"], ["a", "z"]], false, false);
286
- var peg$e46 = peg$literalExpectation("[", false);
287
- var peg$e47 = peg$classExpectation(["]"], true, false);
288
- var peg$e48 = peg$literalExpectation("]", false);
289
- var peg$e49 = peg$classExpectation([" ", "\t", "^", "_", "$", "{", "}", "\\"], true, false);
290
- var peg$e50 = peg$classExpectation([["a", "z"], ["A", "Z"], "-", "_"], false, false);
291
- var peg$e51 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "-", "&", "_", ":"], false, false);
292
- var peg$e52 = peg$classExpectation(["'", "`", "\"", "=", "~", "^", "."], false, false);
293
- var peg$e53 = peg$classExpectation(["'", "`", "\"", "=", "~", "^", ".", "c", "b", "u", "v", "d", "r", "H", "k"], false, false);
294
- var peg$e54 = peg$literalExpectation("=", false);
295
- var peg$e55 = peg$literalExpectation("#", false);
296
- var peg$e56 = peg$classExpectation(["\r", "\n"], false, false);
297
- var peg$e57 = peg$otherExpectation("Mandatory Horizontal Whitespace");
298
- var peg$e58 = peg$classExpectation([" ", "\t"], false, false);
299
- var peg$e59 = peg$otherExpectation("Optional Horizontal Whitespace");
300
- var peg$e60 = peg$otherExpectation("Mandatory Vertical Whitespace");
301
- var peg$e61 = peg$otherExpectation("Optional Vertical Whitespace");
302
- var peg$e62 = peg$otherExpectation("Mandatory Whitespace");
303
- var peg$e63 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false);
304
- var peg$e64 = peg$otherExpectation("Optional Whitespace");
305
-
306
- var peg$f0 = function(r) {
307
- return {
308
- kind: 'Bibliography',
309
- loc: location(),
310
- source: text(),
311
- children: r,
312
- }
313
- };
314
- var peg$f1 = function(v) {
315
- return {
316
- kind: 'BracedComment',
317
- loc: location(),
318
- source: text(),
319
- value: v.slice(1, -1),
320
- }
321
- };
322
- var peg$f2 = function(v) {
323
- return {
324
- kind: 'LineComment',
325
- loc: location(),
326
- source: text(),
327
- value: normalizeWhitespace(v),
328
- }
329
- };
330
- var peg$f3 = function(v) {
331
- return {
332
- kind: 'NonEntryText',
333
- loc: location(),
334
- source: text(),
335
- value: normalizeWhitespace(v),
336
- }
337
- };
338
- var peg$f4 = function(n) { return n; };
339
- var peg$f5 = function(comment) { return '{' + comment.join('') + '}' };
340
- var peg$f6 = function(type, id, fields) {
341
- return {
342
- kind: 'Entry',
343
- id: id || '',
344
- type: type.toLowerCase(),
345
- loc: location(),
346
- source: text(),
347
- fields: fields,
348
- }
349
- };
350
- var peg$f7 = function(opener, v, closer) {
351
- switch (opener + closer) {
352
- case '{}':
353
- case '()':
354
- break
355
- default:
356
- throw new Error(`Unbalanced opener-closer for preamble: ${opener}...${closer}`)
357
- break
358
- }
359
- return {
360
- kind: 'PreambleExpression',
361
- loc: location(),
362
- source: text(),
363
- value: v.reduce((a, b) => a.concat(b), []),
364
- }
365
- };
366
- var peg$f8 = function(k, v) {
367
- return {
368
- kind: 'StringDeclaration',
369
- loc: location(),
370
- source: text(),
371
- name: k,
372
- value: v.reduce((a, b) => a.concat(b), []),
373
- }
374
- };
375
- var peg$f9 = function(id) { return id; };
376
- var peg$f10 = function(name) { return isVerbatimField(name) && unnestFields.includes(name) };
377
- var peg$f11 = function(name, value) {
378
- // because this was abused so much, many processors treat double-outer-braces as single
379
- return {
380
- kind: 'Field',
381
- loc: location(),
382
- source: text(),
383
- name: name,
384
- loc: location(),
385
- value: [ protect(value) ]
386
- }
387
- };
388
- var peg$f12 = function(name) { return isVerbatimField(name) };
389
- var peg$f13 = function(name, value) {
390
- return {
391
- kind: 'Field',
392
- loc: location(),
393
- source: text(),
394
- name: name,
395
- loc: location(),
396
- value: [ protect(value) ]
397
- }
398
- };
399
- var peg$f14 = function(name, value) {
400
- // because this was abused so much, many processors treat double-outer-braces as single
401
- if (unnestFields.includes(name) && Array.isArray(value) && value.length === 1 && value[0].kind === 'Block') {
402
- if (options.unnestMode === 'preserve') {
403
- value[0].case = 'preserve'
404
- } else {
405
- value = value[0].value
406
- }
407
- }
408
-
409
- return handle_markup_switches({
410
- kind: 'Field',
411
- loc: location(),
412
- source: text(),
413
- name: name,
414
- value: value,
415
- })
416
- };
417
- var peg$f15 = function(name) { return name.toLowerCase() };
418
- var peg$f16 = function(v) {
419
- return basicTextConversions({
420
- kind: 'Text',
421
- loc: location(),
422
- source: text(),
423
- value: v || '',
424
- mode: 'verbatim',
425
- })
426
- };
427
- var peg$f17 = function(v) {
428
- return basicTextConversions({
429
- kind: 'Text',
430
- loc: location(),
431
- source: text(),
432
- value: v.join(''),
433
- mode: 'verbatim',
434
- })
435
- };
436
- var peg$f18 = function(v) { return v };
437
- var peg$f19 = function(v) { return '{' + v + '}' };
438
- var peg$f20 = function(v) { return v };
439
- var peg$f21 = function(v) { return '{' + v + '}' };
440
- var peg$f22 = function() { return math.set(false) };
441
- var peg$f23 = function(v) {
442
- return v.reduce((a, b) => a.concat(b), []);
443
- };
444
- var peg$f24 = function(v) { return parBreak(v); };
445
- var peg$f25 = function(v) { return parBreak(v); };
446
- var peg$f26 = function(v) { return v; };
447
- var peg$f27 = function(v) { return v; };
448
- var peg$f28 = function(v) {
449
- return basicTextConversions({
450
- kind: 'Text',
451
- loc: location(),
452
- source: text(),
453
- value: math.on ? v.replace(/[ \r\n\t]/g, '') : v,
454
- mode: math.on ? 'math' : 'text',
455
- })
456
- };
457
- var peg$f29 = function(v) {
458
- return basicTextConversions({
459
- kind: 'Text',
460
- loc: location(),
461
- source: text(),
462
- value: v,
463
- mode: math.on ? 'math' : 'text',
464
- })
465
- };
466
- var peg$f30 = function(v) {
467
- return {
468
- kind: 'Number',
469
- loc: location(),
470
- source: text(),
471
- value: parseInt(v, 10),
472
- }
473
- };
474
- var peg$f31 = function(v) {
475
- return {
476
- kind: 'StringReference',
477
- loc: location(),
478
- source: text(),
479
- name: v,
480
- }
481
- };
482
- var peg$f32 = function(env, v, cenv) { return env === cenv };
483
- var peg$f33 = function(env, v, cenv) {
484
- if (markup[env]) {
485
- return {
486
- kind: 'Block',
487
- loc: location(),
488
- source: text(),
489
- value: v,
490
- markup: { [markup[env]]: true },
491
- }
492
- } else {
493
- return {
494
- kind: 'Environment',
495
- loc: location(),
496
- source: text(),
497
- value: v,
498
- env: env,
499
- }
500
- }
501
- };
502
- var peg$f34 = function(mark, chr) {
503
- return {
504
- kind: 'DiacriticCommand',
505
- loc: location(),
506
- source: text(),
507
- mark: mark,
508
- dotless: !!chr[1],
509
- character: chr[1] || chr[0],
510
- }
511
- };
512
- var peg$f35 = function(v) {
513
- const block = {
514
- kind: 'Block',
515
- loc: location(),
516
- source: text(),
517
- value: v,
518
- markup: {},
519
- case: 'protect',
520
- }
521
-
522
- let leadingcmd = block.value.length && (block.value[0].kind.endsWith('Command') || block.value[0].kind === 'Environment') ? block.value[0] : null
523
- let leadingcmdblockarg = leadingcmd
524
- && leadingcmd.kind === 'RegularCommand'
525
- && leadingcmd.arguments.required.length
526
- && leadingcmd.arguments.required[0].kind === 'Block'
527
- && leadingcmd.arguments.required[0]
528
-
529
- // https://github.com/retorquere/zotero-better-bibtex/issues/541#issuecomment-240156274
530
- if (leadingcmd) {
531
- delete block.case
532
-
533
- // command with a block cancels out case protection with containing block
534
- // if a smallcaps block has set case to 'preserve' we want to keep this
535
- if (leadingcmdblockarg && leadingcmdblockarg.case === 'protect') delete leadingcmdblockarg.case
536
-
537
- // \sl, \it etc
538
- if (markup[leadingcmd.command] && leadingcmd.arguments.required.length === 0) {
539
- block.markup[markup[leadingcmd.command]] = true
540
- block.value.shift()
541
- }
542
- }
543
-
544
- block.value = parBreak(block.value)
545
-
546
- return handle_markup_switches(block)
547
- };
548
- var peg$f36 = function() { return !math.on };
549
- var peg$f37 = function(mode) { return math.set(true) };
550
- var peg$f38 = function(mode, v) { return math.set(false) };
551
- var peg$f39 = function(mode, v) {
552
- return {
553
- kind: mode == '$$' ? 'DisplayMath' : 'InlineMath',
554
- loc: location(),
555
- source: text(),
556
- value: v,
557
- case: 'protect',
558
- markup: {},
559
- }
560
- };
561
- var peg$f40 = function(v) {
562
- return {
563
- kind: 'LineComment',
564
- loc: location(),
565
- source: text(),
566
- value: v,
567
- }
568
- };
569
- var peg$f41 = function() {
570
- return {
571
- kind: 'RegularCommand',
572
- loc: location(),
573
- source: text(),
574
- command: '\\',
575
- arguments: {
576
- optional: [],
577
- required: [],
578
- },
579
- }
580
- };
581
- var peg$f42 = function() { return math.on };
582
- var peg$f43 = function(mode, v) {
583
- if (v.kind === 'Block') v = v.value
584
-
585
- return {
586
- kind: mode === '_' ? 'SubscriptCommand' : 'SuperscriptCommand',
587
- loc: location(),
588
- source: text(),
589
- value: v,
590
- }
591
- };
592
- var peg$f44 = function(char) {
593
- return {
594
- kind: 'Text',
595
- loc: location(),
596
- source: text(),
597
- value: char,
598
- mode: 'text',
599
- }
600
- };
601
- var peg$f45 = function(mark, chr) {
602
- return {
603
- kind: 'DiacriticCommand',
604
- loc: location(),
605
- source: text(),
606
- mark: mark,
607
- dotless: !!chr[1],
608
- character: chr[1] || chr[0],
609
- }
610
- };
611
- var peg$f46 = function(mark, chr) {
612
- return {
613
- kind: 'DiacriticCommand',
614
- loc: location(),
615
- source: text(),
616
- mark: mark,
617
- dotless: !!chr[1],
618
- character: chr[1] || chr[0],
619
- }
620
- };
621
- var peg$f47 = function(mark, v) {
622
- return {
623
- kind: 'RegularCommand',
624
- loc: location(),
625
- source: text(),
626
- command: mark,
627
- arguments: {
628
- optional: [],
629
- required: [ protect(v) ],
630
- },
631
- }
632
- };
633
- var peg$f48 = function(v) {
634
- return {
635
- kind: 'SymbolCommand',
636
- loc: location(),
637
- source: text(),
638
- command: v,
639
- }
640
- };
641
- var peg$f49 = function(cmd, name) { return name.value.length == 1 && name.value[0].kind === 'RegularCommand' };
642
- var peg$f50 = function(cmd, name, optional, def) {
643
- return {
644
- kind: 'RegularCommand',
645
- loc: location(),
646
- source: text(),
647
- command: cmd,
648
- arguments: {
649
- optional: [],
650
- required: [name, def],
651
- },
652
- }
653
- };
654
- var peg$f51 = function() {
655
- return {
656
- kind: 'Text',
657
- loc: location(),
658
- source: text(),
659
- value: '(',
660
- mode: math.on ? 'math' : 'text',
661
- }
662
- };
663
- var peg$f52 = function() {
664
- return {
665
- kind: 'Text',
666
- loc: location(),
667
- source: text(),
668
- value: ')',
669
- mode: math.on ? 'math' : 'text',
670
- }
671
- };
672
- var peg$f53 = function(cmd, url) {
673
- // https://github.com/retorquere/zotero-better-bibtex/issues/2617
674
- url.value = url.value.replace(/\\([\#%])/g, '$1')
675
- return {
676
- kind: 'RegularCommand',
677
- loc: location(),
678
- source: text(),
679
- command: cmd,
680
- arguments: {
681
- optional: [],
682
- required: [url],
683
- },
684
- }
685
- };
686
- var peg$f54 = function(cmd, url, label) {
687
- // https://github.com/retorquere/zotero-better-bibtex/issues/2617
688
- url.value = url.value.replace(/\\([\#%])/g, '$1')
689
- return {
690
- kind: 'RegularCommand',
691
- loc: location(),
692
- source: text(),
693
- command: cmd,
694
- arguments: {
695
- optional: [],
696
- required: [url, label],
697
- },
698
- }
699
- };
700
- var peg$f55 = function(delim) { return verbatim.set(delim) };
701
- var peg$f56 = function(delim, v) { return verbatim.set('') };
702
- var peg$f57 = function(delim, v) {
703
- return basicTextConversions({
704
- kind: 'Text',
705
- loc: location(),
706
- source: text(),
707
- value: v.join(''),
708
- mode: 'verbatim',
709
- })
710
- };
711
- var peg$f58 = function(cmd) { return verbatimCommands.includes(cmd) && (has_arguments[cmd] === 2) };
712
- var peg$f59 = function(cmd, optional, req1, req2) {
713
- return {
714
- kind: 'RegularCommand',
715
- loc: location(),
716
- source: text(),
717
- command: cmd,
718
- arguments: {
719
- optional: optional,
720
- required: [protect(req1), protect(req2)],
721
- },
722
- }
723
- };
724
- var peg$f60 = function(cmd) { return verbatimCommands.includes(cmd) && (has_arguments[cmd] === 1) };
725
- var peg$f61 = function(cmd, optional, req) {
726
- return {
727
- kind: 'RegularCommand',
728
- loc: location(),
729
- source: text(),
730
- command: cmd,
731
- arguments: {
732
- optional: optional,
733
- required: [protect(req)],
734
- },
735
- }
736
- };
737
- var peg$f62 = function(cmd) { return (has_arguments[cmd] === 2) };
738
- var peg$f63 = function(cmd, optional, req1, req2) {
739
- return {
740
- kind: 'RegularCommand',
741
- loc: location(),
742
- source: text(),
743
- command: cmd,
744
- arguments: {
745
- optional: optional,
746
- required: [req1, req2],
747
- },
748
- }
749
- };
750
- var peg$f64 = function(cmd) { return (has_arguments[cmd] === 1) };
751
- var peg$f65 = function(cmd, optional, req) {
752
- let m
753
- if (req.kind === 'Block') {
754
- switch (cmd) {
755
- case 'textsuperscript':
756
- case 'sp':
757
- req.markup.sup = true
758
- break
759
- case 'textsubscript':
760
- case 'sb':
761
- req.markup.sub = true
762
- break
763
- case 'textsc':
764
- req.markup.smallCaps = true
765
- break
766
- case 'enquote':
767
- case 'mkbibquote':
768
- req.markup.enquote = true
769
- break
770
- case 'textbf':
771
- case 'mkbibbold':
772
- req.markup.bold = true
773
- break
774
- case 'emph':
775
- case 'textit':
776
- case 'mkbibitalic':
777
- case 'mkbibemph':
778
- req.markup.italics = true
779
- break
780
- default:
781
- if (m = cmd.match(/^((sub)*)section$/)) {
782
- req.markup[`h${(m[1].length / 3) + 1}`] = true
783
- }
784
- }
785
- }
786
-
787
- // ignore case stuff on bibcyr
788
- if (cmd === 'bibcyr') delete req.case
789
-
790
- return {
791
- kind: 'RegularCommand',
792
- loc: location(),
793
- source: text(),
794
- command: cmd,
795
- arguments: {
796
- optional: optional,
797
- required: [req],
798
- }
799
- }
800
- };
801
- var peg$f66 = function(cmd, optional) {
802
- return {
803
- kind: 'RegularCommand',
804
- loc: location(),
805
- source: text(),
806
- command: cmd,
807
- arguments: {
808
- optional: optional,
809
- required: [],
810
- }
811
- }
812
- };
813
- var peg$f67 = function(char) { return char !== verbatim.delim };
814
- var peg$f68 = function(char) { return char };
815
- var peg$f69 = function(char) {
816
- return basicTextConversions({
817
- kind: 'Text',
818
- loc: location(),
819
- source: text(),
820
- value: char,
821
- mode: math.on ? 'math' : 'text',
822
- })
823
- };
824
- var peg$f70 = function(v) {
825
- return basicTextConversions({
826
- kind: 'Text', // this isn't really correct but I don't need these right now
827
- loc: location(),
828
- source: text(),
829
- value: v,
830
- mode: math.on ? 'math' : 'text',
831
- })
832
- };
833
- var peg$f71 = function(v) {
834
- return basicTextConversions({
835
- kind: 'Text',
836
- loc: location(),
837
- source: text(),
838
- value: normalizeWhitespace(v),
839
- mode: math.on ? 'math' : 'text',
840
- })
841
- };
842
- var peg$f72 = function(v) { return v };
843
- var peg$f73 = function(ws) { return ws };
844
- var peg$currPos = options.peg$currPos | 0;
845
- var peg$savedPos = peg$currPos;
846
- var peg$posDetailsCache = [{ line: 1, column: 1 }];
847
- var peg$maxFailPos = peg$currPos;
848
- var peg$maxFailExpected = options.peg$maxFailExpected || [];
849
- var peg$silentFails = options.peg$silentFails | 0;
850
-
851
- var peg$result;
852
-
853
- if (options.startRule) {
854
- if (!(options.startRule in peg$startRuleFunctions)) {
855
- throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
856
- }
857
-
858
- peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
859
- }
860
-
861
- function text() {
862
- return input.substring(peg$savedPos, peg$currPos);
863
- }
864
-
865
- function offset() {
866
- return peg$savedPos;
867
- }
868
-
869
- function range() {
870
- return {
871
- source: peg$source,
872
- start: peg$savedPos,
873
- end: peg$currPos
874
- };
875
- }
876
-
877
- function location() {
878
- return peg$computeLocation(peg$savedPos, peg$currPos);
879
- }
880
-
881
- function expected(description, location) {
882
- location = location !== undefined
883
- ? location
884
- : peg$computeLocation(peg$savedPos, peg$currPos);
885
-
886
- throw peg$buildStructuredError(
887
- [peg$otherExpectation(description)],
888
- input.substring(peg$savedPos, peg$currPos),
889
- location
890
- );
891
- }
892
-
893
- function error(message, location) {
894
- location = location !== undefined
895
- ? location
896
- : peg$computeLocation(peg$savedPos, peg$currPos);
897
-
898
- throw peg$buildSimpleError(message, location);
899
- }
900
-
901
- function peg$literalExpectation(text, ignoreCase) {
902
- return { type: "literal", text: text, ignoreCase: ignoreCase };
903
- }
904
-
905
- function peg$classExpectation(parts, inverted, ignoreCase) {
906
- return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
907
- }
908
-
909
- function peg$anyExpectation() {
910
- return { type: "any" };
911
- }
912
-
913
- function peg$endExpectation() {
914
- return { type: "end" };
915
- }
916
-
917
- function peg$otherExpectation(description) {
918
- return { type: "other", description: description };
919
- }
920
-
921
- function peg$computePosDetails(pos) {
922
- var details = peg$posDetailsCache[pos];
923
- var p;
924
-
925
- if (details) {
926
- return details;
927
- } else {
928
- if (pos >= peg$posDetailsCache.length) {
929
- p = peg$posDetailsCache.length - 1;
930
- } else {
931
- p = pos;
932
- while (!peg$posDetailsCache[--p]) {}
933
- }
934
-
935
- details = peg$posDetailsCache[p];
936
- details = {
937
- line: details.line,
938
- column: details.column
939
- };
940
-
941
- while (p < pos) {
942
- if (input.charCodeAt(p) === 10) {
943
- details.line++;
944
- details.column = 1;
945
- } else {
946
- details.column++;
947
- }
948
-
949
- p++;
950
- }
951
-
952
- peg$posDetailsCache[pos] = details;
953
-
954
- return details;
955
- }
956
- }
957
-
958
- function peg$computeLocation(startPos, endPos, offset) {
959
- var startPosDetails = peg$computePosDetails(startPos);
960
- var endPosDetails = peg$computePosDetails(endPos);
961
-
962
- var res = {
963
- source: peg$source,
964
- start: {
965
- offset: startPos,
966
- line: startPosDetails.line,
967
- column: startPosDetails.column
968
- },
969
- end: {
970
- offset: endPos,
971
- line: endPosDetails.line,
972
- column: endPosDetails.column
973
- }
974
- };
975
- if (offset && peg$source && (typeof peg$source.offset === "function")) {
976
- res.start = peg$source.offset(res.start);
977
- res.end = peg$source.offset(res.end);
978
- }
979
- return res;
980
- }
981
-
982
- function peg$fail(expected) {
983
- if (peg$currPos < peg$maxFailPos) { return; }
984
-
985
- if (peg$currPos > peg$maxFailPos) {
986
- peg$maxFailPos = peg$currPos;
987
- peg$maxFailExpected = [];
988
- }
989
-
990
- peg$maxFailExpected.push(expected);
991
- }
992
-
993
- function peg$buildSimpleError(message, location) {
994
- return new peg$SyntaxError(message, null, null, location);
995
- }
996
-
997
- function peg$buildStructuredError(expected, found, location) {
998
- return new peg$SyntaxError(
999
- peg$SyntaxError.buildMessage(expected, found),
1000
- expected,
1001
- found,
1002
- location
1003
- );
1004
- }
1005
-
1006
- function peg$parseBibliography() {
1007
- var s0, s1, s2, s3;
1008
-
1009
- s0 = peg$currPos;
1010
- s1 = peg$parse__();
1011
- s2 = [];
1012
- s3 = peg$parseNode();
1013
- while (s3 !== peg$FAILED) {
1014
- s2.push(s3);
1015
- s3 = peg$parseNode();
1016
- }
1017
- s3 = peg$parse__();
1018
- peg$savedPos = s0;
1019
- s0 = peg$f0(s2);
1020
-
1021
- return s0;
1022
- }
1023
-
1024
- function peg$parseComment() {
1025
- var s0, s1, s2, s3, s4, s5, s6, s7;
1026
-
1027
- s0 = peg$currPos;
1028
- if (input.charCodeAt(peg$currPos) === 64) {
1029
- s1 = peg$c0;
1030
- peg$currPos++;
1031
- } else {
1032
- s1 = peg$FAILED;
1033
- if (peg$silentFails === 0) { peg$fail(peg$e0); }
1034
- }
1035
- if (s1 !== peg$FAILED) {
1036
- s2 = peg$parse__();
1037
- s3 = input.substr(peg$currPos, 7);
1038
- if (s3.toLowerCase() === peg$c1) {
1039
- peg$currPos += 7;
1040
- } else {
1041
- s3 = peg$FAILED;
1042
- if (peg$silentFails === 0) { peg$fail(peg$e1); }
1043
- }
1044
- if (s3 !== peg$FAILED) {
1045
- s4 = peg$parse__h();
1046
- s5 = peg$parseBracedComment();
1047
- if (s5 !== peg$FAILED) {
1048
- peg$savedPos = s0;
1049
- s0 = peg$f1(s5);
1050
- } else {
1051
- peg$currPos = s0;
1052
- s0 = peg$FAILED;
1053
- }
1054
- } else {
1055
- peg$currPos = s0;
1056
- s0 = peg$FAILED;
1057
- }
1058
- } else {
1059
- peg$currPos = s0;
1060
- s0 = peg$FAILED;
1061
- }
1062
- if (s0 === peg$FAILED) {
1063
- s0 = peg$currPos;
1064
- if (input.charCodeAt(peg$currPos) === 64) {
1065
- s1 = peg$c0;
1066
- peg$currPos++;
1067
- } else {
1068
- s1 = peg$FAILED;
1069
- if (peg$silentFails === 0) { peg$fail(peg$e0); }
1070
- }
1071
- if (s1 !== peg$FAILED) {
1072
- s2 = peg$parse__();
1073
- s3 = input.substr(peg$currPos, 7);
1074
- if (s3.toLowerCase() === peg$c1) {
1075
- peg$currPos += 7;
1076
- } else {
1077
- s3 = peg$FAILED;
1078
- if (peg$silentFails === 0) { peg$fail(peg$e1); }
1079
- }
1080
- if (s3 !== peg$FAILED) {
1081
- s4 = peg$parse__h();
1082
- s5 = peg$currPos;
1083
- s6 = [];
1084
- s7 = input.charAt(peg$currPos);
1085
- if (peg$r0.test(s7)) {
1086
- peg$currPos++;
1087
- } else {
1088
- s7 = peg$FAILED;
1089
- if (peg$silentFails === 0) { peg$fail(peg$e2); }
1090
- }
1091
- while (s7 !== peg$FAILED) {
1092
- s6.push(s7);
1093
- s7 = input.charAt(peg$currPos);
1094
- if (peg$r0.test(s7)) {
1095
- peg$currPos++;
1096
- } else {
1097
- s7 = peg$FAILED;
1098
- if (peg$silentFails === 0) { peg$fail(peg$e2); }
1099
- }
1100
- }
1101
- s5 = input.substring(s5, peg$currPos);
1102
- s6 = [];
1103
- s7 = input.charAt(peg$currPos);
1104
- if (peg$r1.test(s7)) {
1105
- peg$currPos++;
1106
- } else {
1107
- s7 = peg$FAILED;
1108
- if (peg$silentFails === 0) { peg$fail(peg$e3); }
1109
- }
1110
- while (s7 !== peg$FAILED) {
1111
- s6.push(s7);
1112
- s7 = input.charAt(peg$currPos);
1113
- if (peg$r1.test(s7)) {
1114
- peg$currPos++;
1115
- } else {
1116
- s7 = peg$FAILED;
1117
- if (peg$silentFails === 0) { peg$fail(peg$e3); }
1118
- }
1119
- }
1120
- peg$savedPos = s0;
1121
- s0 = peg$f2(s5);
1122
- } else {
1123
- peg$currPos = s0;
1124
- s0 = peg$FAILED;
1125
- }
1126
- } else {
1127
- peg$currPos = s0;
1128
- s0 = peg$FAILED;
1129
- }
1130
- if (s0 === peg$FAILED) {
1131
- s0 = peg$currPos;
1132
- s1 = peg$currPos;
1133
- s2 = peg$currPos;
1134
- s3 = input.charAt(peg$currPos);
1135
- if (peg$r2.test(s3)) {
1136
- peg$currPos++;
1137
- } else {
1138
- s3 = peg$FAILED;
1139
- if (peg$silentFails === 0) { peg$fail(peg$e4); }
1140
- }
1141
- if (s3 !== peg$FAILED) {
1142
- s4 = [];
1143
- s5 = input.charAt(peg$currPos);
1144
- if (peg$r0.test(s5)) {
1145
- peg$currPos++;
1146
- } else {
1147
- s5 = peg$FAILED;
1148
- if (peg$silentFails === 0) { peg$fail(peg$e2); }
1149
- }
1150
- while (s5 !== peg$FAILED) {
1151
- s4.push(s5);
1152
- s5 = input.charAt(peg$currPos);
1153
- if (peg$r0.test(s5)) {
1154
- peg$currPos++;
1155
- } else {
1156
- s5 = peg$FAILED;
1157
- if (peg$silentFails === 0) { peg$fail(peg$e2); }
1158
- }
1159
- }
1160
- s3 = [s3, s4];
1161
- s2 = s3;
1162
- } else {
1163
- peg$currPos = s2;
1164
- s2 = peg$FAILED;
1165
- }
1166
- if (s2 !== peg$FAILED) {
1167
- s1 = input.substring(s1, peg$currPos);
1168
- } else {
1169
- s1 = s2;
1170
- }
1171
- if (s1 !== peg$FAILED) {
1172
- s2 = [];
1173
- s3 = input.charAt(peg$currPos);
1174
- if (peg$r1.test(s3)) {
1175
- peg$currPos++;
1176
- } else {
1177
- s3 = peg$FAILED;
1178
- if (peg$silentFails === 0) { peg$fail(peg$e3); }
1179
- }
1180
- while (s3 !== peg$FAILED) {
1181
- s2.push(s3);
1182
- s3 = input.charAt(peg$currPos);
1183
- if (peg$r1.test(s3)) {
1184
- peg$currPos++;
1185
- } else {
1186
- s3 = peg$FAILED;
1187
- if (peg$silentFails === 0) { peg$fail(peg$e3); }
1188
- }
1189
- }
1190
- peg$savedPos = s0;
1191
- s0 = peg$f3(s1);
1192
- } else {
1193
- peg$currPos = s0;
1194
- s0 = peg$FAILED;
1195
- }
1196
- }
1197
- }
1198
-
1199
- return s0;
1200
- }
1201
-
1202
- function peg$parseNode() {
1203
- var s0, s1;
1204
-
1205
- s0 = peg$currPos;
1206
- s1 = peg$parseComment();
1207
- if (s1 === peg$FAILED) {
1208
- s1 = peg$parsePreambleExpression();
1209
- if (s1 === peg$FAILED) {
1210
- s1 = peg$parseStringDeclaration();
1211
- if (s1 === peg$FAILED) {
1212
- s1 = peg$parseEntry();
1213
- }
1214
- }
1215
- }
1216
- if (s1 !== peg$FAILED) {
1217
- peg$savedPos = s0;
1218
- s1 = peg$f4(s1);
1219
- }
1220
- s0 = s1;
1221
-
1222
- return s0;
1223
- }
1224
-
1225
- function peg$parseBracedComment() {
1226
- var s0, s1, s2, s3;
1227
-
1228
- s0 = peg$currPos;
1229
- if (input.charCodeAt(peg$currPos) === 123) {
1230
- s1 = peg$c2;
1231
- peg$currPos++;
1232
- } else {
1233
- s1 = peg$FAILED;
1234
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
1235
- }
1236
- if (s1 !== peg$FAILED) {
1237
- s2 = [];
1238
- s3 = input.charAt(peg$currPos);
1239
- if (peg$r3.test(s3)) {
1240
- peg$currPos++;
1241
- } else {
1242
- s3 = peg$FAILED;
1243
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1244
- }
1245
- if (s3 === peg$FAILED) {
1246
- s3 = peg$parseBracedComment();
1247
- }
1248
- while (s3 !== peg$FAILED) {
1249
- s2.push(s3);
1250
- s3 = input.charAt(peg$currPos);
1251
- if (peg$r3.test(s3)) {
1252
- peg$currPos++;
1253
- } else {
1254
- s3 = peg$FAILED;
1255
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1256
- }
1257
- if (s3 === peg$FAILED) {
1258
- s3 = peg$parseBracedComment();
1259
- }
1260
- }
1261
- if (input.charCodeAt(peg$currPos) === 125) {
1262
- s3 = peg$c3;
1263
- peg$currPos++;
1264
- } else {
1265
- s3 = peg$FAILED;
1266
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
1267
- }
1268
- if (s3 !== peg$FAILED) {
1269
- peg$savedPos = s0;
1270
- s0 = peg$f5(s2);
1271
- } else {
1272
- peg$currPos = s0;
1273
- s0 = peg$FAILED;
1274
- }
1275
- } else {
1276
- peg$currPos = s0;
1277
- s0 = peg$FAILED;
1278
- }
1279
-
1280
- return s0;
1281
- }
1282
-
1283
- function peg$parseEntry() {
1284
- var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
1285
-
1286
- s0 = peg$currPos;
1287
- if (input.charCodeAt(peg$currPos) === 64) {
1288
- s1 = peg$c0;
1289
- peg$currPos++;
1290
- } else {
1291
- s1 = peg$FAILED;
1292
- if (peg$silentFails === 0) { peg$fail(peg$e0); }
1293
- }
1294
- if (s1 !== peg$FAILED) {
1295
- s2 = peg$parse__();
1296
- s3 = peg$currPos;
1297
- s4 = [];
1298
- s5 = input.charAt(peg$currPos);
1299
- if (peg$r4.test(s5)) {
1300
- peg$currPos++;
1301
- } else {
1302
- s5 = peg$FAILED;
1303
- if (peg$silentFails === 0) { peg$fail(peg$e8); }
1304
- }
1305
- if (s5 !== peg$FAILED) {
1306
- while (s5 !== peg$FAILED) {
1307
- s4.push(s5);
1308
- s5 = input.charAt(peg$currPos);
1309
- if (peg$r4.test(s5)) {
1310
- peg$currPos++;
1311
- } else {
1312
- s5 = peg$FAILED;
1313
- if (peg$silentFails === 0) { peg$fail(peg$e8); }
1314
- }
1315
- }
1316
- } else {
1317
- s4 = peg$FAILED;
1318
- }
1319
- if (s4 !== peg$FAILED) {
1320
- s3 = input.substring(s3, peg$currPos);
1321
- } else {
1322
- s3 = s4;
1323
- }
1324
- if (s3 !== peg$FAILED) {
1325
- s4 = peg$parse__();
1326
- s5 = input.charAt(peg$currPos);
1327
- if (peg$r5.test(s5)) {
1328
- peg$currPos++;
1329
- } else {
1330
- s5 = peg$FAILED;
1331
- if (peg$silentFails === 0) { peg$fail(peg$e9); }
1332
- }
1333
- if (s5 !== peg$FAILED) {
1334
- s6 = peg$parse__();
1335
- s7 = peg$parseEntryId();
1336
- if (s7 === peg$FAILED) {
1337
- s7 = null;
1338
- }
1339
- s8 = peg$parse__();
1340
- s9 = [];
1341
- s10 = peg$parseField();
1342
- while (s10 !== peg$FAILED) {
1343
- s9.push(s10);
1344
- s10 = peg$parseField();
1345
- }
1346
- s10 = peg$parse__();
1347
- s11 = input.charAt(peg$currPos);
1348
- if (peg$r6.test(s11)) {
1349
- peg$currPos++;
1350
- } else {
1351
- s11 = peg$FAILED;
1352
- if (peg$silentFails === 0) { peg$fail(peg$e10); }
1353
- }
1354
- if (s11 !== peg$FAILED) {
1355
- s12 = peg$parse__();
1356
- peg$savedPos = s0;
1357
- s0 = peg$f6(s3, s7, s9);
1358
- } else {
1359
- peg$currPos = s0;
1360
- s0 = peg$FAILED;
1361
- }
1362
- } else {
1363
- peg$currPos = s0;
1364
- s0 = peg$FAILED;
1365
- }
1366
- } else {
1367
- peg$currPos = s0;
1368
- s0 = peg$FAILED;
1369
- }
1370
- } else {
1371
- peg$currPos = s0;
1372
- s0 = peg$FAILED;
1373
- }
1374
-
1375
- return s0;
1376
- }
1377
-
1378
- function peg$parsePreambleExpression() {
1379
- var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
1380
-
1381
- s0 = peg$currPos;
1382
- if (input.charCodeAt(peg$currPos) === 64) {
1383
- s1 = peg$c0;
1384
- peg$currPos++;
1385
- } else {
1386
- s1 = peg$FAILED;
1387
- if (peg$silentFails === 0) { peg$fail(peg$e0); }
1388
- }
1389
- if (s1 !== peg$FAILED) {
1390
- s2 = peg$parse__();
1391
- s3 = input.substr(peg$currPos, 8);
1392
- if (s3.toLowerCase() === peg$c4) {
1393
- peg$currPos += 8;
1394
- } else {
1395
- s3 = peg$FAILED;
1396
- if (peg$silentFails === 0) { peg$fail(peg$e11); }
1397
- }
1398
- if (s3 !== peg$FAILED) {
1399
- s4 = peg$parse__();
1400
- s5 = input.charAt(peg$currPos);
1401
- if (peg$r5.test(s5)) {
1402
- peg$currPos++;
1403
- } else {
1404
- s5 = peg$FAILED;
1405
- if (peg$silentFails === 0) { peg$fail(peg$e9); }
1406
- }
1407
- if (s5 !== peg$FAILED) {
1408
- s6 = peg$parse__();
1409
- s7 = [];
1410
- s8 = peg$parseEnvironment();
1411
- if (s8 === peg$FAILED) {
1412
- s8 = peg$parseBlock();
1413
- if (s8 === peg$FAILED) {
1414
- s8 = peg$parseMath();
1415
- if (s8 === peg$FAILED) {
1416
- s8 = peg$parseCommand();
1417
- if (s8 === peg$FAILED) {
1418
- s8 = peg$parseText();
1419
- }
1420
- }
1421
- }
1422
- }
1423
- while (s8 !== peg$FAILED) {
1424
- s7.push(s8);
1425
- s8 = peg$parseEnvironment();
1426
- if (s8 === peg$FAILED) {
1427
- s8 = peg$parseBlock();
1428
- if (s8 === peg$FAILED) {
1429
- s8 = peg$parseMath();
1430
- if (s8 === peg$FAILED) {
1431
- s8 = peg$parseCommand();
1432
- if (s8 === peg$FAILED) {
1433
- s8 = peg$parseText();
1434
- }
1435
- }
1436
- }
1437
- }
1438
- }
1439
- s8 = peg$parse__();
1440
- s9 = input.charAt(peg$currPos);
1441
- if (peg$r6.test(s9)) {
1442
- peg$currPos++;
1443
- } else {
1444
- s9 = peg$FAILED;
1445
- if (peg$silentFails === 0) { peg$fail(peg$e10); }
1446
- }
1447
- if (s9 !== peg$FAILED) {
1448
- s10 = peg$parse__();
1449
- peg$savedPos = s0;
1450
- s0 = peg$f7(s5, s7, s9);
1451
- } else {
1452
- peg$currPos = s0;
1453
- s0 = peg$FAILED;
1454
- }
1455
- } else {
1456
- peg$currPos = s0;
1457
- s0 = peg$FAILED;
1458
- }
1459
- } else {
1460
- peg$currPos = s0;
1461
- s0 = peg$FAILED;
1462
- }
1463
- } else {
1464
- peg$currPos = s0;
1465
- s0 = peg$FAILED;
1466
- }
1467
-
1468
- return s0;
1469
- }
1470
-
1471
- function peg$parseStringDeclaration() {
1472
- var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
1473
-
1474
- s0 = peg$currPos;
1475
- if (input.charCodeAt(peg$currPos) === 64) {
1476
- s1 = peg$c0;
1477
- peg$currPos++;
1478
- } else {
1479
- s1 = peg$FAILED;
1480
- if (peg$silentFails === 0) { peg$fail(peg$e0); }
1481
- }
1482
- if (s1 !== peg$FAILED) {
1483
- s2 = peg$parse__();
1484
- s3 = input.substr(peg$currPos, 6);
1485
- if (s3.toLowerCase() === peg$c5) {
1486
- peg$currPos += 6;
1487
- } else {
1488
- s3 = peg$FAILED;
1489
- if (peg$silentFails === 0) { peg$fail(peg$e12); }
1490
- }
1491
- if (s3 !== peg$FAILED) {
1492
- s4 = peg$parse__();
1493
- s5 = input.charAt(peg$currPos);
1494
- if (peg$r5.test(s5)) {
1495
- peg$currPos++;
1496
- } else {
1497
- s5 = peg$FAILED;
1498
- if (peg$silentFails === 0) { peg$fail(peg$e9); }
1499
- }
1500
- if (s5 !== peg$FAILED) {
1501
- s6 = peg$parse__();
1502
- s7 = peg$parseVariableName();
1503
- if (s7 !== peg$FAILED) {
1504
- s8 = peg$parseFieldSeparator();
1505
- if (s8 !== peg$FAILED) {
1506
- s9 = [];
1507
- s10 = peg$parseRegularValue();
1508
- if (s10 !== peg$FAILED) {
1509
- while (s10 !== peg$FAILED) {
1510
- s9.push(s10);
1511
- s10 = peg$parseRegularValue();
1512
- }
1513
- } else {
1514
- s9 = peg$FAILED;
1515
- }
1516
- if (s9 !== peg$FAILED) {
1517
- s10 = peg$parse__();
1518
- s11 = input.charAt(peg$currPos);
1519
- if (peg$r6.test(s11)) {
1520
- peg$currPos++;
1521
- } else {
1522
- s11 = peg$FAILED;
1523
- if (peg$silentFails === 0) { peg$fail(peg$e10); }
1524
- }
1525
- if (s11 !== peg$FAILED) {
1526
- s12 = peg$parse__();
1527
- peg$savedPos = s0;
1528
- s0 = peg$f8(s7, s9);
1529
- } else {
1530
- peg$currPos = s0;
1531
- s0 = peg$FAILED;
1532
- }
1533
- } else {
1534
- peg$currPos = s0;
1535
- s0 = peg$FAILED;
1536
- }
1537
- } else {
1538
- peg$currPos = s0;
1539
- s0 = peg$FAILED;
1540
- }
1541
- } else {
1542
- peg$currPos = s0;
1543
- s0 = peg$FAILED;
1544
- }
1545
- } else {
1546
- peg$currPos = s0;
1547
- s0 = peg$FAILED;
1548
- }
1549
- } else {
1550
- peg$currPos = s0;
1551
- s0 = peg$FAILED;
1552
- }
1553
- } else {
1554
- peg$currPos = s0;
1555
- s0 = peg$FAILED;
1556
- }
1557
-
1558
- return s0;
1559
- }
1560
-
1561
- function peg$parseEntryId() {
1562
- var s0, s1, s2, s3, s4;
1563
-
1564
- s0 = peg$currPos;
1565
- s1 = peg$parse__();
1566
- s2 = peg$currPos;
1567
- s3 = [];
1568
- s4 = input.charAt(peg$currPos);
1569
- if (peg$r7.test(s4)) {
1570
- peg$currPos++;
1571
- } else {
1572
- s4 = peg$FAILED;
1573
- if (peg$silentFails === 0) { peg$fail(peg$e13); }
1574
- }
1575
- while (s4 !== peg$FAILED) {
1576
- s3.push(s4);
1577
- s4 = input.charAt(peg$currPos);
1578
- if (peg$r7.test(s4)) {
1579
- peg$currPos++;
1580
- } else {
1581
- s4 = peg$FAILED;
1582
- if (peg$silentFails === 0) { peg$fail(peg$e13); }
1583
- }
1584
- }
1585
- s2 = input.substring(s2, peg$currPos);
1586
- s3 = peg$parse__();
1587
- if (input.charCodeAt(peg$currPos) === 44) {
1588
- s4 = peg$c6;
1589
- peg$currPos++;
1590
- } else {
1591
- s4 = peg$FAILED;
1592
- if (peg$silentFails === 0) { peg$fail(peg$e14); }
1593
- }
1594
- if (s4 !== peg$FAILED) {
1595
- peg$savedPos = s0;
1596
- s0 = peg$f9(s2);
1597
- } else {
1598
- peg$currPos = s0;
1599
- s0 = peg$FAILED;
1600
- }
1601
-
1602
- return s0;
1603
- }
1604
-
1605
- function peg$parseField() {
1606
- var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
1607
-
1608
- s0 = peg$currPos;
1609
- s1 = peg$parseFieldName();
1610
- if (s1 !== peg$FAILED) {
1611
- peg$savedPos = peg$currPos;
1612
- s2 = peg$f10(s1);
1613
- if (s2) {
1614
- s2 = undefined;
1615
- } else {
1616
- s2 = peg$FAILED;
1617
- }
1618
- if (s2 !== peg$FAILED) {
1619
- s3 = peg$parseFieldSeparator();
1620
- if (s3 !== peg$FAILED) {
1621
- if (input.charCodeAt(peg$currPos) === 123) {
1622
- s4 = peg$c2;
1623
- peg$currPos++;
1624
- } else {
1625
- s4 = peg$FAILED;
1626
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
1627
- }
1628
- if (s4 !== peg$FAILED) {
1629
- s5 = peg$currPos;
1630
- peg$silentFails++;
1631
- if (input.charCodeAt(peg$currPos) === 123) {
1632
- s6 = peg$c2;
1633
- peg$currPos++;
1634
- } else {
1635
- s6 = peg$FAILED;
1636
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
1637
- }
1638
- peg$silentFails--;
1639
- if (s6 !== peg$FAILED) {
1640
- peg$currPos = s5;
1641
- s5 = undefined;
1642
- } else {
1643
- s5 = peg$FAILED;
1644
- }
1645
- if (s5 !== peg$FAILED) {
1646
- s6 = peg$parseVerbatimFieldValue();
1647
- if (s6 !== peg$FAILED) {
1648
- if (input.charCodeAt(peg$currPos) === 125) {
1649
- s7 = peg$c3;
1650
- peg$currPos++;
1651
- } else {
1652
- s7 = peg$FAILED;
1653
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
1654
- }
1655
- if (s7 !== peg$FAILED) {
1656
- s8 = [];
1657
- s9 = peg$parseFieldTerminator();
1658
- while (s9 !== peg$FAILED) {
1659
- s8.push(s9);
1660
- s9 = peg$parseFieldTerminator();
1661
- }
1662
- peg$savedPos = s0;
1663
- s0 = peg$f11(s1, s6);
1664
- } else {
1665
- peg$currPos = s0;
1666
- s0 = peg$FAILED;
1667
- }
1668
- } else {
1669
- peg$currPos = s0;
1670
- s0 = peg$FAILED;
1671
- }
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
- } else {
1685
- peg$currPos = s0;
1686
- s0 = peg$FAILED;
1687
- }
1688
- } else {
1689
- peg$currPos = s0;
1690
- s0 = peg$FAILED;
1691
- }
1692
- if (s0 === peg$FAILED) {
1693
- s0 = peg$currPos;
1694
- s1 = peg$parseFieldName();
1695
- if (s1 !== peg$FAILED) {
1696
- peg$savedPos = peg$currPos;
1697
- s2 = peg$f12(s1);
1698
- if (s2) {
1699
- s2 = undefined;
1700
- } else {
1701
- s2 = peg$FAILED;
1702
- }
1703
- if (s2 !== peg$FAILED) {
1704
- s3 = peg$parseFieldSeparator();
1705
- if (s3 !== peg$FAILED) {
1706
- s4 = peg$parseVerbatimFieldValue();
1707
- if (s4 !== peg$FAILED) {
1708
- s5 = [];
1709
- s6 = peg$parseFieldTerminator();
1710
- while (s6 !== peg$FAILED) {
1711
- s5.push(s6);
1712
- s6 = peg$parseFieldTerminator();
1713
- }
1714
- peg$savedPos = s0;
1715
- s0 = peg$f13(s1, s4);
1716
- } else {
1717
- peg$currPos = s0;
1718
- s0 = peg$FAILED;
1719
- }
1720
- } else {
1721
- peg$currPos = s0;
1722
- s0 = peg$FAILED;
1723
- }
1724
- } else {
1725
- peg$currPos = s0;
1726
- s0 = peg$FAILED;
1727
- }
1728
- } else {
1729
- peg$currPos = s0;
1730
- s0 = peg$FAILED;
1731
- }
1732
- if (s0 === peg$FAILED) {
1733
- s0 = peg$currPos;
1734
- s1 = peg$parseFieldName();
1735
- if (s1 !== peg$FAILED) {
1736
- s2 = peg$parseFieldSeparator();
1737
- if (s2 !== peg$FAILED) {
1738
- s3 = peg$parseFieldValue();
1739
- if (s3 !== peg$FAILED) {
1740
- s4 = [];
1741
- s5 = peg$parseFieldTerminator();
1742
- while (s5 !== peg$FAILED) {
1743
- s4.push(s5);
1744
- s5 = peg$parseFieldTerminator();
1745
- }
1746
- peg$savedPos = s0;
1747
- s0 = peg$f14(s1, s3);
1748
- } else {
1749
- peg$currPos = s0;
1750
- s0 = peg$FAILED;
1751
- }
1752
- } else {
1753
- peg$currPos = s0;
1754
- s0 = peg$FAILED;
1755
- }
1756
- } else {
1757
- peg$currPos = s0;
1758
- s0 = peg$FAILED;
1759
- }
1760
- }
1761
- }
1762
-
1763
- return s0;
1764
- }
1765
-
1766
- function peg$parseFieldName() {
1767
- var s0, s1, s2, s3, s4;
1768
-
1769
- s0 = peg$currPos;
1770
- s1 = peg$parse__();
1771
- s2 = peg$currPos;
1772
- s3 = [];
1773
- s4 = input.charAt(peg$currPos);
1774
- if (peg$r8.test(s4)) {
1775
- peg$currPos++;
1776
- } else {
1777
- s4 = peg$FAILED;
1778
- if (peg$silentFails === 0) { peg$fail(peg$e15); }
1779
- }
1780
- if (s4 !== peg$FAILED) {
1781
- while (s4 !== peg$FAILED) {
1782
- s3.push(s4);
1783
- s4 = input.charAt(peg$currPos);
1784
- if (peg$r8.test(s4)) {
1785
- peg$currPos++;
1786
- } else {
1787
- s4 = peg$FAILED;
1788
- if (peg$silentFails === 0) { peg$fail(peg$e15); }
1789
- }
1790
- }
1791
- } else {
1792
- s3 = peg$FAILED;
1793
- }
1794
- if (s3 !== peg$FAILED) {
1795
- s2 = input.substring(s2, peg$currPos);
1796
- } else {
1797
- s2 = s3;
1798
- }
1799
- if (s2 !== peg$FAILED) {
1800
- peg$savedPos = s0;
1801
- s0 = peg$f15(s2);
1802
- } else {
1803
- peg$currPos = s0;
1804
- s0 = peg$FAILED;
1805
- }
1806
-
1807
- return s0;
1808
- }
1809
-
1810
- function peg$parseVerbatimFieldValue() {
1811
- var s0, s1, s2, s3;
1812
-
1813
- s0 = peg$currPos;
1814
- if (input.charCodeAt(peg$currPos) === 34) {
1815
- s1 = peg$c7;
1816
- peg$currPos++;
1817
- } else {
1818
- s1 = peg$FAILED;
1819
- if (peg$silentFails === 0) { peg$fail(peg$e16); }
1820
- }
1821
- if (s1 !== peg$FAILED) {
1822
- s2 = peg$parseVerbatimString();
1823
- if (s2 === peg$FAILED) {
1824
- s2 = null;
1825
- }
1826
- if (input.charCodeAt(peg$currPos) === 34) {
1827
- s3 = peg$c7;
1828
- peg$currPos++;
1829
- } else {
1830
- s3 = peg$FAILED;
1831
- if (peg$silentFails === 0) { peg$fail(peg$e16); }
1832
- }
1833
- if (s3 !== peg$FAILED) {
1834
- peg$savedPos = s0;
1835
- s0 = peg$f16(s2);
1836
- } else {
1837
- peg$currPos = s0;
1838
- s0 = peg$FAILED;
1839
- }
1840
- } else {
1841
- peg$currPos = s0;
1842
- s0 = peg$FAILED;
1843
- }
1844
- if (s0 === peg$FAILED) {
1845
- s0 = peg$currPos;
1846
- if (input.charCodeAt(peg$currPos) === 123) {
1847
- s1 = peg$c2;
1848
- peg$currPos++;
1849
- } else {
1850
- s1 = peg$FAILED;
1851
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
1852
- }
1853
- if (s1 !== peg$FAILED) {
1854
- s2 = [];
1855
- s3 = peg$parseVerbatimText();
1856
- while (s3 !== peg$FAILED) {
1857
- s2.push(s3);
1858
- s3 = peg$parseVerbatimText();
1859
- }
1860
- if (input.charCodeAt(peg$currPos) === 125) {
1861
- s3 = peg$c3;
1862
- peg$currPos++;
1863
- } else {
1864
- s3 = peg$FAILED;
1865
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
1866
- }
1867
- if (s3 !== peg$FAILED) {
1868
- peg$savedPos = s0;
1869
- s0 = peg$f17(s2);
1870
- } else {
1871
- peg$currPos = s0;
1872
- s0 = peg$FAILED;
1873
- }
1874
- } else {
1875
- peg$currPos = s0;
1876
- s0 = peg$FAILED;
1877
- }
1878
- }
1879
-
1880
- return s0;
1881
- }
1882
-
1883
- function peg$parseVerbatimText() {
1884
- var s0, s1, s2, s3, s4;
1885
-
1886
- s0 = peg$currPos;
1887
- s1 = peg$currPos;
1888
- s2 = [];
1889
- s3 = input.charAt(peg$currPos);
1890
- if (peg$r3.test(s3)) {
1891
- peg$currPos++;
1892
- } else {
1893
- s3 = peg$FAILED;
1894
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1895
- }
1896
- if (s3 !== peg$FAILED) {
1897
- while (s3 !== peg$FAILED) {
1898
- s2.push(s3);
1899
- s3 = input.charAt(peg$currPos);
1900
- if (peg$r3.test(s3)) {
1901
- peg$currPos++;
1902
- } else {
1903
- s3 = peg$FAILED;
1904
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1905
- }
1906
- }
1907
- } else {
1908
- s2 = peg$FAILED;
1909
- }
1910
- if (s2 !== peg$FAILED) {
1911
- s1 = input.substring(s1, peg$currPos);
1912
- } else {
1913
- s1 = s2;
1914
- }
1915
- if (s1 !== peg$FAILED) {
1916
- peg$savedPos = s0;
1917
- s1 = peg$f18(s1);
1918
- }
1919
- s0 = s1;
1920
- if (s0 === peg$FAILED) {
1921
- s0 = peg$currPos;
1922
- if (input.charCodeAt(peg$currPos) === 123) {
1923
- s1 = peg$c2;
1924
- peg$currPos++;
1925
- } else {
1926
- s1 = peg$FAILED;
1927
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
1928
- }
1929
- if (s1 !== peg$FAILED) {
1930
- s2 = peg$currPos;
1931
- s3 = [];
1932
- s4 = peg$parseVerbatimText();
1933
- while (s4 !== peg$FAILED) {
1934
- s3.push(s4);
1935
- s4 = peg$parseVerbatimText();
1936
- }
1937
- s2 = input.substring(s2, peg$currPos);
1938
- if (input.charCodeAt(peg$currPos) === 125) {
1939
- s3 = peg$c3;
1940
- peg$currPos++;
1941
- } else {
1942
- s3 = peg$FAILED;
1943
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
1944
- }
1945
- if (s3 !== peg$FAILED) {
1946
- peg$savedPos = s0;
1947
- s0 = peg$f19(s2);
1948
- } else {
1949
- peg$currPos = s0;
1950
- s0 = peg$FAILED;
1951
- }
1952
- } else {
1953
- peg$currPos = s0;
1954
- s0 = peg$FAILED;
1955
- }
1956
- }
1957
-
1958
- return s0;
1959
- }
1960
-
1961
- function peg$parseVerbatimString() {
1962
- var s0, s1, s2, s3, s4;
1963
-
1964
- s0 = peg$currPos;
1965
- s1 = peg$currPos;
1966
- s2 = [];
1967
- s3 = input.charAt(peg$currPos);
1968
- if (peg$r9.test(s3)) {
1969
- peg$currPos++;
1970
- } else {
1971
- s3 = peg$FAILED;
1972
- if (peg$silentFails === 0) { peg$fail(peg$e17); }
1973
- }
1974
- if (s3 !== peg$FAILED) {
1975
- while (s3 !== peg$FAILED) {
1976
- s2.push(s3);
1977
- s3 = input.charAt(peg$currPos);
1978
- if (peg$r9.test(s3)) {
1979
- peg$currPos++;
1980
- } else {
1981
- s3 = peg$FAILED;
1982
- if (peg$silentFails === 0) { peg$fail(peg$e17); }
1983
- }
1984
- }
1985
- } else {
1986
- s2 = peg$FAILED;
1987
- }
1988
- if (s2 !== peg$FAILED) {
1989
- s1 = input.substring(s1, peg$currPos);
1990
- } else {
1991
- s1 = s2;
1992
- }
1993
- if (s1 !== peg$FAILED) {
1994
- peg$savedPos = s0;
1995
- s1 = peg$f20(s1);
1996
- }
1997
- s0 = s1;
1998
- if (s0 === peg$FAILED) {
1999
- s0 = peg$currPos;
2000
- if (input.charCodeAt(peg$currPos) === 123) {
2001
- s1 = peg$c2;
2002
- peg$currPos++;
2003
- } else {
2004
- s1 = peg$FAILED;
2005
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
2006
- }
2007
- if (s1 !== peg$FAILED) {
2008
- s2 = peg$currPos;
2009
- s3 = [];
2010
- s4 = peg$parseVerbatimString();
2011
- while (s4 !== peg$FAILED) {
2012
- s3.push(s4);
2013
- s4 = peg$parseVerbatimString();
2014
- }
2015
- s2 = input.substring(s2, peg$currPos);
2016
- if (input.charCodeAt(peg$currPos) === 125) {
2017
- s3 = peg$c3;
2018
- peg$currPos++;
2019
- } else {
2020
- s3 = peg$FAILED;
2021
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
2022
- }
2023
- if (s3 !== peg$FAILED) {
2024
- peg$savedPos = s0;
2025
- s0 = peg$f21(s2);
2026
- } else {
2027
- peg$currPos = s0;
2028
- s0 = peg$FAILED;
2029
- }
2030
- } else {
2031
- peg$currPos = s0;
2032
- s0 = peg$FAILED;
2033
- }
2034
- }
2035
-
2036
- return s0;
2037
- }
2038
-
2039
- function peg$parseFieldValue() {
2040
- var s0, s1, s2, s3;
2041
-
2042
- s0 = peg$parseNumber();
2043
- if (s0 === peg$FAILED) {
2044
- s0 = peg$currPos;
2045
- peg$savedPos = peg$currPos;
2046
- s1 = peg$f22();
2047
- if (s1) {
2048
- s1 = undefined;
2049
- } else {
2050
- s1 = peg$FAILED;
2051
- }
2052
- if (s1 !== peg$FAILED) {
2053
- s2 = [];
2054
- s3 = peg$parseRegularValue();
2055
- if (s3 === peg$FAILED) {
2056
- s3 = peg$parseStringValue();
2057
- }
2058
- while (s3 !== peg$FAILED) {
2059
- s2.push(s3);
2060
- s3 = peg$parseRegularValue();
2061
- if (s3 === peg$FAILED) {
2062
- s3 = peg$parseStringValue();
2063
- }
2064
- }
2065
- peg$savedPos = s0;
2066
- s0 = peg$f23(s2);
2067
- } else {
2068
- peg$currPos = s0;
2069
- s0 = peg$FAILED;
2070
- }
2071
- }
2072
-
2073
- return s0;
2074
- }
2075
-
2076
- function peg$parseRegularValue() {
2077
- var s0, s1, s2, s3, s4;
2078
-
2079
- s0 = peg$currPos;
2080
- if (input.charCodeAt(peg$currPos) === 34) {
2081
- s1 = peg$c7;
2082
- peg$currPos++;
2083
- } else {
2084
- s1 = peg$FAILED;
2085
- if (peg$silentFails === 0) { peg$fail(peg$e16); }
2086
- }
2087
- if (s1 !== peg$FAILED) {
2088
- s2 = [];
2089
- s3 = peg$parseEnvironment();
2090
- if (s3 === peg$FAILED) {
2091
- s3 = peg$parseBlock();
2092
- if (s3 === peg$FAILED) {
2093
- s3 = peg$parseMath();
2094
- if (s3 === peg$FAILED) {
2095
- s3 = peg$parseCommand();
2096
- if (s3 === peg$FAILED) {
2097
- s3 = peg$parseTextNoQuotes();
2098
- }
2099
- }
2100
- }
2101
- }
2102
- while (s3 !== peg$FAILED) {
2103
- s2.push(s3);
2104
- s3 = peg$parseEnvironment();
2105
- if (s3 === peg$FAILED) {
2106
- s3 = peg$parseBlock();
2107
- if (s3 === peg$FAILED) {
2108
- s3 = peg$parseMath();
2109
- if (s3 === peg$FAILED) {
2110
- s3 = peg$parseCommand();
2111
- if (s3 === peg$FAILED) {
2112
- s3 = peg$parseTextNoQuotes();
2113
- }
2114
- }
2115
- }
2116
- }
2117
- }
2118
- if (input.charCodeAt(peg$currPos) === 34) {
2119
- s3 = peg$c7;
2120
- peg$currPos++;
2121
- } else {
2122
- s3 = peg$FAILED;
2123
- if (peg$silentFails === 0) { peg$fail(peg$e16); }
2124
- }
2125
- if (s3 !== peg$FAILED) {
2126
- s4 = peg$parseConcat();
2127
- if (s4 === peg$FAILED) {
2128
- s4 = null;
2129
- }
2130
- peg$savedPos = s0;
2131
- s0 = peg$f24(s2);
2132
- } else {
2133
- peg$currPos = s0;
2134
- s0 = peg$FAILED;
2135
- }
2136
- } else {
2137
- peg$currPos = s0;
2138
- s0 = peg$FAILED;
2139
- }
2140
- if (s0 === peg$FAILED) {
2141
- s0 = peg$currPos;
2142
- if (input.charCodeAt(peg$currPos) === 123) {
2143
- s1 = peg$c2;
2144
- peg$currPos++;
2145
- } else {
2146
- s1 = peg$FAILED;
2147
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
2148
- }
2149
- if (s1 !== peg$FAILED) {
2150
- s2 = [];
2151
- s3 = peg$parseEnvironment();
2152
- if (s3 === peg$FAILED) {
2153
- s3 = peg$parseBlock();
2154
- if (s3 === peg$FAILED) {
2155
- s3 = peg$parseMath();
2156
- if (s3 === peg$FAILED) {
2157
- s3 = peg$parseCommand();
2158
- if (s3 === peg$FAILED) {
2159
- s3 = peg$parseText();
2160
- }
2161
- }
2162
- }
2163
- }
2164
- while (s3 !== peg$FAILED) {
2165
- s2.push(s3);
2166
- s3 = peg$parseEnvironment();
2167
- if (s3 === peg$FAILED) {
2168
- s3 = peg$parseBlock();
2169
- if (s3 === peg$FAILED) {
2170
- s3 = peg$parseMath();
2171
- if (s3 === peg$FAILED) {
2172
- s3 = peg$parseCommand();
2173
- if (s3 === peg$FAILED) {
2174
- s3 = peg$parseText();
2175
- }
2176
- }
2177
- }
2178
- }
2179
- }
2180
- if (input.charCodeAt(peg$currPos) === 125) {
2181
- s3 = peg$c3;
2182
- peg$currPos++;
2183
- } else {
2184
- s3 = peg$FAILED;
2185
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
2186
- }
2187
- if (s3 !== peg$FAILED) {
2188
- s4 = peg$parseConcat();
2189
- if (s4 === peg$FAILED) {
2190
- s4 = null;
2191
- }
2192
- peg$savedPos = s0;
2193
- s0 = peg$f25(s2);
2194
- } else {
2195
- peg$currPos = s0;
2196
- s0 = peg$FAILED;
2197
- }
2198
- } else {
2199
- peg$currPos = s0;
2200
- s0 = peg$FAILED;
2201
- }
2202
- if (s0 === peg$FAILED) {
2203
- s0 = peg$currPos;
2204
- s1 = peg$parseStringReference();
2205
- if (s1 !== peg$FAILED) {
2206
- s2 = peg$parseConcat();
2207
- if (s2 === peg$FAILED) {
2208
- s2 = null;
2209
- }
2210
- peg$savedPos = s0;
2211
- s0 = peg$f26(s1);
2212
- } else {
2213
- peg$currPos = s0;
2214
- s0 = peg$FAILED;
2215
- }
2216
- }
2217
- }
2218
-
2219
- return s0;
2220
- }
2221
-
2222
- function peg$parseStringValue() {
2223
- var s0, s1, s2;
2224
-
2225
- s0 = peg$currPos;
2226
- s1 = peg$parseStringReference();
2227
- if (s1 !== peg$FAILED) {
2228
- s2 = peg$parseConcat();
2229
- if (s2 === peg$FAILED) {
2230
- s2 = null;
2231
- }
2232
- peg$savedPos = s0;
2233
- s0 = peg$f27(s1);
2234
- } else {
2235
- peg$currPos = s0;
2236
- s0 = peg$FAILED;
2237
- }
2238
-
2239
- return s0;
2240
- }
2241
-
2242
- function peg$parseText() {
2243
- var s0, s1, s2, s3;
2244
-
2245
- s0 = peg$currPos;
2246
- s1 = peg$currPos;
2247
- s2 = [];
2248
- s3 = input.charAt(peg$currPos);
2249
- if (peg$r10.test(s3)) {
2250
- peg$currPos++;
2251
- } else {
2252
- s3 = peg$FAILED;
2253
- if (peg$silentFails === 0) { peg$fail(peg$e18); }
2254
- }
2255
- if (s3 !== peg$FAILED) {
2256
- while (s3 !== peg$FAILED) {
2257
- s2.push(s3);
2258
- s3 = input.charAt(peg$currPos);
2259
- if (peg$r10.test(s3)) {
2260
- peg$currPos++;
2261
- } else {
2262
- s3 = peg$FAILED;
2263
- if (peg$silentFails === 0) { peg$fail(peg$e18); }
2264
- }
2265
- }
2266
- } else {
2267
- s2 = peg$FAILED;
2268
- }
2269
- if (s2 !== peg$FAILED) {
2270
- s1 = input.substring(s1, peg$currPos);
2271
- } else {
2272
- s1 = s2;
2273
- }
2274
- if (s1 !== peg$FAILED) {
2275
- peg$savedPos = s0;
2276
- s1 = peg$f28(s1);
2277
- }
2278
- s0 = s1;
2279
-
2280
- return s0;
2281
- }
2282
-
2283
- function peg$parseTextNoQuotes() {
2284
- var s0, s1, s2, s3;
2285
-
2286
- s0 = peg$currPos;
2287
- s1 = peg$currPos;
2288
- s2 = [];
2289
- s3 = input.charAt(peg$currPos);
2290
- if (peg$r11.test(s3)) {
2291
- peg$currPos++;
2292
- } else {
2293
- s3 = peg$FAILED;
2294
- if (peg$silentFails === 0) { peg$fail(peg$e19); }
2295
- }
2296
- if (s3 !== peg$FAILED) {
2297
- while (s3 !== peg$FAILED) {
2298
- s2.push(s3);
2299
- s3 = input.charAt(peg$currPos);
2300
- if (peg$r11.test(s3)) {
2301
- peg$currPos++;
2302
- } else {
2303
- s3 = peg$FAILED;
2304
- if (peg$silentFails === 0) { peg$fail(peg$e19); }
2305
- }
2306
- }
2307
- } else {
2308
- s2 = peg$FAILED;
2309
- }
2310
- if (s2 !== peg$FAILED) {
2311
- s1 = input.substring(s1, peg$currPos);
2312
- } else {
2313
- s1 = s2;
2314
- }
2315
- if (s1 !== peg$FAILED) {
2316
- peg$savedPos = s0;
2317
- s1 = peg$f29(s1);
2318
- }
2319
- s0 = s1;
2320
-
2321
- return s0;
2322
- }
2323
-
2324
- function peg$parseNumber() {
2325
- var s0, s1, s2, s3;
2326
-
2327
- s0 = peg$currPos;
2328
- s1 = peg$currPos;
2329
- s2 = [];
2330
- s3 = input.charAt(peg$currPos);
2331
- if (peg$r12.test(s3)) {
2332
- peg$currPos++;
2333
- } else {
2334
- s3 = peg$FAILED;
2335
- if (peg$silentFails === 0) { peg$fail(peg$e20); }
2336
- }
2337
- if (s3 !== peg$FAILED) {
2338
- while (s3 !== peg$FAILED) {
2339
- s2.push(s3);
2340
- s3 = input.charAt(peg$currPos);
2341
- if (peg$r12.test(s3)) {
2342
- peg$currPos++;
2343
- } else {
2344
- s3 = peg$FAILED;
2345
- if (peg$silentFails === 0) { peg$fail(peg$e20); }
2346
- }
2347
- }
2348
- } else {
2349
- s2 = peg$FAILED;
2350
- }
2351
- if (s2 !== peg$FAILED) {
2352
- s1 = input.substring(s1, peg$currPos);
2353
- } else {
2354
- s1 = s2;
2355
- }
2356
- if (s1 !== peg$FAILED) {
2357
- peg$savedPos = s0;
2358
- s1 = peg$f30(s1);
2359
- }
2360
- s0 = s1;
2361
-
2362
- return s0;
2363
- }
2364
-
2365
- function peg$parseStringReference() {
2366
- var s0, s1;
2367
-
2368
- s0 = peg$currPos;
2369
- s1 = peg$parseVariableName();
2370
- if (s1 !== peg$FAILED) {
2371
- peg$savedPos = s0;
2372
- s1 = peg$f31(s1);
2373
- }
2374
- s0 = s1;
2375
-
2376
- return s0;
2377
- }
2378
-
2379
- function peg$parseEnvironment() {
2380
- var s0, s1, s2, s3, s4, s5, s6, s7, s8;
2381
-
2382
- s0 = peg$currPos;
2383
- if (input.substr(peg$currPos, 7) === peg$c8) {
2384
- s1 = peg$c8;
2385
- peg$currPos += 7;
2386
- } else {
2387
- s1 = peg$FAILED;
2388
- if (peg$silentFails === 0) { peg$fail(peg$e21); }
2389
- }
2390
- if (s1 !== peg$FAILED) {
2391
- s2 = peg$currPos;
2392
- s3 = [];
2393
- s4 = input.charAt(peg$currPos);
2394
- if (peg$r13.test(s4)) {
2395
- peg$currPos++;
2396
- } else {
2397
- s4 = peg$FAILED;
2398
- if (peg$silentFails === 0) { peg$fail(peg$e22); }
2399
- }
2400
- if (s4 !== peg$FAILED) {
2401
- while (s4 !== peg$FAILED) {
2402
- s3.push(s4);
2403
- s4 = input.charAt(peg$currPos);
2404
- if (peg$r13.test(s4)) {
2405
- peg$currPos++;
2406
- } else {
2407
- s4 = peg$FAILED;
2408
- if (peg$silentFails === 0) { peg$fail(peg$e22); }
2409
- }
2410
- }
2411
- } else {
2412
- s3 = peg$FAILED;
2413
- }
2414
- if (s3 !== peg$FAILED) {
2415
- s2 = input.substring(s2, peg$currPos);
2416
- } else {
2417
- s2 = s3;
2418
- }
2419
- if (s2 !== peg$FAILED) {
2420
- if (input.charCodeAt(peg$currPos) === 125) {
2421
- s3 = peg$c3;
2422
- peg$currPos++;
2423
- } else {
2424
- s3 = peg$FAILED;
2425
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
2426
- }
2427
- if (s3 !== peg$FAILED) {
2428
- s4 = [];
2429
- s5 = peg$parseEnvironment();
2430
- if (s5 === peg$FAILED) {
2431
- s5 = peg$parseBlock();
2432
- if (s5 === peg$FAILED) {
2433
- s5 = peg$parseCommand();
2434
- if (s5 === peg$FAILED) {
2435
- s5 = peg$parseMath();
2436
- if (s5 === peg$FAILED) {
2437
- s5 = peg$parseText();
2438
- }
2439
- }
2440
- }
2441
- }
2442
- while (s5 !== peg$FAILED) {
2443
- s4.push(s5);
2444
- s5 = peg$parseEnvironment();
2445
- if (s5 === peg$FAILED) {
2446
- s5 = peg$parseBlock();
2447
- if (s5 === peg$FAILED) {
2448
- s5 = peg$parseCommand();
2449
- if (s5 === peg$FAILED) {
2450
- s5 = peg$parseMath();
2451
- if (s5 === peg$FAILED) {
2452
- s5 = peg$parseText();
2453
- }
2454
- }
2455
- }
2456
- }
2457
- }
2458
- if (input.substr(peg$currPos, 5) === peg$c9) {
2459
- s5 = peg$c9;
2460
- peg$currPos += 5;
2461
- } else {
2462
- s5 = peg$FAILED;
2463
- if (peg$silentFails === 0) { peg$fail(peg$e23); }
2464
- }
2465
- if (s5 !== peg$FAILED) {
2466
- s6 = peg$currPos;
2467
- s7 = [];
2468
- s8 = input.charAt(peg$currPos);
2469
- if (peg$r13.test(s8)) {
2470
- peg$currPos++;
2471
- } else {
2472
- s8 = peg$FAILED;
2473
- if (peg$silentFails === 0) { peg$fail(peg$e22); }
2474
- }
2475
- if (s8 !== peg$FAILED) {
2476
- while (s8 !== peg$FAILED) {
2477
- s7.push(s8);
2478
- s8 = input.charAt(peg$currPos);
2479
- if (peg$r13.test(s8)) {
2480
- peg$currPos++;
2481
- } else {
2482
- s8 = peg$FAILED;
2483
- if (peg$silentFails === 0) { peg$fail(peg$e22); }
2484
- }
2485
- }
2486
- } else {
2487
- s7 = peg$FAILED;
2488
- }
2489
- if (s7 !== peg$FAILED) {
2490
- s6 = input.substring(s6, peg$currPos);
2491
- } else {
2492
- s6 = s7;
2493
- }
2494
- if (s6 !== peg$FAILED) {
2495
- if (input.charCodeAt(peg$currPos) === 125) {
2496
- s7 = peg$c3;
2497
- peg$currPos++;
2498
- } else {
2499
- s7 = peg$FAILED;
2500
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
2501
- }
2502
- if (s7 !== peg$FAILED) {
2503
- peg$savedPos = peg$currPos;
2504
- s8 = peg$f32(s2, s4, s6);
2505
- if (s8) {
2506
- s8 = undefined;
2507
- } else {
2508
- s8 = peg$FAILED;
2509
- }
2510
- if (s8 !== peg$FAILED) {
2511
- peg$savedPos = s0;
2512
- s0 = peg$f33(s2, s4, s6);
2513
- } else {
2514
- peg$currPos = s0;
2515
- s0 = peg$FAILED;
2516
- }
2517
- } else {
2518
- peg$currPos = s0;
2519
- s0 = peg$FAILED;
2520
- }
2521
- } else {
2522
- peg$currPos = s0;
2523
- s0 = peg$FAILED;
2524
- }
2525
- } else {
2526
- peg$currPos = s0;
2527
- s0 = peg$FAILED;
2528
- }
2529
- } else {
2530
- peg$currPos = s0;
2531
- s0 = peg$FAILED;
2532
- }
2533
- } else {
2534
- peg$currPos = s0;
2535
- s0 = peg$FAILED;
2536
- }
2537
- } else {
2538
- peg$currPos = s0;
2539
- s0 = peg$FAILED;
2540
- }
2541
-
2542
- return s0;
2543
- }
2544
-
2545
- function peg$parseBlock() {
2546
- var s0, s1, s2, s3, s4, s5, s6;
2547
-
2548
- s0 = peg$currPos;
2549
- if (input.substr(peg$currPos, 2) === peg$c10) {
2550
- s1 = peg$c10;
2551
- peg$currPos += 2;
2552
- } else {
2553
- s1 = peg$FAILED;
2554
- if (peg$silentFails === 0) { peg$fail(peg$e24); }
2555
- }
2556
- if (s1 !== peg$FAILED) {
2557
- s2 = peg$parseExtendedDiacritic();
2558
- if (s2 !== peg$FAILED) {
2559
- s3 = peg$parse__();
2560
- s4 = input.charAt(peg$currPos);
2561
- if (peg$r13.test(s4)) {
2562
- peg$currPos++;
2563
- } else {
2564
- s4 = peg$FAILED;
2565
- if (peg$silentFails === 0) { peg$fail(peg$e22); }
2566
- }
2567
- if (s4 === peg$FAILED) {
2568
- s4 = peg$currPos;
2569
- if (input.charCodeAt(peg$currPos) === 92) {
2570
- s5 = peg$c11;
2571
- peg$currPos++;
2572
- } else {
2573
- s5 = peg$FAILED;
2574
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
2575
- }
2576
- if (s5 !== peg$FAILED) {
2577
- s6 = input.charAt(peg$currPos);
2578
- if (peg$r14.test(s6)) {
2579
- peg$currPos++;
2580
- } else {
2581
- s6 = peg$FAILED;
2582
- if (peg$silentFails === 0) { peg$fail(peg$e26); }
2583
- }
2584
- if (s6 !== peg$FAILED) {
2585
- s5 = [s5, s6];
2586
- s4 = s5;
2587
- } else {
2588
- peg$currPos = s4;
2589
- s4 = peg$FAILED;
2590
- }
2591
- } else {
2592
- peg$currPos = s4;
2593
- s4 = peg$FAILED;
2594
- }
2595
- }
2596
- if (s4 !== peg$FAILED) {
2597
- if (input.charCodeAt(peg$currPos) === 125) {
2598
- s5 = peg$c3;
2599
- peg$currPos++;
2600
- } else {
2601
- s5 = peg$FAILED;
2602
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
2603
- }
2604
- if (s5 !== peg$FAILED) {
2605
- peg$savedPos = s0;
2606
- s0 = peg$f34(s2, s4);
2607
- } else {
2608
- peg$currPos = s0;
2609
- s0 = peg$FAILED;
2610
- }
2611
- } else {
2612
- peg$currPos = s0;
2613
- s0 = peg$FAILED;
2614
- }
2615
- } else {
2616
- peg$currPos = s0;
2617
- s0 = peg$FAILED;
2618
- }
2619
- } else {
2620
- peg$currPos = s0;
2621
- s0 = peg$FAILED;
2622
- }
2623
- if (s0 === peg$FAILED) {
2624
- s0 = peg$currPos;
2625
- if (input.charCodeAt(peg$currPos) === 123) {
2626
- s1 = peg$c2;
2627
- peg$currPos++;
2628
- } else {
2629
- s1 = peg$FAILED;
2630
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
2631
- }
2632
- if (s1 !== peg$FAILED) {
2633
- s2 = [];
2634
- s3 = peg$parseEnvironment();
2635
- if (s3 === peg$FAILED) {
2636
- s3 = peg$parseBlock();
2637
- if (s3 === peg$FAILED) {
2638
- s3 = peg$parseCommand();
2639
- if (s3 === peg$FAILED) {
2640
- s3 = peg$parseMath();
2641
- if (s3 === peg$FAILED) {
2642
- s3 = peg$parseText();
2643
- }
2644
- }
2645
- }
2646
- }
2647
- while (s3 !== peg$FAILED) {
2648
- s2.push(s3);
2649
- s3 = peg$parseEnvironment();
2650
- if (s3 === peg$FAILED) {
2651
- s3 = peg$parseBlock();
2652
- if (s3 === peg$FAILED) {
2653
- s3 = peg$parseCommand();
2654
- if (s3 === peg$FAILED) {
2655
- s3 = peg$parseMath();
2656
- if (s3 === peg$FAILED) {
2657
- s3 = peg$parseText();
2658
- }
2659
- }
2660
- }
2661
- }
2662
- }
2663
- if (input.charCodeAt(peg$currPos) === 125) {
2664
- s3 = peg$c3;
2665
- peg$currPos++;
2666
- } else {
2667
- s3 = peg$FAILED;
2668
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
2669
- }
2670
- if (s3 !== peg$FAILED) {
2671
- peg$savedPos = s0;
2672
- s0 = peg$f35(s2);
2673
- } else {
2674
- peg$currPos = s0;
2675
- s0 = peg$FAILED;
2676
- }
2677
- } else {
2678
- peg$currPos = s0;
2679
- s0 = peg$FAILED;
2680
- }
2681
- }
2682
-
2683
- return s0;
2684
- }
2685
-
2686
- function peg$parseMath() {
2687
- var s0, s1, s2, s3, s4, s5, s6;
2688
-
2689
- s0 = peg$currPos;
2690
- peg$savedPos = peg$currPos;
2691
- s1 = peg$f36();
2692
- if (s1) {
2693
- s1 = undefined;
2694
- } else {
2695
- s1 = peg$FAILED;
2696
- }
2697
- if (s1 !== peg$FAILED) {
2698
- if (input.charCodeAt(peg$currPos) === 36) {
2699
- s2 = peg$c12;
2700
- peg$currPos++;
2701
- } else {
2702
- s2 = peg$FAILED;
2703
- if (peg$silentFails === 0) { peg$fail(peg$e27); }
2704
- }
2705
- if (s2 === peg$FAILED) {
2706
- if (input.substr(peg$currPos, 2) === peg$c13) {
2707
- s2 = peg$c13;
2708
- peg$currPos += 2;
2709
- } else {
2710
- s2 = peg$FAILED;
2711
- if (peg$silentFails === 0) { peg$fail(peg$e28); }
2712
- }
2713
- if (s2 === peg$FAILED) {
2714
- if (input.substr(peg$currPos, 2) === peg$c14) {
2715
- s2 = peg$c14;
2716
- peg$currPos += 2;
2717
- } else {
2718
- s2 = peg$FAILED;
2719
- if (peg$silentFails === 0) { peg$fail(peg$e29); }
2720
- }
2721
- }
2722
- }
2723
- if (s2 !== peg$FAILED) {
2724
- peg$savedPos = peg$currPos;
2725
- s3 = peg$f37(s2);
2726
- if (s3) {
2727
- s3 = undefined;
2728
- } else {
2729
- s3 = peg$FAILED;
2730
- }
2731
- if (s3 !== peg$FAILED) {
2732
- s4 = [];
2733
- s5 = peg$parseBlock();
2734
- if (s5 === peg$FAILED) {
2735
- s5 = peg$parseCommand();
2736
- if (s5 === peg$FAILED) {
2737
- s5 = peg$parseText();
2738
- }
2739
- }
2740
- while (s5 !== peg$FAILED) {
2741
- s4.push(s5);
2742
- s5 = peg$parseBlock();
2743
- if (s5 === peg$FAILED) {
2744
- s5 = peg$parseCommand();
2745
- if (s5 === peg$FAILED) {
2746
- s5 = peg$parseText();
2747
- }
2748
- }
2749
- }
2750
- if (input.charCodeAt(peg$currPos) === 36) {
2751
- s5 = peg$c12;
2752
- peg$currPos++;
2753
- } else {
2754
- s5 = peg$FAILED;
2755
- if (peg$silentFails === 0) { peg$fail(peg$e27); }
2756
- }
2757
- if (s5 === peg$FAILED) {
2758
- if (input.substr(peg$currPos, 2) === peg$c13) {
2759
- s5 = peg$c13;
2760
- peg$currPos += 2;
2761
- } else {
2762
- s5 = peg$FAILED;
2763
- if (peg$silentFails === 0) { peg$fail(peg$e28); }
2764
- }
2765
- if (s5 === peg$FAILED) {
2766
- if (input.substr(peg$currPos, 2) === peg$c15) {
2767
- s5 = peg$c15;
2768
- peg$currPos += 2;
2769
- } else {
2770
- s5 = peg$FAILED;
2771
- if (peg$silentFails === 0) { peg$fail(peg$e30); }
2772
- }
2773
- }
2774
- }
2775
- if (s5 !== peg$FAILED) {
2776
- peg$savedPos = peg$currPos;
2777
- s6 = peg$f38(s2, s4);
2778
- if (s6) {
2779
- s6 = undefined;
2780
- } else {
2781
- s6 = peg$FAILED;
2782
- }
2783
- if (s6 !== peg$FAILED) {
2784
- peg$savedPos = s0;
2785
- s0 = peg$f39(s2, s4);
2786
- } else {
2787
- peg$currPos = s0;
2788
- s0 = peg$FAILED;
2789
- }
2790
- } else {
2791
- peg$currPos = s0;
2792
- s0 = peg$FAILED;
2793
- }
2794
- } else {
2795
- peg$currPos = s0;
2796
- s0 = peg$FAILED;
2797
- }
2798
- } else {
2799
- peg$currPos = s0;
2800
- s0 = peg$FAILED;
2801
- }
2802
- } else {
2803
- peg$currPos = s0;
2804
- s0 = peg$FAILED;
2805
- }
2806
-
2807
- return s0;
2808
- }
2809
-
2810
- function peg$parseLineComment() {
2811
- var s0, s1, s2, s3, s4, s5;
2812
-
2813
- s0 = peg$currPos;
2814
- if (input.charCodeAt(peg$currPos) === 37) {
2815
- s1 = peg$c16;
2816
- peg$currPos++;
2817
- } else {
2818
- s1 = peg$FAILED;
2819
- if (peg$silentFails === 0) { peg$fail(peg$e31); }
2820
- }
2821
- if (s1 !== peg$FAILED) {
2822
- s2 = peg$parse__h();
2823
- s3 = peg$currPos;
2824
- s4 = [];
2825
- s5 = input.charAt(peg$currPos);
2826
- if (peg$r15.test(s5)) {
2827
- peg$currPos++;
2828
- } else {
2829
- s5 = peg$FAILED;
2830
- if (peg$silentFails === 0) { peg$fail(peg$e32); }
2831
- }
2832
- if (s5 !== peg$FAILED) {
2833
- while (s5 !== peg$FAILED) {
2834
- s4.push(s5);
2835
- s5 = input.charAt(peg$currPos);
2836
- if (peg$r15.test(s5)) {
2837
- peg$currPos++;
2838
- } else {
2839
- s5 = peg$FAILED;
2840
- if (peg$silentFails === 0) { peg$fail(peg$e32); }
2841
- }
2842
- }
2843
- } else {
2844
- s4 = peg$FAILED;
2845
- }
2846
- if (s4 !== peg$FAILED) {
2847
- s3 = input.substring(s3, peg$currPos);
2848
- } else {
2849
- s3 = s4;
2850
- }
2851
- if (s3 !== peg$FAILED) {
2852
- s4 = [];
2853
- s5 = peg$parseEOL();
2854
- if (s5 !== peg$FAILED) {
2855
- while (s5 !== peg$FAILED) {
2856
- s4.push(s5);
2857
- s5 = peg$parseEOL();
2858
- }
2859
- } else {
2860
- s4 = peg$FAILED;
2861
- }
2862
- if (s4 !== peg$FAILED) {
2863
- peg$savedPos = s0;
2864
- s0 = peg$f40(s3);
2865
- } else {
2866
- peg$currPos = s0;
2867
- s0 = peg$FAILED;
2868
- }
2869
- } else {
2870
- peg$currPos = s0;
2871
- s0 = peg$FAILED;
2872
- }
2873
- } else {
2874
- peg$currPos = s0;
2875
- s0 = peg$FAILED;
2876
- }
2877
-
2878
- return s0;
2879
- }
2880
-
2881
- function peg$parseCommand() {
2882
- var s0;
2883
-
2884
- s0 = peg$parseScriptCommand();
2885
- if (s0 === peg$FAILED) {
2886
- s0 = peg$parseLineBreak();
2887
- if (s0 === peg$FAILED) {
2888
- s0 = peg$parseDiacriticCommand();
2889
- if (s0 === peg$FAILED) {
2890
- s0 = peg$parseRegularCommand();
2891
- if (s0 === peg$FAILED) {
2892
- s0 = peg$parseSymbolCommand();
2893
- if (s0 === peg$FAILED) {
2894
- s0 = peg$parseInvalidCommand();
2895
- }
2896
- }
2897
- }
2898
- }
2899
- }
2900
-
2901
- return s0;
2902
- }
2903
-
2904
- function peg$parseLineBreak() {
2905
- var s0, s1, s2, s3;
2906
-
2907
- s0 = peg$currPos;
2908
- s1 = peg$parse__();
2909
- if (input.substr(peg$currPos, 2) === peg$c17) {
2910
- s2 = peg$c17;
2911
- peg$currPos += 2;
2912
- } else {
2913
- s2 = peg$FAILED;
2914
- if (peg$silentFails === 0) { peg$fail(peg$e33); }
2915
- }
2916
- if (s2 !== peg$FAILED) {
2917
- s3 = peg$parse__();
2918
- peg$savedPos = s0;
2919
- s0 = peg$f41();
2920
- } else {
2921
- peg$currPos = s0;
2922
- s0 = peg$FAILED;
2923
- }
2924
-
2925
- return s0;
2926
- }
2927
-
2928
- function peg$parseScriptCommand() {
2929
- var s0, s1, s2, s3, s4;
2930
-
2931
- s0 = peg$currPos;
2932
- peg$savedPos = peg$currPos;
2933
- s1 = peg$f42();
2934
- if (s1) {
2935
- s1 = undefined;
2936
- } else {
2937
- s1 = peg$FAILED;
2938
- }
2939
- if (s1 !== peg$FAILED) {
2940
- s2 = input.charAt(peg$currPos);
2941
- if (peg$r16.test(s2)) {
2942
- peg$currPos++;
2943
- } else {
2944
- s2 = peg$FAILED;
2945
- if (peg$silentFails === 0) { peg$fail(peg$e34); }
2946
- }
2947
- if (s2 !== peg$FAILED) {
2948
- s3 = peg$parse__h();
2949
- s4 = peg$parseArgument();
2950
- if (s4 !== peg$FAILED) {
2951
- peg$savedPos = s0;
2952
- s0 = peg$f43(s2, s4);
2953
- } else {
2954
- peg$currPos = s0;
2955
- s0 = peg$FAILED;
2956
- }
2957
- } else {
2958
- peg$currPos = s0;
2959
- s0 = peg$FAILED;
2960
- }
2961
- } else {
2962
- peg$currPos = s0;
2963
- s0 = peg$FAILED;
2964
- }
2965
- if (s0 === peg$FAILED) {
2966
- s0 = peg$currPos;
2967
- s1 = input.charAt(peg$currPos);
2968
- if (peg$r16.test(s1)) {
2969
- peg$currPos++;
2970
- } else {
2971
- s1 = peg$FAILED;
2972
- if (peg$silentFails === 0) { peg$fail(peg$e34); }
2973
- }
2974
- if (s1 !== peg$FAILED) {
2975
- peg$savedPos = s0;
2976
- s1 = peg$f44(s1);
2977
- }
2978
- s0 = s1;
2979
- }
2980
-
2981
- return s0;
2982
- }
2983
-
2984
- function peg$parseDiacriticCommand() {
2985
- var s0, s1, s2, s3, s4, s5, s6;
2986
-
2987
- s0 = peg$currPos;
2988
- if (input.charCodeAt(peg$currPos) === 92) {
2989
- s1 = peg$c11;
2990
- peg$currPos++;
2991
- } else {
2992
- s1 = peg$FAILED;
2993
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
2994
- }
2995
- if (s1 !== peg$FAILED) {
2996
- s2 = peg$parseSimpleDiacritic();
2997
- if (s2 !== peg$FAILED) {
2998
- s3 = peg$parse__();
2999
- s4 = input.charAt(peg$currPos);
3000
- if (peg$r13.test(s4)) {
3001
- peg$currPos++;
3002
- } else {
3003
- s4 = peg$FAILED;
3004
- if (peg$silentFails === 0) { peg$fail(peg$e22); }
3005
- }
3006
- if (s4 === peg$FAILED) {
3007
- s4 = peg$currPos;
3008
- if (input.charCodeAt(peg$currPos) === 92) {
3009
- s5 = peg$c11;
3010
- peg$currPos++;
3011
- } else {
3012
- s5 = peg$FAILED;
3013
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
3014
- }
3015
- if (s5 !== peg$FAILED) {
3016
- s6 = input.charAt(peg$currPos);
3017
- if (peg$r14.test(s6)) {
3018
- peg$currPos++;
3019
- } else {
3020
- s6 = peg$FAILED;
3021
- if (peg$silentFails === 0) { peg$fail(peg$e26); }
3022
- }
3023
- if (s6 !== peg$FAILED) {
3024
- s5 = [s5, s6];
3025
- s4 = s5;
3026
- } else {
3027
- peg$currPos = s4;
3028
- s4 = peg$FAILED;
3029
- }
3030
- } else {
3031
- peg$currPos = s4;
3032
- s4 = peg$FAILED;
3033
- }
3034
- }
3035
- if (s4 !== peg$FAILED) {
3036
- peg$savedPos = s0;
3037
- s0 = peg$f45(s2, s4);
3038
- } else {
3039
- peg$currPos = s0;
3040
- s0 = peg$FAILED;
3041
- }
3042
- } else {
3043
- peg$currPos = s0;
3044
- s0 = peg$FAILED;
3045
- }
3046
- } else {
3047
- peg$currPos = s0;
3048
- s0 = peg$FAILED;
3049
- }
3050
- if (s0 === peg$FAILED) {
3051
- s0 = peg$currPos;
3052
- if (input.charCodeAt(peg$currPos) === 92) {
3053
- s1 = peg$c11;
3054
- peg$currPos++;
3055
- } else {
3056
- s1 = peg$FAILED;
3057
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
3058
- }
3059
- if (s1 !== peg$FAILED) {
3060
- s2 = peg$parseExtendedDiacritic();
3061
- if (s2 !== peg$FAILED) {
3062
- if (input.charCodeAt(peg$currPos) === 123) {
3063
- s3 = peg$c2;
3064
- peg$currPos++;
3065
- } else {
3066
- s3 = peg$FAILED;
3067
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
3068
- }
3069
- if (s3 !== peg$FAILED) {
3070
- s4 = input.charAt(peg$currPos);
3071
- if (peg$r13.test(s4)) {
3072
- peg$currPos++;
3073
- } else {
3074
- s4 = peg$FAILED;
3075
- if (peg$silentFails === 0) { peg$fail(peg$e22); }
3076
- }
3077
- if (s4 === peg$FAILED) {
3078
- s4 = peg$currPos;
3079
- if (input.charCodeAt(peg$currPos) === 92) {
3080
- s5 = peg$c11;
3081
- peg$currPos++;
3082
- } else {
3083
- s5 = peg$FAILED;
3084
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
3085
- }
3086
- if (s5 !== peg$FAILED) {
3087
- s6 = input.charAt(peg$currPos);
3088
- if (peg$r14.test(s6)) {
3089
- peg$currPos++;
3090
- } else {
3091
- s6 = peg$FAILED;
3092
- if (peg$silentFails === 0) { peg$fail(peg$e26); }
3093
- }
3094
- if (s6 !== peg$FAILED) {
3095
- s5 = [s5, s6];
3096
- s4 = s5;
3097
- } else {
3098
- peg$currPos = s4;
3099
- s4 = peg$FAILED;
3100
- }
3101
- } else {
3102
- peg$currPos = s4;
3103
- s4 = peg$FAILED;
3104
- }
3105
- }
3106
- if (s4 !== peg$FAILED) {
3107
- if (input.charCodeAt(peg$currPos) === 125) {
3108
- s5 = peg$c3;
3109
- peg$currPos++;
3110
- } else {
3111
- s5 = peg$FAILED;
3112
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
3113
- }
3114
- if (s5 !== peg$FAILED) {
3115
- peg$savedPos = s0;
3116
- s0 = peg$f46(s2, s4);
3117
- } else {
3118
- peg$currPos = s0;
3119
- s0 = peg$FAILED;
3120
- }
3121
- } else {
3122
- peg$currPos = s0;
3123
- s0 = peg$FAILED;
3124
- }
3125
- } else {
3126
- peg$currPos = s0;
3127
- s0 = peg$FAILED;
3128
- }
3129
- } else {
3130
- peg$currPos = s0;
3131
- s0 = peg$FAILED;
3132
- }
3133
- } else {
3134
- peg$currPos = s0;
3135
- s0 = peg$FAILED;
3136
- }
3137
- if (s0 === peg$FAILED) {
3138
- s0 = peg$currPos;
3139
- if (input.charCodeAt(peg$currPos) === 92) {
3140
- s1 = peg$c11;
3141
- peg$currPos++;
3142
- } else {
3143
- s1 = peg$FAILED;
3144
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
3145
- }
3146
- if (s1 !== peg$FAILED) {
3147
- s2 = peg$parseExtendedDiacritic();
3148
- if (s2 !== peg$FAILED) {
3149
- s3 = peg$currPos;
3150
- peg$silentFails++;
3151
- if (input.charCodeAt(peg$currPos) === 123) {
3152
- s4 = peg$c2;
3153
- peg$currPos++;
3154
- } else {
3155
- s4 = peg$FAILED;
3156
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
3157
- }
3158
- peg$silentFails--;
3159
- if (s4 !== peg$FAILED) {
3160
- peg$currPos = s3;
3161
- s3 = undefined;
3162
- } else {
3163
- s3 = peg$FAILED;
3164
- }
3165
- if (s3 !== peg$FAILED) {
3166
- s4 = peg$parseRegularValue();
3167
- if (s4 !== peg$FAILED) {
3168
- peg$savedPos = s0;
3169
- s0 = peg$f47(s2, s4);
3170
- } else {
3171
- peg$currPos = s0;
3172
- s0 = peg$FAILED;
3173
- }
3174
- } else {
3175
- peg$currPos = s0;
3176
- s0 = peg$FAILED;
3177
- }
3178
- } else {
3179
- peg$currPos = s0;
3180
- s0 = peg$FAILED;
3181
- }
3182
- } else {
3183
- peg$currPos = s0;
3184
- s0 = peg$FAILED;
3185
- }
3186
- }
3187
- }
3188
-
3189
- return s0;
3190
- }
3191
-
3192
- function peg$parseSymbolCommand() {
3193
- var s0, s1, s2;
3194
-
3195
- s0 = peg$currPos;
3196
- if (input.charCodeAt(peg$currPos) === 92) {
3197
- s1 = peg$c11;
3198
- peg$currPos++;
3199
- } else {
3200
- s1 = peg$FAILED;
3201
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
3202
- }
3203
- if (s1 !== peg$FAILED) {
3204
- s2 = input.charAt(peg$currPos);
3205
- if (peg$r17.test(s2)) {
3206
- peg$currPos++;
3207
- } else {
3208
- s2 = peg$FAILED;
3209
- if (peg$silentFails === 0) { peg$fail(peg$e35); }
3210
- }
3211
- if (s2 !== peg$FAILED) {
3212
- peg$savedPos = s0;
3213
- s0 = peg$f48(s2);
3214
- } else {
3215
- peg$currPos = s0;
3216
- s0 = peg$FAILED;
3217
- }
3218
- } else {
3219
- peg$currPos = s0;
3220
- s0 = peg$FAILED;
3221
- }
3222
-
3223
- return s0;
3224
- }
3225
-
3226
- function peg$parseRegularCommand() {
3227
- var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
3228
-
3229
- s0 = peg$currPos;
3230
- if (input.charCodeAt(peg$currPos) === 92) {
3231
- s1 = peg$c11;
3232
- peg$currPos++;
3233
- } else {
3234
- s1 = peg$FAILED;
3235
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
3236
- }
3237
- if (s1 !== peg$FAILED) {
3238
- if (input.substr(peg$currPos, 10) === peg$c18) {
3239
- s2 = peg$c18;
3240
- peg$currPos += 10;
3241
- } else {
3242
- s2 = peg$FAILED;
3243
- if (peg$silentFails === 0) { peg$fail(peg$e36); }
3244
- }
3245
- if (s2 !== peg$FAILED) {
3246
- s3 = peg$parseBlock();
3247
- if (s3 !== peg$FAILED) {
3248
- peg$savedPos = peg$currPos;
3249
- s4 = peg$f49(s2, s3);
3250
- if (s4) {
3251
- s4 = undefined;
3252
- } else {
3253
- s4 = peg$FAILED;
3254
- }
3255
- if (s4 !== peg$FAILED) {
3256
- s5 = [];
3257
- s6 = peg$parseOptionalArgument();
3258
- while (s6 !== peg$FAILED) {
3259
- s5.push(s6);
3260
- s6 = peg$parseOptionalArgument();
3261
- }
3262
- s6 = peg$parseArgument();
3263
- if (s6 !== peg$FAILED) {
3264
- peg$savedPos = s0;
3265
- s0 = peg$f50(s2, s3, s5, s6);
3266
- } else {
3267
- peg$currPos = s0;
3268
- s0 = peg$FAILED;
3269
- }
3270
- } else {
3271
- peg$currPos = s0;
3272
- s0 = peg$FAILED;
3273
- }
3274
- } else {
3275
- peg$currPos = s0;
3276
- s0 = peg$FAILED;
3277
- }
3278
- } else {
3279
- peg$currPos = s0;
3280
- s0 = peg$FAILED;
3281
- }
3282
- } else {
3283
- peg$currPos = s0;
3284
- s0 = peg$FAILED;
3285
- }
3286
- if (s0 === peg$FAILED) {
3287
- s0 = peg$currPos;
3288
- if (input.substr(peg$currPos, 6) === peg$c19) {
3289
- s1 = peg$c19;
3290
- peg$currPos += 6;
3291
- } else {
3292
- s1 = peg$FAILED;
3293
- if (peg$silentFails === 0) { peg$fail(peg$e37); }
3294
- }
3295
- if (s1 !== peg$FAILED) {
3296
- s2 = peg$parse__h();
3297
- peg$savedPos = s0;
3298
- s0 = peg$f51();
3299
- } else {
3300
- peg$currPos = s0;
3301
- s0 = peg$FAILED;
3302
- }
3303
- if (s0 === peg$FAILED) {
3304
- s0 = peg$currPos;
3305
- if (input.substr(peg$currPos, 7) === peg$c20) {
3306
- s1 = peg$c20;
3307
- peg$currPos += 7;
3308
- } else {
3309
- s1 = peg$FAILED;
3310
- if (peg$silentFails === 0) { peg$fail(peg$e38); }
3311
- }
3312
- if (s1 !== peg$FAILED) {
3313
- s2 = peg$parse__h();
3314
- peg$savedPos = s0;
3315
- s0 = peg$f52();
3316
- } else {
3317
- peg$currPos = s0;
3318
- s0 = peg$FAILED;
3319
- }
3320
- if (s0 === peg$FAILED) {
3321
- s0 = peg$currPos;
3322
- if (input.charCodeAt(peg$currPos) === 92) {
3323
- s1 = peg$c11;
3324
- peg$currPos++;
3325
- } else {
3326
- s1 = peg$FAILED;
3327
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
3328
- }
3329
- if (s1 !== peg$FAILED) {
3330
- if (input.substr(peg$currPos, 3) === peg$c21) {
3331
- s2 = peg$c21;
3332
- peg$currPos += 3;
3333
- } else {
3334
- s2 = peg$FAILED;
3335
- if (peg$silentFails === 0) { peg$fail(peg$e39); }
3336
- }
3337
- if (s2 !== peg$FAILED) {
3338
- s3 = peg$parse__h();
3339
- s4 = peg$currPos;
3340
- peg$silentFails++;
3341
- if (input.charCodeAt(peg$currPos) === 123) {
3342
- s5 = peg$c2;
3343
- peg$currPos++;
3344
- } else {
3345
- s5 = peg$FAILED;
3346
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
3347
- }
3348
- peg$silentFails--;
3349
- if (s5 !== peg$FAILED) {
3350
- peg$currPos = s4;
3351
- s4 = undefined;
3352
- } else {
3353
- s4 = peg$FAILED;
3354
- }
3355
- if (s4 !== peg$FAILED) {
3356
- s5 = peg$parseVerbatimFieldValue();
3357
- if (s5 !== peg$FAILED) {
3358
- peg$savedPos = s0;
3359
- s0 = peg$f53(s2, s5);
3360
- } else {
3361
- peg$currPos = s0;
3362
- s0 = peg$FAILED;
3363
- }
3364
- } else {
3365
- peg$currPos = s0;
3366
- s0 = peg$FAILED;
3367
- }
3368
- } else {
3369
- peg$currPos = s0;
3370
- s0 = peg$FAILED;
3371
- }
3372
- } else {
3373
- peg$currPos = s0;
3374
- s0 = peg$FAILED;
3375
- }
3376
- if (s0 === peg$FAILED) {
3377
- s0 = peg$currPos;
3378
- if (input.charCodeAt(peg$currPos) === 92) {
3379
- s1 = peg$c11;
3380
- peg$currPos++;
3381
- } else {
3382
- s1 = peg$FAILED;
3383
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
3384
- }
3385
- if (s1 !== peg$FAILED) {
3386
- if (input.substr(peg$currPos, 4) === peg$c22) {
3387
- s2 = peg$c22;
3388
- peg$currPos += 4;
3389
- } else {
3390
- s2 = peg$FAILED;
3391
- if (peg$silentFails === 0) { peg$fail(peg$e40); }
3392
- }
3393
- if (s2 !== peg$FAILED) {
3394
- s3 = peg$parse__h();
3395
- s4 = peg$currPos;
3396
- peg$silentFails++;
3397
- if (input.charCodeAt(peg$currPos) === 123) {
3398
- s5 = peg$c2;
3399
- peg$currPos++;
3400
- } else {
3401
- s5 = peg$FAILED;
3402
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
3403
- }
3404
- peg$silentFails--;
3405
- if (s5 !== peg$FAILED) {
3406
- peg$currPos = s4;
3407
- s4 = undefined;
3408
- } else {
3409
- s4 = peg$FAILED;
3410
- }
3411
- if (s4 !== peg$FAILED) {
3412
- s5 = peg$parseVerbatimFieldValue();
3413
- if (s5 !== peg$FAILED) {
3414
- s6 = peg$parseArgument();
3415
- if (s6 !== peg$FAILED) {
3416
- peg$savedPos = s0;
3417
- s0 = peg$f54(s2, s5, s6);
3418
- } else {
3419
- peg$currPos = s0;
3420
- s0 = peg$FAILED;
3421
- }
3422
- } else {
3423
- peg$currPos = s0;
3424
- s0 = peg$FAILED;
3425
- }
3426
- } else {
3427
- peg$currPos = s0;
3428
- s0 = peg$FAILED;
3429
- }
3430
- } else {
3431
- peg$currPos = s0;
3432
- s0 = peg$FAILED;
3433
- }
3434
- } else {
3435
- peg$currPos = s0;
3436
- s0 = peg$FAILED;
3437
- }
3438
- if (s0 === peg$FAILED) {
3439
- s0 = peg$currPos;
3440
- if (input.substr(peg$currPos, 5) === peg$c23) {
3441
- s1 = peg$c23;
3442
- peg$currPos += 5;
3443
- } else {
3444
- s1 = peg$FAILED;
3445
- if (peg$silentFails === 0) { peg$fail(peg$e41); }
3446
- }
3447
- if (s1 !== peg$FAILED) {
3448
- if (input.length > peg$currPos) {
3449
- s2 = input.charAt(peg$currPos);
3450
- peg$currPos++;
3451
- } else {
3452
- s2 = peg$FAILED;
3453
- if (peg$silentFails === 0) { peg$fail(peg$e42); }
3454
- }
3455
- if (s2 !== peg$FAILED) {
3456
- peg$savedPos = peg$currPos;
3457
- s3 = peg$f55(s2);
3458
- if (s3) {
3459
- s3 = undefined;
3460
- } else {
3461
- s3 = peg$FAILED;
3462
- }
3463
- if (s3 !== peg$FAILED) {
3464
- s4 = [];
3465
- s5 = peg$parseVerbatimChar();
3466
- while (s5 !== peg$FAILED) {
3467
- s4.push(s5);
3468
- s5 = peg$parseVerbatimChar();
3469
- }
3470
- if (input.length > peg$currPos) {
3471
- s5 = input.charAt(peg$currPos);
3472
- peg$currPos++;
3473
- } else {
3474
- s5 = peg$FAILED;
3475
- if (peg$silentFails === 0) { peg$fail(peg$e42); }
3476
- }
3477
- if (s5 !== peg$FAILED) {
3478
- peg$savedPos = peg$currPos;
3479
- s6 = peg$f56(s2, s4);
3480
- if (s6) {
3481
- s6 = undefined;
3482
- } else {
3483
- s6 = peg$FAILED;
3484
- }
3485
- if (s6 !== peg$FAILED) {
3486
- peg$savedPos = s0;
3487
- s0 = peg$f57(s2, s4);
3488
- } else {
3489
- peg$currPos = s0;
3490
- s0 = peg$FAILED;
3491
- }
3492
- } else {
3493
- peg$currPos = s0;
3494
- s0 = peg$FAILED;
3495
- }
3496
- } else {
3497
- peg$currPos = s0;
3498
- s0 = peg$FAILED;
3499
- }
3500
- } else {
3501
- peg$currPos = s0;
3502
- s0 = peg$FAILED;
3503
- }
3504
- } else {
3505
- peg$currPos = s0;
3506
- s0 = peg$FAILED;
3507
- }
3508
- if (s0 === peg$FAILED) {
3509
- s0 = peg$currPos;
3510
- if (input.charCodeAt(peg$currPos) === 92) {
3511
- s1 = peg$c11;
3512
- peg$currPos++;
3513
- } else {
3514
- s1 = peg$FAILED;
3515
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
3516
- }
3517
- if (s1 !== peg$FAILED) {
3518
- s2 = peg$currPos;
3519
- peg$silentFails++;
3520
- if (input.substr(peg$currPos, 5) === peg$c24) {
3521
- s3 = peg$c24;
3522
- peg$currPos += 5;
3523
- } else {
3524
- s3 = peg$FAILED;
3525
- if (peg$silentFails === 0) { peg$fail(peg$e43); }
3526
- }
3527
- peg$silentFails--;
3528
- if (s3 === peg$FAILED) {
3529
- s2 = undefined;
3530
- } else {
3531
- peg$currPos = s2;
3532
- s2 = peg$FAILED;
3533
- }
3534
- if (s2 !== peg$FAILED) {
3535
- s3 = peg$currPos;
3536
- peg$silentFails++;
3537
- if (input.substr(peg$currPos, 3) === peg$c25) {
3538
- s4 = peg$c25;
3539
- peg$currPos += 3;
3540
- } else {
3541
- s4 = peg$FAILED;
3542
- if (peg$silentFails === 0) { peg$fail(peg$e44); }
3543
- }
3544
- peg$silentFails--;
3545
- if (s4 === peg$FAILED) {
3546
- s3 = undefined;
3547
- } else {
3548
- peg$currPos = s3;
3549
- s3 = peg$FAILED;
3550
- }
3551
- if (s3 !== peg$FAILED) {
3552
- s4 = peg$currPos;
3553
- s5 = [];
3554
- s6 = input.charAt(peg$currPos);
3555
- if (peg$r18.test(s6)) {
3556
- peg$currPos++;
3557
- } else {
3558
- s6 = peg$FAILED;
3559
- if (peg$silentFails === 0) { peg$fail(peg$e45); }
3560
- }
3561
- if (s6 !== peg$FAILED) {
3562
- while (s6 !== peg$FAILED) {
3563
- s5.push(s6);
3564
- s6 = input.charAt(peg$currPos);
3565
- if (peg$r18.test(s6)) {
3566
- peg$currPos++;
3567
- } else {
3568
- s6 = peg$FAILED;
3569
- if (peg$silentFails === 0) { peg$fail(peg$e45); }
3570
- }
3571
- }
3572
- } else {
3573
- s5 = peg$FAILED;
3574
- }
3575
- if (s5 !== peg$FAILED) {
3576
- s4 = input.substring(s4, peg$currPos);
3577
- } else {
3578
- s4 = s5;
3579
- }
3580
- if (s4 !== peg$FAILED) {
3581
- peg$savedPos = peg$currPos;
3582
- s5 = peg$f58(s4);
3583
- if (s5) {
3584
- s5 = undefined;
3585
- } else {
3586
- s5 = peg$FAILED;
3587
- }
3588
- if (s5 !== peg$FAILED) {
3589
- s6 = [];
3590
- s7 = peg$parseOptionalArgument();
3591
- while (s7 !== peg$FAILED) {
3592
- s6.push(s7);
3593
- s7 = peg$parseOptionalArgument();
3594
- }
3595
- s7 = peg$parse__h();
3596
- s8 = peg$currPos;
3597
- peg$silentFails++;
3598
- if (input.charCodeAt(peg$currPos) === 123) {
3599
- s9 = peg$c2;
3600
- peg$currPos++;
3601
- } else {
3602
- s9 = peg$FAILED;
3603
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
3604
- }
3605
- peg$silentFails--;
3606
- if (s9 !== peg$FAILED) {
3607
- peg$currPos = s8;
3608
- s8 = undefined;
3609
- } else {
3610
- s8 = peg$FAILED;
3611
- }
3612
- if (s8 !== peg$FAILED) {
3613
- s9 = peg$parseVerbatimFieldValue();
3614
- if (s9 !== peg$FAILED) {
3615
- s10 = peg$parseVerbatimFieldValue();
3616
- if (s10 !== peg$FAILED) {
3617
- peg$savedPos = s0;
3618
- s0 = peg$f59(s4, s6, s9, s10);
3619
- } else {
3620
- peg$currPos = s0;
3621
- s0 = peg$FAILED;
3622
- }
3623
- } else {
3624
- peg$currPos = s0;
3625
- s0 = peg$FAILED;
3626
- }
3627
- } else {
3628
- peg$currPos = s0;
3629
- s0 = peg$FAILED;
3630
- }
3631
- } else {
3632
- peg$currPos = s0;
3633
- s0 = peg$FAILED;
3634
- }
3635
- } else {
3636
- peg$currPos = s0;
3637
- s0 = peg$FAILED;
3638
- }
3639
- } else {
3640
- peg$currPos = s0;
3641
- s0 = peg$FAILED;
3642
- }
3643
- } else {
3644
- peg$currPos = s0;
3645
- s0 = peg$FAILED;
3646
- }
3647
- } else {
3648
- peg$currPos = s0;
3649
- s0 = peg$FAILED;
3650
- }
3651
- if (s0 === peg$FAILED) {
3652
- s0 = peg$currPos;
3653
- if (input.charCodeAt(peg$currPos) === 92) {
3654
- s1 = peg$c11;
3655
- peg$currPos++;
3656
- } else {
3657
- s1 = peg$FAILED;
3658
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
3659
- }
3660
- if (s1 !== peg$FAILED) {
3661
- s2 = peg$currPos;
3662
- peg$silentFails++;
3663
- if (input.substr(peg$currPos, 5) === peg$c24) {
3664
- s3 = peg$c24;
3665
- peg$currPos += 5;
3666
- } else {
3667
- s3 = peg$FAILED;
3668
- if (peg$silentFails === 0) { peg$fail(peg$e43); }
3669
- }
3670
- peg$silentFails--;
3671
- if (s3 === peg$FAILED) {
3672
- s2 = undefined;
3673
- } else {
3674
- peg$currPos = s2;
3675
- s2 = peg$FAILED;
3676
- }
3677
- if (s2 !== peg$FAILED) {
3678
- s3 = peg$currPos;
3679
- peg$silentFails++;
3680
- if (input.substr(peg$currPos, 3) === peg$c25) {
3681
- s4 = peg$c25;
3682
- peg$currPos += 3;
3683
- } else {
3684
- s4 = peg$FAILED;
3685
- if (peg$silentFails === 0) { peg$fail(peg$e44); }
3686
- }
3687
- peg$silentFails--;
3688
- if (s4 === peg$FAILED) {
3689
- s3 = undefined;
3690
- } else {
3691
- peg$currPos = s3;
3692
- s3 = peg$FAILED;
3693
- }
3694
- if (s3 !== peg$FAILED) {
3695
- s4 = peg$currPos;
3696
- s5 = [];
3697
- s6 = input.charAt(peg$currPos);
3698
- if (peg$r18.test(s6)) {
3699
- peg$currPos++;
3700
- } else {
3701
- s6 = peg$FAILED;
3702
- if (peg$silentFails === 0) { peg$fail(peg$e45); }
3703
- }
3704
- if (s6 !== peg$FAILED) {
3705
- while (s6 !== peg$FAILED) {
3706
- s5.push(s6);
3707
- s6 = input.charAt(peg$currPos);
3708
- if (peg$r18.test(s6)) {
3709
- peg$currPos++;
3710
- } else {
3711
- s6 = peg$FAILED;
3712
- if (peg$silentFails === 0) { peg$fail(peg$e45); }
3713
- }
3714
- }
3715
- } else {
3716
- s5 = peg$FAILED;
3717
- }
3718
- if (s5 !== peg$FAILED) {
3719
- s4 = input.substring(s4, peg$currPos);
3720
- } else {
3721
- s4 = s5;
3722
- }
3723
- if (s4 !== peg$FAILED) {
3724
- peg$savedPos = peg$currPos;
3725
- s5 = peg$f60(s4);
3726
- if (s5) {
3727
- s5 = undefined;
3728
- } else {
3729
- s5 = peg$FAILED;
3730
- }
3731
- if (s5 !== peg$FAILED) {
3732
- s6 = [];
3733
- s7 = peg$parseOptionalArgument();
3734
- while (s7 !== peg$FAILED) {
3735
- s6.push(s7);
3736
- s7 = peg$parseOptionalArgument();
3737
- }
3738
- s7 = peg$parse__h();
3739
- s8 = peg$currPos;
3740
- peg$silentFails++;
3741
- if (input.charCodeAt(peg$currPos) === 123) {
3742
- s9 = peg$c2;
3743
- peg$currPos++;
3744
- } else {
3745
- s9 = peg$FAILED;
3746
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
3747
- }
3748
- peg$silentFails--;
3749
- if (s9 !== peg$FAILED) {
3750
- peg$currPos = s8;
3751
- s8 = undefined;
3752
- } else {
3753
- s8 = peg$FAILED;
3754
- }
3755
- if (s8 !== peg$FAILED) {
3756
- s9 = peg$parseVerbatimFieldValue();
3757
- if (s9 !== peg$FAILED) {
3758
- peg$savedPos = s0;
3759
- s0 = peg$f61(s4, s6, s9);
3760
- } else {
3761
- peg$currPos = s0;
3762
- s0 = peg$FAILED;
3763
- }
3764
- } else {
3765
- peg$currPos = s0;
3766
- s0 = peg$FAILED;
3767
- }
3768
- } else {
3769
- peg$currPos = s0;
3770
- s0 = peg$FAILED;
3771
- }
3772
- } else {
3773
- peg$currPos = s0;
3774
- s0 = peg$FAILED;
3775
- }
3776
- } else {
3777
- peg$currPos = s0;
3778
- s0 = peg$FAILED;
3779
- }
3780
- } else {
3781
- peg$currPos = s0;
3782
- s0 = peg$FAILED;
3783
- }
3784
- } else {
3785
- peg$currPos = s0;
3786
- s0 = peg$FAILED;
3787
- }
3788
- if (s0 === peg$FAILED) {
3789
- s0 = peg$currPos;
3790
- if (input.charCodeAt(peg$currPos) === 92) {
3791
- s1 = peg$c11;
3792
- peg$currPos++;
3793
- } else {
3794
- s1 = peg$FAILED;
3795
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
3796
- }
3797
- if (s1 !== peg$FAILED) {
3798
- s2 = peg$currPos;
3799
- peg$silentFails++;
3800
- if (input.substr(peg$currPos, 5) === peg$c24) {
3801
- s3 = peg$c24;
3802
- peg$currPos += 5;
3803
- } else {
3804
- s3 = peg$FAILED;
3805
- if (peg$silentFails === 0) { peg$fail(peg$e43); }
3806
- }
3807
- peg$silentFails--;
3808
- if (s3 === peg$FAILED) {
3809
- s2 = undefined;
3810
- } else {
3811
- peg$currPos = s2;
3812
- s2 = peg$FAILED;
3813
- }
3814
- if (s2 !== peg$FAILED) {
3815
- s3 = peg$currPos;
3816
- peg$silentFails++;
3817
- if (input.substr(peg$currPos, 3) === peg$c25) {
3818
- s4 = peg$c25;
3819
- peg$currPos += 3;
3820
- } else {
3821
- s4 = peg$FAILED;
3822
- if (peg$silentFails === 0) { peg$fail(peg$e44); }
3823
- }
3824
- peg$silentFails--;
3825
- if (s4 === peg$FAILED) {
3826
- s3 = undefined;
3827
- } else {
3828
- peg$currPos = s3;
3829
- s3 = peg$FAILED;
3830
- }
3831
- if (s3 !== peg$FAILED) {
3832
- s4 = peg$currPos;
3833
- s5 = [];
3834
- s6 = input.charAt(peg$currPos);
3835
- if (peg$r18.test(s6)) {
3836
- peg$currPos++;
3837
- } else {
3838
- s6 = peg$FAILED;
3839
- if (peg$silentFails === 0) { peg$fail(peg$e45); }
3840
- }
3841
- if (s6 !== peg$FAILED) {
3842
- while (s6 !== peg$FAILED) {
3843
- s5.push(s6);
3844
- s6 = input.charAt(peg$currPos);
3845
- if (peg$r18.test(s6)) {
3846
- peg$currPos++;
3847
- } else {
3848
- s6 = peg$FAILED;
3849
- if (peg$silentFails === 0) { peg$fail(peg$e45); }
3850
- }
3851
- }
3852
- } else {
3853
- s5 = peg$FAILED;
3854
- }
3855
- if (s5 !== peg$FAILED) {
3856
- s4 = input.substring(s4, peg$currPos);
3857
- } else {
3858
- s4 = s5;
3859
- }
3860
- if (s4 !== peg$FAILED) {
3861
- peg$savedPos = peg$currPos;
3862
- s5 = peg$f62(s4);
3863
- if (s5) {
3864
- s5 = undefined;
3865
- } else {
3866
- s5 = peg$FAILED;
3867
- }
3868
- if (s5 !== peg$FAILED) {
3869
- s6 = [];
3870
- s7 = peg$parseOptionalArgument();
3871
- while (s7 !== peg$FAILED) {
3872
- s6.push(s7);
3873
- s7 = peg$parseOptionalArgument();
3874
- }
3875
- s7 = peg$parse__h();
3876
- s8 = peg$parseArgument();
3877
- if (s8 !== peg$FAILED) {
3878
- s9 = peg$parseArgument();
3879
- if (s9 !== peg$FAILED) {
3880
- peg$savedPos = s0;
3881
- s0 = peg$f63(s4, s6, s8, s9);
3882
- } else {
3883
- peg$currPos = s0;
3884
- s0 = peg$FAILED;
3885
- }
3886
- } else {
3887
- peg$currPos = s0;
3888
- s0 = peg$FAILED;
3889
- }
3890
- } else {
3891
- peg$currPos = s0;
3892
- s0 = peg$FAILED;
3893
- }
3894
- } else {
3895
- peg$currPos = s0;
3896
- s0 = peg$FAILED;
3897
- }
3898
- } else {
3899
- peg$currPos = s0;
3900
- s0 = peg$FAILED;
3901
- }
3902
- } else {
3903
- peg$currPos = s0;
3904
- s0 = peg$FAILED;
3905
- }
3906
- } else {
3907
- peg$currPos = s0;
3908
- s0 = peg$FAILED;
3909
- }
3910
- if (s0 === peg$FAILED) {
3911
- s0 = peg$currPos;
3912
- if (input.charCodeAt(peg$currPos) === 92) {
3913
- s1 = peg$c11;
3914
- peg$currPos++;
3915
- } else {
3916
- s1 = peg$FAILED;
3917
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
3918
- }
3919
- if (s1 !== peg$FAILED) {
3920
- s2 = peg$currPos;
3921
- peg$silentFails++;
3922
- if (input.substr(peg$currPos, 5) === peg$c24) {
3923
- s3 = peg$c24;
3924
- peg$currPos += 5;
3925
- } else {
3926
- s3 = peg$FAILED;
3927
- if (peg$silentFails === 0) { peg$fail(peg$e43); }
3928
- }
3929
- peg$silentFails--;
3930
- if (s3 === peg$FAILED) {
3931
- s2 = undefined;
3932
- } else {
3933
- peg$currPos = s2;
3934
- s2 = peg$FAILED;
3935
- }
3936
- if (s2 !== peg$FAILED) {
3937
- s3 = peg$currPos;
3938
- peg$silentFails++;
3939
- if (input.substr(peg$currPos, 3) === peg$c25) {
3940
- s4 = peg$c25;
3941
- peg$currPos += 3;
3942
- } else {
3943
- s4 = peg$FAILED;
3944
- if (peg$silentFails === 0) { peg$fail(peg$e44); }
3945
- }
3946
- peg$silentFails--;
3947
- if (s4 === peg$FAILED) {
3948
- s3 = undefined;
3949
- } else {
3950
- peg$currPos = s3;
3951
- s3 = peg$FAILED;
3952
- }
3953
- if (s3 !== peg$FAILED) {
3954
- s4 = peg$currPos;
3955
- s5 = [];
3956
- s6 = input.charAt(peg$currPos);
3957
- if (peg$r18.test(s6)) {
3958
- peg$currPos++;
3959
- } else {
3960
- s6 = peg$FAILED;
3961
- if (peg$silentFails === 0) { peg$fail(peg$e45); }
3962
- }
3963
- if (s6 !== peg$FAILED) {
3964
- while (s6 !== peg$FAILED) {
3965
- s5.push(s6);
3966
- s6 = input.charAt(peg$currPos);
3967
- if (peg$r18.test(s6)) {
3968
- peg$currPos++;
3969
- } else {
3970
- s6 = peg$FAILED;
3971
- if (peg$silentFails === 0) { peg$fail(peg$e45); }
3972
- }
3973
- }
3974
- } else {
3975
- s5 = peg$FAILED;
3976
- }
3977
- if (s5 !== peg$FAILED) {
3978
- s4 = input.substring(s4, peg$currPos);
3979
- } else {
3980
- s4 = s5;
3981
- }
3982
- if (s4 !== peg$FAILED) {
3983
- peg$savedPos = peg$currPos;
3984
- s5 = peg$f64(s4);
3985
- if (s5) {
3986
- s5 = undefined;
3987
- } else {
3988
- s5 = peg$FAILED;
3989
- }
3990
- if (s5 !== peg$FAILED) {
3991
- s6 = [];
3992
- s7 = peg$parseOptionalArgument();
3993
- while (s7 !== peg$FAILED) {
3994
- s6.push(s7);
3995
- s7 = peg$parseOptionalArgument();
3996
- }
3997
- s7 = peg$parse__h();
3998
- s8 = peg$parseArgument();
3999
- if (s8 !== peg$FAILED) {
4000
- peg$savedPos = s0;
4001
- s0 = peg$f65(s4, s6, s8);
4002
- } else {
4003
- peg$currPos = s0;
4004
- s0 = peg$FAILED;
4005
- }
4006
- } else {
4007
- peg$currPos = s0;
4008
- s0 = peg$FAILED;
4009
- }
4010
- } else {
4011
- peg$currPos = s0;
4012
- s0 = peg$FAILED;
4013
- }
4014
- } else {
4015
- peg$currPos = s0;
4016
- s0 = peg$FAILED;
4017
- }
4018
- } else {
4019
- peg$currPos = s0;
4020
- s0 = peg$FAILED;
4021
- }
4022
- } else {
4023
- peg$currPos = s0;
4024
- s0 = peg$FAILED;
4025
- }
4026
- if (s0 === peg$FAILED) {
4027
- s0 = peg$currPos;
4028
- if (input.charCodeAt(peg$currPos) === 92) {
4029
- s1 = peg$c11;
4030
- peg$currPos++;
4031
- } else {
4032
- s1 = peg$FAILED;
4033
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
4034
- }
4035
- if (s1 !== peg$FAILED) {
4036
- s2 = peg$currPos;
4037
- peg$silentFails++;
4038
- if (input.substr(peg$currPos, 5) === peg$c24) {
4039
- s3 = peg$c24;
4040
- peg$currPos += 5;
4041
- } else {
4042
- s3 = peg$FAILED;
4043
- if (peg$silentFails === 0) { peg$fail(peg$e43); }
4044
- }
4045
- peg$silentFails--;
4046
- if (s3 === peg$FAILED) {
4047
- s2 = undefined;
4048
- } else {
4049
- peg$currPos = s2;
4050
- s2 = peg$FAILED;
4051
- }
4052
- if (s2 !== peg$FAILED) {
4053
- s3 = peg$currPos;
4054
- peg$silentFails++;
4055
- if (input.substr(peg$currPos, 3) === peg$c25) {
4056
- s4 = peg$c25;
4057
- peg$currPos += 3;
4058
- } else {
4059
- s4 = peg$FAILED;
4060
- if (peg$silentFails === 0) { peg$fail(peg$e44); }
4061
- }
4062
- peg$silentFails--;
4063
- if (s4 === peg$FAILED) {
4064
- s3 = undefined;
4065
- } else {
4066
- peg$currPos = s3;
4067
- s3 = peg$FAILED;
4068
- }
4069
- if (s3 !== peg$FAILED) {
4070
- s4 = peg$currPos;
4071
- s5 = [];
4072
- s6 = input.charAt(peg$currPos);
4073
- if (peg$r18.test(s6)) {
4074
- peg$currPos++;
4075
- } else {
4076
- s6 = peg$FAILED;
4077
- if (peg$silentFails === 0) { peg$fail(peg$e45); }
4078
- }
4079
- if (s6 !== peg$FAILED) {
4080
- while (s6 !== peg$FAILED) {
4081
- s5.push(s6);
4082
- s6 = input.charAt(peg$currPos);
4083
- if (peg$r18.test(s6)) {
4084
- peg$currPos++;
4085
- } else {
4086
- s6 = peg$FAILED;
4087
- if (peg$silentFails === 0) { peg$fail(peg$e45); }
4088
- }
4089
- }
4090
- } else {
4091
- s5 = peg$FAILED;
4092
- }
4093
- if (s5 !== peg$FAILED) {
4094
- s4 = input.substring(s4, peg$currPos);
4095
- } else {
4096
- s4 = s5;
4097
- }
4098
- if (s4 !== peg$FAILED) {
4099
- s5 = [];
4100
- s6 = peg$parseOptionalArgument();
4101
- while (s6 !== peg$FAILED) {
4102
- s5.push(s6);
4103
- s6 = peg$parseOptionalArgument();
4104
- }
4105
- s6 = peg$parse__();
4106
- peg$savedPos = s0;
4107
- s0 = peg$f66(s4, s5);
4108
- } else {
4109
- peg$currPos = s0;
4110
- s0 = peg$FAILED;
4111
- }
4112
- } else {
4113
- peg$currPos = s0;
4114
- s0 = peg$FAILED;
4115
- }
4116
- } else {
4117
- peg$currPos = s0;
4118
- s0 = peg$FAILED;
4119
- }
4120
- } else {
4121
- peg$currPos = s0;
4122
- s0 = peg$FAILED;
4123
- }
4124
- }
4125
- }
4126
- }
4127
- }
4128
- }
4129
- }
4130
- }
4131
- }
4132
- }
4133
- }
4134
-
4135
- return s0;
4136
- }
4137
-
4138
- function peg$parseVerbatimChar() {
4139
- var s0, s1, s2;
4140
-
4141
- s0 = peg$currPos;
4142
- if (input.length > peg$currPos) {
4143
- s1 = input.charAt(peg$currPos);
4144
- peg$currPos++;
4145
- } else {
4146
- s1 = peg$FAILED;
4147
- if (peg$silentFails === 0) { peg$fail(peg$e42); }
4148
- }
4149
- if (s1 !== peg$FAILED) {
4150
- peg$savedPos = peg$currPos;
4151
- s2 = peg$f67(s1);
4152
- if (s2) {
4153
- s2 = undefined;
4154
- } else {
4155
- s2 = peg$FAILED;
4156
- }
4157
- if (s2 !== peg$FAILED) {
4158
- peg$savedPos = s0;
4159
- s0 = peg$f68(s1);
4160
- } else {
4161
- peg$currPos = s0;
4162
- s0 = peg$FAILED;
4163
- }
4164
- } else {
4165
- peg$currPos = s0;
4166
- s0 = peg$FAILED;
4167
- }
4168
-
4169
- return s0;
4170
- }
4171
-
4172
- function peg$parseInvalidCommand() {
4173
- var s0, s1, s2, s3, s4, s5;
4174
-
4175
- s0 = peg$currPos;
4176
- if (input.charCodeAt(peg$currPos) === 92) {
4177
- s1 = peg$c11;
4178
- peg$currPos++;
4179
- } else {
4180
- s1 = peg$FAILED;
4181
- if (peg$silentFails === 0) { peg$fail(peg$e25); }
4182
- }
4183
- if (s1 !== peg$FAILED) {
4184
- s2 = peg$currPos;
4185
- peg$silentFails++;
4186
- if (input.substr(peg$currPos, 5) === peg$c24) {
4187
- s3 = peg$c24;
4188
- peg$currPos += 5;
4189
- } else {
4190
- s3 = peg$FAILED;
4191
- if (peg$silentFails === 0) { peg$fail(peg$e43); }
4192
- }
4193
- peg$silentFails--;
4194
- if (s3 === peg$FAILED) {
4195
- s2 = undefined;
4196
- } else {
4197
- peg$currPos = s2;
4198
- s2 = peg$FAILED;
4199
- }
4200
- if (s2 !== peg$FAILED) {
4201
- s3 = peg$currPos;
4202
- peg$silentFails++;
4203
- if (input.substr(peg$currPos, 3) === peg$c25) {
4204
- s4 = peg$c25;
4205
- peg$currPos += 3;
4206
- } else {
4207
- s4 = peg$FAILED;
4208
- if (peg$silentFails === 0) { peg$fail(peg$e44); }
4209
- }
4210
- peg$silentFails--;
4211
- if (s4 === peg$FAILED) {
4212
- s3 = undefined;
4213
- } else {
4214
- peg$currPos = s3;
4215
- s3 = peg$FAILED;
4216
- }
4217
- if (s3 !== peg$FAILED) {
4218
- s4 = input.charAt(peg$currPos);
4219
- if (peg$r12.test(s4)) {
4220
- peg$currPos++;
4221
- } else {
4222
- s4 = peg$FAILED;
4223
- if (peg$silentFails === 0) { peg$fail(peg$e20); }
4224
- }
4225
- if (s4 !== peg$FAILED) {
4226
- s5 = peg$parse__();
4227
- peg$savedPos = s0;
4228
- s0 = peg$f69(s4);
4229
- } else {
4230
- peg$currPos = s0;
4231
- s0 = peg$FAILED;
4232
- }
4233
- } else {
4234
- peg$currPos = s0;
4235
- s0 = peg$FAILED;
4236
- }
4237
- } else {
4238
- peg$currPos = s0;
4239
- s0 = peg$FAILED;
4240
- }
4241
- } else {
4242
- peg$currPos = s0;
4243
- s0 = peg$FAILED;
4244
- }
4245
-
4246
- return s0;
4247
- }
4248
-
4249
- function peg$parseOptionalArgument() {
4250
- var s0, s1, s2, s3, s4, s5;
4251
-
4252
- s0 = peg$currPos;
4253
- if (input.charCodeAt(peg$currPos) === 91) {
4254
- s1 = peg$c26;
4255
- peg$currPos++;
4256
- } else {
4257
- s1 = peg$FAILED;
4258
- if (peg$silentFails === 0) { peg$fail(peg$e46); }
4259
- }
4260
- if (s1 !== peg$FAILED) {
4261
- s2 = peg$parse__h();
4262
- s3 = peg$currPos;
4263
- s4 = [];
4264
- s5 = input.charAt(peg$currPos);
4265
- if (peg$r19.test(s5)) {
4266
- peg$currPos++;
4267
- } else {
4268
- s5 = peg$FAILED;
4269
- if (peg$silentFails === 0) { peg$fail(peg$e47); }
4270
- }
4271
- if (s5 !== peg$FAILED) {
4272
- while (s5 !== peg$FAILED) {
4273
- s4.push(s5);
4274
- s5 = input.charAt(peg$currPos);
4275
- if (peg$r19.test(s5)) {
4276
- peg$currPos++;
4277
- } else {
4278
- s5 = peg$FAILED;
4279
- if (peg$silentFails === 0) { peg$fail(peg$e47); }
4280
- }
4281
- }
4282
- } else {
4283
- s4 = peg$FAILED;
4284
- }
4285
- if (s4 !== peg$FAILED) {
4286
- s3 = input.substring(s3, peg$currPos);
4287
- } else {
4288
- s3 = s4;
4289
- }
4290
- if (s3 !== peg$FAILED) {
4291
- s4 = peg$parse__h();
4292
- if (input.charCodeAt(peg$currPos) === 93) {
4293
- s5 = peg$c27;
4294
- peg$currPos++;
4295
- } else {
4296
- s5 = peg$FAILED;
4297
- if (peg$silentFails === 0) { peg$fail(peg$e48); }
4298
- }
4299
- if (s5 !== peg$FAILED) {
4300
- peg$savedPos = s0;
4301
- s0 = peg$f70(s3);
4302
- } else {
4303
- peg$currPos = s0;
4304
- s0 = peg$FAILED;
4305
- }
4306
- } else {
4307
- peg$currPos = s0;
4308
- s0 = peg$FAILED;
4309
- }
4310
- } else {
4311
- peg$currPos = s0;
4312
- s0 = peg$FAILED;
4313
- }
4314
-
4315
- return s0;
4316
- }
4317
-
4318
- function peg$parseArgument() {
4319
- var s0, s1, s2;
4320
-
4321
- s0 = peg$currPos;
4322
- s1 = peg$parse__h();
4323
- s2 = input.charAt(peg$currPos);
4324
- if (peg$r20.test(s2)) {
4325
- peg$currPos++;
4326
- } else {
4327
- s2 = peg$FAILED;
4328
- if (peg$silentFails === 0) { peg$fail(peg$e49); }
4329
- }
4330
- if (s2 !== peg$FAILED) {
4331
- peg$savedPos = s0;
4332
- s0 = peg$f71(s2);
4333
- } else {
4334
- peg$currPos = s0;
4335
- s0 = peg$FAILED;
4336
- }
4337
- if (s0 === peg$FAILED) {
4338
- s0 = peg$currPos;
4339
- s1 = peg$parse__h();
4340
- s2 = peg$parseBlock();
4341
- if (s2 === peg$FAILED) {
4342
- s2 = peg$parseCommand();
4343
- }
4344
- if (s2 !== peg$FAILED) {
4345
- peg$savedPos = s0;
4346
- s0 = peg$f72(s2);
4347
- } else {
4348
- peg$currPos = s0;
4349
- s0 = peg$FAILED;
4350
- }
4351
- }
4352
-
4353
- return s0;
4354
- }
4355
-
4356
- function peg$parseVariableName() {
4357
- var s0, s1, s2, s3, s4;
4358
-
4359
- s0 = peg$currPos;
4360
- s1 = peg$currPos;
4361
- s2 = input.charAt(peg$currPos);
4362
- if (peg$r21.test(s2)) {
4363
- peg$currPos++;
4364
- } else {
4365
- s2 = peg$FAILED;
4366
- if (peg$silentFails === 0) { peg$fail(peg$e50); }
4367
- }
4368
- if (s2 !== peg$FAILED) {
4369
- s3 = [];
4370
- s4 = input.charAt(peg$currPos);
4371
- if (peg$r22.test(s4)) {
4372
- peg$currPos++;
4373
- } else {
4374
- s4 = peg$FAILED;
4375
- if (peg$silentFails === 0) { peg$fail(peg$e51); }
4376
- }
4377
- while (s4 !== peg$FAILED) {
4378
- s3.push(s4);
4379
- s4 = input.charAt(peg$currPos);
4380
- if (peg$r22.test(s4)) {
4381
- peg$currPos++;
4382
- } else {
4383
- s4 = peg$FAILED;
4384
- if (peg$silentFails === 0) { peg$fail(peg$e51); }
4385
- }
4386
- }
4387
- s2 = [s2, s3];
4388
- s1 = s2;
4389
- } else {
4390
- peg$currPos = s1;
4391
- s1 = peg$FAILED;
4392
- }
4393
- if (s1 !== peg$FAILED) {
4394
- s0 = input.substring(s0, peg$currPos);
4395
- } else {
4396
- s0 = s1;
4397
- }
4398
-
4399
- return s0;
4400
- }
4401
-
4402
- function peg$parseSimpleDiacritic() {
4403
- var s0;
4404
-
4405
- s0 = input.charAt(peg$currPos);
4406
- if (peg$r23.test(s0)) {
4407
- peg$currPos++;
4408
- } else {
4409
- s0 = peg$FAILED;
4410
- if (peg$silentFails === 0) { peg$fail(peg$e52); }
4411
- }
4412
-
4413
- return s0;
4414
- }
4415
-
4416
- function peg$parseExtendedDiacritic() {
4417
- var s0;
4418
-
4419
- s0 = input.charAt(peg$currPos);
4420
- if (peg$r24.test(s0)) {
4421
- peg$currPos++;
4422
- } else {
4423
- s0 = peg$FAILED;
4424
- if (peg$silentFails === 0) { peg$fail(peg$e53); }
4425
- }
4426
-
4427
- return s0;
4428
- }
4429
-
4430
- function peg$parseFieldSeparator() {
4431
- var s0, s1, s2, s3;
4432
-
4433
- s0 = peg$currPos;
4434
- s1 = peg$parse__();
4435
- if (input.charCodeAt(peg$currPos) === 61) {
4436
- s2 = peg$c28;
4437
- peg$currPos++;
4438
- } else {
4439
- s2 = peg$FAILED;
4440
- if (peg$silentFails === 0) { peg$fail(peg$e54); }
4441
- }
4442
- if (s2 !== peg$FAILED) {
4443
- s3 = peg$parse__();
4444
- s1 = [s1, s2, s3];
4445
- s0 = s1;
4446
- } else {
4447
- peg$currPos = s0;
4448
- s0 = peg$FAILED;
4449
- }
4450
-
4451
- return s0;
4452
- }
4453
-
4454
- function peg$parseFieldTerminator() {
4455
- var s0;
4456
-
4457
- s0 = peg$parse_();
4458
- if (s0 === peg$FAILED) {
4459
- if (input.charCodeAt(peg$currPos) === 44) {
4460
- s0 = peg$c6;
4461
- peg$currPos++;
4462
- } else {
4463
- s0 = peg$FAILED;
4464
- if (peg$silentFails === 0) { peg$fail(peg$e14); }
4465
- }
4466
- if (s0 === peg$FAILED) {
4467
- s0 = peg$parseLineComment();
4468
- }
4469
- }
4470
-
4471
- return s0;
4472
- }
4473
-
4474
- function peg$parseConcat() {
4475
- var s0, s1, s2, s3;
4476
-
4477
- s0 = peg$currPos;
4478
- s1 = peg$parse__();
4479
- if (input.charCodeAt(peg$currPos) === 35) {
4480
- s2 = peg$c29;
4481
- peg$currPos++;
4482
- } else {
4483
- s2 = peg$FAILED;
4484
- if (peg$silentFails === 0) { peg$fail(peg$e55); }
4485
- }
4486
- if (s2 !== peg$FAILED) {
4487
- s3 = peg$parse__();
4488
- s1 = [s1, s2, s3];
4489
- s0 = s1;
4490
- } else {
4491
- peg$currPos = s0;
4492
- s0 = peg$FAILED;
4493
- }
4494
-
4495
- return s0;
4496
- }
4497
-
4498
- function peg$parseEOL() {
4499
- var s0;
4500
-
4501
- s0 = input.charAt(peg$currPos);
4502
- if (peg$r25.test(s0)) {
4503
- peg$currPos++;
4504
- } else {
4505
- s0 = peg$FAILED;
4506
- if (peg$silentFails === 0) { peg$fail(peg$e56); }
4507
- }
4508
-
4509
- return s0;
4510
- }
4511
-
4512
- function peg$parse_h() {
4513
- var s0, s1;
4514
-
4515
- peg$silentFails++;
4516
- s0 = [];
4517
- s1 = input.charAt(peg$currPos);
4518
- if (peg$r26.test(s1)) {
4519
- peg$currPos++;
4520
- } else {
4521
- s1 = peg$FAILED;
4522
- if (peg$silentFails === 0) { peg$fail(peg$e58); }
4523
- }
4524
- if (s1 !== peg$FAILED) {
4525
- while (s1 !== peg$FAILED) {
4526
- s0.push(s1);
4527
- s1 = input.charAt(peg$currPos);
4528
- if (peg$r26.test(s1)) {
4529
- peg$currPos++;
4530
- } else {
4531
- s1 = peg$FAILED;
4532
- if (peg$silentFails === 0) { peg$fail(peg$e58); }
4533
- }
4534
- }
4535
- } else {
4536
- s0 = peg$FAILED;
4537
- }
4538
- peg$silentFails--;
4539
- if (s0 === peg$FAILED) {
4540
- s1 = peg$FAILED;
4541
- if (peg$silentFails === 0) { peg$fail(peg$e57); }
4542
- }
4543
-
4544
- return s0;
4545
- }
4546
-
4547
- function peg$parse__h() {
4548
- var s0, s1;
4549
-
4550
- peg$silentFails++;
4551
- s0 = [];
4552
- s1 = input.charAt(peg$currPos);
4553
- if (peg$r26.test(s1)) {
4554
- peg$currPos++;
4555
- } else {
4556
- s1 = peg$FAILED;
4557
- if (peg$silentFails === 0) { peg$fail(peg$e58); }
4558
- }
4559
- while (s1 !== peg$FAILED) {
4560
- s0.push(s1);
4561
- s1 = input.charAt(peg$currPos);
4562
- if (peg$r26.test(s1)) {
4563
- peg$currPos++;
4564
- } else {
4565
- s1 = peg$FAILED;
4566
- if (peg$silentFails === 0) { peg$fail(peg$e58); }
4567
- }
4568
- }
4569
- peg$silentFails--;
4570
- s1 = peg$FAILED;
4571
- if (peg$silentFails === 0) { peg$fail(peg$e59); }
4572
-
4573
- return s0;
4574
- }
4575
-
4576
- function peg$parse_v() {
4577
- var s0, s1;
4578
-
4579
- peg$silentFails++;
4580
- s0 = [];
4581
- s1 = input.charAt(peg$currPos);
4582
- if (peg$r25.test(s1)) {
4583
- peg$currPos++;
4584
- } else {
4585
- s1 = peg$FAILED;
4586
- if (peg$silentFails === 0) { peg$fail(peg$e56); }
4587
- }
4588
- if (s1 !== peg$FAILED) {
4589
- while (s1 !== peg$FAILED) {
4590
- s0.push(s1);
4591
- s1 = input.charAt(peg$currPos);
4592
- if (peg$r25.test(s1)) {
4593
- peg$currPos++;
4594
- } else {
4595
- s1 = peg$FAILED;
4596
- if (peg$silentFails === 0) { peg$fail(peg$e56); }
4597
- }
4598
- }
4599
- } else {
4600
- s0 = peg$FAILED;
4601
- }
4602
- peg$silentFails--;
4603
- if (s0 === peg$FAILED) {
4604
- s1 = peg$FAILED;
4605
- if (peg$silentFails === 0) { peg$fail(peg$e60); }
4606
- }
4607
-
4608
- return s0;
4609
- }
4610
-
4611
- function peg$parse__v() {
4612
- var s0, s1;
4613
-
4614
- peg$silentFails++;
4615
- s0 = [];
4616
- s1 = input.charAt(peg$currPos);
4617
- if (peg$r25.test(s1)) {
4618
- peg$currPos++;
4619
- } else {
4620
- s1 = peg$FAILED;
4621
- if (peg$silentFails === 0) { peg$fail(peg$e56); }
4622
- }
4623
- while (s1 !== peg$FAILED) {
4624
- s0.push(s1);
4625
- s1 = input.charAt(peg$currPos);
4626
- if (peg$r25.test(s1)) {
4627
- peg$currPos++;
4628
- } else {
4629
- s1 = peg$FAILED;
4630
- if (peg$silentFails === 0) { peg$fail(peg$e56); }
4631
- }
4632
- }
4633
- peg$silentFails--;
4634
- s1 = peg$FAILED;
4635
- if (peg$silentFails === 0) { peg$fail(peg$e61); }
4636
-
4637
- return s0;
4638
- }
4639
-
4640
- function peg$parse_() {
4641
- var s0, s1, s2, s3;
4642
-
4643
- peg$silentFails++;
4644
- s0 = peg$currPos;
4645
- s1 = peg$currPos;
4646
- s2 = [];
4647
- s3 = input.charAt(peg$currPos);
4648
- if (peg$r27.test(s3)) {
4649
- peg$currPos++;
4650
- } else {
4651
- s3 = peg$FAILED;
4652
- if (peg$silentFails === 0) { peg$fail(peg$e63); }
4653
- }
4654
- if (s3 !== peg$FAILED) {
4655
- while (s3 !== peg$FAILED) {
4656
- s2.push(s3);
4657
- s3 = input.charAt(peg$currPos);
4658
- if (peg$r27.test(s3)) {
4659
- peg$currPos++;
4660
- } else {
4661
- s3 = peg$FAILED;
4662
- if (peg$silentFails === 0) { peg$fail(peg$e63); }
4663
- }
4664
- }
4665
- } else {
4666
- s2 = peg$FAILED;
4667
- }
4668
- if (s2 !== peg$FAILED) {
4669
- s1 = input.substring(s1, peg$currPos);
4670
- } else {
4671
- s1 = s2;
4672
- }
4673
- if (s1 !== peg$FAILED) {
4674
- peg$savedPos = s0;
4675
- s1 = peg$f73(s1);
4676
- }
4677
- s0 = s1;
4678
- peg$silentFails--;
4679
- if (s0 === peg$FAILED) {
4680
- s1 = peg$FAILED;
4681
- if (peg$silentFails === 0) { peg$fail(peg$e62); }
4682
- }
4683
-
4684
- return s0;
4685
- }
4686
-
4687
- function peg$parse__() {
4688
- var s0, s1;
4689
-
4690
- peg$silentFails++;
4691
- s0 = [];
4692
- s1 = input.charAt(peg$currPos);
4693
- if (peg$r27.test(s1)) {
4694
- peg$currPos++;
4695
- } else {
4696
- s1 = peg$FAILED;
4697
- if (peg$silentFails === 0) { peg$fail(peg$e63); }
4698
- }
4699
- while (s1 !== peg$FAILED) {
4700
- s0.push(s1);
4701
- s1 = input.charAt(peg$currPos);
4702
- if (peg$r27.test(s1)) {
4703
- peg$currPos++;
4704
- } else {
4705
- s1 = peg$FAILED;
4706
- if (peg$silentFails === 0) { peg$fail(peg$e63); }
4707
- }
4708
- }
4709
- peg$silentFails--;
4710
- s1 = peg$FAILED;
4711
- if (peg$silentFails === 0) { peg$fail(peg$e64); }
4712
-
4713
- return s0;
4714
- }
4715
-
4716
-
4717
- /*
4718
- MIT License
4719
-
4720
- Copyright (c) 2017 Derek P Sifford, parts copyright (c) 2019 by Emiliano Heyns
4721
-
4722
- Permission is hereby granted, free of charge, to any person obtaining a copy
4723
- of this software and associated documentation files (the "Software"), to deal
4724
- in the Software without restriction, including without limitation the rights
4725
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4726
- copies of the Software, and to permit persons to whom the Software is
4727
- furnished to do so, subject to the following conditions:
4728
-
4729
- The above copyright notice and this permission notice shall be included in all
4730
- copies or substantial portions of the Software.
4731
-
4732
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4733
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4734
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4735
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4736
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4737
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4738
- SOFTWARE.
4739
- */
4740
-
4741
- const markup = {
4742
- sl: 'italics',
4743
- em: 'italics',
4744
- it: 'italics',
4745
- itshape: 'italics',
4746
-
4747
- bf: 'bold',
4748
- bfseries: 'bold',
4749
-
4750
- sc: 'smallCaps',
4751
- scshape: 'smallCaps',
4752
-
4753
- tt: 'fixedWidth',
4754
- texttt: 'fixedWidth',
4755
- rm: 'roman',
4756
- sf: 'sansSerif',
4757
- }
4758
-
4759
- const unnestFields = (options.unnestFields || []).map(field => field.toLowerCase())
4760
- const verbatimFields = (options.verbatimFields || [ 'urlraw', 'url', 'doi', 'file', 'files', 'eprint', 'verba', 'verbb', 'verbc' ]).map(field => typeof field === 'string' ? field.toLowerCase() : field)
4761
- const verbatimCommands = (options.verbatimCommands || [ 'url' ])
4762
-
4763
- function isVerbatimField(name) {
4764
- return verbatimFields.find(p => (typeof p === 'string') ? name === p : name.match(p))
4765
- }
4766
-
4767
- function normalizeWhitespace(t) {
4768
- return t.replace(/\r/g, '').replace(/[ \t\n]+/g, ' ')
4769
- }
4770
-
4771
- const has_arguments = {
4772
- ElsevierGlyph: 1,
4773
- end: 1,
4774
- begin: 1,
4775
- bibcyr: 1,
4776
- bibstring: 1,
4777
- chsf: 1,
4778
- cite: 1,
4779
- citeauthor: 1,
4780
- cyrchar: 1,
4781
- ding: 1,
4782
- emph: 1,
4783
- enquote: 1,
4784
- frac: 2,
4785
- href: 2,
4786
- hspace: 1,
4787
- mathrm: 1,
4788
- mbox: 1,
4789
- mkbibbold: 1,
4790
- mkbibemph: 1,
4791
- mkbibitalic: 1,
4792
- mkbibquote: 1,
4793
- newcommand: 2,
4794
- noopsort: 1,
4795
- ocirc: 1,
4796
- section: 1,
4797
- sb: 1,
4798
- sp: 1,
4799
- subsection: 1,
4800
- subsubsection: 1,
4801
- subsubsubsection: 1,
4802
- t: 1,
4803
- textbf: 1,
4804
- textcite: 1,
4805
- textit: 1,
4806
- textrm: 1,
4807
- textsc: 1,
4808
- textsubscript: 1,
4809
- textsuperscript: 1,
4810
- textup: 1,
4811
- texttt: 1,
4812
- url: 1,
4813
- vphantom: 1,
4814
- vspace: 1,
4815
- }
4816
-
4817
- if (options.combining) {
4818
- for (const cmd of options.combining) {
4819
- has_arguments[cmd] = 1
4820
- }
4821
- }
4822
-
4823
- function say() {
4824
- console.log(JSON.stringify(Array.from(arguments), null, 2))
4825
- return true
4826
- }
4827
-
4828
- function peek(n) {
4829
- return input.substr(peg$savedPos, n)
4830
- }
4831
-
4832
- const math = {
4833
- on: false,
4834
-
4835
- set: function(state) {
4836
- this.on = state
4837
- return true
4838
- }
4839
- }
4840
-
4841
- const verbatim = {
4842
- delim: '',
4843
-
4844
- set: function(delim) {
4845
- this.delim = delim
4846
- return true
4847
- }
4848
- }
4849
-
4850
- function basicTextConversions(node) {
4851
- if (node.kind !== 'Text') throw new Error(node.kind + ' is not a Text node')
4852
-
4853
- switch (node.mode) {
4854
- case 'verbatim':
4855
- break
4856
-
4857
- case 'math':
4858
- node.value = node.value.replace(/~/g, '\u00A0')
4859
- break
4860
-
4861
- case 'text':
4862
- node.value = node.value
4863
- .replace(/---/g, '\u2014')
4864
- .replace(/--/g, '\u2013')
4865
- .replace(/</g, '\u00A1')
4866
- .replace(/>/g, '\u00BF')
4867
- .replace(/~/g, '\u00A0')
4868
- .replace(/``/g, options.markup.enquote.open)
4869
- .replace(/''/g, options.markup.enquote.close)
4870
- break
4871
-
4872
- default:
4873
- throw new Error(`Unexpected text mode ${node.mode}`)
4874
- }
4875
-
4876
- return node
4877
- }
4878
-
4879
- function protect(v) {
4880
- let source
4881
- if (Array.isArray(v)) {
4882
- source = v.map(e => e.source).join('')
4883
- } else {
4884
- v = [ v ]
4885
- source = v.source
4886
- }
4887
-
4888
- return {
4889
- kind: 'Block',
4890
- value: v,
4891
- markup: {},
4892
- case: 'protect',
4893
- source: source,
4894
- }
4895
- }
4896
-
4897
- function handle_markup_switches(block) {
4898
- const value = block.value
4899
- if (!Array.isArray(value)) return block
4900
-
4901
- block.value = []
4902
-
4903
- const pseudo = {
4904
- block: null,
4905
- markup: {},
4906
- }
4907
- function pseudo_block() {
4908
- pseudo.block = {
4909
- kind: 'Block',
4910
- loc: location(),
4911
- source: '',
4912
- value: [],
4913
- markup: JSON.parse(JSON.stringify(pseudo.markup)),
4914
- pseudo: true,
4915
- }
4916
- block.value.push(pseudo.block)
4917
- }
4918
- for (const node of value) {
4919
- if (node.kind === 'Environment' || node.kind === 'Block') {
4920
- block.value.push(node)
4921
-
4922
- if (Object.keys(pseudo.markup).length) {
4923
- pseudo_block()
4924
- } else {
4925
- pseudo.block = null
4926
- }
4927
- continue
4928
- }
4929
-
4930
- if (node.kind === 'RegularCommand' && markup[node.command]) {
4931
- if (pseudo.markup.italics) { // https://github.com/citation-js/bibtex-parser-experiments/commit/cae475f075a05d1c074485a061b08ed245170c7e
4932
- delete pseudo.markup.italics
4933
- if (markup[node.command] !== 'italics') pseudo.markup[markup[node.command]] = true
4934
- } else {
4935
- pseudo.markup[markup[node.command]] = true
4936
- }
4937
-
4938
- if (Object.keys(pseudo.markup).length) {
4939
- pseudo_block()
4940
- } else {
4941
- pseudo.block = null
4942
- }
4943
- }
4944
-
4945
- if (pseudo.block) {
4946
- pseudo.block.source += node.source
4947
- pseudo.block.value.push(node)
4948
-
4949
- } else {
4950
- block.value.push(node)
4951
-
4952
- }
4953
- }
4954
-
4955
- block.value = block.value.filter(node => !(node.pseudo && node.value.length === 0))
4956
-
4957
- return block
4958
- }
4959
-
4960
- function parBreak(nodes) {
4961
- const broken = []
4962
- for (const node of nodes) {
4963
- if (node.kind !== 'Text') {
4964
- broken.push(node)
4965
- }
4966
- else {
4967
- node.value.split(/([ \t\r]*\n[ \t\r]*\n[ \t\r\n]*|[ \t\r\n]*\u2029[ \t\r\n]*)/).forEach((par, i) => {
4968
- if (i % 2 == 0) {
4969
- broken.push(basicTextConversions({...node, value: normalizeWhitespace(par)}))
4970
- }
4971
- else {
4972
- broken.push({
4973
- ...node,
4974
- kind: 'RegularCommand',
4975
- command: 'par',
4976
- arguments: {
4977
- optional: [],
4978
- required: [],
4979
- },
4980
- })
4981
- }
4982
- })
4983
- }
4984
- }
4985
- return broken
4986
- }
4987
-
4988
- peg$result = peg$startRuleFunction();
4989
-
4990
- if (options.peg$library) {
4991
- return /** @type {any} */ ({
4992
- peg$result,
4993
- peg$currPos,
4994
- peg$FAILED,
4995
- peg$maxFailExpected,
4996
- peg$maxFailPos
4997
- });
4998
- }
4999
- if (peg$result !== peg$FAILED && peg$currPos === input.length) {
5000
- return peg$result;
5001
- } else {
5002
- if (peg$result !== peg$FAILED && peg$currPos < input.length) {
5003
- peg$fail(peg$endExpectation());
5004
- }
5005
-
5006
- throw peg$buildStructuredError(
5007
- peg$maxFailExpected,
5008
- peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
5009
- peg$maxFailPos < input.length
5010
- ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
5011
- : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
5012
- );
5013
- }
5014
- }
5015
-
5016
- module.exports = {
5017
- StartRules: ["Bibliography"],
5018
- SyntaxError: peg$SyntaxError,
5019
- parse: peg$parse
5020
- };