blob: 9c12d0327155e861636f68d66cb43c5698e911b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/* PIA - Lenguajes Modernos de Programación
* FACULTAD DE CIENCIAS FÍSICO MATEMÁTICAS
* Luis Sebastián Martínez Vega - LCC */
#include <string>
#ifndef LEXER_H
#define LEXER_H
enum token_type{
sum,
substraction,
division,
multiplication,
power,
variable,
number,
function,
left_parens,
right_parens,
nil
};
struct Token{
token_type type;
std::string value;
Token(token_type type, const std::string &value) : type(type), value(value){}
};
class Lexer{
private:
std::string text;
size_t current_char;
Token current_token;
std::string createNumber();
bool matchFunction(const std::string &function_name);
public:
Lexer(std::string text = {});
void setText(std::string text);
Token getCurrentToken();
Token match();
Token nextToken();
};
#endif /* LEXER_H */
|