xo-expression/xo-reader: refactor Environment -> SymbolTable

This commit is contained in:
Roland Conybeare 2025-11-19 12:42:31 -05:00
commit 42147bb7c0
10 changed files with 35 additions and 35 deletions

View file

@ -8,7 +8,7 @@
xxx;
#include "xo/expression/Variable.hpp"
#include "xo/expression/LocalEnv.hpp"
#include "xo/expression/LocalSymtab.hpp"
#include <vector>
namespace xo {

View file

@ -5,7 +5,7 @@
#pragma once
#include "xo/expression/LocalEnv.hpp"
#include "xo/expression/LocalSymtab.hpp"
namespace xo {
namespace scm {
@ -34,16 +34,16 @@ namespace xo {
**/
void upsert(bp<Variable> target);
bp<Environment> top_envframe() const;
void push_envframe(const rp<Environment> & x);
rp<Environment> pop_envframe();
bp<SymbolTable> top_envframe() const;
void push_envframe(const rp<SymbolTable> & x);
rp<SymbolTable> pop_envframe();
void reset_to_toplevel() { stack_.resize(1); }
/** relative to top-of-stack.
* 0 -> top (last in), z-1 -> bottom (first in)
**/
bp<Environment> operator[](std::size_t i) {
bp<SymbolTable> operator[](std::size_t i) {
std::size_t z = stack_.size();
assert(i < z);
@ -51,7 +51,7 @@ namespace xo {
return stack_[z - i - 1].get();
}
bp<Environment> operator[](std::size_t i) const {
bp<SymbolTable> operator[](std::size_t i) const {
std::size_t z = stack_.size();
assert(i < z);
@ -63,7 +63,7 @@ namespace xo {
bool pretty_print(const ppindentinfo & ppii) const;
private:
std::vector<rp<Environment>> stack_;
std::vector<rp<SymbolTable>> stack_;
};
inline std::ostream &

View file

@ -6,7 +6,7 @@
#pragma once
#include "exprstate.hpp"
#include "xo/expression/LocalEnv.hpp"
#include "xo/expression/LocalSymtab.hpp"
//#include <cstdint>
namespace xo {
@ -55,8 +55,8 @@ namespace xo {
**/
class lambda_xs : public exprstate {
public:
using Environment = xo::scm::Environment;
using LocalEnv = xo::scm::LocalEnv;
using Environment = xo::scm::SymbolTable;
using LocalEnv = xo::scm::LocalSymtab;
public:
lambda_xs();

View file

@ -6,13 +6,13 @@
#pragma once
#include "exprstate.hpp"
#include "xo/expression/LocalEnv.hpp"
#include "xo/expression/LocalSymtab.hpp"
namespace xo {
namespace scm {
class let1_xs : public exprstate {
public:
using LocalEnv = xo::scm::LocalEnv;
using LocalEnv = xo::scm::LocalSymtab;
public:
/** given local definition equivalent to

View file

@ -24,7 +24,7 @@ namespace xo {
public:
using Expression = xo::scm::Expression;
using Variable = xo::scm::Variable;
using LocalEnv = xo::scm::LocalEnv;
using LocalEnv = xo::scm::LocalSymtab;
using token_type = token<char>;
public:
@ -59,13 +59,13 @@ namespace xo {
void upsert_var(bp<Variable> x);
/** @return available variable bindings in current parsing state **/
bp<Environment> top_envframe() const;
bp<SymbolTable> top_envframe() const;
/** @return frame @p i levels from the top **/
bp<Environment> lookup_envframe(std::size_t i) const;
bp<SymbolTable> lookup_envframe(std::size_t i) const;
/** push frame @p x (with new variable bindings) onto environment stack **/
void push_envframe(const rp<LocalEnv> & x);
/** @return pop innermost environment frame and return it **/
rp<Environment> pop_envframe();
rp<SymbolTable> pop_envframe();
/** @return number of stacked environment frames **/
size_t env_stack_size() const { return env_stack_.size(); }