-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lexer.h
49 lines (39 loc) · 941 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
//===----------------------------------------------------------------------===//
// Lexer
//===----------------------------------------------------------------------===//
#ifndef LEXER_H
#define LEXER_H
#include <string>
// The lexer returns tokens [0-255] if it is an unknown character, otherwise one
// of these for known things.
enum Token {
tok_eof = -1,
// commands
tok_def = -2,
tok_extern = -3,
// primary
tok_identifier = -4,
tok_number = -5,
// control
tok_if = -6,
tok_then = -7,
tok_else = -8,
tok_for = -9,
tok_in = -10,
// operators
tok_binary = -11,
tok_unary = -12,
// var definition
tok_var = -13
};
class Lexer
{
private:
std::string IdentifierStr; // Filled in if tok_identifier
double NumVal; // Filled in if tok_number
public:
std::string getIdentifierStr() { return IdentifierStr; }
double getNumVal() { return NumVal; }
int gettok();
};
#endif