-
Notifications
You must be signed in to change notification settings - Fork 0
/
token.h
55 lines (49 loc) · 861 Bytes
/
token.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
#pragma once
#include "common.h"
class Token //基类
{
public:
Tag tag;
Token(Tag t);
virtual string toString();
virtual ~Token();
};
class Num: public Token //数字常量
{
public:
int num;
Num(int x);
virtual string toString();
virtual ~Num();
};
class Char: public Token //字符常量
{
public:
char ch;
Char(char x);
virtual string toString();
virtual ~Char();
};
class Str: public Token //字符串常量
{
public:
string str;
Str(string x);
virtual string toString();
virtual ~Str();
};
class Id: public Token //标识符
{
public:
string id;
Id(string x);
virtual string toString();
virtual ~Id();
};
class Keywords //关键字
{
public:
map<string, int> key;
Keywords();
Tag getTag(string name);
};