@Override
        public void handle(Token t, StringBuilder sb) {
            switch (t.getType()) {
                case BLOCK_BEGIN:
                    blockLevel++;
                    sb.append(t.getText());
                    break;
                case BLOCK_END:
                    if (blockLevel == 0) {
                        throw new IllegalStateException("Found END in SQL script without BEGIN!");
                    }

                    blockLevel--;
                    sb.append(t.getText());
                    break;
                case SEMICOLON:
                    if (blockLevel == 0) {
                        if (requireSemicolon
                            && (lastToken != null && lastToken.getType() == BLOCK_END)) {
                            sb.append(t.getText());
                        }
                        addStatement(sb.toString());
                        sb.setLength(0);
                    } else {
                        sb.append(t.getText());
                    }
                    break;
                default:
                    sb.append(t.getText());
            }
            lastToken = t;
        }
An SQL script parser.

<p>It performs lexical analysis of a script and generates events for semicolons.
As a result it returns a script without comments and newlines.</p>
core/src/main/java/org/jdbi/v3/core/internal/SqlScriptParser.java