diff options
Diffstat (limited to 'core/lexer.c')
| -rw-r--r-- | core/lexer.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/core/lexer.c b/core/lexer.c index 59aaa13..4f1b4aa 100644 --- a/core/lexer.c +++ b/core/lexer.c @@ -213,6 +213,29 @@ lexer_check_kw(const char *kw, struct token *result) return -1; } +/* + * Skips an entire line, this is useful for comments + * + * @state: Defconf state + */ +static void +lexer_skip_line(struct defconf_state *state) +{ + int c; + + if (state == NULL) { + return; + } + + for (;;) { + c = lexer_nom(state, false); + if (c == EOF) + return; + if (c == '\n') + return; + } +} + int lexer_scan(struct defconf_state *state, struct token *result) { @@ -228,6 +251,19 @@ lexer_scan(struct defconf_state *state, struct token *result) return -1; } + /* Check for single characters */ + switch (c) { + case '/': + /* Is this a comment? */ + if ((c = lexer_nom(state, false)) == '/') { + lexer_skip_line(state); + result->type = TT_COMMENT; + return 0; + } + + break; + } + /* Scan for an identifier */ if ((ident = lexer_scan_ident(state, c)) != NULL) { if (lexer_check_kw(ident, result) == 0) { |
