( word: string, scanner: Scanner, grammar: LanguageGrammar, )
| 912 | } |
| 913 | |
| 914 | function 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 | |
| 932 | function tokenizeLineWithGrammar( |
| 933 | line: string, |
no test coverage detected