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

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")
Properties
Modifier and Type Member Description
public readonly property blockCommentEnd
blockCommentEnd as String
Closing delimiter for multi-line block comments (e.g.
public readonly property blockCommentStart
blockCommentStart as String
Opening delimiter for multi-line block comments (e.g.
public readonly property builtins
builtins as ArrayList<String>
Ordered list of built-in function names.
public readonly property caseInsensitive
caseInsensitive as Boolean
Indicates whether keyword and type lookups are case-insensitive (e.g.
public readonly property complexityKeywords
complexityKeywords as ArrayList<String>
Ordered list of cyclomatic complexity decision tokens.
public readonly property constants
constants as ArrayList<String>
Ordered list of language constant literals (such as true, false, null).
public readonly property definitionMode
definitionMode as String
Structural declaration family ("klyn", "python", "c-like", "javascript", "sql", "markup", "stylesheet").
public readonly property docCommentEnd
docCommentEnd as String
Closing delimiter for documentation comments.
public readonly property docCommentStart
docCommentStart as String
Opening delimiter for documentation comments (e.g.
public readonly property extensions
extensions as ArrayList<String>
Registered file extensions (without leading dot).
public readonly property filenames
filenames as ArrayList<String>
Exact lowercase filenames associated with this language (such as "makefile" or "dockerfile").
public readonly property id
id as String
Canonical lowercase language identifier.
public readonly property identifierExtraChars
identifierExtraChars as String
Additional characters permitted inside identifiers (such as "$" or "-").
public readonly property isProse
isProse as Boolean
Indicates whether this language represents documentation/data prose rather than executable code.
public readonly property keywords
keywords as ArrayList<String>
Ordered list of language keywords.
public readonly property lineComment
lineComment as String
Primary single-line comment marker, or "" if none is defined.
public readonly property lineComments
lineComments as ArrayList<String>
Single-line comment prefixes (such as ["#"] or ["//"]).
public readonly property literalDelimiters
literalDelimiters as ArrayList<String>
Ordered list of character or secondary literal delimiters (e.g.
public readonly property name
name as String
Human-readable display name of the language.
public readonly property nestedBlockComments
nestedBlockComments as Boolean
Whether multi-line block comments can be nested.
public readonly property numericLiterals
numericLiterals as ArrayList<String>
Ordered list of symbolic numeric literals (such as nan, inf).
public readonly property preprocessorPrefix
preprocessorPrefix as String
Prefix used for preprocessor directives (such as "#" in C/C++/C#), or "".
public readonly property queryKeywords
queryKeywords as ArrayList<String>
Ordered list of contextual query keywords (KQL).
public readonly property queryTypes
queryTypes as ArrayList<String>
Ordered list of contextual query type names (KQL).
public readonly property shebangs
shebangs as ArrayList<String>
Interpreter names recognized in #! shebang lines.
public readonly property stringDelimiters
stringDelimiters as ArrayList<String>
Ordered list of string delimiters (longest first, e.g.
public readonly property stringPrefixes
stringPrefixes as ArrayList<String>
Ordered list of recognized string prefixes (longest first, e.g.
public readonly property supportsAnnotations
supportsAnnotations as Boolean
Indicates whether @Identifier annotations or decorators are supported.
public readonly property supportsRegexLiterals
supportsRegexLiterals as Boolean
Indicates whether /pattern/flags regular expression literals are supported.
public readonly property types
types as ArrayList<String>
Ordered list of built-in type names.
Inherited Properties
propertyInherited Properties from Object: type
Constructors
Modifier and Type Member Description
public LanguageProfile
LanguageProfile(id as String, name as String = "")
Constructs a language profile with the given identifier and display name.
Methods
Modifier and Type Member Description
public isBuiltin
isBuiltin(word as String) as Boolean
Checks in $O(1)$ whether word is a registered built-in function of this language.
public isComplexityKeyword
isComplexityKeyword(word as String) as Boolean
Checks in $O(1)$ whether word is a cyclomatic complexity decision token.
public isConstant
isConstant(word as String) as Boolean
Checks in $O(1)$ whether word is a registered constant literal (true, false, null, etc.).
public isExtraIdentChar
isExtraIdentChar(ch as Char) as Boolean
Checks whether ch is included in identifierExtraChars.
public isFormattedPrefix
isFormattedPrefix(prefix as String) as Boolean
Checks whether a string prefix enables {...} expression interpolation.
public isKeyword
isKeyword(word as String) as Boolean
Checks in $O(1)$ whether word is a registered keyword of this language.
public isNumericLiteral
isNumericLiteral(word as String) as Boolean
Checks in $O(1)$ whether word is a symbolic numeric literal (nan, inf, etc.).
public isQueryKeyword
isQueryKeyword(word as String) as Boolean
Checks in $O(1)$ whether word is a contextual query keyword.
public isQueryType
isQueryType(word as String) as Boolean
Checks in $O(1)$ whether word is a contextual query type name.
public isRawPrefix
isRawPrefix(prefix as String) as Boolean
Checks whether a string prefix disables backslash escape sequences.
public isType
isType(word as String) as Boolean
Checks in $O(1)$ whether word is a registered built-in type of this language.
public withBlockComment
withBlockComment(startDel as String, endDel as String) as LanguageProfile
Configures multi-line block comment delimiters.
public withBuiltins
withBuiltins(words as ArrayList<String>) as LanguageProfile
Registers built-in function names in $O(1)$ lookup tables.
public withCaseInsensitive
withCaseInsensitive(insensitive as Boolean) as LanguageProfile
Enables or disables case-insensitive keyword/type matching.
public withComplexityKeywords
withComplexityKeywords(words as ArrayList<String>) as LanguageProfile
Registers cyclomatic complexity decision keywords and operators.
public withConstants
withConstants(words as ArrayList<String>) as LanguageProfile
Registers language constant literals (e.g.
public withDefinitionMode
withDefinitionMode(mode as String) as LanguageProfile
Sets the structural definition mode for declaration navigation ("klyn", "python", "c-like", etc.).
public withDocComment
withDocComment(startDel as String, endDel as String) as LanguageProfile
Configures multi-line documentation comment delimiters.
public withExtensions
withExtensions(extensions as ArrayList<String>) as LanguageProfile
Registers file extensions for this language profile.
public withFilenames
withFilenames(filenames as ArrayList<String>) as LanguageProfile
Registers exact filenames for this language profile.
public withFormattedStringPrefixes
withFormattedStringPrefixes(prefixes as ArrayList<String>) as LanguageProfile
Configures which string prefixes enable {...} interpolation.
public withIdentifierExtraChars
withIdentifierExtraChars(chars as String) as LanguageProfile
Configures extra characters permitted inside identifiers.
public withKeywords
withKeywords(words as ArrayList<String>) as LanguageProfile
Registers language keywords in $O(1)$ lookup tables.
public withLineComments
withLineComments(comments as ArrayList<String>) as LanguageProfile
Configures single-line comment prefixes.
public withLiteralDelimiters
withLiteralDelimiters(delimiters as ArrayList<String>) as LanguageProfile
Configures character or secondary literal delimiters (e.g.
public withNestedBlockComments
withNestedBlockComments(enabled as Boolean) as LanguageProfile
Enables or disables nested multi-line block comments.
public withNumericLiterals
withNumericLiterals(words as ArrayList<String>) as LanguageProfile
Registers symbolic numeric literals (such as nan, inf, inff).
public withPreprocessorPrefix
withPreprocessorPrefix(prefix as String) as LanguageProfile
Configures the preprocessor line prefix (e.g.
public withProse
withProse(prose as Boolean) as LanguageProfile
Marks this language profile as documentation/prose or executable code.
public withQueryKeywords
withQueryKeywords(words as ArrayList<String>) as LanguageProfile
Registers contextual query keywords (such as Klyn KQL select, from, where).
public withQueryTypes
withQueryTypes(words as ArrayList<String>) as LanguageProfile
Registers contextual query type names (such as Klyn KQL Decimal, UUID).
public withRawStringPrefixes
withRawStringPrefixes(prefixes as ArrayList<String>) as LanguageProfile
Configures which string prefixes disable backslash escaping (raw strings).
public withShebangs
withShebangs(shebangs as ArrayList<String>) as LanguageProfile
Registers #! shebang interpreter names for this language profile.
public withStringDelimiters
withStringDelimiters(delimiters as ArrayList<String>) as LanguageProfile
Configures string literal delimiters (ordered longest first, e.g.
public withStringPrefixes
withStringPrefixes(prefixes as ArrayList<String>) as LanguageProfile
Configures recognized string prefixes (ordered longest first).
public withSupportsAnnotations
withSupportsAnnotations(supported as Boolean) as LanguageProfile
Enables or disables @Annotation / @decorator token recognition.
public withSupportsRegexLiterals
withSupportsRegexLiterals(supported as Boolean) as LanguageProfile
Enables or disables /.../flags regex literal scanning.
public withTypes
withTypes(words as ArrayList<String>) as LanguageProfile
Registers built-in type names in $O(1)$ lookup tables.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toMap, toString, toXml