UNPKG

rawsql-ts

Version:

[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.

34 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IdentifierTokenReader = void 0; const BaseTokenReader_1 = require("./BaseTokenReader"); const Lexeme_1 = require("../models/Lexeme"); const stringUtils_1 = require("../utils/stringUtils"); /** * Reads SQL identifier tokens */ class IdentifierTokenReader extends BaseTokenReader_1.BaseTokenReader { /** * Try to read an identifier token */ tryRead(previous) { if (this.isEndOfInput()) { return null; } const char = this.input[this.position]; // wildcard identifier if (char === '*') { // Assume that the OperatorTokenReader is executed before the IdentifierTokenReader. // Since we have determined that the OperatorTokenReader is not an Operator, // we treat '*' here as a wildcard identifier. this.position++; return this.createLexeme(Lexeme_1.TokenType.Identifier, char); } // Regular identifier const result = stringUtils_1.StringUtils.readRegularIdentifier(this.input, this.position); this.position = result.newPosition; return this.createLexeme(Lexeme_1.TokenType.Identifier, result.identifier); } } exports.IdentifierTokenReader = IdentifierTokenReader; //# sourceMappingURL=IdentifierTokenReader.js.map