Search in sources :

Example 1 with PRecEntry

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

the class StructType method createASTNode.

public PExpression createASTNode(Typechecker typechecker) {
    ArrayList<PRecEntry> list = new ArrayList<PRecEntry>();
    Set<Entry<String, BType>> entrySet = this.types.entrySet();
    for (Entry<String, BType> entry : entrySet) {
        String name = entry.getKey();
        BType type = entry.getValue();
        TIdentifierLiteral literal = new TIdentifierLiteral(name);
        ArrayList<TIdentifierLiteral> idList = new ArrayList<TIdentifierLiteral>();
        idList.add(literal);
        AIdentifierExpression id = new AIdentifierExpression(idList);
        ARecEntry recEntry = new ARecEntry(id, type.createASTNode(typechecker));
        list.add(recEntry);
    }
    AStructExpression node = new AStructExpression(list);
    typechecker.setType(node, new SetType(this));
    return node;
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) ARecEntry(de.be4.classicalb.core.parser.node.ARecEntry) ArrayList(java.util.ArrayList) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral) AStructExpression(de.be4.classicalb.core.parser.node.AStructExpression) ARecEntry(de.be4.classicalb.core.parser.node.ARecEntry) PRecEntry(de.be4.classicalb.core.parser.node.PRecEntry) Entry(java.util.Map.Entry) PRecEntry(de.be4.classicalb.core.parser.node.PRecEntry)

Example 2 with PRecEntry

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

the class TranslatingVisitor method caseARecExpression.

@Override
public void caseARecExpression(ARecExpression node) {
    Map<java.lang.String, BObject> s = Record.newStorage();
    // TODO or make the record immutable after filling it
    for (PRecEntry e : node.getEntries()) {
        e.apply(this);
        RecordEntry entry = (RecordEntry) this.getResult();
        s.put(entry.getKey().getValue(), entry.getValue());
    }
    this.setResult(new Record(s));
}
Also used : BObject(de.prob.translator.types.BObject) PRecEntry(de.be4.classicalb.core.parser.node.PRecEntry) Record(de.prob.translator.types.Record) String(de.prob.translator.types.String)

Aggregations

PRecEntry (de.be4.classicalb.core.parser.node.PRecEntry)2 AIdentifierExpression (de.be4.classicalb.core.parser.node.AIdentifierExpression)1 ARecEntry (de.be4.classicalb.core.parser.node.ARecEntry)1 AStructExpression (de.be4.classicalb.core.parser.node.AStructExpression)1 TIdentifierLiteral (de.be4.classicalb.core.parser.node.TIdentifierLiteral)1 BObject (de.prob.translator.types.BObject)1 Record (de.prob.translator.types.Record)1 String (de.prob.translator.types.String)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1