I'd like to use Beamer overlays inside a grammar definition:
\documentclass{beamer}
\usepackage{syntax}
\begin{document}
\begin{frame}[fragile]{}
\begin{grammar}
<term>
::= <term1>
\only<2>{
\alt <term2>
}
\end{grammar}
\end{frame}
\end{document}
but this results in
<term> ::= <term1> <2>
| <term2>
(note how <2> is, seemingly, picked up by grammar instead of \only!)
I've also tried \visible<2> and \uncover<2> (both result in an error ! Argument of \beamer@fakeinvisible has an extra }.), and \begin{onlyenv}<2> (results in Runaway argument? {onlyenv> \end {grammar} ! File ended while scanning use of \end.).

lstlisting's escape character toยง. But that's "inside out"; here I imagine I'd need to redefine Beamer's<>characters so that they don't clash withgrammar? โ Cactus May 24 '16 at 13:33