xo-expression: + GeneralizedExpression pretty-printing [WIP]
This commit is contained in:
parent
55602c83cc
commit
0b0d8ffdc0
11 changed files with 204 additions and 1 deletions
|
|
@ -1,6 +1,8 @@
|
|||
/* @file GeneralizedExpression.cpp */
|
||||
|
||||
#include "GeneralizedExpression.hpp"
|
||||
#include "pretty_expression.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
namespace xo {
|
||||
namespace ast {
|
||||
|
|
@ -8,6 +10,20 @@ namespace xo {
|
|||
GeneralizedExpression::display_string() const {
|
||||
return tostr(*this);
|
||||
}
|
||||
|
||||
std::uint32_t
|
||||
GeneralizedExpression::pretty_print(ppstate * pps, bool upto) const {
|
||||
// Slooooow fallback for subtypes that don't implement pretty printing support
|
||||
// Currently have support for:
|
||||
// - Lambda
|
||||
|
||||
std::uint32_t saved = pps->pos();
|
||||
pps->write(display_string());
|
||||
if (upto && !pps->has_margin())
|
||||
return false;
|
||||
|
||||
return upto ? pps->scan_no_newline(saved) : true;
|
||||
}
|
||||
} /*namespace ast*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue