public class LanguageRegistry extends Object
Central registry and factory for language profiles and tokenizers across the Klyn ecosystem.
LanguageRegistry provides $O(1)$ resolution of LanguageProfile and Tokenizer instances by language ID, file path/extension, exact filename, or #! shebang line. It ships with built-in profiles and tokenizers for Klyn, Java, Python, C/C++, JavaScript, TypeScript, C#, Visual Basic, SQL, HTML, XML, CSS/QSS, JSON, Markdown, Rust, Go, Kotlin, Swift, Shell, YAML, TOML, INI, and Makefile, and supports registering custom languages at runtime.
import klyn.code
klynTok = LanguageRegistry.tokenizerForPath("src/App.kn")
assert klynTok.profile().id == "klyn"
sqlTok = LanguageRegistry.tokenizerForId("sql")
assert sqlTok.profile().id == "sql"| Modifier and Type | Member | Description |
|---|---|---|
| public static | allProfilesallProfiles() as ArrayList<LanguageProfile> |
Returns all registered LanguageProfile descriptors. |
| public static | profileForIdprofileForId(idOrAlias as String) as LanguageProfile |
Resolves a LanguageProfile by its canonical identifier or common alias (e.g. |
| public static | profileForPathprofileForPath(filePath as String, firstLine as String = "") as LanguageProfile |
Resolves a LanguageProfile from a file path, filename, or optional first-line shebang (#!). |
| public static | registerregister(profile as LanguageProfile, tokenizer as Tokenizer = null) as Void |
Registers a custom or built-in LanguageProfile and its Tokenizer. |
| public static | tokenizerForId | Resolves a Tokenizer by language ID or extension alias. |
| public static | tokenizerForPath | Resolves the appropriate Tokenizer for a file path or #! shebang line. |