Search in sources :

Example 6 with Node

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

the class DomBuilder method createExpressionAST.

private Start createExpressionAST(final PExpression expression) {
    Start start = new Start();
    AExpressionParseUnit node = new AExpressionParseUnit();
    start.setPParseUnit(node);
    start.setEOF(EOF);
    node.setExpression((PExpression) expression.clone());
    node.getExpression().apply(new RenameIdentifiers());
    return start;
}
Also used : AExpressionParseUnit(de.be4.classicalb.core.parser.node.AExpressionParseUnit) Start(de.be4.classicalb.core.parser.node.Start)

Example 7 with Node

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

the class IdentifierExtractor method union.

public static Set<String> union(final Node... assignments) {
    Set<String> union = new HashSet<>();
    for (Node assignment : assignments) {
        IdentifierExtractor v = new IdentifierExtractor();
        assignment.apply(v);
        union.addAll(v.getIdentifiers());
    }
    return union;
}
Also used : Node(de.be4.classicalb.core.parser.node.Node) HashSet(java.util.HashSet)

Example 8 with Node

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

the class EventBParserBase method toPrologTerm.

private static void toPrologTerm(final IPrologTermOutput pto, final Node ast, final boolean wrap, final String wrapper) {
    if (wrap) {
        pto.openTerm(wrapper);
    }
    final ASTProlog prolog = new ASTProlog(pto, null);
    ast.apply(prolog);
    if (wrap) {
        pto.closeTerm();
    }
}
Also used : ASTProlog(de.be4.classicalb.core.parser.analysis.prolog.ASTProlog)

Example 9 with Node

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

the class MachineContext method caseALetSubstitution.

@Override
public void caseALetSubstitution(ALetSubstitution node) {
    contextTable.add(new LinkedHashMap<String, Node>());
    List<PExpression> copy = new ArrayList<PExpression>(node.getIdentifiers());
    for (PExpression e : copy) {
        putLocalVariableIntoCurrentScope((AIdentifierExpression) e);
    }
    node.getPredicate().apply(this);
    node.getSubstitution().apply(this);
}
Also used : Node(de.be4.classicalb.core.parser.node.Node) ArrayList(java.util.ArrayList) PExpression(de.be4.classicalb.core.parser.node.PExpression)

Example 10 with Node

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

the class MachineContext method caseAAssertionsMachineClause.

@Override
public void caseAAssertionsMachineClause(AAssertionsMachineClause node) {
    this.assertiondMachineClause = node;
    this.contextTable = new ArrayList<LinkedHashMap<String, Node>>();
    ArrayList<MachineContext> list = lookupReferencedMachines();
    for (int i = 0; i < list.size(); i++) {
        MachineContext s = list.get(i);
        this.contextTable.add(s.getSetParamter());
        this.contextTable.add(s.getScalarParameter());
        this.contextTable.add(s.getDeferredSets());
        this.contextTable.add(s.getEnumeratedSets());
        this.contextTable.add(s.getEnumValues());
        this.contextTable.add(s.getConstants());
        this.contextTable.add(s.getDefinitions());
        this.contextTable.add(s.getVariables());
    }
    List<PPredicate> copy = new ArrayList<PPredicate>(node.getPredicates());
    for (PPredicate e : copy) {
        e.apply(this);
    }
}
Also used : ArrayList(java.util.ArrayList) PPredicate(de.be4.classicalb.core.parser.node.PPredicate) LinkedHashMap(java.util.LinkedHashMap)

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