Remove unnecessary downcast in prepare_grammar::perform