intl-messageformat 4.1.1 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +32 -44
  2. package/LICENSE +0 -0
  3. package/README.md +108 -59
  4. package/core.js +1 -0
  5. package/dist/compiler.d.ts +10 -4
  6. package/dist/compiler.js +11 -14
  7. package/dist/compiler.js.map +1 -1
  8. package/dist/core.d.ts +78 -0
  9. package/dist/core.js +248 -0
  10. package/dist/core.js.map +1 -0
  11. package/dist/index.d.ts +4 -16
  12. package/dist/index.js +7 -198
  13. package/dist/index.js.map +1 -1
  14. package/dist/umd/intl-messageformat.js +1548 -1373
  15. package/dist/umd/intl-messageformat.js.map +1 -1
  16. package/dist/umd/intl-messageformat.min.js +1 -1
  17. package/dist/umd/intl-messageformat.min.js.map +1 -1
  18. package/index.js +0 -0
  19. package/lib/compiler.d.ts +10 -4
  20. package/lib/compiler.js +11 -14
  21. package/lib/compiler.js.map +1 -1
  22. package/lib/core.d.ts +78 -0
  23. package/lib/core.js +245 -0
  24. package/lib/core.js.map +1 -0
  25. package/lib/index.d.ts +4 -16
  26. package/lib/index.js +4 -198
  27. package/lib/index.js.map +1 -1
  28. package/package.json +4 -4
  29. package/src/compiler.ts +39 -16
  30. package/src/core.ts +269 -0
  31. package/src/index.ts +6 -242
  32. package/.nyc_output/34ec6f1e-d2e9-445f-8813-bd6e8b5975bb.json +0 -1
  33. package/.nyc_output/9b57550b-ff23-4ed6-b289-f7ff8d2beb4f.json +0 -1
  34. package/.nyc_output/b696f16a-7b55-4692-a441-41aa11ca2fb0.json +0 -1
  35. package/.nyc_output/processinfo/34ec6f1e-d2e9-445f-8813-bd6e8b5975bb.json +0 -1
  36. package/.nyc_output/processinfo/9b57550b-ff23-4ed6-b289-f7ff8d2beb4f.json +0 -1
  37. package/.nyc_output/processinfo/b696f16a-7b55-4692-a441-41aa11ca2fb0.json +0 -1
  38. package/.nyc_output/processinfo/index.json +0 -1
