use of de.be4.classicalb.core.parser.node.AMachineReference in project probparsers by bendisposto.
the class BMachine method addIncludesClause.
public void addIncludesClause(String machineName) {
AIncludesMachineClause includes = new AIncludesMachineClause();
List<PMachineReference> referencesList = new ArrayList<>();
List<TIdentifierLiteral> idList = new ArrayList<>();
idList.add(new TIdentifierLiteral(machineName));
referencesList.add(new AMachineReference(idList, new ArrayList<PExpression>()));
includes.setMachineReferences(referencesList);
this.parseUnit.getMachineClauses().add(includes);
}
use of de.be4.classicalb.core.parser.node.AMachineReference in project probparsers by bendisposto.
the class RulesReferencesFinder method registerMachineReference.
private void registerMachineReference(AMachineReference mchRef) {
String name = mchRef.getMachineName().get(0).getText();
try {
final File file = lookupFile(mainFile.getParentFile(), name, mchRef);
RulesMachineReference rulesMachineReference = new RulesMachineReference(file, name, mchRef);
referncesTable.put(name, rulesMachineReference);
} catch (CheckException e) {
errorList.add(e);
}
}
use of de.be4.classicalb.core.parser.node.AMachineReference in project probparsers by bendisposto.
the class ReferencedMachines method caseAMachineReference.
/**
* INCLUDES, EXTENDS, IMPORTS
*/
@Override
public void caseAMachineReference(AMachineReference node) {
String name = getIdentifier(node.getMachineName());
if (node.parent() instanceof AFileMachineReference) {
final AFileMachineReference fileNode = (AFileMachineReference) node.parent();
String file = fileNode.getFile().getText().replaceAll("\"", "");
MachineReference ref;
try {
ref = new MachineReference(name, node, file);
referncesTable.put(name, ref);
} catch (CheckException e) {
throw new VisitorException(e);
}
} else {
MachineReference machineReference = new MachineReference(name, node);
if (this.filePathTable.containsKey(name)) {
machineReference.setDirectoryPath(filePathTable.get(name));
}
referncesTable.put(name, machineReference);
}
}
use of de.be4.classicalb.core.parser.node.AMachineReference in project probparsers by bendisposto.
the class RulesReferencesFinder method registerMachineNames.
private void registerMachineNames(final PMachineReference machineReference) {
if (machineReference instanceof AFileMachineReference) {
registerMachineByFilePragma((AFileMachineReference) machineReference);
} else {
AMachineReference mchRef = (AMachineReference) machineReference;
registerMachineReference(mchRef);
}
}
use of de.be4.classicalb.core.parser.node.AMachineReference in project probparsers by bendisposto.
the class RulesReferencesFinder method registerMachineByFilePragma.
private void registerMachineByFilePragma(AFileMachineReference fileNode) {
final String filePath = fileNode.getFile().getText().replaceAll("\"", "");
final AMachineReference ref = (AMachineReference) fileNode.getReference();
final String name = ref.getMachineName().get(0).getText();
File file = null;
File tempFile = new File(filePath);
if (tempFile.exists() && tempFile.isAbsolute() && !tempFile.isDirectory()) {
file = tempFile;
} else {
tempFile = new File(mainFile.getParentFile(), filePath);
if (tempFile.exists() && !tempFile.isDirectory()) {
file = tempFile;
}
}
if (tempFile.isDirectory()) {
errorList.add(new CheckException(String.format("File '%s' is a directory.", filePath), fileNode.getFile()));
return;
} else if (file == null) {
errorList.add(new CheckException(String.format("File '%s' does not exist.", filePath), fileNode.getFile()));
return;
} else {
RulesMachineReference rulesMachineReference = new RulesMachineReference(file, name, fileNode.getReference());
referncesTable.put(name, rulesMachineReference);
return;
}
}
Aggregations