-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompiler.c
More file actions
71 lines (60 loc) · 1.67 KB
/
Compiler.c
File metadata and controls
71 lines (60 loc) · 1.67 KB
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
// Compiler.c
// Name: Eric Hübel, Mat.Nr: 54045, S-Nr: 86462, Gruppe: 041-62
#include <ctype.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#if _WIN32 || _WIN64
#include <windows.h>
#endif
#include "Compiler.h"
#include "Lexer.h"
#include "Liste.h"
#include "Semroutinen.h"
#include "Parser.h"
#include "CodeGen.h"
extern tProc* curProc;
extern tMorph Morph;
extern tBog gProg[];
tBog StartBog[2] = {
/* 0*/{BgGr, { (ul)gProg }, NULL, 1, 0},
/* 1*/{BgEn, { (ul)0 }, NULL, 0, 0} };
int main(int argc, char* argv[]){
// Platform anzeigen
DEBUG_PRINT("Env: %s", ENV_MSG);
DEBUG_PRINT("Varsize: %d Byte\n", VARSIZE);
#if _WIN32 || _WIN64
SetConsoleOutputCP(CP_UTF8); // Sonderzeichen unter Windows!!
#endif
if (argc != 2){
printf("Nutzung: %s <PL0-Datei>\n", argv[0]);
return 0;
}
int ret = initLex(argv[1]);
if (ret == 1){
printf("Fehler beim Lesen der Datei!\n");
return 1;
}
// Hier die MainFkt. erstellen als Hauptankerpunkt
curProc = createMainProc();
initConst();
ret = openOFile(argv[1]);
if (ret == 1){
printf("Fehler beim Schreiben der Codeausgabedatei!\n");
return 1;
}
ret = pars(StartBog);
if (ret == 1){
ret = closeOFile();
if (ret == 1){
printf("Fehler beim Schreiben der Codeausgabedatei!\n");
return 1;
}
printf("\nProgramm OK! :)\n");
}
else if (ret == 0){
printf("\nSyntaxfehler in Zeile %d, Spalte %d!\n", Morph.PosLine, Morph.PosCol);
return 1;
}
return 0;
}