mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2024-11-24 13:53:07 +01:00
Add support for comments in config
This commit is contained in:
parent
0d5c32baf5
commit
f0204c359e
@ -202,7 +202,7 @@ static int end(void)
|
|||||||
|
|
||||||
static int commands(void)
|
static int commands(void)
|
||||||
{
|
{
|
||||||
accept(TOK_NEW_LN);
|
end();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
NOT_ACCEPT(TOK_EOF);
|
NOT_ACCEPT(TOK_EOF);
|
||||||
|
13
src/lexer.c
13
src/lexer.c
@ -195,6 +195,18 @@ static int cmp_nextn(Lexer *ctx, int n, char *s)
|
|||||||
return ((unsigned char)c - *(unsigned 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)
|
static void read_while(Lexer *ctx, Predicate p, int add)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
@ -366,6 +378,7 @@ Token lexer_get_token(Lexer *ctx)
|
|||||||
return remove_token_queue(ctx);
|
return remove_token_queue(ctx);
|
||||||
|
|
||||||
read_while(ctx, isblank, 0);
|
read_while(ctx, isblank, 0);
|
||||||
|
ignore_comments(ctx);
|
||||||
|
|
||||||
ctx->tok_pos.line = ctx->line;
|
ctx->tok_pos.line = ctx->line;
|
||||||
ctx->tok_pos.col = ctx->col;
|
ctx->tok_pos.col = ctx->col;
|
||||||
|
Loading…
Reference in New Issue
Block a user