MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / classifyWord

Function classifyWord

packages/core/src/widgets/codeEditorSyntax.ts:914–930  ·  view source on GitHub ↗
(
  word: string,
  scanner: Scanner,
  grammar: LanguageGrammar,
)

Source from the content-addressed store, hash-verified

912}
913
914function classifyWord(
915 word: string,
916 scanner: Scanner,
917 grammar: LanguageGrammar,
918): CodeEditorSyntaxTokenKind {
919 if (grammar.keywords.has(word)) return "keyword";
920 if (grammar.types.has(word)) return "type";
921
922 let lookahead = scanner.index;
923 while (isWhitespace(asChar(scanner.source, lookahead))) {
924 lookahead += 1;
925 }
926 if (asChar(scanner.source, lookahead) === "(") return "function";
927
928 if (/^[A-Z_][A-Z0-9_]{1,}$/.test(word)) return "variable";
929 return "plain";
930}
931
932function tokenizeLineWithGrammar(
933 line: string,

Callers 1

tokenizeLineWithGrammarFunction · 0.85

Calls 3

asCharFunction · 0.85
isWhitespaceFunction · 0.70
hasMethod · 0.45

Tested by

no test coverage detected