MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / inline_modifier_follows

Function inline_modifier_follows

codegraph-kernel/grammars/scala/scanner.c:536–566  ·  view source on GitHub ↗

`inline` also prefixes the scrutinee of `inline 1 match`, and it can end a modifier line whose definition is on the next one.

Source from the content-addressed store, hash-verified

534// `inline` also prefixes the scrutinee of `inline 1 match`, and it can end a
535// modifier line whose definition is on the next one.
536static bool inline_modifier_follows(TSLexer *lexer) {
537 if (name_follows_word(lexer)) {
538 return modifier_word_allowed(lexer);
539 }
540 // A scrutinee starts an expression. See canStartExprTokens in the
541 // reference parser.
542 if ((lexer->lookahead >= '0' && lexer->lookahead <= '9') ||
543 lexer->lookahead == '"' || lexer->lookahead == '\'' ||
544 lexer->lookahead == '(' || lexer->lookahead == '{' ||
545 lexer->lookahead == '-') {
546 return true;
547 }
548 if (lexer->lookahead != '\n' && lexer->lookahead != '\r') {
549 return false;
550 }
551 while (is_space(lexer->lookahead)) {
552 advance(lexer);
553 }
554 // Across a line break only a reserved word counts. A soft modifier there
555 // would be a name too, and `val b = inline` followed by such a line is a
556 // value rather than a modifier list.
557 static const char *const definition_starts[] = {
558 "def", "val", "var", "type", "given", "class",
559 "object", "trait", "enum", "final", "lazy", "override",
560 "private", "protected", "sealed", "abstract", "implicit"};
561 char word[sizeof "transparent"];
562 int len = read_word(lexer, word, (int)sizeof word);
563 return len > 0 &&
564 word_in(word, definition_starts,
565 sizeof(definition_starts) / sizeof(definition_starts[0]));
566}
567
568// True when `class` or `object` follows `case`, marking a definition not a
569// clause. Reads the whole word so an identifier like `cobject` is not misread

Callers 1

scan_implFunction · 0.85

Calls 6

name_follows_wordFunction · 0.85
modifier_word_allowedFunction · 0.85
is_spaceFunction · 0.85
read_wordFunction · 0.85
word_inFunction · 0.85
advanceFunction · 0.70

Tested by

no test coverage detected