tokenizeCode()
Updated 10 Nov 2026
tokenizeCode(source, language?): Token[]
Defined in: tokenizer.ts:986
Tokenizes entire code block string into a flat token list. Adheres to fundamental compiler lexical precedence:
- Whitespace & universal newlines (\r\n, \n, standalone \r)
- Comments (line & block)
- Strings & prefixed literals (e.g. f"...", r"...",
...) - Context-sensitive RegExp literals (JavaScript)
- Numbers (hex, binary, float, bigint, complex, CSS hex colors)
- Identifiers + O(1) Set classifications (keywords, builtins, booleans, functions)
- Operators (longest match first) & Punctuation
- Fallback character preservation
Parameters
source
string
language?
string
Returns
Token[]