Lexem next() {
        if (offset < script.length()) {
            if (matches(separator)) {
                return Lexem.SEPARATOR;
            } else if (matchesSingleLineComment() || matchesMultilineComment()) {
                return Lexem.COMMENT;
            } else if (
                matchesQuotedString('\'') ||
                matchesQuotedString('"') ||
                matchesQuotedString('`') ||
                matchesDollarQuotedString()
            ) {
                return Lexem.QUOTED_STRING;
            } else if (matches(identifier)) {
                return Lexem.IDENTIFIER;
            } else if (matches(whitespace)) {
                return Lexem.WHITESPACE;
            } else {
                currentMatch = String.valueOf(script.charAt(offset++));
                return Lexem.OTHER;
            }
        } else {
            return Lexem.EOF;
        }
    }
Rough lexical parser for SQL scripts.
modules/database-commons/src/main/java/org/testcontainers/ext/ScriptScanner.java