Fix: ADD SWITCHER keyword normalization
Some checks are pending
Botlib CI / build (push) Waiting to run
BotServer CI / build (push) Waiting to run
Bottest CI / build (push) Waiting to run
BotUI CI / build (push) Waiting to run

- 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
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-28 09:54:03 -03:00
parent 6083beb248
commit 30056c29da
2 changed files with 7 additions and 7 deletions

View file

@ -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();

View file

@ -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('(')) {