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

Method #consumeNumber

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

Source from the content-addressed store, hash-verified

580 }
581
582 #consumeNumber() {
583 var token = this.#makeToken("NUMBER");
584 var value = this.#consumeChar();
585
586 // consume integer part: XXX
587 while (this.#isNumeric(this.#currentChar())) {
588 value += this.#consumeChar();
589 }
590
591 // consume decimal part: .YYY
592 if (this.#currentChar() === "." && this.#isNumeric(this.#nextChar())) {
593 value += this.#consumeChar();
594 }
595 while (this.#isNumeric(this.#currentChar())) {
596 value += this.#consumeChar();
597 }
598
599 // consume exponent: (e|E)[-]ZZZ
600 if (this.#currentChar() === "e" || this.#currentChar() === "E") {
601 if (this.#isNumeric(this.#nextChar())) {
602 value += this.#consumeChar();
603 } else if (this.#nextChar() === "-") {
604 value += this.#consumeChar();
605 value += this.#consumeChar();
606 }
607 }
608 while (this.#isNumeric(this.#currentChar())) {
609 value += this.#consumeChar();
610 }
611
612 token.value = value;
613 token.end = this.#position;
614 return token;
615 }
616
617 #consumeOp() {
618 var token = this.#makeOpToken();

Callers 1

#tokenizeMethod · 0.95

Calls 5

#makeTokenMethod · 0.95
#consumeCharMethod · 0.95
#isNumericMethod · 0.95
#currentCharMethod · 0.95
#nextCharMethod · 0.95

Tested by

no test coverage detected