diff --git a/corpus/definitions.txt b/corpus/definitions.txt index 0329b68e1..dfffe2454 100644 --- a/corpus/definitions.txt +++ b/corpus/definitions.txt @@ -502,7 +502,9 @@ class A ================================================================================ Class definitions (Scala 3) ================================================================================ -final case class C() extends A derives B, C.D +final case class C() + extends A + derives B, C.D -------------------------------------------------------------------------------- (compilation_unit diff --git a/grammar.js b/grammar.js index fc62031b9..653517a07 100644 --- a/grammar.js +++ b/grammar.js @@ -42,6 +42,7 @@ module.exports = grammar({ "catch", "finally", "extends", + "derives", "with", ], diff --git a/script/smoke_test.sh b/script/smoke_test.sh index b8ced8e91..b374cd0c0 100755 --- a/script/smoke_test.sh +++ b/script/smoke_test.sh @@ -5,7 +5,7 @@ SCALA_SCALA_LIBRARY_EXPECTED=100 SCALA_SCALA_COMPILER_EXPECTED=96 DOTTY_COMPILER_EXPECTED=84 -SYNTAX_COMPLEXITY_CEILING=1300 +SYNTAX_COMPLEXITY_CEILING=1400 if [ ! -d "$SCALA_SCALA_DIR" ]; then echo "\$SCALA_SCALA_DIR must be set" diff --git a/src/scanner.c b/src/scanner.c index 52a334fb4..b20bd0273 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -18,6 +18,7 @@ enum TokenType { CATCH, FINALLY, EXTENDS, + DERIVES, WITH, }; @@ -255,25 +256,33 @@ bool tree_sitter_scala_external_scanner_scan(void *payload, TSLexer *lexer, } if (valid_symbols[CATCH]) { - if (lexer->lookahead == 'c') { - return !scan_word(lexer, "catch"); - } - if (lexer->lookahead == 'f') { - return !scan_word(lexer, "finally"); + if (scan_word(lexer, "catch")) { + return false; } - return true; } if (valid_symbols[FINALLY]) { - return !scan_word(lexer, "finally"); + if (scan_word(lexer, "finally")) { + return false; + } } if (valid_symbols[EXTENDS]) { - return !scan_word(lexer, "extends"); + if (scan_word(lexer, "extends")) { + return false; + } } if (valid_symbols[WITH]) { - return !scan_word(lexer, "with"); + if (scan_word(lexer, "with")) { + return false; + } + } + + if (valid_symbols[DERIVES]) { + if (scan_word(lexer, "derives")) { + return false; + } } if (newline_count > 1) {