forked from openenclave/oeedger8r-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast.h
115 lines (101 loc) · 1.48 KB
/
ast.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright (c) Open Enclave SDK contributors.
// Licensed under the MIT License.
#ifndef AST_H
#define AST_H
#include <string>
#include <vector>
#include "lexer.h"
enum AType
{
Bool,
Char,
Short,
Int,
Long,
LLong,
Float,
Double,
LDouble,
Int8,
Int16,
Int32,
Int64,
UInt8,
UInt16,
UInt32,
UInt64,
Void,
WChar,
SizeT,
Struct,
Union,
Enum,
Foreign,
Ptr,
Const,
Unsigned
};
struct Type
{
AType tag_;
Type* t_;
std::string name_;
};
struct Attrs
{
bool in_;
bool out_;
bool inout_;
bool isptr_;
bool isary_;
bool string_;
bool wstring_;
bool user_check_;
bool is_size_or_count_;
Token size_;
Token count_;
};
typedef std::vector<std::string> Dims;
struct Decl
{
std::string name_;
Type* type_;
Dims* dims_;
Attrs* attrs_;
};
struct EnumVal
{
std::string name_;
Token* value_;
};
struct UserType
{
std::string name_;
AType tag_;
std::vector<Decl*> fields_;
std::vector<EnumVal> items_;
};
struct Function
{
std::string name_;
Type* rtype_;
std::vector<Decl*> params_;
bool switchless_;
bool errno_;
};
struct Edl
{
std::string name_;
std::vector<std::string> includes_;
std::vector<UserType*> types_;
std::vector<Function*> trusted_funcs_;
std::vector<Function*> untrusted_funcs_;
};
enum Directive
{
Ifdef,
Ifndef,
Else,
Endif,
};
#endif // AST_H