summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/exceptions.hpp11
-rw-r--r--include/lexer.hpp4
2 files changed, 10 insertions, 5 deletions
diff --git a/include/exceptions.hpp b/include/exceptions.hpp
index 0469784..4b5fcfa 100644
--- a/include/exceptions.hpp
+++ b/include/exceptions.hpp
@@ -1,4 +1,9 @@
+/* PIA - Lenguajes Modernos de Programación
+ * FACULTAD DE CIENCIAS FÍSICO MATEMÁTICAS
+ * Luis Sebastián Martínez Vega - LCC */
+
#include <string>
+
#ifndef EXCEPTIONS_H
#define EXCEPTIONS_H
@@ -6,18 +11,18 @@ class Exception{
private:
std::string error_msg;
public:
- Exception(const std::string &error_msg);
+ explicit Exception(const std::string &error_msg): error_msg(error_msg){}
std::string showMsg();
};
class LexerException: public Exception{
public:
- LexerException(const std::string &error_msg): Exception(error_msg){}
+ explicit LexerException(const std::string &error_msg): Exception(error_msg){}
};
class ParserException: public Exception{
public:
- ParserException(const std::string &error_msg): Exception(error_msg){}
+ explicit ParserException(const std::string &error_msg): Exception(error_msg){}
};
#endif /* EXCEPTIONS_H */
diff --git a/include/lexer.hpp b/include/lexer.hpp
index e674999..27779ea 100644
--- a/include/lexer.hpp
+++ b/include/lexer.hpp
@@ -33,7 +33,7 @@ enum token_type{
struct Token{
token_type type;
std::string value;
- Token(token_type type, std::string value) : type(type), value(value){}
+ Token(token_type type, const std::string &value) : type(type), value(value){}
};
class Lexer{
@@ -42,7 +42,7 @@ private:
std::string text;
size_t current_char;
Token current_token;
- bool matchFunction(std::string function_name);
+ bool matchFunction(const std::string &function_name);
std::string createNumber();
public:
Lexer(std::string text = {});