public class LanguageProfile extends Object
Declarative lexical profile describing the syntax and vocabulary of a programming language.
LanguageProfile stores keyword, type, built-in, constant, and query vocabularies inside HashSet<String> tables for $O(1)$ classification during tokenization, while also retaining ordered lists for completion providers and tooling inspection.
import klyn.code
profile = LanguageProfile("mini", "MiniLang")
profile.withExtensions(["mini"])
profile.withLineComments(["#"])
profile.withKeywords(["if", "else", "def", "return"])
profile.withTypes(["Int", "String"])
assert profile.isKeyword("def")
assert profile.isType("Int")| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | blockCommentEndblockCommentEnd as String |
Closing delimiter for multi-line block comments (e.g. |
| public readonly property | blockCommentStartblockCommentStart as String |
Opening delimiter for multi-line block comments (e.g. |
| public readonly property | builtins | Ordered list of built-in function names. |
| public readonly property | caseInsensitivecaseInsensitive as Boolean |
Indicates whether keyword and type lookups are case-insensitive (e.g. |
| public readonly property | complexityKeywords | Ordered list of cyclomatic complexity decision tokens. |
| public readonly property | constants | Ordered list of language constant literals (such as true, false, null). |
| public readonly property | definitionModedefinitionMode as String |
Structural declaration family ("klyn", "python", "c-like", "javascript", "sql", "markup", "stylesheet"). |
| public readonly property | docCommentEnddocCommentEnd as String |
Closing delimiter for documentation comments. |
| public readonly property | docCommentStartdocCommentStart as String |
Opening delimiter for documentation comments (e.g. |
| public readonly property | extensions | Registered file extensions (without leading dot). |
| public readonly property | filenames | Exact lowercase filenames associated with this language (such as "makefile" or "dockerfile"). |
| public readonly property | idid as String |
Canonical lowercase language identifier. |
| public readonly property | identifierExtraCharsidentifierExtraChars as String |
Additional characters permitted inside identifiers (such as "$" or "-"). |
| public readonly property | isProseisProse as Boolean |
Indicates whether this language represents documentation/data prose rather than executable code. |
| public readonly property | keywords | Ordered list of language keywords. |
| public readonly property | lineCommentlineComment as String |
Primary single-line comment marker, or "" if none is defined. |
| public readonly property | lineComments | Single-line comment prefixes (such as ["#"] or ["//"]). |
| public readonly property | literalDelimiters | Ordered list of character or secondary literal delimiters (e.g. |
| public readonly property | namename as String |
Human-readable display name of the language. |
| public readonly property | nestedBlockCommentsnestedBlockComments as Boolean |
Whether multi-line block comments can be nested. |
| public readonly property | numericLiterals | Ordered list of symbolic numeric literals (such as nan, inf). |
| public readonly property | preprocessorPrefixpreprocessorPrefix as String |
Prefix used for preprocessor directives (such as "#" in C/C++/C#), or "". |
| public readonly property | queryKeywords | Ordered list of contextual query keywords (KQL). |
| public readonly property | queryTypes | Ordered list of contextual query type names (KQL). |
| public readonly property | shebangs | Interpreter names recognized in #! shebang lines. |
| public readonly property | stringDelimiters | Ordered list of string delimiters (longest first, e.g. |
| public readonly property | stringPrefixes | Ordered list of recognized string prefixes (longest first, e.g. |
| public readonly property | supportsAnnotationssupportsAnnotations as Boolean |
Indicates whether @Identifier annotations or decorators are supported. |
| public readonly property | supportsRegexLiteralssupportsRegexLiterals as Boolean |
Indicates whether /pattern/flags regular expression literals are supported. |
| public readonly property | types | Ordered list of built-in type names. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | LanguageProfileLanguageProfile(id as String, name as String = "") |
Constructs a language profile with the given identifier and display name. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | isBuiltin | Checks in $O(1)$ whether word is a registered built-in function of this language. |
| public | isComplexityKeyword | Checks in $O(1)$ whether word is a cyclomatic complexity decision token. |
| public | isConstant | Checks in $O(1)$ whether word is a registered constant literal (true, false, null, etc.). |
| public | isExtraIdentChar | Checks whether ch is included in identifierExtraChars. |
| public | isFormattedPrefix | Checks whether a string prefix enables {...} expression interpolation. |
| public | isKeyword | Checks in $O(1)$ whether word is a registered keyword of this language. |
| public | isNumericLiteral | Checks in $O(1)$ whether word is a symbolic numeric literal (nan, inf, etc.). |
| public | isQueryKeyword | Checks in $O(1)$ whether word is a contextual query keyword. |
| public | isQueryType | Checks in $O(1)$ whether word is a contextual query type name. |
| public | isRawPrefix | Checks whether a string prefix disables backslash escape sequences. |
| public | isType | Checks in $O(1)$ whether word is a registered built-in type of this language. |
| public | withBlockCommentwithBlockComment(startDel as String, endDel as String) as LanguageProfile |
Configures multi-line block comment delimiters. |
| public | withBuiltinswithBuiltins(words as ArrayList<String>) as LanguageProfile |
Registers built-in function names in $O(1)$ lookup tables. |
| public | withCaseInsensitivewithCaseInsensitive(insensitive as Boolean) as LanguageProfile |
Enables or disables case-insensitive keyword/type matching. |
| public | withComplexityKeywordswithComplexityKeywords(words as ArrayList<String>) as LanguageProfile |
Registers cyclomatic complexity decision keywords and operators. |
| public | withConstantswithConstants(words as ArrayList<String>) as LanguageProfile |
Registers language constant literals (e.g. |
| public | withDefinitionModewithDefinitionMode(mode as String) as LanguageProfile |
Sets the structural definition mode for declaration navigation ("klyn", "python", "c-like", etc.). |
| public | withDocCommentwithDocComment(startDel as String, endDel as String) as LanguageProfile |
Configures multi-line documentation comment delimiters. |
| public | withExtensionswithExtensions(extensions as ArrayList<String>) as LanguageProfile |
Registers file extensions for this language profile. |
| public | withFilenameswithFilenames(filenames as ArrayList<String>) as LanguageProfile |
Registers exact filenames for this language profile. |
| public | withFormattedStringPrefixeswithFormattedStringPrefixes(prefixes as ArrayList<String>) as LanguageProfile |
Configures which string prefixes enable {...} interpolation. |
| public | withIdentifierExtraCharswithIdentifierExtraChars(chars as String) as LanguageProfile |
Configures extra characters permitted inside identifiers. |
| public | withKeywordswithKeywords(words as ArrayList<String>) as LanguageProfile |
Registers language keywords in $O(1)$ lookup tables. |
| public | withLineCommentswithLineComments(comments as ArrayList<String>) as LanguageProfile |
Configures single-line comment prefixes. |
| public | withLiteralDelimiterswithLiteralDelimiters(delimiters as ArrayList<String>) as LanguageProfile |
Configures character or secondary literal delimiters (e.g. |
| public | withNestedBlockCommentswithNestedBlockComments(enabled as Boolean) as LanguageProfile |
Enables or disables nested multi-line block comments. |
| public | withNumericLiteralswithNumericLiterals(words as ArrayList<String>) as LanguageProfile |
Registers symbolic numeric literals (such as nan, inf, inff). |
| public | withPreprocessorPrefixwithPreprocessorPrefix(prefix as String) as LanguageProfile |
Configures the preprocessor line prefix (e.g. |
| public | withProsewithProse(prose as Boolean) as LanguageProfile |
Marks this language profile as documentation/prose or executable code. |
| public | withQueryKeywordswithQueryKeywords(words as ArrayList<String>) as LanguageProfile |
Registers contextual query keywords (such as Klyn KQL select, from, where). |
| public | withQueryTypeswithQueryTypes(words as ArrayList<String>) as LanguageProfile |
Registers contextual query type names (such as Klyn KQL Decimal, UUID). |
| public | withRawStringPrefixeswithRawStringPrefixes(prefixes as ArrayList<String>) as LanguageProfile |
Configures which string prefixes disable backslash escaping (raw strings). |
| public | withShebangswithShebangs(shebangs as ArrayList<String>) as LanguageProfile |
Registers #! shebang interpreter names for this language profile. |
| public | withStringDelimiterswithStringDelimiters(delimiters as ArrayList<String>) as LanguageProfile |
Configures string literal delimiters (ordered longest first, e.g. |
| public | withStringPrefixeswithStringPrefixes(prefixes as ArrayList<String>) as LanguageProfile |
Configures recognized string prefixes (ordered longest first). |
| public | withSupportsAnnotationswithSupportsAnnotations(supported as Boolean) as LanguageProfile |
Enables or disables @Annotation / @decorator token recognition. |
| public | withSupportsRegexLiteralswithSupportsRegexLiterals(supported as Boolean) as LanguageProfile |
Enables or disables /.../flags regex literal scanning. |
| public | withTypeswithTypes(words as ArrayList<String>) as LanguageProfile |
Registers built-in type names in $O(1)$ lookup tables. |