improved syntax_error to hold line number as well

This commit is contained in:
Bob Polis
2020-09-21 12:25:40 +02:00
parent 27b798a83e
commit 372bc976a0
2 changed files with 7 additions and 3 deletions

View File

@ -52,7 +52,7 @@ std::string interpreter::eval(std::istream& in, bool& done) {
_pc++;
continue;
}
// check literal int
if (std::isdigit(code[0])) {
_stack.push_back(code);
@ -130,7 +130,7 @@ void interpreter::exec_instruction(const std::string& code, bool& done) {
else if (code == "inp") inp();
else if (code == "out") out();
else if (code == "err") err();
else throw syntax_error {code};
else throw syntax_error {code, _pc + 1};
}
// integer operations -----------------------------------------------------