diff --git a/src/config.c b/src/config.c index f1c8073..c214fb4 100644 --- a/src/config.c +++ b/src/config.c @@ -202,7 +202,7 @@ static int end(void) static int commands(void) { - accept(TOK_NEW_LN); + end(); while (1) { NOT_ACCEPT(TOK_EOF); diff --git a/src/lexer.c b/src/lexer.c index d509085..6ab40c4 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -195,6 +195,18 @@ static int cmp_nextn(Lexer *ctx, int n, char *s) return ((unsigned char)c - *(unsigned char *)s); } +static void ignore_comments(Lexer *ctx) +{ + char c; + + if (peek_char(ctx) != '#') + return; + + do { + c = next_char(ctx); + } while (c != '\n'); +} + static void read_while(Lexer *ctx, Predicate p, int add) { char c; @@ -366,6 +378,7 @@ Token lexer_get_token(Lexer *ctx) return remove_token_queue(ctx); read_while(ctx, isblank, 0); + ignore_comments(ctx); ctx->tok_pos.line = ctx->line; ctx->tok_pos.col = ctx->col;