From 5982821b7c05525b74e012b91553261354f081b9 Mon Sep 17 00:00:00 2001 From: Nikolaj Sidorenco Date: Sun, 21 Jul 2024 22:47:48 +0200 Subject: [PATCH] add tests --- src/scanner.c | 10 ++++-- test/corpus/compiler_directive.txt | 52 ++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/scanner.c b/src/scanner.c index 13060a6..9f601cf 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -174,9 +174,13 @@ bool tree_sitter_fsharp_external_scanner_scan(void *payload, TSLexer *lexer, for (;;) { if (lexer->lookahead == '\n') { - if (valid_symbols[NEWLINE] && valid_symbols[IGNORE_INDENT]) { - lexer->result_symbol = NEWLINE; - return true; + if (valid_symbols[IGNORE_INDENT]) { + if (valid_symbols[NEWLINE]) { + lexer->result_symbol = NEWLINE; + return true; + } else { + return false; + } } else { found_end_of_line = true; indent_length = 0; diff --git a/test/corpus/compiler_directive.txt b/test/corpus/compiler_directive.txt index 85d5c27..066b984 100644 --- a/test/corpus/compiler_directive.txt +++ b/test/corpus/compiler_directive.txt @@ -143,6 +143,58 @@ let f = (const (unit))))))) +================================================================================ +light compiler directive directly above expression +================================================================================ + +#light +let x = "a" +let y = 'a'.ToString(); + +if x = y then () else failwith "Failed: 1" + +-------------------------------------------------------------------------------- + +(file + (compiler_directive_decl) + (value_declaration + (function_or_value_defn + (value_declaration_left + (identifier_pattern + (long_identifier_or_op + (identifier)))) + (const + (string)))) + (value_declaration + (function_or_value_defn + (value_declaration_left + (identifier_pattern + (long_identifier_or_op + (identifier)))) + (sequential_expression + (application_expression + (dot_expression + (const + (char)) + (long_identifier_or_op + (identifier)))) + (long_identifier_or_op + (MISSING identifier))))) + (if_expression + (infix_expression + (long_identifier_or_op + (identifier)) + (infix_op) + (long_identifier_or_op + (identifier))) + (const + (unit)) + (application_expression + (long_identifier_or_op + (identifier)) + (const + (string))))) + ================================================================================ preproc_if inside expression block ================================================================================