don't warn about trailing comments during parsing

This commit is contained in:
Sami Samhuri 2011-04-22 12:55:31 -07:00
parent a0d5f40515
commit 228ff0a4ef

View file

@ -27,16 +27,25 @@ struct context {
};
typedef struct context Ctx;
static LakeVal *_parse_expr(Ctx *ctx);
static int maybe_spaces(Ctx *ctx);
static char peek(Ctx *ctx)
{
if (ctx->i < ctx->n) return ctx->s[ctx->i];
return PARSE_EOF;
}
static void warn_trailing(Ctx *ctx)
{
if (ctx->i < ctx->n) {
maybe_spaces(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);
}
}
static LakeVal *_parse_expr(Ctx *ctx);
LakeVal *parse_expr(char *s, size_t n)
{
Ctx ctx = { s, n, 0, 0 };
@ -64,14 +73,6 @@ LakeList *parse_exprs(char *s, size_t n)
return results;
}
static int maybe_spaces(Ctx *ctx);
static char peek(Ctx *ctx)
{
if (ctx->i < ctx->n) return ctx->s[ctx->i];
return PARSE_EOF;
}
LakeList *parse_naked_list(char *s, size_t n)
{
Ctx ctx = { s, n, 0, 0 };