use of de.be4.classicalb.core.parser.analysis.checking.DefinitionUsageCheck in project probparsers by bendisposto.
the class BParser method performSemanticChecks.
private List<CheckException> performSemanticChecks(final Start rootNode) {
final List<CheckException> list = new ArrayList<>();
final SemanticCheck[] checks = { new ClausesCheck(), new SemicolonCheck(), new IdentListCheck(), new DefinitionUsageCheck(getDefinitions()), new PrimedIdentifierCheck(), new ProverExpressionsCheck() };
for (SemanticCheck check : checks) {
check.setOptions(parseOptions);
check.runChecks(rootNode);
list.addAll(check.getCheckExceptions());
}
return list;
}
use of de.be4.classicalb.core.parser.analysis.checking.DefinitionUsageCheck in project probparsers by bendisposto.
the class OpSubstitutions method caseAFunctionExpression.
@Override
public void caseAFunctionExpression(final AFunctionExpression node) {
if (node.getIdentifier() != null) {
node.getIdentifier().apply(this);
}
if (node.getIdentifier() instanceof ADefinitionExpression && ((ADefinitionExpression) node.getIdentifier()).getParameters().isEmpty()) {
final LinkedList<PExpression> paramList = new LinkedList<>(node.getParameters());
final TIdentifierLiteral identifier = ((ADefinitionExpression) node.getIdentifier()).getDefLiteral();
if (paramList.size() <= definitions.getParameterCount(identifier.getText())) {
/*
* The parameters seem to belong to this definition, so we need
* to replace the FunctionExpression by a
* DefinitionFunctionExpression. If not enough parameters were
* given this will be found by a later check, i.e.
* DefinitionUsageCheck.
*/
final ADefinitionExpression newNode = replaceWithDefExpression(node, identifier, paramList);
final List<PExpression> copy = newNode.getParameters();
for (final PExpression e : copy) {
e.apply(this);
}
return;
}
}
/*
* Reached in case that: Identifier of this FunctionExpression is not a
* definition or there were more parameters than the definition needs
* (by declaration), so we asume the parameters belong to some other
* construct (for example a function a level higher in the AST).
*/
final List<PExpression> copy = node.getParameters();
for (final PExpression e : copy) {
e.apply(this);
}
}
Aggregations