quality of life printing improvements
This commit is contained in:
parent
b897cc6d25
commit
41f05b9556
2
Makefile
2
Makefile
|
@ -6,7 +6,7 @@ LDFLAGS=-L${UNIVERSAL_SERVICE_DIR} -luniversalservice -L${UNIVERSAL_SERVICE_DIR}
|
||||||
flatrate: main.c
|
flatrate: main.c
|
||||||
$(CC) main.c -o flatrate $(CFLAGS) $(LDFLAGS)
|
$(CC) main.c -o flatrate $(CFLAGS) $(LDFLAGS)
|
||||||
run: flatrate
|
run: flatrate
|
||||||
LD_LIBRARY_PATH="$$(pwd)/${UNIVERSAL_SERVICE_DIR}/:$$(pwd)/${UNIVERSAL_SERVICE_DIR}/examples/string" ./flatrate < prelude.scm
|
cat prelude.scm - | LD_LIBRARY_PATH="$$(pwd)/${UNIVERSAL_SERVICE_DIR}/:$$(pwd)/${UNIVERSAL_SERVICE_DIR}/examples/string" ./flatrate
|
||||||
debug: flatrate
|
debug: flatrate
|
||||||
LD_LIBRARY_PATH="$$(pwd)/${UNIVERSAL_SERVICE_DIR}/:$$(pwd)/${UNIVERSAL_SERVICE_DIR}/examples/string" gdb -tui ./flatrate
|
LD_LIBRARY_PATH="$$(pwd)/${UNIVERSAL_SERVICE_DIR}/:$$(pwd)/${UNIVERSAL_SERVICE_DIR}/examples/string" gdb -tui ./flatrate
|
||||||
valgrind: flatrate
|
valgrind: flatrate
|
||||||
|
|
25
main.c
25
main.c
|
@ -240,7 +240,6 @@ static void tokenize(FILE *input, struct token *tok)
|
||||||
default:
|
default:
|
||||||
if (c == '.') {
|
if (c == '.') {
|
||||||
c2 = getc(input);
|
c2 = getc(input);
|
||||||
/* Flatrate does not have floating point. */
|
|
||||||
if (tonum(c2) >= 0) {
|
if (tonum(c2) >= 0) {
|
||||||
ungetc(c2, input);
|
ungetc(c2, input);
|
||||||
tok_num(input, tok, c);
|
tok_num(input, tok, c);
|
||||||
|
@ -765,12 +764,24 @@ static void display(struct uns_ctr *ctr)
|
||||||
tmp.p = gc.record_get_ptr(ctr->p, 1);
|
tmp.p = gc.record_get_ptr(ctr->p, 1);
|
||||||
display(&tmp);
|
display(&tmp);
|
||||||
|
|
||||||
printf(" . ");
|
|
||||||
|
|
||||||
tmp.p = gc.record_get_ptr(ctr->p, 2);
|
tmp.p = gc.record_get_ptr(ctr->p, 2);
|
||||||
display(&tmp);
|
switch (get_type(tmp.p)) {
|
||||||
printf(")");
|
case EMPTY_LIST:
|
||||||
|
printf(")");
|
||||||
|
goto remove;
|
||||||
|
case CELL:
|
||||||
|
printf(" ");
|
||||||
|
display(&tmp);
|
||||||
|
printf(")");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf(" . ");
|
||||||
|
display(&tmp);
|
||||||
|
printf(")");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
remove:
|
||||||
uns_root_remove(&gc, &tmp);
|
uns_root_remove(&gc, &tmp);
|
||||||
return;
|
return;
|
||||||
case INTEGER:
|
case INTEGER:
|
||||||
|
@ -790,7 +801,7 @@ static void display(struct uns_ctr *ctr)
|
||||||
case SYMBOL:
|
case SYMBOL:
|
||||||
tmp.p = gc.record_get_ptr(ctr->p, 1);
|
tmp.p = gc.record_get_ptr(ctr->p, 1);
|
||||||
uns_root_add(&gc, &tmp);
|
uns_root_add(&gc, &tmp);
|
||||||
printf("'%s ", uns_string_cstring(&gc, &tmp));
|
printf("%s ", uns_string_cstring(&gc, &tmp));
|
||||||
uns_root_remove(&gc, &tmp);
|
uns_root_remove(&gc, &tmp);
|
||||||
return;
|
return;
|
||||||
case EMPTY_LIST:
|
case EMPTY_LIST:
|
||||||
|
@ -867,7 +878,7 @@ int main(void)
|
||||||
case EXPR_PARSE_IMPROPER_LIST_OVERFLOW:
|
case EXPR_PARSE_IMPROPER_LIST_OVERFLOW:
|
||||||
fprintf(stderr, "too many values at end of improper list (must be exactly one)\n");
|
fprintf(stderr, "too many values at end of improper list (must be exactly one)\n");
|
||||||
case EXPR_PARSE_BAD_IMPROPER_LIST:
|
case EXPR_PARSE_BAD_IMPROPER_LIST:
|
||||||
fprintf(stderr, "Bad syntax for improper list (must be (value . value))");
|
fprintf(stderr, "Bad syntax for improper list (must be (value . value))\n");
|
||||||
break;
|
break;
|
||||||
case EXPR_PARSE_INTERNAL_ERROR:
|
case EXPR_PARSE_INTERNAL_ERROR:
|
||||||
fprintf(stderr, "Bug in implementation\n");
|
fprintf(stderr, "Bug in implementation\n");
|
||||||
|
|
Reference in New Issue