mirror of
https://github.com/samsonjs/lake.git
synced 2026-04-27 14:57:43 +00:00
don't warn about trailing comments during parsing
This commit is contained in:
parent
a0d5f40515
commit
228ff0a4ef
1 changed files with 12 additions and 11 deletions
23
src/parse.c
23
src/parse.c
|
|
@ -27,16 +27,25 @@ struct context {
|
||||||
};
|
};
|
||||||
typedef struct context Ctx;
|
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)
|
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;
|
char *trailing = ctx->s + ctx->i;
|
||||||
printf("warning: ignoring %d trailing chars: %s\n", (int)(ctx->n - ctx->i), trailing);
|
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)
|
LakeVal *parse_expr(char *s, size_t n)
|
||||||
{
|
{
|
||||||
Ctx ctx = { s, n, 0, 0 };
|
Ctx ctx = { s, n, 0, 0 };
|
||||||
|
|
@ -64,14 +73,6 @@ LakeList *parse_exprs(char *s, size_t n)
|
||||||
return results;
|
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)
|
LakeList *parse_naked_list(char *s, size_t n)
|
||||||
{
|
{
|
||||||
Ctx ctx = { s, n, 0, 0 };
|
Ctx ctx = { s, n, 0, 0 };
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue