public static Expression parse(final String metricName, final String expression) {
        CompilerConfiguration cc = new CompilerConfiguration();
        cc.setScriptBaseClass(DelegatingScript.class.getName());
        ImportCustomizer icz = new ImportCustomizer();
        icz.addImport("K8sRetagType", K8sRetagType.class.getName());
        icz.addImport("DetectPoint", DetectPoint.class.getName());
        icz.addImport("Layer", Layer.class.getName());
        icz.addImport("ProcessRegistry", ProcessRegistry.class.getName());
        cc.addCompilationCustomizers(icz);

        final SecureASTCustomizer secureASTCustomizer = new SecureASTCustomizer();
        secureASTCustomizer.setDisallowedStatements(
            ImmutableList.<Class<? extends Statement>>builder()
                         .add(WhileStatement.class)
                         .add(DoWhileStatement.class)
                         .add(ForStatement.class)
                         .build());
        // noinspection rawtypes
        secureASTCustomizer.setAllowedReceiversClasses(
            ImmutableList.<Class>builder()
                         .add(Object.class)
                         .add(Map.class)
                         .add(List.class)
                         .add(Array.class)
                         .add(K8sRetagType.class)
                         .add(DetectPoint.class)
                         .add(Layer.class)
                         .add(ProcessRegistry.class)
                         .add(GString.class)
                         .add(String.class)
                .build());
        cc.addCompilationCustomizers(secureASTCustomizer);

        GroovyShell sh = new GroovyShell(new Binding(), cc);
        DelegatingScript script = (DelegatingScript) sh.parse(expression);
        return new Expression(metricName, expression, script);
    }
Parse string literal to Expression object, which can be reused.

@param metricName the name of metric defined in mal rule
@param expression string literal represents the DSL expression.
@return Expression object could be executed.
oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/dsl/DSL.java