use of de.be4.classicalb.core.parser.node.AIdentifierExpression in project probparsers by bendisposto.
the class RulesMachineChecker method checkReplacesAttribute.
private void checkReplacesAttribute(POperationAttribute pOperationAttribute, LinkedList<PExpression> arguments) {
if (arguments.size() != 1 || !(arguments.get(0) instanceof AIdentifierExpression)) {
errorList.add(new CheckException("Expected exactly one identifier after REPLACES.", pOperationAttribute));
return;
}
final AIdentifierExpression idExpr = (AIdentifierExpression) arguments.get(0);
currentOperation.addReplacesIdentifier(idExpr);
return;
}
use of de.be4.classicalb.core.parser.node.AIdentifierExpression in project probparsers by bendisposto.
the class RulesMachineChecker method caseAVarSubstitution.
@Override
public void caseAVarSubstitution(AVarSubstitution node) {
final HashSet<String> variables = new HashSet<>();
LinkedList<PExpression> identifiers = node.getIdentifiers();
for (PExpression e : identifiers) {
if (e instanceof AIdentifierExpression) {
AIdentifierExpression id = (AIdentifierExpression) e;
String name = id.getIdentifier().get(0).getText();
variables.add(name);
} else {
errorList.add(new CheckException("There must be a list of identifiers in VAR substitution.", node));
}
}
this.identifierScope.createNewScope(new LinkedList<PExpression>(node.getIdentifiers()), true);
node.getSubstitution().apply(this);
this.identifierScope.removeScope();
}
use of de.be4.classicalb.core.parser.node.AIdentifierExpression in project probparsers by bendisposto.
the class RulesMachineChecker method checkClassificationAttribute.
private void checkClassificationAttribute(POperationAttribute pOperationAttribute, LinkedList<PExpression> arguments) {
if (currentOperation instanceof RuleOperation) {
final RuleOperation rule = (RuleOperation) currentOperation;
if (arguments.size() == 1 && arguments.get(0) instanceof AIdentifierExpression) {
AIdentifierExpression identifier = (AIdentifierExpression) arguments.get(0);
String identifierString = Utils.getTIdentifierListAsString(identifier.getIdentifier());
rule.setClassification(identifierString);
} else {
errorList.add(new CheckException("Expected exactly one identifier after CLASSIFICATION.", pOperationAttribute));
}
} else {
errorList.add(new CheckException("CLASSIFICATION is not an attribute of a FUNCTION or COMPUTATION operation.", pOperationAttribute));
}
return;
}
use of de.be4.classicalb.core.parser.node.AIdentifierExpression in project probparsers by bendisposto.
the class RulesProject method checkReferencedRuleOperations.
public void checkReferencedRuleOperations() {
if (this.hasErrors()) {
return;
}
final HashMap<String, RulesParseUnit> map = new HashMap<>();
for (IModel model : bModels) {
RulesParseUnit parseUnit = (RulesParseUnit) model;
map.put(parseUnit.getMachineName(), parseUnit);
}
for (IModel model : bModels) {
if (model instanceof RulesParseUnit) {
RulesParseUnit rulesParseUnit = (RulesParseUnit) model;
Set<AIdentifierExpression> referencedRuleOperations = rulesParseUnit.getRulesMachineChecker().getReferencedRuleOperations();
final HashSet<String> knownRules = new HashSet<>();
for (RuleOperation ruleOperation : rulesParseUnit.getRulesMachineChecker().getRuleOperations()) {
knownRules.add(ruleOperation.getName());
}
for (RulesMachineReference rulesMachineReference : rulesParseUnit.getMachineReferences()) {
String referenceName = rulesMachineReference.getName();
RulesParseUnit otherParseUnit = map.get(referenceName);
for (RuleOperation ruleOperation : otherParseUnit.getRulesMachineChecker().getRuleOperations()) {
knownRules.add(ruleOperation.getName());
}
}
for (AIdentifierExpression aIdentifierExpression : referencedRuleOperations) {
String ruleName = Utils.getAIdentifierAsString(aIdentifierExpression);
if (!knownRules.contains(ruleName)) {
this.bExceptionList.add(new BException(rulesParseUnit.getPath(), new CheckException("Unknown rule '" + ruleName + "'.", aIdentifierExpression)));
}
}
}
}
}
use of de.be4.classicalb.core.parser.node.AIdentifierExpression in project probparsers by bendisposto.
the class RulesProject method checkDependsOnComputations.
private void checkDependsOnComputations(AbstractOperation operation) {
boolean errorOccured = false;
for (AIdentifierExpression aIdentifierExpression : operation.getDependsOnComputationList()) {
final String name = aIdentifierExpression.getIdentifier().get(0).getText();
if (allOperations.containsKey(name)) {
AbstractOperation abstractOperation = allOperations.get(name);
if (!(abstractOperation instanceof ComputationOperation)) {
this.bExceptionList.add(new BException(operation.getFileName(), new CheckException("Identifier '" + name + "' is not a COMPUTATION.", aIdentifierExpression)));
errorOccured = true;
}
} else {
errorOccured = true;
this.bExceptionList.add(new BException(operation.getFileName(), new CheckException("Unknown operation: '" + name + "'.", aIdentifierExpression)));
}
}
if (!errorOccured) {
checkVisibilityOfAIdentifierList(operation, operation.getDependsOnComputationList());
}
}
Aggregations