log.log("The full name of the sugar is '" + fullExtName + "'.", Log.DETAIL);
if (dependsOnModel)
return;
RelativePath sdfExtension = environment.createOutPath(baseProcessor.getRelativeNamespaceSep() + extName + ".sdf");
RelativePath strExtension = environment.createOutPath(baseProcessor.getRelativeNamespaceSep() + extName + ".str");
String sdfImports = " imports " + StringCommands.printListSeparated(availableSDFImports, " ") + "\n";
String strImports = " imports " + StringCommands.printListSeparated(availableSTRImports, " ") + "\n";
// this is a list of SDF and Stratego statements
IStrategoTerm extensionBody = baseProcessor.getExtensionBody(toplevelDecl);
IStrategoTerm sdfExtract = fixSDF(extractSDF(extensionBody), baseProcessor.getInterpreter());
IStrategoTerm strExtract = extractSTR(extensionBody);
IStrategoTerm editorExtract = extractEditor(extensionBody);
String sdfExtensionHead =
"module " + fullExtName + "\n"
+ sdfImports
+ "exports " + "\n"
+ " (/)" + "\n";
String sdfExtensionContent = SDFCommands.prettyPrintSDF(sdfExtract, baseProcessor.getInterpreter());
String sdfSource = SDFCommands.makePermissiveSdf(sdfExtensionHead + sdfExtensionContent);
driverResult.generateFile(sdfExtension, sdfSource);
availableSDFImports.add(fullExtName);
if (CommandExecution.FULL_COMMAND_LINE)
log.log("Wrote SDF file to '" + sdfExtension.getAbsolutePath() + "'.", Log.DETAIL);
String strExtensionTerm = "Module(" + "\"" + fullExtName+ "\"" + ", " + strExtract + ")" + "\n";
// try {
// strExtensionTerm = STRCommands.assimilate("strip-annos", currentTransProg, strExtensionTerm, langLib.getInterpreter());
// } catch (Exception e) {
// e.printStackTrace();
// }
// String strExtensionContent = SDFCommands.prettyPrintSTR(strExtensionTerm, langLib.getInterpreter());
String strExtensionContent = SDFCommands.prettyPrintSTR(ATermCommands.atermFromString(strExtensionTerm), baseProcessor.getInterpreter());
int index = strExtensionContent.indexOf('\n');
if (index >= 0)
strExtensionContent =
strExtensionContent.substring(0, index + 1) + "\n"
+ strImports + "\n"
+ strExtensionContent.substring(index + 1);
else
strExtensionContent += strImports;
driverResult.generateFile(strExtension, strExtensionContent);
availableSTRImports.add(fullExtName);
if (CommandExecution.FULL_COMMAND_LINE)
log.log("Wrote Stratego file to '" + strExtension.getAbsolutePath() + "'.", Log.DETAIL);
processEditorServices(extName, editorExtract);
/*
* adapt current grammar