mirror of
https://github.com/samsonjs/lake.git
synced 2026-03-25 08:55:49 +00:00
print errors to stderr
This commit is contained in:
parent
23c8c5cecd
commit
4bfb171676
3 changed files with 7 additions and 7 deletions
|
|
@ -68,7 +68,7 @@ char *lake_repr(LakeVal *expr)
|
|||
break;
|
||||
|
||||
default:
|
||||
printf("error: unrecognized value, type %d, size %zu bytes", expr->type, expr->size);
|
||||
fprintf(stderr, "error: unrecognized value, type %d, size %zu bytes", expr->type, expr->size);
|
||||
s = g_strdup("");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ static void warn_trailing(Ctx *ctx)
|
|||
/* don't warn about trailing comments */
|
||||
if (ctx->i < ctx->n && peek(ctx) != ';') {
|
||||
char *trailing = ctx->s + ctx->i;
|
||||
printf("warning: ignoring %d trailing chars: %s\n", (int)(ctx->n - ctx->i), trailing);
|
||||
fprintf(stderr, "warning: ignoring %d trailing chars: %s\n", (int)(ctx->n - ctx->i), trailing);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
10
src/repl.c
10
src/repl.c
|
|
@ -41,7 +41,7 @@ static LakeVal *prompt_read(LakeCtx *ctx, Env *env, char *prompt)
|
|||
char buf[n];
|
||||
if (!fgets(buf, n, stdin)) {
|
||||
if (ferror(stdin)) {
|
||||
printf("error: cannot read from stdin");
|
||||
fprintf(stderr, "error: cannot read from stdin");
|
||||
}
|
||||
if (feof(stdin)) {
|
||||
return VAL(EOF);
|
||||
|
|
@ -50,19 +50,19 @@ static LakeVal *prompt_read(LakeCtx *ctx, Env *env, char *prompt)
|
|||
}
|
||||
/* trim the newline if any */
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
|
||||
|
||||
/* parse list expressions */
|
||||
if (first_char(buf) == '(') {
|
||||
return parse_expr(ctx, buf, strlen(buf));
|
||||
}
|
||||
|
||||
|
||||
/* try to parse a naked call without parens
|
||||
(makes the repl more palatable) */
|
||||
LakeList *list = parse_naked_list(ctx, buf, strlen(buf));
|
||||
if (!list || LIST_N(list) == 0) return NULL;
|
||||
|
||||
LakeVal *result;
|
||||
|
||||
|
||||
/* naked call */
|
||||
LakeVal *head;
|
||||
if (is_special_form(ctx, list) ||
|
||||
|
|
@ -75,7 +75,7 @@ static LakeVal *prompt_read(LakeCtx *ctx, Env *env, char *prompt)
|
|||
else {
|
||||
result = LIST_VAL(list, 0);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue