xo-expression2: + DApplyExpr [WIP]. Builds, not used or tested

This commit is contained in:
Roland Conybeare 2026-01-25 13:14:26 -05:00
commit 6c73d08e32
5 changed files with 165 additions and 1 deletions

View file

@ -0,0 +1,64 @@
/** @file DApplyExpr.hpp
*
* @author Roland Conybeare, Jan 2026
**/
#pragma once
#include "Expression.hpp"
#include "TypeRef.hpp"
#include "exprtype.hpp"
#include <xo/object2/DArray.hpp>
#include <xo/reflect/TypeDescr.hpp>
#include <xo/indentlog/print/pretty.hpp>
namespace xo {
namespace scm {
/** @class DApplyExpr
* @brief syntax for a procedure/function call
**/
class DApplyExpr {
public:
using TypeDescr = xo::reflect::TypeDescr;
using ppindentinfo = xo::print::ppindentinfo;
using size_type = std::size_t;
public:
obj<AExpression> fn() const noexcept { return fn_; }
const DArray * args() const noexcept { return args_; }
size_type n_arg() const noexcept { return args_->size(); }
obj<AExpression> arg(size_type i) const;
/** @defgroup scm-applyexpr-expression-facet **/
///@{
exprtype extype() const noexcept { return exprtype::apply; }
TypeRef typeref() const noexcept { return typeref_; }
TypeDescr valuetype() const noexcept { return typeref_.td(); }
void assign_valuetype(TypeDescr td) noexcept;
///@}
/** @defgroup scm-applyexpr-printable-facet **/
///@{
bool pretty(const ppindentinfo & ppii) const;
///@}
private:
/** expression value always has type consistent
* with this description
**/
TypeRef typeref_;
/** expression for function/procedure to invoke **/
obj<AExpression> fn_;
/** expression for each argument vector **/
const DArray * args_;
};
}
}
/* end DApplyExpr.hpp */

View file

@ -15,7 +15,7 @@
namespace xo {
namespace scm {
/** @class DVariable*
/** @class DVariable
* @brief syntax for a variable reference
**/
class DVariable {

View file

@ -29,8 +29,10 @@ namespace xo {
#ifdef NOT_YET
/** variable assignment **/
assign,
#endif
/** function call **/
apply,
#ifdef NOT_YET
/** function definition **/
lambda,
#endif
@ -61,7 +63,9 @@ namespace xo {
case exprtype::define: return "define";
#ifdef NOT_YET
case exprtype::assign: return "assign";
#endif
case exprtype::apply: return "apply";
#ifdef NOT_YET
case exprtype::lambda: return "lambda";
case exprtype::variable: return "variable";
case exprtype::ifexpr: return "if_expr";