Search in sources :

Example 26 with Node

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

the class TranslatingVisitor method caseASequenceExtensionExpression.

@Override
public void caseASequenceExtensionExpression(ASequenceExtensionExpression node) {
    List<BObject> s = new ArrayList<BObject>();
    for (PExpression e : node.getExpression()) {
        e.apply(this);
        s.add(this.getResult());
    }
    this.setResult(new Sequence(s));
}
Also used : BObject(de.prob.translator.types.BObject) ArrayList(java.util.ArrayList) Sequence(de.prob.translator.types.Sequence) PExpression(de.be4.classicalb.core.parser.node.PExpression)

Example 27 with Node

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

the class SetType method createASTNode.

public PExpression createASTNode(Typechecker typechecker) {
    APowSubsetExpression node = new APowSubsetExpression(subtype.createASTNode(typechecker));
    typechecker.setType(node, this);
    return node;
}
Also used : APowSubsetExpression(de.be4.classicalb.core.parser.node.APowSubsetExpression)

Example 28 with Node

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

the class StringType method createASTNode.

public PExpression createASTNode(Typechecker typechecker) {
    AStringSetExpression node = new AStringSetExpression();
    typechecker.setType(node, new SetType(this));
    return node;
}
Also used : AStringSetExpression(de.be4.classicalb.core.parser.node.AStringSetExpression)

Example 29 with Node

use of de.be4.classicalb.core.parser.node.Node 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 30 with Node

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

the class MissingPositionsAdder method defaultIn.

public void defaultIn(Node node) {
    SourcePosition startPos = node.getStartPos();
    if (startPos == null) {
        Node parent = node.parent();
        if (parent != null && parent.getStartPos() != null) {
            node.setStartPos(parent.getStartPos());
            node.setEndPos(parent.getEndPos());
        }
    }
}
Also used : SourcePosition(de.hhu.stups.sablecc.patch.SourcePosition) Node(de.be4.classicalb.core.parser.node.Node)

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