-
Notifications
You must be signed in to change notification settings - Fork 0
/
Backend.hpp
42 lines (33 loc) · 1.75 KB
/
Backend.hpp
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
#ifndef BACKEND_HPP
#define BACKEND_HPP
#include "AbstractSyntaxTreeDumpLanguageAnalyser.hpp"
#include <cstdio>
#include <map>
class Backend {
public:
Backend();
void BackendDtor();
void translate(const char *abstractSyntaxTreeInputFileName, const char *translationOutputFileName);
private:
AbstractSyntaxTreeDumpLanguageAnalyser analyser;
AbstractSyntaxTreeDumpLanguageAnalyser::FunctionScope *currentFunctionScope;
std::FILE *translationOutputFile;
void translateFunctionDeclaration(const AbstractSyntaxTree::Node *node);
void translateFunctionImplementation(const AbstractSyntaxTree::Node *node);
void translateBlock(const AbstractSyntaxTree::Node *node);
void translateConcatenation(const AbstractSyntaxTree::Node *node);
void translateStatement(const AbstractSyntaxTree::Node *node);
void translateIf(const AbstractSyntaxTree::Node *node);
void translateWhile(const AbstractSyntaxTree::Node *node);
void translateCondition(const AbstractSyntaxTree::Node *node, bool isIfCondition, size_t uniqueJumpLabelNo);
void translateOperator(const AbstractSyntaxTree::Node *node);
void translateAssignmentOperator(const AbstractSyntaxTree::Node *node);
void translateFunctionCallOperator(const AbstractSyntaxTree::Node *node);
void translateFunctionCallParameter(const AbstractSyntaxTree::Node *node, size_t parameterNo);
void translateReturnOperator(const AbstractSyntaxTree::Node *node);
void translateMathematicalOperator(const AbstractSyntaxTree::Node *node);
void translateExpression(const AbstractSyntaxTree::Node *node);
void translateVariable(const AbstractSyntaxTree::Node *node, bool forAssignment);
void translateNumber(const AbstractSyntaxTree::Node *node);
};
#endif /* BACKEND_HPP */