@formatjs/icu-messageformat-parser 3.2.0 → 3.3.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.d.ts +6 -6
- package/date-time-pattern-generator.js +62 -77
- package/error.d.ts +64 -64
- package/error.js +64 -63
- package/index.d.ts +5 -4
- package/index.js +40 -42
- package/manipulator.d.ts +19 -19
- package/manipulator.js +161 -119
- package/no-parser.d.ts +2 -2
- package/no-parser.js +4 -4
- package/package.json +3 -3
- package/parser.d.ts +142 -139
- package/parser.js +839 -900
- package/printer.d.ts +1 -1
- package/printer.js +68 -79
- package/regex.generated.d.ts +1 -0
- package/regex.generated.js +2 -2
- package/time-data.generated.d.ts +2 -0
- package/time-data.generated.js +1162 -1424
- package/types.d.ts +77 -74
- package/types.js +68 -67
package/manipulator.js
CHANGED
|
@@ -1,135 +1,177 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isArgumentElement, isDateElement, isNumberElement, isPluralElement, isSelectElement, isTagElement, isTimeElement, TYPE, } from './types.js';
|
|
1
|
+
import { isArgumentElement, isDateElement, isNumberElement, isPluralElement, isPoundElement, isSelectElement, isTagElement, isTimeElement, TYPE } from "./types.js";
|
|
3
2
|
function cloneDeep(obj) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
if (Array.isArray(obj)) {
|
|
4
|
+
// @ts-expect-error meh
|
|
5
|
+
return obj.map(cloneDeep);
|
|
6
|
+
}
|
|
7
|
+
if (obj !== null && typeof obj === "object") {
|
|
8
|
+
// @ts-expect-error meh
|
|
9
|
+
return Object.keys(obj).reduce((cloned, k) => {
|
|
10
|
+
// @ts-expect-error meh
|
|
11
|
+
cloned[k] = cloneDeep(obj[k]);
|
|
12
|
+
return cloned;
|
|
13
|
+
}, {});
|
|
14
|
+
}
|
|
15
|
+
return obj;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Replace pound elements with number elements referencing the given variable.
|
|
19
|
+
* This is needed when nesting plurals - the # in the outer plural should become
|
|
20
|
+
* an explicit variable reference when nested inside another plural.
|
|
21
|
+
* GH #4202
|
|
22
|
+
*/
|
|
23
|
+
function replacePoundWithArgument(ast, variableName) {
|
|
24
|
+
return ast.map((el) => {
|
|
25
|
+
if (isPoundElement(el)) {
|
|
26
|
+
// Replace # with {variableName, number}
|
|
27
|
+
return {
|
|
28
|
+
type: TYPE.number,
|
|
29
|
+
value: variableName,
|
|
30
|
+
style: null,
|
|
31
|
+
location: el.location
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (isPluralElement(el) || isSelectElement(el)) {
|
|
35
|
+
// Recursively process options
|
|
36
|
+
const newOptions = {};
|
|
37
|
+
for (const key of Object.keys(el.options)) {
|
|
38
|
+
newOptions[key] = { value: replacePoundWithArgument(el.options[key].value, variableName) };
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
...el,
|
|
42
|
+
options: newOptions
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (isTagElement(el)) {
|
|
46
|
+
return {
|
|
47
|
+
...el,
|
|
48
|
+
children: replacePoundWithArgument(el.children, variableName)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return el;
|
|
52
|
+
});
|
|
17
53
|
}
|
|
18
54
|
function hoistPluralOrSelectElement(ast, el, positionToInject) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
55
|
+
// pull this out of the ast and move it to the top
|
|
56
|
+
const cloned = cloneDeep(el);
|
|
57
|
+
const { options } = cloned;
|
|
58
|
+
// GH #4202: Check if there are other plural/select elements after this one
|
|
59
|
+
const afterElements = ast.slice(positionToInject + 1);
|
|
60
|
+
const hasSubsequentPluralOrSelect = afterElements.some(isPluralOrSelectElement);
|
|
61
|
+
cloned.options = Object.keys(options).reduce((all, k) => {
|
|
62
|
+
let optionValue = options[k].value;
|
|
63
|
+
// GH #4202: If there are subsequent plurals/selects and this is a plural,
|
|
64
|
+
// replace # with explicit variable reference to avoid ambiguity
|
|
65
|
+
if (hasSubsequentPluralOrSelect && isPluralElement(el)) {
|
|
66
|
+
optionValue = replacePoundWithArgument(optionValue, el.value);
|
|
67
|
+
}
|
|
68
|
+
const newValue = hoistSelectors([
|
|
69
|
+
...ast.slice(0, positionToInject),
|
|
70
|
+
...optionValue,
|
|
71
|
+
...afterElements
|
|
72
|
+
]);
|
|
73
|
+
all[k] = { value: newValue };
|
|
74
|
+
return all;
|
|
75
|
+
}, {});
|
|
76
|
+
return cloned;
|
|
30
77
|
}
|
|
31
78
|
function isPluralOrSelectElement(el) {
|
|
32
|
-
|
|
79
|
+
return isPluralElement(el) || isSelectElement(el);
|
|
33
80
|
}
|
|
34
81
|
function findPluralOrSelectElement(ast) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
82
|
+
return !!ast.find((el) => {
|
|
83
|
+
if (isPluralOrSelectElement(el)) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if (isTagElement(el)) {
|
|
87
|
+
return findPluralOrSelectElement(el.children);
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
});
|
|
44
91
|
}
|
|
45
92
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
93
|
+
* Hoist all selectors to the beginning of the AST & flatten the
|
|
94
|
+
* resulting options. E.g:
|
|
95
|
+
* "I have {count, plural, one{a dog} other{many dogs}}"
|
|
96
|
+
* becomes "{count, plural, one{I have a dog} other{I have many dogs}}".
|
|
97
|
+
* If there are multiple selectors, the order of which one is hoisted 1st
|
|
98
|
+
* is non-deterministic.
|
|
99
|
+
* The goal is to provide as many full sentences as possible since fragmented
|
|
100
|
+
* sentences are not translator-friendly
|
|
101
|
+
* @param ast AST
|
|
102
|
+
*/
|
|
56
103
|
export function hoistSelectors(ast) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
104
|
+
for (let i = 0; i < ast.length; i++) {
|
|
105
|
+
const el = ast[i];
|
|
106
|
+
if (isPluralOrSelectElement(el)) {
|
|
107
|
+
return [hoistPluralOrSelectElement(ast, el, i)];
|
|
108
|
+
}
|
|
109
|
+
if (isTagElement(el) && findPluralOrSelectElement([el])) {
|
|
110
|
+
throw new Error("Cannot hoist plural/select within a tag element. Please put the tag element inside each plural/select option");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return ast;
|
|
67
114
|
}
|
|
68
115
|
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
function collectVariables(ast, vars) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
vars.set(el.value, el.type);
|
|
93
|
-
collectVariables(el.children, vars);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
116
|
+
* Collect all variables in an AST to Record<string, TYPE>
|
|
117
|
+
* @param ast AST to collect variables from
|
|
118
|
+
* @param vars Record of variable name to variable type
|
|
119
|
+
*/
|
|
120
|
+
function collectVariables(ast, vars = new Map()) {
|
|
121
|
+
ast.forEach((el) => {
|
|
122
|
+
if (isArgumentElement(el) || isDateElement(el) || isTimeElement(el) || isNumberElement(el)) {
|
|
123
|
+
if (el.value in vars && vars.get(el.value) !== el.type) {
|
|
124
|
+
throw new Error(`Variable ${el.value} has conflicting types`);
|
|
125
|
+
}
|
|
126
|
+
vars.set(el.value, el.type);
|
|
127
|
+
}
|
|
128
|
+
if (isPluralElement(el) || isSelectElement(el)) {
|
|
129
|
+
vars.set(el.value, el.type);
|
|
130
|
+
Object.keys(el.options).forEach((k) => {
|
|
131
|
+
collectVariables(el.options[k].value, vars);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
if (isTagElement(el)) {
|
|
135
|
+
vars.set(el.value, el.type);
|
|
136
|
+
collectVariables(el.children, vars);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
96
139
|
}
|
|
97
140
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
141
|
+
* Check if 2 ASTs are structurally the same. This primarily means that
|
|
142
|
+
* they have the same variables with the same type
|
|
143
|
+
* @param a
|
|
144
|
+
* @param b
|
|
145
|
+
* @returns
|
|
146
|
+
*/
|
|
104
147
|
export function isStructurallySame(a, b) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}, { success: true });
|
|
148
|
+
const aVars = new Map();
|
|
149
|
+
const bVars = new Map();
|
|
150
|
+
collectVariables(a, aVars);
|
|
151
|
+
collectVariables(b, bVars);
|
|
152
|
+
if (aVars.size !== bVars.size) {
|
|
153
|
+
return {
|
|
154
|
+
success: false,
|
|
155
|
+
error: new Error(`Different number of variables: [${Array.from(aVars.keys()).join(", ")}] vs [${Array.from(bVars.keys()).join(", ")}]`)
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return Array.from(aVars.entries()).reduce((result, [key, type]) => {
|
|
159
|
+
if (!result.success) {
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
const bType = bVars.get(key);
|
|
163
|
+
if (bType == null) {
|
|
164
|
+
return {
|
|
165
|
+
success: false,
|
|
166
|
+
error: new Error(`Missing variable ${key} in message`)
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
if (bType !== type) {
|
|
170
|
+
return {
|
|
171
|
+
success: false,
|
|
172
|
+
error: new Error(`Variable ${key} has conflicting types: ${TYPE[type]} vs ${TYPE[bType]}`)
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
return result;
|
|
176
|
+
}, { success: true });
|
|
135
177
|
}
|
package/no-parser.d.ts
CHANGED
package/no-parser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function parse() {
|
|
2
|
-
|
|
2
|
+
throw new Error("You're trying to format an uncompiled message with react-intl without parser, please import from 'react-intl' instead");
|
|
3
3
|
}
|
|
4
|
-
export * from
|
|
5
|
-
export
|
|
6
|
-
export { isStructurallySame } from
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export const _Parser = undefined;
|
|
6
|
+
export { isStructurallySame } from "./manipulator.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/icu-messageformat-parser",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"tslib": "^2.8.0",
|
|
15
|
-
"@formatjs/ecma402-abstract": "3.0.
|
|
16
|
-
"@formatjs/icu-skeleton-parser": "2.0.
|
|
15
|
+
"@formatjs/ecma402-abstract": "3.0.8",
|
|
16
|
+
"@formatjs/icu-skeleton-parser": "2.0.8"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
package/parser.d.ts
CHANGED
|
@@ -1,147 +1,150 @@
|
|
|
1
|
-
import { ParserError } from
|
|
2
|
-
import { MessageFormatElement } from
|
|
1
|
+
import { type ParserError } from "./error.js";
|
|
2
|
+
import { type MessageFormatElement } from "./types.js";
|
|
3
3
|
export interface Position {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
/** Offset in terms of UTF-16 *code unit*. */
|
|
5
|
+
offset: number;
|
|
6
|
+
line: number;
|
|
7
|
+
/** Column offset in terms of unicode *code point*. */
|
|
8
|
+
column: number;
|
|
9
9
|
}
|
|
10
10
|
export interface ParserOptions {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Whether to treat HTML/XML tags as string literal
|
|
13
|
+
* instead of parsing them as tag token.
|
|
14
|
+
* When this is false we only allow simple tags without
|
|
15
|
+
* any attributes
|
|
16
|
+
*/
|
|
17
|
+
ignoreTag?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Should `select`, `selectordinal`, and `plural` arguments always include
|
|
20
|
+
* the `other` case clause.
|
|
21
|
+
*/
|
|
22
|
+
requiresOtherClause?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether to parse number/datetime skeleton
|
|
25
|
+
* into Intl.NumberFormatOptions and Intl.DateTimeFormatOptions, respectively.
|
|
26
|
+
*/
|
|
27
|
+
shouldParseSkeletons?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Capture location info in AST
|
|
30
|
+
* Default is false
|
|
31
|
+
*/
|
|
32
|
+
captureLocation?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Instance of Intl.Locale to resolve locale-dependent skeleton
|
|
35
|
+
*/
|
|
36
|
+
locale?: Intl.Locale;
|
|
37
37
|
}
|
|
38
|
-
export type Result<
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
export type Result<
|
|
39
|
+
T,
|
|
40
|
+
E
|
|
41
|
+
> = {
|
|
42
|
+
val: T;
|
|
43
|
+
err: null;
|
|
41
44
|
} | {
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
val: null;
|
|
46
|
+
err: E;
|
|
44
47
|
};
|
|
45
48
|
export declare class Parser {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
49
|
+
private message;
|
|
50
|
+
private position;
|
|
51
|
+
private locale?;
|
|
52
|
+
private ignoreTag;
|
|
53
|
+
private requiresOtherClause;
|
|
54
|
+
private shouldParseSkeletons?;
|
|
55
|
+
constructor(message: string, options?: ParserOptions);
|
|
56
|
+
parse(): Result<MessageFormatElement[], ParserError>;
|
|
57
|
+
private parseMessage;
|
|
58
|
+
/**
|
|
59
|
+
* A tag name must start with an ASCII lower/upper case letter. The grammar is based on the
|
|
60
|
+
* [custom element name][] except that a dash is NOT always mandatory and uppercase letters
|
|
61
|
+
* are accepted:
|
|
62
|
+
*
|
|
63
|
+
* ```
|
|
64
|
+
* tag ::= "<" tagName (whitespace)* "/>" | "<" tagName (whitespace)* ">" message "</" tagName (whitespace)* ">"
|
|
65
|
+
* tagName ::= [a-z] (PENChar)*
|
|
66
|
+
* PENChar ::=
|
|
67
|
+
* "-" | "." | [0-9] | "_" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
|
|
68
|
+
* [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
|
|
69
|
+
* [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
|
|
73
|
+
* NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do
|
|
74
|
+
* since other tag-based engines like React allow it
|
|
75
|
+
*/
|
|
76
|
+
private parseTag;
|
|
77
|
+
/**
|
|
78
|
+
* This method assumes that the caller has peeked ahead for the first tag character.
|
|
79
|
+
*/
|
|
80
|
+
private parseTagName;
|
|
81
|
+
private parseLiteral;
|
|
82
|
+
tryParseLeftAngleBracket(): string | null;
|
|
83
|
+
/**
|
|
84
|
+
* Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes
|
|
85
|
+
* a character that requires quoting (that is, "only where needed"), and works the same in
|
|
86
|
+
* nested messages as on the top level of the pattern. The new behavior is otherwise compatible.
|
|
87
|
+
*/
|
|
88
|
+
private tryParseQuote;
|
|
89
|
+
private tryParseUnquoted;
|
|
90
|
+
private parseArgument;
|
|
91
|
+
/**
|
|
92
|
+
* Advance the parser until the end of the identifier, if it is currently on
|
|
93
|
+
* an identifier character. Return an empty string otherwise.
|
|
94
|
+
*/
|
|
95
|
+
private parseIdentifierIfPossible;
|
|
96
|
+
private parseArgumentOptions;
|
|
97
|
+
private tryParseArgumentClose;
|
|
98
|
+
/**
|
|
99
|
+
* See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659
|
|
100
|
+
*/
|
|
101
|
+
private parseSimpleArgStyleIfPossible;
|
|
102
|
+
private parseNumberSkeletonFromString;
|
|
103
|
+
/**
|
|
104
|
+
* @param nesting_level The current nesting level of messages.
|
|
105
|
+
* This can be positive when parsing message fragment in select or plural argument options.
|
|
106
|
+
* @param parent_arg_type The parent argument's type.
|
|
107
|
+
* @param parsed_first_identifier If provided, this is the first identifier-like selector of
|
|
108
|
+
* the argument. It is a by-product of a previous parsing attempt.
|
|
109
|
+
* @param expecting_close_tag If true, this message is directly or indirectly nested inside
|
|
110
|
+
* between a pair of opening and closing tags. The nested message will not parse beyond
|
|
111
|
+
* the closing tag boundary.
|
|
112
|
+
*/
|
|
113
|
+
private tryParsePluralOrSelectOptions;
|
|
114
|
+
private tryParseDecimalInteger;
|
|
115
|
+
private offset;
|
|
116
|
+
private isEOF;
|
|
117
|
+
private clonePosition;
|
|
118
|
+
/**
|
|
119
|
+
* Return the code point at the current position of the parser.
|
|
120
|
+
* Throws if the index is out of bound.
|
|
121
|
+
*/
|
|
122
|
+
private char;
|
|
123
|
+
private error;
|
|
124
|
+
/** Bump the parser to the next UTF-16 code unit. */
|
|
125
|
+
private bump;
|
|
126
|
+
/**
|
|
127
|
+
* If the substring starting at the current position of the parser has
|
|
128
|
+
* the given prefix, then bump the parser to the character immediately
|
|
129
|
+
* following the prefix and return true. Otherwise, don't bump the parser
|
|
130
|
+
* and return false.
|
|
131
|
+
*/
|
|
132
|
+
private bumpIf;
|
|
133
|
+
/**
|
|
134
|
+
* Bump the parser until the pattern character is found and return `true`.
|
|
135
|
+
* Otherwise bump to the end of the file and return `false`.
|
|
136
|
+
*/
|
|
137
|
+
private bumpUntil;
|
|
138
|
+
/**
|
|
139
|
+
* Bump the parser to the target offset.
|
|
140
|
+
* If target offset is beyond the end of the input, bump the parser to the end of the input.
|
|
141
|
+
*/
|
|
142
|
+
private bumpTo;
|
|
143
|
+
/** advance the parser through all whitespace to the next non-whitespace code unit. */
|
|
144
|
+
private bumpSpace;
|
|
145
|
+
/**
|
|
146
|
+
* Peek at the *next* Unicode codepoint in the input without advancing the parser.
|
|
147
|
+
* If the input has been exhausted, then this returns null.
|
|
148
|
+
*/
|
|
149
|
+
private peek;
|
|
147
150
|
}
|