xo-reader: integer arithmetic + parser + pretty-printing adds

This commit is contained in:
Roland Conybeare 2025-07-27 13:35:20 -04:00
commit d39235c619
15 changed files with 209 additions and 14 deletions

View file

@ -106,8 +106,11 @@ namespace xo {
/** evaluates to the arguments to pass to @ref fn_ **/
std::vector<rp<Expression>> args_expr_v_;
};
} /*namespace scm */
namespace print {
PPDETAIL_ATOMIC(xo::scm::applyexprstatetype);
}
} /*namespace xo*/
/* end apply_xs.hpp */

View file

@ -107,6 +107,7 @@ namespace xo {
parserstatemachine * p_psm) override;
virtual void print(std::ostream & os) const override;
virtual bool pretty_print(const print::ppindentinfo & ppii) const override;
private:
static std::unique_ptr<define_xs> make();

View file

@ -57,6 +57,8 @@ namespace xo {
parserstatemachine * p_psm) override;
virtual void on_i64_token(const token_type & tk,
parserstatemachine * p_psm) override;
virtual void on_f64_token(const token_type & tk,
parserstatemachine * p_psm) override;
// ----- victory methods -----

View file

@ -7,6 +7,7 @@
#include "xo/expression/Expression.hpp"
#include "xo/tokenizer/token.hpp"
#include "xo/indentlog/print/ppdetail_atomic.hpp"
#include <stack>
//#include <cstdint>
@ -145,6 +146,9 @@ namespace xo {
/** print human-readable representation on @p os **/
virtual void print(std::ostream & os) const;
/** pretty-print using @p ppii **/
virtual bool pretty_print(const print::ppindentinfo & ppii) const;
// ----- input methods -----
/** handle incoming 'def' token **/

View file

@ -91,7 +91,10 @@ namespace xo {
};
} /*namespace scm*/
namespace print {
PPDETAIL_ATOMIC(xo::scm::ifexprstatetype);
}
} /*namespace xo*/
/** end if_else_xs.hpp **/
/* end if_else_xs.hpp */

View file

@ -83,6 +83,7 @@ namespace xo {
parserstatemachine * p_psm) override;
virtual void print(std::ostream & os) const override;
virtual bool pretty_print(const print::ppindentinfo & ppii) const override;
private:
static std::unique_ptr<lambda_xs> make();
@ -105,6 +106,10 @@ namespace xo {
};
} /*namespace scm*/
namespace print {
PPDETAIL_ATOMIC(xo::scm::lambdastatetype);
}
} /*namespace xo*/

View file

@ -10,6 +10,13 @@
namespace xo {
namespace print {
template <>
struct ppdetail<const xo::scm::envframestack*> {
static inline bool print_pretty(const ppindentinfo & ppii, const xo::scm::envframestack * p) {
return p->pretty_print(ppii);
}
};
template <>
struct ppdetail<xo::scm::envframestack*> {
static inline bool print_pretty(const ppindentinfo & ppii, const xo::scm::envframestack * p) {

View file

@ -16,5 +16,19 @@ namespace xo {
return p->pretty_print(ppii);
}
};
template <>
struct ppdetail<const xo::scm::exprstatestack*> {
static inline bool print_pretty(const ppindentinfo & ppii, const xo::scm::exprstatestack * p) {
return p->pretty_print(ppii);
}
};
template <>
struct ppdetail<xo::scm::exprstate*> {
static inline bool print_pretty(const ppindentinfo & ppii, const xo::scm::exprstate * p) {
return p->pretty_print(ppii);
}
};
} /*namespace print*/
} /*namespace xo*/

View file

@ -6,6 +6,7 @@
#pragma once
#include "exprstate.hpp"
#include "xo/reflect/TypeDescr.hpp"
#include <iostream>
//#include <cstdint>
@ -90,6 +91,12 @@ namespace xo {
bool admits_f64() const;
void apply_type_error(const char * self_name,
optype op,
bp<Expression> expr1,
bp<Expression> expr2,
parserstatemachine * p_psm) const;
virtual const char * get_expect_str() const override;
virtual void on_expr(bp<Expression> expr,
@ -113,6 +120,8 @@ namespace xo {
parserstatemachine * p_psm) override;
virtual void on_rightparen_token(const token_type & tk,
parserstatemachine * p_psm) override;
virtual void on_rightbrace_token(const token_type & tk,
parserstatemachine * p_psm) override;
virtual void on_then_token(const token_type & tk,
parserstatemachine * p_psm) override;
virtual void on_else_token(const token_type & tk,
@ -132,6 +141,7 @@ namespace xo {
parserstatemachine * p_psm) override;
virtual void print(std::ostream & os) const override;
virtual bool pretty_print(const print::ppindentinfo & ppii) const override;
private:
static std::unique_ptr<progress_xs> make(rp<Expression> valex,