MCPcopy Create free account
hub / github.com/angular/angular / tokenize

Method tokenize

packages/compiler/src/ml_parser/lexer.ts:230–285  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

228 }
229
230 tokenize(): void {
231 while (this._cursor.peek() !== chars.$EOF) {
232 const start = this._cursor.clone();
233 try {
234 if (this._attemptCharCode(chars.$LT)) {
235 if (this._attemptCharCode(chars.$BANG)) {
236 if (this._attemptCharCode(chars.$LBRACKET)) {
237 this._consumeCdata(start);
238 } else if (this._attemptCharCode(chars.$MINUS)) {
239 this._consumeComment(start);
240 } else {
241 this._consumeDocType(start);
242 }
243 } else if (this._attemptCharCode(chars.$SLASH)) {
244 this._consumeTagClose(start);
245 } else if (this._attemptCharCode(chars.$QUESTION)) {
246 this._consumeProcessingInstruction(start);
247 } else {
248 this._consumeTagOpen(start);
249 }
250 } else if (
251 this._tokenizeLet &&
252 // Use `peek` instead of `attempCharCode` since we
253 // don't want to advance in case it's not `@let`.
254 this._cursor.peek() === chars.$AT &&
255 !this._inInterpolation &&
256 this._isLetStart()
257 ) {
258 this._consumeLetDeclaration(start);
259 } else if (this._tokenizeBlocks && this._isBlockStart()) {
260 this._consumeBlockStart(start);
261 } else if (
262 this._tokenizeBlocks &&
263 !this._inInterpolation &&
264 !this._isInExpansionCase() &&
265 !this._isInExpansionForm() &&
266 this._attemptCharCode(chars.$RBRACE)
267 ) {
268 this._consumeBlockEnd(start);
269 } else if (!(this._tokenizeIcu && this._tokenizeExpansionForm())) {
270 // In (possibly interpolated) text the end of the text is given by `isTextEnd()`, while
271 // the premature end of an interpolation is given by the start of a new HTML element.
272 this._consumeWithInterpolation(
273 TokenType.TEXT,
274 TokenType.INTERPOLATION,
275 () => this._isTextEnd(),
276 () => this._isTagStart(),
277 );
278 }
279 } catch (e) {
280 this.handleError(e);
281 }
282 }
283 this._beginToken(TokenType.EOF);
284 this._endToken([]);
285 }
286
287 private _getBlockName(): string {

Callers 3

tokenizeFunction · 0.95
lexFunction · 0.45
constructorMethod · 0.45

Calls 15

_attemptCharCodeMethod · 0.95
_consumeCdataMethod · 0.95
_consumeCommentMethod · 0.95
_consumeDocTypeMethod · 0.95
_consumeTagCloseMethod · 0.95
_consumeTagOpenMethod · 0.95
_isLetStartMethod · 0.95
_isBlockStartMethod · 0.95
_consumeBlockStartMethod · 0.95
_isInExpansionCaseMethod · 0.95

Tested by

no test coverage detected