private boolean matchesDollarQuotedString() {
        //Matches $<tag>$ .... $<tag>$
        if (matches(dollarQuotedStringDelimiter)) {
            String delimiter = currentMatch;
            int end = script.indexOf(delimiter, offset);
            if (end < 0) {
                throw new ScriptUtils.ScriptParseException(
                    String.format("Unclosed dollar quoted string [%s].", delimiter),
                    resource
                );
            }
            end += delimiter.length();
            currentMatch = delimiter + script.substring(offset, end);
            offset = end;
            return true;
        }
        return false;
    }
Rough lexical parser for SQL scripts.
modules/database-commons/src/main/java/org/testcontainers/ext/ScriptScanner.java