summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <>2001-04-15 01:53:16 +0000
committerPixel <>2001-04-15 01:53:16 +0000
commit0aca28afe35e25329bd8d680b532ccf78d4e4557 (patch)
tree0a4e648d3cded13fda699976cc7967d0f4060cd8
parentdf05ffca736e4090a6b2acce53eafb72d85b87c9 (diff)
Qque modifs...
-rw-r--r--lib/assembler.c190
-rw-r--r--lib/exceptions.c4
2 files changed, 91 insertions, 103 deletions
diff --git a/lib/assembler.c b/lib/assembler.c
index 60fe86f..e727ce2 100644
--- a/lib/assembler.c
+++ b/lib/assembler.c
@@ -1287,7 +1287,7 @@ static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs, expression_
static void evaluate_pattern(_TableauVariable * it, expression_t * e)
{
- metaexpr_t *m;
+ metaexpr_t *m, *n;
expression_t *t;
if (!e->pattern) {
@@ -1296,111 +1296,95 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e)
m = e->pattern->expr[e->index];
- switch (e->e_subtype) {
- case E_OPERATION:
- switch (e->op) {
- case OP_DECAL:
- /* On est sous la forme LABEL[VALEUR + PATTERN] au pire */
- switch (e->child->next->e_subtype) {
- case E_OPERATION:
- /* Et voila on y est... */
- t = (expression_t *) Emalloc(sizeof(expression_t));
- t->e_type = t->e_subtype = E_VALUE;
- t->avalue = e->child->next->child->next->index;
- t->next = t->child = NULL;
-
- InsererVarDansTab(it, CreerElement(m->string, t));
- free(t);
-
- t = (expression_t *) Emalloc(sizeof(expression_t));
- t->e_type = t->e_subtype = E_LABEL;
- t->avalue = 0;
- t->next = t->child = NULL;
- t->symbol = Estrdup(e->child->symbol);
-
- pushdword(e->child->next->child->avalue, t);
- free(t);
- break;
- case E_VALUE:
- /* Sous la forme LABEL[VALEUR] */
- t = (expression_t *) Emalloc(sizeof(expression_t));
- t->e_type = t->e_subtype = E_LABEL;
- t->avalue = 0;
- t->next = t->child = NULL;
- t->symbol = Estrdup(e->child->symbol);
-
- pushdword(e->child->next->avalue, t);
- free(t);
- break;
- case E_PATTERN:
- /* Sous la forme LABEL[PATTERN] */
- t = (expression_t *) Emalloc(sizeof(expression_t));
- t->e_type = t->e_subtype = E_VALUE;
- t->avalue = e->child->next->index;
- t->next = t->child = NULL;
-
- InsererVarDansTab(it, CreerElement(m->string, t));
- free(t);
-
- t = (expression_t *) Emalloc(sizeof(expression_t));
- t->e_type = t->e_subtype = E_LABEL;
- t->avalue = 0;
- t->next = t->child = NULL;
- t->symbol = Estrdup(e->child->symbol);
-
- pushdword(0, t);
- free(t);
- break;
- default:
- exception(1, _("Pattern not matching..."));
- break;
+ if (m->name) {
+ if (m->string) {
+ if (m->type) {
+ if (!strcmp(m->name, "I")) {
+ exception(1, _("Unknow constant type in the meta language"));
+ }
+ if (e->e_subtype == E_VALUE) {
+ pushdword(e->avalue, NULL);
+ } else {
+ pushdword(0, e);
+ }
+ } else {
+ if (m->string) {
+ if (m->string != 'P') {
+ exception(1,
+ _
+ ("Error in the metalanguage (pattern should be here if not a constant type)"));
+ }
+ t = (expression_t *) Emalloc(sizeof(expression_t));
+ t->next = t->child = t->prev = t->father = NULL;
+ t->e_type = t->e_subtype = E_VALUE;
+ t->avalue = e->index;
+ t->symbol = NULL;
+ InsererVarDansTab(it, CreerElement(m->name, t))
+ free(t);
+ }
}
- break;
- case OP_DIRECT:
- switch (e->child->e_subtype) {
- case E_OPERATION:
- /* Sous la forme [VALUE + PATTERN] */
- t = (expression_t *) Emalloc(sizeof(expression_t));
- t->e_type = t->e_subtype = E_VALUE;
- t->avalue = e->child->child->next->index;
- t->next = t->child = NULL;
-
- InsererVarDansTab(it, CreerElement(m->string, t));
- free(t);
-
- pushdword(e->child->child->avalue, NULL);
- break;
- case E_VALUE:
- /* Sous la forme [VALUE] */
- pushdword(e->child->avalue, NULL);
- break;
- case E_PATTERN:
- /* Sous la forme [PATTERN] */
- t = (expression_t *) Emalloc(sizeof(expression_t));
- t->e_type = t->e_subtype = E_VALUE;
- t->avalue = e->child->child->next->index;
- t->next = t->child = NULL;
-
- InsererVarDansTab(it, CreerElement(m->string, t));
- free(t);
-
- pushdword(e->child->child->avalue, NULL);
- break;
- default:
- exception(1, _("Pattern not matching..."));
- break;
+ }
+ } else {
+ n = m;
+ if (m->left) { /* Binaire */
+ m = m->left;
+ if (m->string) {
+ if (m->type) {
+ if (!strcmp(m->name, "I")) {
+ exception(1, _("Unknow constant type in the meta language"));
+ }
+ if (e->child->e_subtype == E_VALUE) {
+ pushdword(e->avalue, NULL);
+ } else {
+ pushdword(0, e);
+ }
+ } else {
+ if (m->string) {
+ if (m->string != 'P') {
+ exception(1,
+ _
+ ("Error in the metalanguage (pattern should be here if not a constant type)"));
+ }
+ t = (expression_t *) Emalloc(sizeof(expression_t));
+ t->next = t->child = t->prev = t->father = NULL;
+ t->e_type = t->e_subtype = E_VALUE;
+ t->avalue = e->index;
+ t->symbol = NULL;
+ InsererVarDansTab(it, CreerElement(m->name, t))
+ free(t);
+ }
+ }
+ }
+ } else {
+ m = m->right;
+ if (m->string) {
+ if (m->type) {
+ if (!strcmp(m->name, "I")) {
+ exception(1, _("Unknow constant type in the meta language"));
+ }
+ if (e->e_subtype == E_VALUE) {
+ pushdword(e->avalue, NULL);
+ } else {
+ pushdword(0, e);
+ }
+ } else {
+ if (m->string) {
+ if (m->string != 'P') {
+ exception(1,
+ _
+ ("Error in the metalanguage (pattern should be here if not a constant type)"));
+ }
+ t = (expression_t *) Emalloc(sizeof(expression_t));
+ t->next = t->child = t->prev = t->father = NULL;
+ t->e_type = t->e_subtype = E_VALUE;
+ t->avalue = e->index;
+ t->symbol = NULL;
+ InsererVarDansTab(it, CreerElement(m->name, t))
+ free(t);
+ }
+ }
}
- break;
- default:
- exception(1, _("Pattern not matching..."));
- break;
}
- break;
- case E_PATTERN:
- break;
- default:
- exception(1, _("Pattern not matching..."));
- break;
}
}
diff --git a/lib/exceptions.c b/lib/exceptions.c
index 0bacb32..b86fb9f 100644
--- a/lib/exceptions.c
+++ b/lib/exceptions.c
@@ -1,7 +1,11 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#else
+#define _(x) x
+#endif
#include "exceptions.h"
char *contexts[128];