MCPcopy
hub / github.com/formatjs/formatjs / parse

Method parse

packages/icu-messageformat-parser/parser.ts:188–219  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

186 }
187
188 parse(): Result<MessageFormatElement[], ParserError> {
189 if (this.offset() !== 0) {
190 throw Error('parser can only be used once')
191 }
192 if (this.message.length > 0) {
193 const firstCode = this.message.charCodeAt(0)
194 if (
195 firstCode !== 35 /* # */ &&
196 firstCode !== 39 /* ' */ &&
197 firstCode !== 60 /* < */ &&
198 firstCode !== 123 /* { */ &&
199 firstCode !== 125 /* } */
200 ) {
201 const plainEndPosition = plainTopLevelEndPosition(this.message)
202 if (plainEndPosition) {
203 const start = this.clonePosition()
204 this.position = plainEndPosition
205 return {
206 val: [
207 {
208 type: TYPE.literal,
209 value: this.message,
210 location: createLocation(start, this.clonePosition()),
211 },
212 ],
213 err: null,
214 }
215 }
216 }
217 }
218 return this.parseMessage(0, '', false)
219 }
220
221 private parseMessage(
222 nestingLevel: number,

Callers 15

mainFunction · 0.80
validatePackageExportsFunction · 0.80
parseTsconfigLineFunction · 0.80
readPackageJsonFunction · 0.80
mainFunction · 0.80
getLocalesFromJsonFunction · 0.80
mainFunction · 0.80
bumpVersionMethod · 0.80
readJsonFileFunction · 0.80
parseLDMLCollationsFunction · 0.80
analyzeProfileFunction · 0.80

Calls 5

offsetMethod · 0.95
clonePositionMethod · 0.95
parseMessageMethod · 0.95
plainTopLevelEndPositionFunction · 0.85
createLocationFunction · 0.85

Tested by 2

assertConformanceFunction · 0.64
parseTestCaseFunction · 0.64