mirror of
https://github.com/Z3Prover/z3
synced 2025-05-12 10:14:42 +00:00
Reorganizing the code
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
8b70f0b833
commit
d8cd3fc3ab
36 changed files with 261 additions and 429 deletions
62
src/util/smt2_util.cpp
Normal file
62
src/util/smt2_util.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*++
|
||||
Copyright (c) 2011 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
smt2_util.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
Goodies for SMT2 standard
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo (leonardo) 2012-10-20
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#include"smt2_util.h"
|
||||
|
||||
bool is_smt2_simple_symbol_char(char s) {
|
||||
return
|
||||
('0' <= s && s <= '9') ||
|
||||
('a' <= s && s <= 'z') ||
|
||||
('A' <= s && s <= 'Z') ||
|
||||
s == '~' || s == '!' || s == '@' || s == '$' || s == '%' || s == '^' || s == '&' ||
|
||||
s == '*' || s == '_' || s == '-' || s == '+' || s == '=' || s == '<' || s == '>' ||
|
||||
s == '.' || s == '?' || s == '/';
|
||||
}
|
||||
|
||||
bool is_smt2_quoted_symbol(char const * s) {
|
||||
if (s == 0)
|
||||
return false;
|
||||
if ('0' <= s[0] && s[0] <= '9')
|
||||
return true;
|
||||
unsigned len = static_cast<unsigned>(strlen(s));
|
||||
for (unsigned i = 0; i < len; i++)
|
||||
if (!is_smt2_simple_symbol_char(s[i]))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_smt2_quoted_symbol(symbol const & s) {
|
||||
if (s.is_numerical())
|
||||
return false;
|
||||
return is_smt2_quoted_symbol(s.bare_str());
|
||||
}
|
||||
|
||||
std::string mk_smt2_quoted_symbol(symbol const & s) {
|
||||
SASSERT(is_smt2_quoted_symbol(s));
|
||||
string_buffer<> buffer;
|
||||
buffer.append('|');
|
||||
char const * str = s.bare_str();
|
||||
while (*str) {
|
||||
if (*str == '|' || *str == '\\')
|
||||
buffer.append('\\');
|
||||
buffer.append(*str);
|
||||
str++;
|
||||
}
|
||||
buffer.append('|');
|
||||
return std::string(buffer.c_str());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue