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

Method tokenize

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

Source from the content-addressed store, hash-verified

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