What the lexer found wrong: unclosed tags and tags inside literals or quoted identifiers.
The dialect the SQL was read with.
Whether the text holds any template tag.
The input text.
Every token, in input order.
The index of the token that covers offset, or -1 when the offset is outside the text.
The tokens that carry meaning: everything except whitespace, SQL comments and template comments.
StaticLexLexes MJ Query text.
The text, template tags included.
The SQL dialect whose lexical rules read the SQL between tags.
An immutable token stream over MJ Query text: SQL in one dialect, with MJ template tags.
Every character of the input belongs to exactly one token, so joining the tokens' text gives the input back. Spans are UTF-16 offsets. Lexing runs in linear time and never throws.
SQL comments are found first, by the dialect's lexical rules over the raw text, because the render pipeline removes them before the template is evaluated.
{# … #}always opens a template comment and takes precedence over a dialect's#line comment. A tag written inside a SQL comment is inert, stays part of the comment token, and gets anInfodiagnostic. Template tags are then found over the rest of the text, as the template engine finds them. The SQL around the tags is read as though each tag were blank, so a tag inside a string literal or quoted identifier is seen there: the tag records that TemplateTagInfo.SqlContext, and the literal is split into pieces around it, each piece carryingContainsTemplate.