Phrase structure grammar
\(
\begin{array}{lcl}
< program > & ::= & < exp > \\
< exp > & ::= & < var\ exp > \\
& | & < fn\ exp > \\
& | & < app\ exp > \\
& | & < intlit\ exp > \\
& | & < papp\ exp > \\
< fn\ exp > & ::= & fn\quad '('\ < var\ exp >^*\ ')'\ =>\ < exp > \\
< app\ exp > & ::= & '('\ < exp >\ < exp >^*\ ')' \\
< papp\ exp > & ::= & < prim\ op >\ '('\ < args >\ ')' \\
< args > & ::= & ( < exp >\ (\ ','\ < exp > )^*\ )?\\
\end{array}
\)
Lexical grammar
\(
\begin{array}{lcl}
< var\ exp > & ::= & < letter >\ (\ < letter >\ |\ < digit >\ |\ \ \_\ \ )^*\\
< intlit\ exp > & ::= & < digit >^+\\
< digit > & ::= & 0\ |\ 1\ |\ 2\ |\ ...\ |\ 8\ |\ 9\\
< letter > & ::= & a\ |\ b\ |\ ...\ |\ z\ |\ A\ |\ B\ |\ ...\ |\ Z\\
< prim\ op > & ::= & +\ |\ *\ |\ add1\\
\end{array}
\)