safer implementations of as_grammar_, as_action_, is_grammar, is_action, and def