summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/assembler.h7
-rw-r--r--include/exceptions.h (renamed from include/global.h)6
-rw-r--r--include/meta.h1
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/assembler.c20
-rw-r--r--lib/exceptions.c29
-rw-r--r--lib/hash.c5
-rw-r--r--lib/meta.c31
-rw-r--r--lib/numbers.c1
-rw-r--r--lib/parser.c2
-rw-r--r--po/ProjetArchi.pot58
-rw-r--r--po/cat-id-tbl.c24
-rw-r--r--src/compilo.c47
13 files changed, 206 insertions, 27 deletions
diff --git a/include/assembler.h b/include/assembler.h
index e69de29..0213f15 100644
--- a/include/assembler.h
+++ b/include/assembler.h
@@ -0,0 +1,7 @@
+#ifndef __ASSEMBLER_H__
+#define __ASSEMBLER_H__
+
+int assembler_init(void);
+void assembler_flush(void);
+
+#endif
diff --git a/include/global.h b/include/exceptions.h
index 21d412d..efc02f7 100644
--- a/include/global.h
+++ b/include/exceptions.h
@@ -1,10 +1,10 @@
-#ifndef __GLOBAL_H__
-#define __GLOBAL_H__
+#ifndef __EXCEPTIONS_H__
+#define __EXCEPTIONS_H__
#include <stdio.h>
-void exception(int, char *);
char * Estrdup(char *);
void * Emalloc(size_t);
+void exception(int, char *);
#endif
diff --git a/include/meta.h b/include/meta.h
index 7e456a5..471710d 100644
--- a/include/meta.h
+++ b/include/meta.h
@@ -53,4 +53,5 @@ extern instruct_t *instructs;
void meta_parse_line(char *);
int meta_init(void);
void meta_flush(void);
+int meta_load(char *);
#endif
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 4d66b47..b463138 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -4,7 +4,7 @@ AM_CFLAGS = -O3 -Wall -Wstrict-prototypes $(CFLAGS)
INCLUDES = -I. -I.. -I$(includedir) -I../include
lib_LTLIBRARIES = libCompilo.la
-libCompilo_la_SOURCES = assembler.c parser.c meta.c numbers.c hash.h
+libCompilo_la_SOURCES = assembler.c parser.c meta.c numbers.c hash.c exceptions.c
libCompilo_la_LDFLAGS = -version-info $(ProjetArchi_VERSION_INFO)
diff --git a/lib/assembler.c b/lib/assembler.c
index e69de29..3fd358c 100644
--- a/lib/assembler.c
+++ b/lib/assembler.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "meta.h"
+#include "hash.h"
+#include "parser.h"
+
+
+void push_pile(char * a) {
+}
+
+void act_pile(int o) {
+}
+
+int assembler_init(void) {
+ return 0;
+}
+
+void assembler_flush(void) {
+}
diff --git a/lib/exceptions.c b/lib/exceptions.c
new file mode 100644
index 0000000..349e8a9
--- /dev/null
+++ b/lib/exceptions.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "config.h"
+#include "exceptions.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);
+}
diff --git a/lib/hash.c b/lib/hash.c
index 9f45885..3736b80 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -2,7 +2,6 @@
#include <stdlib.h>
#include <string.h>
#include "hash.h"
-#include "global.h"
static char *CHAINEHACHAGE = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
static void TraitementDesErreurs(int codeerreur)
@@ -100,7 +99,7 @@ static void Detruit(_ListeChaine * l) {
_ListeChaine l_aux = NULL;
while (*l) {
- l_aux = l->Suivant;
+ l_aux = (*l)->Suivant;
free((*l)->Elem.NomVar);
free(*l);
*l = l_aux;
@@ -182,6 +181,8 @@ int Initialise(_TableauVariable * t)
}
void DetruitTab(_TableauVariable * t){
+ int i;
+
for (i = 0; i < strlen(CHAINEHACHAGE); i++) {
Detruit(&((*t)[i]));
}
diff --git a/lib/meta.c b/lib/meta.c
index 7aa5add..c40f116 100644
--- a/lib/meta.c
+++ b/lib/meta.c
@@ -10,7 +10,7 @@ void exception(int, char *);
char * Estrdup(char *);
void * Emalloc(size_t);
#endif
-#include "global.h"
+#include "exceptions.h"
#include "numbers.h"
#include "meta.h"
@@ -448,6 +448,25 @@ void meta_flush(void) {
instructs = NULL;
}
+int meta_load(char * n) {
+ FILE * f;
+ char buf[BUFSIZ], *p;
+
+ if (!(f = fopen(n, "r"))) {
+ return 1;
+ }
+ while (fgets(buf, BUFSIZ, f)) {
+ if ((p = strchr(buf, '\r'))) {
+ *p = '\0';
+ }
+ if ((p = strchr(buf, '\n'))) {
+ *p = '\0';
+ }
+ meta_parse_line(buf);
+ }
+ return 0;
+}
+
#ifndef HAVE_CONFIG_H
char * Estrdup(char * o) {
char * r;
@@ -475,8 +494,6 @@ void exception(int level, char *msg)
void main(void)
{
- FILE *f;
- char buf[BUFSIZ], *p;
phon_t *phon;
field_t *field;
pattern_t *pattern;
@@ -486,13 +503,7 @@ void main(void)
if (meta_init())
exception(1, _("Meta parser init failed."));
- f = fopen("instructions.txt", "r");
- while (fgets(buf, BUFSIZ, f)) {
- if ((p = strchr(buf, '\n'))) {
- *p = '\0';
- }
- meta_parse_line(buf);
- }
+ meta_load("instructions.txt");
fprintf(stderr, "\nListe des phonèmes:\n");
for (phon = phons->next; phon; phon = phon->next) {
diff --git a/lib/numbers.c b/lib/numbers.c
index ba45f29..8334dd4 100644
--- a/lib/numbers.c
+++ b/lib/numbers.c
@@ -1,4 +1,3 @@
-#include "global.h"
#include "numbers.h"
int char_to_number(char *st, int *valid)
diff --git a/lib/parser.c b/lib/parser.c
index a2947e6..ee3e64c 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -6,7 +6,7 @@
#define _(x) x
void exception(int, char *);
#endif
-#include "global.h"
+#include "exceptions.h"
#include "parser.h"
diff --git a/po/ProjetArchi.pot b/po/ProjetArchi.pot
index 14ef553..915184b 100644
--- a/po/ProjetArchi.pot
+++ b/po/ProjetArchi.pot
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2001-03-30 01:34+0200\n"
+"POT-Creation-Date: 2001-04-01 14:30+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -67,11 +67,11 @@ msgstr ""
msgid "expecting ; as field separator"
msgstr ""
-#: lib/meta.c:456 lib/meta.c:465 src/compilo.c:14 src/compilo.c:23
+#: lib/meta.c:475 lib/meta.c:484 src/compilo.c:15 src/compilo.c:24
msgid "Out of memory."
msgstr ""
-#: lib/meta.c:487
+#: lib/meta.c:504 src/compilo.c:43
msgid "Meta parser init failed."
msgstr ""
@@ -106,3 +106,55 @@ msgstr ""
#: lib/parser.c:241
msgid "Invalid character"
msgstr ""
+
+#: src/compilo.c:36
+msgid ""
+"Assembler\n"
+"\n"
+msgstr ""
+
+#: src/compilo.c:40
+msgid " o Initialising the meta engine... "
+msgstr ""
+
+#: src/compilo.c:46
+msgid ""
+" Done!\n"
+" o Meta language loading... "
+msgstr ""
+
+#: src/compilo.c:49
+msgid "Meta language loading failed."
+msgstr ""
+
+#: src/compilo.c:52
+msgid ""
+" Done!\n"
+" o Initialising the assembler core..."
+msgstr ""
+
+#: src/compilo.c:55
+msgid "Assembler core init failed."
+msgstr ""
+
+#: src/compilo.c:58
+msgid " Done!\n"
+msgstr ""
+
+#: src/compilo.c:69
+msgid ""
+"\n"
+"Performing initialisation...\n"
+"\n"
+msgstr ""
+
+#: src/compilo.c:72
+msgid ""
+"\n"
+"Performing shutdown...\n"
+"\n"
+msgstr ""
+
+#: src/compilo.c:75
+msgid "Exitting, bye!\n"
+msgstr ""
diff --git a/po/cat-id-tbl.c b/po/cat-id-tbl.c
index 50d239e..a94117f 100644
--- a/po/cat-id-tbl.c
+++ b/po/cat-id-tbl.c
@@ -31,6 +31,28 @@ const struct _msg_ent _msg_tbl[] = {
{"Parse error: too much right parenthesis", 22},
{"Parse error: enclosure mismatch", 23},
{"Invalid character", 24},
+ {"\
+Assembler\n\
+\n", 25},
+ {" o Initialising the meta engine... ", 26},
+ {"\
+ Done!\n\
+ o Meta language loading... ", 27},
+ {"Meta language loading failed.", 28},
+ {"\
+ Done!\n\
+ o Initialising the assembler core...", 29},
+ {"Assembler core init failed.", 30},
+ {" Done!\n", 31},
+ {"\
+\n\
+Performing initialisation...\n\
+\n", 32},
+ {"\
+\n\
+Performing shutdown...\n\
+\n", 33},
+ {"Exitting, bye!\n", 34},
};
-int _msg_tbl_length = 24;
+int _msg_tbl_length = 34;
diff --git a/src/compilo.c b/src/compilo.c
index b146b4d..6c9e36b 100644
--- a/src/compilo.c
+++ b/src/compilo.c
@@ -1,7 +1,8 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include "config.h"
-#include "global.h"
+#include "exceptions.h"
#include "meta.h"
#include "parser.h"
#include "hash.h"
@@ -31,10 +32,46 @@ void exception(int level, char *msg)
exit(level);
}
-void push_pile(char * s) {}
-void act_pile(int t) {}
+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) {
- return 0;
-} \ No newline at end of file
+ invite();
+
+ fprintf(stderr, _("\nPerforming initialisation...\n\n"));
+ init_all();
+
+ fprintf(stderr, _("\nPerforming shutdown...\n\n"));
+ flush_all();
+
+ fprintf(stderr, _("Exitting, bye!\n"));
+ return 0;
+}