diff --git a/src/common.hpp b/src/common.hpp index ee56cb5..530dcd7 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -3,7 +3,7 @@ #include -enum TokenType +enum class TokenType { KEYWORD, IDENTIFIER, @@ -11,7 +11,7 @@ enum TokenType ID_OR_LIT }; -enum ValueType +enum class ValueType { STRING, NUMBER, @@ -24,8 +24,8 @@ struct Instruction; struct Keyword; struct Runtime; -const std::string resolve_TokenType_str(enum TokenType); -const std::string resolve_ValueType_str(enum ValueType); +std::string resolve_TokenType_str(enum class TokenType); +std::string resolve_ValueType_str(enum class ValueType); #endif //BISCUIT_INTERPRETER_COMMON_HPP diff --git a/src/exceptions.hpp b/src/exceptions.hpp index 48d806c..a6a4ea5 100644 --- a/src/exceptions.hpp +++ b/src/exceptions.hpp @@ -29,9 +29,9 @@ struct WrongArgumentCountExcept : public std::exception struct WrongTokenExcept : public std::exception { - enum TokenType expected, got; + enum class TokenType expected, got; std::string keyword_name, token_str; - inline WrongTokenExcept(const std::string& _keyword_name, const std::string& _token_str, const enum TokenType& _expected, const enum TokenType& _got) + inline WrongTokenExcept(const std::string& _keyword_name, const std::string& _token_str, enum class TokenType _expected, enum class TokenType _got) : expected(_expected), got(_got), keyword_name(_keyword_name), token_str(_token_str) {} }; @@ -39,9 +39,9 @@ struct WrongTokenExcept : public std::exception // Runtime errors struct TypeErrorExcept : public std::exception { - enum ValueType expected, got; + enum class ValueType expected, got; std::string token_str; - inline TypeErrorExcept(const std::string& _token_str, const enum ValueType& _expected, const enum ValueType& _got) + inline TypeErrorExcept(const std::string& _token_str, enum class ValueType _expected, enum class ValueType _got) : expected(_expected), got(_got), token_str(_token_str) {} }; diff --git a/src/parse.cpp b/src/parse.cpp index 7bfdf1f..d9e5010 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -279,7 +279,7 @@ Instruction::Instruction(std::vector& _token_list) // Make sure the keyword gets the number of arguments it needs if(keyword_ptr->expected_num_args != -1 && (keyword_ptr->expected_num_args != tokens.size() - 1)) - throw WrongArgumentCountExcept(keyword_ptr->name, keyword_ptr->expected_num_args, tokens.size() - 1); + throw WrongArgumentCountExcept(keyword_ptr->name, keyword_ptr->expected_num_args, static_cast(tokens.size() - 1)); // Check the arguments supplied are the right kind of tokens for(int i = 0; i < keyword_ptr->expected_num_args; i++) diff --git a/src/util.cpp b/src/util.cpp index 24d4106..69c13f6 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,7 +1,7 @@ #include "common.hpp" #include -const std::string resolve_TokenType_str(enum TokenType ttype) +std::string resolve_TokenType_str(TokenType ttype) { switch(ttype) { @@ -22,7 +22,7 @@ const std::string resolve_TokenType_str(enum TokenType ttype) return "UNKNOW TOKENTYPE"; } -const std::string resolve_ValueType_str(enum ValueType vtype) +std::string resolve_ValueType_str(ValueType vtype) { switch(vtype) {