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

Method tokenize

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

Source from the content-addressed store, hash-verified

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