@Override public ASTNode transform(org.kframework.kil.Variable node) throws TransformerException { if (node.getSort().equals("Bag")) return new Variable(node.getName(), Kind.CELL_COLLECTION.toString()); DataStructureSort dataStructureSort = context.dataStructureSortOf(node.getSort()); if (dataStructureSort != null) { if (dataStructureSort.type().equals(org.kframework.kil.KSorts.LIST)) return new Variable(node.getName(), KSorts.LIST); if (dataStructureSort.type().equals(org.kframework.kil.KSorts.MAP)) return new Variable(node.getName(), KSorts.MAP); if (dataStructureSort.type().equals(org.kframework.kil.KSorts.SET)) return new Variable(node.getName(), KSorts.SET); } return new Variable(node.getName(), node.getSort()); }
@Override public Void visit(Variable v, Void _) { builder.append(v.getName()); if (v.isUserTyped()) { builder.append(':'); builder.append(v.getSort()); } return null; }
public void printLabel(Term t) { if (t instanceof Variable) { Variable v = (Variable) t; builder.append(v.getName()); } else { KLabelConstant l = (KLabelConstant)t; builder.append('`'); builder.append(l.getLabel()); builder.append('`'); } }
@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; }
public static boolean isAnonVar(Variable node) { return node.getName().startsWith(Constants.anyVarSymbol); }