summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <Pixel>2001-05-01 16:29:53 +0000
committerPixel <Pixel>2001-05-01 16:29:53 +0000
commit759be422fcf0fcca5a91b01e5ed7f752d95f0f8d (patch)
tree87652f23ced34ec3cdc3e8978439626c1d1af32e
parent368207e46ca78ec42d77a3b1d3539cf4250617eb (diff)
Pouet
-rw-r--r--include/exceptions.h2
-rw-r--r--lib/exceptions.c2
-rw-r--r--lib/parser.c32
3 files changed, 11 insertions, 25 deletions
diff --git a/include/exceptions.h b/include/exceptions.h
index 6f6e8c4..ab578a7 100644
--- a/include/exceptions.h
+++ b/include/exceptions.h
@@ -10,4 +10,6 @@ void pushcontext(char *);
void popcontext(void);
void flushcontext(void);
+extern int global_error;
+
#endif
diff --git a/lib/exceptions.c b/lib/exceptions.c
index e59013b..72842a4 100644
--- a/lib/exceptions.c
+++ b/lib/exceptions.c
@@ -17,6 +17,7 @@
char *contexts[128];
int clevel = 0;
+int global_error = 0;
char *Estrdup(char *o)
{
@@ -82,6 +83,7 @@ void exception(int level, char *msg)
case 1:
fprintf(stderr, " Error description: %s\n", msg);
flush_pile();
+ global_error = 1;
break;
default:
fprintf(stderr, "Error detected. Showing context.\n");
diff --git a/lib/parser.c b/lib/parser.c
index 6d608b4..23239c4 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -96,7 +96,7 @@ static void push_op(op_t op)
if (pileop_pos != PILEOP_MAX)
pile_operators[pileop_pos++] = op;
else
- exception(2, _("Too many nested operators in expression.\n"));
+ exception(1, _("Too many nested operators in expression.\n"));
}
@@ -127,7 +127,7 @@ static void push_call(int call)
if (pilecall_pos != PILECALL_MAX)
pile_nestedcall[pilecall_pos++] = call;
else
- exception(2, _("Too many nested functions calls in expression.\n"));
+ exception(1, _("Too many nested functions calls in expression.\n"));
}
/* Cette fonction lit un "mot" sur la chaine line et renvoit le nouveau pointeur */
@@ -175,7 +175,7 @@ static char *getword(char *line, char *p)
}
line++;
}
- while (((*line) && (*line != ')') && (*line != ']')
+ while (((*line) && (*line != ')')
&& (*line != ';') && (get_func(*line) == -1)
&& (get_func(o) == -1)) || (instring));
*p = '\0';
@@ -193,7 +193,7 @@ void parse_line(char *line)
sprintf(buffer, "Read line '%s'", line);
pushcontext(buffer);
- while (*line) {
+ while ((*line) && !(global_error)) {
line = getword(line, buffer);
sprintf(imm, "Analysing word '%s' at position %i", buffer, line - d);
pushcontext(imm);
@@ -209,9 +209,8 @@ void parse_line(char *line)
exception(1, _("Invalid binary operator"));
}
}
- while (get_pri(get_last_op()) >= get_pri(buffer[0])
- && (((get_last_op() & 127) != '(')
- && ((get_last_op() & 127) != '['))) {
+ while ((get_pri(get_last_op()) >= get_pri(buffer[0]))
+ && ((get_last_op() & 127) != '(')) {
act_pile(get_func(pop_op()));
got_unary = 0;
}
@@ -223,8 +222,7 @@ void parse_line(char *line)
} else
push_op(buffer[0]);
got_unary = 128;
- } else if ((buffer[0] == ';') || (buffer[0] == ')')
- || (buffer[0] == ']')) {
+ } else if ((buffer[0] == ';') || (buffer[0] == ')')) {
/* Le mot lut est un opérateur spécial, on vide la pile */
switch (buffer[0]) {
case ';':
@@ -257,21 +255,6 @@ void parse_line(char *line)
}
got_unary = 0;
break;
- case ']':
- /* Fin d'opérateur de décalage */
- while (1) {
- if (!pileop_pos)
- exception(1, _("Parse error: too much right parenthesis"));
- op = pop_op();
- if (((op & 127) == '['))
- break;
- if (((op & 127) == '('))
- exception(1, _("Parse error: enclosure mismatch"));
- act_pile(get_func(op));
- }
- act_pile(get_func(op));
- got_unary = 0;
- break;
}
} else if (((buffer[0] >= 'A') && (buffer[0] <= 'Z'))
|| ((buffer[0] >= 'a') && (buffer[0] <= 'z'))
@@ -289,6 +272,5 @@ void parse_line(char *line)
}
popcontext();
}
-
popcontext();
}