public void ParseRoutineBody()

in fastmodel-transform/fastmodel-transform-hologres/src/main/java/com/aliyun/fastmodel/transform/hologres/parser/HologreSQLParserBase.java [49:94]


    public void ParseRoutineBody(HologreSQLParser.Createfunc_opt_listContext _localctx) {
        String lang = null;
        for (HologreSQLParser.Createfunc_opt_itemContext coi : _localctx.createfunc_opt_item()) {
            if (coi.LANGUAGE() != null) {
                if (coi.nonreservedword_or_sconst() != null) {
                    if (coi.nonreservedword_or_sconst().nonreservedword() != null) {
                        if (coi.nonreservedword_or_sconst().nonreservedword().identifier() != null) {
                            if (coi.nonreservedword_or_sconst().nonreservedword().identifier()
                                .Identifier() != null) {
                                lang = coi.nonreservedword_or_sconst().nonreservedword().identifier()
                                    .Identifier().getText();
                                break;
                            }
                        }
                    }
                }
            }
        }
        if (null == lang) {return;}
        HologreSQLParser.Createfunc_opt_itemContext func_as = null;
        for (HologreSQLParser.Createfunc_opt_itemContext a : _localctx.createfunc_opt_item()) {
            if (a.func_as() != null) {
                func_as = a;
                break;

            }

        }
        if (func_as != null) {
            String txt = GetRoutineBodyString(func_as.func_as().sconst(0));
            int line = func_as.func_as().sconst(0).start.getLine();
            HologreSQLParser ph = getHologreSQLParser(txt);
            switch (lang) {
                case "plpgsql":
                    func_as.func_as().Definition = ph.plsqlroot();
                    break;
                case "sql":
                    func_as.func_as().Definition = ph.root();
                    break;
            }
            for (HologreSQLParseError err : ph.ParseErrors) {
                ParseErrors.add(new HologreSQLParseError(err.getNumber(), err.getOffset(), err.getLine() + line, err.getColumn(), err.getMessage()));
            }
        }

    }