commit 2eb08459e47cccd6938a04bb08f2f09cc68e7b09 parent 9b07f8b452c18d654cb26c509ba4fc465504949a Author: Ryan Sepassi <rsepassi@gmail.com> Date: Wed, 20 May 2026 19:58:07 -0700 toy: support // line comments toy_skip_ws now consumes // through end-of-line in addition to whitespace. Block comments deferred. Test corpus prose can now sit next to the code it describes. Diffstat:
| M | lang/toy/lexer.c | | | 14 | +++++++++++--- |
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/lang/toy/lexer.c b/lang/toy/lexer.c @@ -31,9 +31,17 @@ static void toy_lexer_advance_line(ToyLexer* lex) { } static void toy_skip_ws(ToyLexer* lex) { - while (lex->cur < lex->end && toy_is_space(*lex->cur)) { - if (*lex->cur == '\n') toy_lexer_advance_line(lex); - lex->cur++; + for (;;) { + while (lex->cur < lex->end && toy_is_space(*lex->cur)) { + if (*lex->cur == '\n') toy_lexer_advance_line(lex); + lex->cur++; + } + if (lex->cur + 1 < lex->end && lex->cur[0] == '/' && lex->cur[1] == '/') { + lex->cur += 2; + while (lex->cur < lex->end && *lex->cur != '\n') lex->cur++; + continue; + } + break; } }