From 7a0224c14c883a7b95af59eb2b28fbef0a4b1b7c Mon Sep 17 00:00:00 2001 From: GiangTran-FinX Date: Mon, 21 Sep 2026 17:35:47 +0700 Subject: [PATCH] Escape `'` in generated dbscheme names `escape_name` maps `"` to `dquote` but leaves `'` untouched, so a grammar whose node types contain a single quote generates an invalid dbscheme identifier. Lua hits this: its `string` node has `'` as a delimiter token, and the generator emits `@lua_string_'`, which the dbscheme parser rejects with ERROR: token recognition error at: ''' No shipped language contains a bare `'` in a node type, which is why this has not surfaced before. Found while building an out-of-tree extractor. Adds the missing mapping and a test covering both string delimiters. --- shared/tree-sitter-extractor/src/node_types.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/shared/tree-sitter-extractor/src/node_types.rs b/shared/tree-sitter-extractor/src/node_types.rs index 2967bc845802..11e4741ae429 100644 --- a/shared/tree-sitter-extractor/src/node_types.rs +++ b/shared/tree-sitter-extractor/src/node_types.rs @@ -386,6 +386,7 @@ fn escape_name(name: &str) -> String { ':' => result.push_str("colon"), ';' => result.push_str("semicolon"), '"' => result.push_str("dquote"), + '\'' => result.push_str("squote"), '*' => result.push_str("star"), '+' => result.push_str("plus"), '-' => result.push_str("minus"), @@ -448,6 +449,14 @@ fn dbscheme_name_to_class_name(dbscheme_name: &str) -> String { .join("") } +#[test] +fn escape_name_quotes_test() { + // Both string delimiters need a name: a grammar whose node types contain + // `'` used to produce the invalid dbscheme identifier `@lang_string_'`. + assert_eq!("dquote", escape_name("\"")); + assert_eq!("squote", escape_name("'")); +} + #[test] fn to_snake_case_test() { assert_eq!("ruby", to_snake_case("Ruby"));