MCPcopy Create free account
hub / github.com/microsoft/vscode-cpptools / scanNumber

Method scanNumber

Extension/src/Utility/Text/scanner.ts:737–766  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

735 }
736
737 private scanNumber() {
738 const start = this.#offset;
739
740 const main = this.scanDigits();
741 let decimal: string | undefined;
742 let scientific: string | undefined;
743
744 if (this.#ch === CharacterCodes.dot) {
745 this.advance();
746 decimal = this.scanDigits();
747 }
748
749 if (this.#ch === CharacterCodes.E || this.#ch === CharacterCodes.e) {
750 this.assert(isDigit(this.#chNext), 'ParseError: Digit expected (0-9)');
751 this.advance();
752 scientific = this.scanDigits();
753 }
754
755 this.text = scientific ?
756 decimal ?
757 `${main}.${decimal}e${scientific}` :
758 `${main}e${scientific}` :
759 decimal ?
760 `${main}.${decimal}` :
761 main;
762
763 // update the position
764 this.#column += this.#offset - start;
765 return this.kind = Kind.NumericLiteral;
766 }
767
768 private scanHexNumber() {
769 this.assert(isHexDigit(this.#chNextNext), 'ParseError: Hex Digit expected (0-F,0-f)');

Callers 1

scanMethod · 0.95

Calls 4

scanDigitsMethod · 0.95
advanceMethod · 0.95
assertMethod · 0.95
isDigitFunction · 0.90

Tested by

no test coverage detected