mirror of
https://github.com/samsonjs/lake.git
synced 2026-04-27 14:57:43 +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;
|
break;
|
||||||
|
|
||||||
default:
|
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("");
|
s = g_strdup("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ static void warn_trailing(Ctx *ctx)
|
||||||
/* don't warn about trailing comments */
|
/* don't warn about trailing comments */
|
||||||
if (ctx->i < ctx->n && peek(ctx) != ';') {
|
if (ctx->i < ctx->n && peek(ctx) != ';') {
|
||||||
char *trailing = ctx->s + ctx->i;
|
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];
|
char buf[n];
|
||||||
if (!fgets(buf, n, stdin)) {
|
if (!fgets(buf, n, stdin)) {
|
||||||
if (ferror(stdin)) {
|
if (ferror(stdin)) {
|
||||||
printf("error: cannot read from stdin");
|
fprintf(stderr, "error: cannot read from stdin");
|
||||||
}
|
}
|
||||||
if (feof(stdin)) {
|
if (feof(stdin)) {
|
||||||
return VAL(EOF);
|
return VAL(EOF);
|
||||||
|
|
@ -50,19 +50,19 @@ static LakeVal *prompt_read(LakeCtx *ctx, Env *env, char *prompt)
|
||||||
}
|
}
|
||||||
/* trim the newline if any */
|
/* trim the newline if any */
|
||||||
buf[strcspn(buf, "\n")] = '\0';
|
buf[strcspn(buf, "\n")] = '\0';
|
||||||
|
|
||||||
/* parse list expressions */
|
/* parse list expressions */
|
||||||
if (first_char(buf) == '(') {
|
if (first_char(buf) == '(') {
|
||||||
return parse_expr(ctx, buf, strlen(buf));
|
return parse_expr(ctx, buf, strlen(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try to parse a naked call without parens
|
/* try to parse a naked call without parens
|
||||||
(makes the repl more palatable) */
|
(makes the repl more palatable) */
|
||||||
LakeList *list = parse_naked_list(ctx, buf, strlen(buf));
|
LakeList *list = parse_naked_list(ctx, buf, strlen(buf));
|
||||||
if (!list || LIST_N(list) == 0) return NULL;
|
if (!list || LIST_N(list) == 0) return NULL;
|
||||||
|
|
||||||
LakeVal *result;
|
LakeVal *result;
|
||||||
|
|
||||||
/* naked call */
|
/* naked call */
|
||||||
LakeVal *head;
|
LakeVal *head;
|
||||||
if (is_special_form(ctx, list) ||
|
if (is_special_form(ctx, list) ||
|
||||||
|
|
@ -75,7 +75,7 @@ static LakeVal *prompt_read(LakeCtx *ctx, Env *env, char *prompt)
|
||||||
else {
|
else {
|
||||||
result = LIST_VAL(list, 0);
|
result = LIST_VAL(list, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue