Declarative language definition for syntax highlighting.
Defines what to tokenize (keywords, strings, comments, operators) and how to render each token type (colors, effects).
Colors are resolved through Alaja's theme system (Pote), so values
can be atoms (:blue), hex strings ("#FF0000"), or "theme:key".
Example
%Language{
name: "Python",
line_comment: "#",
strings: [
%{delim: ~r/"""/, end: ~r/"""/, multiline: true, escape: true},
%{delim: ~r/"/, end: ~r/"/, escape: true}
],
number: ~r/\b\d[\d_.]*(e\d+)?\b/,
keywords: MapSet.new(~w(def class if elif else for while return)),
operators: MapSet.new(["==", "!=", "<=", ">=", "->"]),
colors: %{
keyword: {:blue, [:bold]},
string: {:green, []},
comment: {:bright_black, [:italic]}
}
}
Summary
Types
@type t() :: %Alaja.Syntax.Language{ block_comment: map() | nil, case_sensitive: boolean(), colors: map(), keywords: MapSet.t(), line_comment: String.t() | nil, module_separator: String.t(), name: String.t(), number: Regex.t() | nil, operators: MapSet.t(), specials: [map()], strings: [map()], types: MapSet.t() }