How a dialect is written (commons lang-sql 0001-sql-langFR-015): a Lexical is data (its comments, quoted identifiers, strings and their prefixes, parameters, operators, keywords and numbers), and compileLexical turns it, once, into the tables the lexer reads: a class for each ASCII character, the rules that can begin at each character, the longest operators first, and a hash table of the keywords. A lexical that cannot be compiled is an error value that names the field.
Every opener, marker and operator must begin with an ASCII character, so that the lexer chooses the rules at a character by one table lookup; a word may hold any character above ASCII.
type CommentSyntax =
| {
readonly kind: "line";
readonly marker: string;
/** Whether the marker is a…(767 characters)
typeCommentSyntax=| {
readonlykind:"line";
readonlymarker:string;
/** Whether the marker is a comment only when white space, a control character or the end of the text follows it (MySQL's `--`). */readonlyspaceAfter?:boolean;
}
| {
readonlykind:"block";
readonlyopen:string;
readonlyclose:string;
/** Whether a comment inside the comment must be closed too (PostgreSQL), or the first `close` ends it (SQLite). */readonlynested:boolean;
/** Whether a comment that begins `open` then `+` is an optimizer hint. */readonlyhints?:boolean;
/** Whether a comment that begins `open` then `!` is a conditional comment (MySQL). */readonlyconditional?:boolean;
};
A kind of comment: a line comment runs from its marker to the end of the line, a block comment from open to close.