MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / #tokenize

Method #tokenize

www/js/_hyperscript-max.js:570–625  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

568 return c === "-" && n === "-" && (this.#isWhitespace(n2) || n2 === "" || n2 === "-") || c === "/" && n === "/" && (this.#isWhitespace(n2) || n2 === "" || n2 === "/");
569 }
570 #tokenize() {
571 while (this.#position < this.#source.length) {
572 if (this.#isLineComment()) {
573 this.#consumeComment();
574 } else if (this.#isWhitespace(this.#currentChar())) {
575 this.#tokens.push(this.#consumeWhitespace());
576 } else if (!this.#possiblePrecedingSymbol() && this.#currentChar() === "." && (this.#isAlpha(this.#nextChar()) || this.#nextChar() === "{" || this.#nextChar() === "-")) {
577 this.#tokens.push(this.#consumeClassReference());
578 } else if (!this.#possiblePrecedingSymbol() && this.#currentChar() === "#" && (this.#isAlpha(this.#nextChar()) || this.#nextChar() === "{")) {
579 if (this.#template === "lines" && this.#templateMode === "indeterminant") {
580 this.#templateMode = "command";
581 this.#tokens.push(this.#consumeTemplateLogic());
582 } else {
583 this.#tokens.push(this.#consumeIdReference());
584 }
585 } else if (this.#template === "lines" && this.#templateMode === "indeterminant" && this.#templateBraceCount === 0) {
586 this.#templateMode = "template";
587 this.#tokens.push(this.#consumeTemplateLine());
588 } else if (this.#currentChar() === "[" && this.#nextChar() === "@") {
589 this.#tokens.push(this.#consumeAttributeReference());
590 } else if (this.#currentChar() === "@") {
591 this.#tokens.push(this.#consumeShortAttributeReference());
592 } else if (this.#currentChar() === "*" && this.#isAlpha(this.#nextChar())) {
593 this.#tokens.push(this.#consumeStyleReference());
594 } else if (this.#inTemplate() && (this.#isAlpha(this.#currentChar()) || this.#currentChar() === "\\") && this.#templateMode !== "command") {
595 this.#tokens.push(this.#consumeTemplateIdentifier());
596 } else if (this.#inCommandMode() && (this.#isAlpha(this.#currentChar()) || this.#isIdentifierChar(this.#currentChar()))) {
597 this.#tokens.push(this.#consumeIdentifier());
598 } else if (this.#isNumeric(this.#currentChar())) {
599 this.#tokens.push(this.#consumeNumber());
600 } else if (this.#inCommandMode() && (this.#currentChar() === '"' || this.#currentChar() === "`")) {
601 this.#tokens.push(this.#consumeString());
602 } else if (this.#inCommandMode() && this.#currentChar() === "'") {
603 if (this.#isValidSingleQuoteStringStart()) {
604 this.#tokens.push(this.#consumeString());
605 } else {
606 this.#tokens.push(this.#consumeOp());
607 }
608 } else if (OP_TABLE[this.#currentChar()]) {
609 if (this.#lastToken === "$" && this.#currentChar() === "{") {
610 this.#templateBraceCount++;
611 }
612 if (this.#currentChar() === "}") {
613 this.#templateBraceCount--;
614 }
615 this.#tokens.push(this.#consumeOp());
616 } else if (this.#inTemplate() || this.#isReservedChar(this.#currentChar())) {
617 this.#tokens.push(this.#makeToken("RESERVED", this.#consumeChar()));
618 } else {
619 if (this.#position < this.#source.length) {
620 throw new Error("Unknown token: " + this.#currentChar() + " ");
621 }
622 }
623 }
624 return new Tokens(this.#tokens, this.#source);
625 }
626 };
627

Callers 1

tokenizeMethod · 0.95

Calls 15

#isLineCommentMethod · 0.95
#consumeCommentMethod · 0.95
#isWhitespaceMethod · 0.95
#currentCharMethod · 0.95
#consumeWhitespaceMethod · 0.95
#isAlphaMethod · 0.95
#nextCharMethod · 0.95
#consumeTemplateLogicMethod · 0.95
#consumeIdReferenceMethod · 0.95
#consumeTemplateLineMethod · 0.95

Tested by

no test coverage detected