From 24a61f3c99125c97ca79ea173c959d7bd89f1a48 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Fri, 17 Feb 2023 08:15:30 -0500 Subject: some cleanup --- parser.cpp | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) (limited to 'parser.cpp') diff --git a/parser.cpp b/parser.cpp index 2d6e9ff..b4c2d1c 100644 --- a/parser.cpp +++ b/parser.cpp @@ -17,7 +17,6 @@ */ #include "corewords.hpp" -#include "executor.hpp" #include "parser.hpp" #include @@ -40,7 +39,7 @@ ParseStatus Parser::parseSource(State& state) { auto word = state.dict.input(); while (word.size() > 0) { - if (auto ret = parseWord(state, word); ret == ParseStatus::Error) + if (auto ret = parseWord(state, word); ret != ParseStatus::Finished) return ret; word = state.dict.input(); @@ -52,11 +51,10 @@ ParseStatus Parser::parseSource(State& state) ParseStatus Parser::parseWord(State& state, Word word) { if (auto i = CoreWords::findi(state, word); i >= 0) { - if (state.compiling()) { + if (state.compiling()) state.dict.add(i & ~CoreWords::CoreImmediate); - } else if (state.dict.equal(word, ":")) { + else if (state.dict.equal(word, ":")) state.compiling(true); - } if (!state.compiling() || (i & CoreWords::CoreImmediate)) CoreWords::run(i & ~CoreWords::CoreImmediate, state); @@ -66,14 +64,14 @@ ParseStatus Parser::parseWord(State& state, Word word) if (state.compiling()) { if (state.dict.read(j) & CoreWords::Immediate) { state.compiling(false); - Executor::fullexec(state, e); + state.execute(e); state.compiling(true); } else { state.dict.add(CoreWords::HiddenWordJump); state.dict.add(e); } } else { - Executor::fullexec(state, e); + state.execute(e); } } else { char buf[word.size()]; @@ -82,7 +80,7 @@ ParseStatus Parser::parseWord(State& state, Word word) char *p; const auto base = state.dict.read(0); - const auto l = static_cast(std::strtol(buf, &p, base)); + const Cell l = std::strtol(buf, &p, base); if (p != buf) { if (state.compiling()) { @@ -92,27 +90,10 @@ ParseStatus Parser::parseWord(State& state, Word word) state.push(l); } } else { - return ParseStatus::Error; + return ParseStatus::NotAWord; } } return ParseStatus::Finished; } - //case Pass::Colon: - // state.pass = Pass::None; - // state.compiling(true); - // state.dict.addDefinition(sub); - // break; - //case Pass::Constant: - // state.pass = Pass::None; - // state.compiling(true); - // state.dict.addDefinition(sub); - // state.dict.add(CoreWords::HiddenWordLiteral); - // state.dict.add(state.pop()); - // state.dict.add(CoreWords::findi(";")); - // CoreWords::run(CoreWords::findi(";"), state); - // break; - //default: - // break; - //} -- cgit v1.2.3