@Override public String visit(ISymbol e) throws IVisitor.VisitorException { // Symbols do not necessarily have sorts - e.g. if they are function names ISort sort = typemap.get(e); if (!isFormula && sort != null && sort.isBool()) { throw new VisitorException( "Use of boolean in a term position is not yet implemented in the Simplify adapter", e.pos()); // FIXME - booleans as terms } // Simplify does not allow tab, newline, cr in identifiers; // these are allowed by SMTLIB. // Note that neither simplify nor SMTLIB allows \ or | // All other printable characters are allowed in both. String oldName = e.value(); String newName = fcnNames.get(oldName); if (newName != null) { // There is a direct translation of a pre-defined SMT-LIB name // into a simplify equivalent - use it. } else { // Use the ? character as an escape newName = oldName.replace("?", "??").replace("\n", "?n").replace("\r", "?r").replace("\t", "?t"); if (reservedWords.contains(newName)) { newName = newName + "?!"; } newName = "|" + newName + "|"; } return newName; }
/** Parses the arguments of the command, producing a new command instance */ public static /*@Nullable*/ C_declare_const parse(Parser p) throws ParserException { /*@Nullable*/ ISymbol symbol = p.parseSymbol(); if (symbol == null) return null; /*@Nullable*/ ISort result = p.parseSort(null); if (result == null) return null; String v = symbol.value(); if (v.length() > 0 && (v.charAt(0) == '@' || v.charAt(0) == '.')) { error(p.smt(), "User-defined symbols may not begin with . or @", symbol.pos()); return null; } return new C_declare_const(symbol, result); }