Lotus.Query.Tokenizer.Profile (Lotus v1.2.0)

Copy Markdown View Source

Lexical rules that tell Lotus.Query.Tokenizer which regions of a statement are not code: string literals, quoted identifiers and comments.

A profile does not describe a grammar. It only lists the delimiters the tokenizer must skip so that {{var}} and [[...]] template syntax is recognized in code and never inside a literal or a comment.

Built-in profiles are selected by query language with for_language/1. An adapter that declares a dialect_spec in its editor config can refine a base profile with from_dialect_spec/2, so one declaration drives both the editor's highlighter and the server-side tokenizer.

Summary

Functions

Returns the built-in profile for a query language identifier such as "sql:postgres" or "json:elasticsearch".

Refines base with the lexical keys of an adapter's dialect_spec.

Types

t()

@type t() :: %Lotus.Query.Tokenizer.Profile{
  backslash_escapes?: boolean(),
  block_comments?: boolean(),
  dollar_quotes?: boolean(),
  identifier_quotes: [String.t()],
  line_comments: [String.t()],
  nested_block_comments?: boolean(),
  string_quotes: [String.t()]
}

Functions

for_language(language)

@spec for_language(String.t() | nil) :: t()

Returns the built-in profile for a query language identifier such as "sql:postgres" or "json:elasticsearch".

Unknown languages, unknown SQL dialects and nil get the ANSI SQL profile: single-quoted strings, double-quoted identifiers, -- and /* */ comments.

from_dialect_spec(base, spec)

@spec from_dialect_spec(t(), map() | nil) :: t()

Refines base with the lexical keys of an adapter's dialect_spec.

Recognized keys mirror Lotus.Source.Adapter.dialect_spec/0: :identifier_quotes, :hash_comments, :slash_comments, :double_quoted_strings, :double_dollar_quoted_strings and :backslash_escapes. Other keys are ignored. A nil spec returns base unchanged.