MCPcopy Index your code
hub / github.com/angular/angular / tokenize

Method tokenize

packages/compiler/src/ml_parser/lexer.ts:224–277  ·  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 {
240 this._consumeTagOpen(start);
241 }
242 } else if (
243 this._tokenizeLet &&
244 // Use `peek` instead of `attempCharCode` since we
245 // don't want to advance in case it's not `@let`.
246 this._cursor.peek() === chars.$AT &&
247 !this._inInterpolation &&
248 this._isLetStart()
249 ) {
250 this._consumeLetDeclaration(start);
251 } else if (this._tokenizeBlocks && this._isBlockStart()) {
252 this._consumeBlockStart(start);
253 } else if (
254 this._tokenizeBlocks &&
255 !this._inInterpolation &&
256 !this._isInExpansionCase() &&
257 !this._isInExpansionForm() &&
258 this._attemptCharCode(chars.$RBRACE)
259 ) {
260 this._consumeBlockEnd(start);
261 } else if (!(this._tokenizeIcu && this._tokenizeExpansionForm())) {
262 // In (possibly interpolated) text the end of the text is given by `isTextEnd()`, while
263 // the premature end of an interpolation is given by the start of a new HTML element.
264 this._consumeWithInterpolation(
265 TokenType.TEXT,
266 TokenType.INTERPOLATION,
267 () => this._isTextEnd(),
268 () => this._isTagStart(),
269 );
270 }
271 } catch (e) {
272 this.handleError(e);
273 }
274 }
275 this._beginToken(TokenType.EOF);
276 this._endToken([]);
277 }
278
279 private _getBlockName(): string {
280 // This allows us to capture up something like `@else if`, but not `@ if`.

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
_isInExpansionFormMethod · 0.95

Tested by

no test coverage detected