Skip to content

Commit 6e080c3

Browse files
committed
fix identifiers containing end
1 parent 33b584d commit 6e080c3

File tree

2 files changed

+65
-10
lines changed

2 files changed

+65
-10
lines changed

common/scanner.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -512,16 +512,17 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
512512
advance(lexer);
513513
if (lexer->lookahead == 'd') {
514514
advance(lexer);
515-
if (valid_symbols[END]) {
516-
lexer->mark_end(lexer);
517-
lexer->result_symbol = END;
518-
return true;
519-
} else if (valid_symbols[DEDENT] && scanner->indents.size > 0) {
520-
array_pop(&scanner->indents);
521-
lexer->result_symbol = DEDENT;
522-
return true;
523-
} else {
524-
return false;
515+
if (lexer->lookahead == ' ' || lexer->lookahead == '\n' ||
516+
lexer->eof(lexer)) {
517+
if (valid_symbols[END]) {
518+
lexer->mark_end(lexer);
519+
lexer->result_symbol = END;
520+
return true;
521+
} else if (valid_symbols[DEDENT] && scanner->indents.size > 0) {
522+
array_pop(&scanner->indents);
523+
lexer->result_symbol = DEDENT;
524+
return true;
525+
}
525526
}
526527
}
527528
}

test/corpus/expr.txt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3616,3 +3616,57 @@ let implementer() =
36163616
(unit))
36173617
(const
36183618
(unit)))))))))
3619+
3620+
================================================================================
3621+
scoping issues with end indentifier
3622+
================================================================================
3623+
3624+
let f x =
3625+
x
3626+
|> List.map (fun endpoint ->
3627+
match endpoint with
3628+
| A -> f endpoints)
3629+
|> g
3630+
3631+
--------------------------------------------------------------------------------
3632+
3633+
(file
3634+
(value_declaration
3635+
(function_or_value_defn
3636+
(function_declaration_left
3637+
(identifier)
3638+
(argument_patterns
3639+
(long_identifier
3640+
(identifier))))
3641+
(infix_expression
3642+
(application_expression
3643+
(infix_expression
3644+
(long_identifier_or_op
3645+
(identifier))
3646+
(infix_op)
3647+
(long_identifier_or_op
3648+
(long_identifier
3649+
(identifier)
3650+
(identifier))))
3651+
(paren_expression
3652+
(fun_expression
3653+
(argument_patterns
3654+
(long_identifier
3655+
(identifier)))
3656+
(match_expression
3657+
(long_identifier_or_op
3658+
(identifier))
3659+
(rules
3660+
(rule
3661+
(identifier_pattern
3662+
(long_identifier_or_op
3663+
(identifier)))
3664+
(application_expression
3665+
(long_identifier_or_op
3666+
(identifier))
3667+
(long_identifier_or_op
3668+
(identifier)))))))))
3669+
(infix_op)
3670+
(long_identifier_or_op
3671+
(long_identifier
3672+
(identifier)))))))

0 commit comments

Comments
 (0)