-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathast.h
41 lines (32 loc) · 1.01 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
#pragma once
#include <memory>
#include <vector>
#include <llvm/Support/IRBuilder.h>
using namespace std;
struct ExprAST {
virtual void Codegen(llvm::IRBuilder<>&, llvm::Module&) = 0;
};
struct BodyAST : ExprAST {
vector<unique_ptr<ExprAST>> exprs_;
void append(ExprAST *expr) { exprs_.push_back(unique_ptr<ExprAST>(expr)); }
virtual void Codegen(llvm::IRBuilder<>& builder, llvm::Module&);
};
struct OperationAST : ExprAST {
bool increment_;
OperationAST(bool increment) : increment_(increment) {}
virtual void Codegen(llvm::IRBuilder<>& builder, llvm::Module&);
};
struct ShiftAST : ExprAST {
bool right_;
ShiftAST(bool right) : right_(right) {}
virtual void Codegen(llvm::IRBuilder<>& builder, llvm::Module&);
};
struct WhileAST : BodyAST {
virtual void Codegen(llvm::IRBuilder<>& builder, llvm::Module&);
};
struct PrintAST : ExprAST {
virtual void Codegen(llvm::IRBuilder<>& builder, llvm::Module&);
};
struct GetAST : ExprAST {
virtual void Codegen(llvm::IRBuilder<>& builder, llvm::Module&);
};