@formatjs/icu-messageformat-parser 2.11.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/date-time-pattern-generator.js +6 -9
- package/error.d.ts +1 -1
- package/error.js +2 -5
- package/index.d.ts +4 -4
- package/index.js +16 -21
- package/manipulator.d.ts +1 -1
- package/manipulator.js +16 -20
- package/no-parser.d.ts +2 -2
- package/no-parser.js +4 -10
- package/package.json +10 -5
- package/parser.d.ts +2 -2
- package/parser.js +59 -62
- package/printer.d.ts +1 -1
- package/printer.js +15 -20
- package/regex.generated.js +2 -5
- package/time-data.generated.js +1 -4
- package/types.js +17 -33
- package/lib/date-time-pattern-generator.d.ts +0 -8
- package/lib/date-time-pattern-generator.js +0 -83
- package/lib/error.d.ts +0 -68
- package/lib/error.js +0 -63
- package/lib/index.d.ts +0 -7
- package/lib/index.js +0 -46
- package/lib/manipulator.d.ts +0 -26
- package/lib/manipulator.js +0 -135
- package/lib/no-parser.d.ts +0 -4
- package/lib/no-parser.js +0 -6
- package/lib/parser.d.ts +0 -147
- package/lib/parser.js +0 -1276
- package/lib/printer.d.ts +0 -4
- package/lib/printer.js +0 -101
- package/lib/regex.generated.d.ts +0 -2
- package/lib/regex.generated.js +0 -3
- package/lib/time-data.generated.d.ts +0 -1
- package/lib/time-data.generated.js +0 -1417
- package/lib/types.d.ts +0 -120
- package/lib/types.js +0 -94
package/lib/parser.js
DELETED
|
@@ -1,1276 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import { __assign } from "tslib";
|
|
3
|
-
import { ErrorKind } from './error';
|
|
4
|
-
import { SKELETON_TYPE, TYPE, } from './types';
|
|
5
|
-
import { SPACE_SEPARATOR_REGEX } from './regex.generated';
|
|
6
|
-
import { parseNumberSkeleton, parseNumberSkeletonFromString, parseDateTimeSkeleton, } from '@formatjs/icu-skeleton-parser';
|
|
7
|
-
import { getBestPattern } from './date-time-pattern-generator';
|
|
8
|
-
var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*"));
|
|
9
|
-
var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$"));
|
|
10
|
-
function createLocation(start, end) {
|
|
11
|
-
return { start: start, end: end };
|
|
12
|
-
}
|
|
13
|
-
// #region Ponyfills
|
|
14
|
-
// Consolidate these variables up top for easier toggling during debugging
|
|
15
|
-
var hasNativeStartsWith = !!String.prototype.startsWith && '_a'.startsWith('a', 1);
|
|
16
|
-
var hasNativeFromCodePoint = !!String.fromCodePoint;
|
|
17
|
-
var hasNativeFromEntries = !!Object.fromEntries;
|
|
18
|
-
var hasNativeCodePointAt = !!String.prototype.codePointAt;
|
|
19
|
-
var hasTrimStart = !!String.prototype.trimStart;
|
|
20
|
-
var hasTrimEnd = !!String.prototype.trimEnd;
|
|
21
|
-
var hasNativeIsSafeInteger = !!Number.isSafeInteger;
|
|
22
|
-
var isSafeInteger = hasNativeIsSafeInteger
|
|
23
|
-
? Number.isSafeInteger
|
|
24
|
-
: function (n) {
|
|
25
|
-
return (typeof n === 'number' &&
|
|
26
|
-
isFinite(n) &&
|
|
27
|
-
Math.floor(n) === n &&
|
|
28
|
-
Math.abs(n) <= 0x1fffffffffffff);
|
|
29
|
-
};
|
|
30
|
-
// IE11 does not support y and u.
|
|
31
|
-
var REGEX_SUPPORTS_U_AND_Y = true;
|
|
32
|
-
try {
|
|
33
|
-
var re = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
|
|
34
|
-
/**
|
|
35
|
-
* legacy Edge or Xbox One browser
|
|
36
|
-
* Unicode flag support: supported
|
|
37
|
-
* Pattern_Syntax support: not supported
|
|
38
|
-
* See https://github.com/formatjs/formatjs/issues/2822
|
|
39
|
-
*/
|
|
40
|
-
REGEX_SUPPORTS_U_AND_Y = ((_a = re.exec('a')) === null || _a === void 0 ? void 0 : _a[0]) === 'a';
|
|
41
|
-
}
|
|
42
|
-
catch (_) {
|
|
43
|
-
REGEX_SUPPORTS_U_AND_Y = false;
|
|
44
|
-
}
|
|
45
|
-
var startsWith = hasNativeStartsWith
|
|
46
|
-
? // Native
|
|
47
|
-
function startsWith(s, search, position) {
|
|
48
|
-
return s.startsWith(search, position);
|
|
49
|
-
}
|
|
50
|
-
: // For IE11
|
|
51
|
-
function startsWith(s, search, position) {
|
|
52
|
-
return s.slice(position, position + search.length) === search;
|
|
53
|
-
};
|
|
54
|
-
var fromCodePoint = hasNativeFromCodePoint
|
|
55
|
-
? String.fromCodePoint
|
|
56
|
-
: // IE11
|
|
57
|
-
function fromCodePoint() {
|
|
58
|
-
var codePoints = [];
|
|
59
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
60
|
-
codePoints[_i] = arguments[_i];
|
|
61
|
-
}
|
|
62
|
-
var elements = '';
|
|
63
|
-
var length = codePoints.length;
|
|
64
|
-
var i = 0;
|
|
65
|
-
var code;
|
|
66
|
-
while (length > i) {
|
|
67
|
-
code = codePoints[i++];
|
|
68
|
-
if (code > 0x10ffff)
|
|
69
|
-
throw RangeError(code + ' is not a valid code point');
|
|
70
|
-
elements +=
|
|
71
|
-
code < 0x10000
|
|
72
|
-
? String.fromCharCode(code)
|
|
73
|
-
: String.fromCharCode(((code -= 0x10000) >> 10) + 0xd800, (code % 0x400) + 0xdc00);
|
|
74
|
-
}
|
|
75
|
-
return elements;
|
|
76
|
-
};
|
|
77
|
-
var fromEntries =
|
|
78
|
-
// native
|
|
79
|
-
hasNativeFromEntries
|
|
80
|
-
? Object.fromEntries
|
|
81
|
-
: // Ponyfill
|
|
82
|
-
function fromEntries(entries) {
|
|
83
|
-
var obj = {};
|
|
84
|
-
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
85
|
-
var _a = entries_1[_i], k = _a[0], v = _a[1];
|
|
86
|
-
obj[k] = v;
|
|
87
|
-
}
|
|
88
|
-
return obj;
|
|
89
|
-
};
|
|
90
|
-
var codePointAt = hasNativeCodePointAt
|
|
91
|
-
? // Native
|
|
92
|
-
function codePointAt(s, index) {
|
|
93
|
-
return s.codePointAt(index);
|
|
94
|
-
}
|
|
95
|
-
: // IE 11
|
|
96
|
-
function codePointAt(s, index) {
|
|
97
|
-
var size = s.length;
|
|
98
|
-
if (index < 0 || index >= size) {
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
var first = s.charCodeAt(index);
|
|
102
|
-
var second;
|
|
103
|
-
return first < 0xd800 ||
|
|
104
|
-
first > 0xdbff ||
|
|
105
|
-
index + 1 === size ||
|
|
106
|
-
(second = s.charCodeAt(index + 1)) < 0xdc00 ||
|
|
107
|
-
second > 0xdfff
|
|
108
|
-
? first
|
|
109
|
-
: ((first - 0xd800) << 10) + (second - 0xdc00) + 0x10000;
|
|
110
|
-
};
|
|
111
|
-
var trimStart = hasTrimStart
|
|
112
|
-
? // Native
|
|
113
|
-
function trimStart(s) {
|
|
114
|
-
return s.trimStart();
|
|
115
|
-
}
|
|
116
|
-
: // Ponyfill
|
|
117
|
-
function trimStart(s) {
|
|
118
|
-
return s.replace(SPACE_SEPARATOR_START_REGEX, '');
|
|
119
|
-
};
|
|
120
|
-
var trimEnd = hasTrimEnd
|
|
121
|
-
? // Native
|
|
122
|
-
function trimEnd(s) {
|
|
123
|
-
return s.trimEnd();
|
|
124
|
-
}
|
|
125
|
-
: // Ponyfill
|
|
126
|
-
function trimEnd(s) {
|
|
127
|
-
return s.replace(SPACE_SEPARATOR_END_REGEX, '');
|
|
128
|
-
};
|
|
129
|
-
// Prevent minifier to translate new RegExp to literal form that might cause syntax error on IE11.
|
|
130
|
-
function RE(s, flag) {
|
|
131
|
-
return new RegExp(s, flag);
|
|
132
|
-
}
|
|
133
|
-
// #endregion
|
|
134
|
-
var matchIdentifierAtIndex;
|
|
135
|
-
if (REGEX_SUPPORTS_U_AND_Y) {
|
|
136
|
-
// Native
|
|
137
|
-
var IDENTIFIER_PREFIX_RE_1 = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
|
|
138
|
-
matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
|
|
139
|
-
var _a;
|
|
140
|
-
IDENTIFIER_PREFIX_RE_1.lastIndex = index;
|
|
141
|
-
var match = IDENTIFIER_PREFIX_RE_1.exec(s);
|
|
142
|
-
return (_a = match[1]) !== null && _a !== void 0 ? _a : '';
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
// IE11
|
|
147
|
-
matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
|
|
148
|
-
var match = [];
|
|
149
|
-
while (true) {
|
|
150
|
-
var c = codePointAt(s, index);
|
|
151
|
-
if (c === undefined || _isWhiteSpace(c) || _isPatternSyntax(c)) {
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
match.push(c);
|
|
155
|
-
index += c >= 0x10000 ? 2 : 1;
|
|
156
|
-
}
|
|
157
|
-
return fromCodePoint.apply(void 0, match);
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
var Parser = /** @class */ (function () {
|
|
161
|
-
function Parser(message, options) {
|
|
162
|
-
if (options === void 0) { options = {}; }
|
|
163
|
-
this.message = message;
|
|
164
|
-
this.position = { offset: 0, line: 1, column: 1 };
|
|
165
|
-
this.ignoreTag = !!options.ignoreTag;
|
|
166
|
-
this.locale = options.locale;
|
|
167
|
-
this.requiresOtherClause = !!options.requiresOtherClause;
|
|
168
|
-
this.shouldParseSkeletons = !!options.shouldParseSkeletons;
|
|
169
|
-
}
|
|
170
|
-
Parser.prototype.parse = function () {
|
|
171
|
-
if (this.offset() !== 0) {
|
|
172
|
-
throw Error('parser can only be used once');
|
|
173
|
-
}
|
|
174
|
-
return this.parseMessage(0, '', false);
|
|
175
|
-
};
|
|
176
|
-
Parser.prototype.parseMessage = function (nestingLevel, parentArgType, expectingCloseTag) {
|
|
177
|
-
var elements = [];
|
|
178
|
-
while (!this.isEOF()) {
|
|
179
|
-
var char = this.char();
|
|
180
|
-
if (char === 123 /* `{` */) {
|
|
181
|
-
var result = this.parseArgument(nestingLevel, expectingCloseTag);
|
|
182
|
-
if (result.err) {
|
|
183
|
-
return result;
|
|
184
|
-
}
|
|
185
|
-
elements.push(result.val);
|
|
186
|
-
}
|
|
187
|
-
else if (char === 125 /* `}` */ && nestingLevel > 0) {
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
else if (char === 35 /* `#` */ &&
|
|
191
|
-
(parentArgType === 'plural' || parentArgType === 'selectordinal')) {
|
|
192
|
-
var position = this.clonePosition();
|
|
193
|
-
this.bump();
|
|
194
|
-
elements.push({
|
|
195
|
-
type: TYPE.pound,
|
|
196
|
-
location: createLocation(position, this.clonePosition()),
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
else if (char === 60 /* `<` */ &&
|
|
200
|
-
!this.ignoreTag &&
|
|
201
|
-
this.peek() === 47 // char code for '/'
|
|
202
|
-
) {
|
|
203
|
-
if (expectingCloseTag) {
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
else if (char === 60 /* `<` */ &&
|
|
211
|
-
!this.ignoreTag &&
|
|
212
|
-
_isAlpha(this.peek() || 0)) {
|
|
213
|
-
var result = this.parseTag(nestingLevel, parentArgType);
|
|
214
|
-
if (result.err) {
|
|
215
|
-
return result;
|
|
216
|
-
}
|
|
217
|
-
elements.push(result.val);
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
var result = this.parseLiteral(nestingLevel, parentArgType);
|
|
221
|
-
if (result.err) {
|
|
222
|
-
return result;
|
|
223
|
-
}
|
|
224
|
-
elements.push(result.val);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return { val: elements, err: null };
|
|
228
|
-
};
|
|
229
|
-
/**
|
|
230
|
-
* A tag name must start with an ASCII lower/upper case letter. The grammar is based on the
|
|
231
|
-
* [custom element name][] except that a dash is NOT always mandatory and uppercase letters
|
|
232
|
-
* are accepted:
|
|
233
|
-
*
|
|
234
|
-
* ```
|
|
235
|
-
* tag ::= "<" tagName (whitespace)* "/>" | "<" tagName (whitespace)* ">" message "</" tagName (whitespace)* ">"
|
|
236
|
-
* tagName ::= [a-z] (PENChar)*
|
|
237
|
-
* PENChar ::=
|
|
238
|
-
* "-" | "." | [0-9] | "_" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
|
|
239
|
-
* [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
|
|
240
|
-
* [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
|
241
|
-
* ```
|
|
242
|
-
*
|
|
243
|
-
* [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
|
|
244
|
-
* NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do
|
|
245
|
-
* since other tag-based engines like React allow it
|
|
246
|
-
*/
|
|
247
|
-
Parser.prototype.parseTag = function (nestingLevel, parentArgType) {
|
|
248
|
-
var startPosition = this.clonePosition();
|
|
249
|
-
this.bump(); // `<`
|
|
250
|
-
var tagName = this.parseTagName();
|
|
251
|
-
this.bumpSpace();
|
|
252
|
-
if (this.bumpIf('/>')) {
|
|
253
|
-
// Self closing tag
|
|
254
|
-
return {
|
|
255
|
-
val: {
|
|
256
|
-
type: TYPE.literal,
|
|
257
|
-
value: "<".concat(tagName, "/>"),
|
|
258
|
-
location: createLocation(startPosition, this.clonePosition()),
|
|
259
|
-
},
|
|
260
|
-
err: null,
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
else if (this.bumpIf('>')) {
|
|
264
|
-
var childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, true);
|
|
265
|
-
if (childrenResult.err) {
|
|
266
|
-
return childrenResult;
|
|
267
|
-
}
|
|
268
|
-
var children = childrenResult.val;
|
|
269
|
-
// Expecting a close tag
|
|
270
|
-
var endTagStartPosition = this.clonePosition();
|
|
271
|
-
if (this.bumpIf('</')) {
|
|
272
|
-
if (this.isEOF() || !_isAlpha(this.char())) {
|
|
273
|
-
return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
|
|
274
|
-
}
|
|
275
|
-
var closingTagNameStartPosition = this.clonePosition();
|
|
276
|
-
var closingTagName = this.parseTagName();
|
|
277
|
-
if (tagName !== closingTagName) {
|
|
278
|
-
return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition()));
|
|
279
|
-
}
|
|
280
|
-
this.bumpSpace();
|
|
281
|
-
if (!this.bumpIf('>')) {
|
|
282
|
-
return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
|
|
283
|
-
}
|
|
284
|
-
return {
|
|
285
|
-
val: {
|
|
286
|
-
type: TYPE.tag,
|
|
287
|
-
value: tagName,
|
|
288
|
-
children: children,
|
|
289
|
-
location: createLocation(startPosition, this.clonePosition()),
|
|
290
|
-
},
|
|
291
|
-
err: null,
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
/**
|
|
303
|
-
* This method assumes that the caller has peeked ahead for the first tag character.
|
|
304
|
-
*/
|
|
305
|
-
Parser.prototype.parseTagName = function () {
|
|
306
|
-
var startOffset = this.offset();
|
|
307
|
-
this.bump(); // the first tag name character
|
|
308
|
-
while (!this.isEOF() && _isPotentialElementNameChar(this.char())) {
|
|
309
|
-
this.bump();
|
|
310
|
-
}
|
|
311
|
-
return this.message.slice(startOffset, this.offset());
|
|
312
|
-
};
|
|
313
|
-
Parser.prototype.parseLiteral = function (nestingLevel, parentArgType) {
|
|
314
|
-
var start = this.clonePosition();
|
|
315
|
-
var value = '';
|
|
316
|
-
while (true) {
|
|
317
|
-
var parseQuoteResult = this.tryParseQuote(parentArgType);
|
|
318
|
-
if (parseQuoteResult) {
|
|
319
|
-
value += parseQuoteResult;
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
var parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType);
|
|
323
|
-
if (parseUnquotedResult) {
|
|
324
|
-
value += parseUnquotedResult;
|
|
325
|
-
continue;
|
|
326
|
-
}
|
|
327
|
-
var parseLeftAngleResult = this.tryParseLeftAngleBracket();
|
|
328
|
-
if (parseLeftAngleResult) {
|
|
329
|
-
value += parseLeftAngleResult;
|
|
330
|
-
continue;
|
|
331
|
-
}
|
|
332
|
-
break;
|
|
333
|
-
}
|
|
334
|
-
var location = createLocation(start, this.clonePosition());
|
|
335
|
-
return {
|
|
336
|
-
val: { type: TYPE.literal, value: value, location: location },
|
|
337
|
-
err: null,
|
|
338
|
-
};
|
|
339
|
-
};
|
|
340
|
-
Parser.prototype.tryParseLeftAngleBracket = function () {
|
|
341
|
-
if (!this.isEOF() &&
|
|
342
|
-
this.char() === 60 /* `<` */ &&
|
|
343
|
-
(this.ignoreTag ||
|
|
344
|
-
// If at the opening tag or closing tag position, bail.
|
|
345
|
-
!_isAlphaOrSlash(this.peek() || 0))) {
|
|
346
|
-
this.bump(); // `<`
|
|
347
|
-
return '<';
|
|
348
|
-
}
|
|
349
|
-
return null;
|
|
350
|
-
};
|
|
351
|
-
/**
|
|
352
|
-
* Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes
|
|
353
|
-
* a character that requires quoting (that is, "only where needed"), and works the same in
|
|
354
|
-
* nested messages as on the top level of the pattern. The new behavior is otherwise compatible.
|
|
355
|
-
*/
|
|
356
|
-
Parser.prototype.tryParseQuote = function (parentArgType) {
|
|
357
|
-
if (this.isEOF() || this.char() !== 39 /* `'` */) {
|
|
358
|
-
return null;
|
|
359
|
-
}
|
|
360
|
-
// Parse escaped char following the apostrophe, or early return if there is no escaped char.
|
|
361
|
-
// Check if is valid escaped character
|
|
362
|
-
switch (this.peek()) {
|
|
363
|
-
case 39 /* `'` */:
|
|
364
|
-
// double quote, should return as a single quote.
|
|
365
|
-
this.bump();
|
|
366
|
-
this.bump();
|
|
367
|
-
return "'";
|
|
368
|
-
// '{', '<', '>', '}'
|
|
369
|
-
case 123:
|
|
370
|
-
case 60:
|
|
371
|
-
case 62:
|
|
372
|
-
case 125:
|
|
373
|
-
break;
|
|
374
|
-
case 35: // '#'
|
|
375
|
-
if (parentArgType === 'plural' || parentArgType === 'selectordinal') {
|
|
376
|
-
break;
|
|
377
|
-
}
|
|
378
|
-
return null;
|
|
379
|
-
default:
|
|
380
|
-
return null;
|
|
381
|
-
}
|
|
382
|
-
this.bump(); // apostrophe
|
|
383
|
-
var codePoints = [this.char()]; // escaped char
|
|
384
|
-
this.bump();
|
|
385
|
-
// read chars until the optional closing apostrophe is found
|
|
386
|
-
while (!this.isEOF()) {
|
|
387
|
-
var ch = this.char();
|
|
388
|
-
if (ch === 39 /* `'` */) {
|
|
389
|
-
if (this.peek() === 39 /* `'` */) {
|
|
390
|
-
codePoints.push(39);
|
|
391
|
-
// Bump one more time because we need to skip 2 characters.
|
|
392
|
-
this.bump();
|
|
393
|
-
}
|
|
394
|
-
else {
|
|
395
|
-
// Optional closing apostrophe.
|
|
396
|
-
this.bump();
|
|
397
|
-
break;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
codePoints.push(ch);
|
|
402
|
-
}
|
|
403
|
-
this.bump();
|
|
404
|
-
}
|
|
405
|
-
return fromCodePoint.apply(void 0, codePoints);
|
|
406
|
-
};
|
|
407
|
-
Parser.prototype.tryParseUnquoted = function (nestingLevel, parentArgType) {
|
|
408
|
-
if (this.isEOF()) {
|
|
409
|
-
return null;
|
|
410
|
-
}
|
|
411
|
-
var ch = this.char();
|
|
412
|
-
if (ch === 60 /* `<` */ ||
|
|
413
|
-
ch === 123 /* `{` */ ||
|
|
414
|
-
(ch === 35 /* `#` */ &&
|
|
415
|
-
(parentArgType === 'plural' || parentArgType === 'selectordinal')) ||
|
|
416
|
-
(ch === 125 /* `}` */ && nestingLevel > 0)) {
|
|
417
|
-
return null;
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
this.bump();
|
|
421
|
-
return fromCodePoint(ch);
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
Parser.prototype.parseArgument = function (nestingLevel, expectingCloseTag) {
|
|
425
|
-
var openingBracePosition = this.clonePosition();
|
|
426
|
-
this.bump(); // `{`
|
|
427
|
-
this.bumpSpace();
|
|
428
|
-
if (this.isEOF()) {
|
|
429
|
-
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
|
430
|
-
}
|
|
431
|
-
if (this.char() === 125 /* `}` */) {
|
|
432
|
-
this.bump();
|
|
433
|
-
return this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
|
|
434
|
-
}
|
|
435
|
-
// argument name
|
|
436
|
-
var value = this.parseIdentifierIfPossible().value;
|
|
437
|
-
if (!value) {
|
|
438
|
-
return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
|
|
439
|
-
}
|
|
440
|
-
this.bumpSpace();
|
|
441
|
-
if (this.isEOF()) {
|
|
442
|
-
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
|
443
|
-
}
|
|
444
|
-
switch (this.char()) {
|
|
445
|
-
// Simple argument: `{name}`
|
|
446
|
-
case 125 /* `}` */: {
|
|
447
|
-
this.bump(); // `}`
|
|
448
|
-
return {
|
|
449
|
-
val: {
|
|
450
|
-
type: TYPE.argument,
|
|
451
|
-
// value does not include the opening and closing braces.
|
|
452
|
-
value: value,
|
|
453
|
-
location: createLocation(openingBracePosition, this.clonePosition()),
|
|
454
|
-
},
|
|
455
|
-
err: null,
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
// Argument with options: `{name, format, ...}`
|
|
459
|
-
case 44 /* `,` */: {
|
|
460
|
-
this.bump(); // `,`
|
|
461
|
-
this.bumpSpace();
|
|
462
|
-
if (this.isEOF()) {
|
|
463
|
-
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
|
464
|
-
}
|
|
465
|
-
return this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);
|
|
466
|
-
}
|
|
467
|
-
default:
|
|
468
|
-
return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
/**
|
|
472
|
-
* Advance the parser until the end of the identifier, if it is currently on
|
|
473
|
-
* an identifier character. Return an empty string otherwise.
|
|
474
|
-
*/
|
|
475
|
-
Parser.prototype.parseIdentifierIfPossible = function () {
|
|
476
|
-
var startingPosition = this.clonePosition();
|
|
477
|
-
var startOffset = this.offset();
|
|
478
|
-
var value = matchIdentifierAtIndex(this.message, startOffset);
|
|
479
|
-
var endOffset = startOffset + value.length;
|
|
480
|
-
this.bumpTo(endOffset);
|
|
481
|
-
var endPosition = this.clonePosition();
|
|
482
|
-
var location = createLocation(startingPosition, endPosition);
|
|
483
|
-
return { value: value, location: location };
|
|
484
|
-
};
|
|
485
|
-
Parser.prototype.parseArgumentOptions = function (nestingLevel, expectingCloseTag, value, openingBracePosition) {
|
|
486
|
-
var _a;
|
|
487
|
-
// Parse this range:
|
|
488
|
-
// {name, type, style}
|
|
489
|
-
// ^---^
|
|
490
|
-
var typeStartPosition = this.clonePosition();
|
|
491
|
-
var argType = this.parseIdentifierIfPossible().value;
|
|
492
|
-
var typeEndPosition = this.clonePosition();
|
|
493
|
-
switch (argType) {
|
|
494
|
-
case '':
|
|
495
|
-
// Expecting a style string number, date, time, plural, selectordinal, or select.
|
|
496
|
-
return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
|
|
497
|
-
case 'number':
|
|
498
|
-
case 'date':
|
|
499
|
-
case 'time': {
|
|
500
|
-
// Parse this range:
|
|
501
|
-
// {name, number, style}
|
|
502
|
-
// ^-------^
|
|
503
|
-
this.bumpSpace();
|
|
504
|
-
var styleAndLocation = null;
|
|
505
|
-
if (this.bumpIf(',')) {
|
|
506
|
-
this.bumpSpace();
|
|
507
|
-
var styleStartPosition = this.clonePosition();
|
|
508
|
-
var result = this.parseSimpleArgStyleIfPossible();
|
|
509
|
-
if (result.err) {
|
|
510
|
-
return result;
|
|
511
|
-
}
|
|
512
|
-
var style = trimEnd(result.val);
|
|
513
|
-
if (style.length === 0) {
|
|
514
|
-
return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
|
|
515
|
-
}
|
|
516
|
-
var styleLocation = createLocation(styleStartPosition, this.clonePosition());
|
|
517
|
-
styleAndLocation = { style: style, styleLocation: styleLocation };
|
|
518
|
-
}
|
|
519
|
-
var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
|
|
520
|
-
if (argCloseResult.err) {
|
|
521
|
-
return argCloseResult;
|
|
522
|
-
}
|
|
523
|
-
var location_1 = createLocation(openingBracePosition, this.clonePosition());
|
|
524
|
-
// Extract style or skeleton
|
|
525
|
-
if (styleAndLocation && startsWith(styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style, '::', 0)) {
|
|
526
|
-
// Skeleton starts with `::`.
|
|
527
|
-
var skeleton = trimStart(styleAndLocation.style.slice(2));
|
|
528
|
-
if (argType === 'number') {
|
|
529
|
-
var result = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation);
|
|
530
|
-
if (result.err) {
|
|
531
|
-
return result;
|
|
532
|
-
}
|
|
533
|
-
return {
|
|
534
|
-
val: { type: TYPE.number, value: value, location: location_1, style: result.val },
|
|
535
|
-
err: null,
|
|
536
|
-
};
|
|
537
|
-
}
|
|
538
|
-
else {
|
|
539
|
-
if (skeleton.length === 0) {
|
|
540
|
-
return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1);
|
|
541
|
-
}
|
|
542
|
-
var dateTimePattern = skeleton;
|
|
543
|
-
// Get "best match" pattern only if locale is passed, if not, let it
|
|
544
|
-
// pass as-is where `parseDateTimeSkeleton()` will throw an error
|
|
545
|
-
// for unsupported patterns.
|
|
546
|
-
if (this.locale) {
|
|
547
|
-
dateTimePattern = getBestPattern(skeleton, this.locale);
|
|
548
|
-
}
|
|
549
|
-
var style = {
|
|
550
|
-
type: SKELETON_TYPE.dateTime,
|
|
551
|
-
pattern: dateTimePattern,
|
|
552
|
-
location: styleAndLocation.styleLocation,
|
|
553
|
-
parsedOptions: this.shouldParseSkeletons
|
|
554
|
-
? parseDateTimeSkeleton(dateTimePattern)
|
|
555
|
-
: {},
|
|
556
|
-
};
|
|
557
|
-
var type = argType === 'date' ? TYPE.date : TYPE.time;
|
|
558
|
-
return {
|
|
559
|
-
val: { type: type, value: value, location: location_1, style: style },
|
|
560
|
-
err: null,
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
// Regular style or no style.
|
|
565
|
-
return {
|
|
566
|
-
val: {
|
|
567
|
-
type: argType === 'number'
|
|
568
|
-
? TYPE.number
|
|
569
|
-
: argType === 'date'
|
|
570
|
-
? TYPE.date
|
|
571
|
-
: TYPE.time,
|
|
572
|
-
value: value,
|
|
573
|
-
location: location_1,
|
|
574
|
-
style: (_a = styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style) !== null && _a !== void 0 ? _a : null,
|
|
575
|
-
},
|
|
576
|
-
err: null,
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
case 'plural':
|
|
580
|
-
case 'selectordinal':
|
|
581
|
-
case 'select': {
|
|
582
|
-
// Parse this range:
|
|
583
|
-
// {name, plural, options}
|
|
584
|
-
// ^---------^
|
|
585
|
-
var typeEndPosition_1 = this.clonePosition();
|
|
586
|
-
this.bumpSpace();
|
|
587
|
-
if (!this.bumpIf(',')) {
|
|
588
|
-
return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, __assign({}, typeEndPosition_1)));
|
|
589
|
-
}
|
|
590
|
-
this.bumpSpace();
|
|
591
|
-
// Parse offset:
|
|
592
|
-
// {name, plural, offset:1, options}
|
|
593
|
-
// ^-----^
|
|
594
|
-
//
|
|
595
|
-
// or the first option:
|
|
596
|
-
//
|
|
597
|
-
// {name, plural, one {...} other {...}}
|
|
598
|
-
// ^--^
|
|
599
|
-
var identifierAndLocation = this.parseIdentifierIfPossible();
|
|
600
|
-
var pluralOffset = 0;
|
|
601
|
-
if (argType !== 'select' && identifierAndLocation.value === 'offset') {
|
|
602
|
-
if (!this.bumpIf(':')) {
|
|
603
|
-
return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));
|
|
604
|
-
}
|
|
605
|
-
this.bumpSpace();
|
|
606
|
-
var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
|
|
607
|
-
if (result.err) {
|
|
608
|
-
return result;
|
|
609
|
-
}
|
|
610
|
-
// Parse another identifier for option parsing
|
|
611
|
-
this.bumpSpace();
|
|
612
|
-
identifierAndLocation = this.parseIdentifierIfPossible();
|
|
613
|
-
pluralOffset = result.val;
|
|
614
|
-
}
|
|
615
|
-
var optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation);
|
|
616
|
-
if (optionsResult.err) {
|
|
617
|
-
return optionsResult;
|
|
618
|
-
}
|
|
619
|
-
var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
|
|
620
|
-
if (argCloseResult.err) {
|
|
621
|
-
return argCloseResult;
|
|
622
|
-
}
|
|
623
|
-
var location_2 = createLocation(openingBracePosition, this.clonePosition());
|
|
624
|
-
if (argType === 'select') {
|
|
625
|
-
return {
|
|
626
|
-
val: {
|
|
627
|
-
type: TYPE.select,
|
|
628
|
-
value: value,
|
|
629
|
-
options: fromEntries(optionsResult.val),
|
|
630
|
-
location: location_2,
|
|
631
|
-
},
|
|
632
|
-
err: null,
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
else {
|
|
636
|
-
return {
|
|
637
|
-
val: {
|
|
638
|
-
type: TYPE.plural,
|
|
639
|
-
value: value,
|
|
640
|
-
options: fromEntries(optionsResult.val),
|
|
641
|
-
offset: pluralOffset,
|
|
642
|
-
pluralType: argType === 'plural' ? 'cardinal' : 'ordinal',
|
|
643
|
-
location: location_2,
|
|
644
|
-
},
|
|
645
|
-
err: null,
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
default:
|
|
650
|
-
return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
Parser.prototype.tryParseArgumentClose = function (openingBracePosition) {
|
|
654
|
-
// Parse: {value, number, ::currency/GBP }
|
|
655
|
-
//
|
|
656
|
-
if (this.isEOF() || this.char() !== 125 /* `}` */) {
|
|
657
|
-
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
|
658
|
-
}
|
|
659
|
-
this.bump(); // `}`
|
|
660
|
-
return { val: true, err: null };
|
|
661
|
-
};
|
|
662
|
-
/**
|
|
663
|
-
* See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659
|
|
664
|
-
*/
|
|
665
|
-
Parser.prototype.parseSimpleArgStyleIfPossible = function () {
|
|
666
|
-
var nestedBraces = 0;
|
|
667
|
-
var startPosition = this.clonePosition();
|
|
668
|
-
while (!this.isEOF()) {
|
|
669
|
-
var ch = this.char();
|
|
670
|
-
switch (ch) {
|
|
671
|
-
case 39 /* `'` */: {
|
|
672
|
-
// Treat apostrophe as quoting but include it in the style part.
|
|
673
|
-
// Find the end of the quoted literal text.
|
|
674
|
-
this.bump();
|
|
675
|
-
var apostrophePosition = this.clonePosition();
|
|
676
|
-
if (!this.bumpUntil("'")) {
|
|
677
|
-
return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));
|
|
678
|
-
}
|
|
679
|
-
this.bump();
|
|
680
|
-
break;
|
|
681
|
-
}
|
|
682
|
-
case 123 /* `{` */: {
|
|
683
|
-
nestedBraces += 1;
|
|
684
|
-
this.bump();
|
|
685
|
-
break;
|
|
686
|
-
}
|
|
687
|
-
case 125 /* `}` */: {
|
|
688
|
-
if (nestedBraces > 0) {
|
|
689
|
-
nestedBraces -= 1;
|
|
690
|
-
}
|
|
691
|
-
else {
|
|
692
|
-
return {
|
|
693
|
-
val: this.message.slice(startPosition.offset, this.offset()),
|
|
694
|
-
err: null,
|
|
695
|
-
};
|
|
696
|
-
}
|
|
697
|
-
break;
|
|
698
|
-
}
|
|
699
|
-
default:
|
|
700
|
-
this.bump();
|
|
701
|
-
break;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
return {
|
|
705
|
-
val: this.message.slice(startPosition.offset, this.offset()),
|
|
706
|
-
err: null,
|
|
707
|
-
};
|
|
708
|
-
};
|
|
709
|
-
Parser.prototype.parseNumberSkeletonFromString = function (skeleton, location) {
|
|
710
|
-
var tokens = [];
|
|
711
|
-
try {
|
|
712
|
-
tokens = parseNumberSkeletonFromString(skeleton);
|
|
713
|
-
}
|
|
714
|
-
catch (e) {
|
|
715
|
-
return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location);
|
|
716
|
-
}
|
|
717
|
-
return {
|
|
718
|
-
val: {
|
|
719
|
-
type: SKELETON_TYPE.number,
|
|
720
|
-
tokens: tokens,
|
|
721
|
-
location: location,
|
|
722
|
-
parsedOptions: this.shouldParseSkeletons
|
|
723
|
-
? parseNumberSkeleton(tokens)
|
|
724
|
-
: {},
|
|
725
|
-
},
|
|
726
|
-
err: null,
|
|
727
|
-
};
|
|
728
|
-
};
|
|
729
|
-
/**
|
|
730
|
-
* @param nesting_level The current nesting level of messages.
|
|
731
|
-
* This can be positive when parsing message fragment in select or plural argument options.
|
|
732
|
-
* @param parent_arg_type The parent argument's type.
|
|
733
|
-
* @param parsed_first_identifier If provided, this is the first identifier-like selector of
|
|
734
|
-
* the argument. It is a by-product of a previous parsing attempt.
|
|
735
|
-
* @param expecting_close_tag If true, this message is directly or indirectly nested inside
|
|
736
|
-
* between a pair of opening and closing tags. The nested message will not parse beyond
|
|
737
|
-
* the closing tag boundary.
|
|
738
|
-
*/
|
|
739
|
-
Parser.prototype.tryParsePluralOrSelectOptions = function (nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {
|
|
740
|
-
var _a;
|
|
741
|
-
var hasOtherClause = false;
|
|
742
|
-
var options = [];
|
|
743
|
-
var parsedSelectors = new Set();
|
|
744
|
-
var selector = parsedFirstIdentifier.value, selectorLocation = parsedFirstIdentifier.location;
|
|
745
|
-
// Parse:
|
|
746
|
-
// one {one apple}
|
|
747
|
-
// ^--^
|
|
748
|
-
while (true) {
|
|
749
|
-
if (selector.length === 0) {
|
|
750
|
-
var startPosition = this.clonePosition();
|
|
751
|
-
if (parentArgType !== 'select' && this.bumpIf('=')) {
|
|
752
|
-
// Try parse `={number}` selector
|
|
753
|
-
var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);
|
|
754
|
-
if (result.err) {
|
|
755
|
-
return result;
|
|
756
|
-
}
|
|
757
|
-
selectorLocation = createLocation(startPosition, this.clonePosition());
|
|
758
|
-
selector = this.message.slice(startPosition.offset, this.offset());
|
|
759
|
-
}
|
|
760
|
-
else {
|
|
761
|
-
break;
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
// Duplicate selector clauses
|
|
765
|
-
if (parsedSelectors.has(selector)) {
|
|
766
|
-
return this.error(parentArgType === 'select'
|
|
767
|
-
? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR
|
|
768
|
-
: ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);
|
|
769
|
-
}
|
|
770
|
-
if (selector === 'other') {
|
|
771
|
-
hasOtherClause = true;
|
|
772
|
-
}
|
|
773
|
-
// Parse:
|
|
774
|
-
// one {one apple}
|
|
775
|
-
// ^----------^
|
|
776
|
-
this.bumpSpace();
|
|
777
|
-
var openingBracePosition = this.clonePosition();
|
|
778
|
-
if (!this.bumpIf('{')) {
|
|
779
|
-
return this.error(parentArgType === 'select'
|
|
780
|
-
? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT
|
|
781
|
-
: ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));
|
|
782
|
-
}
|
|
783
|
-
var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);
|
|
784
|
-
if (fragmentResult.err) {
|
|
785
|
-
return fragmentResult;
|
|
786
|
-
}
|
|
787
|
-
var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
|
|
788
|
-
if (argCloseResult.err) {
|
|
789
|
-
return argCloseResult;
|
|
790
|
-
}
|
|
791
|
-
options.push([
|
|
792
|
-
selector,
|
|
793
|
-
{
|
|
794
|
-
value: fragmentResult.val,
|
|
795
|
-
location: createLocation(openingBracePosition, this.clonePosition()),
|
|
796
|
-
},
|
|
797
|
-
]);
|
|
798
|
-
// Keep track of the existing selectors
|
|
799
|
-
parsedSelectors.add(selector);
|
|
800
|
-
// Prep next selector clause.
|
|
801
|
-
this.bumpSpace();
|
|
802
|
-
(_a = this.parseIdentifierIfPossible(), selector = _a.value, selectorLocation = _a.location);
|
|
803
|
-
}
|
|
804
|
-
if (options.length === 0) {
|
|
805
|
-
return this.error(parentArgType === 'select'
|
|
806
|
-
? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR
|
|
807
|
-
: ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition()));
|
|
808
|
-
}
|
|
809
|
-
if (this.requiresOtherClause && !hasOtherClause) {
|
|
810
|
-
return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
|
|
811
|
-
}
|
|
812
|
-
return { val: options, err: null };
|
|
813
|
-
};
|
|
814
|
-
Parser.prototype.tryParseDecimalInteger = function (expectNumberError, invalidNumberError) {
|
|
815
|
-
var sign = 1;
|
|
816
|
-
var startingPosition = this.clonePosition();
|
|
817
|
-
if (this.bumpIf('+')) {
|
|
818
|
-
}
|
|
819
|
-
else if (this.bumpIf('-')) {
|
|
820
|
-
sign = -1;
|
|
821
|
-
}
|
|
822
|
-
var hasDigits = false;
|
|
823
|
-
var decimal = 0;
|
|
824
|
-
while (!this.isEOF()) {
|
|
825
|
-
var ch = this.char();
|
|
826
|
-
if (ch >= 48 /* `0` */ && ch <= 57 /* `9` */) {
|
|
827
|
-
hasDigits = true;
|
|
828
|
-
decimal = decimal * 10 + (ch - 48);
|
|
829
|
-
this.bump();
|
|
830
|
-
}
|
|
831
|
-
else {
|
|
832
|
-
break;
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
var location = createLocation(startingPosition, this.clonePosition());
|
|
836
|
-
if (!hasDigits) {
|
|
837
|
-
return this.error(expectNumberError, location);
|
|
838
|
-
}
|
|
839
|
-
decimal *= sign;
|
|
840
|
-
if (!isSafeInteger(decimal)) {
|
|
841
|
-
return this.error(invalidNumberError, location);
|
|
842
|
-
}
|
|
843
|
-
return { val: decimal, err: null };
|
|
844
|
-
};
|
|
845
|
-
Parser.prototype.offset = function () {
|
|
846
|
-
return this.position.offset;
|
|
847
|
-
};
|
|
848
|
-
Parser.prototype.isEOF = function () {
|
|
849
|
-
return this.offset() === this.message.length;
|
|
850
|
-
};
|
|
851
|
-
Parser.prototype.clonePosition = function () {
|
|
852
|
-
// This is much faster than `Object.assign` or spread.
|
|
853
|
-
return {
|
|
854
|
-
offset: this.position.offset,
|
|
855
|
-
line: this.position.line,
|
|
856
|
-
column: this.position.column,
|
|
857
|
-
};
|
|
858
|
-
};
|
|
859
|
-
/**
|
|
860
|
-
* Return the code point at the current position of the parser.
|
|
861
|
-
* Throws if the index is out of bound.
|
|
862
|
-
*/
|
|
863
|
-
Parser.prototype.char = function () {
|
|
864
|
-
var offset = this.position.offset;
|
|
865
|
-
if (offset >= this.message.length) {
|
|
866
|
-
throw Error('out of bound');
|
|
867
|
-
}
|
|
868
|
-
var code = codePointAt(this.message, offset);
|
|
869
|
-
if (code === undefined) {
|
|
870
|
-
throw Error("Offset ".concat(offset, " is at invalid UTF-16 code unit boundary"));
|
|
871
|
-
}
|
|
872
|
-
return code;
|
|
873
|
-
};
|
|
874
|
-
Parser.prototype.error = function (kind, location) {
|
|
875
|
-
return {
|
|
876
|
-
val: null,
|
|
877
|
-
err: {
|
|
878
|
-
kind: kind,
|
|
879
|
-
message: this.message,
|
|
880
|
-
location: location,
|
|
881
|
-
},
|
|
882
|
-
};
|
|
883
|
-
};
|
|
884
|
-
/** Bump the parser to the next UTF-16 code unit. */
|
|
885
|
-
Parser.prototype.bump = function () {
|
|
886
|
-
if (this.isEOF()) {
|
|
887
|
-
return;
|
|
888
|
-
}
|
|
889
|
-
var code = this.char();
|
|
890
|
-
if (code === 10 /* '\n' */) {
|
|
891
|
-
this.position.line += 1;
|
|
892
|
-
this.position.column = 1;
|
|
893
|
-
this.position.offset += 1;
|
|
894
|
-
}
|
|
895
|
-
else {
|
|
896
|
-
this.position.column += 1;
|
|
897
|
-
// 0 ~ 0x10000 -> unicode BMP, otherwise skip the surrogate pair.
|
|
898
|
-
this.position.offset += code < 0x10000 ? 1 : 2;
|
|
899
|
-
}
|
|
900
|
-
};
|
|
901
|
-
/**
|
|
902
|
-
* If the substring starting at the current position of the parser has
|
|
903
|
-
* the given prefix, then bump the parser to the character immediately
|
|
904
|
-
* following the prefix and return true. Otherwise, don't bump the parser
|
|
905
|
-
* and return false.
|
|
906
|
-
*/
|
|
907
|
-
Parser.prototype.bumpIf = function (prefix) {
|
|
908
|
-
if (startsWith(this.message, prefix, this.offset())) {
|
|
909
|
-
for (var i = 0; i < prefix.length; i++) {
|
|
910
|
-
this.bump();
|
|
911
|
-
}
|
|
912
|
-
return true;
|
|
913
|
-
}
|
|
914
|
-
return false;
|
|
915
|
-
};
|
|
916
|
-
/**
|
|
917
|
-
* Bump the parser until the pattern character is found and return `true`.
|
|
918
|
-
* Otherwise bump to the end of the file and return `false`.
|
|
919
|
-
*/
|
|
920
|
-
Parser.prototype.bumpUntil = function (pattern) {
|
|
921
|
-
var currentOffset = this.offset();
|
|
922
|
-
var index = this.message.indexOf(pattern, currentOffset);
|
|
923
|
-
if (index >= 0) {
|
|
924
|
-
this.bumpTo(index);
|
|
925
|
-
return true;
|
|
926
|
-
}
|
|
927
|
-
else {
|
|
928
|
-
this.bumpTo(this.message.length);
|
|
929
|
-
return false;
|
|
930
|
-
}
|
|
931
|
-
};
|
|
932
|
-
/**
|
|
933
|
-
* Bump the parser to the target offset.
|
|
934
|
-
* If target offset is beyond the end of the input, bump the parser to the end of the input.
|
|
935
|
-
*/
|
|
936
|
-
Parser.prototype.bumpTo = function (targetOffset) {
|
|
937
|
-
if (this.offset() > targetOffset) {
|
|
938
|
-
throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset()));
|
|
939
|
-
}
|
|
940
|
-
targetOffset = Math.min(targetOffset, this.message.length);
|
|
941
|
-
while (true) {
|
|
942
|
-
var offset = this.offset();
|
|
943
|
-
if (offset === targetOffset) {
|
|
944
|
-
break;
|
|
945
|
-
}
|
|
946
|
-
if (offset > targetOffset) {
|
|
947
|
-
throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary"));
|
|
948
|
-
}
|
|
949
|
-
this.bump();
|
|
950
|
-
if (this.isEOF()) {
|
|
951
|
-
break;
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
};
|
|
955
|
-
/** advance the parser through all whitespace to the next non-whitespace code unit. */
|
|
956
|
-
Parser.prototype.bumpSpace = function () {
|
|
957
|
-
while (!this.isEOF() && _isWhiteSpace(this.char())) {
|
|
958
|
-
this.bump();
|
|
959
|
-
}
|
|
960
|
-
};
|
|
961
|
-
/**
|
|
962
|
-
* Peek at the *next* Unicode codepoint in the input without advancing the parser.
|
|
963
|
-
* If the input has been exhausted, then this returns null.
|
|
964
|
-
*/
|
|
965
|
-
Parser.prototype.peek = function () {
|
|
966
|
-
if (this.isEOF()) {
|
|
967
|
-
return null;
|
|
968
|
-
}
|
|
969
|
-
var code = this.char();
|
|
970
|
-
var offset = this.offset();
|
|
971
|
-
var nextCode = this.message.charCodeAt(offset + (code >= 0x10000 ? 2 : 1));
|
|
972
|
-
return nextCode !== null && nextCode !== void 0 ? nextCode : null;
|
|
973
|
-
};
|
|
974
|
-
return Parser;
|
|
975
|
-
}());
|
|
976
|
-
export { Parser };
|
|
977
|
-
/**
|
|
978
|
-
* This check if codepoint is alphabet (lower & uppercase)
|
|
979
|
-
* @param codepoint
|
|
980
|
-
* @returns
|
|
981
|
-
*/
|
|
982
|
-
function _isAlpha(codepoint) {
|
|
983
|
-
return ((codepoint >= 97 && codepoint <= 122) ||
|
|
984
|
-
(codepoint >= 65 && codepoint <= 90));
|
|
985
|
-
}
|
|
986
|
-
function _isAlphaOrSlash(codepoint) {
|
|
987
|
-
return _isAlpha(codepoint) || codepoint === 47; /* '/' */
|
|
988
|
-
}
|
|
989
|
-
/** See `parseTag` function docs. */
|
|
990
|
-
function _isPotentialElementNameChar(c) {
|
|
991
|
-
return (c === 45 /* '-' */ ||
|
|
992
|
-
c === 46 /* '.' */ ||
|
|
993
|
-
(c >= 48 && c <= 57) /* 0..9 */ ||
|
|
994
|
-
c === 95 /* '_' */ ||
|
|
995
|
-
(c >= 97 && c <= 122) /** a..z */ ||
|
|
996
|
-
(c >= 65 && c <= 90) /* A..Z */ ||
|
|
997
|
-
c == 0xb7 ||
|
|
998
|
-
(c >= 0xc0 && c <= 0xd6) ||
|
|
999
|
-
(c >= 0xd8 && c <= 0xf6) ||
|
|
1000
|
-
(c >= 0xf8 && c <= 0x37d) ||
|
|
1001
|
-
(c >= 0x37f && c <= 0x1fff) ||
|
|
1002
|
-
(c >= 0x200c && c <= 0x200d) ||
|
|
1003
|
-
(c >= 0x203f && c <= 0x2040) ||
|
|
1004
|
-
(c >= 0x2070 && c <= 0x218f) ||
|
|
1005
|
-
(c >= 0x2c00 && c <= 0x2fef) ||
|
|
1006
|
-
(c >= 0x3001 && c <= 0xd7ff) ||
|
|
1007
|
-
(c >= 0xf900 && c <= 0xfdcf) ||
|
|
1008
|
-
(c >= 0xfdf0 && c <= 0xfffd) ||
|
|
1009
|
-
(c >= 0x10000 && c <= 0xeffff));
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
|
-
* Code point equivalent of regex `\p{White_Space}`.
|
|
1013
|
-
* From: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
|
|
1014
|
-
*/
|
|
1015
|
-
function _isWhiteSpace(c) {
|
|
1016
|
-
return ((c >= 0x0009 && c <= 0x000d) ||
|
|
1017
|
-
c === 0x0020 ||
|
|
1018
|
-
c === 0x0085 ||
|
|
1019
|
-
(c >= 0x200e && c <= 0x200f) ||
|
|
1020
|
-
c === 0x2028 ||
|
|
1021
|
-
c === 0x2029);
|
|
1022
|
-
}
|
|
1023
|
-
/**
|
|
1024
|
-
* Code point equivalent of regex `\p{Pattern_Syntax}`.
|
|
1025
|
-
* See https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
|
|
1026
|
-
*/
|
|
1027
|
-
function _isPatternSyntax(c) {
|
|
1028
|
-
return ((c >= 0x0021 && c <= 0x0023) ||
|
|
1029
|
-
c === 0x0024 ||
|
|
1030
|
-
(c >= 0x0025 && c <= 0x0027) ||
|
|
1031
|
-
c === 0x0028 ||
|
|
1032
|
-
c === 0x0029 ||
|
|
1033
|
-
c === 0x002a ||
|
|
1034
|
-
c === 0x002b ||
|
|
1035
|
-
c === 0x002c ||
|
|
1036
|
-
c === 0x002d ||
|
|
1037
|
-
(c >= 0x002e && c <= 0x002f) ||
|
|
1038
|
-
(c >= 0x003a && c <= 0x003b) ||
|
|
1039
|
-
(c >= 0x003c && c <= 0x003e) ||
|
|
1040
|
-
(c >= 0x003f && c <= 0x0040) ||
|
|
1041
|
-
c === 0x005b ||
|
|
1042
|
-
c === 0x005c ||
|
|
1043
|
-
c === 0x005d ||
|
|
1044
|
-
c === 0x005e ||
|
|
1045
|
-
c === 0x0060 ||
|
|
1046
|
-
c === 0x007b ||
|
|
1047
|
-
c === 0x007c ||
|
|
1048
|
-
c === 0x007d ||
|
|
1049
|
-
c === 0x007e ||
|
|
1050
|
-
c === 0x00a1 ||
|
|
1051
|
-
(c >= 0x00a2 && c <= 0x00a5) ||
|
|
1052
|
-
c === 0x00a6 ||
|
|
1053
|
-
c === 0x00a7 ||
|
|
1054
|
-
c === 0x00a9 ||
|
|
1055
|
-
c === 0x00ab ||
|
|
1056
|
-
c === 0x00ac ||
|
|
1057
|
-
c === 0x00ae ||
|
|
1058
|
-
c === 0x00b0 ||
|
|
1059
|
-
c === 0x00b1 ||
|
|
1060
|
-
c === 0x00b6 ||
|
|
1061
|
-
c === 0x00bb ||
|
|
1062
|
-
c === 0x00bf ||
|
|
1063
|
-
c === 0x00d7 ||
|
|
1064
|
-
c === 0x00f7 ||
|
|
1065
|
-
(c >= 0x2010 && c <= 0x2015) ||
|
|
1066
|
-
(c >= 0x2016 && c <= 0x2017) ||
|
|
1067
|
-
c === 0x2018 ||
|
|
1068
|
-
c === 0x2019 ||
|
|
1069
|
-
c === 0x201a ||
|
|
1070
|
-
(c >= 0x201b && c <= 0x201c) ||
|
|
1071
|
-
c === 0x201d ||
|
|
1072
|
-
c === 0x201e ||
|
|
1073
|
-
c === 0x201f ||
|
|
1074
|
-
(c >= 0x2020 && c <= 0x2027) ||
|
|
1075
|
-
(c >= 0x2030 && c <= 0x2038) ||
|
|
1076
|
-
c === 0x2039 ||
|
|
1077
|
-
c === 0x203a ||
|
|
1078
|
-
(c >= 0x203b && c <= 0x203e) ||
|
|
1079
|
-
(c >= 0x2041 && c <= 0x2043) ||
|
|
1080
|
-
c === 0x2044 ||
|
|
1081
|
-
c === 0x2045 ||
|
|
1082
|
-
c === 0x2046 ||
|
|
1083
|
-
(c >= 0x2047 && c <= 0x2051) ||
|
|
1084
|
-
c === 0x2052 ||
|
|
1085
|
-
c === 0x2053 ||
|
|
1086
|
-
(c >= 0x2055 && c <= 0x205e) ||
|
|
1087
|
-
(c >= 0x2190 && c <= 0x2194) ||
|
|
1088
|
-
(c >= 0x2195 && c <= 0x2199) ||
|
|
1089
|
-
(c >= 0x219a && c <= 0x219b) ||
|
|
1090
|
-
(c >= 0x219c && c <= 0x219f) ||
|
|
1091
|
-
c === 0x21a0 ||
|
|
1092
|
-
(c >= 0x21a1 && c <= 0x21a2) ||
|
|
1093
|
-
c === 0x21a3 ||
|
|
1094
|
-
(c >= 0x21a4 && c <= 0x21a5) ||
|
|
1095
|
-
c === 0x21a6 ||
|
|
1096
|
-
(c >= 0x21a7 && c <= 0x21ad) ||
|
|
1097
|
-
c === 0x21ae ||
|
|
1098
|
-
(c >= 0x21af && c <= 0x21cd) ||
|
|
1099
|
-
(c >= 0x21ce && c <= 0x21cf) ||
|
|
1100
|
-
(c >= 0x21d0 && c <= 0x21d1) ||
|
|
1101
|
-
c === 0x21d2 ||
|
|
1102
|
-
c === 0x21d3 ||
|
|
1103
|
-
c === 0x21d4 ||
|
|
1104
|
-
(c >= 0x21d5 && c <= 0x21f3) ||
|
|
1105
|
-
(c >= 0x21f4 && c <= 0x22ff) ||
|
|
1106
|
-
(c >= 0x2300 && c <= 0x2307) ||
|
|
1107
|
-
c === 0x2308 ||
|
|
1108
|
-
c === 0x2309 ||
|
|
1109
|
-
c === 0x230a ||
|
|
1110
|
-
c === 0x230b ||
|
|
1111
|
-
(c >= 0x230c && c <= 0x231f) ||
|
|
1112
|
-
(c >= 0x2320 && c <= 0x2321) ||
|
|
1113
|
-
(c >= 0x2322 && c <= 0x2328) ||
|
|
1114
|
-
c === 0x2329 ||
|
|
1115
|
-
c === 0x232a ||
|
|
1116
|
-
(c >= 0x232b && c <= 0x237b) ||
|
|
1117
|
-
c === 0x237c ||
|
|
1118
|
-
(c >= 0x237d && c <= 0x239a) ||
|
|
1119
|
-
(c >= 0x239b && c <= 0x23b3) ||
|
|
1120
|
-
(c >= 0x23b4 && c <= 0x23db) ||
|
|
1121
|
-
(c >= 0x23dc && c <= 0x23e1) ||
|
|
1122
|
-
(c >= 0x23e2 && c <= 0x2426) ||
|
|
1123
|
-
(c >= 0x2427 && c <= 0x243f) ||
|
|
1124
|
-
(c >= 0x2440 && c <= 0x244a) ||
|
|
1125
|
-
(c >= 0x244b && c <= 0x245f) ||
|
|
1126
|
-
(c >= 0x2500 && c <= 0x25b6) ||
|
|
1127
|
-
c === 0x25b7 ||
|
|
1128
|
-
(c >= 0x25b8 && c <= 0x25c0) ||
|
|
1129
|
-
c === 0x25c1 ||
|
|
1130
|
-
(c >= 0x25c2 && c <= 0x25f7) ||
|
|
1131
|
-
(c >= 0x25f8 && c <= 0x25ff) ||
|
|
1132
|
-
(c >= 0x2600 && c <= 0x266e) ||
|
|
1133
|
-
c === 0x266f ||
|
|
1134
|
-
(c >= 0x2670 && c <= 0x2767) ||
|
|
1135
|
-
c === 0x2768 ||
|
|
1136
|
-
c === 0x2769 ||
|
|
1137
|
-
c === 0x276a ||
|
|
1138
|
-
c === 0x276b ||
|
|
1139
|
-
c === 0x276c ||
|
|
1140
|
-
c === 0x276d ||
|
|
1141
|
-
c === 0x276e ||
|
|
1142
|
-
c === 0x276f ||
|
|
1143
|
-
c === 0x2770 ||
|
|
1144
|
-
c === 0x2771 ||
|
|
1145
|
-
c === 0x2772 ||
|
|
1146
|
-
c === 0x2773 ||
|
|
1147
|
-
c === 0x2774 ||
|
|
1148
|
-
c === 0x2775 ||
|
|
1149
|
-
(c >= 0x2794 && c <= 0x27bf) ||
|
|
1150
|
-
(c >= 0x27c0 && c <= 0x27c4) ||
|
|
1151
|
-
c === 0x27c5 ||
|
|
1152
|
-
c === 0x27c6 ||
|
|
1153
|
-
(c >= 0x27c7 && c <= 0x27e5) ||
|
|
1154
|
-
c === 0x27e6 ||
|
|
1155
|
-
c === 0x27e7 ||
|
|
1156
|
-
c === 0x27e8 ||
|
|
1157
|
-
c === 0x27e9 ||
|
|
1158
|
-
c === 0x27ea ||
|
|
1159
|
-
c === 0x27eb ||
|
|
1160
|
-
c === 0x27ec ||
|
|
1161
|
-
c === 0x27ed ||
|
|
1162
|
-
c === 0x27ee ||
|
|
1163
|
-
c === 0x27ef ||
|
|
1164
|
-
(c >= 0x27f0 && c <= 0x27ff) ||
|
|
1165
|
-
(c >= 0x2800 && c <= 0x28ff) ||
|
|
1166
|
-
(c >= 0x2900 && c <= 0x2982) ||
|
|
1167
|
-
c === 0x2983 ||
|
|
1168
|
-
c === 0x2984 ||
|
|
1169
|
-
c === 0x2985 ||
|
|
1170
|
-
c === 0x2986 ||
|
|
1171
|
-
c === 0x2987 ||
|
|
1172
|
-
c === 0x2988 ||
|
|
1173
|
-
c === 0x2989 ||
|
|
1174
|
-
c === 0x298a ||
|
|
1175
|
-
c === 0x298b ||
|
|
1176
|
-
c === 0x298c ||
|
|
1177
|
-
c === 0x298d ||
|
|
1178
|
-
c === 0x298e ||
|
|
1179
|
-
c === 0x298f ||
|
|
1180
|
-
c === 0x2990 ||
|
|
1181
|
-
c === 0x2991 ||
|
|
1182
|
-
c === 0x2992 ||
|
|
1183
|
-
c === 0x2993 ||
|
|
1184
|
-
c === 0x2994 ||
|
|
1185
|
-
c === 0x2995 ||
|
|
1186
|
-
c === 0x2996 ||
|
|
1187
|
-
c === 0x2997 ||
|
|
1188
|
-
c === 0x2998 ||
|
|
1189
|
-
(c >= 0x2999 && c <= 0x29d7) ||
|
|
1190
|
-
c === 0x29d8 ||
|
|
1191
|
-
c === 0x29d9 ||
|
|
1192
|
-
c === 0x29da ||
|
|
1193
|
-
c === 0x29db ||
|
|
1194
|
-
(c >= 0x29dc && c <= 0x29fb) ||
|
|
1195
|
-
c === 0x29fc ||
|
|
1196
|
-
c === 0x29fd ||
|
|
1197
|
-
(c >= 0x29fe && c <= 0x2aff) ||
|
|
1198
|
-
(c >= 0x2b00 && c <= 0x2b2f) ||
|
|
1199
|
-
(c >= 0x2b30 && c <= 0x2b44) ||
|
|
1200
|
-
(c >= 0x2b45 && c <= 0x2b46) ||
|
|
1201
|
-
(c >= 0x2b47 && c <= 0x2b4c) ||
|
|
1202
|
-
(c >= 0x2b4d && c <= 0x2b73) ||
|
|
1203
|
-
(c >= 0x2b74 && c <= 0x2b75) ||
|
|
1204
|
-
(c >= 0x2b76 && c <= 0x2b95) ||
|
|
1205
|
-
c === 0x2b96 ||
|
|
1206
|
-
(c >= 0x2b97 && c <= 0x2bff) ||
|
|
1207
|
-
(c >= 0x2e00 && c <= 0x2e01) ||
|
|
1208
|
-
c === 0x2e02 ||
|
|
1209
|
-
c === 0x2e03 ||
|
|
1210
|
-
c === 0x2e04 ||
|
|
1211
|
-
c === 0x2e05 ||
|
|
1212
|
-
(c >= 0x2e06 && c <= 0x2e08) ||
|
|
1213
|
-
c === 0x2e09 ||
|
|
1214
|
-
c === 0x2e0a ||
|
|
1215
|
-
c === 0x2e0b ||
|
|
1216
|
-
c === 0x2e0c ||
|
|
1217
|
-
c === 0x2e0d ||
|
|
1218
|
-
(c >= 0x2e0e && c <= 0x2e16) ||
|
|
1219
|
-
c === 0x2e17 ||
|
|
1220
|
-
(c >= 0x2e18 && c <= 0x2e19) ||
|
|
1221
|
-
c === 0x2e1a ||
|
|
1222
|
-
c === 0x2e1b ||
|
|
1223
|
-
c === 0x2e1c ||
|
|
1224
|
-
c === 0x2e1d ||
|
|
1225
|
-
(c >= 0x2e1e && c <= 0x2e1f) ||
|
|
1226
|
-
c === 0x2e20 ||
|
|
1227
|
-
c === 0x2e21 ||
|
|
1228
|
-
c === 0x2e22 ||
|
|
1229
|
-
c === 0x2e23 ||
|
|
1230
|
-
c === 0x2e24 ||
|
|
1231
|
-
c === 0x2e25 ||
|
|
1232
|
-
c === 0x2e26 ||
|
|
1233
|
-
c === 0x2e27 ||
|
|
1234
|
-
c === 0x2e28 ||
|
|
1235
|
-
c === 0x2e29 ||
|
|
1236
|
-
(c >= 0x2e2a && c <= 0x2e2e) ||
|
|
1237
|
-
c === 0x2e2f ||
|
|
1238
|
-
(c >= 0x2e30 && c <= 0x2e39) ||
|
|
1239
|
-
(c >= 0x2e3a && c <= 0x2e3b) ||
|
|
1240
|
-
(c >= 0x2e3c && c <= 0x2e3f) ||
|
|
1241
|
-
c === 0x2e40 ||
|
|
1242
|
-
c === 0x2e41 ||
|
|
1243
|
-
c === 0x2e42 ||
|
|
1244
|
-
(c >= 0x2e43 && c <= 0x2e4f) ||
|
|
1245
|
-
(c >= 0x2e50 && c <= 0x2e51) ||
|
|
1246
|
-
c === 0x2e52 ||
|
|
1247
|
-
(c >= 0x2e53 && c <= 0x2e7f) ||
|
|
1248
|
-
(c >= 0x3001 && c <= 0x3003) ||
|
|
1249
|
-
c === 0x3008 ||
|
|
1250
|
-
c === 0x3009 ||
|
|
1251
|
-
c === 0x300a ||
|
|
1252
|
-
c === 0x300b ||
|
|
1253
|
-
c === 0x300c ||
|
|
1254
|
-
c === 0x300d ||
|
|
1255
|
-
c === 0x300e ||
|
|
1256
|
-
c === 0x300f ||
|
|
1257
|
-
c === 0x3010 ||
|
|
1258
|
-
c === 0x3011 ||
|
|
1259
|
-
(c >= 0x3012 && c <= 0x3013) ||
|
|
1260
|
-
c === 0x3014 ||
|
|
1261
|
-
c === 0x3015 ||
|
|
1262
|
-
c === 0x3016 ||
|
|
1263
|
-
c === 0x3017 ||
|
|
1264
|
-
c === 0x3018 ||
|
|
1265
|
-
c === 0x3019 ||
|
|
1266
|
-
c === 0x301a ||
|
|
1267
|
-
c === 0x301b ||
|
|
1268
|
-
c === 0x301c ||
|
|
1269
|
-
c === 0x301d ||
|
|
1270
|
-
(c >= 0x301e && c <= 0x301f) ||
|
|
1271
|
-
c === 0x3020 ||
|
|
1272
|
-
c === 0x3030 ||
|
|
1273
|
-
c === 0xfd3e ||
|
|
1274
|
-
c === 0xfd3f ||
|
|
1275
|
-
(c >= 0xfe45 && c <= 0xfe46));
|
|
1276
|
-
}
|