[DGD] Re: explode bug?
Felix A. Croes
felix at dworkin.nl
Mon Oct 27 21:18:34 CET 1997
Wim van der Vegt <wim.vandervegt at ouh.nl> wrote:
>[...]
> 2. All files are saved as DOS files (CRLF's, so DGD stumbles on the
> multiline defines unless i resave the files in unix format).
You mean, DGD format :)
You could have saved them as non-DOS in the first place, by turning off
WinZip's newline conversion.
I wonder how WinZip treated newlines in the huge core file that comes with
Heaven7 3.0a?
> 3. One of the core objects (player or living or someting like it) has more
> than 255 functions and thus prototypes, which is above the dgd limit (so i
> had to split the object into two parts, one inherits the other).
> 4. The objects saves are in a different format than dgd. Any translation
> utilities around?
See the postscriptum for a little C program that might be of some help.
> 5. The major bug i have to trace down is that i'm not able to get anything
> (the get object fails).
> 6. dgd doesn't allow symbols that start with a digit.
Heaven7 uses symbols that start with a digit?
Regards,
Dworkin
# include <ctype.h>
# include <string.h>
# include <stdio.h>
int array, arrbuf[1000];
char buffer[60000]; /* large enough? */
void match(a, b)
char a, b;
{
if (a != b) {
fprintf(stderr, "'%c' expected\n", b);
exit(2);
}
}
char *scan(buf)
char *buf;
{
int i;
switch (*buf++) {
case '-':
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
while (isdigit(*buf)) buf++;
break;
case '"':
while (*buf != '"') {
if (*buf == '\\') buf++;
buf++;
}
buf++;
break;
case '(':
switch (*buf++) {
case '{':
i = array++;
while (*buf != '}') {
buf = scan(buf);
match(*buf++, ',');
arrbuf[i]++;
}
break;
case '[':
i = array++;
while (*buf != ']') {
buf = scan(buf);
match(*buf++, ':');
buf = scan(buf);
match(*buf++, ',');
arrbuf[i]++;
}
break;
default:
fprintf(stderr, "unexpected character '%c'\n", buf[-1]);
exit(2);
}
buf++;
match(*buf++, ')');
break;
default:
fprintf(stderr, "unexpected character '%c'\n", buf[-1]);
exit(2);
}
return buf;
}
char *copy(buf)
char *buf;
{
putchar(*buf);
switch (*buf++) {
case '-':
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
while (isdigit(*buf)) putchar(*buf++);
break;
case '"':
while (*buf != '"') {
if (*buf == '\r') {
putchar('\\');
*buf = 'n';
} else if (*buf == '\\') putchar(*buf++);
putchar(*buf++);
}
putchar(*buf++);
break;
case '(':
putchar(*buf);
switch (*buf++) {
case '{':
printf("%d|", arrbuf[array++]);
while (*buf != '}') {
buf = copy(buf);
putchar(*buf++);
}
break;
case '[':
printf("%d|", arrbuf[array++]);
while (*buf != ']') {
buf = copy(buf);
putchar(*buf++);
buf = copy(buf);
putchar(*buf++);
}
break;
}
putchar(*buf++);
putchar(*buf++);
break;
}
return buf;
}
main()
{
char *p;
puts("#");
while (gets(buffer) != (char *) NULL) {
p = strchr(buffer, ' ');
if (p == (char *) NULL) {
fprintf(stderr, "variable name expected\n");
return 2;
}
*p++ = '\0';
memset(arrbuf, '\0', sizeof(arrbuf));
array = 0;
match(*scan(p), '\0');
printf("%s ", buffer);
array = 0;
copy(p);
putchar('\n');
}
}
More information about the DGD
mailing list