Handle negation correctly for parenthesized groups and user-defined keywords.