diff --git a/src/parser_keywords.rs b/src/parser_keywords.rs index ffc59353f..3cb110b2f 100644 --- a/src/parser_keywords.rs +++ b/src/parser_keywords.rs @@ -4,6 +4,7 @@ struct ReservedWord { text: &'static wstr, + is_reserved: bool, is_super_command: bool, } @@ -11,12 +12,21 @@ macro_rules! rw { ( ( $text:literal ) ) => { ReservedWord { text: L!($text), + is_reserved: true, is_super_command: false, } }; ( ( $text:literal, [subcommand] ) ) => { ReservedWord { text: L!($text), + is_reserved: true, + is_super_command: true, + } + }; + ( ( $text:literal, [subcommand], not reserved ) ) => { + ReservedWord { + text: L!($text), + is_reserved: false, is_super_command: true, } }; @@ -29,6 +39,7 @@ macro_rules! reserved_words { // Don't forget to add any new reserved keywords to the documentation const RESERVED_WORDS: &[ReservedWord] = reserved_words!( + ("!", [subcommand], not reserved), ("["), ("_"), ("and", [subcommand]), @@ -74,5 +85,5 @@ pub fn parser_keywords_is_subcommand(cmd: &impl AsRef) -> bool { /// functions that change the block or command scope, like 'for', 'end' or 'command' or 'exec'. /// These functions may not be overloaded, so their names are reserved. pub fn parser_keywords_is_reserved(word: &wstr) -> bool { - reserved_word(word).is_some() + reserved_word(word).is_some_and(|reserved_word| reserved_word.is_reserved) }