From 522db28910da154b88a7308db0d11d9f7308a191 Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Sat, 11 Apr 2026 16:39:57 -0400 Subject: [PATCH 1/2] playground: update pgsql monarch language with codegen'd keywords --- crates/xtask/src/codegen.rs | 12 + playground/src/generated/keywords.ts | 516 +++++++++++++++++++++++++++ playground/src/pgsql.ts | 106 +----- 3 files changed, 531 insertions(+), 103 deletions(-) create mode 100644 playground/src/generated/keywords.ts diff --git a/crates/xtask/src/codegen.rs b/crates/xtask/src/codegen.rs index 2f78d3bc..2cbc9b06 100644 --- a/crates/xtask/src/codegen.rs +++ b/crates/xtask/src/codegen.rs @@ -83,6 +83,11 @@ pub(crate) fn codegen() -> Result<()> { update_textmate_keywords(&keyword_kinds.all_keywords)?; + let playground_keywords = generate_playground_keywords(&keyword_kinds.all_keywords)?; + let playground_keywords_file = project_root().join("playground/src/generated/keywords.ts"); + std::fs::write(playground_keywords_file, playground_keywords) + .context("problem writing playground keywords")?; + let kinds = generate_kind_src(&ast_src.nodes, &grammar, keyword_kinds.all_keywords); let syntax_kinds = generate_syntax_kinds(kinds)?; @@ -956,6 +961,13 @@ fn keywords_match(all_keywords: &[String]) -> String { format!("(?xi)\\b({keywords_joined})\\b") } +fn generate_playground_keywords(all_keywords: &[String]) -> Result { + let keywords_json = serde_json::to_string_pretty(all_keywords)?; + Ok(format!( + "{PRELUDE}export const keywords = {keywords_json} as const\n" + )) +} + fn update_textmate_keywords(all_keywords: &[String]) -> Result<()> { let tmlanguage_path = project_root().join("squawk-vscode/syntaxes/pgsql.tmLanguage.json"); let content = std::fs::read_to_string(&tmlanguage_path)?; diff --git a/playground/src/generated/keywords.ts b/playground/src/generated/keywords.ts new file mode 100644 index 00000000..0f578998 --- /dev/null +++ b/playground/src/generated/keywords.ts @@ -0,0 +1,516 @@ +// Generated via: +// cargo xtask codegen + +export const keywords = [ + "abort", + "absent", + "absolute", + "access", + "action", + "add", + "admin", + "after", + "aggregate", + "all", + "also", + "alter", + "always", + "analyse", + "analyze", + "and", + "any", + "array", + "as", + "asc", + "asensitive", + "assertion", + "assignment", + "asymmetric", + "at", + "atomic", + "attach", + "attribute", + "authorization", + "backward", + "before", + "begin", + "between", + "bigint", + "binary", + "bit", + "boolean", + "both", + "breadth", + "by", + "cache", + "call", + "called", + "cascade", + "cascaded", + "case", + "cast", + "catalog", + "chain", + "char", + "character", + "characteristics", + "check", + "checkpoint", + "class", + "close", + "cluster", + "coalesce", + "collate", + "collation", + "column", + "columns", + "comment", + "comments", + "commit", + "committed", + "compression", + "concurrently", + "conditional", + "configuration", + "conflict", + "connection", + "constraint", + "constraints", + "content", + "continue", + "conversion", + "copy", + "cost", + "create", + "cross", + "csv", + "cube", + "current", + "current_catalog", + "current_date", + "current_role", + "current_schema", + "current_time", + "current_timestamp", + "current_user", + "cursor", + "cycle", + "data", + "database", + "day", + "deallocate", + "dec", + "decimal", + "declare", + "default", + "defaults", + "deferrable", + "deferred", + "definer", + "delete", + "delimiter", + "delimiters", + "depends", + "depth", + "desc", + "destination", + "detach", + "dictionary", + "disable", + "discard", + "distinct", + "do", + "document", + "domain", + "double", + "drop", + "each", + "edge", + "else", + "empty", + "enable", + "encoding", + "encrypted", + "end", + "enforced", + "enum", + "error", + "escape", + "event", + "except", + "exclude", + "excluding", + "exclusive", + "execute", + "exists", + "explain", + "expression", + "extension", + "external", + "extract", + "false", + "family", + "fetch", + "filter", + "finalize", + "first", + "float", + "following", + "for", + "force", + "foreign", + "format", + "forward", + "freeze", + "from", + "full", + "function", + "functions", + "generated", + "global", + "grant", + "granted", + "graph", + "graph_table", + "greatest", + "group", + "grouping", + "groups", + "handler", + "having", + "header", + "hold", + "hour", + "identity", + "if", + "ignore", + "ilike", + "immediate", + "immutable", + "implicit", + "import", + "in", + "include", + "including", + "increment", + "indent", + "index", + "indexes", + "inherit", + "inherits", + "initially", + "inline", + "inner", + "inout", + "input", + "insensitive", + "insert", + "instead", + "int", + "integer", + "intersect", + "interval", + "into", + "invoker", + "is", + "isnull", + "isolation", + "join", + "json", + "json_array", + "json_arrayagg", + "json_exists", + "json_object", + "json_objectagg", + "json_query", + "json_scalar", + "json_serialize", + "json_table", + "json_value", + "keep", + "key", + "keys", + "label", + "language", + "large", + "last", + "lateral", + "leading", + "leakproof", + "least", + "left", + "level", + "like", + "limit", + "listen", + "load", + "local", + "localtime", + "localtimestamp", + "location", + "lock", + "locked", + "logged", + "lsn", + "mapping", + "match", + "matched", + "materialized", + "maxvalue", + "merge", + "merge_action", + "method", + "minute", + "minvalue", + "mode", + "month", + "move", + "name", + "names", + "national", + "natural", + "nchar", + "nested", + "new", + "next", + "nfc", + "nfd", + "nfkc", + "nfkd", + "no", + "node", + "none", + "normalize", + "normalized", + "not", + "nothing", + "notify", + "notnull", + "nowait", + "null", + "nullif", + "nulls", + "numeric", + "object", + "objects", + "of", + "off", + "offset", + "oids", + "old", + "omit", + "on", + "only", + "operator", + "option", + "options", + "or", + "order", + "ordinality", + "others", + "out", + "outer", + "over", + "overlaps", + "overlay", + "overriding", + "owned", + "owner", + "parallel", + "parameter", + "parser", + "partial", + "partition", + "partitions", + "passing", + "password", + "path", + "period", + "placing", + "plan", + "plans", + "policy", + "portion", + "position", + "preceding", + "precision", + "prepare", + "prepared", + "preserve", + "primary", + "prior", + "privileges", + "procedural", + "procedure", + "procedures", + "program", + "properties", + "property", + "publication", + "quote", + "quotes", + "range", + "read", + "real", + "reassign", + "recursive", + "ref", + "references", + "referencing", + "refresh", + "reindex", + "relationship", + "relative", + "release", + "rename", + "repack", + "repeatable", + "replace", + "replica", + "reset", + "respect", + "restart", + "restrict", + "return", + "returning", + "returns", + "revoke", + "right", + "role", + "rollback", + "rollup", + "routine", + "routines", + "row", + "rows", + "rule", + "savepoint", + "scalar", + "schema", + "schemas", + "scroll", + "search", + "second", + "security", + "select", + "sequence", + "sequences", + "serializable", + "server", + "session", + "session_user", + "set", + "setof", + "sets", + "share", + "show", + "similar", + "simple", + "skip", + "smallint", + "snapshot", + "some", + "source", + "split", + "sql", + "stable", + "standalone", + "start", + "statement", + "statistics", + "stdin", + "stdout", + "storage", + "stored", + "strict", + "string", + "strip", + "subscription", + "substring", + "support", + "symmetric", + "sysid", + "system", + "system_user", + "table", + "tables", + "tablesample", + "tablespace", + "target", + "temp", + "template", + "temporary", + "text", + "then", + "ties", + "time", + "timestamp", + "to", + "trailing", + "transaction", + "transform", + "treat", + "trigger", + "trim", + "true", + "truncate", + "trusted", + "type", + "types", + "uescape", + "unbounded", + "uncommitted", + "unconditional", + "unencrypted", + "union", + "unique", + "unknown", + "unlisten", + "unlogged", + "until", + "update", + "user", + "using", + "vacuum", + "valid", + "validate", + "validator", + "value", + "values", + "varchar", + "variadic", + "varying", + "verbose", + "version", + "vertex", + "view", + "views", + "virtual", + "volatile", + "wait", + "when", + "where", + "whitespace", + "window", + "with", + "within", + "without", + "work", + "wrapper", + "write", + "xml", + "xmlattributes", + "xmlconcat", + "xmlelement", + "xmlexists", + "xmlforest", + "xmlnamespaces", + "xmlparse", + "xmlpi", + "xmlroot", + "xmlserialize", + "xmltable", + "year", + "yes", + "zone" +] as const diff --git a/playground/src/pgsql.ts b/playground/src/pgsql.ts index 1f802bbe..dd61161b 100644 --- a/playground/src/pgsql.ts +++ b/playground/src/pgsql.ts @@ -25,6 +25,8 @@ SOFTWARE. // Vendored from monaco-editor/src/basic-languages/pgsql/pgsql.ts import type * as monaco from "monaco-editor" +import { keywords } from "./generated/keywords" + export const language = { defaultToken: "", tokenPostfix: ".sql", @@ -35,109 +37,7 @@ export const language = { { open: "(", close: ")", token: "delimiter.parenthesis" }, ], - keywords: [ - // This list is generated using `keywords.js` - "ALL", - "ANALYSE", - "ANALYZE", - "AND", - "ANY", - "ARRAY", - "AS", - "ASC", - "ASYMMETRIC", - "AUTHORIZATION", - "BINARY", - "BOTH", - "CASE", - "CAST", - "CHECK", - "COLLATE", - "COLLATION", - "COLUMN", - "CONCURRENTLY", - "CONSTRAINT", - "CREATE", - "CROSS", - "CURRENT_CATALOG", - "CURRENT_DATE", - "CURRENT_ROLE", - "CURRENT_SCHEMA", - "CURRENT_TIME", - "CURRENT_TIMESTAMP", - "CURRENT_USER", - "DEFAULT", - "DEFERRABLE", - "DESC", - "DISTINCT", - "DO", - "ELSE", - "END", - "EXCEPT", - "FALSE", - "FETCH", - "FOR", - "FOREIGN", - "FREEZE", - "FROM", - "FULL", - "GRANT", - "GROUP", - "HAVING", - "ILIKE", - "IN", - "INITIALLY", - "INNER", - "INTERSECT", - "INTO", - "IS", - "ISNULL", - "JOIN", - "LATERAL", - "LEADING", - "LEFT", - "LIKE", - "LIMIT", - "LOCALTIME", - "LOCALTIMESTAMP", - "NATURAL", - "NOT", - "NOTNULL", - "NULL", - "OFFSET", - "ON", - "ONLY", - "OR", - "ORDER", - "OUTER", - "OVERLAPS", - "PLACING", - "PRIMARY", - "REFERENCES", - "RETURNING", - "RIGHT", - "SELECT", - "SESSION_USER", - "SIMILAR", - "SOME", - "SYMMETRIC", - "TABLE", - "TABLESAMPLE", - "THEN", - "TO", - "TRAILING", - "TRUE", - "UNION", - "UNIQUE", - "USER", - "USING", - "VARIADIC", - "VERBOSE", - "WHEN", - "WHERE", - "WINDOW", - "WITH", - ], + keywords, operators: [ "AND", "BETWEEN", From b39ec20db662a0aed13c45127fc4cd149e400b8e Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Sat, 11 Apr 2026 16:41:00 -0400 Subject: [PATCH 2/2] fix --- playground/src/generated/keywords.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playground/src/generated/keywords.ts b/playground/src/generated/keywords.ts index 0f578998..3003a8de 100644 --- a/playground/src/generated/keywords.ts +++ b/playground/src/generated/keywords.ts @@ -512,5 +512,5 @@ export const keywords = [ "xmltable", "year", "yes", - "zone" + "zone", ] as const