diff --git a/interpreter.cpp b/interpreter.cpp index 4f3615c..1a340db 100644 --- a/interpreter.cpp +++ b/interpreter.cpp @@ -36,6 +36,8 @@ std::string interpreter::eval(std::istream& in, bool& done) { for (std::string line; std::getline(in, line); ++_pc) { if (line[0] == ':') { _labels.emplace(line.substr(1), _pc--); + } else if (line[0] == '#') { // check comment + _pc--; } else { _prog.push_back(line); } @@ -47,12 +49,6 @@ std::string interpreter::eval(std::istream& in, bool& done) { // fetch next instruction std::string code {_prog[_pc]}; - // check comment - if (code[0] == '#') { - _pc++; - continue; - } - // check literal int if (std::isdigit(code[0])) { _stack.push_back(code);