LanguageRegistry
classin packageklyn.code
public class LanguageRegistry extends Object
└ LanguageRegistry

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"
Inherited Properties
propertyInherited Properties from Object: type
Methods
Modifier and Type Member Description
public static allProfiles
allProfiles() as ArrayList<LanguageProfile>
Returns all registered LanguageProfile descriptors.
public static profileForId
profileForId(idOrAlias as String) as LanguageProfile
Resolves a LanguageProfile by its canonical identifier or common alias (e.g.
public static profileForPath
profileForPath(filePath as String, firstLine as String = "") as LanguageProfile
Resolves a LanguageProfile from a file path, filename, or optional first-line shebang (#!).
public static register
register(profile as LanguageProfile, tokenizer as Tokenizer = null) as Void
Registers a custom or built-in LanguageProfile and its Tokenizer.
public static tokenizerForId
tokenizerForId(idOrAlias as String) as Tokenizer
Resolves a Tokenizer by language ID or extension alias.
public static tokenizerForPath
tokenizerForPath(filePath as String, firstLine as String = "") as Tokenizer
Resolves the appropriate Tokenizer for a file path or #! shebang line.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toMap, toString, toXml