feat(util/sexpr/format): expose flatten
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
e602c4ba49
commit
01736bf82a
3 changed files with 12 additions and 4 deletions
|
@ -120,6 +120,13 @@ static void tst5() {
|
|||
std::cout << "{" << format() << "}" << "\n";
|
||||
}
|
||||
|
||||
static void tst6() {
|
||||
format r = (format("test") ^ format("hello")) + line() + format("world");
|
||||
std::cout << "test6\n";
|
||||
std::cout << r << "\n";
|
||||
std::cout << flatten(r) << "\n";
|
||||
}
|
||||
|
||||
int main() {
|
||||
save_stack_info();
|
||||
tst1();
|
||||
|
@ -127,5 +134,6 @@ int main() {
|
|||
tst3();
|
||||
tst4();
|
||||
tst5();
|
||||
tst6();
|
||||
return has_violations() ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -152,12 +152,12 @@ sexpr format::flatten(sexpr const & s) {
|
|||
}
|
||||
lean_unreachable(); // LCOV_EXCL_LINE
|
||||
}
|
||||
format format::flatten(format const & f){
|
||||
return format(flatten(f.m_value));
|
||||
format flatten(format const & f){
|
||||
return format(format::flatten(f.m_value));
|
||||
}
|
||||
format group(format const & f) {
|
||||
get_g_diff_flatten() = false;
|
||||
format flat_f = format::flatten(f);
|
||||
format flat_f = flatten(f);
|
||||
if (get_g_diff_flatten()) {
|
||||
return choice(flat_f, f);
|
||||
} else {
|
||||
|
|
|
@ -41,7 +41,6 @@ public:
|
|||
private:
|
||||
sexpr m_value;
|
||||
static sexpr flatten(sexpr const & s);
|
||||
static format flatten(format const & f);
|
||||
|
||||
// Functions for the internal sexpr representation
|
||||
static inline format_kind sexpr_kind(sexpr const & s) {
|
||||
|
@ -196,6 +195,7 @@ public:
|
|||
friend format above(format const & f1, format const & f2);
|
||||
friend format bracket(std::string const & l, format const & x, std::string const & r);
|
||||
friend format wrap(format const & f1, format const & f2);
|
||||
friend format flatten(format const & f);
|
||||
|
||||
// x + y = x <> y
|
||||
friend format operator+(format const & f1, format const & f2);
|
||||
|
|
Loading…
Reference in a new issue