added recognition of # at start of line as comment desginator

This commit is contained in:
Bob Polis 2020-09-21 10:45:49 +02:00
parent 98602abb9e
commit 49626f9925

View File

@ -46,7 +46,13 @@ std::string interpreter::eval(std::istream& in, bool& done) {
while (_pc < _prog.size() && !done) { while (_pc < _prog.size() && !done) {
// fetch next instruction // fetch next instruction
std::string code {_prog[_pc]}; std::string code {_prog[_pc]};
// check comment
if (code[0] == '#') {
_pc++;
continue;
}
// check literal int // check literal int
if (std::isdigit(code[0])) { if (std::isdigit(code[0])) {
_stack.push_back(code); _stack.push_back(code);