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
|
#ifndef AST_HPP_INCLUDED
#define AST_HPP_INCLUDED
#include <string>
#include <vector>
#include <stdexcept>
#include "../coretypes.hpp"
class TypeRef;
namespace AST {
class ExprNode;
class TypeParam
{
public:
TypeParam(bool is_lifetime, ::std::string name);
void addLifetimeBound(::std::string name);
void addTypeBound(TypeRef type);
};
typedef ::std::vector<TypeParam> TypeParams;
typedef ::std::pair< ::std::string, TypeRef> StructItem;
class PathNode
{
::std::string m_name;
TypeParams m_params;
public:
const ::std::string& name() const;
const TypeParams& args() const;
};
class Path
{
public:
Path();
struct TagAbsolute {};
Path(TagAbsolute);
void append(::std::string str) {}
size_t length() const {return 0;}
PathNode& operator[](size_t idx) { throw ::std::out_of_range("Path []"); }
};
class Pattern
{
public:
Pattern();
struct TagMaybeBind {};
Pattern(TagMaybeBind, ::std::string name);
struct TagValue {};
Pattern(TagValue, ExprNode node);
};
class ExprNode
{
public:
ExprNode();
struct TagBlock {};
ExprNode(TagBlock, ::std::vector<ExprNode> nodes);
struct TagAssign {};
ExprNode(TagAssign, ExprNode slot, ExprNode value) {}
struct TagInteger {};
ExprNode(TagInteger, uint64_t value, enum eCoreType datatype);
struct TagCallPath {};
ExprNode(TagCallPath, Path path, ::std::vector<ExprNode> args);
struct TagMatch {};
ExprNode(TagMatch, ExprNode val, ::std::vector< ::std::pair<Pattern,ExprNode> > arms);
struct TagNamedValue {};
ExprNode(TagNamedValue, Path path);
};
class Expr
{
public:
Expr() {}
Expr(ExprNode node) {}
};
class Module
{
public:
void add_alias(bool is_public, Path path) {}
void add_constant(bool is_public, ::std::string name, TypeRef type, Expr val);
void add_global(bool is_public, bool is_mut, ::std::string name, TypeRef type, Expr val);
void add_struct(bool is_public, ::std::string name, TypeParams params, ::std::vector<StructItem> items);
void add_function(bool is_public, ::std::string name, TypeParams params, TypeRef ret_type, ::std::vector<StructItem> args, Expr code);
};
}
#endif // AST_HPP_INCLUDED
|