-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPL0_Compiler.c
55 lines (41 loc) · 1.25 KB
/
PL0_Compiler.c
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
//
// Created by Isaias Perez Vega
//
#include <stdio.h>
#include <stdlib.h>
// Compiler Modules
#include "LexicalAnalyzer.c"
#include "Parser.c"
#include "VirtualMachine.c"
// PL0 Compiler will use command line parameters to determine if
// the lexical list, machine code, and or virtual machine trace should be printed.
int main(int argc, const char * argv[]) {
FILE* traceFile = fopen("traceFile.txt", "w");
int l = 0, a = 0, v = 0;
// Run and print nothing to console except in and out
if (argc == 0) {
// Do nothing
// Print different types of output
} else if (argc > 0) {
for (int i = 0; i < argc; i++) {
// Print Lexime List
if (strcmp(argv[i], "-l") == 0) {
l = 1;
}
// Print Machine Code
if (strcmp(argv[i], "-a") == 0) {
a = 1;
}
// Print VM Trace
if (strcmp(argv[i], "-v") == 0) {
v = 1;
}
}
}
// Execute compiler process
lexicalScan(traceFile, l);
parseCodeGenerator(traceFile, a);
runVirtualMachine(traceFile, v);
fclose(traceFile);
return 0;
}