From 49626f99256466166f045f6a5a5fc6879fdbcd74 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Mon, 21 Sep 2020 10:45:49 +0200 Subject: [PATCH] added recognition of # at start of line as comment desginator --- interpreter.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/interpreter.cpp b/interpreter.cpp index 3a3d2e6..1b1b71f 100644 --- a/interpreter.cpp +++ b/interpreter.cpp @@ -46,7 +46,13 @@ std::string interpreter::eval(std::istream& in, bool& done) { while (_pc < _prog.size() && !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);