|
|
@ -25,6 +25,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
constinit static sforth::forth<4096> forth {sforth::initialize<&forth>()};
|
|
|
|
constinit static sforth::forth<4096> forth {sforth::initialize<&forth>()};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool parse_stream(auto&, std::istream&, bool say_okay = false);
|
|
|
|
|
|
|
|
|
|
|
|
constinit static sforth::native_word<".", [](auto) {
|
|
|
|
constinit static sforth::native_word<".", [](auto) {
|
|
|
|
char buf[8 * sizeof(sforth::cell) + 1] = {};
|
|
|
|
char buf[8 * sizeof(sforth::cell) + 1] = {};
|
|
|
|
std::to_chars(buf, buf + sizeof(buf), forth.pop(), forth.base);
|
|
|
|
std::to_chars(buf, buf + sizeof(buf), forth.pop(), forth.base);
|
|
|
@ -43,14 +45,18 @@ constinit static sforth::native_word<"TYPE", [](auto) {
|
|
|
|
const auto caddr = reinterpret_cast<const char *>(forth.pop());
|
|
|
|
const auto caddr = reinterpret_cast<const char *>(forth.pop());
|
|
|
|
std::cout << std::string_view{caddr, u};
|
|
|
|
std::cout << std::string_view{caddr, u};
|
|
|
|
}, &emit> type;
|
|
|
|
}, &emit> type;
|
|
|
|
|
|
|
|
constinit static sforth::native_word<"INCLUDE", [](auto) {
|
|
|
|
static bool parse_stream(auto&, std::istream&, bool say_okay = false);
|
|
|
|
const auto w = forth.parse();
|
|
|
|
|
|
|
|
std::string s {w.begin(), w.end()};
|
|
|
|
|
|
|
|
std::ifstream file {s};
|
|
|
|
|
|
|
|
parse_stream(forth, file);
|
|
|
|
|
|
|
|
}, &type> incl;
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, const char *argv[])
|
|
|
|
int main(int argc, const char *argv[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::span args (argv + 1, argc - 1);
|
|
|
|
std::span args (argv + 1, argc - 1);
|
|
|
|
|
|
|
|
|
|
|
|
dot.next = std::exchange(forth.next, &type);
|
|
|
|
dot.next = std::exchange(forth.next, &incl);
|
|
|
|
|
|
|
|
|
|
|
|
for (auto arg : args) {
|
|
|
|
for (auto arg : args) {
|
|
|
|
if (std::ifstream file {arg}; parse_stream(forth, file))
|
|
|
|
if (std::ifstream file {arg}; parse_stream(forth, file))
|
|
|
|