@Override public Void visit(Token t, Void _) { builder.append("#token{\""); builder.append(t.tokenSort()); builder.append("\",\""); String s = StringEscapeUtils.escapeJava(t.value()); builder.append(s); builder.append("\"}"); return null; }
@java.lang.Override public ASTNode visit(KApp kapp, Void _) { if (kapp.getLabel() instanceof Token) { Token node = (Token) kapp.getLabel(); /* this code needs to be refactored; this transformer is backend dependent so whenever somebody refactors the backends should split this transformer for each backend. */ if (kompileOptions.experimental.legacyKast) { if (context.variableTokenSorts.contains(node.tokenSort())) { String sort = KSorts.K; String name = node.value(); int index = node.value().lastIndexOf(":"); if (index > 0) { sort = node.value().substring(index + 1); name = node.value().substring(0, index); } if (Sort.of("#" + sort).isDataSort()) { return KApp.of(KLabelConstant.of(AddSymbolicK.symbolicConstructor(sort)), Token.kAppOf(Sort.BUILTIN_ID, name)); } else { return KApp.of(KLabelConstant.of(AddSymbolicK.symbolicConstructor(KSorts.K)), Token.kAppOf(Sort.BUILTIN_ID, node.value())); } } } if (context.variableTokenSorts.contains(node.tokenSort())) return new org.kframework.kil.Variable(node.value(), node.tokenSort()); } return super.visit(kapp, _); //To change body of overridden methods use File | Settings | File Templates. }