Skip to content

Commit

Permalink
fix identifiers containing end
Browse files Browse the repository at this point in the history
  • Loading branch information
Nsidorenco committed Sep 9, 2024
1 parent 33b584d commit 6e080c3
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 10 deletions.
21 changes: 11 additions & 10 deletions common/scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,16 +512,17 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
advance(lexer);
if (lexer->lookahead == 'd') {
advance(lexer);
if (valid_symbols[END]) {
lexer->mark_end(lexer);
lexer->result_symbol = END;
return true;
} else if (valid_symbols[DEDENT] && scanner->indents.size > 0) {
array_pop(&scanner->indents);
lexer->result_symbol = DEDENT;
return true;
} else {
return false;
if (lexer->lookahead == ' ' || lexer->lookahead == '\n' ||
lexer->eof(lexer)) {
if (valid_symbols[END]) {
lexer->mark_end(lexer);
lexer->result_symbol = END;
return true;
} else if (valid_symbols[DEDENT] && scanner->indents.size > 0) {
array_pop(&scanner->indents);
lexer->result_symbol = DEDENT;
return true;
}
}
}
}
Expand Down
54 changes: 54 additions & 0 deletions test/corpus/expr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3616,3 +3616,57 @@ let implementer() =
(unit))
(const
(unit)))))))))

================================================================================
scoping issues with end indentifier
================================================================================

let f x =
x
|> List.map (fun endpoint ->
match endpoint with
| A -> f endpoints)
|> g

--------------------------------------------------------------------------------

(file
(value_declaration
(function_or_value_defn
(function_declaration_left
(identifier)
(argument_patterns
(long_identifier
(identifier))))
(infix_expression
(application_expression
(infix_expression
(long_identifier_or_op
(identifier))
(infix_op)
(long_identifier_or_op
(long_identifier
(identifier)
(identifier))))
(paren_expression
(fun_expression
(argument_patterns
(long_identifier
(identifier)))
(match_expression
(long_identifier_or_op
(identifier))
(rules
(rule
(identifier_pattern
(long_identifier_or_op
(identifier)))
(application_expression
(long_identifier_or_op
(identifier))
(long_identifier_or_op
(identifier)))))))))
(infix_op)
(long_identifier_or_op
(long_identifier
(identifier)))))))

0 comments on commit 6e080c3

Please sign in to comment.