class PgArrayParser {

    private static final BaseErrorListener ERROR_LISTENER = new BaseErrorListener() {
        @Override
        public void syntaxError(Recognizer<?, ?> recognizer,
                                Object offendingSymbol,
                                int line,
                                int charPositionInLine,
                                String message,
                                RecognitionException e) {
            throw new PgArrayParsingException(message, e, line, charPositionInLine);
        }
    };

    public static Object parse(String s, Function<byte[], Object> convert) {
        return invokeParser(CharStreams.fromString(s), convert);
    }

    public static Object parse(byte[] bytes, Function<byte[], Object> convert) {
        try {
            return invokeParser(CharStreams.fromStream(new ByteArrayInputStream(bytes), StandardCharsets.UTF_8), convert);
        } catch (IOException e) {
            return new IllegalArgumentException(e);
        }
    }

    private static Object invokeParser(CharStream input, Function<byte[], Object> convert) {<FILL_FUNCTION_BODY>}
}

        try {
            var lexer = new PgArrayLexer(input);
            var tokenStream = new CommonTokenStream(lexer);
            var parser = new io.crate.protocols.postgres.antlr.PgArrayParser(tokenStream);

            lexer.removeErrorListeners();
            lexer.addErrorListener(ERROR_LISTENER);

            parser.removeErrorListeners();
            parser.addErrorListener(ERROR_LISTENER);

            ParserRuleContext tree;
            try {
                // first, try parsing with potentially faster SLL mode
                parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
                tree = parser.array();
            } catch (ParseCancellationException ex) {
                // if we fail, parse with LL mode
                tokenStream.seek(0); // rewind input stream
                parser.reset();

                parser.getInterpreter().setPredictionMode(PredictionMode.LL);
                tree = parser.array();
            }
            return tree.accept(new PgArrayASTVisitor(convert));
        } catch (StackOverflowError e) {
            throw new PgArrayParsingException("stack overflow while parsing: " + e.getLocalizedMessage());
        }
    
<no_super_class>