summaryrefslogtreecommitdiff
path: root/src/compilo.c
blob: 6c9e36bdd6e6dc63dd2d5df2bff52444f4b383b8 (plain)
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
72
73
74
75
76
77
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "config.h"
#include "exceptions.h"
#include "meta.h"
#include "parser.h"
#include "hash.h"
#include "assembler.h"

char * Estrdup(char * o) {
        char * r;
        
        if (!(r = strdup(o))) {
                exception(1, _("Out of memory."));
        }
        return r;       
}

void * Emalloc(size_t s) {
        void * r;
        
        if (!(r = malloc(s))) {
                exception(1, _("Out of memory."));
        }
        return r;
}

void exception(int level, char *msg)
{
        fprintf(stderr, "%s\n", msg);
        exit(level);
}

void invite(void) {
	fprintf(stderr, _("Assembler\n\n"));
}

void init_all(void) {
	fprintf(stderr, _(" o Initialising the meta engine...   "));

	if (meta_init()) {
		exception(1, _("Meta parser init failed."));
	}

	fprintf(stderr, _(" Done!\n o Meta language loading...          "));

	if (meta_load("instructions.txt")) {
		exception(1, _("Meta language loading failed."));
	}
	
	fprintf(stderr, _(" Done!\n o Initialising the assembler core..."));
	
	if (assembler_init()) {
		exception(1, _("Assembler core init failed."));
	}
	
	fprintf(stderr, _(" Done!\n"));
}

void flush_all(void) {
	assembler_flush();
	meta_flush();
}

int main(void) {
	invite();

	fprintf(stderr, _("\nPerforming initialisation...\n\n"));
	init_all();
	
	fprintf(stderr, _("\nPerforming shutdown...\n\n"));
	flush_all();
	
	fprintf(stderr, _("Exitting, bye!\n"));
        return 0;
}