@Override
  public ASTNode visit(org.kframework.kil.KApp node, Void _void) {
    if (node.getLabel() instanceof org.kframework.kil.Token) {
      if (node.getLabel() instanceof BoolBuiltin) {
        return BoolToken.of(((BoolBuiltin) node.getLabel()).booleanValue());
      } else if (node.getLabel() instanceof IntBuiltin) {
        return IntToken.of(((IntBuiltin) node.getLabel()).bigIntegerValue());
      } else if (node.getLabel() instanceof StringBuiltin) {
        return StringToken.of(((StringBuiltin) node.getLabel()).stringValue());
      } else if (node.getLabel() instanceof FloatBuiltin) {
        return FloatToken.of(
            ((FloatBuiltin) node.getLabel()).bigFloatValue(),
            ((FloatBuiltin) node.getLabel()).exponent());
      } else if (node.getLabel() instanceof GenericToken) {
        return UninterpretedToken.of(
            Sort.of(((GenericToken) node.getLabel()).tokenSort()),
            ((GenericToken) node.getLabel()).value());
      } else {
        assert false : "unsupported Token " + node.getLabel();
      }
    }

    Term kLabel = (Term) this.visitNode(node.getLabel());
    Term kList = (Term) this.visitNode(node.getChild());
    if (kList instanceof Variable) {
      kList = kList.sort().equals(Sort.KLIST) ? kList : KList.singleton(kList);
    }
    return KItem.of(kLabel, kList, termContext, node.getSource(), node.getLocation());
  }
Esempio n. 2
0
 @Override
 public Void visit(KApp app, Void _) {
     if (app.getLabel() instanceof Token) {
         assert ((KList)app.getChild()).isEmpty();
         this.visitNode(app.getLabel());
     } else {
         printLabel(app.getLabel());
         Term child = app.getChild();
         builder.append('(');
         if (child instanceof KList) {
             visitNestedKLists((KList)child);
         } else if (child instanceof Variable) {
             Variable klistVar = (Variable)child;
             assert (klistVar.getSort().equals("KList"));
             builder.append(klistVar.getName());
             builder.append(":KList");
         } else {
             assert false;
         }
         builder.append(')');
     }
     return null;
 }
  @Override
  public ASTNode transform(org.kframework.kil.KApp node) throws TransformerException {
    if (node.getLabel() instanceof org.kframework.kil.Token) {
      if (node.getLabel() instanceof BoolBuiltin) {
        return BoolToken.of(((BoolBuiltin) node.getLabel()).booleanValue());
      } else if (node.getLabel() instanceof IntBuiltin) {
        return IntToken.of(((IntBuiltin) node.getLabel()).bigIntegerValue());
      } else if (node.getLabel() instanceof StringBuiltin) {
        return StringToken.of(((StringBuiltin) node.getLabel()).stringValue());
      } else if (node.getLabel() instanceof GenericToken) {
        return UninterpretedToken.of(
            ((GenericToken) node.getLabel()).tokenSort(), ((GenericToken) node.getLabel()).value());
      } else {
        assert false : "unsupported Token " + node.getLabel();
      }
    }

    KLabel kLabel = (KLabel) node.getLabel().accept(this);
    KList kList = (KList) node.getChild().accept(this);

    return new KItem(kLabel, kList, this.context);
  }