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
46
47
48
49
50
51
52
53
54
55
|
/* 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 function_name{
sin,
cos,
tan,
csc,
sec,
ctg
};
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, std::string value) : type(type), value(value){}
};
class Lexer{
private:
char var_name;
std::string text;
size_t current_char;
Token current_token;
bool matchFunction(std::string function_name);
std::string createNumber();
public:
Lexer(std::string text = {});
void setText(std::string text);
Token getCurrentToken();
Token match();
Token nextToken();
};
#endif /* LEXER_H */
|