use of abs.backend.common.InternalBackendException in project abstools by abstools.
the class MaudeCompiler method parseArgs.
@Override
public List<String> parseArgs(String[] args) throws InternalBackendException {
List<String> restArgs = super.parseArgs(args);
List<String> remainingArgs = new ArrayList<>();
for (int i = 0; i < restArgs.size(); i++) {
String arg = restArgs.get(i);
if (arg.equals("-timed")) {
module = SIMULATOR.EQ_TIMED;
} else if (arg.equals("-o")) {
i++;
if (i == restArgs.size()) {
throw new InternalBackendException("Missing output file name after '-o'");
} else {
outputfile = new File(restArgs.get(i));
}
} else if (arg.startsWith("-main=")) {
mainBlock = arg.split("=")[1];
} else if (arg.startsWith("-limit=")) {
// -limit implies -timed
module = SIMULATOR.EQ_TIMED;
clocklimit = Integer.parseInt(arg.split("=")[1]);
} else if (arg.startsWith("-defaultcost=")) {
defaultResources = Integer.parseInt(arg.split("=")[1]);
} else if (arg.equals("-maude")) {
// nothing to do
} else {
remainingArgs.add(arg);
}
}
return remainingArgs;
}
use of abs.backend.common.InternalBackendException in project abstools by abstools.
the class MaudeCompiler method compile.
/**
* @param args
* @throws Exception
*/
public int compile(String[] args) throws Exception {
if (verbose)
System.out.println("Generating Maude code...");
final Model model = parse(args);
if (model.hasParserErrors() || model.hasErrors() || model.hasTypeErrors()) {
printErrorMessage();
return 1;
}
PrintStream stream = System.out;
if (outputfile != null) {
stream = new PrintStream(outputfile);
}
InputStream is = ClassLoader.getSystemResourceAsStream(RUNTIME_INTERPRETER_PATH);
if (is == null) {
throw new InternalBackendException("Could not locate abs-interpreter.maude");
}
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
stream.println("*** Generated " + dateFormat.format(new Date()));
ByteStreams.copy(is, stream);
model.generateMaude(stream, module, mainBlock, clocklimit, defaultResources);
if (verbose)
System.out.println("Finished. Start `maude " + outputfile.toString() + "' to run the model.");
return 0;
}
use of abs.backend.common.InternalBackendException in project abstools by abstools.
the class OutlinePrinterBackEnd method parseArgs.
@Override
public List<String> parseArgs(String[] args) throws InternalBackendException {
List<String> restArgs = super.parseArgs(args);
List<String> remainingArgs = new ArrayList<>();
for (int i = 0; i < restArgs.size(); i++) {
String arg = restArgs.get(i);
if (arg.equals("-o")) {
i++;
if (i == restArgs.size()) {
throw new InternalBackendException("Missing output file name after '-o'");
} else {
outputfile = new File(restArgs.get(i));
if (outputfile.exists()) {
outputfile.delete();
}
}
} else if (arg.equals("-f")) {
force = true;
} else if (arg.equals("-outline")) {
// nothing to do
} else {
remainingArgs.add(arg);
}
}
return remainingArgs;
}
use of abs.backend.common.InternalBackendException in project abstools by abstools.
the class PrettyPrinterBackEnd method parseArgs.
@Override
public List<String> parseArgs(String[] args) throws InternalBackendException {
List<String> restArgs = super.parseArgs(args);
List<String> remainingArgs = new ArrayList<>();
for (int i = 0; i < restArgs.size(); i++) {
String arg = restArgs.get(i);
if (arg.equals("-o")) {
i++;
if (i == restArgs.size()) {
throw new InternalBackendException("Missing output file name after '-o'");
} else {
outputfile = new File(restArgs.get(i));
if (outputfile.exists()) {
outputfile.delete();
}
}
} else if (arg.equals("-f")) {
force = true;
} else if (arg.equals("-keepsugar")) {
keepsugar = true;
} else if (arg.equals("-prettyprint")) {
// nothing to do
} else {
remainingArgs.add(arg);
}
}
return remainingArgs;
}
use of abs.backend.common.InternalBackendException in project abstools by abstools.
the class PrologBackend method parseArgs.
public List<String> parseArgs(String[] args) throws InternalBackendException {
List<String> restArgs = super.parseArgs(args);
List<String> remainingArgs = new ArrayList<>();
for (int i = 0; i < restArgs.size(); i++) {
String arg = restArgs.get(i);
if (arg.equals("-prolog")) {
// nothing to do
} else if (arg.equals("-d")) {
i++;
if (i == restArgs.size()) {
throw new InternalBackendException("Please provide a destination directory");
} else {
destDir = new File(args[i]);
}
} else if (arg.equals("-fn")) {
i++;
if (i == restArgs.size()) {
throw new InternalBackendException("Please provide a file name");
} else {
outFilename = args[i];
}
} else {
remainingArgs.add(arg);
}
}
return remainingArgs;
}
Aggregations