use of de.be4.classicalb.core.parser.node.PExpression in project probparsers by bendisposto.
the class ASTBuilder method createSetOfPExpression.
public static PExpression createSetOfPExpression(PExpression pExpression, PositionedNode pos) {
final ArrayList<PExpression> list = new ArrayList<>();
list.add((PExpression) cloneNode(pExpression));
return createPositinedNode(new ASetExtensionExpression(list), pos);
}
use of de.be4.classicalb.core.parser.node.PExpression in project probparsers by bendisposto.
the class ASTBuilder method addBooleanPreferenceDefinition.
public static void addBooleanPreferenceDefinition(IDefinitions iDefinitions, String name, boolean bool) {
AExpressionDefinitionDefinition def = new AExpressionDefinitionDefinition(new TIdentifierLiteral(name), new ArrayList<PExpression>(), bool ? new ABooleanTrueExpression() : new ABooleanFalseExpression());
iDefinitions.addDefinition(def, IDefinitions.Type.Expression);
}
use of de.be4.classicalb.core.parser.node.PExpression in project probparsers by bendisposto.
the class BMachine method addPromotesClause.
public void addPromotesClause(List<String> operationList) {
APromotesMachineClause promotes = new APromotesMachineClause();
List<PExpression> opList = new ArrayList<>();
for (String name : operationList) {
List<TIdentifierLiteral> idList = new ArrayList<>();
idList.add(new TIdentifierLiteral(name));
AIdentifierExpression idExpr = new AIdentifierExpression(idList);
opList.add(idExpr);
}
promotes.setOperationNames(opList);
this.parseUnit.getMachineClauses().add(promotes);
}
use of de.be4.classicalb.core.parser.node.PExpression 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());
}
}
}
use of de.be4.classicalb.core.parser.node.PExpression in project probparsers by bendisposto.
the class OpSubstitutions method setTypeSubstDef.
private void setTypeSubstDef(final AFuncOpSubstitution node, final String idString) {
final AExpressionDefinitionDefinition oldDefinition = (AExpressionDefinitionDefinition) definitions.getDefinition(idString);
final Node defRhs = oldDefinition.getRhs();
final PSubstitution rhsSubst;
if (defRhs instanceof AFunctionExpression) {
final AFunctionExpression rhsFunction = (AFunctionExpression) defRhs;
rhsSubst = new AOpSubstitution(rhsFunction.getIdentifier(), new LinkedList<PExpression>(rhsFunction.getParameters()));
rhsSubst.setStartPos(rhsFunction.getStartPos());
rhsSubst.setEndPos(rhsFunction.getEndPos());
} else if (defRhs instanceof AIdentifierExpression) {
final AIdentifierExpression rhsIdent = (AIdentifierExpression) defRhs;
rhsSubst = new AOpSubstitution(rhsIdent, new LinkedList<PExpression>());
rhsSubst.setStartPos(rhsIdent.getStartPos());
rhsSubst.setEndPos(rhsIdent.getEndPos());
} else {
// some other expression was parsed (NOT allowed)
throw new VisitorException(new CheckException("Expecting operation", node));
}
final TIdentifierLiteral oldDefId = oldDefinition.getName();
final TDefLiteralSubstitution defId = new TDefLiteralSubstitution(oldDefId.getText(), oldDefId.getLine(), oldDefId.getPos());
final ASubstitutionDefinitionDefinition substDef = new ASubstitutionDefinitionDefinition(defId, new LinkedList<PExpression>(oldDefinition.getParameters()), rhsSubst);
substDef.setStartPos(oldDefinition.getStartPos());
substDef.setEndPos(oldDefinition.getEndPos());
definitions.replaceDefinition(idString, Type.Substitution, substDef);
oldDefinition.replaceBy(substDef);
}
Aggregations