metaborg / spoofax-pie

Spoofax implementation using PIE pipelines
Apache License 2.0
12 stars 9 forks source link

Add options to stratego-runtime configuration #123

Closed Virtlink closed 1 year ago

Virtlink commented 1 year ago

This PR adds the following options to the stratego-runtime CFG configuration block:

This PR also adds the documentation.

Usage example for with-primitive-library:

stratego-runtime {
    with-primitive-library = java mb.tiger.MyPrimitiveLibrary
}
package mb.tiger;

import org.spoofax.interpreter.library.AbstractStrategoOperatorRegistry;
import javax.inject.Inject;

public final class MyPrimitiveLibrary extends AbstractStrategoOperatorRegistry {
    @Inject public MyPrimitiveLibrary() {
        add(new MyPrimitive());
    }
    @Override public String getOperatorRegistryName() {
        return getClass().getSimpleName();
    }
}

Usage example for overriding the generated classes:

stratego-runtime {
    class-kind = Generated
    base-StrategoRuntimeBuilderFactory = java mb.tiger.MyTigerStrategoRuntimeBuilderFactory
    extend-StrategoRuntimeBuilderFactory = java mb.tiger.MyExtendedTigerStrategoRuntimeBuilderFactory
}