xo-expression/xo-reader: refactor Environment -> SymbolTable
This commit is contained in:
parent
cfca87ee44
commit
800928cd69
40 changed files with 146 additions and 510 deletions
|
|
@ -8,11 +8,11 @@
|
|||
#include "pretty_localenv.hpp"
|
||||
|
||||
namespace xo {
|
||||
using xo::scm::LocalEnv;
|
||||
using xo::scm::LocalSymtab;
|
||||
using xo::scm::Variable;
|
||||
|
||||
namespace scm {
|
||||
bp<Environment>
|
||||
bp<SymbolTable>
|
||||
envframestack::top_envframe() const {
|
||||
std::size_t z = stack_.size();
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ namespace xo {
|
|||
}
|
||||
|
||||
void
|
||||
envframestack::push_envframe(const rp<Environment> & frame)
|
||||
envframestack::push_envframe(const rp<SymbolTable> & frame)
|
||||
{
|
||||
constexpr bool c_debug_flag = true;
|
||||
scope log(XO_DEBUG(c_debug_flag),
|
||||
|
|
@ -38,7 +38,7 @@ namespace xo {
|
|||
stack_[z] = frame;
|
||||
}
|
||||
|
||||
rp<Environment>
|
||||
rp<SymbolTable>
|
||||
envframestack::pop_envframe() {
|
||||
constexpr bool c_debug_flag = true;
|
||||
scope log(XO_DEBUG(c_debug_flag));
|
||||
|
|
@ -48,7 +48,7 @@ namespace xo {
|
|||
if (z > 0) {
|
||||
//std::unique_ptr<exprstate> top = std::move(stack_[z-1]);
|
||||
|
||||
rp<Environment> retval = stack_.at(z-1);
|
||||
rp<SymbolTable> retval = stack_.at(z-1);
|
||||
|
||||
stack_.resize(z-1);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace xo {
|
||||
using xo::scm::Lambda;
|
||||
using xo::scm::LocalEnv;
|
||||
using xo::scm::LocalSymtab;
|
||||
|
||||
namespace scm {
|
||||
const char *
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ namespace xo {
|
|||
using Apply = xo::scm::Apply;
|
||||
using Lambda = xo::scm::Lambda;
|
||||
using LambdaAccess = xo::scm::LambdaAccess;
|
||||
using Environment = xo::scm::Environment;
|
||||
using LocalEnv = xo::scm::LocalEnv;
|
||||
using Environment = xo::scm::SymbolTable;
|
||||
using LocalEnv = xo::scm::LocalSymtab;
|
||||
using Variable = xo::scm::Variable;
|
||||
|
||||
namespace scm {
|
||||
|
|
@ -37,7 +37,7 @@ namespace xo {
|
|||
const rp<Expression> & rhs,
|
||||
parserstatemachine * p_psm)
|
||||
{
|
||||
rp<Environment> parent_env = p_psm->top_envframe().promote();
|
||||
rp<SymbolTable> parent_env = p_psm->top_envframe().promote();
|
||||
rp<Variable> var1 = Variable::make(lhs_name, rhs->valuetype());
|
||||
rp<LocalEnv> let_env = LocalEnv::make1(var1, parent_env);
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ namespace xo {
|
|||
|
||||
std::string lambda_name = Variable::gensym("let1");
|
||||
|
||||
rp<Environment> parent_env = p_psm->top_envframe().promote();
|
||||
rp<SymbolTable> parent_env = p_psm->top_envframe().promote();
|
||||
|
||||
rp<Expression> lambda
|
||||
= Lambda::make_from_env(lambda_name,
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@
|
|||
#include "xo/expression/DefineExpr.hpp"
|
||||
#include "xo/expression/Constant.hpp"
|
||||
#include "xo/expression/ConvertExpr.hpp"
|
||||
#include "xo/expression/GlobalEnv.hpp"
|
||||
//#include "xo/expression/LocalEnv.hpp"
|
||||
#include "xo/expression/GlobalSymtab.hpp"
|
||||
//#include "xo/expression/LocalSymtab.hpp"
|
||||
//#include <regex>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace xo {
|
||||
using xo::scm::Expression;
|
||||
using xo::scm::LocalEnv;
|
||||
using xo::scm::LocalSymtab;
|
||||
using xo::reflect::TypeDescr;
|
||||
|
||||
namespace scm {
|
||||
|
|
@ -28,7 +28,7 @@ namespace xo {
|
|||
: psm_{debug_flag}
|
||||
{
|
||||
/* top-level environment. initially empty */
|
||||
rp<Environment> toplevel_env = GlobalEnv::make_empty();
|
||||
rp<SymbolTable> toplevel_env = GlobalSymtab::make_empty();
|
||||
|
||||
this->psm_.env_stack_.push_envframe(toplevel_env);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include "xo/expression/pretty_expression.hpp"
|
||||
|
||||
namespace xo {
|
||||
using xo::scm::LocalEnv;
|
||||
using xo::scm::LocalSymtab;
|
||||
using xo::scm::Variable;
|
||||
|
||||
namespace scm {
|
||||
|
|
@ -45,12 +45,12 @@ namespace xo {
|
|||
xs_stack_.push_exprstate(std::move(x));
|
||||
}
|
||||
|
||||
bp<Environment>
|
||||
bp<SymbolTable>
|
||||
parserstatemachine::top_envframe() const {
|
||||
return env_stack_.top_envframe();
|
||||
}
|
||||
|
||||
bp<Environment>
|
||||
bp<SymbolTable>
|
||||
parserstatemachine::lookup_envframe(std::size_t i) const {
|
||||
return env_stack_[i];
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ namespace xo {
|
|||
env_stack_.push_envframe(x);
|
||||
}
|
||||
|
||||
rp<Environment>
|
||||
rp<SymbolTable>
|
||||
parserstatemachine::pop_envframe() {
|
||||
scope log(XO_DEBUG(debug_flag_));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue