Skip to content

Commit

Permalink
Merge pull request #394 from yamacir-kit/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
yamacir-kit authored Jun 5, 2022
2 parents d0f170f + b25aab2 commit 215c45e
Show file tree
Hide file tree
Showing 65 changed files with 1,486 additions and 996 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|:-------------------|:--
| `all` (default) | Build shared-library `libmeevax.0.4.0.so` and executable `meevax`.
| `all` (default) | Build shared-library `libmeevax.0.4.40.so` and executable `meevax`.
| `test` | Test executable `meevax`.
| `package` | Generate debian package `meevax_0.4.0_amd64.deb`.
| `package` | Generate debian package `meevax_0.4.40_amd64.deb`.
| `install` | Copy files into `/usr/local` __(1)__.
| `install.deb` | `all` + `package` + `sudo apt install <meevax>.deb`
| `safe-install.deb` | `all` + `test` + `package` + `sudo apt install <meevax>.deb`
Expand All @@ -120,7 +120,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's
## Usage

```
Meevax Lisp System, version 0.4.0
Meevax Lisp System, version 0.4.40
Usage: meevax [OPTION...] [FILE...]
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.0
0.4.40
4 changes: 2 additions & 2 deletions basis/srfi-34.ss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
; IN THE SOFTWARE.

(define-library (srfi 34)
(import (only (meevax exception) default-exception-handler)
(import (only (meevax exception) throw)
(scheme r5rs)
)

Expand All @@ -29,7 +29,7 @@
guard
)

(begin (define %current-exception-handlers (list default-exception-handler))
(begin (define %current-exception-handlers (list throw))

(define (%with-exception-handlers new-handlers thunk)
(let ((old-handlers %current-exception-handlers))
Expand Down
3 changes: 3 additions & 0 deletions benchmark/ack.ss
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
(import (scheme r5rs)
(scheme process-context))

(define (ack m n)
(cond ((= m 0) (+ n 1))
((= n 0) (ack (- m 1) 1))
Expand Down
3 changes: 3 additions & 0 deletions benchmark/tarai.ss
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
(import (scheme r5rs)
(scheme process-context))

(define (tarai x y z)
(if (not (< y x)) y
(tarai (tarai (- x 1) y z)
Expand Down
14 changes: 7 additions & 7 deletions include/meevax/kernel/complex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ inline namespace kernel
auto imag() noexcept -> reference;

#define DEFINE(NAME) \
auto NAME() const -> object override \
auto NAME() const -> lvalue override \
{ \
return unspecified_object; \
} \
Expand All @@ -55,7 +55,7 @@ inline namespace kernel
#undef DEFINE

#define DEFINE(NAME) \
auto NAME(const_reference) const -> object override \
auto NAME(const_reference) const -> lvalue override \
{ \
return unspecified_object; \
} \
Expand All @@ -66,11 +66,11 @@ inline namespace kernel

#undef DEFINE

auto operator + (const_reference) const -> object override { return unspecified_object; }
auto operator - (const_reference) const -> object override { return unspecified_object; }
auto operator * (const_reference) const -> object override { return unspecified_object; }
auto operator / (const_reference) const -> object override { return unspecified_object; }
auto operator % (const_reference) const -> object override { return unspecified_object; }
auto operator + (const_reference) const -> lvalue override { return unspecified_object; }
auto operator - (const_reference) const -> lvalue override { return unspecified_object; }
auto operator * (const_reference) const -> lvalue override { return unspecified_object; }
auto operator / (const_reference) const -> lvalue override { return unspecified_object; }
auto operator % (const_reference) const -> lvalue override { return unspecified_object; }

auto operator ==(const_reference) const -> bool override { return false; };
auto operator !=(const_reference) const -> bool override { return false; };
Expand Down
71 changes: 26 additions & 45 deletions include/meevax/kernel/configurator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,39 +45,38 @@ inline namespace kernel

const dispatcher<std::string> long_options, long_options_with_arguments;

protected:
let batch = f;
let debug = f;
let interactive = f;
let trace = f;
let verbose = f;

public:
bool batch = false;
bool debug = false;
bool interactive = false;
bool trace = false;
bool verbose = false;

explicit configurator()
: short_options
{
std::make_pair('b', [this](auto&&...)
{
return batch = t;
return make<bool>(batch = true);
}),

std::make_pair('d', [this](auto&&...)
{
return debug = t;
return make<bool>(debug = true);
}),

std::make_pair('h', [this](auto&&...) -> object
std::make_pair('h', [this](auto&&...) -> lvalue
{
display_help();
throw exit_status::success;
}),

std::make_pair('i', [this](auto&&...)
{
return interactive = t;
return make<bool>(interactive = true);
}),

std::make_pair('v', [this](auto&&...) -> object
std::make_pair('v', [this](auto&&...) -> lvalue
{
display_version();
throw exit_status::success;
Expand All @@ -93,7 +92,7 @@ inline namespace kernel

std::make_pair('l', [this](const_reference x, auto&&...)
{
return load(x.as<string>());
return load(x.as_const<string>());
}),

std::make_pair('w', [this](const_reference x, auto&&...)
Expand All @@ -106,36 +105,36 @@ inline namespace kernel
{
std::make_pair("batch", [this](auto&&...)
{
return batch = t;
return make<bool>(batch = true);
}),

std::make_pair("debug", [this](auto&&...)
{
return debug = t;
return make<bool>(debug = true);
}),

std::make_pair("help", [this](auto&&...) -> object
std::make_pair("help", [this](auto&&...) -> lvalue
{
display_help();
throw exit_status::success;
}),

std::make_pair("interactive", [this](auto&&...)
{
return interactive = t;
return make<bool>(interactive = true);
}),

std::make_pair("trace", [this](auto&&...)
{
return trace = t;
return make<bool>(trace = true);
}),

std::make_pair("verbose", [this](auto&&...)
{
return verbose = t;
return make<bool>(verbose = true);
}),

std::make_pair("version", [this](auto&&...) -> object
std::make_pair("version", [this](auto&&...) -> lvalue
{
display_version();
throw exit_status::success;
Expand All @@ -151,7 +150,7 @@ inline namespace kernel

std::make_pair("load", [this](const_reference x, auto&&...)
{
return load(x.as<string>());
return load(x.as_const<string>());
}),

std::make_pair("write", [this](const_reference x, auto&&...)
Expand All @@ -172,22 +171,19 @@ inline namespace kernel

if (std::empty(args))
{
interactive = t;
interactive = true;
}
else for (auto current_option = std::begin(args); current_option != std::end(args); ++current_option) [&]()
{
std::smatch analysis {};

std::regex_match(*current_option, analysis, pattern);

if (is_debug_mode())
{
std::cout << header("configure") << "analysis[0] = " << analysis[0] << std::endl;
std::cout << header("") << "analysis[1] = " << analysis[1] << std::endl;
std::cout << header("") << "analysis[2] = " << analysis[2] << std::endl;
std::cout << header("") << "analysis[3] = " << analysis[3] << std::endl;
std::cout << header("") << "analysis[4] = " << analysis[4] << std::endl;
}
// std::cout << header("configure") << "analysis[0] = " << analysis[0] << std::endl;
// std::cout << header("") << "analysis[1] = " << analysis[1] << std::endl;
// std::cout << header("") << "analysis[2] = " << analysis[2] << std::endl;
// std::cout << header("") << "analysis[3] = " << analysis[3] << std::endl;
// std::cout << header("") << "analysis[4] = " << analysis[4] << std::endl;

if (auto const current_short_options = analysis.str(4); not current_short_options.empty())
{
Expand Down Expand Up @@ -276,21 +272,6 @@ inline namespace kernel
print(" --verbose Display detailed informations.");
print(" -w, --write=OBJECT Same as -e '(write OBJECT)'");
}

#define BOILERPLATE(NAME) \
auto is_##NAME##_mode() const -> bool \
{ \
return select(NAME); \
} \
static_assert(true)

BOILERPLATE(batch);
BOILERPLATE(debug);
BOILERPLATE(interactive);
BOILERPLATE(trace);
BOILERPLATE(verbose);

#undef BOILERPLATE
};
} // namespace kernel
} // namespace meevax
Expand Down
2 changes: 1 addition & 1 deletion include/meevax/kernel/constant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace meevax
{
inline namespace kernel
{
extern std::unordered_map<std::string, object> const constants;
extern std::unordered_map<std::string, lvalue> const constants;
} // namespace kernel
} // namespace meevax

Expand Down
32 changes: 16 additions & 16 deletions include/meevax/kernel/environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ inline namespace kernel
using pair::pair;

public:
using configurator::is_debug_mode;
using configurator::is_trace_mode;
using configurator::is_verbose_mode;
using configurator::debug;
using configurator::trace;
using configurator::verbose;

using reader::intern;
using reader::read;
Expand All @@ -55,18 +55,18 @@ inline namespace kernel
{
(import(xs), ...);

define<procedure>("set-batch!", [this](let const& xs, auto&&...) { return batch = car(xs); });
define<procedure>("set-debug!", [this](let const& xs, auto&&...) { return debug = car(xs); });
define<procedure>("set-interactive!", [this](let const& xs, auto&&...) { return interactive = car(xs); });
define<procedure>("set-trace!", [this](let const& xs, auto&&...) { return trace = car(xs); });
define<procedure>("set-verbose!", [this](let const& xs, auto&&...) { return verbose = car(xs); });
define<procedure>("set-batch!", [this](let const& xs, auto&&...) { return batch = select(car(xs)); });
define<procedure>("set-debug!", [this](let const& xs, auto&&...) { return debug = select(car(xs)); });
define<procedure>("set-interactive!", [this](let const& xs, auto&&...) { return interactive = select(car(xs)); });
define<procedure>("set-trace!", [this](let const& xs, auto&&...) { return trace = select(car(xs)); });
define<procedure>("set-verbose!", [this](let const& xs, auto&&...) { return verbose = select(car(xs)); });
}

auto operator [](const_reference) -> const_reference;

auto operator [](std::string const&) -> const_reference;

auto apply(const_reference, const_reference) -> object;
auto apply(const_reference, const_reference) -> lvalue;

auto declare_import(const_reference) -> void;

Expand All @@ -86,13 +86,13 @@ inline namespace kernel
define(name, make<T>(name, std::forward<decltype(xs)>(xs)...));
}

auto evaluate(const_reference) -> object;
auto evaluate(const_reference) -> lvalue;

auto execute() -> object;
auto execute() -> lvalue;

auto execute(const_reference) -> object;
auto execute(const_reference) -> lvalue;

auto fork() const -> object
auto fork() const -> lvalue
{
return make<environment>(*this);
}
Expand All @@ -108,15 +108,15 @@ inline namespace kernel

auto global() const noexcept -> const_reference;

auto load(std::string const&) -> object;
auto load(std::string const&) -> lvalue;

auto scope() const noexcept -> const_reference;

auto scope() noexcept -> reference;

auto identify(const_reference, const_reference) -> object;
auto identify(const_reference, const_reference) -> lvalue;

auto identify(const_reference, const_reference) const -> object;
auto identify(const_reference, const_reference) const -> lvalue;
};

auto operator >>(std::istream &, environment &) -> std::istream &;
Expand Down
2 changes: 1 addition & 1 deletion include/meevax/kernel/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ inline namespace kernel
return underlying_cast(value);
}

catch (const_reference error) // NOTE: default-exception-handler (Terminate the program without running any outstanding dynamic-wind after procedures)
catch (const_reference error) // NOTE: procedure `throw` (Terminate the program without running any outstanding dynamic-wind after procedures)
{
std::cerr << "; " << error << std::endl;
return underlying_cast(exit_status::failure);
Expand Down
14 changes: 7 additions & 7 deletions include/meevax/kernel/exact_integer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ inline namespace kernel

auto truncate_quotient(exact_integer const&) const -> exact_integer;

#define DEFINE(NAME) auto NAME() const -> object override
#define DEFINE(NAME) auto NAME() const -> lvalue override

DEFINE(exact); DEFINE(inexact);

Expand All @@ -97,7 +97,7 @@ inline namespace kernel

#undef DEFINE

#define DEFINE(NAME) auto NAME(const_reference) const -> object override
#define DEFINE(NAME) auto NAME(const_reference) const -> lvalue override

DEFINE(atan2);
DEFINE(pow);
Expand All @@ -118,11 +118,11 @@ inline namespace kernel

explicit operator std::string() const;

auto operator + (const_reference) const -> object override;
auto operator - (const_reference) const -> object override;
auto operator * (const_reference) const -> object override;
auto operator / (const_reference) const -> object override;
auto operator % (const_reference) const -> object override;
auto operator + (const_reference) const -> lvalue override;
auto operator - (const_reference) const -> lvalue override;
auto operator * (const_reference) const -> lvalue override;
auto operator / (const_reference) const -> lvalue override;
auto operator % (const_reference) const -> lvalue override;

auto operator ==(const_reference) const -> bool override;
auto operator !=(const_reference) const -> bool override;
Expand Down
Loading

0 comments on commit 215c45e

Please sign in to comment.