Skip to content

Commit 375b8b1

Browse files
authored
Fix scanner and keyword (#229)
Close #228
1 parent 130cd8e commit 375b8b1

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/scanner.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,11 @@ bool tree_sitter_rescript_external_scanner_scan(
187187
if (lexer->lookahead == 'n') {
188188
advance(lexer);
189189
if (lexer->lookahead == 'd') {
190-
// Ignore new lines before `and` keyword (recursive definition)
191-
in_multiline_statement = true;
190+
advance(lexer);
191+
if (is_whitespace(lexer->lookahead)) {
192+
// Ignore new lines before `and` keyword (recursive definition)
193+
in_multiline_statement = true;
194+
}
192195
}
193196
}
194197
} else if (lexer->lookahead == 'e') {

test/corpus/expressions.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,8 @@ Subscript expressions
16081608

16091609
myArray[42]
16101610
myObj["foo"]
1611+
andd[0]
1612+
andd[1]
16111613

16121614
--------------------------------------------------------------------------------
16131615

@@ -1620,7 +1622,16 @@ myObj["foo"]
16201622
(subscript_expression
16211623
(value_identifier)
16221624
(string
1623-
(string_fragment)))))
1625+
(string_fragment))))
1626+
1627+
(expression_statement
1628+
(subscript_expression
1629+
(value_identifier)
1630+
(number)))
1631+
(expression_statement
1632+
(subscript_expression
1633+
(value_identifier)
1634+
(number))))
16241635

16251636
================================================================================
16261637
Variants

0 commit comments

Comments
 (0)