Search in sources :

Example 6 with StrategoExecutor

use of org.metaborg.spoofax.meta.core.pluto.util.StrategoExecutor in project spoofax by metaborg.

the class Sdf2ParenthesizeLegacy method build.

@Override
public None build(Input input) throws IOException {
    requireBuild(input.origin);
    if (SpoofaxContext.BETTER_STAMPERS) {
        require(input.inputFile, new Sdf2ParenthesizeStamper(input.context));
    } else {
        require(input.inputFile);
    }
    // @formatter:off
    final Arguments arguments = new Arguments().addFile("-i", input.inputFile).add("-m", input.inputModule).add("--lang", input.inputModule).add("--omod", input.outputModule).addFile("-o", input.outputFile).add("--main-strategy", "io-" + input.inputModule + "-parenthesize").add("--rule-prefix", input.inputModule).add("--sig-module", "signatures/-");
    final ExecutionResult result = new StrategoExecutor().withToolsContext().withStrategy(main_sdf2parenthesize_0_0.instance).withTracker(newResourceTracker(Pattern.quote("[ sdf2parenthesize | info ]") + ".*", Pattern.quote("Invoking native tool") + ".*")).withName("sdf2parenthesize").executeCLI(arguments);
    if (!result.success) {
        FileCommands.writeToFile(input.outputFile, "module " + input.inputModule + "\nrules\n\n  parenthesize-" + input.inputModule + " = id");
    }
    // @formatter:on
    provide(input.outputFile);
    return None.val;
}
Also used : Sdf2ParenthesizeStamper(org.metaborg.spoofax.meta.core.pluto.stamp.Sdf2ParenthesizeStamper) Arguments(org.metaborg.util.cmd.Arguments) ExecutionResult(org.metaborg.spoofax.meta.core.pluto.util.StrategoExecutor.ExecutionResult) StrategoExecutor(org.metaborg.spoofax.meta.core.pluto.util.StrategoExecutor)

Example 7 with StrategoExecutor

use of org.metaborg.spoofax.meta.core.pluto.util.StrategoExecutor in project spoofax by metaborg.

the class StrategoBuildStep method execute.

@Override
protected void execute(StrategoBuildStepConfig config, LanguageSpecBuildPhase phase, LanguageSpecBuildInput input) throws MetaborgException {
    // @formatter:off
    final StrategoExecutor executor = new StrategoExecutor().withToolsContext().withTracker(new ResourceAgentTracker(resourceService, input.languageSpec().location())).withStrategyName(config.strategy).withName(config.strategy);
    // @formatter:on
    final ExecutionResult result = executor.executeCLI(config.arguments());
    if (!result.success) {
        throw new MetaborgException("Stratego execution of " + config.strategy + " failed");
    }
}
Also used : ResourceAgentTracker(org.metaborg.spoofax.meta.core.pluto.util.ResourceAgentTracker) MetaborgException(org.metaborg.core.MetaborgException) ExecutionResult(org.metaborg.spoofax.meta.core.pluto.util.StrategoExecutor.ExecutionResult) StrategoExecutor(org.metaborg.spoofax.meta.core.pluto.util.StrategoExecutor)

Aggregations

StrategoExecutor (org.metaborg.spoofax.meta.core.pluto.util.StrategoExecutor)7 ExecutionResult (org.metaborg.spoofax.meta.core.pluto.util.StrategoExecutor.ExecutionResult)7 Arguments (org.metaborg.util.cmd.Arguments)6 File (java.io.File)2 ResourceAgentTracker (org.metaborg.spoofax.meta.core.pluto.util.ResourceAgentTracker)2 Path (java.nio.file.Path)1 MetaborgException (org.metaborg.core.MetaborgException)1 Sdf2ParenthesizeStamper (org.metaborg.spoofax.meta.core.pluto.stamp.Sdf2ParenthesizeStamper)1 Sdf2RtgStamper (org.metaborg.spoofax.meta.core.pluto.stamp.Sdf2RtgStamper)1