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

Method #tokenize

src/core/tokenizer.js:683–750  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

681 }
682
683 #tokenize() {
684 while (this.#position < this.#source.length) {
685 if (this.#isLineComment()) {
686 this.#consumeComment();
687 } else if (this.#isWhitespace(this.#currentChar())) {
688 this.#tokens.push(this.#consumeWhitespace());
689 } else if (
690 !this.#possiblePrecedingSymbol() &&
691 this.#currentChar() === "." &&
692 (this.#isAlpha(this.#nextChar()) || this.#nextChar() === "{" || this.#nextChar() === "-")
693 ) {
694 this.#tokens.push(this.#consumeClassReference());
695 } else if (
696 !this.#possiblePrecedingSymbol() &&
697 this.#currentChar() === "#" &&
698 (this.#isAlpha(this.#nextChar()) || this.#nextChar() === "{")
699 ) {
700 if (this.#template === "lines" && this.#templateMode === "indeterminant") {
701 this.#templateMode = "command";
702 this.#tokens.push(this.#consumeTemplateLogic());
703 } else {
704 this.#tokens.push(this.#consumeIdReference());
705 }
706 } else if (this.#template === "lines" && this.#templateMode === "indeterminant" && this.#templateBraceCount === 0) {
707 this.#templateMode = "template";
708 this.#tokens.push(this.#consumeTemplateLine());
709 } else if (this.#currentChar() === "[" && this.#nextChar() === "@") {
710 this.#tokens.push(this.#consumeAttributeReference());
711 } else if (this.#currentChar() === "@") {
712 this.#tokens.push(this.#consumeShortAttributeReference());
713 } else if (this.#currentChar() === "*" && this.#isAlpha(this.#nextChar())) {
714 this.#tokens.push(this.#consumeStyleReference());
715 } else if (this.#inTemplate() &&
716 (this.#isAlpha(this.#currentChar()) || this.#currentChar() === "\\") &&
717 this.#templateMode !== "command"
718 ) {
719 this.#tokens.push(this.#consumeTemplateIdentifier());
720 } else if (this.#inCommandMode() && (this.#isAlpha(this.#currentChar()) || this.#isIdentifierChar(this.#currentChar()))) {
721 this.#tokens.push(this.#consumeIdentifier());
722 } else if (this.#isNumeric(this.#currentChar())) {
723 this.#tokens.push(this.#consumeNumber());
724 } else if (this.#inCommandMode() && (this.#currentChar() === '"' || this.#currentChar() === "`")) {
725 this.#tokens.push(this.#consumeString());
726 } else if (this.#inCommandMode() && this.#currentChar() === "'") {
727 if (this.#isValidSingleQuoteStringStart()) {
728 this.#tokens.push(this.#consumeString());
729 } else {
730 this.#tokens.push(this.#consumeOp());
731 }
732 } else if (OP_TABLE[this.#currentChar()]) {
733 if (this.#lastToken === "$" && this.#currentChar() === "{") {
734 this.#templateBraceCount++;
735 }
736 if (this.#currentChar() === "}") {
737 this.#templateBraceCount--;
738 }
739 this.#tokens.push(this.#consumeOp());
740 } else if (this.#inTemplate() || this.#isReservedChar(this.#currentChar())) {

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