Skip to content

Commit

Permalink
Rename function rename_ to corename
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Aug 28, 2024
1 parent b668d6e commit e7f1f84
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 42 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries:
cmake -B build -DCMAKE_BUILD_TYPE=Release
cd build
make package
sudo apt install build/meevax_0.5.219_amd64.deb
sudo apt install build/meevax_0.5.220_amd64.deb
```

or
Expand Down Expand Up @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.219.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.220.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.219_amd64.deb`
| `package` | Generate debian package `meevax_0.5.220_amd64.deb`
| `install` | Copy files into `/usr/local` directly

## Usage
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.219
0.5.220
77 changes: 39 additions & 38 deletions include/meevax/kernel/syntactic_environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ inline namespace kernel
{
return form;
}
} static inline default_rename {};
}
static inline default_rename {};

struct syntactic_closure : public identifier
{
Expand All @@ -54,15 +55,15 @@ inline namespace kernel

auto expand(let const& bound_variables, renamer & inject)
{
struct sc_renamer : public renamer
struct local_renamer : public renamer
{
syntactic_closure const* enclosure;

renamer & inject;

let renamings;

explicit sc_renamer(syntactic_closure const* enclosure, renamer & inject)
explicit local_renamer(syntactic_closure const* enclosure, renamer & inject)
: enclosure { enclosure }
, inject { inject }
{}
Expand Down Expand Up @@ -103,7 +104,7 @@ inline namespace kernel
}
};

auto rename = sc_renamer(this, inject);
auto rename = local_renamer(this, inject);

return environment.as<syntactic_environment>().expand(form,
unify(car(environment), bound_variables),
Expand Down Expand Up @@ -283,7 +284,7 @@ inline namespace kernel

if (not variable.is<absolute>()) // The binding-spec is not an internal syntax definition.
{
body = CONS(CONS(rename_("set!"), binding_spec), body);
body = CONS(CONS(corename("set!"), binding_spec), body);
}
}

Expand All @@ -299,7 +300,7 @@ inline namespace kernel
}
}

return expander.expand(LIST(CONS(CONS(rename_("lambda"),
return expander.expand(LIST(CONS(CONS(corename("lambda"),
formals,
body),
make_list(length(binding_specs), unit))),
Expand Down Expand Up @@ -342,23 +343,23 @@ inline namespace kernel

static EXPANDER(include)
{
return expander.expand(CONS(rename_("begin"),
return expander.expand(CONS(corename("begin"),
meevax::include(cadr(expression))),
bound_variables,
rename);
}

static EXPANDER(include_case_insensitive)
{
return expander.expand(CONS(rename_("begin"),
return expander.expand(CONS(corename("begin"),
meevax::include(cadr(expression), false)),
bound_variables,
rename);
}

static EXPANDER(conditional_expand)
{
return expander.expand(CONS(rename_("begin"),
return expander.expand(CONS(corename("begin"),
meevax::conditional_expand(cdr(expression))),
bound_variables,
rename);
Expand Down Expand Up @@ -414,7 +415,7 @@ inline namespace kernel

let const formals = map(formal, cadr(expression));

return expander.expand(LIST(CONS(rename_("lambda"),
return expander.expand(LIST(CONS(corename("lambda"),
formals,
cddr(expression) /* body */)),
bound_variables,
Expand All @@ -436,7 +437,7 @@ inline namespace kernel

car(current_environment) = cons(formals, bound_variables);

return expander.expand(LIST(CONS(rename_("lambda"),
return expander.expand(LIST(CONS(corename("lambda"),
formals,
cddr(expression) /* body */)),
bound_variables,
Expand All @@ -451,7 +452,7 @@ inline namespace kernel
{
return LIST(rename(car(expression)),
caadr(expression) /* variable */,
expander.expand(CONS(rename_("lambda"),
expander.expand(CONS(corename("lambda"),
cdadr(expression) /* formals */,
cddr(expression) /* body */),
bound_variables,
Expand Down Expand Up @@ -794,34 +795,39 @@ inline namespace kernel

static auto core() -> auto const&
{
#define BINDING(NAME, SYNTAX) \
#define BIND(NAME, SYNTAX) \
make<absolute>(make_symbol(NAME), make<syntax>(NAME, expander::SYNTAX, generator::SYNTAX))

let static const core = make<syntactic_environment>(
unit,
list(BINDING("begin" , sequence ),
BINDING("call-with-current-continuation!", call_with_current_continuation),
BINDING("conditional-expand" , conditional_expand ),
BINDING("current" , current ),
BINDING("define" , define ),
BINDING("define-syntax" , define_syntax ),
BINDING("if" , conditional ),
BINDING("include" , include ),
BINDING("include-case-insensitive" , include_case_insensitive ),
BINDING("install" , install ),
BINDING("lambda" , lambda ),
BINDING("let-syntax" , let_syntax ),
BINDING("letrec" , letrec ),
BINDING("letrec-syntax" , letrec_syntax ),
BINDING("quote" , quote ),
BINDING("quote-syntax" , quote_syntax ),
BINDING("set!" , set )));

#undef BINDING
list(BIND("begin" , sequence ),
BIND("call-with-current-continuation!", call_with_current_continuation),
BIND("conditional-expand" , conditional_expand ),
BIND("current" , current ),
BIND("define" , define ),
BIND("define-syntax" , define_syntax ),
BIND("if" , conditional ),
BIND("include" , include ),
BIND("include-case-insensitive" , include_case_insensitive ),
BIND("install" , install ),
BIND("lambda" , lambda ),
BIND("let-syntax" , let_syntax ),
BIND("letrec" , letrec ),
BIND("letrec-syntax" , letrec_syntax ),
BIND("quote" , quote ),
BIND("quote-syntax" , quote_syntax ),
BIND("set!" , set )));

#undef BIND

return core;
}

static auto corename(std::string const& variable)
{
return make<syntactic_closure>(core(), unit, make_symbol(variable));
}

inline auto define(object const& variable, object const& value = undefined) -> void
{
assert(identify(variable, unit).template is<absolute>());
Expand Down Expand Up @@ -1038,11 +1044,6 @@ inline namespace kernel
}
}

static auto rename_(std::string const& variable)
{
return make<syntactic_closure>(core(), unit, make_symbol(variable));
}

inline auto sweep(object const& form,
object const& bound_variables,
object const& binding_specs = unit) const -> pair
Expand Down Expand Up @@ -1076,7 +1077,7 @@ inline namespace kernel
return sweep(cdr(form),
bound_variables,
cons(list(caadr(definition), // <variable>
cons(rename_("lambda"),
cons(corename("lambda"),
cdadr(definition), // <formals>
cddr(definition))), // <body>
binding_specs));
Expand Down

0 comments on commit e7f1f84

Please sign in to comment.