-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLexer.h
52 lines (40 loc) · 834 Bytes
/
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
#ifndef SOLID_LANG_LEXER_H
#define SOLID_LANG_LEXER_H
#include <string>
enum Token {
t_eof = -1,
t_func = -2,
t_native = -3,
t_id = -4,
t_num = -5,
t_when = -6,
t_then = -7,
t_otherwise = -8,
t_while = -9,
t_let = -10,
t_in = -11,
t_step = -12,
t_do = -13,
t_unary = -14,
t_binary = -15,
t_operator = -16,
};
class Lexer {
public:
explicit Lexer(FILE *In) : In(In) {}
int GetCurrentToken() const { return CurrentToken; }
int GetNextToken() {
CurrentToken = GetToken();
return CurrentToken;
}
std::string GetIdVal() { return IdVal; }
double GetNumVal() const { return NumVal; }
private:
FILE *In;
std::string IdVal;
double NumVal;
int LastChar = ' ';
int CurrentToken;
int GetToken();
};
#endif