Compare commits

..

No commits in common. 'a92731ee996c4dab54f51d656d5a6edece0738b3' and 'd8b279b7709410112002828199b0261508a9dda4' have entirely different histories.

@ -37,11 +37,6 @@ constinit static sforth::native_word<".", [](auto) {
constinit static sforth::native_word<"emit", [](auto) {
std::cout << static_cast<char>(forth.pop());
}, &dot> emit;
constinit static sforth::native_word<"type", [](auto) {
const unsigned u = forth.pop();
const auto caddr = reinterpret_cast<const char *>(forth.pop());
std::cout << std::string_view{caddr, u};
}, &emit> type;
static bool parse_stream(auto&, std::istream&, bool say_okay = false);
@ -49,7 +44,7 @@ int main(int argc, const char *argv[])
{
std::span args (argv + 1, argc - 1);
dot.next = std::exchange(forth.next, &type);
dot.next = std::exchange(forth.next, &emit);
for (auto arg : args) {
if (std::ifstream file {arg}; parse_stream(forth, file))
@ -69,11 +64,6 @@ bool parse_stream(auto &fth, std::istream& str, bool say_okay)
if (line == "bye")
return true;
for (auto& ch : line) {
if (ch >= 'A' && ch <= 'Z')
ch = ch - 'A' + 'a';
}
try {
fth.parse_line(line);
} catch (sforth::error e) {

@ -208,7 +208,6 @@ constexpr auto initialize()
, S{"dp" }, [](auto) { fthp->push(std::bit_cast<cell>(fthp) + 4 * sizeof(cell)); }, 0
, S{"state"}, [](auto) { fthp->push(std::bit_cast<cell>(fthp) + 7 * sizeof(cell)); }, 0
, S{"base" }, [](auto) { fthp->push(std::bit_cast<cell>(fthp) + 8 * sizeof(cell)); }, 0
, S{"depth"}, [](auto) { fthp->push(std::distance(fthp->sp, fthp->dstack.end())); }, 0
, S{"unused"}, [](auto) { fthp->push(sizeof(cell) * std::distance(fthp->here, fthp->dict.end())); }, 0
, S{"_lit" }, lit_impl, 0
, S{"swap" }, [](auto) { auto a = fthp->pop(); auto b = fthp->pop(); fthp->push(a, b); }, 0
@ -265,13 +264,6 @@ constexpr auto initialize()
auto g = fthp->get(w);
assert<error::word_not_found>(g.has_value());
*fthp->here++ = std::bit_cast<cell>((*g)->body()); }, word_base::immediate
, S{"source"}, [](auto) {
auto len = 0u;
while (fthp->source[len])
len++;
fthp->push(std::bit_cast<cell>(fthp->source));
fthp->push(len); }, 0
, S{">in"}, [](auto) { fthp->push(std::bit_cast<cell>(&fthp->sourcei)); }, 0
>::word;
constexpr static auto& dict2 = comp_dict<prologue, &dict1
, S{"align" }, S{"here dup aligned swap - allot"}, 0
@ -311,8 +303,6 @@ constexpr auto initialize()
, S{"negate"}, S{"-1 *"}, 0
, S{"2*" }, S{"2 *"}, 0
, S{"bl" }, S{"32"}, 0
, S{"false" }, S{"0"}, 0
, S{"true" }, S{"-1"}, 0
>::word;
return &dict2;

Loading…
Cancel
Save