-
Notifications
You must be signed in to change notification settings - Fork 0
/
lexer.h
81 lines (64 loc) · 1.67 KB
/
lexer.h
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef KOMPILAR_LEXER_H
#define KOMPILAR_LEXER_H
#include <iostream>
#include "machine.h"
#include "trantable.h"
#define EOF_MARK "eof"
#define ERROR_CLASS "error"
class lexer {
public:
class token {
private:
std::string t_str;
std::string t_class;
int line;
int col;
public:
token () {};
token(std::string _str, std::string _class) {
t_str = _str;
t_class = _class;
}
token(std::string _str, std::string _class, int _line, int _col) {
t_str = _str;
t_class = _class;
line = _line;
col = _col;
}
int get_line() {
return line;
}
int get_col() {
return col;
}
std::string get_str() {
return t_str;
}
std::string get_class() {
return t_class;
}
void set_str(std::string str) {
t_str = str;
}
void set_class(std::string _class) {
t_class = _class;
}
void set_line(int _line) {
line = _line;
}
void set_str(int _col) {
col = _col;
}
friend std::ostream &operator <<(std::ostream &os, token &tok);
};
private:
// std::ifstream rules_ifs;
transition_table ttab;
int line;
int col;
public:
lexer(machine &mac);
// void lex_analyze();
token next_token(std::istream &ifs);
};
#endif //KOMPILAR_PARSER_H