From 30056c29da99d986ce91945f810ec173ee1562ad Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Tue, 28 Apr 2026 09:54:03 -0300 Subject: [PATCH] Fix: ADD SWITCHER keyword normalization - Root cause: Compiler wasn't converting 'ADD SWITCHER' to 'ADD_SWITCHER' - Impact: Users writing 'ADD SWITCHER' (with space) had keyword fail to parse - Files: botserver/src/basic/compiler/mod.rs (added normalization) - Files: botserver/src/basic/mod.rs (fixed case-sensitive 'AS' check, removed redundant pattern) - Testing: Verified syntax patterns match after normalization --- botserver/src/basic/compiler/mod.rs | 3 ++- botserver/src/basic/mod.rs | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/botserver/src/basic/compiler/mod.rs b/botserver/src/basic/compiler/mod.rs index 2c0bccf8..307ecb7e 100644 --- a/botserver/src/basic/compiler/mod.rs +++ b/botserver/src/basic/compiler/mod.rs @@ -535,7 +535,8 @@ impl BasicCompiler { .replace("GROUP BY", "GROUP_BY") .replace("ADD SUGGESTION TOOL", "ADD_SUGGESTION_TOOL") .replace("ADD SUGGESTION TEXT", "ADD_SUGGESTION_TEXT") - .replace("ADD SUGGESTION", "ADD_SUGGESTION"); + .replace("ADD SUGGESTION", "ADD_SUGGESTION") + .replace("ADD SWITCHER", "ADD_SWITCHER"); if normalized.starts_with("SET SCHEDULE") || trimmed.starts_with("SET SCHEDULE") { has_schedule = true; let parts: Vec<&str> = normalized.split('"').collect(); diff --git a/botserver/src/basic/mod.rs b/botserver/src/basic/mod.rs index d196ee0f..32362c09 100644 --- a/botserver/src/basic/mod.rs +++ b/botserver/src/basic/mod.rs @@ -1323,11 +1323,10 @@ pub fn convert_keywords_to_lowercase(script: &str) -> String { // ADD family - single-token keywords to avoid ADD conflicts (r#"ADD_SUGGESTION_TOOL"#, 2, 2, vec!["tool", "text"]), (r#"ADD_SUGGESTION_TEXT"#, 2, 2, vec!["value", "text"]), -(r#"ADD_SUGGESTION(?!\\s+TOOL|\\s+TEXT|_)"#, 2, 2, vec!["context", "text"]), - (r#"ADD_SWITCHER"#, 2, 2, vec!["switcher", "text"]), - (r#"ADD\s+SWITCHER"#, 2, 2, vec!["switcher", "text"]), - (r#"ADD_MEMBER"#, 2, 2, vec!["name", "role"]), - (r#"ADD\s+MEMBER"#, 2, 2, vec!["name", "role"]), + (r#"ADD_SUGGESTION(?!\\s+TOOL|\\s+TEXT|_)"#, 2, 2, vec!["context", "text"]), + (r#"ADD_SWITCHER"#, 2, 2, vec!["switcher", "text"]), + (r#"ADD_MEMBER"#, 2, 2, vec!["name", "role"]), + (r#"ADD\s+MEMBER"#, 2, 2, vec!["name", "role"]), // CREATE family (r#"CREATE\s+TASK"#, 1, 1, vec!["task"]), @@ -1358,7 +1357,7 @@ pub fn convert_keywords_to_lowercase(script: &str) -> String { if trimmed_upper.contains("ADD_SUGGESTION_TOOL") || trimmed_upper.contains("ADD_SUGGESTION_TEXT") || trimmed_upper.starts_with("ADD_SUGGESTION_") || - (trimmed_upper.starts_with("ADD_SWITCHER") && trimmed.contains(" as ")) || + (trimmed_upper.starts_with("ADD_SWITCHER") && trimmed_upper.contains(" AS ")) || trimmed_upper.starts_with("ADD_MEMBER") || (trimmed_upper.starts_with("CLEAR_SWITCHERS") && trimmed.contains('(')) || (trimmed_upper.starts_with("USE_") && trimmed.contains('(')) {