From b7494212646ab49a4e8fd7bade83f26a15cc8ff9 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Sat, 5 Mar 2022 18:00:18 -0600 Subject: Commit inicial --- include/lexer.hpp | 41 +++++++++++++++++++++++++++++++++++++++++ lexer.cpp | 16 ++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 include/lexer.hpp create mode 100644 lexer.cpp diff --git a/include/lexer.hpp b/include/lexer.hpp new file mode 100644 index 0000000..73c5717 --- /dev/null +++ b/include/lexer.hpp @@ -0,0 +1,41 @@ +#include + +#ifndef LEXER_H +#define LEXER_H + +const std::string EMPTY_STRING = ""; + +enum token_type{ + sum, + substraction, + division, + multiplication, + power, + variable, + number, + sin, + cos, + tan, + function, + left_parens, + right_parens +}; + +struct Token{ + token_type type; + std::string value; +}; + +class Lexer{ +private: + std::string text; + size_t txt_ptr; + Token current_token; + void setCurrentToken(Token val); +public: + Lexer(std::string text); + void nextToken(); + Token getCurrentToken(); +}; + +#endif /* LEXER_H */ diff --git a/lexer.cpp b/lexer.cpp new file mode 100644 index 0000000..0054f5a --- /dev/null +++ b/lexer.cpp @@ -0,0 +1,16 @@ +#include +#include "include/lexer.hpp" + +Lexer::Lexer(std::string text){ + this->text = text; +} + +void Lexer::setCurrentToken(Token val){ + current_token = val; +} + +Token Lexer::getCurrentToken(){ + return current_token; +} + +void Lexer::nextToken(){} -- cgit v1.2.3