diff options
author | HombreLaser <sebastian-440@live.com> | 2022-03-27 11:57:00 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2022-03-27 11:57:00 -0600 |
commit | e3936c5fc5b846f90d8cdfc589960c6881caa019 (patch) | |
tree | e198e538fb6a1af8925bbf9dc1351dc24e5db589 /include | |
parent | 07885de508b71ef4c4097f14cc5edc9e288b0631 (diff) |
Lexer funcional
Diffstat (limited to 'include')
-rw-r--r-- | include/exceptions.hpp | 11 | ||||
-rw-r--r-- | include/lexer.hpp | 4 |
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 = {}); |