|
|
|
@ -24,7 +24,6 @@
|
|
|
|
|
#include <array>
|
|
|
|
|
#include <bit>
|
|
|
|
|
#include <cstddef>
|
|
|
|
|
#include <charconv>
|
|
|
|
|
#include <string_view>
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
|
@ -64,7 +63,7 @@ inline auto error_string(error err) noexcept -> std::string_view
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef assert
|
|
|
|
|
template<error Err>
|
|
|
|
|
inline void assert(bool condition)
|
|
|
|
|
{
|
|
|
|
@ -139,13 +138,10 @@ struct forth : public word_list
|
|
|
|
|
const auto word = parse();
|
|
|
|
|
|
|
|
|
|
if (auto ent = get(word); !ent) {
|
|
|
|
|
cell n;
|
|
|
|
|
const auto [p, e] = std::from_chars(word.cbegin(), word.cend(),
|
|
|
|
|
n, base);
|
|
|
|
|
|
|
|
|
|
assert<error::word_not_found>(e == std::errc() && p == word.cend());
|
|
|
|
|
const auto n = from_chars<cell>(word, base);
|
|
|
|
|
assert<error::word_not_found>(n.has_value());
|
|
|
|
|
|
|
|
|
|
push(n);
|
|
|
|
|
push(*n);
|
|
|
|
|
|
|
|
|
|
if (compiling)
|
|
|
|
|
execute((*get("literal"))->body());
|
|
|
|
@ -299,9 +295,9 @@ constexpr auto initialize()
|
|
|
|
|
, S{"char+" }, S{"1 +" }, 0
|
|
|
|
|
, S{"-rot" }, S{"rot rot"}, 0
|
|
|
|
|
, S{"2drop" }, S{"drop drop"}, 0
|
|
|
|
|
, S{"0=" }, S{"0 ="}, 0
|
|
|
|
|
, S{"0<" }, S{"0 <"}, 0
|
|
|
|
|
, S{"<>" }, S{"= 0="}, 0
|
|
|
|
|
, S{"0=" }, S{"0 ="}, 0
|
|
|
|
|
, S{">" }, S{"swap <"}, 0
|
|
|
|
|
, S{"invert"}, S{"-1 xor"}, 0
|
|
|
|
|
, S{"negate"}, S{"-1 *"}, 0
|
|
|
|
|