Search in sources :

Example 91 with Node

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

the class RulesMachineChecker method checkSucceededRuleErrorTypeOperator.

private void checkSucceededRuleErrorTypeOperator(AOperatorPredicate node, final List<PExpression> arguments) {
    if (arguments.size() != 2) {
        this.errorList.add(new CheckException("The SUCCEEDED_RULE_ERROR_TYPE predicate operator expects exactly two arguments.", node));
        return;
    }
    PExpression pExpression = node.getIdentifiers().get(0);
    if (!(pExpression instanceof AIdentifierExpression)) {
        this.errorList.add(new CheckException("The first argument of SUCCEEDED_RULE_ERROR_TYPE must be an identifier.", node));
        return;
    }
    PExpression secondArg = node.getIdentifiers().get(1);
    if (!(secondArg instanceof AIntegerExpression)) {
        this.errorList.add(new CheckException("The second argument of SUCCEEDED_RULE_ERROR_TYPE must be an integer value.", node));
        return;
    }
    this.referencedRuleOperations.add((AIdentifierExpression) arguments.get(0));
    return;
}
Also used : AIntegerExpression(de.be4.classicalb.core.parser.node.AIntegerExpression) CheckException(de.be4.classicalb.core.parser.exceptions.CheckException) AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) PExpression(de.be4.classicalb.core.parser.node.PExpression)

Example 92 with Node

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

the class RulesMachineChecker method caseASubstitutionDefinitionDefinition.

@Override
public void caseASubstitutionDefinitionDefinition(ASubstitutionDefinitionDefinition node) {
    final String name = node.getName().getText();
    this.definitions.add(name);
    if ("GOAL".equals(name)) {
        errorList.add(new CheckException("The GOAL definition must be a predicate.", node));
        return;
    }
    this.identifierScope.createNewScope(new LinkedList<>(node.getParameters()));
    node.getRhs().apply(this);
    this.identifierScope.removeScope();
}
Also used : CheckException(de.be4.classicalb.core.parser.exceptions.CheckException)

Example 93 with Node

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

the class RulesMachineChecker method checkGetRuleCounterExamplesOperator.

private void checkGetRuleCounterExamplesOperator(AOperatorExpression node, final LinkedList<PExpression> parameters) {
    // the grammar ensures at least one argument
    if (parameters.size() > 2) {
        this.errorList.add(new CheckException("Invalid number of arguments. Expected one or two arguments.", node));
    }
    PExpression pExpression = node.getIdentifiers().get(0);
    if (!(pExpression instanceof AIdentifierExpression)) {
        this.errorList.add(new CheckException("The first argument of GET_RULE_COUNTEREXAMPLES must be an identifier.", node));
        return;
    }
    this.referencedRuleOperations.add((AIdentifierExpression) pExpression);
    return;
}
Also used : CheckException(de.be4.classicalb.core.parser.exceptions.CheckException) AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) PExpression(de.be4.classicalb.core.parser.node.PExpression)

Example 94 with Node

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

the class MachineContext method caseAConstantsMachineClause.

@Override
public void caseAConstantsMachineClause(AConstantsMachineClause node) {
    hasConstants = true;
    List<PExpression> copy = new ArrayList<PExpression>(node.getIdentifiers());
    for (PExpression e : copy) {
        AIdentifierExpression c = (AIdentifierExpression) e;
        String name = Utils.getTIdentifierListAsString(c.getIdentifier());
        exist(c.getIdentifier());
        constants.put(name, c);
    }
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) ArrayList(java.util.ArrayList) PExpression(de.be4.classicalb.core.parser.node.PExpression)

Example 95 with Node

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

the class MachineContext method caseAAbstractMachineParseUnit.

@Override
public void caseAAbstractMachineParseUnit(AAbstractMachineParseUnit node) {
    this.abstractMachineParseUnit = node;
    if (node.getVariant() != null) {
        node.getVariant().apply(this);
    }
    if (node.getHeader() != null) {
        node.getHeader().apply(this);
    }
    List<PMachineClause> machineClauses = node.getMachineClauses();
    // Sort the machine clauses: declarations clauses first, then
    // properties clauses
    MachineClauseSorter.sortMachineClauses(start);
    for (PMachineClause e : machineClauses) {
        e.apply(this);
    }
}
Also used : PMachineClause(de.be4.classicalb.core.parser.node.PMachineClause)

Aggregations

CheckException (de.be4.classicalb.core.parser.exceptions.CheckException)42 PExpression (de.be4.classicalb.core.parser.node.PExpression)30 ArrayList (java.util.ArrayList)30 Node (de.be4.classicalb.core.parser.node.Node)20 AIdentifierExpression (de.be4.classicalb.core.parser.node.AIdentifierExpression)16 TIdentifierLiteral (de.be4.classicalb.core.parser.node.TIdentifierLiteral)12 TPragmaIdOrString (de.be4.classicalb.core.parser.node.TPragmaIdOrString)11 VisitorException (de.be4.classicalb.core.parser.exceptions.VisitorException)8 HashSet (java.util.HashSet)8 Token (de.be4.ltl.core.parser.node.Token)7 Type (de.be4.classicalb.core.parser.IDefinitions.Type)6 IOException (java.io.IOException)6 ASTProlog (de.be4.classicalb.core.parser.analysis.prolog.ASTProlog)5 PositionedNode (de.hhu.stups.sablecc.patch.PositionedNode)5 LinkedList (java.util.LinkedList)5 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)4 LinkedHashMap (java.util.LinkedHashMap)4 Test (org.junit.Test)4 ClassicalPositionPrinter (de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter)3 NodeIdAssignment (de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment)3