Search in sources :

Example 1 with ContextTypeNode

use of org.kie.dmn.feel.lang.ast.ContextTypeNode in project drools by kiegroup.

the class ASTBuilderVisitor method visitContextType.

@Override
public BaseNode visitContextType(FEEL_1_1Parser.ContextTypeContext ctx) {
    List<String> pNames = new ArrayList<>();
    for (TerminalNode id : ctx.Identifier()) {
        pNames.add(id.getText());
    }
    if (!pNames.get(0).equals("context")) {
        throw new IllegalStateException("grammar rule changed.");
    } else {
        pNames.remove(0);
    }
    List<TypeNode> pTypes = new ArrayList<>();
    for (TypeContext t : ctx.type()) {
        pTypes.add((TypeNode) visit(t));
    }
    Map<String, TypeNode> gens = new HashMap<>();
    for (int i = 0; i < pNames.size(); i++) {
        gens.put(pNames.get(i), pTypes.get(i));
    }
    return new ContextTypeNode(ctx, gens);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ListTypeNode(org.kie.dmn.feel.lang.ast.ListTypeNode) TypeNode(org.kie.dmn.feel.lang.ast.TypeNode) ContextTypeNode(org.kie.dmn.feel.lang.ast.ContextTypeNode) FunctionTypeNode(org.kie.dmn.feel.lang.ast.FunctionTypeNode) TerminalNode(org.antlr.v4.runtime.tree.TerminalNode) TypeContext(org.kie.dmn.feel.parser.feel11.FEEL_1_1Parser.TypeContext) ContextTypeNode(org.kie.dmn.feel.lang.ast.ContextTypeNode)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 TerminalNode (org.antlr.v4.runtime.tree.TerminalNode)1 ContextTypeNode (org.kie.dmn.feel.lang.ast.ContextTypeNode)1 FunctionTypeNode (org.kie.dmn.feel.lang.ast.FunctionTypeNode)1 ListTypeNode (org.kie.dmn.feel.lang.ast.ListTypeNode)1 TypeNode (org.kie.dmn.feel.lang.ast.TypeNode)1 TypeContext (org.kie.dmn.feel.parser.feel11.FEEL_1_1Parser.TypeContext)1