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

Method tokenize

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

Source from the content-addressed store, hash-verified

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