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.
- package/CHANGELOG.md +32 -44
- package/LICENSE +0 -0
- package/README.md +108 -59
- package/core.js +1 -0
- package/dist/compiler.d.ts +10 -4
- package/dist/compiler.js +11 -14
- package/dist/compiler.js.map +1 -1
- package/dist/core.d.ts +78 -0
- package/dist/core.js +248 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +4 -16
- package/dist/index.js +7 -198
- package/dist/index.js.map +1 -1
- package/dist/umd/intl-messageformat.js +1548 -1373
- package/dist/umd/intl-messageformat.js.map +1 -1
- package/dist/umd/intl-messageformat.min.js +1 -1
- package/dist/umd/intl-messageformat.min.js.map +1 -1
- package/index.js +0 -0
- package/lib/compiler.d.ts +10 -4
- package/lib/compiler.js +11 -14
- package/lib/compiler.js.map +1 -1
- package/lib/core.d.ts +78 -0
- package/lib/core.js +245 -0
- package/lib/core.js.map +1 -0
- package/lib/index.d.ts +4 -16
- package/lib/index.js +4 -198
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/compiler.ts +39 -16
- package/src/core.ts +269 -0
- package/src/index.ts +6 -242
- package/.nyc_output/34ec6f1e-d2e9-445f-8813-bd6e8b5975bb.json +0 -1
- package/.nyc_output/9b57550b-ff23-4ed6-b289-f7ff8d2beb4f.json +0 -1
- package/.nyc_output/b696f16a-7b55-4692-a441-41aa11ca2fb0.json +0 -1
- package/.nyc_output/processinfo/34ec6f1e-d2e9-445f-8813-bd6e8b5975bb.json +0 -1
- package/.nyc_output/processinfo/9b57550b-ff23-4ed6-b289-f7ff8d2beb4f.json +0 -1
- package/.nyc_output/processinfo/b696f16a-7b55-4692-a441-41aa11ca2fb0.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
|
@@ -1,648 +1,458 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}(this, function () { 'use strict';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
27
|
+
if (typeof Error.captureStackTrace === "function") {
|
|
28
|
+
Error.captureStackTrace(this, peg$SyntaxError);
|
|
225
29
|
}
|
|
30
|
+
}
|
|
226
31
|
|
|
227
|
-
|
|
32
|
+
peg$subclass(peg$SyntaxError, Error);
|
|
228
33
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
40
|
+
"class": function(expectation) {
|
|
41
|
+
var escapedParts = "",
|
|
42
|
+
i;
|
|
238
43
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
-
|
|
246
|
-
|
|
50
|
+
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
|
|
51
|
+
},
|
|
247
52
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
53
|
+
any: function(expectation) {
|
|
54
|
+
return "any character";
|
|
55
|
+
},
|
|
251
56
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
57
|
+
end: function(expectation) {
|
|
58
|
+
return "end of input";
|
|
59
|
+
},
|
|
255
60
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
61
|
+
other: function(expectation) {
|
|
62
|
+
return expectation.description;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
260
65
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
66
|
+
function hex(ch) {
|
|
67
|
+
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
68
|
+
}
|
|
264
69
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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
|
-
|
|
292
|
-
|
|
293
|
-
|
|
96
|
+
function describeExpectation(expectation) {
|
|
97
|
+
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
98
|
+
}
|
|
294
99
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
100
|
+
function describeExpected(expected) {
|
|
101
|
+
var descriptions = new Array(expected.length),
|
|
102
|
+
i, j;
|
|
298
103
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
104
|
+
for (i = 0; i < expected.length; i++) {
|
|
105
|
+
descriptions[i] = describeExpectation(expected[i]);
|
|
106
|
+
}
|
|
302
107
|
|
|
303
|
-
|
|
108
|
+
descriptions.sort();
|
|
304
109
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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
|
-
|
|
316
|
-
|
|
317
|
-
|
|
120
|
+
switch (descriptions.length) {
|
|
121
|
+
case 1:
|
|
122
|
+
return descriptions[0];
|
|
318
123
|
|
|
319
|
-
|
|
320
|
-
|
|
124
|
+
case 2:
|
|
125
|
+
return descriptions[0] + " or " + descriptions[1];
|
|
321
126
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
127
|
+
default:
|
|
128
|
+
return descriptions.slice(0, -1).join(", ")
|
|
129
|
+
+ ", or "
|
|
130
|
+
+ descriptions[descriptions.length - 1];
|
|
327
131
|
}
|
|
132
|
+
}
|
|
328
133
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
134
|
+
function describeFound(found) {
|
|
135
|
+
return found ? "\"" + literalEscape(found) + "\"" : "end of input";
|
|
136
|
+
}
|
|
332
137
|
|
|
333
|
-
|
|
334
|
-
|
|
138
|
+
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
139
|
+
};
|
|
335
140
|
|
|
336
|
-
|
|
337
|
-
|
|
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
|
-
|
|
497
|
-
}
|
|
144
|
+
var peg$FAILED = {},
|
|
498
145
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
}
|
|
146
|
+
peg$startRuleFunctions = { start: peg$parsestart },
|
|
147
|
+
peg$startRuleFunction = peg$parsestart,
|
|
502
148
|
|
|
503
|
-
|
|
504
|
-
|
|
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
|
-
|
|
508
|
-
|
|
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
|
-
|
|
512
|
-
return { type: "end" };
|
|
513
|
-
}
|
|
299
|
+
peg$result;
|
|
514
300
|
|
|
515
|
-
|
|
516
|
-
|
|
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
|
-
|
|
520
|
-
|
|
306
|
+
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
307
|
+
}
|
|
521
308
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
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
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
column: details.column
|
|
534
|
-
};
|
|
313
|
+
function peg$literalExpectation(text, ignoreCase) {
|
|
314
|
+
return { type: "literal", text: text, ignoreCase: ignoreCase };
|
|
315
|
+
}
|
|
535
316
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
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
|
-
|
|
545
|
-
|
|
321
|
+
function peg$anyExpectation() {
|
|
322
|
+
return { type: "any" };
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function peg$endExpectation() {
|
|
326
|
+
return { type: "end" };
|
|
327
|
+
}
|
|
546
328
|
|
|
547
|
-
|
|
548
|
-
|
|
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
|
-
|
|
553
|
-
|
|
554
|
-
|
|
344
|
+
details = peg$posDetailsCache[p];
|
|
345
|
+
details = {
|
|
346
|
+
line: details.line,
|
|
347
|
+
column: details.column
|
|
348
|
+
};
|
|
555
349
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
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
|
-
|
|
571
|
-
|
|
366
|
+
function peg$computeLocation(startPos, endPos) {
|
|
367
|
+
var startPosDetails = peg$computePosDetails(startPos),
|
|
368
|
+
endPosDetails = peg$computePosDetails(endPos);
|
|
572
369
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
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
|
-
|
|
579
|
-
}
|
|
384
|
+
function peg$fail(expected) {
|
|
385
|
+
if (peg$currPos < peg$maxFailPos) { return; }
|
|
580
386
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
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
|
-
|
|
591
|
-
|
|
392
|
+
peg$maxFailExpected.push(expected);
|
|
393
|
+
}
|
|
592
394
|
|
|
593
|
-
|
|
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
|
-
|
|
596
|
-
|
|
404
|
+
function peg$parsestart() {
|
|
405
|
+
var s0;
|
|
597
406
|
|
|
598
|
-
|
|
599
|
-
var s0, s1, s2;
|
|
407
|
+
s0 = peg$parsemessageFormatPattern();
|
|
600
408
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
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
|
-
|
|
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
|
-
|
|
618
|
-
|
|
428
|
+
return s0;
|
|
429
|
+
}
|
|
619
430
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
s0 = peg$parseargumentElement();
|
|
623
|
-
}
|
|
431
|
+
function peg$parsemessageFormatElement() {
|
|
432
|
+
var s0;
|
|
624
433
|
|
|
625
|
-
|
|
434
|
+
s0 = peg$parsemessageTextElement();
|
|
435
|
+
if (s0 === peg$FAILED) {
|
|
436
|
+
s0 = peg$parseargumentElement();
|
|
626
437
|
}
|
|
627
438
|
|
|
628
|
-
|
|
629
|
-
|
|
439
|
+
return s0;
|
|
440
|
+
}
|
|
630
441
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
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
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
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
|
-
|
|
684
|
-
|
|
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
|
-
|
|
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
|
-
|
|
701
|
-
|
|
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 =
|
|
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$
|
|
542
|
+
s1 = peg$c3(s1);
|
|
708
543
|
}
|
|
709
544
|
s0 = s1;
|
|
710
|
-
|
|
711
|
-
return s0;
|
|
712
545
|
}
|
|
713
546
|
|
|
714
|
-
|
|
715
|
-
|
|
547
|
+
return s0;
|
|
548
|
+
}
|
|
716
549
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
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
|
-
|
|
736
|
-
if (peg$silentFails === 0) { peg$fail(peg$
|
|
573
|
+
s6 = peg$FAILED;
|
|
574
|
+
if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
|
737
575
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
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
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
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
|
-
|
|
636
|
+
} else {
|
|
637
|
+
peg$currPos = s0;
|
|
638
|
+
s0 = peg$FAILED;
|
|
844
639
|
}
|
|
845
640
|
|
|
846
|
-
|
|
847
|
-
|
|
641
|
+
return s0;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function peg$parseelementFormat() {
|
|
645
|
+
var s0;
|
|
848
646
|
|
|
849
|
-
|
|
647
|
+
s0 = peg$parsesimpleFormat();
|
|
648
|
+
if (s0 === peg$FAILED) {
|
|
649
|
+
s0 = peg$parsepluralFormat();
|
|
850
650
|
if (s0 === peg$FAILED) {
|
|
851
|
-
s0 = peg$
|
|
651
|
+
s0 = peg$parseselectOrdinalFormat();
|
|
852
652
|
if (s0 === peg$FAILED) {
|
|
853
|
-
s0 = peg$
|
|
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
|
-
|
|
864
|
-
|
|
658
|
+
return s0;
|
|
659
|
+
}
|
|
865
660
|
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
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$
|
|
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$
|
|
876
|
-
s1 = peg$
|
|
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$
|
|
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
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
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
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
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
|
-
|
|
735
|
+
} else {
|
|
736
|
+
peg$currPos = s0;
|
|
737
|
+
s0 = peg$FAILED;
|
|
943
738
|
}
|
|
944
739
|
|
|
945
|
-
|
|
946
|
-
|
|
740
|
+
return s0;
|
|
741
|
+
}
|
|
947
742
|
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
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
|
-
|
|
788
|
+
} else {
|
|
789
|
+
peg$currPos = s0;
|
|
790
|
+
s0 = peg$FAILED;
|
|
996
791
|
}
|
|
997
792
|
|
|
998
|
-
|
|
999
|
-
|
|
793
|
+
return s0;
|
|
794
|
+
}
|
|
1000
795
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
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
|
-
|
|
841
|
+
} else {
|
|
842
|
+
peg$currPos = s0;
|
|
843
|
+
s0 = peg$FAILED;
|
|
1049
844
|
}
|
|
1050
845
|
|
|
1051
|
-
|
|
1052
|
-
|
|
846
|
+
return s0;
|
|
847
|
+
}
|
|
1053
848
|
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
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
|
-
|
|
903
|
+
} else {
|
|
904
|
+
peg$currPos = s0;
|
|
905
|
+
s0 = peg$FAILED;
|
|
1111
906
|
}
|
|
1112
907
|
|
|
1113
|
-
|
|
1114
|
-
|
|
908
|
+
return s0;
|
|
909
|
+
}
|
|
1115
910
|
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
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
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
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
|
-
|
|
1151
|
-
|
|
945
|
+
return s0;
|
|
946
|
+
}
|
|
1152
947
|
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
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
|
-
|
|
999
|
+
} else {
|
|
1000
|
+
peg$currPos = s0;
|
|
1001
|
+
s0 = peg$FAILED;
|
|
1207
1002
|
}
|
|
1208
1003
|
|
|
1209
|
-
|
|
1210
|
-
|
|
1004
|
+
return s0;
|
|
1005
|
+
}
|
|
1211
1006
|
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
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
|
-
|
|
1034
|
+
} else {
|
|
1035
|
+
peg$currPos = s0;
|
|
1036
|
+
s0 = peg$FAILED;
|
|
1242
1037
|
}
|
|
1243
1038
|
|
|
1244
|
-
|
|
1245
|
-
|
|
1039
|
+
return s0;
|
|
1040
|
+
}
|
|
1246
1041
|
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1286
|
-
|
|
1171
|
+
function peg$parsenumber() {
|
|
1172
|
+
var s0, s1, s2, s3, s4, s5;
|
|
1287
1173
|
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
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
|
-
|
|
1295
|
-
if (peg$silentFails === 0) { peg$fail(peg$
|
|
1189
|
+
s3 = peg$FAILED;
|
|
1190
|
+
if (peg$silentFails === 0) { peg$fail(peg$c45); }
|
|
1296
1191
|
}
|
|
1297
|
-
if (
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
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
|
-
|
|
1207
|
+
peg$currPos = s2;
|
|
1208
|
+
s2 = peg$FAILED;
|
|
1310
1209
|
}
|
|
1311
|
-
peg$
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
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
|
-
|
|
1321
|
-
|
|
1222
|
+
return s0;
|
|
1223
|
+
}
|
|
1322
1224
|
|
|
1323
|
-
|
|
1324
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1346
|
-
|
|
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
|
-
|
|
1353
|
-
if (peg$silentFails === 0) { peg$fail(peg$
|
|
1243
|
+
s2 = peg$FAILED;
|
|
1244
|
+
if (peg$silentFails === 0) { peg$fail(peg$c50); }
|
|
1354
1245
|
}
|
|
1355
|
-
|
|
1356
|
-
return s0;
|
|
1357
1246
|
}
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
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
|
-
|
|
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) ===
|
|
1378
|
-
s1 = peg$
|
|
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$
|
|
1281
|
+
if (peg$silentFails === 0) { peg$fail(peg$c48); }
|
|
1383
1282
|
}
|
|
1384
|
-
if (s1
|
|
1385
|
-
|
|
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
|
-
|
|
1286
|
+
peg$savedPos = s0;
|
|
1287
|
+
s1 = peg$c53(s2);
|
|
1288
|
+
s0 = s1;
|
|
1414
1289
|
} else {
|
|
1415
|
-
|
|
1290
|
+
peg$currPos = s0;
|
|
1291
|
+
s0 = peg$FAILED;
|
|
1416
1292
|
}
|
|
1293
|
+
} else {
|
|
1294
|
+
peg$currPos = s0;
|
|
1295
|
+
s0 = peg$FAILED;
|
|
1417
1296
|
}
|
|
1418
|
-
|
|
1419
|
-
peg$savedPos = s0;
|
|
1420
|
-
s1 = peg$c47(s1);
|
|
1421
|
-
}
|
|
1422
|
-
s0 = s1;
|
|
1297
|
+
}
|
|
1423
1298
|
|
|
1424
|
-
|
|
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
|
-
|
|
1428
|
-
|
|
1333
|
+
function peg$parsechar() {
|
|
1334
|
+
var s0, s1, s2, s3, s4, s5, s6, s7;
|
|
1429
1335
|
|
|
1430
|
-
|
|
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$
|
|
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$
|
|
1440
|
-
s1 = peg$
|
|
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$
|
|
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$
|
|
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$
|
|
1454
|
-
s1 = peg$
|
|
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$
|
|
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$
|
|
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$
|
|
1468
|
-
s1 = peg$
|
|
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$
|
|
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$
|
|
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$
|
|
1482
|
-
s1 = peg$
|
|
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$
|
|
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$
|
|
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$
|
|
1496
|
-
s1 = peg$
|
|
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$
|
|
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$
|
|
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
|
-
|
|
1558
|
-
|
|
1484
|
+
return s0;
|
|
1485
|
+
}
|
|
1559
1486
|
|
|
1560
|
-
|
|
1561
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1507
|
+
return s0;
|
|
1508
|
+
}
|
|
1581
1509
|
|
|
1582
|
-
|
|
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
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
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
|
-
|
|
1601
|
-
|
|
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
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
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
|
-
|
|
1981
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1807
1982
|
|
|
1808
1983
|
}));
|
|
1809
1984
|
//# sourceMappingURL=intl-messageformat.js.map
|