line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
namespace Enum { |
2
|
|
|
|
|
|
|
namespace Parser { |
3
|
|
|
|
|
|
|
namespace Syntax { |
4
|
|
|
|
|
|
|
typedef enum { |
5
|
|
|
|
|
|
|
Value, |
6
|
|
|
|
|
|
|
Term, |
7
|
|
|
|
|
|
|
Expr, |
8
|
|
|
|
|
|
|
Stmt, |
9
|
|
|
|
|
|
|
BlockStmt |
10
|
|
|
|
|
|
|
} Type; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
class FileInfo { |
16
|
|
|
|
|
|
|
public: |
17
|
|
|
|
|
|
|
size_t start_line_num; |
18
|
|
|
|
|
|
|
size_t end_line_num; |
19
|
|
|
|
|
|
|
size_t indent; |
20
|
|
|
|
|
|
|
size_t block_id; |
21
|
|
|
|
|
|
|
const char *filename; |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
class TokenInfo { |
25
|
|
|
|
|
|
|
public: |
26
|
|
|
|
|
|
|
Enum::Token::Type::Type type; |
27
|
|
|
|
|
|
|
Enum::Token::Kind::Kind kind; |
28
|
|
|
|
|
|
|
const char *name; |
29
|
|
|
|
|
|
|
const char *data; |
30
|
|
|
|
|
|
|
bool has_warnings; |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
class Token { |
34
|
|
|
|
|
|
|
public: |
35
|
|
|
|
|
|
|
Enum::Parser::Syntax::Type stype; |
36
|
|
|
|
|
|
|
Enum::Token::Type::Type type; |
37
|
|
|
|
|
|
|
TokenInfo info; |
38
|
|
|
|
|
|
|
FileInfo finfo; |
39
|
|
|
|
|
|
|
Token **tks; |
40
|
|
|
|
|
|
|
const char *_data; |
41
|
|
|
|
|
|
|
size_t token_num; |
42
|
|
|
|
|
|
|
size_t total_token_num; |
43
|
|
|
|
|
|
|
const char *deparsed_data; |
44
|
|
|
|
|
|
|
bool isDeparsed; |
45
|
|
|
|
|
|
|
bool isDeleted; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Token(std::string data_, FileInfo finfo); |
48
|
|
|
|
|
|
|
Token(Tokens *tokens); |
49
|
|
|
|
|
|
|
const char *deparse(void); |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
class Tokens : public std::vector<Token *> { |
53
|
|
|
|
|
|
|
public: |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
Tokens(void) {} |
56
|
|
|
|
|
|
|
inline void add(Token *token) { |
57
|
|
|
|
|
|
|
if (token) push_back(token); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
inline void remove(size_t) { |
61
|
|
|
|
|
|
|
//erase(idx); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
inline Token *lastToken(void) { |
65
|
|
|
|
|
|
|
return (size() > 0) ? back() : NULL; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
extern TokenInfo decl_tokens[]; |
70
|
|
|
|
|
|
|
extern TokenInfo type_to_info[]; |