Search in sources :

Example 1 with AFileExpression

use of de.be4.classicalb.core.parser.node.AFileExpression in project probparsers by bendisposto.

the class ReferencedMachines method registerMachineNames.

private void registerMachineNames(List<PExpression> referencedMachineList) {
    for (PExpression machineExpression : referencedMachineList) {
        if (machineExpression instanceof AIdentifierExpression) {
            AIdentifierExpression identifier = (AIdentifierExpression) machineExpression;
            String name = getIdentifier(identifier.getIdentifier());
            final MachineReference machineReference = new MachineReference(name, identifier);
            if (this.filePathTable.containsKey(name)) {
                machineReference.setDirectoryPath(filePathTable.get(name));
            }
            referncesTable.put(name, machineReference);
        } else if (machineExpression instanceof AFileExpression) {
            final AFileExpression fileNode = (AFileExpression) machineExpression;
            final AIdentifierExpression identifier = (AIdentifierExpression) fileNode.getIdentifier();
            String file = fileNode.getContent().getText().replaceAll("\"", "");
            String name = getIdentifier(identifier.getIdentifier());
            MachineReference machineReference;
            try {
                machineReference = new MachineReference(name, identifier, file);
                referncesTable.put(name, machineReference);
            } catch (CheckException e) {
                throw new VisitorException(e);
            }
        } else {
            throw new AssertionError("Not supported class: " + machineExpression.getClass());
        }
    }
}
Also used : CheckException(de.be4.classicalb.core.parser.exceptions.CheckException) AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) AFileExpression(de.be4.classicalb.core.parser.node.AFileExpression) TPragmaIdOrString(de.be4.classicalb.core.parser.node.TPragmaIdOrString) VisitorException(de.be4.classicalb.core.parser.exceptions.VisitorException) PExpression(de.be4.classicalb.core.parser.node.PExpression) AFileMachineReference(de.be4.classicalb.core.parser.node.AFileMachineReference) AMachineReference(de.be4.classicalb.core.parser.node.AMachineReference)

Aggregations

CheckException (de.be4.classicalb.core.parser.exceptions.CheckException)1 VisitorException (de.be4.classicalb.core.parser.exceptions.VisitorException)1 AFileExpression (de.be4.classicalb.core.parser.node.AFileExpression)1 AFileMachineReference (de.be4.classicalb.core.parser.node.AFileMachineReference)1 AIdentifierExpression (de.be4.classicalb.core.parser.node.AIdentifierExpression)1 AMachineReference (de.be4.classicalb.core.parser.node.AMachineReference)1 PExpression (de.be4.classicalb.core.parser.node.PExpression)1 TPragmaIdOrString (de.be4.classicalb.core.parser.node.TPragmaIdOrString)1