From 751929a0586f3cd79262f3ce0edd9aa971777761 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 2 Jun 2022 22:27:00 +0200 Subject: [PATCH] Fix whitespace skipping in scanner Once again, implicit fall-through is the devil. --- src/scanner.c | 1 + test/corpus/comments.txt | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/scanner.c b/src/scanner.c index 8b19246..1e73721 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -29,6 +29,7 @@ static void skip_whitespace(TSLexer *lexer) { case '\n': case '\r': lexer->advance(lexer, true); + break; default: return; } diff --git a/test/corpus/comments.txt b/test/corpus/comments.txt index e7375fe..62f2cc7 100644 --- a/test/corpus/comments.txt +++ b/test/corpus/comments.txt @@ -42,7 +42,6 @@ Comment with slashes (source_file (comment)) - ================================================================================ Comment with asterisks ================================================================================ @@ -90,3 +89,42 @@ Comment end-delimiter only (ERROR (operator) (operator))) + +================================================================================ +Comment in real code +================================================================================ +let + /* This is a comment */ + var a := 12 + /* This is an other comment */ + var b := 27 + /* Yet another comment */ +in + /* This is the final comment */ + (a + b) <> 42 + /* Sike! This is the *actual* final comment */ +end + +-------------------------------------------------------------------------------- + +(source_file + (let_expression + (comment) + (variable_declaration + (identifier) + (integer_literal)) + (comment) + (variable_declaration + (identifier) + (integer_literal)) + (comment) + (comment) + (binary_expression + (sequence_expression + (binary_expression + (identifier) + (operator) + (identifier))) + (operator) + (integer_literal)) + (comment)))