1 /********************* */
2 /*! \file smt2_quote_string.cpp
4 ** Top contributors (to current version):
5 ** Tim King, Morgan Deters, Kshitij Bansal
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS
8 ** in the top-level source directory) and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
12 ** \brief Quotes a string if necessary for smt2.
14 ** Quotes a string if necessary for smt2.
17 #include "util/smt2_quote_string.h"
24 * SMT-LIB 2 quoting for symbols
26 std::string
quoteSymbol(const std::string
& s
){
27 if(s
.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@$%^&*_-+=<>.?/") == std::string::npos
) {
28 // simple unquoted symbol
32 // must quote the symbol, but it cannot contain | or \, we turn those into _
34 while((p
= tmp
.find_first_of("\\|")) != std::string::npos
) {
35 tmp
= tmp
.replace(p
, 1, "_");
37 return "|" + tmp
+ "|";