blob: 8c59067147ec41f82ccd27b778ffcf77308b817c (
plain)
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
|
#ifndef WILLOWC_INCLUDE_AST_HPP
#define WILLOWC_INCLUDE_AST_HPP
#include <cstdint>
#include <memory>
#include <vector>
#include <willow/IR/Instructions.h>
#include <willow/IR/Types.h>
#include <tokenizer.hpp>
namespace willowc {
using Opcode = willow::Instruction::Opcode;
using TokenIndex = std::size_t;
// this is like willow::ValueKind, but treats groups all ssa values into 'Value'
// (because they can't be differentiated by syntax alone)
enum class ExprKind { Constant, BasicBlock, Function, Value };
struct ExprAST {
ExprKind kind;
std::string name;
// token??
};
struct InstAST {
Opcode op;
std::string name;
std::vector<std::unique_ptr<ExprAST>> args;
};
struct BlockAST {
std::string label;
std::vector<std::unique_ptr<InstAST>> body;
};
struct ParameterAST {
std::string name;
willow::Type type;
};
struct FunctionDeclAST {
std::string name;
std::vector<std::unique_ptr<ParameterAST>> parameters;
std::string returntype;
std::vector<std::unique_ptr<BlockAST>> body;
// TODO: movable symbol table
};
struct ModuleAST {
std::vector<std::unique_ptr<FunctionDeclAST>> Functions;
// TODO: imports, symbol table
};
}; // namespace willowc
#endif // WILLOWC_INCLUDE_AST_HPP
|