// Minimal Shiki / TextMate grammar for the RDBMS Playground *simple-mode* // command language, so docs code blocks fenced as ```rdbms get syntax // highlighting. Advanced-mode examples use the built-in `sql` grammar. // // Keyword/clause vocabulary is taken from the in-app help/usage strings // (`src/friendly/strings/en-US.yaml`) and the command grammar. Matching is // case-insensitive (keywords are case-insensitive in the app; identifiers // are case-preserving and intentionally left unscoped so they read as plain // text against the coloured keywords). // // Two language ids share one grammar: // - `rdbms` — real commands; gets a decorative `> ` prompt via CSS. // - `rdbms-syntax` — abstract syntax templates (with ); same // highlighting, but a distinct `data-language` so the // prompt (scoped to data-language='rdbms') is NOT added. const patterns = [ { include: '#comment' }, { include: '#string' }, { include: '#flag' }, { include: '#number' }, { include: '#constant' }, { include: '#type' }, { include: '#keyword' }, ]; const repository = { comment: { match: '#.*$', name: 'comment.line.number-sign.rdbms', }, string: { name: 'string.quoted.single.rdbms', begin: "'", end: "'", patterns: [{ match: "''", name: 'constant.character.escape.rdbms' }], }, flag: { match: '--[A-Za-z][A-Za-z-]*', name: 'keyword.operator.flag.rdbms', }, number: { match: '\\b[0-9]+(?:\\.[0-9]+)?\\b', name: 'constant.numeric.rdbms', }, constant: { match: '(?i)\\b(true|false|null)\\b', name: 'constant.language.rdbms', }, type: { match: '(?i)\\b(text|int|real|decimal|bool|date|datetime|blob|serial|shortid)\\b', name: 'support.type.rdbms', }, keyword: { match: '(?i)\\b(create|table|tables|drop|add|column|with|pk|to|from|into|values|insert|update|seed|set|where|delete|show|data|rename|change|alter|relationship|relationships|index|indexes|on|as|references|constraint|not|unique|default|check|primary|key|cascade|restrict|and|or|in|between|like|is|explain|replay|undo|redo|save|new|load|rebuild|export|import|copy|mode|help|hint|quit|messages|all|last|types|simple|advanced)\\b', name: 'keyword.control.rdbms', }, }; /** Real simple-mode commands — gets the `> ` prompt (via CSS). */ export default { name: 'rdbms', scopeName: 'source.rdbms', aliases: ['rdbms-playground'], patterns, repository, }; /** Abstract syntax templates — same highlighting, no prompt. */ export const rdbmsSyntax = { name: 'rdbms-syntax', scopeName: 'source.rdbms-syntax', patterns, repository, };