Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nsidorenco committed Jul 28, 2024
1 parent 75be9f8 commit 1deef5d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
52 changes: 52 additions & 0 deletions test/corpus/compiler_directive.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
================================================================================
Expand Down

0 comments on commit 1deef5d

Please sign in to comment.