use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class RulesMachineChecker method caseAExpressionDefinitionDefinition.
@Override
public void caseAExpressionDefinitionDefinition(AExpressionDefinitionDefinition node) {
final String name = node.getName().getText();
this.definitions.add(name);
if ("GOAL".equals(name)) {
errorList.add(new CheckException("The GOAL definition must be a predicate.", node));
return;
}
this.identifierScope.createNewScope(new LinkedList<>(node.getParameters()));
node.getRhs().apply(this);
this.identifierScope.removeScope();
}
use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class RulesMachineChecker method caseARuleOperation.
@Override
public void caseARuleOperation(ARuleOperation node) {
currentOperation = new RuleOperation(node.getRuleName(), this.fileName, this.machineName, machineReferences);
if (containsRule(currentOperation.getName())) {
errorList.add(new CheckException("Duplicate operation name '" + currentOperation.getName() + "'.", node.getRuleName()));
}
RuleOperation ruleOp = (RuleOperation) currentOperation;
rulesMap.put(node, ruleOp);
visitOperationAttributes(node.getAttributes());
node.getRuleBody().apply(this);
checkAllErrorTypesImplemented(ruleOp);
currentOperation = null;
}
use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class RulesReferencesFinder method determineRootDirectory.
private void determineRootDirectory(final TPragmaIdOrString packageTerminal, final Node node) {
final String text = packageTerminal.getText();
if ((text.startsWith("\"") && text.endsWith("\""))) {
this.packageName = text.replaceAll("\"", "");
} else {
this.packageName = text;
}
final String[] packageNameArray = determinePackage(packageTerminal, node);
File dir = null;
try {
dir = mainFile.getCanonicalFile();
} catch (IOException e) {
errorList.add(new CheckException(e.getMessage(), (Node) null, e));
return;
}
for (int i = packageNameArray.length - 1; i >= 0; i--) {
final String name1 = packageNameArray[i];
dir = dir.getParentFile();
final String name2 = dir.getName();
if (!name1.equals(name2)) {
errorList.add(new CheckException(String.format("Package declaration '%s' does not match the folder structure: '%s' vs '%s'", this.packageName, name1, name2), node));
}
}
rootDirectory = dir.getParentFile();
}
use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class RulesReferencesFinder method caseAPackageParseUnit.
@Override
public void caseAPackageParseUnit(APackageParseUnit node) {
determineRootDirectory(node.getPackage(), node);
List<PImportPackage> copy = new ArrayList<>(node.getImports());
for (PImportPackage e : copy) {
e.apply(this);
}
node.getParseUnit().apply(this);
// delete this node
node.replaceBy(node.getParseUnit());
}
use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class RulesReferencesFinder method caseAImportPackage.
@Override
public void caseAImportPackage(AImportPackage node) {
final String[] packageArray = determinePackage(node.getPackage(), node);
final File pathFile = getFileStartingAtRootDirectory(packageArray);
final String path = pathFile.getAbsolutePath();
if (!pathFile.exists()) {
errorList.add(new CheckException(String.format("Imported package does not exist: %s", path), node.getPackage()));
return;
}
if (this.pathList.contains(path)) {
errorList.add(new CheckException(String.format("Duplicate package import: %s", node.getPackage().getText()), node));
return;
}
this.pathList.add(path);
}
Aggregations