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

Function scan_impl

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

Source from the content-addressed store, hash-verified

958}
959
960static bool scan_impl(void *payload, TSLexer *lexer,
961 const bool *valid_symbols) {
962 #ifdef DEBUG
963 {
964 if (valid_symbols[ERROR_SENTINEL]) {
965 LOG("entering tree_sitter_scala_external_scanner_scan. ERROR_SENTINEL is valid\n");
966 } else {
967 char debug_str[1024] = "entering tree_sitter_scala_external_scanner_scan valid symbols: ";
968 for (unsigned i = 0; i < ERROR_SENTINEL; i++) {
969 if (valid_symbols[i]) {
970 strcat(debug_str, token_name[i]);
971 strcat(debug_str, ", ");
972 }
973 }
974 strcat(debug_str, "\n");
975 LOG("%s", debug_str);
976 }
977 }
978 #endif
979
980 // The `>` of a using directive. It is immediate after the `//`, so this has
981 // to run before the blanks are skipped below.
982 if (valid_symbols[USING_DIRECTIVE_START] && !valid_symbols[ERROR_SENTINEL] &&
983 lexer->lookahead == '>') {
984 advance(lexer);
985 lexer->mark_end(lexer);
986 advance_past_blanks(lexer);
987 if (!scan_word(lexer, "using")) {
988 return false;
989 }
990 lexer->result_symbol = USING_DIRECTIVE_START;
991 LOG(" USING_DIRECTIVE_START\n");
992 return true;
993 }
994
995 Scanner *scanner = (Scanner *)payload;
996 int16_t prev = scanner->indents.size > 0 ? *array_back(&scanner->indents) : -1;
997 int16_t prev_width = indent_width(prev);
998 int16_t newline_count = 0;
999 int16_t indentation_size = 0;
1000
1001 while (is_space(lexer->lookahead)) {
1002 if (lexer->lookahead == '\n') {
1003 newline_count++;
1004 indentation_size = 0;
1005 }
1006 else {
1007 indentation_size++;
1008 }
1009 skip(lexer);
1010 }
1011
1012 // COMMA_OUTDENT is a distinct token so tree-sitter only makes it valid
1013 // where comma termination is expected (colon_argument,
1014 // _indentable_expression).
1015 if (valid_symbols[COMMA_OUTDENT] && lexer->lookahead == ',' && prev != -1) {
1016 lexer->mark_end(lexer);
1017 // Error recovery makes every symbol valid, so keep the eager pop there.

Calls 15

advance_past_blanksFunction · 0.85
scan_wordFunction · 0.85
indent_widthFunction · 0.85
is_spaceFunction · 0.85
scan_rest_of_lineFunction · 0.85
at_case_region_widthFunction · 0.85
is_case_clause_introFunction · 0.85
check_comment_at_layoutFunction · 0.85
finish_block_commentFunction · 0.85
read_wordFunction · 0.85
word_inFunction · 0.85

Tested by

no test coverage detected