From cb04555442286affb56a95a54c428f8f643b3503 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sat, 30 Nov 2024 10:02:26 -0500 Subject: create namespace; refactor header --- main.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index c3267ba..99f5ecc 100644 --- a/main.cpp +++ b/main.cpp @@ -14,7 +14,7 @@ /// You should have received a copy of the GNU General Public License along /// with this program. If not, see . -#include "forth.hpp" +#include "sforth/forth.hpp" #include #include @@ -22,23 +22,23 @@ #include #include -static std::array dict; -static auto fth = new (dict.data()) forth; +static std::array dict; +static auto fth = new (dict.data()) sforth::forth; -static bool parse_stream(forth *, std::istream&, bool say_okay = false); +static bool parse_stream(sforth::forth *, std::istream&, bool say_okay = false); int main(int argc, const char *argv[]) { std::span args (argv + 1, argc - 1); - forth::initialize<&fth>(dict.end()); + sforth::initialize<&fth>(dict.end()); fth->add(".", [](auto) { char buf[32] = {}; std::to_chars(buf, buf + sizeof(buf), fth->pop(), fth->base); std::cout << buf << ' '; }); fth->add("emit", [](auto) { std::cout << static_cast(fth->pop()); }); - fth->add("dictsize", [](auto) { fth->push(dict.size() * sizeof(cell)); }); + fth->add("dictsize", [](auto) { fth->push(dict.size() * sizeof(sforth::cell)); }); for (auto arg : args) { if (std::ifstream file {arg}; parse_stream(fth, file)) @@ -48,7 +48,7 @@ int main(int argc, const char *argv[]) parse_stream(fth, std::cin, true); } -bool parse_stream(forth *fth, std::istream& str, bool say_okay) +bool parse_stream(sforth::forth *fth, std::istream& str, bool say_okay) { std::string line; @@ -60,8 +60,8 @@ bool parse_stream(forth *fth, std::istream& str, bool say_okay) try { fth->parse_line(line); - } catch (forth::error e) { - std::cerr << fth->error_string(e) << " in " << line << std::endl; + } catch (sforth::error e) { + std::cerr << sforth::error_string(e) << " in " << line << std::endl; continue; } } -- cgit v1.2.3