public class RustTokenizer extends CodeTokenizer
Specialized CodeTokenizer for Rust source files (.rs).
Supports Rust attributes (#[derive(...)], #![allow(...)]), lifetime annotations ('a, 'static, '_) distinguished from character literals ('x', '\n', b'x'), macro invocations (println!, vec!), numeric type suffixes (42usize, 100_u128, 3.5f64), /// and //! documentation comments, and nested block comments.
import klyn.code
import klyn.code.rust
tokenizer = RustTokenizer()
res = tokenizer.tokenizeLine("pub fn borrow<'a>(input: &'a str) -> &'a str { input }")
assert res.spans[0].kind == TokenKind.KEYWORD| Modifier and Type | Member | Description |
|---|---|---|
| public | RustTokenizer | Constructs a RustTokenizer configured with RustLanguage.profile(). |
| Modifier and Type | Member | Description |
|---|---|---|
| public override | classifyIdentifier | Classifies Rust identifiers, recognizing macro invocations (ident!), type / mod declarations, associated types, and :: path segments. |
| public override | tokenizeLinetokenizeLine(line as String, initialState as LexicalState = null) as LineScanResult |
Tokenizes a single line of Rust source code, handling #[...] / #![...] attributes, /// / //! doc comments, and 'lifetime annotations without misclassifying them as unclosed character literals. |