-
Notifications
You must be signed in to change notification settings - Fork 0
/
FrontendMain.cpp
36 lines (25 loc) · 899 Bytes
/
FrontendMain.cpp
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
#include "Frontend.hpp"
#include <exception>
int main(int argc, const char *argv[])
{
--argc;
if (argc == 0 || argc > 2) {
printf("usage: backend <program language input file name> <abstract syntax tree dump output file name>\n");
return EXIT_SUCCESS;
}
const char *programLanguageInputFileName = argv[1];
const char *abstractSyntaxTreeDumpOutputFileName = argv[2];
Frontend frontend;
try {
frontend.translate(programLanguageInputFileName, abstractSyntaxTreeDumpOutputFileName);
return EXIT_SUCCESS;
} catch (const std::exception &exception) {
std::fprintf(stderr, "%s\n", exception.what());
frontend.FrontendDtor();
return EXIT_FAILURE;
} catch (...) {
std::fprintf(stderr, "Program failure: unhandled exception\n");
frontend.FrontendDtor();
return EXIT_FAILURE;
}
}