@common.js/formatjs__icu-messageformat-parser 3.5.12
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/LICENSE.md +9 -0
- package/README.md +5 -0
- package/index.d.ts +394 -0
- package/index.js +2683 -0
- package/index.js.map +1 -0
- package/manipulator.d.ts +177 -0
- package/manipulator.js +344 -0
- package/manipulator.js.map +1 -0
- package/no-parser.d.ts +185 -0
- package/no-parser.js +261 -0
- package/no-parser.js.map +1 -0
- package/package.json +15 -0
- package/printer.d.ts +156 -0
- package/printer.js +291 -0
- package/printer.js.map +1 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 FormatJS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# @common.js/formatjs__icu-messageformat-parser
|
|
2
|
+
|
|
3
|
+
The [@formatjs/icu-messageformat-parser](https://www.npmjs.com/package/@formatjs/icu-messageformat-parser) package exported as CommonJS modules.
|
|
4
|
+
|
|
5
|
+
Exported from [@formatjs/icu-messageformat-parser@3.5.12](https://www.npmjs.com/package/@formatjs/icu-messageformat-parser/v/3.5.12) using https://github.com/etienne-martin/common.js.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { NumberSkeletonToken } from "@formatjs/icu-skeleton-parser";
|
|
2
|
+
|
|
3
|
+
//#region packages/ecma402-abstract/types/number.d.ts
|
|
4
|
+
type NumberFormatNotation = "standard" | "scientific" | "engineering" | "compact";
|
|
5
|
+
type RoundingPriorityType = "auto" | "morePrecision" | "lessPrecision";
|
|
6
|
+
type RoundingModeType = "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven";
|
|
7
|
+
type UseGroupingType = "min2" | "auto" | "always" | boolean;
|
|
8
|
+
interface NumberFormatDigitOptions {
|
|
9
|
+
minimumIntegerDigits?: number;
|
|
10
|
+
minimumSignificantDigits?: number;
|
|
11
|
+
maximumSignificantDigits?: number;
|
|
12
|
+
minimumFractionDigits?: number;
|
|
13
|
+
maximumFractionDigits?: number;
|
|
14
|
+
roundingPriority?: RoundingPriorityType;
|
|
15
|
+
roundingIncrement?: number;
|
|
16
|
+
roundingMode?: RoundingModeType;
|
|
17
|
+
trailingZeroDisplay?: TrailingZeroDisplay;
|
|
18
|
+
}
|
|
19
|
+
type NumberFormatOptionsLocaleMatcher = "lookup" | "best fit";
|
|
20
|
+
type NumberFormatOptionsStyle = "decimal" | "percent" | "currency" | "unit";
|
|
21
|
+
type NumberFormatOptionsCompactDisplay = "short" | "long";
|
|
22
|
+
type NumberFormatOptionsCurrencyDisplay = "symbol" | "code" | "name" | "narrowSymbol";
|
|
23
|
+
type NumberFormatOptionsCurrencySign = "standard" | "accounting";
|
|
24
|
+
type NumberFormatOptionsNotation = NumberFormatNotation;
|
|
25
|
+
type NumberFormatOptionsSignDisplay = "auto" | "always" | "never" | "exceptZero" | "negative";
|
|
26
|
+
type NumberFormatOptionsUnitDisplay = "long" | "short" | "narrow";
|
|
27
|
+
type TrailingZeroDisplay = "auto" | "stripIfInteger";
|
|
28
|
+
type NumberFormatOptions = Omit<Intl.NumberFormatOptions, "signDisplay" | "useGrouping"> & NumberFormatDigitOptions & {
|
|
29
|
+
localeMatcher?: NumberFormatOptionsLocaleMatcher;
|
|
30
|
+
style?: NumberFormatOptionsStyle;
|
|
31
|
+
compactDisplay?: NumberFormatOptionsCompactDisplay;
|
|
32
|
+
currencyDisplay?: NumberFormatOptionsCurrencyDisplay;
|
|
33
|
+
currencySign?: NumberFormatOptionsCurrencySign;
|
|
34
|
+
notation?: NumberFormatOptionsNotation;
|
|
35
|
+
signDisplay?: NumberFormatOptionsSignDisplay;
|
|
36
|
+
unit?: string;
|
|
37
|
+
unitDisplay?: NumberFormatOptionsUnitDisplay;
|
|
38
|
+
numberingSystem?: string;
|
|
39
|
+
trailingZeroDisplay?: TrailingZeroDisplay;
|
|
40
|
+
roundingPriority?: RoundingPriorityType;
|
|
41
|
+
roundingIncrement?: number;
|
|
42
|
+
roundingMode?: RoundingModeType;
|
|
43
|
+
useGrouping?: UseGroupingType;
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region packages/icu-messageformat-parser/types.d.ts
|
|
47
|
+
interface ExtendedNumberFormatOptions extends NumberFormatOptions {
|
|
48
|
+
scale?: number;
|
|
49
|
+
}
|
|
50
|
+
declare enum TYPE {
|
|
51
|
+
/**
|
|
52
|
+
* Raw text
|
|
53
|
+
*/
|
|
54
|
+
literal = 0,
|
|
55
|
+
/**
|
|
56
|
+
* Variable w/o any format, e.g `var` in `this is a {var}`
|
|
57
|
+
*/
|
|
58
|
+
argument = 1,
|
|
59
|
+
/**
|
|
60
|
+
* Variable w/ number format
|
|
61
|
+
*/
|
|
62
|
+
number = 2,
|
|
63
|
+
/**
|
|
64
|
+
* Variable w/ date format
|
|
65
|
+
*/
|
|
66
|
+
date = 3,
|
|
67
|
+
/**
|
|
68
|
+
* Variable w/ time format
|
|
69
|
+
*/
|
|
70
|
+
time = 4,
|
|
71
|
+
/**
|
|
72
|
+
* Variable w/ select format
|
|
73
|
+
*/
|
|
74
|
+
select = 5,
|
|
75
|
+
/**
|
|
76
|
+
* Variable w/ plural format
|
|
77
|
+
*/
|
|
78
|
+
plural = 6,
|
|
79
|
+
/**
|
|
80
|
+
* Only possible within plural argument.
|
|
81
|
+
* This is the `#` symbol that will be substituted with the count.
|
|
82
|
+
*/
|
|
83
|
+
pound = 7,
|
|
84
|
+
/**
|
|
85
|
+
* XML-like tag
|
|
86
|
+
*/
|
|
87
|
+
tag = 8
|
|
88
|
+
}
|
|
89
|
+
declare enum SKELETON_TYPE {
|
|
90
|
+
number = 0,
|
|
91
|
+
dateTime = 1
|
|
92
|
+
}
|
|
93
|
+
interface LocationDetails {
|
|
94
|
+
offset: number;
|
|
95
|
+
line: number;
|
|
96
|
+
column: number;
|
|
97
|
+
}
|
|
98
|
+
interface Location {
|
|
99
|
+
start: LocationDetails;
|
|
100
|
+
end: LocationDetails;
|
|
101
|
+
}
|
|
102
|
+
interface BaseElement<T extends TYPE> {
|
|
103
|
+
type: T;
|
|
104
|
+
value: string;
|
|
105
|
+
location?: Location;
|
|
106
|
+
}
|
|
107
|
+
type LiteralElement = BaseElement<TYPE.literal>;
|
|
108
|
+
type ArgumentElement = BaseElement<TYPE.argument>;
|
|
109
|
+
interface TagElement extends BaseElement<TYPE.tag> {
|
|
110
|
+
children: MessageFormatElement[];
|
|
111
|
+
}
|
|
112
|
+
interface SimpleFormatElement<T extends TYPE, S extends Skeleton> extends BaseElement<T> {
|
|
113
|
+
style?: string | S | null;
|
|
114
|
+
}
|
|
115
|
+
type NumberElement = SimpleFormatElement<TYPE.number, NumberSkeleton>;
|
|
116
|
+
type DateElement = SimpleFormatElement<TYPE.date, DateTimeSkeleton>;
|
|
117
|
+
type TimeElement = SimpleFormatElement<TYPE.time, DateTimeSkeleton>;
|
|
118
|
+
type ValidPluralRule = "zero" | "one" | "two" | "few" | "many" | "other" | string;
|
|
119
|
+
interface PluralOrSelectOption {
|
|
120
|
+
value: MessageFormatElement[];
|
|
121
|
+
location?: Location;
|
|
122
|
+
}
|
|
123
|
+
interface SelectElement extends BaseElement<TYPE.select> {
|
|
124
|
+
options: Record<string, PluralOrSelectOption>;
|
|
125
|
+
}
|
|
126
|
+
interface PluralElement extends BaseElement<TYPE.plural> {
|
|
127
|
+
options: Record<ValidPluralRule, PluralOrSelectOption>;
|
|
128
|
+
offset: number;
|
|
129
|
+
pluralType: Intl.PluralRulesOptions["type"];
|
|
130
|
+
}
|
|
131
|
+
interface PoundElement {
|
|
132
|
+
type: TYPE.pound;
|
|
133
|
+
location?: Location;
|
|
134
|
+
}
|
|
135
|
+
type MessageFormatElement = ArgumentElement | DateElement | LiteralElement | NumberElement | PluralElement | PoundElement | SelectElement | TagElement | TimeElement;
|
|
136
|
+
interface NumberSkeleton {
|
|
137
|
+
type: SKELETON_TYPE.number;
|
|
138
|
+
tokens: NumberSkeletonToken[];
|
|
139
|
+
location?: Location;
|
|
140
|
+
parsedOptions: ExtendedNumberFormatOptions;
|
|
141
|
+
}
|
|
142
|
+
interface DateTimeSkeleton {
|
|
143
|
+
type: SKELETON_TYPE.dateTime;
|
|
144
|
+
pattern: string;
|
|
145
|
+
location?: Location;
|
|
146
|
+
parsedOptions: Intl.DateTimeFormatOptions;
|
|
147
|
+
}
|
|
148
|
+
type Skeleton = NumberSkeleton | DateTimeSkeleton;
|
|
149
|
+
/**
|
|
150
|
+
* Type Guards
|
|
151
|
+
*/
|
|
152
|
+
declare function isLiteralElement(el: MessageFormatElement): el is LiteralElement;
|
|
153
|
+
declare function isArgumentElement(el: MessageFormatElement): el is ArgumentElement;
|
|
154
|
+
declare function isNumberElement(el: MessageFormatElement): el is NumberElement;
|
|
155
|
+
declare function isDateElement(el: MessageFormatElement): el is DateElement;
|
|
156
|
+
declare function isTimeElement(el: MessageFormatElement): el is TimeElement;
|
|
157
|
+
declare function isSelectElement(el: MessageFormatElement): el is SelectElement;
|
|
158
|
+
declare function isPluralElement(el: MessageFormatElement): el is PluralElement;
|
|
159
|
+
declare function isPoundElement(el: MessageFormatElement): el is PoundElement;
|
|
160
|
+
declare function isTagElement(el: MessageFormatElement): el is TagElement;
|
|
161
|
+
declare function isNumberSkeleton(el: NumberElement["style"] | Skeleton): el is NumberSkeleton;
|
|
162
|
+
declare function isDateTimeSkeleton(el?: DateElement["style"] | TimeElement["style"] | Skeleton): el is DateTimeSkeleton;
|
|
163
|
+
declare function createLiteralElement(value: string): LiteralElement;
|
|
164
|
+
declare function createNumberElement(value: string, style?: string | null): NumberElement;
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region packages/icu-messageformat-parser/error.d.ts
|
|
167
|
+
interface ParserError {
|
|
168
|
+
kind: ErrorKind;
|
|
169
|
+
message: string;
|
|
170
|
+
location: Location;
|
|
171
|
+
}
|
|
172
|
+
declare enum ErrorKind {
|
|
173
|
+
/** Argument is unclosed (e.g. `{0`) */
|
|
174
|
+
EXPECT_ARGUMENT_CLOSING_BRACE = 1,
|
|
175
|
+
/** Argument is empty (e.g. `{}`). */
|
|
176
|
+
EMPTY_ARGUMENT = 2,
|
|
177
|
+
/** Argument is malformed (e.g. `{foo!}``) */
|
|
178
|
+
MALFORMED_ARGUMENT = 3,
|
|
179
|
+
/** Expect an argument type (e.g. `{foo,}`) */
|
|
180
|
+
EXPECT_ARGUMENT_TYPE = 4,
|
|
181
|
+
/** Unsupported argument type (e.g. `{foo,foo}`) */
|
|
182
|
+
INVALID_ARGUMENT_TYPE = 5,
|
|
183
|
+
/** Expect an argument style (e.g. `{foo, number, }`) */
|
|
184
|
+
EXPECT_ARGUMENT_STYLE = 6,
|
|
185
|
+
/** The number skeleton is invalid. */
|
|
186
|
+
INVALID_NUMBER_SKELETON = 7,
|
|
187
|
+
/** The date time skeleton is invalid. */
|
|
188
|
+
INVALID_DATE_TIME_SKELETON = 8,
|
|
189
|
+
/** Exepct a number skeleton following the `::` (e.g. `{foo, number, ::}`) */
|
|
190
|
+
EXPECT_NUMBER_SKELETON = 9,
|
|
191
|
+
/** Exepct a date time skeleton following the `::` (e.g. `{foo, date, ::}`) */
|
|
192
|
+
EXPECT_DATE_TIME_SKELETON = 10,
|
|
193
|
+
/** Unmatched apostrophes in the argument style (e.g. `{foo, number, 'test`) */
|
|
194
|
+
UNCLOSED_QUOTE_IN_ARGUMENT_STYLE = 11,
|
|
195
|
+
/** Missing select argument options (e.g. `{foo, select}`) */
|
|
196
|
+
EXPECT_SELECT_ARGUMENT_OPTIONS = 12,
|
|
197
|
+
/** Expecting an offset value in `plural` or `selectordinal` argument (e.g `{foo, plural, offset}`) */
|
|
198
|
+
EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE = 13,
|
|
199
|
+
/** Offset value in `plural` or `selectordinal` is invalid (e.g. `{foo, plural, offset: x}`) */
|
|
200
|
+
INVALID_PLURAL_ARGUMENT_OFFSET_VALUE = 14,
|
|
201
|
+
/** Expecting a selector in `select` argument (e.g `{foo, select}`) */
|
|
202
|
+
EXPECT_SELECT_ARGUMENT_SELECTOR = 15,
|
|
203
|
+
/** Expecting a selector in `plural` or `selectordinal` argument (e.g `{foo, plural}`) */
|
|
204
|
+
EXPECT_PLURAL_ARGUMENT_SELECTOR = 16,
|
|
205
|
+
/** Expecting a message fragment after the `select` selector (e.g. `{foo, select, apple}`) */
|
|
206
|
+
EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT = 17,
|
|
207
|
+
/**
|
|
208
|
+
* Expecting a message fragment after the `plural` or `selectordinal` selector
|
|
209
|
+
* (e.g. `{foo, plural, one}`)
|
|
210
|
+
*/
|
|
211
|
+
EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT = 18,
|
|
212
|
+
/** Selector in `plural` or `selectordinal` is malformed (e.g. `{foo, plural, =x {#}}`) */
|
|
213
|
+
INVALID_PLURAL_ARGUMENT_SELECTOR = 19,
|
|
214
|
+
/**
|
|
215
|
+
* Duplicate selectors in `plural` or `selectordinal` argument.
|
|
216
|
+
* (e.g. {foo, plural, one {#} one {#}})
|
|
217
|
+
*/
|
|
218
|
+
DUPLICATE_PLURAL_ARGUMENT_SELECTOR = 20,
|
|
219
|
+
/** Duplicate selectors in `select` argument.
|
|
220
|
+
* (e.g. {foo, select, apple {apple} apple {apple}})
|
|
221
|
+
*/
|
|
222
|
+
DUPLICATE_SELECT_ARGUMENT_SELECTOR = 21,
|
|
223
|
+
/** Plural or select argument option must have `other` clause. */
|
|
224
|
+
MISSING_OTHER_CLAUSE = 22,
|
|
225
|
+
/** The tag is malformed. (e.g. `<bold!>foo</bold!>) */
|
|
226
|
+
INVALID_TAG = 23,
|
|
227
|
+
/** The tag name is invalid. (e.g. `<123>foo</123>`) */
|
|
228
|
+
INVALID_TAG_NAME = 25,
|
|
229
|
+
/** The closing tag does not match the opening tag. (e.g. `<bold>foo</italic>`) */
|
|
230
|
+
UNMATCHED_CLOSING_TAG = 26,
|
|
231
|
+
/** The opening tag has unmatched closing tag. (e.g. `<bold>foo`) */
|
|
232
|
+
UNCLOSED_TAG = 27
|
|
233
|
+
}
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region packages/icu-messageformat-parser/parser.d.ts
|
|
236
|
+
interface ParserOptions {
|
|
237
|
+
/**
|
|
238
|
+
* Whether to treat HTML/XML tags as string literal
|
|
239
|
+
* instead of parsing them as tag token.
|
|
240
|
+
* When this is false we only allow simple tags without
|
|
241
|
+
* any attributes
|
|
242
|
+
*/
|
|
243
|
+
ignoreTag?: boolean;
|
|
244
|
+
/**
|
|
245
|
+
* Should `select`, `selectordinal`, and `plural` arguments always include
|
|
246
|
+
* the `other` case clause.
|
|
247
|
+
*/
|
|
248
|
+
requiresOtherClause?: boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Whether to parse number/datetime skeleton
|
|
251
|
+
* into Intl.NumberFormatOptions and Intl.DateTimeFormatOptions, respectively.
|
|
252
|
+
*/
|
|
253
|
+
shouldParseSkeletons?: boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Capture location info in AST
|
|
256
|
+
* Default is false
|
|
257
|
+
*/
|
|
258
|
+
captureLocation?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Instance of Intl.Locale to resolve locale-dependent skeleton
|
|
261
|
+
*/
|
|
262
|
+
locale?: Intl.Locale;
|
|
263
|
+
}
|
|
264
|
+
type Result<T, E> = {
|
|
265
|
+
val: T;
|
|
266
|
+
err: null;
|
|
267
|
+
} | {
|
|
268
|
+
val: null;
|
|
269
|
+
err: E;
|
|
270
|
+
};
|
|
271
|
+
declare class Parser {
|
|
272
|
+
private message;
|
|
273
|
+
private position;
|
|
274
|
+
private locale?;
|
|
275
|
+
private ignoreTag;
|
|
276
|
+
private requiresOtherClause;
|
|
277
|
+
private shouldParseSkeletons?;
|
|
278
|
+
constructor(message: string, options?: ParserOptions);
|
|
279
|
+
parse(): Result<MessageFormatElement[], ParserError>;
|
|
280
|
+
private parseMessage;
|
|
281
|
+
/**
|
|
282
|
+
* A tag name must start with an ASCII lower/upper case letter. The grammar is based on the
|
|
283
|
+
* [custom element name][] except that a dash is NOT always mandatory and uppercase letters
|
|
284
|
+
* are accepted:
|
|
285
|
+
*
|
|
286
|
+
* ```
|
|
287
|
+
* tag ::= "<" tagName (whitespace)* "/>" | "<" tagName (whitespace)* ">" message "</" tagName (whitespace)* ">"
|
|
288
|
+
* tagName ::= [a-z] (PENChar)*
|
|
289
|
+
* PENChar ::=
|
|
290
|
+
* "-" | "." | [0-9] | "_" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
|
|
291
|
+
* [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
|
|
292
|
+
* [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
|
293
|
+
* ```
|
|
294
|
+
*
|
|
295
|
+
* [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
|
|
296
|
+
* NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do
|
|
297
|
+
* since other tag-based engines like React allow it
|
|
298
|
+
*/
|
|
299
|
+
private parseTag;
|
|
300
|
+
/**
|
|
301
|
+
* This method assumes that the caller has peeked ahead for the first tag character.
|
|
302
|
+
*/
|
|
303
|
+
private parseTagName;
|
|
304
|
+
private parseLiteral;
|
|
305
|
+
tryParseLeftAngleBracket(): string | null;
|
|
306
|
+
/**
|
|
307
|
+
* Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes
|
|
308
|
+
* a character that requires quoting (that is, "only where needed"), and works the same in
|
|
309
|
+
* nested messages as on the top level of the pattern. The new behavior is otherwise compatible.
|
|
310
|
+
*/
|
|
311
|
+
private tryParseQuote;
|
|
312
|
+
private tryParseUnquoted;
|
|
313
|
+
private parseArgument;
|
|
314
|
+
/**
|
|
315
|
+
* Advance the parser until the end of the identifier, if it is currently on
|
|
316
|
+
* an identifier character. Return an empty string otherwise.
|
|
317
|
+
*/
|
|
318
|
+
private parseIdentifierIfPossible;
|
|
319
|
+
private parseArgumentOptions;
|
|
320
|
+
private tryParseArgumentClose;
|
|
321
|
+
/**
|
|
322
|
+
* See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659
|
|
323
|
+
*/
|
|
324
|
+
private parseSimpleArgStyleIfPossible;
|
|
325
|
+
private parseNumberSkeletonFromString;
|
|
326
|
+
/**
|
|
327
|
+
* @param nesting_level The current nesting level of messages.
|
|
328
|
+
* This can be positive when parsing message fragment in select or plural argument options.
|
|
329
|
+
* @param parent_arg_type The parent argument's type.
|
|
330
|
+
* @param parsed_first_identifier If provided, this is the first identifier-like selector of
|
|
331
|
+
* the argument. It is a by-product of a previous parsing attempt.
|
|
332
|
+
* @param expecting_close_tag If true, this message is directly or indirectly nested inside
|
|
333
|
+
* between a pair of opening and closing tags. The nested message will not parse beyond
|
|
334
|
+
* the closing tag boundary.
|
|
335
|
+
*/
|
|
336
|
+
private tryParsePluralOrSelectOptions;
|
|
337
|
+
private tryParseDecimalInteger;
|
|
338
|
+
private offset;
|
|
339
|
+
private isEOF;
|
|
340
|
+
private clonePosition;
|
|
341
|
+
/**
|
|
342
|
+
* Return the code point at the current position of the parser.
|
|
343
|
+
* Throws if the index is out of bound.
|
|
344
|
+
*/
|
|
345
|
+
private char;
|
|
346
|
+
private error;
|
|
347
|
+
/** Bump the parser to the next UTF-16 code unit. */
|
|
348
|
+
private bump;
|
|
349
|
+
/**
|
|
350
|
+
* If the substring starting at the current position of the parser has
|
|
351
|
+
* the given prefix, then bump the parser to the character immediately
|
|
352
|
+
* following the prefix and return true. Otherwise, don't bump the parser
|
|
353
|
+
* and return false.
|
|
354
|
+
*/
|
|
355
|
+
private bumpIf;
|
|
356
|
+
/**
|
|
357
|
+
* Bump the parser until the pattern character is found and return `true`.
|
|
358
|
+
* Otherwise bump to the end of the file and return `false`.
|
|
359
|
+
*/
|
|
360
|
+
private bumpUntil;
|
|
361
|
+
/**
|
|
362
|
+
* Bump the parser to the target offset.
|
|
363
|
+
* If target offset is beyond the end of the input, bump the parser to the end of the input.
|
|
364
|
+
*/
|
|
365
|
+
private bumpTo;
|
|
366
|
+
/** advance the parser through all whitespace to the next non-whitespace code unit. */
|
|
367
|
+
private bumpSpace;
|
|
368
|
+
/**
|
|
369
|
+
* Peek at the *next* Unicode codepoint in the input without advancing the parser.
|
|
370
|
+
* If the input has been exhausted, then this returns null.
|
|
371
|
+
*/
|
|
372
|
+
private peek;
|
|
373
|
+
}
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region packages/icu-messageformat-parser/manipulator.d.ts
|
|
376
|
+
interface IsStructurallySameResult {
|
|
377
|
+
error?: Error;
|
|
378
|
+
success: boolean;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Check if 2 ASTs are structurally the same. This primarily means that
|
|
382
|
+
* they have the same variables with the same type
|
|
383
|
+
* @param a
|
|
384
|
+
* @param b
|
|
385
|
+
* @returns
|
|
386
|
+
*/
|
|
387
|
+
declare function isStructurallySame(a: MessageFormatElement[], b: MessageFormatElement[]): IsStructurallySameResult;
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region packages/icu-messageformat-parser/index.d.ts
|
|
390
|
+
declare function parse(message: string, opts?: ParserOptions): MessageFormatElement[];
|
|
391
|
+
declare const _Parser: typeof Parser;
|
|
392
|
+
//#endregion
|
|
393
|
+
export { ArgumentElement, BaseElement, DateElement, DateTimeSkeleton, ExtendedNumberFormatOptions, LiteralElement, Location, LocationDetails, MessageFormatElement, NumberElement, NumberSkeleton, type ParserOptions, PluralElement, PluralOrSelectOption, PoundElement, SKELETON_TYPE, SelectElement, SimpleFormatElement, Skeleton, TYPE, TagElement, TimeElement, ValidPluralRule, _Parser, createLiteralElement, createNumberElement, isArgumentElement, isDateElement, isDateTimeSkeleton, isLiteralElement, isNumberElement, isNumberSkeleton, isPluralElement, isPoundElement, isSelectElement, isStructurallySame, isTagElement, isTimeElement, parse };
|
|
394
|
+
//# sourceMappingURL=index.d.ts.map
|