From d7c3ab9b4b8d125a8c4b86d999d636294e0b42bb Mon Sep 17 00:00:00 2001 From: fsan Date: Wed, 6 Oct 2021 12:25:11 -0300 Subject: [PATCH] The interpreter holds 1 global scope, if you try to access a non declared value it *should* crash. --- interpreter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interpreter.cpp b/interpreter.cpp index 21ceb17..2f07e55 100644 --- a/interpreter.cpp +++ b/interpreter.cpp @@ -5,7 +5,7 @@ interpreter::evalSTM(struct token stm) { switch (stm.tok_type) { case token::STM_ASSIGN: table[stm.value] = evalEXP(*stm.rvalue); - std::cout << stm.value << " igual a " << table[stm.value] << '\n'; + std::cout << stm.value << " igual a " << table.at(stm.value) << '\n'; break; case token::STM_COMPOUND: evalSTM(*stm.lvalue); @@ -25,7 +25,7 @@ interpreter::evalEXP(struct token exp) { return std::stoi(exp.value); break; case token::EXP_ID: - return table[exp.value]; + return table.at(exp.value); break; case token::EXP_OPERATION: if(exp.value == "+") return evalEXP(*exp.lvalue) + evalEXP(*exp.rvalue);