@@ -1,648 +1,458 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
- typeof define === 'function' && define.amd ? define(factory) :
4
- (global = global || self, global.IntlMessageFormat = factory());
5
- }(this, function () { 'use strict';
6
-
7
- /*
8
- Copyright (c) 2014, Yahoo! Inc. All rights reserved.
9
- Copyrights licensed under the New BSD License.
10
- See the accompanying LICENSE file for terms.
11
- */
12
- var __extends = (undefined && undefined.__extends) || (function () {
13
- var extendStatics = function (d, b) {
14
- extendStatics = Object.setPrototypeOf ||
15
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
17
- return extendStatics(d, b);
18
- };
19
- return function (d, b) {
20
- extendStatics(d, b);
21
- function __() { this.constructor = d; }
22
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23
- };
24
- })();
25
- var Compiler = /** @class */ (function () {
26
- function Compiler(locales, formats) {
27
- this.locales = [];
28
- this.formats = {
29
- number: {},
30
- date: {},
31
- time: {}
32
- };
33
- this.pluralNumberFormat = null;
34
- this.currentPlural = null;
35
- this.pluralStack = [];
36
- this.locales = locales;
37
- this.formats = formats;
38
- }
39
- Compiler.prototype.compile = function (ast) {
40
- this.pluralStack = [];
41
- this.currentPlural = null;
42
- this.pluralNumberFormat = null;
43
- return this.compileMessage(ast);
44
- };
45
- Compiler.prototype.compileMessage = function (ast) {
46
- var _this = this;
47
- if (!(ast && ast.type === 'messageFormatPattern')) {
48
- throw new Error('Message AST is not of type: "messageFormatPattern"');
49
- }
50
- var elements = ast.elements;
51
- var pattern = elements
52
- .filter(function (el) {
53
- return el.type === 'messageTextElement' || el.type === 'argumentElement';
54
- })
55
- .map(function (el) {
56
- return el.type === 'messageTextElement'
57
- ? _this.compileMessageText(el)
58
- : _this.compileArgument(el);
59
- });
60
- if (pattern.length !== elements.length) {
61
- throw new Error('Message element does not have a valid type');
62
- }
63
- return pattern;
64
- };
65
- Compiler.prototype.compileMessageText = function (element) {
66
- // When this `element` is part of plural sub-pattern and its value contains
67
- // an unescaped '#', use a `PluralOffsetString` helper to properly output
68
- // the number with the correct offset in the string.
69
- if (this.currentPlural && /(^|[^\\])#/g.test(element.value)) {
70
- // Create a cache a NumberFormat instance that can be reused for any
71
- // PluralOffsetString instance in this message.
72
- if (!this.pluralNumberFormat) {
73
- this.pluralNumberFormat = new Intl.NumberFormat(this.locales);
74
- }
75
- return new PluralOffsetString(this.currentPlural.id, this.currentPlural.format.offset, this.pluralNumberFormat, element.value);
76
- }
77
- // Unescape the escaped '#'s in the message text.
78
- return element.value.replace(/\\#/g, '#');
79
- };
80
- Compiler.prototype.compileArgument = function (element) {
81
- var format = element.format, id = element.id;
82
- if (!format) {
83
- return new StringFormat(id);
84
- }
85
- var _a = this, formats = _a.formats, locales = _a.locales;
86
- switch (format.type) {
87
- case 'numberFormat':
88
- return {
89
- id: id,
90
- format: new Intl.NumberFormat(locales, formats.number[format.style])
91
- .format
92
- };
93
- case 'dateFormat':
94
- return {
95
- id: id,
96
- format: new Intl.DateTimeFormat(locales, formats.date[format.style])
97
- .format
98
- };
99
- case 'timeFormat':
100
- return {
101
- id: id,
102
- format: new Intl.DateTimeFormat(locales, formats.time[format.style])
103
- .format
104
- };
105
- case 'pluralFormat':
106
- return new PluralFormat(id, format.ordinal, format.offset, this.compileOptions(element), locales);
107
- case 'selectFormat':
108
- return new SelectFormat(id, this.compileOptions(element));
109
- default:
110
- throw new Error('Message element does not have a valid format type');
111
- }
112
- };
113
- Compiler.prototype.compileOptions = function (element) {
114
- var _this = this;
115
- var format = element.format;
116
- var options = format.options;
117
- // Save the current plural element, if any, then set it to a new value when
118
- // compiling the options sub-patterns. This conforms the spec's algorithm
119
- // for handling `"#"` syntax in message text.
120
- this.pluralStack.push(this.currentPlural);
121
- this.currentPlural = format.type === 'pluralFormat' ? element : null;
122
- var optionsHash = options.reduce(function (all, option) {
123
- // Compile the sub-pattern and save it under the options's selector.
124
- all[option.selector] = _this.compileMessage(option.value);
125
- return all;
126
- }, {});
127
- // Pop the plural stack to put back the original current plural value.
128
- this.currentPlural = this.pluralStack.pop();
129
- return optionsHash;
130
- };
131
- return Compiler;
132
- }());
133
- // -- Compiler Helper Classes --------------------------------------------------
134
- var Formatter = /** @class */ (function () {
135
- function Formatter(id) {
136
- this.id = id;
137
- }
138
- return Formatter;
139
- }());
140
- var StringFormat = /** @class */ (function (_super) {
141
- __extends(StringFormat, _super);
142
- function StringFormat() {
143
- return _super !== null && _super.apply(this, arguments) || this;
144
- }
145
- StringFormat.prototype.format = function (value) {
146
- if (!value && typeof value !== 'number') {
147
- return '';
148
- }
149
- return typeof value === 'string' ? value : String(value);
150
- };
151
- return StringFormat;
152
- }(Formatter));
153
- var PluralFormat = /** @class */ (function () {
154
- function PluralFormat(id, useOrdinal, offset, options, locales) {
155
- this.id = id;
156
- this.offset = offset;
157
- this.options = options;
158
- this.pluralRules = new Intl.PluralRules(locales, {
159
- type: useOrdinal ? 'ordinal' : 'cardinal'
160
- });
161
- }
162
- PluralFormat.prototype.getOption = function (value) {
163
- var options = this.options;
164
- var option = options['=' + value] ||
165
- options[this.pluralRules.select(value - this.offset)];
166
- return option || options.other;
167
- };
168
- return PluralFormat;
169
- }());
170
- var PluralOffsetString = /** @class */ (function (_super) {
171
- __extends(PluralOffsetString, _super);
172
- function PluralOffsetString(id, offset, numberFormat, string) {
173
- var _this = _super.call(this, id) || this;
174
- _this.offset = offset;
175
- _this.numberFormat = numberFormat;
176
- _this.string = string;
177
- return _this;
178
- }
179
- PluralOffsetString.prototype.format = function (value) {
180
- var number = this.numberFormat.format(value - this.offset);
181
- return this.string
182
- .replace(/(^|[^\\])#/g, '$1' + number)
183
- .replace(/\\#/g, '#');
184
- };
185
- return PluralOffsetString;
186
- }(Formatter));
187
- var SelectFormat = /** @class */ (function () {
188
- function SelectFormat(id, options) {
189
- this.id = id;
190
- this.options = options;
191
- }
192
- SelectFormat.prototype.getOption = function (value) {
193
- var options = this.options;
194
- return options[value] || options.other;
195
- };
196
- return SelectFormat;
197
- }());
198
- function isSelectOrPluralFormat(f) {
199
- return !!f.options;
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (global = global || self, factory(global.IntlMessageFormat = {}));
5
+ }(this, function (exports) { 'use strict';
6
+
7
+ var parser = /*
8
+ * Generated by PEG.js 0.10.0.
9
+ *
10
+ * http://pegjs.org/
11
+ */
12
+ (function() {
13
+
14
+ function peg$subclass(child, parent) {
15
+ function ctor() { this.constructor = child; }
16
+ ctor.prototype = parent.prototype;
17
+ child.prototype = new ctor();
200
18
  }
201
19
 
202
- var parser = /*
203
- * Generated by PEG.js 0.10.0.
204
- *
205
- * http://pegjs.org/
206
- */
207
- (function() {
208
-
209
- function peg$subclass(child, parent) {
210
- function ctor() { this.constructor = child; }
211
- ctor.prototype = parent.prototype;
212
- child.prototype = new ctor();
213
- }
214
-
215
- function peg$SyntaxError(message, expected, found, location) {
216
- this.message = message;
217
- this.expected = expected;
218
- this.found = found;
219
- this.location = location;
220
- this.name = "SyntaxError";
20
+ function peg$SyntaxError(message, expected, found, location) {
21
+ this.message = message;
22
+ this.expected = expected;
23
+ this.found = found;
24
+ this.location = location;
25
+ this.name = "SyntaxError";
221
26
 
222
- if (typeof Error.captureStackTrace === "function") {
223
- Error.captureStackTrace(this, peg$SyntaxError);
224
- }
27
+ if (typeof Error.captureStackTrace === "function") {
28
+ Error.captureStackTrace(this, peg$SyntaxError);
225
29
  }
30
+ }
226
31
 
227
- peg$subclass(peg$SyntaxError, Error);
32
+ peg$subclass(peg$SyntaxError, Error);
228
33
 
229
- peg$SyntaxError.buildMessage = function(expected, found) {
230
- var DESCRIBE_EXPECTATION_FNS = {
231
- literal: function(expectation) {
232
- return "\"" + literalEscape(expectation.text) + "\"";
233
- },
34
+ peg$SyntaxError.buildMessage = function(expected, found) {
35
+ var DESCRIBE_EXPECTATION_FNS = {
36
+ literal: function(expectation) {
37
+ return "\"" + literalEscape(expectation.text) + "\"";
38
+ },
234
39
 
235
- "class": function(expectation) {
236
- var escapedParts = "",
237
- i;
40
+ "class": function(expectation) {
41
+ var escapedParts = "",
42
+ i;
238
43
 
239
- for (i = 0; i < expectation.parts.length; i++) {
240
- escapedParts += expectation.parts[i] instanceof Array
241
- ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
242
- : classEscape(expectation.parts[i]);
243
- }
44
+ for (i = 0; i < expectation.parts.length; i++) {
45
+ escapedParts += expectation.parts[i] instanceof Array
46
+ ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
47
+ : classEscape(expectation.parts[i]);
48
+ }
244
49
 
245
- return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
246
- },
50
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
51
+ },
247
52
 
248
- any: function(expectation) {
249
- return "any character";
250
- },
53
+ any: function(expectation) {
54
+ return "any character";
55
+ },
251
56
 
252
- end: function(expectation) {
253
- return "end of input";
254
- },
57
+ end: function(expectation) {
58
+ return "end of input";
59
+ },
255
60
 
256
- other: function(expectation) {
257
- return expectation.description;
258
- }
259
- };
61
+ other: function(expectation) {
62
+ return expectation.description;
63
+ }
64
+ };
260
65
 
261
- function hex(ch) {
262
- return ch.charCodeAt(0).toString(16).toUpperCase();
263
- }
66
+ function hex(ch) {
67
+ return ch.charCodeAt(0).toString(16).toUpperCase();
68
+ }
264
69
 
265
- function literalEscape(s) {
266
- return s
267
- .replace(/\\/g, '\\\\')
268
- .replace(/"/g, '\\"')
269
- .replace(/\0/g, '\\0')
270
- .replace(/\t/g, '\\t')
271
- .replace(/\n/g, '\\n')
272
- .replace(/\r/g, '\\r')
273
- .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
274
- .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
275
- }
70
+ function literalEscape(s) {
71
+ return s
72
+ .replace(/\\/g, '\\\\')
73
+ .replace(/"/g, '\\"')
74
+ .replace(/\0/g, '\\0')
75
+ .replace(/\t/g, '\\t')
76
+ .replace(/\n/g, '\\n')
77
+ .replace(/\r/g, '\\r')
78
+ .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
79
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
80
+ }
276
81
 
277
- function classEscape(s) {
278
- return s
279
- .replace(/\\/g, '\\\\')
280
- .replace(/\]/g, '\\]')
281
- .replace(/\^/g, '\\^')
282
- .replace(/-/g, '\\-')
283
- .replace(/\0/g, '\\0')
284
- .replace(/\t/g, '\\t')
285
- .replace(/\n/g, '\\n')
286
- .replace(/\r/g, '\\r')
287
- .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
288
- .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
289
- }
82
+ function classEscape(s) {
83
+ return s
84
+ .replace(/\\/g, '\\\\')
85
+ .replace(/\]/g, '\\]')
86
+ .replace(/\^/g, '\\^')
87
+ .replace(/-/g, '\\-')
88
+ .replace(/\0/g, '\\0')
89
+ .replace(/\t/g, '\\t')
90
+ .replace(/\n/g, '\\n')
91
+ .replace(/\r/g, '\\r')
92
+ .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
93
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
94
+ }
290
95
 
291
- function describeExpectation(expectation) {
292
- return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
293
- }
96
+ function describeExpectation(expectation) {
97
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
98
+ }
294
99
 
295
- function describeExpected(expected) {
296
- var descriptions = new Array(expected.length),
297
- i, j;
100
+ function describeExpected(expected) {
101
+ var descriptions = new Array(expected.length),
102
+ i, j;
298
103
 
299
- for (i = 0; i < expected.length; i++) {
300
- descriptions[i] = describeExpectation(expected[i]);
301
- }
104
+ for (i = 0; i < expected.length; i++) {
105
+ descriptions[i] = describeExpectation(expected[i]);
106
+ }
302
107
 
303
- descriptions.sort();
108
+ descriptions.sort();
304
109
 
305
- if (descriptions.length > 0) {
306
- for (i = 1, j = 1; i < descriptions.length; i++) {
307
- if (descriptions[i - 1] !== descriptions[i]) {
308
- descriptions[j] = descriptions[i];
309
- j++;
310
- }
110
+ if (descriptions.length > 0) {
111
+ for (i = 1, j = 1; i < descriptions.length; i++) {
112
+ if (descriptions[i - 1] !== descriptions[i]) {
113
+ descriptions[j] = descriptions[i];
114
+ j++;
311
115
  }
312
- descriptions.length = j;
313
116
  }
117
+ descriptions.length = j;
118
+ }
314
119
 
315
- switch (descriptions.length) {
316
- case 1:
317
- return descriptions[0];
120
+ switch (descriptions.length) {
121
+ case 1:
122
+ return descriptions[0];
318
123
 
319
- case 2:
320
- return descriptions[0] + " or " + descriptions[1];
124
+ case 2:
125
+ return descriptions[0] + " or " + descriptions[1];
321
126
 
322
- default:
323
- return descriptions.slice(0, -1).join(", ")
324
- + ", or "
325
- + descriptions[descriptions.length - 1];
326
- }
127
+ default:
128
+ return descriptions.slice(0, -1).join(", ")
129
+ + ", or "
130
+ + descriptions[descriptions.length - 1];
327
131
  }
132
+ }
328
133
 
329
- function describeFound(found) {
330
- return found ? "\"" + literalEscape(found) + "\"" : "end of input";
331
- }
134
+ function describeFound(found) {
135
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
136
+ }
332
137
 
333
- return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
334
- };
138
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
139
+ };
335
140
 
336
- function peg$parse(input, options) {
337
- options = options !== void 0 ? options : {};
338
-
339
- var peg$FAILED = {},
340
-
341
- peg$startRuleFunctions = { start: peg$parsestart },
342
- peg$startRuleFunction = peg$parsestart,
343
-
344
- peg$c0 = function(elements) {
345
- return {
346
- type : 'messageFormatPattern',
347
- elements: elements,
348
- location: location()
349
- };
350
- },
351
- peg$c1 = function(chunks) {
352
- return chunks.reduce(function (all, chunk) {
353
- return all.concat(chunk)
354
- }, []).join('')
355
- },
356
- peg$c2 = function(messageText) {
357
- return {
358
- type : 'messageTextElement',
359
- value: messageText,
360
- location: location()
361
- };
362
- },
363
- peg$c3 = /^[^ \t\n\r,.+={}#]/,
364
- peg$c4 = peg$classExpectation([" ", "\t", "\n", "\r", ",", ".", "+", "=", "{", "}", "#"], true, false),
365
- peg$c5 = "{",
366
- peg$c6 = peg$literalExpectation("{", false),
367
- peg$c7 = ",",
368
- peg$c8 = peg$literalExpectation(",", false),
369
- peg$c9 = "}",
370
- peg$c10 = peg$literalExpectation("}", false),
371
- peg$c11 = function(id, format) {
372
- return {
373
- type : 'argumentElement',
374
- id : id,
375
- format: format && format[2],
376
- location: location()
377
- };
378
- },
379
- peg$c12 = "number",
380
- peg$c13 = peg$literalExpectation("number", false),
381
- peg$c14 = "date",
382
- peg$c15 = peg$literalExpectation("date", false),
383
- peg$c16 = "time",
384
- peg$c17 = peg$literalExpectation("time", false),
385
- peg$c18 = function(type, style) {
386
- return {
387
- type : type + 'Format',
388
- style: style && style[2],
389
- location: location()
390
- };
391
- },
392
- peg$c19 = "plural",
393
- peg$c20 = peg$literalExpectation("plural", false),
394
- peg$c21 = function(pluralStyle) {
395
- return {
396
- type : pluralStyle.type,
397
- ordinal: false,
398
- offset : pluralStyle.offset || 0,
399
- options: pluralStyle.options,
400
- location: location()
401
- };
402
- },
403
- peg$c22 = "selectordinal",
404
- peg$c23 = peg$literalExpectation("selectordinal", false),
405
- peg$c24 = function(pluralStyle) {
406
- return {
407
- type : pluralStyle.type,
408
- ordinal: true,
409
- offset : pluralStyle.offset || 0,
410
- options: pluralStyle.options,
411
- location: location()
412
- }
413
- },
414
- peg$c25 = "select",
415
- peg$c26 = peg$literalExpectation("select", false),
416
- peg$c27 = function(options) {
417
- return {
418
- type : 'selectFormat',
419
- options: options,
420
- location: location()
421
- };
422
- },
423
- peg$c28 = "=",
424
- peg$c29 = peg$literalExpectation("=", false),
425
- peg$c30 = function(selector, pattern) {
426
- return {
427
- type : 'optionalFormatPattern',
428
- selector: selector,
429
- value : pattern,
430
- location: location()
431
- };
432
- },
433
- peg$c31 = "offset:",
434
- peg$c32 = peg$literalExpectation("offset:", false),
435
- peg$c33 = function(number) {
436
- return number;
437
- },
438
- peg$c34 = function(offset, options) {
439
- return {
440
- type : 'pluralFormat',
441
- offset : offset,
442
- options: options,
443
- location: location()
444
- };
445
- },
446
- peg$c35 = peg$otherExpectation("whitespace"),
447
- peg$c36 = /^[ \t\n\r]/,
448
- peg$c37 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false),
449
- peg$c38 = peg$otherExpectation("optionalWhitespace"),
450
- peg$c39 = /^[0-9]/,
451
- peg$c40 = peg$classExpectation([["0", "9"]], false, false),
452
- peg$c41 = /^[0-9a-f]/i,
453
- peg$c42 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true),
454
- peg$c43 = "0",
455
- peg$c44 = peg$literalExpectation("0", false),
456
- peg$c45 = /^[1-9]/,
457
- peg$c46 = peg$classExpectation([["1", "9"]], false, false),
458
- peg$c47 = function(digits) {
459
- return parseInt(digits, 10);
460
- },
461
- peg$c48 = /^[^{}\\\0-\x1F\x7F \t\n\r]/,
462
- peg$c49 = peg$classExpectation(["{", "}", "\\", ["\0", "\x1F"], "\x7F", " ", "\t", "\n", "\r"], true, false),
463
- peg$c50 = "\\\\",
464
- peg$c51 = peg$literalExpectation("\\\\", false),
465
- peg$c52 = function() { return '\\'; },
466
- peg$c53 = "\\#",
467
- peg$c54 = peg$literalExpectation("\\#", false),
468
- peg$c55 = function() { return '\\#'; },
469
- peg$c56 = "\\{",
470
- peg$c57 = peg$literalExpectation("\\{", false),
471
- peg$c58 = function() { return '\u007B'; },
472
- peg$c59 = "\\}",
473
- peg$c60 = peg$literalExpectation("\\}", false),
474
- peg$c61 = function() { return '\u007D'; },
475
- peg$c62 = "\\u",
476
- peg$c63 = peg$literalExpectation("\\u", false),
477
- peg$c64 = function(digits) {
478
- return String.fromCharCode(parseInt(digits, 16));
479
- },
480
- peg$c65 = function(chars) { return chars.join(''); },
481
-
482
- peg$currPos = 0,
483
- peg$savedPos = 0,
484
- peg$posDetailsCache = [{ line: 1, column: 1 }],
485
- peg$maxFailPos = 0,
486
- peg$maxFailExpected = [],
487
- peg$silentFails = 0,
488
-
489
- peg$result;
490
-
491
- if ("startRule" in options) {
492
- if (!(options.startRule in peg$startRuleFunctions)) {
493
- throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
494
- }
141
+ function peg$parse(input, options) {
142
+ options = options !== void 0 ? options : {};
495
143
 
496
- peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
497
- }
144
+ var peg$FAILED = {},
498
145
 
499
- function location() {
500
- return peg$computeLocation(peg$savedPos, peg$currPos);
501
- }
146
+ peg$startRuleFunctions = { start: peg$parsestart },
147
+ peg$startRuleFunction = peg$parsestart,
502
148
 
503
- function peg$literalExpectation(text, ignoreCase) {
504
- return { type: "literal", text: text, ignoreCase: ignoreCase };
505
- }
149
+ peg$c0 = function(elements) {
150
+ return {
151
+ type : 'messageFormatPattern',
152
+ elements: elements,
153
+ location: location()
154
+ };
155
+ },
156
+ peg$c1 = function(chunks) {
157
+ return chunks.reduce(function (all, chunk) {
158
+ return all.concat(chunk)
159
+ }, []).join('')
160
+ },
161
+ peg$c2 = function(messageText) {
162
+ return {
163
+ type : 'messageTextElement',
164
+ value: messageText,
165
+ location: location()
166
+ };
167
+ },
168
+ peg$c3 = function(chars) { return chars.join(''); },
169
+ peg$c4 = "{",
170
+ peg$c5 = peg$literalExpectation("{", false),
171
+ peg$c6 = ",",
172
+ peg$c7 = peg$literalExpectation(",", false),
173
+ peg$c8 = "}",
174
+ peg$c9 = peg$literalExpectation("}", false),
175
+ peg$c10 = function(id, format) {
176
+ return {
177
+ type : 'argumentElement',
178
+ id : id,
179
+ format: format && format[2],
180
+ location: location()
181
+ };
182
+ },
183
+ peg$c11 = "number",
184
+ peg$c12 = peg$literalExpectation("number", false),
185
+ peg$c13 = "date",
186
+ peg$c14 = peg$literalExpectation("date", false),
187
+ peg$c15 = "time",
188
+ peg$c16 = peg$literalExpectation("time", false),
189
+ peg$c17 = function(type, style) {
190
+ return {
191
+ type : type + 'Format',
192
+ style: style && style[2],
193
+ location: location()
194
+ };
195
+ },
196
+ peg$c18 = "plural",
197
+ peg$c19 = peg$literalExpectation("plural", false),
198
+ peg$c20 = function(pluralStyle) {
199
+ return {
200
+ type : pluralStyle.type,
201
+ ordinal: false,
202
+ offset : pluralStyle.offset || 0,
203
+ options: pluralStyle.options,
204
+ location: location()
205
+ };
206
+ },
207
+ peg$c21 = "selectordinal",
208
+ peg$c22 = peg$literalExpectation("selectordinal", false),
209
+ peg$c23 = function(pluralStyle) {
210
+ return {
211
+ type : pluralStyle.type,
212
+ ordinal: true,
213
+ offset : pluralStyle.offset || 0,
214
+ options: pluralStyle.options,
215
+ location: location()
216
+ }
217
+ },
218
+ peg$c24 = "select",
219
+ peg$c25 = peg$literalExpectation("select", false),
220
+ peg$c26 = function(options) {
221
+ return {
222
+ type : 'selectFormat',
223
+ options: options,
224
+ location: location()
225
+ };
226
+ },
227
+ peg$c27 = "=",
228
+ peg$c28 = peg$literalExpectation("=", false),
229
+ peg$c29 = function(selector, pattern) {
230
+ return {
231
+ type : 'optionalFormatPattern',
232
+ selector: selector,
233
+ value : pattern,
234
+ location: location()
235
+ };
236
+ },
237
+ peg$c30 = "offset:",
238
+ peg$c31 = peg$literalExpectation("offset:", false),
239
+ peg$c32 = function(number) {
240
+ return number;
241
+ },
242
+ peg$c33 = function(offset, options) {
243
+ return {
244
+ type : 'pluralFormat',
245
+ offset : offset,
246
+ options: options,
247
+ location: location()
248
+ };
249
+ },
250
+ peg$c34 = peg$otherExpectation("whitespace"),
251
+ peg$c35 = /^[ \t\n\r]/,
252
+ peg$c36 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false),
253
+ peg$c37 = peg$otherExpectation("optionalWhitespace"),
254
+ peg$c38 = /^[0-9]/,
255
+ peg$c39 = peg$classExpectation([["0", "9"]], false, false),
256
+ peg$c40 = /^[0-9a-f]/i,
257
+ peg$c41 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true),
258
+ peg$c42 = "0",
259
+ peg$c43 = peg$literalExpectation("0", false),
260
+ peg$c44 = /^[1-9]/,
261
+ peg$c45 = peg$classExpectation([["1", "9"]], false, false),
262
+ peg$c46 = function(digits) {
263
+ return parseInt(digits, 10);
264
+ },
265
+ peg$c47 = "'",
266
+ peg$c48 = peg$literalExpectation("'", false),
267
+ peg$c49 = /^[ \t\n\r,.+={}#]/,
268
+ peg$c50 = peg$classExpectation([" ", "\t", "\n", "\r", ",", ".", "+", "=", "{", "}", "#"], false, false),
269
+ peg$c51 = peg$anyExpectation(),
270
+ peg$c52 = function(char) { return char; },
271
+ peg$c53 = function(sequence) { return sequence; },
272
+ peg$c54 = /^[^{}\\\0-\x1F\x7F \t\n\r]/,
273
+ peg$c55 = peg$classExpectation(["{", "}", "\\", ["\0", "\x1F"], "\x7F", " ", "\t", "\n", "\r"], true, false),
274
+ peg$c56 = "\\\\",
275
+ peg$c57 = peg$literalExpectation("\\\\", false),
276
+ peg$c58 = function() { return '\\'; },
277
+ peg$c59 = "\\#",
278
+ peg$c60 = peg$literalExpectation("\\#", false),
279
+ peg$c61 = function() { return '\\#'; },
280
+ peg$c62 = "\\{",
281
+ peg$c63 = peg$literalExpectation("\\{", false),
282
+ peg$c64 = function() { return '\u007B'; },
283
+ peg$c65 = "\\}",
284
+ peg$c66 = peg$literalExpectation("\\}", false),
285
+ peg$c67 = function() { return '\u007D'; },
286
+ peg$c68 = "\\u",
287
+ peg$c69 = peg$literalExpectation("\\u", false),
288
+ peg$c70 = function(digits) {
289
+ return String.fromCharCode(parseInt(digits, 16));
290
+ },
506
291
 
507
- function peg$classExpectation(parts, inverted, ignoreCase) {
508
- return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
509
- }
292
+ peg$currPos = 0,
293
+ peg$savedPos = 0,
294
+ peg$posDetailsCache = [{ line: 1, column: 1 }],
295
+ peg$maxFailPos = 0,
296
+ peg$maxFailExpected = [],
297
+ peg$silentFails = 0,
510
298
 
511
- function peg$endExpectation() {
512
- return { type: "end" };
513
- }
299
+ peg$result;
514
300
 
515
- function peg$otherExpectation(description) {
516
- return { type: "other", description: description };
301
+ if ("startRule" in options) {
302
+ if (!(options.startRule in peg$startRuleFunctions)) {
303
+ throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
517
304
  }
518
305
 
519
- function peg$computePosDetails(pos) {
520
- var details = peg$posDetailsCache[pos], p;
306
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
307
+ }
521
308
 
522
- if (details) {
523
- return details;
524
- } else {
525
- p = pos - 1;
526
- while (!peg$posDetailsCache[p]) {
527
- p--;
528
- }
309
+ function location() {
310
+ return peg$computeLocation(peg$savedPos, peg$currPos);
311
+ }
529
312
 
530
- details = peg$posDetailsCache[p];
531
- details = {
532
- line: details.line,
533
- column: details.column
534
- };
313
+ function peg$literalExpectation(text, ignoreCase) {
314
+ return { type: "literal", text: text, ignoreCase: ignoreCase };
315
+ }
535
316
 
536
- while (p < pos) {
537
- if (input.charCodeAt(p) === 10) {
538
- details.line++;
539
- details.column = 1;
540
- } else {
541
- details.column++;
542
- }
317
+ function peg$classExpectation(parts, inverted, ignoreCase) {
318
+ return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
319
+ }
543
320
 
544
- p++;
545
- }
321
+ function peg$anyExpectation() {
322
+ return { type: "any" };
323
+ }
324
+
325
+ function peg$endExpectation() {
326
+ return { type: "end" };
327
+ }
546
328
 
547
- peg$posDetailsCache[pos] = details;
548
- return details;
329
+ function peg$otherExpectation(description) {
330
+ return { type: "other", description: description };
331
+ }
332
+
333
+ function peg$computePosDetails(pos) {
334
+ var details = peg$posDetailsCache[pos], p;
335
+
336
+ if (details) {
337
+ return details;
338
+ } else {
339
+ p = pos - 1;
340
+ while (!peg$posDetailsCache[p]) {
341
+ p--;
549
342
  }
550
- }
551
343
 
552
- function peg$computeLocation(startPos, endPos) {
553
- var startPosDetails = peg$computePosDetails(startPos),
554
- endPosDetails = peg$computePosDetails(endPos);
344
+ details = peg$posDetailsCache[p];
345
+ details = {
346
+ line: details.line,
347
+ column: details.column
348
+ };
555
349
 
556
- return {
557
- start: {
558
- offset: startPos,
559
- line: startPosDetails.line,
560
- column: startPosDetails.column
561
- },
562
- end: {
563
- offset: endPos,
564
- line: endPosDetails.line,
565
- column: endPosDetails.column
350
+ while (p < pos) {
351
+ if (input.charCodeAt(p) === 10) {
352
+ details.line++;
353
+ details.column = 1;
354
+ } else {
355
+ details.column++;
566
356
  }
567
- };
357
+
358
+ p++;
359
+ }
360
+
361
+ peg$posDetailsCache[pos] = details;
362
+ return details;
568
363
  }
364
+ }
569
365
 
570
- function peg$fail(expected) {
571
- if (peg$currPos < peg$maxFailPos) { return; }
366
+ function peg$computeLocation(startPos, endPos) {
367
+ var startPosDetails = peg$computePosDetails(startPos),
368
+ endPosDetails = peg$computePosDetails(endPos);
572
369
 
573
- if (peg$currPos > peg$maxFailPos) {
574
- peg$maxFailPos = peg$currPos;
575
- peg$maxFailExpected = [];
370
+ return {
371
+ start: {
372
+ offset: startPos,
373
+ line: startPosDetails.line,
374
+ column: startPosDetails.column
375
+ },
376
+ end: {
377
+ offset: endPos,
378
+ line: endPosDetails.line,
379
+ column: endPosDetails.column
576
380
  }
381
+ };
382
+ }
577
383
 
578
- peg$maxFailExpected.push(expected);
579
- }
384
+ function peg$fail(expected) {
385
+ if (peg$currPos < peg$maxFailPos) { return; }
580
386
 
581
- function peg$buildStructuredError(expected, found, location) {
582
- return new peg$SyntaxError(
583
- peg$SyntaxError.buildMessage(expected, found),
584
- expected,
585
- found,
586
- location
587
- );
387
+ if (peg$currPos > peg$maxFailPos) {
388
+ peg$maxFailPos = peg$currPos;
389
+ peg$maxFailExpected = [];
588
390
  }
589
391
 
590
- function peg$parsestart() {
591
- var s0;
392
+ peg$maxFailExpected.push(expected);
393
+ }
592
394
 
593
- s0 = peg$parsemessageFormatPattern();
395
+ function peg$buildStructuredError(expected, found, location) {
396
+ return new peg$SyntaxError(
397
+ peg$SyntaxError.buildMessage(expected, found),
398
+ expected,
399
+ found,
400
+ location
401
+ );
402
+ }
594
403
 
595
- return s0;
596
- }
404
+ function peg$parsestart() {
405
+ var s0;
597
406
 
598
- function peg$parsemessageFormatPattern() {
599
- var s0, s1, s2;
407
+ s0 = peg$parsemessageFormatPattern();
600
408
 
601
- s0 = peg$currPos;
602
- s1 = [];
603
- s2 = peg$parsemessageFormatElement();
604
- while (s2 !== peg$FAILED) {
605
- s1.push(s2);
606
- s2 = peg$parsemessageFormatElement();
607
- }
608
- if (s1 !== peg$FAILED) {
609
- peg$savedPos = s0;
610
- s1 = peg$c0(s1);
611
- }
612
- s0 = s1;
409
+ return s0;
410
+ }
411
+
412
+ function peg$parsemessageFormatPattern() {
413
+ var s0, s1, s2;
613
414
 
614
- return s0;
415
+ s0 = peg$currPos;
416
+ s1 = [];
417
+ s2 = peg$parsemessageFormatElement();
418
+ while (s2 !== peg$FAILED) {
419
+ s1.push(s2);
420
+ s2 = peg$parsemessageFormatElement();
421
+ }
422
+ if (s1 !== peg$FAILED) {
423
+ peg$savedPos = s0;
424
+ s1 = peg$c0(s1);
615
425
  }
426
+ s0 = s1;
616
427
 
617
- function peg$parsemessageFormatElement() {
618
- var s0;
428
+ return s0;
429
+ }
619
430
 
620
- s0 = peg$parsemessageTextElement();
621
- if (s0 === peg$FAILED) {
622
- s0 = peg$parseargumentElement();
623
- }
431
+ function peg$parsemessageFormatElement() {
432
+ var s0;
624
433
 
625
- return s0;
434
+ s0 = peg$parsemessageTextElement();
435
+ if (s0 === peg$FAILED) {
436
+ s0 = peg$parseargumentElement();
626
437
  }
627
438
 
628
- function peg$parsemessageText() {
629
- var s0, s1, s2, s3, s4, s5;
439
+ return s0;
440
+ }
630
441
 
631
- s0 = peg$currPos;
632
- s1 = [];
633
- s2 = peg$currPos;
634
- s3 = peg$parse_();
635
- if (s3 !== peg$FAILED) {
636
- s4 = peg$parsechars();
637
- if (s4 !== peg$FAILED) {
638
- s5 = peg$parse_();
639
- if (s5 !== peg$FAILED) {
640
- s3 = [s3, s4, s5];
641
- s2 = s3;
642
- } else {
643
- peg$currPos = s2;
644
- s2 = peg$FAILED;
645
- }
442
+ function peg$parsemessageText() {
443
+ var s0, s1, s2, s3, s4, s5;
444
+
445
+ s0 = peg$currPos;
446
+ s1 = [];
447
+ s2 = peg$currPos;
448
+ s3 = peg$parse_();
449
+ if (s3 !== peg$FAILED) {
450
+ s4 = peg$parsechars();
451
+ if (s4 !== peg$FAILED) {
452
+ s5 = peg$parse_();
453
+ if (s5 !== peg$FAILED) {
454
+ s3 = [s3, s4, s5];
455
+ s2 = s3;
646
456
  } else {
647
457
  peg$currPos = s2;
648
458
  s2 = peg$FAILED;
@@ -651,22 +461,22 @@
651
461
  peg$currPos = s2;
652
462
  s2 = peg$FAILED;
653
463
  }
654
- if (s2 !== peg$FAILED) {
655
- while (s2 !== peg$FAILED) {
656
- s1.push(s2);
657
- s2 = peg$currPos;
658
- s3 = peg$parse_();
659
- if (s3 !== peg$FAILED) {
660
- s4 = peg$parsechars();
661
- if (s4 !== peg$FAILED) {
662
- s5 = peg$parse_();
663
- if (s5 !== peg$FAILED) {
664
- s3 = [s3, s4, s5];
665
- s2 = s3;
666
- } else {
667
- peg$currPos = s2;
668
- s2 = peg$FAILED;
669
- }
464
+ } else {
465
+ peg$currPos = s2;
466
+ s2 = peg$FAILED;
467
+ }
468
+ if (s2 !== peg$FAILED) {
469
+ while (s2 !== peg$FAILED) {
470
+ s1.push(s2);
471
+ s2 = peg$currPos;
472
+ s3 = peg$parse_();
473
+ if (s3 !== peg$FAILED) {
474
+ s4 = peg$parsechars();
475
+ if (s4 !== peg$FAILED) {
476
+ s5 = peg$parse_();
477
+ if (s5 !== peg$FAILED) {
478
+ s3 = [s3, s4, s5];
479
+ s2 = s3;
670
480
  } else {
671
481
  peg$currPos = s2;
672
482
  s2 = peg$FAILED;
@@ -675,117 +485,101 @@
675
485
  peg$currPos = s2;
676
486
  s2 = peg$FAILED;
677
487
  }
488
+ } else {
489
+ peg$currPos = s2;
490
+ s2 = peg$FAILED;
678
491
  }
679
- } else {
680
- s1 = peg$FAILED;
681
492
  }
493
+ } else {
494
+ s1 = peg$FAILED;
495
+ }
496
+ if (s1 !== peg$FAILED) {
497
+ peg$savedPos = s0;
498
+ s1 = peg$c1(s1);
499
+ }
500
+ s0 = s1;
501
+ if (s0 === peg$FAILED) {
502
+ s0 = peg$currPos;
503
+ s1 = peg$parsews();
682
504
  if (s1 !== peg$FAILED) {
683
- peg$savedPos = s0;
684
- s1 = peg$c1(s1);
685
- }
686
- s0 = s1;
687
- if (s0 === peg$FAILED) {
688
- s0 = peg$currPos;
689
- s1 = peg$parsews();
690
- if (s1 !== peg$FAILED) {
691
- s0 = input.substring(s0, peg$currPos);
692
- } else {
693
- s0 = s1;
694
- }
505
+ s0 = input.substring(s0, peg$currPos);
506
+ } else {
507
+ s0 = s1;
695
508
  }
509
+ }
510
+
511
+ return s0;
512
+ }
513
+
514
+ function peg$parsemessageTextElement() {
515
+ var s0, s1;
696
516
 
697
- return s0;
517
+ s0 = peg$currPos;
518
+ s1 = peg$parsemessageText();
519
+ if (s1 !== peg$FAILED) {
520
+ peg$savedPos = s0;
521
+ s1 = peg$c2(s1);
698
522
  }
523
+ s0 = s1;
524
+
525
+ return s0;
526
+ }
699
527
 
700
- function peg$parsemessageTextElement() {
701
- var s0, s1;
528
+ function peg$parseargument() {
529
+ var s0, s1, s2;
702
530
 
531
+ s0 = peg$parsenumber();
532
+ if (s0 === peg$FAILED) {
703
533
  s0 = peg$currPos;
704
- s1 = peg$parsemessageText();
534
+ s1 = [];
535
+ s2 = peg$parsequoteEscapedChar();
536
+ while (s2 !== peg$FAILED) {
537
+ s1.push(s2);
538
+ s2 = peg$parsequoteEscapedChar();
539
+ }
705
540
  if (s1 !== peg$FAILED) {
706
541
  peg$savedPos = s0;
707
- s1 = peg$c2(s1);
542
+ s1 = peg$c3(s1);
708
543
  }
709
544
  s0 = s1;
710
-
711
- return s0;
712
545
  }
713
546
 
714
- function peg$parseargument() {
715
- var s0, s1, s2;
547
+ return s0;
548
+ }
716
549
 
717
- s0 = peg$parsenumber();
718
- if (s0 === peg$FAILED) {
719
- s0 = peg$currPos;
720
- s1 = [];
721
- if (peg$c3.test(input.charAt(peg$currPos))) {
722
- s2 = input.charAt(peg$currPos);
723
- peg$currPos++;
724
- } else {
725
- s2 = peg$FAILED;
726
- if (peg$silentFails === 0) { peg$fail(peg$c4); }
727
- }
728
- if (s2 !== peg$FAILED) {
729
- while (s2 !== peg$FAILED) {
730
- s1.push(s2);
731
- if (peg$c3.test(input.charAt(peg$currPos))) {
732
- s2 = input.charAt(peg$currPos);
550
+ function peg$parseargumentElement() {
551
+ var s0, s1, s2, s3, s4, s5, s6, s7, s8;
552
+
553
+ s0 = peg$currPos;
554
+ if (input.charCodeAt(peg$currPos) === 123) {
555
+ s1 = peg$c4;
556
+ peg$currPos++;
557
+ } else {
558
+ s1 = peg$FAILED;
559
+ if (peg$silentFails === 0) { peg$fail(peg$c5); }
560
+ }
561
+ if (s1 !== peg$FAILED) {
562
+ s2 = peg$parse_();
563
+ if (s2 !== peg$FAILED) {
564
+ s3 = peg$parseargument();
565
+ if (s3 !== peg$FAILED) {
566
+ s4 = peg$parse_();
567
+ if (s4 !== peg$FAILED) {
568
+ s5 = peg$currPos;
569
+ if (input.charCodeAt(peg$currPos) === 44) {
570
+ s6 = peg$c6;
733
571
  peg$currPos++;
734
572
  } else {
735
- s2 = peg$FAILED;
736
- if (peg$silentFails === 0) { peg$fail(peg$c4); }
573
+ s6 = peg$FAILED;
574
+ if (peg$silentFails === 0) { peg$fail(peg$c7); }
737
575
  }
738
- }
739
- } else {
740
- s1 = peg$FAILED;
741
- }
742
- if (s1 !== peg$FAILED) {
743
- s0 = input.substring(s0, peg$currPos);
744
- } else {
745
- s0 = s1;
746
- }
747
- }
748
-
749
- return s0;
750
- }
751
-
752
- function peg$parseargumentElement() {
753
- var s0, s1, s2, s3, s4, s5, s6, s7, s8;
754
-
755
- s0 = peg$currPos;
756
- if (input.charCodeAt(peg$currPos) === 123) {
757
- s1 = peg$c5;
758
- peg$currPos++;
759
- } else {
760
- s1 = peg$FAILED;
761
- if (peg$silentFails === 0) { peg$fail(peg$c6); }
762
- }
763
- if (s1 !== peg$FAILED) {
764
- s2 = peg$parse_();
765
- if (s2 !== peg$FAILED) {
766
- s3 = peg$parseargument();
767
- if (s3 !== peg$FAILED) {
768
- s4 = peg$parse_();
769
- if (s4 !== peg$FAILED) {
770
- s5 = peg$currPos;
771
- if (input.charCodeAt(peg$currPos) === 44) {
772
- s6 = peg$c7;
773
- peg$currPos++;
774
- } else {
775
- s6 = peg$FAILED;
776
- if (peg$silentFails === 0) { peg$fail(peg$c8); }
777
- }
778
- if (s6 !== peg$FAILED) {
779
- s7 = peg$parse_();
780
- if (s7 !== peg$FAILED) {
781
- s8 = peg$parseelementFormat();
782
- if (s8 !== peg$FAILED) {
783
- s6 = [s6, s7, s8];
784
- s5 = s6;
785
- } else {
786
- peg$currPos = s5;
787
- s5 = peg$FAILED;
788
- }
576
+ if (s6 !== peg$FAILED) {
577
+ s7 = peg$parse_();
578
+ if (s7 !== peg$FAILED) {
579
+ s8 = peg$parseelementFormat();
580
+ if (s8 !== peg$FAILED) {
581
+ s6 = [s6, s7, s8];
582
+ s5 = s6;
789
583
  } else {
790
584
  peg$currPos = s5;
791
585
  s5 = peg$FAILED;
@@ -794,27 +588,27 @@
794
588
  peg$currPos = s5;
795
589
  s5 = peg$FAILED;
796
590
  }
797
- if (s5 === peg$FAILED) {
798
- s5 = null;
799
- }
800
- if (s5 !== peg$FAILED) {
801
- s6 = peg$parse_();
802
- if (s6 !== peg$FAILED) {
803
- if (input.charCodeAt(peg$currPos) === 125) {
804
- s7 = peg$c9;
805
- peg$currPos++;
806
- } else {
807
- s7 = peg$FAILED;
808
- if (peg$silentFails === 0) { peg$fail(peg$c10); }
809
- }
810
- if (s7 !== peg$FAILED) {
811
- peg$savedPos = s0;
812
- s1 = peg$c11(s3, s5);
813
- s0 = s1;
814
- } else {
815
- peg$currPos = s0;
816
- s0 = peg$FAILED;
817
- }
591
+ } else {
592
+ peg$currPos = s5;
593
+ s5 = peg$FAILED;
594
+ }
595
+ if (s5 === peg$FAILED) {
596
+ s5 = null;
597
+ }
598
+ if (s5 !== peg$FAILED) {
599
+ s6 = peg$parse_();
600
+ if (s6 !== peg$FAILED) {
601
+ if (input.charCodeAt(peg$currPos) === 125) {
602
+ s7 = peg$c8;
603
+ peg$currPos++;
604
+ } else {
605
+ s7 = peg$FAILED;
606
+ if (peg$silentFails === 0) { peg$fail(peg$c9); }
607
+ }
608
+ if (s7 !== peg$FAILED) {
609
+ peg$savedPos = s0;
610
+ s1 = peg$c10(s3, s5);
611
+ s0 = s1;
818
612
  } else {
819
613
  peg$currPos = s0;
820
614
  s0 = peg$FAILED;
@@ -839,78 +633,78 @@
839
633
  peg$currPos = s0;
840
634
  s0 = peg$FAILED;
841
635
  }
842
-
843
- return s0;
636
+ } else {
637
+ peg$currPos = s0;
638
+ s0 = peg$FAILED;
844
639
  }
845
640
 
846
- function peg$parseelementFormat() {
847
- var s0;
641
+ return s0;
642
+ }
643
+
644
+ function peg$parseelementFormat() {
645
+ var s0;
848
646
 
849
- s0 = peg$parsesimpleFormat();
647
+ s0 = peg$parsesimpleFormat();
648
+ if (s0 === peg$FAILED) {
649
+ s0 = peg$parsepluralFormat();
850
650
  if (s0 === peg$FAILED) {
851
- s0 = peg$parsepluralFormat();
651
+ s0 = peg$parseselectOrdinalFormat();
852
652
  if (s0 === peg$FAILED) {
853
- s0 = peg$parseselectOrdinalFormat();
854
- if (s0 === peg$FAILED) {
855
- s0 = peg$parseselectFormat();
856
- }
653
+ s0 = peg$parseselectFormat();
857
654
  }
858
655
  }
859
-
860
- return s0;
861
656
  }
862
657
 
863
- function peg$parsesimpleFormat() {
864
- var s0, s1, s2, s3, s4, s5, s6;
658
+ return s0;
659
+ }
865
660
 
866
- s0 = peg$currPos;
867
- if (input.substr(peg$currPos, 6) === peg$c12) {
868
- s1 = peg$c12;
869
- peg$currPos += 6;
661
+ function peg$parsesimpleFormat() {
662
+ var s0, s1, s2, s3, s4, s5, s6;
663
+
664
+ s0 = peg$currPos;
665
+ if (input.substr(peg$currPos, 6) === peg$c11) {
666
+ s1 = peg$c11;
667
+ peg$currPos += 6;
668
+ } else {
669
+ s1 = peg$FAILED;
670
+ if (peg$silentFails === 0) { peg$fail(peg$c12); }
671
+ }
672
+ if (s1 === peg$FAILED) {
673
+ if (input.substr(peg$currPos, 4) === peg$c13) {
674
+ s1 = peg$c13;
675
+ peg$currPos += 4;
870
676
  } else {
871
677
  s1 = peg$FAILED;
872
- if (peg$silentFails === 0) { peg$fail(peg$c13); }
678
+ if (peg$silentFails === 0) { peg$fail(peg$c14); }
873
679
  }
874
680
  if (s1 === peg$FAILED) {
875
- if (input.substr(peg$currPos, 4) === peg$c14) {
876
- s1 = peg$c14;
681
+ if (input.substr(peg$currPos, 4) === peg$c15) {
682
+ s1 = peg$c15;
877
683
  peg$currPos += 4;
878
684
  } else {
879
685
  s1 = peg$FAILED;
880
- if (peg$silentFails === 0) { peg$fail(peg$c15); }
881
- }
882
- if (s1 === peg$FAILED) {
883
- if (input.substr(peg$currPos, 4) === peg$c16) {
884
- s1 = peg$c16;
885
- peg$currPos += 4;
886
- } else {
887
- s1 = peg$FAILED;
888
- if (peg$silentFails === 0) { peg$fail(peg$c17); }
889
- }
686
+ if (peg$silentFails === 0) { peg$fail(peg$c16); }
890
687
  }
891
688
  }
892
- if (s1 !== peg$FAILED) {
893
- s2 = peg$parse_();
894
- if (s2 !== peg$FAILED) {
895
- s3 = peg$currPos;
896
- if (input.charCodeAt(peg$currPos) === 44) {
897
- s4 = peg$c7;
898
- peg$currPos++;
899
- } else {
900
- s4 = peg$FAILED;
901
- if (peg$silentFails === 0) { peg$fail(peg$c8); }
902
- }
903
- if (s4 !== peg$FAILED) {
904
- s5 = peg$parse_();
905
- if (s5 !== peg$FAILED) {
906
- s6 = peg$parsechars();
907
- if (s6 !== peg$FAILED) {
908
- s4 = [s4, s5, s6];
909
- s3 = s4;
910
- } else {
911
- peg$currPos = s3;
912
- s3 = peg$FAILED;
913
- }
689
+ }
690
+ if (s1 !== peg$FAILED) {
691
+ s2 = peg$parse_();
692
+ if (s2 !== peg$FAILED) {
693
+ s3 = peg$currPos;
694
+ if (input.charCodeAt(peg$currPos) === 44) {
695
+ s4 = peg$c6;
696
+ peg$currPos++;
697
+ } else {
698
+ s4 = peg$FAILED;
699
+ if (peg$silentFails === 0) { peg$fail(peg$c7); }
700
+ }
701
+ if (s4 !== peg$FAILED) {
702
+ s5 = peg$parse_();
703
+ if (s5 !== peg$FAILED) {
704
+ s6 = peg$parsechars();
705
+ if (s6 !== peg$FAILED) {
706
+ s4 = [s4, s5, s6];
707
+ s3 = s4;
914
708
  } else {
915
709
  peg$currPos = s3;
916
710
  s3 = peg$FAILED;
@@ -919,17 +713,17 @@
919
713
  peg$currPos = s3;
920
714
  s3 = peg$FAILED;
921
715
  }
922
- if (s3 === peg$FAILED) {
923
- s3 = null;
924
- }
925
- if (s3 !== peg$FAILED) {
926
- peg$savedPos = s0;
927
- s1 = peg$c18(s1, s3);
928
- s0 = s1;
929
- } else {
930
- peg$currPos = s0;
931
- s0 = peg$FAILED;
932
- }
716
+ } else {
717
+ peg$currPos = s3;
718
+ s3 = peg$FAILED;
719
+ }
720
+ if (s3 === peg$FAILED) {
721
+ s3 = null;
722
+ }
723
+ if (s3 !== peg$FAILED) {
724
+ peg$savedPos = s0;
725
+ s1 = peg$c17(s1, s3);
726
+ s0 = s1;
933
727
  } else {
934
728
  peg$currPos = s0;
935
729
  s0 = peg$FAILED;
@@ -938,43 +732,43 @@
938
732
  peg$currPos = s0;
939
733
  s0 = peg$FAILED;
940
734
  }
941
-
942
- return s0;
735
+ } else {
736
+ peg$currPos = s0;
737
+ s0 = peg$FAILED;
943
738
  }
944
739
 
945
- function peg$parsepluralFormat() {
946
- var s0, s1, s2, s3, s4, s5;
740
+ return s0;
741
+ }
947
742
 
948
- s0 = peg$currPos;
949
- if (input.substr(peg$currPos, 6) === peg$c19) {
950
- s1 = peg$c19;
951
- peg$currPos += 6;
952
- } else {
953
- s1 = peg$FAILED;
954
- if (peg$silentFails === 0) { peg$fail(peg$c20); }
955
- }
956
- if (s1 !== peg$FAILED) {
957
- s2 = peg$parse_();
958
- if (s2 !== peg$FAILED) {
959
- if (input.charCodeAt(peg$currPos) === 44) {
960
- s3 = peg$c7;
961
- peg$currPos++;
962
- } else {
963
- s3 = peg$FAILED;
964
- if (peg$silentFails === 0) { peg$fail(peg$c8); }
965
- }
966
- if (s3 !== peg$FAILED) {
967
- s4 = peg$parse_();
968
- if (s4 !== peg$FAILED) {
969
- s5 = peg$parsepluralStyle();
970
- if (s5 !== peg$FAILED) {
971
- peg$savedPos = s0;
972
- s1 = peg$c21(s5);
973
- s0 = s1;
974
- } else {
975
- peg$currPos = s0;
976
- s0 = peg$FAILED;
977
- }
743
+ function peg$parsepluralFormat() {
744
+ var s0, s1, s2, s3, s4, s5;
745
+
746
+ s0 = peg$currPos;
747
+ if (input.substr(peg$currPos, 6) === peg$c18) {
748
+ s1 = peg$c18;
749
+ peg$currPos += 6;
750
+ } else {
751
+ s1 = peg$FAILED;
752
+ if (peg$silentFails === 0) { peg$fail(peg$c19); }
753
+ }
754
+ if (s1 !== peg$FAILED) {
755
+ s2 = peg$parse_();
756
+ if (s2 !== peg$FAILED) {
757
+ if (input.charCodeAt(peg$currPos) === 44) {
758
+ s3 = peg$c6;
759
+ peg$currPos++;
760
+ } else {
761
+ s3 = peg$FAILED;
762
+ if (peg$silentFails === 0) { peg$fail(peg$c7); }
763
+ }
764
+ if (s3 !== peg$FAILED) {
765
+ s4 = peg$parse_();
766
+ if (s4 !== peg$FAILED) {
767
+ s5 = peg$parsepluralStyle();
768
+ if (s5 !== peg$FAILED) {
769
+ peg$savedPos = s0;
770
+ s1 = peg$c20(s5);
771
+ s0 = s1;
978
772
  } else {
979
773
  peg$currPos = s0;
980
774
  s0 = peg$FAILED;
@@ -991,43 +785,43 @@
991
785
  peg$currPos = s0;
992
786
  s0 = peg$FAILED;
993
787
  }
994
-
995
- return s0;
788
+ } else {
789
+ peg$currPos = s0;
790
+ s0 = peg$FAILED;
996
791
  }
997
792
 
998
- function peg$parseselectOrdinalFormat() {
999
- var s0, s1, s2, s3, s4, s5;
793
+ return s0;
794
+ }
1000
795
 
1001
- s0 = peg$currPos;
1002
- if (input.substr(peg$currPos, 13) === peg$c22) {
1003
- s1 = peg$c22;
1004
- peg$currPos += 13;
1005
- } else {
1006
- s1 = peg$FAILED;
1007
- if (peg$silentFails === 0) { peg$fail(peg$c23); }
1008
- }
1009
- if (s1 !== peg$FAILED) {
1010
- s2 = peg$parse_();
1011
- if (s2 !== peg$FAILED) {
1012
- if (input.charCodeAt(peg$currPos) === 44) {
1013
- s3 = peg$c7;
1014
- peg$currPos++;
1015
- } else {
1016
- s3 = peg$FAILED;
1017
- if (peg$silentFails === 0) { peg$fail(peg$c8); }
1018
- }
1019
- if (s3 !== peg$FAILED) {
1020
- s4 = peg$parse_();
1021
- if (s4 !== peg$FAILED) {
1022
- s5 = peg$parsepluralStyle();
1023
- if (s5 !== peg$FAILED) {
1024
- peg$savedPos = s0;
1025
- s1 = peg$c24(s5);
1026
- s0 = s1;
1027
- } else {
1028
- peg$currPos = s0;
1029
- s0 = peg$FAILED;
1030
- }
796
+ function peg$parseselectOrdinalFormat() {
797
+ var s0, s1, s2, s3, s4, s5;
798
+
799
+ s0 = peg$currPos;
800
+ if (input.substr(peg$currPos, 13) === peg$c21) {
801
+ s1 = peg$c21;
802
+ peg$currPos += 13;
803
+ } else {
804
+ s1 = peg$FAILED;
805
+ if (peg$silentFails === 0) { peg$fail(peg$c22); }
806
+ }
807
+ if (s1 !== peg$FAILED) {
808
+ s2 = peg$parse_();
809
+ if (s2 !== peg$FAILED) {
810
+ if (input.charCodeAt(peg$currPos) === 44) {
811
+ s3 = peg$c6;
812
+ peg$currPos++;
813
+ } else {
814
+ s3 = peg$FAILED;
815
+ if (peg$silentFails === 0) { peg$fail(peg$c7); }
816
+ }
817
+ if (s3 !== peg$FAILED) {
818
+ s4 = peg$parse_();
819
+ if (s4 !== peg$FAILED) {
820
+ s5 = peg$parsepluralStyle();
821
+ if (s5 !== peg$FAILED) {
822
+ peg$savedPos = s0;
823
+ s1 = peg$c23(s5);
824
+ s0 = s1;
1031
825
  } else {
1032
826
  peg$currPos = s0;
1033
827
  s0 = peg$FAILED;
@@ -1044,52 +838,52 @@
1044
838
  peg$currPos = s0;
1045
839
  s0 = peg$FAILED;
1046
840
  }
1047
-
1048
- return s0;
841
+ } else {
842
+ peg$currPos = s0;
843
+ s0 = peg$FAILED;
1049
844
  }
1050
845
 
1051
- function peg$parseselectFormat() {
1052
- var s0, s1, s2, s3, s4, s5, s6;
846
+ return s0;
847
+ }
1053
848
 
1054
- s0 = peg$currPos;
1055
- if (input.substr(peg$currPos, 6) === peg$c25) {
1056
- s1 = peg$c25;
1057
- peg$currPos += 6;
1058
- } else {
1059
- s1 = peg$FAILED;
1060
- if (peg$silentFails === 0) { peg$fail(peg$c26); }
1061
- }
1062
- if (s1 !== peg$FAILED) {
1063
- s2 = peg$parse_();
1064
- if (s2 !== peg$FAILED) {
1065
- if (input.charCodeAt(peg$currPos) === 44) {
1066
- s3 = peg$c7;
1067
- peg$currPos++;
1068
- } else {
1069
- s3 = peg$FAILED;
1070
- if (peg$silentFails === 0) { peg$fail(peg$c8); }
1071
- }
1072
- if (s3 !== peg$FAILED) {
1073
- s4 = peg$parse_();
1074
- if (s4 !== peg$FAILED) {
1075
- s5 = [];
1076
- s6 = peg$parseoptionalFormatPattern();
1077
- if (s6 !== peg$FAILED) {
1078
- while (s6 !== peg$FAILED) {
1079
- s5.push(s6);
1080
- s6 = peg$parseoptionalFormatPattern();
1081
- }
1082
- } else {
1083
- s5 = peg$FAILED;
1084
- }
1085
- if (s5 !== peg$FAILED) {
1086
- peg$savedPos = s0;
1087
- s1 = peg$c27(s5);
1088
- s0 = s1;
1089
- } else {
1090
- peg$currPos = s0;
1091
- s0 = peg$FAILED;
849
+ function peg$parseselectFormat() {
850
+ var s0, s1, s2, s3, s4, s5, s6;
851
+
852
+ s0 = peg$currPos;
853
+ if (input.substr(peg$currPos, 6) === peg$c24) {
854
+ s1 = peg$c24;
855
+ peg$currPos += 6;
856
+ } else {
857
+ s1 = peg$FAILED;
858
+ if (peg$silentFails === 0) { peg$fail(peg$c25); }
859
+ }
860
+ if (s1 !== peg$FAILED) {
861
+ s2 = peg$parse_();
862
+ if (s2 !== peg$FAILED) {
863
+ if (input.charCodeAt(peg$currPos) === 44) {
864
+ s3 = peg$c6;
865
+ peg$currPos++;
866
+ } else {
867
+ s3 = peg$FAILED;
868
+ if (peg$silentFails === 0) { peg$fail(peg$c7); }
869
+ }
870
+ if (s3 !== peg$FAILED) {
871
+ s4 = peg$parse_();
872
+ if (s4 !== peg$FAILED) {
873
+ s5 = [];
874
+ s6 = peg$parseoptionalFormatPattern();
875
+ if (s6 !== peg$FAILED) {
876
+ while (s6 !== peg$FAILED) {
877
+ s5.push(s6);
878
+ s6 = peg$parseoptionalFormatPattern();
1092
879
  }
880
+ } else {
881
+ s5 = peg$FAILED;
882
+ }
883
+ if (s5 !== peg$FAILED) {
884
+ peg$savedPos = s0;
885
+ s1 = peg$c26(s5);
886
+ s0 = s1;
1093
887
  } else {
1094
888
  peg$currPos = s0;
1095
889
  s0 = peg$FAILED;
@@ -1106,82 +900,82 @@
1106
900
  peg$currPos = s0;
1107
901
  s0 = peg$FAILED;
1108
902
  }
1109
-
1110
- return s0;
903
+ } else {
904
+ peg$currPos = s0;
905
+ s0 = peg$FAILED;
1111
906
  }
1112
907
 
1113
- function peg$parseselector() {
1114
- var s0, s1, s2, s3;
908
+ return s0;
909
+ }
1115
910
 
1116
- s0 = peg$currPos;
1117
- s1 = peg$currPos;
1118
- if (input.charCodeAt(peg$currPos) === 61) {
1119
- s2 = peg$c28;
1120
- peg$currPos++;
1121
- } else {
1122
- s2 = peg$FAILED;
1123
- if (peg$silentFails === 0) { peg$fail(peg$c29); }
1124
- }
1125
- if (s2 !== peg$FAILED) {
1126
- s3 = peg$parsenumber();
1127
- if (s3 !== peg$FAILED) {
1128
- s2 = [s2, s3];
1129
- s1 = s2;
1130
- } else {
1131
- peg$currPos = s1;
1132
- s1 = peg$FAILED;
1133
- }
911
+ function peg$parseselector() {
912
+ var s0, s1, s2, s3;
913
+
914
+ s0 = peg$currPos;
915
+ s1 = peg$currPos;
916
+ if (input.charCodeAt(peg$currPos) === 61) {
917
+ s2 = peg$c27;
918
+ peg$currPos++;
919
+ } else {
920
+ s2 = peg$FAILED;
921
+ if (peg$silentFails === 0) { peg$fail(peg$c28); }
922
+ }
923
+ if (s2 !== peg$FAILED) {
924
+ s3 = peg$parsenumber();
925
+ if (s3 !== peg$FAILED) {
926
+ s2 = [s2, s3];
927
+ s1 = s2;
1134
928
  } else {
1135
929
  peg$currPos = s1;
1136
930
  s1 = peg$FAILED;
1137
931
  }
1138
- if (s1 !== peg$FAILED) {
1139
- s0 = input.substring(s0, peg$currPos);
1140
- } else {
1141
- s0 = s1;
1142
- }
1143
- if (s0 === peg$FAILED) {
1144
- s0 = peg$parsechars();
1145
- }
1146
-
1147
- return s0;
932
+ } else {
933
+ peg$currPos = s1;
934
+ s1 = peg$FAILED;
935
+ }
936
+ if (s1 !== peg$FAILED) {
937
+ s0 = input.substring(s0, peg$currPos);
938
+ } else {
939
+ s0 = s1;
940
+ }
941
+ if (s0 === peg$FAILED) {
942
+ s0 = peg$parsechars();
1148
943
  }
1149
944
 
1150
- function peg$parseoptionalFormatPattern() {
1151
- var s0, s1, s2, s3, s4, s5, s6;
945
+ return s0;
946
+ }
1152
947
 
1153
- s0 = peg$currPos;
1154
- s1 = peg$parse_();
1155
- if (s1 !== peg$FAILED) {
1156
- s2 = peg$parseselector();
1157
- if (s2 !== peg$FAILED) {
1158
- s3 = peg$parse_();
1159
- if (s3 !== peg$FAILED) {
1160
- if (input.charCodeAt(peg$currPos) === 123) {
1161
- s4 = peg$c5;
1162
- peg$currPos++;
1163
- } else {
1164
- s4 = peg$FAILED;
1165
- if (peg$silentFails === 0) { peg$fail(peg$c6); }
1166
- }
1167
- if (s4 !== peg$FAILED) {
1168
- s5 = peg$parsemessageFormatPattern();
1169
- if (s5 !== peg$FAILED) {
1170
- if (input.charCodeAt(peg$currPos) === 125) {
1171
- s6 = peg$c9;
1172
- peg$currPos++;
1173
- } else {
1174
- s6 = peg$FAILED;
1175
- if (peg$silentFails === 0) { peg$fail(peg$c10); }
1176
- }
1177
- if (s6 !== peg$FAILED) {
1178
- peg$savedPos = s0;
1179
- s1 = peg$c30(s2, s5);
1180
- s0 = s1;
1181
- } else {
1182
- peg$currPos = s0;
1183
- s0 = peg$FAILED;
1184
- }
948
+ function peg$parseoptionalFormatPattern() {
949
+ var s0, s1, s2, s3, s4, s5, s6;
950
+
951
+ s0 = peg$currPos;
952
+ s1 = peg$parse_();
953
+ if (s1 !== peg$FAILED) {
954
+ s2 = peg$parseselector();
955
+ if (s2 !== peg$FAILED) {
956
+ s3 = peg$parse_();
957
+ if (s3 !== peg$FAILED) {
958
+ if (input.charCodeAt(peg$currPos) === 123) {
959
+ s4 = peg$c4;
960
+ peg$currPos++;
961
+ } else {
962
+ s4 = peg$FAILED;
963
+ if (peg$silentFails === 0) { peg$fail(peg$c5); }
964
+ }
965
+ if (s4 !== peg$FAILED) {
966
+ s5 = peg$parsemessageFormatPattern();
967
+ if (s5 !== peg$FAILED) {
968
+ if (input.charCodeAt(peg$currPos) === 125) {
969
+ s6 = peg$c8;
970
+ peg$currPos++;
971
+ } else {
972
+ s6 = peg$FAILED;
973
+ if (peg$silentFails === 0) { peg$fail(peg$c9); }
974
+ }
975
+ if (s6 !== peg$FAILED) {
976
+ peg$savedPos = s0;
977
+ s1 = peg$c29(s2, s5);
978
+ s0 = s1;
1185
979
  } else {
1186
980
  peg$currPos = s0;
1187
981
  s0 = peg$FAILED;
@@ -1202,33 +996,33 @@
1202
996
  peg$currPos = s0;
1203
997
  s0 = peg$FAILED;
1204
998
  }
1205
-
1206
- return s0;
999
+ } else {
1000
+ peg$currPos = s0;
1001
+ s0 = peg$FAILED;
1207
1002
  }
1208
1003
 
1209
- function peg$parseoffset() {
1210
- var s0, s1, s2, s3;
1004
+ return s0;
1005
+ }
1211
1006
 
1212
- s0 = peg$currPos;
1213
- if (input.substr(peg$currPos, 7) === peg$c31) {
1214
- s1 = peg$c31;
1215
- peg$currPos += 7;
1216
- } else {
1217
- s1 = peg$FAILED;
1218
- if (peg$silentFails === 0) { peg$fail(peg$c32); }
1219
- }
1220
- if (s1 !== peg$FAILED) {
1221
- s2 = peg$parse_();
1222
- if (s2 !== peg$FAILED) {
1223
- s3 = peg$parsenumber();
1224
- if (s3 !== peg$FAILED) {
1225
- peg$savedPos = s0;
1226
- s1 = peg$c33(s3);
1227
- s0 = s1;
1228
- } else {
1229
- peg$currPos = s0;
1230
- s0 = peg$FAILED;
1231
- }
1007
+ function peg$parseoffset() {
1008
+ var s0, s1, s2, s3;
1009
+
1010
+ s0 = peg$currPos;
1011
+ if (input.substr(peg$currPos, 7) === peg$c30) {
1012
+ s1 = peg$c30;
1013
+ peg$currPos += 7;
1014
+ } else {
1015
+ s1 = peg$FAILED;
1016
+ if (peg$silentFails === 0) { peg$fail(peg$c31); }
1017
+ }
1018
+ if (s1 !== peg$FAILED) {
1019
+ s2 = peg$parse_();
1020
+ if (s2 !== peg$FAILED) {
1021
+ s3 = peg$parsenumber();
1022
+ if (s3 !== peg$FAILED) {
1023
+ peg$savedPos = s0;
1024
+ s1 = peg$c32(s3);
1025
+ s0 = s1;
1232
1026
  } else {
1233
1027
  peg$currPos = s0;
1234
1028
  s0 = peg$FAILED;
@@ -1237,39 +1031,39 @@
1237
1031
  peg$currPos = s0;
1238
1032
  s0 = peg$FAILED;
1239
1033
  }
1240
-
1241
- return s0;
1034
+ } else {
1035
+ peg$currPos = s0;
1036
+ s0 = peg$FAILED;
1242
1037
  }
1243
1038
 
1244
- function peg$parsepluralStyle() {
1245
- var s0, s1, s2, s3, s4;
1039
+ return s0;
1040
+ }
1246
1041
 
1247
- s0 = peg$currPos;
1248
- s1 = peg$parseoffset();
1249
- if (s1 === peg$FAILED) {
1250
- s1 = null;
1251
- }
1252
- if (s1 !== peg$FAILED) {
1253
- s2 = peg$parse_();
1254
- if (s2 !== peg$FAILED) {
1255
- s3 = [];
1256
- s4 = peg$parseoptionalFormatPattern();
1257
- if (s4 !== peg$FAILED) {
1258
- while (s4 !== peg$FAILED) {
1259
- s3.push(s4);
1260
- s4 = peg$parseoptionalFormatPattern();
1261
- }
1262
- } else {
1263
- s3 = peg$FAILED;
1264
- }
1265
- if (s3 !== peg$FAILED) {
1266
- peg$savedPos = s0;
1267
- s1 = peg$c34(s1, s3);
1268
- s0 = s1;
1269
- } else {
1270
- peg$currPos = s0;
1271
- s0 = peg$FAILED;
1042
+ function peg$parsepluralStyle() {
1043
+ var s0, s1, s2, s3, s4;
1044
+
1045
+ s0 = peg$currPos;
1046
+ s1 = peg$parseoffset();
1047
+ if (s1 === peg$FAILED) {
1048
+ s1 = null;
1049
+ }
1050
+ if (s1 !== peg$FAILED) {
1051
+ s2 = peg$parse_();
1052
+ if (s2 !== peg$FAILED) {
1053
+ s3 = [];
1054
+ s4 = peg$parseoptionalFormatPattern();
1055
+ if (s4 !== peg$FAILED) {
1056
+ while (s4 !== peg$FAILED) {
1057
+ s3.push(s4);
1058
+ s4 = peg$parseoptionalFormatPattern();
1272
1059
  }
1060
+ } else {
1061
+ s3 = peg$FAILED;
1062
+ }
1063
+ if (s3 !== peg$FAILED) {
1064
+ peg$savedPos = s0;
1065
+ s1 = peg$c33(s1, s3);
1066
+ s0 = s1;
1273
1067
  } else {
1274
1068
  peg$currPos = s0;
1275
1069
  s0 = peg$FAILED;
@@ -1278,226 +1072,361 @@
1278
1072
  peg$currPos = s0;
1279
1073
  s0 = peg$FAILED;
1280
1074
  }
1075
+ } else {
1076
+ peg$currPos = s0;
1077
+ s0 = peg$FAILED;
1078
+ }
1079
+
1080
+ return s0;
1081
+ }
1082
+
1083
+ function peg$parsews() {
1084
+ var s0, s1;
1281
1085
 
1282
- return s0;
1086
+ peg$silentFails++;
1087
+ s0 = [];
1088
+ if (peg$c35.test(input.charAt(peg$currPos))) {
1089
+ s1 = input.charAt(peg$currPos);
1090
+ peg$currPos++;
1091
+ } else {
1092
+ s1 = peg$FAILED;
1093
+ if (peg$silentFails === 0) { peg$fail(peg$c36); }
1283
1094
  }
1095
+ if (s1 !== peg$FAILED) {
1096
+ while (s1 !== peg$FAILED) {
1097
+ s0.push(s1);
1098
+ if (peg$c35.test(input.charAt(peg$currPos))) {
1099
+ s1 = input.charAt(peg$currPos);
1100
+ peg$currPos++;
1101
+ } else {
1102
+ s1 = peg$FAILED;
1103
+ if (peg$silentFails === 0) { peg$fail(peg$c36); }
1104
+ }
1105
+ }
1106
+ } else {
1107
+ s0 = peg$FAILED;
1108
+ }
1109
+ peg$silentFails--;
1110
+ if (s0 === peg$FAILED) {
1111
+ s1 = peg$FAILED;
1112
+ if (peg$silentFails === 0) { peg$fail(peg$c34); }
1113
+ }
1114
+
1115
+ return s0;
1116
+ }
1117
+
1118
+ function peg$parse_() {
1119
+ var s0, s1, s2;
1120
+
1121
+ peg$silentFails++;
1122
+ s0 = peg$currPos;
1123
+ s1 = [];
1124
+ s2 = peg$parsews();
1125
+ while (s2 !== peg$FAILED) {
1126
+ s1.push(s2);
1127
+ s2 = peg$parsews();
1128
+ }
1129
+ if (s1 !== peg$FAILED) {
1130
+ s0 = input.substring(s0, peg$currPos);
1131
+ } else {
1132
+ s0 = s1;
1133
+ }
1134
+ peg$silentFails--;
1135
+ if (s0 === peg$FAILED) {
1136
+ s1 = peg$FAILED;
1137
+ if (peg$silentFails === 0) { peg$fail(peg$c37); }
1138
+ }
1139
+
1140
+ return s0;
1141
+ }
1142
+
1143
+ function peg$parsedigit() {
1144
+ var s0;
1145
+
1146
+ if (peg$c38.test(input.charAt(peg$currPos))) {
1147
+ s0 = input.charAt(peg$currPos);
1148
+ peg$currPos++;
1149
+ } else {
1150
+ s0 = peg$FAILED;
1151
+ if (peg$silentFails === 0) { peg$fail(peg$c39); }
1152
+ }
1153
+
1154
+ return s0;
1155
+ }
1156
+
1157
+ function peg$parsehexDigit() {
1158
+ var s0;
1159
+
1160
+ if (peg$c40.test(input.charAt(peg$currPos))) {
1161
+ s0 = input.charAt(peg$currPos);
1162
+ peg$currPos++;
1163
+ } else {
1164
+ s0 = peg$FAILED;
1165
+ if (peg$silentFails === 0) { peg$fail(peg$c41); }
1166
+ }
1167
+
1168
+ return s0;
1169
+ }
1284
1170
 
1285
- function peg$parsews() {
1286
- var s0, s1;
1171
+ function peg$parsenumber() {
1172
+ var s0, s1, s2, s3, s4, s5;
1287
1173
 
1288
- peg$silentFails++;
1289
- s0 = [];
1290
- if (peg$c36.test(input.charAt(peg$currPos))) {
1291
- s1 = input.charAt(peg$currPos);
1174
+ s0 = peg$currPos;
1175
+ if (input.charCodeAt(peg$currPos) === 48) {
1176
+ s1 = peg$c42;
1177
+ peg$currPos++;
1178
+ } else {
1179
+ s1 = peg$FAILED;
1180
+ if (peg$silentFails === 0) { peg$fail(peg$c43); }
1181
+ }
1182
+ if (s1 === peg$FAILED) {
1183
+ s1 = peg$currPos;
1184
+ s2 = peg$currPos;
1185
+ if (peg$c44.test(input.charAt(peg$currPos))) {
1186
+ s3 = input.charAt(peg$currPos);
1292
1187
  peg$currPos++;
1293
1188
  } else {
1294
- s1 = peg$FAILED;
1295
- if (peg$silentFails === 0) { peg$fail(peg$c37); }
1189
+ s3 = peg$FAILED;
1190
+ if (peg$silentFails === 0) { peg$fail(peg$c45); }
1296
1191
  }
1297
- if (s1 !== peg$FAILED) {
1298
- while (s1 !== peg$FAILED) {
1299
- s0.push(s1);
1300
- if (peg$c36.test(input.charAt(peg$currPos))) {
1301
- s1 = input.charAt(peg$currPos);
1302
- peg$currPos++;
1303
- } else {
1304
- s1 = peg$FAILED;
1305
- if (peg$silentFails === 0) { peg$fail(peg$c37); }
1306
- }
1192
+ if (s3 !== peg$FAILED) {
1193
+ s4 = [];
1194
+ s5 = peg$parsedigit();
1195
+ while (s5 !== peg$FAILED) {
1196
+ s4.push(s5);
1197
+ s5 = peg$parsedigit();
1198
+ }
1199
+ if (s4 !== peg$FAILED) {
1200
+ s3 = [s3, s4];
1201
+ s2 = s3;
1202
+ } else {
1203
+ peg$currPos = s2;
1204
+ s2 = peg$FAILED;
1307
1205
  }
1308
1206
  } else {
1309
- s0 = peg$FAILED;
1207
+ peg$currPos = s2;
1208
+ s2 = peg$FAILED;
1310
1209
  }
1311
- peg$silentFails--;
1312
- if (s0 === peg$FAILED) {
1313
- s1 = peg$FAILED;
1314
- if (peg$silentFails === 0) { peg$fail(peg$c35); }
1210
+ if (s2 !== peg$FAILED) {
1211
+ s1 = input.substring(s1, peg$currPos);
1212
+ } else {
1213
+ s1 = s2;
1315
1214
  }
1316
-
1317
- return s0;
1318
1215
  }
1216
+ if (s1 !== peg$FAILED) {
1217
+ peg$savedPos = s0;
1218
+ s1 = peg$c46(s1);
1219
+ }
1220
+ s0 = s1;
1319
1221
 
1320
- function peg$parse_() {
1321
- var s0, s1, s2;
1222
+ return s0;
1223
+ }
1322
1224
 
1323
- peg$silentFails++;
1324
- s0 = peg$currPos;
1325
- s1 = [];
1326
- s2 = peg$parsews();
1327
- while (s2 !== peg$FAILED) {
1328
- s1.push(s2);
1329
- s2 = peg$parsews();
1330
- }
1331
- if (s1 !== peg$FAILED) {
1332
- s0 = input.substring(s0, peg$currPos);
1333
- } else {
1334
- s0 = s1;
1335
- }
1336
- peg$silentFails--;
1337
- if (s0 === peg$FAILED) {
1338
- s1 = peg$FAILED;
1339
- if (peg$silentFails === 0) { peg$fail(peg$c38); }
1340
- }
1225
+ function peg$parsequoteEscapedChar() {
1226
+ var s0, s1, s2;
1341
1227
 
1342
- return s0;
1228
+ s0 = peg$currPos;
1229
+ s1 = peg$currPos;
1230
+ peg$silentFails++;
1231
+ if (input.charCodeAt(peg$currPos) === 39) {
1232
+ s2 = peg$c47;
1233
+ peg$currPos++;
1234
+ } else {
1235
+ s2 = peg$FAILED;
1236
+ if (peg$silentFails === 0) { peg$fail(peg$c48); }
1343
1237
  }
1344
-
1345
- function peg$parsedigit() {
1346
- var s0;
1347
-
1348
- if (peg$c39.test(input.charAt(peg$currPos))) {
1349
- s0 = input.charAt(peg$currPos);
1238
+ if (s2 === peg$FAILED) {
1239
+ if (peg$c49.test(input.charAt(peg$currPos))) {
1240
+ s2 = input.charAt(peg$currPos);
1350
1241
  peg$currPos++;
1351
1242
  } else {
1352
- s0 = peg$FAILED;
1353
- if (peg$silentFails === 0) { peg$fail(peg$c40); }
1243
+ s2 = peg$FAILED;
1244
+ if (peg$silentFails === 0) { peg$fail(peg$c50); }
1354
1245
  }
1355
-
1356
- return s0;
1357
1246
  }
1358
-
1359
- function peg$parsehexDigit() {
1360
- var s0;
1361
-
1362
- if (peg$c41.test(input.charAt(peg$currPos))) {
1363
- s0 = input.charAt(peg$currPos);
1247
+ peg$silentFails--;
1248
+ if (s2 === peg$FAILED) {
1249
+ s1 = void 0;
1250
+ } else {
1251
+ peg$currPos = s1;
1252
+ s1 = peg$FAILED;
1253
+ }
1254
+ if (s1 !== peg$FAILED) {
1255
+ if (input.length > peg$currPos) {
1256
+ s2 = input.charAt(peg$currPos);
1364
1257
  peg$currPos++;
1365
1258
  } else {
1259
+ s2 = peg$FAILED;
1260
+ if (peg$silentFails === 0) { peg$fail(peg$c51); }
1261
+ }
1262
+ if (s2 !== peg$FAILED) {
1263
+ peg$savedPos = s0;
1264
+ s1 = peg$c52(s2);
1265
+ s0 = s1;
1266
+ } else {
1267
+ peg$currPos = s0;
1366
1268
  s0 = peg$FAILED;
1367
- if (peg$silentFails === 0) { peg$fail(peg$c42); }
1368
1269
  }
1369
-
1370
- return s0;
1270
+ } else {
1271
+ peg$currPos = s0;
1272
+ s0 = peg$FAILED;
1371
1273
  }
1372
-
1373
- function peg$parsenumber() {
1374
- var s0, s1, s2, s3, s4, s5;
1375
-
1274
+ if (s0 === peg$FAILED) {
1376
1275
  s0 = peg$currPos;
1377
- if (input.charCodeAt(peg$currPos) === 48) {
1378
- s1 = peg$c43;
1276
+ if (input.charCodeAt(peg$currPos) === 39) {
1277
+ s1 = peg$c47;
1379
1278
  peg$currPos++;
1380
1279
  } else {
1381
1280
  s1 = peg$FAILED;
1382
- if (peg$silentFails === 0) { peg$fail(peg$c44); }
1281
+ if (peg$silentFails === 0) { peg$fail(peg$c48); }
1383
1282
  }
1384
- if (s1 === peg$FAILED) {
1385
- s1 = peg$currPos;
1386
- s2 = peg$currPos;
1387
- if (peg$c45.test(input.charAt(peg$currPos))) {
1388
- s3 = input.charAt(peg$currPos);
1389
- peg$currPos++;
1390
- } else {
1391
- s3 = peg$FAILED;
1392
- if (peg$silentFails === 0) { peg$fail(peg$c46); }
1393
- }
1394
- if (s3 !== peg$FAILED) {
1395
- s4 = [];
1396
- s5 = peg$parsedigit();
1397
- while (s5 !== peg$FAILED) {
1398
- s4.push(s5);
1399
- s5 = peg$parsedigit();
1400
- }
1401
- if (s4 !== peg$FAILED) {
1402
- s3 = [s3, s4];
1403
- s2 = s3;
1404
- } else {
1405
- peg$currPos = s2;
1406
- s2 = peg$FAILED;
1407
- }
1408
- } else {
1409
- peg$currPos = s2;
1410
- s2 = peg$FAILED;
1411
- }
1283
+ if (s1 !== peg$FAILED) {
1284
+ s2 = peg$parseescape();
1412
1285
  if (s2 !== peg$FAILED) {
1413
- s1 = input.substring(s1, peg$currPos);
1286
+ peg$savedPos = s0;
1287
+ s1 = peg$c53(s2);
1288
+ s0 = s1;
1414
1289
  } else {
1415
- s1 = s2;
1290
+ peg$currPos = s0;
1291
+ s0 = peg$FAILED;
1416
1292
  }
1293
+ } else {
1294
+ peg$currPos = s0;
1295
+ s0 = peg$FAILED;
1417
1296
  }
1418
- if (s1 !== peg$FAILED) {
1419
- peg$savedPos = s0;
1420
- s1 = peg$c47(s1);
1421
- }
1422
- s0 = s1;
1297
+ }
1423
1298
 
1424
- return s0;
1299
+ return s0;
1300
+ }
1301
+
1302
+ function peg$parseapostrophe() {
1303
+ var s0;
1304
+
1305
+ if (input.charCodeAt(peg$currPos) === 39) {
1306
+ s0 = peg$c47;
1307
+ peg$currPos++;
1308
+ } else {
1309
+ s0 = peg$FAILED;
1310
+ if (peg$silentFails === 0) { peg$fail(peg$c48); }
1311
+ }
1312
+
1313
+ return s0;
1314
+ }
1315
+
1316
+ function peg$parseescape() {
1317
+ var s0;
1318
+
1319
+ if (peg$c49.test(input.charAt(peg$currPos))) {
1320
+ s0 = input.charAt(peg$currPos);
1321
+ peg$currPos++;
1322
+ } else {
1323
+ s0 = peg$FAILED;
1324
+ if (peg$silentFails === 0) { peg$fail(peg$c50); }
1425
1325
  }
1326
+ if (s0 === peg$FAILED) {
1327
+ s0 = peg$parseapostrophe();
1328
+ }
1329
+
1330
+ return s0;
1331
+ }
1426
1332
 
1427
- function peg$parsechar() {
1428
- var s0, s1, s2, s3, s4, s5, s6, s7;
1333
+ function peg$parsechar() {
1334
+ var s0, s1, s2, s3, s4, s5, s6, s7;
1429
1335
 
1430
- if (peg$c48.test(input.charAt(peg$currPos))) {
1336
+ s0 = peg$currPos;
1337
+ if (input.charCodeAt(peg$currPos) === 39) {
1338
+ s1 = peg$c47;
1339
+ peg$currPos++;
1340
+ } else {
1341
+ s1 = peg$FAILED;
1342
+ if (peg$silentFails === 0) { peg$fail(peg$c48); }
1343
+ }
1344
+ if (s1 !== peg$FAILED) {
1345
+ s2 = peg$parseapostrophe();
1346
+ if (s2 !== peg$FAILED) {
1347
+ peg$savedPos = s0;
1348
+ s1 = peg$c53(s2);
1349
+ s0 = s1;
1350
+ } else {
1351
+ peg$currPos = s0;
1352
+ s0 = peg$FAILED;
1353
+ }
1354
+ } else {
1355
+ peg$currPos = s0;
1356
+ s0 = peg$FAILED;
1357
+ }
1358
+ if (s0 === peg$FAILED) {
1359
+ if (peg$c54.test(input.charAt(peg$currPos))) {
1431
1360
  s0 = input.charAt(peg$currPos);
1432
1361
  peg$currPos++;
1433
1362
  } else {
1434
1363
  s0 = peg$FAILED;
1435
- if (peg$silentFails === 0) { peg$fail(peg$c49); }
1364
+ if (peg$silentFails === 0) { peg$fail(peg$c55); }
1436
1365
  }
1437
1366
  if (s0 === peg$FAILED) {
1438
1367
  s0 = peg$currPos;
1439
- if (input.substr(peg$currPos, 2) === peg$c50) {
1440
- s1 = peg$c50;
1368
+ if (input.substr(peg$currPos, 2) === peg$c56) {
1369
+ s1 = peg$c56;
1441
1370
  peg$currPos += 2;
1442
1371
  } else {
1443
1372
  s1 = peg$FAILED;
1444
- if (peg$silentFails === 0) { peg$fail(peg$c51); }
1373
+ if (peg$silentFails === 0) { peg$fail(peg$c57); }
1445
1374
  }
1446
1375
  if (s1 !== peg$FAILED) {
1447
1376
  peg$savedPos = s0;
1448
- s1 = peg$c52();
1377
+ s1 = peg$c58();
1449
1378
  }
1450
1379
  s0 = s1;
1451
1380
  if (s0 === peg$FAILED) {
1452
1381
  s0 = peg$currPos;
1453
- if (input.substr(peg$currPos, 2) === peg$c53) {
1454
- s1 = peg$c53;
1382
+ if (input.substr(peg$currPos, 2) === peg$c59) {
1383
+ s1 = peg$c59;
1455
1384
  peg$currPos += 2;
1456
1385
  } else {
1457
1386
  s1 = peg$FAILED;
1458
- if (peg$silentFails === 0) { peg$fail(peg$c54); }
1387
+ if (peg$silentFails === 0) { peg$fail(peg$c60); }
1459
1388
  }
1460
1389
  if (s1 !== peg$FAILED) {
1461
1390
  peg$savedPos = s0;
1462
- s1 = peg$c55();
1391
+ s1 = peg$c61();
1463
1392
  }
1464
1393
  s0 = s1;
1465
1394
  if (s0 === peg$FAILED) {
1466
1395
  s0 = peg$currPos;
1467
- if (input.substr(peg$currPos, 2) === peg$c56) {
1468
- s1 = peg$c56;
1396
+ if (input.substr(peg$currPos, 2) === peg$c62) {
1397
+ s1 = peg$c62;
1469
1398
  peg$currPos += 2;
1470
1399
  } else {
1471
1400
  s1 = peg$FAILED;
1472
- if (peg$silentFails === 0) { peg$fail(peg$c57); }
1401
+ if (peg$silentFails === 0) { peg$fail(peg$c63); }
1473
1402
  }
1474
1403
  if (s1 !== peg$FAILED) {
1475
1404
  peg$savedPos = s0;
1476
- s1 = peg$c58();
1405
+ s1 = peg$c64();
1477
1406
  }
1478
1407
  s0 = s1;
1479
1408
  if (s0 === peg$FAILED) {
1480
1409
  s0 = peg$currPos;
1481
- if (input.substr(peg$currPos, 2) === peg$c59) {
1482
- s1 = peg$c59;
1410
+ if (input.substr(peg$currPos, 2) === peg$c65) {
1411
+ s1 = peg$c65;
1483
1412
  peg$currPos += 2;
1484
1413
  } else {
1485
1414
  s1 = peg$FAILED;
1486
- if (peg$silentFails === 0) { peg$fail(peg$c60); }
1415
+ if (peg$silentFails === 0) { peg$fail(peg$c66); }
1487
1416
  }
1488
1417
  if (s1 !== peg$FAILED) {
1489
1418
  peg$savedPos = s0;
1490
- s1 = peg$c61();
1419
+ s1 = peg$c67();
1491
1420
  }
1492
1421
  s0 = s1;
1493
1422
  if (s0 === peg$FAILED) {
1494
1423
  s0 = peg$currPos;
1495
- if (input.substr(peg$currPos, 2) === peg$c62) {
1496
- s1 = peg$c62;
1424
+ if (input.substr(peg$currPos, 2) === peg$c68) {
1425
+ s1 = peg$c68;
1497
1426
  peg$currPos += 2;
1498
1427
  } else {
1499
1428
  s1 = peg$FAILED;
1500
- if (peg$silentFails === 0) { peg$fail(peg$c63); }
1429
+ if (peg$silentFails === 0) { peg$fail(peg$c69); }
1501
1430
  }
1502
1431
  if (s1 !== peg$FAILED) {
1503
1432
  s2 = peg$currPos;
@@ -1535,7 +1464,7 @@
1535
1464
  }
1536
1465
  if (s2 !== peg$FAILED) {
1537
1466
  peg$savedPos = s0;
1538
- s1 = peg$c64(s2);
1467
+ s1 = peg$c70(s2);
1539
1468
  s0 = s1;
1540
1469
  } else {
1541
1470
  peg$currPos = s0;
@@ -1550,260 +1479,506 @@
1550
1479
  }
1551
1480
  }
1552
1481
  }
1553
-
1554
- return s0;
1555
1482
  }
1556
1483
 
1557
- function peg$parsechars() {
1558
- var s0, s1, s2;
1484
+ return s0;
1485
+ }
1559
1486
 
1560
- s0 = peg$currPos;
1561
- s1 = [];
1562
- s2 = peg$parsechar();
1563
- if (s2 !== peg$FAILED) {
1564
- while (s2 !== peg$FAILED) {
1565
- s1.push(s2);
1566
- s2 = peg$parsechar();
1567
- }
1568
- } else {
1569
- s1 = peg$FAILED;
1570
- }
1571
- if (s1 !== peg$FAILED) {
1572
- peg$savedPos = s0;
1573
- s1 = peg$c65(s1);
1574
- }
1575
- s0 = s1;
1487
+ function peg$parsechars() {
1488
+ var s0, s1, s2;
1576
1489
 
1577
- return s0;
1490
+ s0 = peg$currPos;
1491
+ s1 = [];
1492
+ s2 = peg$parsechar();
1493
+ if (s2 !== peg$FAILED) {
1494
+ while (s2 !== peg$FAILED) {
1495
+ s1.push(s2);
1496
+ s2 = peg$parsechar();
1497
+ }
1498
+ } else {
1499
+ s1 = peg$FAILED;
1500
+ }
1501
+ if (s1 !== peg$FAILED) {
1502
+ peg$savedPos = s0;
1503
+ s1 = peg$c3(s1);
1578
1504
  }
1505
+ s0 = s1;
1579
1506
 
1580
- peg$result = peg$startRuleFunction();
1507
+ return s0;
1508
+ }
1581
1509
 
1582
- if (peg$result !== peg$FAILED && peg$currPos === input.length) {
1583
- return peg$result;
1584
- } else {
1585
- if (peg$result !== peg$FAILED && peg$currPos < input.length) {
1586
- peg$fail(peg$endExpectation());
1587
- }
1510
+ peg$result = peg$startRuleFunction();
1588
1511
 
1589
- throw peg$buildStructuredError(
1590
- peg$maxFailExpected,
1591
- peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
1592
- peg$maxFailPos < input.length
1593
- ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
1594
- : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
1595
- );
1512
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
1513
+ return peg$result;
1514
+ } else {
1515
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
1516
+ peg$fail(peg$endExpectation());
1596
1517
  }
1518
+
1519
+ throw peg$buildStructuredError(
1520
+ peg$maxFailExpected,
1521
+ peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
1522
+ peg$maxFailPos < input.length
1523
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
1524
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
1525
+ );
1597
1526
  }
1527
+ }
1598
1528
 
1529
+ return {
1530
+ SyntaxError: peg$SyntaxError,
1531
+ parse: peg$parse
1532
+ };
1533
+ })();
1534
+
1535
+ /*
1536
+ Copyright (c) 2014, Yahoo! Inc. All rights reserved.
1537
+ Copyrights licensed under the New BSD License.
1538
+ See the accompanying LICENSE file for terms.
1539
+ */
1540
+ var __extends = (undefined && undefined.__extends) || (function () {
1541
+ var extendStatics = function (d, b) {
1542
+ extendStatics = Object.setPrototypeOf ||
1543
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1544
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
1545
+ return extendStatics(d, b);
1546
+ };
1547
+ return function (d, b) {
1548
+ extendStatics(d, b);
1549
+ function __() { this.constructor = d; }
1550
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1551
+ };
1552
+ })();
1553
+ var Compiler = /** @class */ (function () {
1554
+ function Compiler(locales, formats, formatters) {
1555
+ this.locales = [];
1556
+ this.formats = {
1557
+ number: {},
1558
+ date: {},
1559
+ time: {}
1560
+ };
1561
+ this.pluralNumberFormat = null;
1562
+ this.currentPlural = null;
1563
+ this.pluralStack = [];
1564
+ this.locales = locales;
1565
+ this.formats = formats;
1566
+ this.formatters = formatters;
1567
+ }
1568
+ Compiler.prototype.compile = function (ast) {
1569
+ this.pluralStack = [];
1570
+ this.currentPlural = null;
1571
+ this.pluralNumberFormat = null;
1572
+ return this.compileMessage(ast);
1573
+ };
1574
+ Compiler.prototype.compileMessage = function (ast) {
1575
+ var _this = this;
1576
+ if (!(ast && ast.type === 'messageFormatPattern')) {
1577
+ throw new Error('Message AST is not of type: "messageFormatPattern"');
1578
+ }
1579
+ var elements = ast.elements;
1580
+ var pattern = elements
1581
+ .filter(function (el) {
1582
+ return el.type === 'messageTextElement' || el.type === 'argumentElement';
1583
+ })
1584
+ .map(function (el) {
1585
+ return el.type === 'messageTextElement'
1586
+ ? _this.compileMessageText(el)
1587
+ : _this.compileArgument(el);
1588
+ });
1589
+ if (pattern.length !== elements.length) {
1590
+ throw new Error('Message element does not have a valid type');
1591
+ }
1592
+ return pattern;
1593
+ };
1594
+ Compiler.prototype.compileMessageText = function (element) {
1595
+ // When this `element` is part of plural sub-pattern and its value contains
1596
+ // an unescaped '#', use a `PluralOffsetString` helper to properly output
1597
+ // the number with the correct offset in the string.
1598
+ if (this.currentPlural && /(^|[^\\])#/g.test(element.value)) {
1599
+ // Create a cache a NumberFormat instance that can be reused for any
1600
+ // PluralOffsetString instance in this message.
1601
+ if (!this.pluralNumberFormat) {
1602
+ this.pluralNumberFormat = new Intl.NumberFormat(this.locales);
1603
+ }
1604
+ return new PluralOffsetString(this.currentPlural.id, this.currentPlural.format.offset, this.pluralNumberFormat, element.value);
1605
+ }
1606
+ // Unescape the escaped '#'s in the message text.
1607
+ return element.value.replace(/\\#/g, '#');
1608
+ };
1609
+ Compiler.prototype.compileArgument = function (element) {
1610
+ var format = element.format, id = element.id;
1611
+ var formatters = this.formatters;
1612
+ if (!format) {
1613
+ return new StringFormat(id);
1614
+ }
1615
+ var _a = this, formats = _a.formats, locales = _a.locales;
1616
+ switch (format.type) {
1617
+ case 'numberFormat':
1618
+ return {
1619
+ id: id,
1620
+ format: formatters.getNumberFormat(locales, formats.number[format.style]).format
1621
+ };
1622
+ case 'dateFormat':
1623
+ return {
1624
+ id: id,
1625
+ format: formatters.getDateTimeFormat(locales, formats.date[format.style]).format
1626
+ };
1627
+ case 'timeFormat':
1628
+ return {
1629
+ id: id,
1630
+ format: formatters.getDateTimeFormat(locales, formats.time[format.style]).format
1631
+ };
1632
+ case 'pluralFormat':
1633
+ return new PluralFormat(id, format.offset, this.compileOptions(element), formatters.getPluralRules(locales, {
1634
+ type: format.ordinal ? 'ordinal' : 'cardinal'
1635
+ }));
1636
+ case 'selectFormat':
1637
+ return new SelectFormat(id, this.compileOptions(element));
1638
+ default:
1639
+ throw new Error('Message element does not have a valid format type');
1640
+ }
1641
+ };
1642
+ Compiler.prototype.compileOptions = function (element) {
1643
+ var _this = this;
1644
+ var format = element.format;
1645
+ var options = format.options;
1646
+ // Save the current plural element, if any, then set it to a new value when
1647
+ // compiling the options sub-patterns. This conforms the spec's algorithm
1648
+ // for handling `"#"` syntax in message text.
1649
+ this.pluralStack.push(this.currentPlural);
1650
+ this.currentPlural = format.type === 'pluralFormat' ? element : null;
1651
+ var optionsHash = options.reduce(function (all, option) {
1652
+ // Compile the sub-pattern and save it under the options's selector.
1653
+ all[option.selector] = _this.compileMessage(option.value);
1654
+ return all;
1655
+ }, {});
1656
+ // Pop the plural stack to put back the original current plural value.
1657
+ this.currentPlural = this.pluralStack.pop();
1658
+ return optionsHash;
1659
+ };
1660
+ return Compiler;
1661
+ }());
1662
+ // -- Compiler Helper Classes --------------------------------------------------
1663
+ var Formatter = /** @class */ (function () {
1664
+ function Formatter(id) {
1665
+ this.id = id;
1666
+ }
1667
+ return Formatter;
1668
+ }());
1669
+ var StringFormat = /** @class */ (function (_super) {
1670
+ __extends(StringFormat, _super);
1671
+ function StringFormat() {
1672
+ return _super !== null && _super.apply(this, arguments) || this;
1673
+ }
1674
+ StringFormat.prototype.format = function (value) {
1675
+ if (!value && typeof value !== 'number') {
1676
+ return '';
1677
+ }
1678
+ return typeof value === 'string' ? value : String(value);
1679
+ };
1680
+ return StringFormat;
1681
+ }(Formatter));
1682
+ var PluralFormat = /** @class */ (function () {
1683
+ function PluralFormat(id, offset, options, pluralRules) {
1684
+ this.id = id;
1685
+ this.offset = offset;
1686
+ this.options = options;
1687
+ this.pluralRules = pluralRules;
1688
+ }
1689
+ PluralFormat.prototype.getOption = function (value) {
1690
+ var options = this.options;
1691
+ var option = options['=' + value] ||
1692
+ options[this.pluralRules.select(value - this.offset)];
1693
+ return option || options.other;
1694
+ };
1695
+ return PluralFormat;
1696
+ }());
1697
+ var PluralOffsetString = /** @class */ (function (_super) {
1698
+ __extends(PluralOffsetString, _super);
1699
+ function PluralOffsetString(id, offset, numberFormat, string) {
1700
+ var _this = _super.call(this, id) || this;
1701
+ _this.offset = offset;
1702
+ _this.numberFormat = numberFormat;
1703
+ _this.string = string;
1704
+ return _this;
1705
+ }
1706
+ PluralOffsetString.prototype.format = function (value) {
1707
+ var number = this.numberFormat.format(value - this.offset);
1708
+ return this.string
1709
+ .replace(/(^|[^\\])#/g, '$1' + number)
1710
+ .replace(/\\#/g, '#');
1711
+ };
1712
+ return PluralOffsetString;
1713
+ }(Formatter));
1714
+ var SelectFormat = /** @class */ (function () {
1715
+ function SelectFormat(id, options) {
1716
+ this.id = id;
1717
+ this.options = options;
1718
+ }
1719
+ SelectFormat.prototype.getOption = function (value) {
1720
+ var options = this.options;
1721
+ return options[value] || options.other;
1722
+ };
1723
+ return SelectFormat;
1724
+ }());
1725
+ function isSelectOrPluralFormat(f) {
1726
+ return !!f.options;
1727
+ }
1728
+
1729
+ /*
1730
+ Copyright (c) 2014, Yahoo! Inc. All rights reserved.
1731
+ Copyrights licensed under the New BSD License.
1732
+ See the accompanying LICENSE file for terms.
1733
+ */
1734
+ var __extends$1 = (undefined && undefined.__extends) || (function () {
1735
+ var extendStatics = function (d, b) {
1736
+ extendStatics = Object.setPrototypeOf ||
1737
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1738
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
1739
+ return extendStatics(d, b);
1740
+ };
1741
+ return function (d, b) {
1742
+ extendStatics(d, b);
1743
+ function __() { this.constructor = d; }
1744
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1745
+ };
1746
+ })();
1747
+ var __assign = (undefined && undefined.__assign) || function () {
1748
+ __assign = Object.assign || function(t) {
1749
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1750
+ s = arguments[i];
1751
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1752
+ t[p] = s[p];
1753
+ }
1754
+ return t;
1755
+ };
1756
+ return __assign.apply(this, arguments);
1757
+ };
1758
+ // -- MessageFormat --------------------------------------------------------
1759
+ function resolveLocale(locales) {
1760
+ if (typeof locales === 'string') {
1761
+ locales = [locales];
1762
+ }
1763
+ try {
1764
+ return Intl.NumberFormat.supportedLocalesOf(locales, {
1765
+ // IE11 localeMatcher `lookup` seems to convert `en` -> `en-US`
1766
+ // but not other browsers,
1767
+ localeMatcher: 'best fit'
1768
+ })[0];
1769
+ }
1770
+ catch (e) {
1771
+ return IntlMessageFormat.defaultLocale;
1772
+ }
1773
+ }
1774
+ function formatPatterns(pattern, values) {
1775
+ var result = '';
1776
+ for (var _i = 0, pattern_1 = pattern; _i < pattern_1.length; _i++) {
1777
+ var part = pattern_1[_i];
1778
+ // Exist early for string parts.
1779
+ if (typeof part === 'string') {
1780
+ result += part;
1781
+ continue;
1782
+ }
1783
+ var id = part.id;
1784
+ // Enforce that all required values are provided by the caller.
1785
+ if (!(values && id in values)) {
1786
+ throw new FormatError("A value must be provided for: " + id, id);
1787
+ }
1788
+ var value = values[id];
1789
+ // Recursively format plural and select parts' option — which can be a
1790
+ // nested pattern structure. The choosing of the option to use is
1791
+ // abstracted-by and delegated-to the part helper object.
1792
+ if (isSelectOrPluralFormat(part)) {
1793
+ result += formatPatterns(part.getOption(value), values);
1794
+ }
1795
+ else {
1796
+ result += part.format(value);
1797
+ }
1798
+ }
1799
+ return result;
1800
+ }
1801
+ function mergeConfig(c1, c2) {
1802
+ if (!c2) {
1803
+ return c1;
1804
+ }
1805
+ return __assign({}, (c1 || {}), (c2 || {}), Object.keys(c1).reduce(function (all, k) {
1806
+ all[k] = __assign({}, c1[k], (c2[k] || {}));
1807
+ return all;
1808
+ }, {}));
1809
+ }
1810
+ function mergeConfigs(defaultConfig, configs) {
1811
+ if (!configs) {
1812
+ return defaultConfig;
1813
+ }
1814
+ return Object.keys(defaultConfig).reduce(function (all, k) {
1815
+ all[k] = mergeConfig(defaultConfig[k], configs[k]);
1816
+ return all;
1817
+ }, __assign({}, defaultConfig));
1818
+ }
1819
+ var FormatError = /** @class */ (function (_super) {
1820
+ __extends$1(FormatError, _super);
1821
+ function FormatError(msg, variableId) {
1822
+ var _this = _super.call(this, msg) || this;
1823
+ _this.variableId = variableId;
1824
+ return _this;
1825
+ }
1826
+ return FormatError;
1827
+ }(Error));
1828
+ function createDefaultFormatters() {
1599
1829
  return {
1600
- SyntaxError: peg$SyntaxError,
1601
- parse: peg$parse
1830
+ getNumberFormat: function () {
1831
+ var _a;
1832
+ var args = [];
1833
+ for (var _i = 0; _i < arguments.length; _i++) {
1834
+ args[_i] = arguments[_i];
1835
+ }
1836
+ return new ((_a = Intl.NumberFormat).bind.apply(_a, [void 0].concat(args)))();
1837
+ },
1838
+ getDateTimeFormat: function () {
1839
+ var _a;
1840
+ var args = [];
1841
+ for (var _i = 0; _i < arguments.length; _i++) {
1842
+ args[_i] = arguments[_i];
1843
+ }
1844
+ return new ((_a = Intl.DateTimeFormat).bind.apply(_a, [void 0].concat(args)))();
1845
+ },
1846
+ getPluralRules: function () {
1847
+ var _a;
1848
+ var args = [];
1849
+ for (var _i = 0; _i < arguments.length; _i++) {
1850
+ args[_i] = arguments[_i];
1851
+ }
1852
+ return new ((_a = Intl.PluralRules).bind.apply(_a, [void 0].concat(args)))();
1853
+ }
1602
1854
  };
1603
- })();
1604
-
1605
- /*
1606
- Copyright (c) 2014, Yahoo! Inc. All rights reserved.
1607
- Copyrights licensed under the New BSD License.
1608
- See the accompanying LICENSE file for terms.
1609
- */
1610
- var __extends$1 = (undefined && undefined.__extends) || (function () {
1611
- var extendStatics = function (d, b) {
1612
- extendStatics = Object.setPrototypeOf ||
1613
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1614
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
1615
- return extendStatics(d, b);
1616
- };
1617
- return function (d, b) {
1618
- extendStatics(d, b);
1619
- function __() { this.constructor = d; }
1620
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1621
- };
1622
- })();
1623
- var __assign = (undefined && undefined.__assign) || function () {
1624
- __assign = Object.assign || function(t) {
1625
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1626
- s = arguments[i];
1627
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1628
- t[p] = s[p];
1629
- }
1630
- return t;
1631
- };
1632
- return __assign.apply(this, arguments);
1633
- };
1634
- // -- MessageFormat --------------------------------------------------------
1635
- function resolveLocale(locales) {
1636
- if (typeof locales === 'string') {
1637
- locales = [locales];
1638
- }
1639
- try {
1640
- return Intl.NumberFormat.supportedLocalesOf(locales, {
1641
- // IE11 localeMatcher `lookup` seems to convert `en` -> `en-US`
1642
- // but not other browsers,
1643
- localeMatcher: 'best fit'
1644
- })[0];
1645
- }
1646
- catch (e) {
1647
- return MessageFormat.defaultLocale;
1648
- }
1649
- }
1650
- function formatPatterns(pattern, values) {
1651
- var result = '';
1652
- for (var _i = 0, pattern_1 = pattern; _i < pattern_1.length; _i++) {
1653
- var part = pattern_1[_i];
1654
- // Exist early for string parts.
1655
- if (typeof part === 'string') {
1656
- result += part;
1657
- continue;
1658
- }
1659
- var id = part.id;
1660
- // Enforce that all required values are provided by the caller.
1661
- if (!(values && id in values)) {
1662
- throw new FormatError("A value must be provided for: " + id, id);
1663
- }
1664
- var value = values[id];
1665
- // Recursively format plural and select parts' option — which can be a
1666
- // nested pattern structure. The choosing of the option to use is
1667
- // abstracted-by and delegated-to the part helper object.
1668
- if (isSelectOrPluralFormat(part)) {
1669
- result += formatPatterns(part.getOption(value), values);
1670
- }
1671
- else {
1672
- result += part.format(value);
1673
- }
1674
- }
1675
- return result;
1676
- }
1677
- function mergeConfig(c1, c2) {
1678
- if (!c2) {
1679
- return c1;
1680
- }
1681
- return __assign({}, (c1 || {}), (c2 || {}), Object.keys(c1).reduce(function (all, k) {
1682
- all[k] = __assign({}, c1[k], (c2[k] || {}));
1683
- return all;
1684
- }, {}));
1685
- }
1686
- function mergeConfigs(defaultConfig, configs) {
1687
- if (!configs) {
1688
- return defaultConfig;
1689
- }
1690
- return Object.keys(defaultConfig).reduce(function (all, k) {
1691
- all[k] = mergeConfig(defaultConfig[k], configs[k]);
1692
- return all;
1693
- }, __assign({}, defaultConfig));
1694
- }
1695
- var FormatError = /** @class */ (function (_super) {
1696
- __extends$1(FormatError, _super);
1697
- function FormatError(msg, variableId) {
1698
- var _this = _super.call(this, msg) || this;
1699
- _this.variableId = variableId;
1700
- return _this;
1701
- }
1702
- return FormatError;
1703
- }(Error));
1704
- var MessageFormat = (function (message, locales, overrideFormats) {
1705
- if (locales === void 0) { locales = MessageFormat.defaultLocale; }
1706
- // Parse string messages into an AST.
1707
- var ast = typeof message === 'string' ? MessageFormat.__parse(message) : message;
1708
- if (!(ast && ast.type === 'messageFormatPattern')) {
1709
- throw new TypeError('A message must be provided as a String or AST.');
1710
- }
1711
- // Creates a new object with the specified `formats` merged with the default
1712
- // formats.
1713
- var formats = mergeConfigs(MessageFormat.formats, overrideFormats);
1714
- // Defined first because it's used to build the format pattern.
1715
- var locale = resolveLocale(locales || []);
1716
- // Compile the `ast` to a pattern that is highly optimized for repeated
1717
- // `format()` invocations. **Note:** This passes the `locales` set provided
1718
- // to the constructor instead of just the resolved locale.
1719
- var pattern = new Compiler(locales, formats).compile(ast);
1720
- // "Bind" `format()` method to `this` so it can be passed by reference like
1721
- // the other `Intl` APIs.
1722
- return {
1723
- format: function (values) {
1724
- try {
1725
- return formatPatterns(pattern, values);
1726
- }
1727
- catch (e) {
1728
- if (e.variableId) {
1729
- throw new Error("The intl string context variable '" + e.variableId + "' was not provided to the string '" + message + "'");
1730
- }
1731
- else {
1732
- throw e;
1733
- }
1734
- }
1735
- },
1736
- resolvedOptions: function () {
1737
- return { locale: locale };
1738
- },
1739
- getAst: function () {
1740
- return ast;
1741
- }
1742
- };
1743
- });
1744
- MessageFormat.defaultLocale = 'en';
1745
- // Default format options used as the prototype of the `formats` provided to the
1746
- // constructor. These are used when constructing the internal Intl.NumberFormat
1747
- // and Intl.DateTimeFormat instances.
1748
- MessageFormat.formats = {
1749
- number: {
1750
- currency: {
1751
- style: 'currency'
1752
- },
1753
- percent: {
1754
- style: 'percent'
1755
- }
1756
- },
1757
- date: {
1758
- short: {
1759
- month: 'numeric',
1760
- day: 'numeric',
1761
- year: '2-digit'
1762
- },
1763
- medium: {
1764
- month: 'short',
1765
- day: 'numeric',
1766
- year: 'numeric'
1767
- },
1768
- long: {
1769
- month: 'long',
1770
- day: 'numeric',
1771
- year: 'numeric'
1772
- },
1773
- full: {
1774
- weekday: 'long',
1775
- month: 'long',
1776
- day: 'numeric',
1777
- year: 'numeric'
1778
- }
1779
- },
1780
- time: {
1781
- short: {
1782
- hour: 'numeric',
1783
- minute: 'numeric'
1784
- },
1785
- medium: {
1786
- hour: 'numeric',
1787
- minute: 'numeric',
1788
- second: 'numeric'
1789
- },
1790
- long: {
1791
- hour: 'numeric',
1792
- minute: 'numeric',
1793
- second: 'numeric',
1794
- timeZoneName: 'short'
1795
- },
1796
- full: {
1797
- hour: 'numeric',
1798
- minute: 'numeric',
1799
- second: 'numeric',
1800
- timeZoneName: 'short'
1801
- }
1802
- }
1803
- };
1804
- MessageFormat.__parse = parser.parse;
1855
+ }
1856
+ var IntlMessageFormat = /** @class */ (function () {
1857
+ function IntlMessageFormat(message, locales, overrideFormats, opts) {
1858
+ var _this = this;
1859
+ if (locales === void 0) { locales = IntlMessageFormat.defaultLocale; }
1860
+ this.format = function (values) {
1861
+ try {
1862
+ return formatPatterns(_this.pattern, values);
1863
+ }
1864
+ catch (e) {
1865
+ if (e.variableId) {
1866
+ throw new Error("The intl string context variable '" + e.variableId + "' was not provided to the string '" + _this.message + "'");
1867
+ }
1868
+ else {
1869
+ throw e;
1870
+ }
1871
+ }
1872
+ };
1873
+ if (typeof message === 'string') {
1874
+ if (!IntlMessageFormat.__parse) {
1875
+ throw new TypeError('IntlMessageFormat.__parse must be set to process `message` of type `string`');
1876
+ }
1877
+ // Parse string messages into an AST.
1878
+ this.ast = IntlMessageFormat.__parse(message);
1879
+ }
1880
+ else {
1881
+ this.ast = message;
1882
+ }
1883
+ this.message = message;
1884
+ if (!(this.ast && this.ast.type === 'messageFormatPattern')) {
1885
+ throw new TypeError('A message must be provided as a String or AST.');
1886
+ }
1887
+ // Creates a new object with the specified `formats` merged with the default
1888
+ // formats.
1889
+ var formats = mergeConfigs(IntlMessageFormat.formats, overrideFormats);
1890
+ // Defined first because it's used to build the format pattern.
1891
+ this.locale = resolveLocale(locales || []);
1892
+ var formatters = (opts && opts.formatters) || createDefaultFormatters();
1893
+ // Compile the `ast` to a pattern that is highly optimized for repeated
1894
+ // `format()` invocations. **Note:** This passes the `locales` set provided
1895
+ // to the constructor instead of just the resolved locale.
1896
+ this.pattern = new Compiler(locales, formats, formatters).compile(this.ast);
1897
+ // "Bind" `format()` method to `this` so it can be passed by reference like
1898
+ // the other `Intl` APIs.
1899
+ }
1900
+ IntlMessageFormat.prototype.resolvedOptions = function () {
1901
+ return { locale: this.locale };
1902
+ };
1903
+ IntlMessageFormat.prototype.getAst = function () {
1904
+ return this.ast;
1905
+ };
1906
+ IntlMessageFormat.defaultLocale = 'en';
1907
+ IntlMessageFormat.__parse = undefined;
1908
+ // Default format options used as the prototype of the `formats` provided to the
1909
+ // constructor. These are used when constructing the internal Intl.NumberFormat
1910
+ // and Intl.DateTimeFormat instances.
1911
+ IntlMessageFormat.formats = {
1912
+ number: {
1913
+ currency: {
1914
+ style: 'currency'
1915
+ },
1916
+ percent: {
1917
+ style: 'percent'
1918
+ }
1919
+ },
1920
+ date: {
1921
+ short: {
1922
+ month: 'numeric',
1923
+ day: 'numeric',
1924
+ year: '2-digit'
1925
+ },
1926
+ medium: {
1927
+ month: 'short',
1928
+ day: 'numeric',
1929
+ year: 'numeric'
1930
+ },
1931
+ long: {
1932
+ month: 'long',
1933
+ day: 'numeric',
1934
+ year: 'numeric'
1935
+ },
1936
+ full: {
1937
+ weekday: 'long',
1938
+ month: 'long',
1939
+ day: 'numeric',
1940
+ year: 'numeric'
1941
+ }
1942
+ },
1943
+ time: {
1944
+ short: {
1945
+ hour: 'numeric',
1946
+ minute: 'numeric'
1947
+ },
1948
+ medium: {
1949
+ hour: 'numeric',
1950
+ minute: 'numeric',
1951
+ second: 'numeric'
1952
+ },
1953
+ long: {
1954
+ hour: 'numeric',
1955
+ minute: 'numeric',
1956
+ second: 'numeric',
1957
+ timeZoneName: 'short'
1958
+ },
1959
+ full: {
1960
+ hour: 'numeric',
1961
+ minute: 'numeric',
1962
+ second: 'numeric',
1963
+ timeZoneName: 'short'
1964
+ }
1965
+ }
1966
+ };
1967
+ return IntlMessageFormat;
1968
+ }());
1969
+
1970
+ /*
1971
+ Copyright (c) 2014, Yahoo! Inc. All rights reserved.
1972
+ Copyrights licensed under the New BSD License.
1973
+ See the accompanying LICENSE file for terms.
1974
+ */
1975
+ IntlMessageFormat.__parse = parser.parse;
1976
+
1977
+ exports.IntlMessageFormat = IntlMessageFormat;
1978
+ exports.createDefaultFormatters = createDefaultFormatters;
1979
+ exports.default = IntlMessageFormat;
1805
1980
 
1806
- return MessageFormat;
1981
+ Object.defineProperty(exports, '__esModule', { value: true });
1807
1982
 
1808
1983
  }));
1809
1984
  //# sourceMappingURL=intl-messageformat.js.map