pretty printing -- copmlete for xo::ast::GeneralizedExpression

This commit is contained in:
Roland Conybeare 2025-07-19 11:47:03 -05:00
commit c0587aa4fb
14 changed files with 206 additions and 29 deletions

View file

@ -14,8 +14,10 @@ namespace xo {
**/
class envframestack {
public:
using LocalEnv = xo::ast::LocalEnv;
using Variable = xo::ast::Variable;
using LocalEnv = xo::ast::LocalEnv;
using Variable = xo::ast::Variable;
using ppstate = xo::print::ppstate;
using ppindentinfo = xo::print::ppindentinfo;
public:
envframestack() {}
@ -58,6 +60,7 @@ namespace xo {
}
void print (std::ostream & os) const;
bool pretty_print(const ppindentinfo & ppii) const;
private:
std::vector<rp<LocalEnv>> stack_;

View file

@ -76,7 +76,7 @@ namespace xo {
}
class parserstatemachine; /* see parserstatemachine.hpp */
class exprstatestack;
class exprstatestack; /* see exprstatestack.hpp */
class formal_arg;

View file

@ -15,6 +15,10 @@ namespace xo {
* @brief A stack of exprstate objects
**/
class exprstatestack {
public:
using ppstate = xo::print::ppstate;
using ppindentinfo = xo::print::ppindentinfo;
public:
exprstatestack() {}
@ -45,6 +49,7 @@ namespace xo {
}
void print (std::ostream & os) const;
bool pretty_print(const ppindentinfo & ppii) const;
private:
std::vector<std::unique_ptr<exprstate>> stack_;
@ -65,21 +70,6 @@ namespace xo {
return os;
}
} /*namespace scm*/
#ifndef ppdetail_atomic
namespace print {
template <>
struct ppdetail<xo::scm::exprstatestack *> {
static bool print_upto(ppstate * pps, const xo::scm::exprstatestack * x) {
return ppdetail_atomic<const xo::scm::exprstatestack *>::print_upto(pps, x);
}
static void print_pretty(ppstate * pps, const xo::scm::exprstatestack * x) {
ppdetail_atomic<const xo::scm::exprstatestack *>::print_pretty(pps, x);
}
};
}
#endif
} /*namespace xo*/

View file

@ -87,13 +87,4 @@ namespace xo {
return os;
}
} /*namespace scm*/
#ifndef ppdetail_atomic
namespace print {
PPDETAIL_ATOMIC(xo::scm::parserstatemachine);
}
#endif
} /*namespace xo*/
/* end parserstatemachine.hpp */

View file

@ -0,0 +1,20 @@
/* file pretty_envframestack.hpp
*
* author: Roland Conybeare, Jul 2025
*/
#pragma once
#include "envframestack.hpp"
#include "xo/indentlog/print/pretty.hpp"
namespace xo {
namespace print {
template <>
struct ppdetail<xo::scm::envframestack*> {
static inline bool print_pretty(const ppindentinfo & ppii, const xo::scm::envframestack * p) {
return p->pretty_print(ppii);
}
};
} /*namespace print*/
} /*namespace xo*/

View file

@ -0,0 +1,20 @@
/* file pretty_exprstatestack.hpp
*
* author: Roland Conybeare, Jul 2025
*/
#pragma once
#include "exprstatestack.hpp"
#include "xo/indentlog/print/pretty.hpp"
namespace xo {
namespace print {
template <>
struct ppdetail<xo::scm::exprstatestack*> {
static inline bool print_pretty(const ppindentinfo & ppii, const xo::scm::exprstatestack * p) {
return p->pretty_print(ppii);
}
};
} /*namespace print*/
} /*namespace xo*/

View file

@ -0,0 +1,18 @@
/* file pretty_parserstatemachine.hpp
*
* author: Roland Conybeare, Jul 2025
*/
#pragma once
#include "parserstatemachine.hpp"
#include "xo/indentlog/print/pretty.hpp"
namespace xo {
namespace print {
template<>
struct ppdetail<xo::scm::parserstatemachine> {
static bool print_pretty(const ppindentinfo & ppii, const xo::scm::parserstatemachine & x);
};
}
} /*namespace xo*/