Search in sources :

Example 11 with TIdentifierLiteral

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

the class ASTBuilder method createEqualPredicate.

public static AEqualPredicate createEqualPredicate(TIdentifierLiteral old, final String value) {
    TIdentifierLiteral e = NodeCloner.cloneNode(old);
    AIdentifierExpression aIdentifier = createAIdentifierExpression(e);
    final AEqualPredicate equal = new AEqualPredicate(aIdentifier, new AStringExpression(new TStringLiteral(value)));
    equal.setStartPos(e.getStartPos());
    equal.setEndPos(e.getEndPos());
    return equal;
}
Also used : AEqualPredicate(de.be4.classicalb.core.parser.node.AEqualPredicate) AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) AStringExpression(de.be4.classicalb.core.parser.node.AStringExpression) TStringLiteral(de.be4.classicalb.core.parser.node.TStringLiteral) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral)

Example 12 with TIdentifierLiteral

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

the class ASTBuilder method createIdentifier.

public static AIdentifierExpression createIdentifier(String name) {
    ArrayList<TIdentifierLiteral> list = new ArrayList<>();
    list.add(new TIdentifierLiteral(name));
    return new AIdentifierExpression(list);
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) ArrayList(java.util.ArrayList) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral)

Example 13 with TIdentifierLiteral

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

the class ASTBuilder method addSortDefinition.

public static void addSortDefinition(IDefinitions iDefinitions) {
    if (iDefinitions.containsDefinition(SORT)) {
        return;
    }
    /*- SORT
		 *  SORT(X) == [];
		 *  EXTERNAL_FUNCTION_SORT(T) == POW(T)-->seq(T);
		 */
    AExpressionDefinitionDefinition sortDef = new AExpressionDefinitionDefinition();
    sortDef.setName(new TIdentifierLiteral(SORT));
    sortDef.setParameters(createExpressionList("X"));
    sortDef.setRhs(new AEmptySequenceExpression());
    iDefinitions.addDefinition(sortDef, IDefinitions.Type.Expression);
    AExpressionDefinitionDefinition sortType = new AExpressionDefinitionDefinition();
    sortType.setName(new TIdentifierLiteral("EXTERNAL_FUNCTION_SORT"));
    sortType.setParameters(createExpressionList("T"));
    sortType.setRhs(new ATotalFunctionExpression(new APowSubsetExpression(createIdentifier("T")), new ASeqExpression(createIdentifier("T"))));
    iDefinitions.addDefinition(sortType, IDefinitions.Type.Expression);
}
Also used : AEmptySequenceExpression(de.be4.classicalb.core.parser.node.AEmptySequenceExpression) APowSubsetExpression(de.be4.classicalb.core.parser.node.APowSubsetExpression) ASeqExpression(de.be4.classicalb.core.parser.node.ASeqExpression) AExpressionDefinitionDefinition(de.be4.classicalb.core.parser.node.AExpressionDefinitionDefinition) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral) ATotalFunctionExpression(de.be4.classicalb.core.parser.node.ATotalFunctionExpression)

Example 14 with TIdentifierLiteral

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

the class ASTBuilder method createIdentifier.

public static AIdentifierExpression createIdentifier(String name, PositionedNode positionNode) {
    ArrayList<TIdentifierLiteral> list = new ArrayList<>();
    TIdentifierLiteral literal = new TIdentifierLiteral(name);
    // literal.setStartPos(positionNode.getStartPos());
    // literal.setEndPos(positionNode.getEndPos());
    list.add(literal);
    AIdentifierExpression result = new AIdentifierExpression(list);
    result.setStartPos(positionNode.getStartPos());
    result.setEndPos(positionNode.getEndPos());
    return result;
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) ArrayList(java.util.ArrayList) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral)

Example 15 with TIdentifierLiteral

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

the class BMachine method addIncludesClause.

public void addIncludesClause(String machineName) {
    AIncludesMachineClause includes = new AIncludesMachineClause();
    List<PMachineReference> referencesList = new ArrayList<>();
    List<TIdentifierLiteral> idList = new ArrayList<>();
    idList.add(new TIdentifierLiteral(machineName));
    referencesList.add(new AMachineReference(idList, new ArrayList<PExpression>()));
    includes.setMachineReferences(referencesList);
    this.parseUnit.getMachineClauses().add(includes);
}
Also used : PMachineReference(de.be4.classicalb.core.parser.node.PMachineReference) ArrayList(java.util.ArrayList) AMachineReference(de.be4.classicalb.core.parser.node.AMachineReference) AIncludesMachineClause(de.be4.classicalb.core.parser.node.AIncludesMachineClause) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral)

Aggregations

TIdentifierLiteral (de.be4.classicalb.core.parser.node.TIdentifierLiteral)44 ArrayList (java.util.ArrayList)23 AIdentifierExpression (de.be4.classicalb.core.parser.node.AIdentifierExpression)13 PExpression (de.be4.classicalb.core.parser.node.PExpression)9 CheckException (de.be4.classicalb.core.parser.exceptions.CheckException)8 AExpressionDefinitionDefinition (de.be4.classicalb.core.parser.node.AExpressionDefinitionDefinition)8 ATotalFunctionExpression (de.be4.classicalb.core.parser.node.ATotalFunctionExpression)5 LinkedList (java.util.LinkedList)4 BException (de.be4.classicalb.core.parser.exceptions.BException)3 APowSubsetExpression (de.be4.classicalb.core.parser.node.APowSubsetExpression)3 AStringExpression (de.be4.classicalb.core.parser.node.AStringExpression)3 PSubstitution (de.be4.classicalb.core.parser.node.PSubstitution)3 TStringLiteral (de.be4.classicalb.core.parser.node.TStringLiteral)3 TIdentifierLiteral (de.be4.eventbalg.core.parser.node.TIdentifierLiteral)3 VisitorException (de.be4.classicalb.core.parser.exceptions.VisitorException)2 AConstructorFreetypeConstructor (de.be4.classicalb.core.parser.node.AConstructorFreetypeConstructor)2 ADefinitionExpression (de.be4.classicalb.core.parser.node.ADefinitionExpression)2 AEqualPredicate (de.be4.classicalb.core.parser.node.AEqualPredicate)2 AEvent (de.be4.classicalb.core.parser.node.AEvent)2 AEventBModelParseUnit (de.be4.classicalb.core.parser.node.AEventBModelParseUnit)2