use of de.bmoth.parser.ast.nodes.MachineNode in project bmoth by hhu-stups.
the class CliTask method executeBenchmarks.
public void executeBenchmarks() {
if (times != 0) {
// first parsing and checking process takes longer and is ignored
MachineNode machineNode = parseMachine(readMachineContent());
String result = doModelCheck(getModelChecker(machineNode)).toString();
for (int i = 1; i <= times; i++) {
logger.info("Executing benchmark " + i + " of " + times);
machineNode = parseMachine(readMachineContent());
parsingTimes += nanoDiffTime;
result = doModelCheck(getModelChecker(machineNode)).toString();
checkingTimes += nanoDiffTime;
}
StringJoiner resultString = new StringJoiner("\n", "", "");
resultString.add("Machine: " + machineFile.getName() + ", algorithm: " + algorithm + ", times: " + times);
resultString.add("Result: " + result);
resultString.add("Average parsing time: " + (parsingTimes / times) + " ns");
resultString.add("Average checking time: " + (checkingTimes / times) + " ns");
logger.info(resultString.toString());
if (resultFileName != null) {
try {
PrintWriter writer = new PrintWriter(resultFileName, "UTF-8");
writer.println(resultString.toString());
writer.close();
} catch (Exception e) {
logger.warning(e.toString());
}
}
}
}
use of de.bmoth.parser.ast.nodes.MachineNode in project bmoth by hhu-stups.
the class CliTask method execute.
public void execute() {
if (isBenchmark) {
executeBenchmarks();
} else {
MachineNode machineNode = parseMachine(readMachineContent());
ModelCheckingResult result = doModelCheck(getModelChecker(machineNode));
logger.info("Result: " + result.toString());
}
}
use of de.bmoth.parser.ast.nodes.MachineNode in project bmoth by hhu-stups.
the class CliTask method parseMachine.
private MachineNode parseMachine(String machineContent) {
MachineNode machineNode = null;
try {
long start = isBenchmark ? System.nanoTime() : 0;
machineNode = Parser.getMachineAsSemanticAst(machineContent);
nanoDiffTime = isBenchmark ? System.nanoTime() - start : 0;
} catch (ParserException e) {
logger.severe(e.toString());
System.exit(1);
}
if (machineNode == null) {
logger.severe("Invalid machine");
System.exit(1);
}
return machineNode;
}
use of de.bmoth.parser.ast.nodes.MachineNode in project bmoth by hhu-stups.
the class Parser method getMachineAst.
private MachineNode getMachineAst(StartContext start) throws ScopeException, ParseErrorException {
MachineAnalyser machineAnalyser = new MachineAnalyser(start);
SemanticAstCreator astCreator = new SemanticAstCreator(machineAnalyser);
return (MachineNode) astCreator.getAstNode();
}
use of de.bmoth.parser.ast.nodes.MachineNode in project bmoth by hhu-stups.
the class Parser method getMachineAsSemanticAst.
public static MachineNode getMachineAsSemanticAst(String inputString) throws ParserException {
Parser parser = new Parser();
try {
StartContext start = parser.parseMachine(inputString);
List<String> warnings = CSTAnalyser.analyseConcreteSyntaxTree(start);
MachineNode machineNode = parser.getMachineAst(start);
machineNode.setWarnings(warnings);
TypeChecker.typecheckMachineNode(machineNode);
return machineNode;
} catch (ParseErrorException | TypeErrorException | ScopeException e) {
throw new ParserException(e);
}
}
Aggregations