Theory CodeGen
theory CodeGen imports Main begin
section‹Case Study: Compiling Expressions›
text‹\label{sec:ExprCompiler}
\index{compiling expressions example|(}%
The task is to develop a compiler from a generic type of expressions (built
from variables, constants and binary operations) to a stack machine. This
generic type of expressions is a generalization of the boolean expressions in
\S\ref{sec:boolex}. This time we do not commit ourselves to a particular
type of variables or values but make them type parameters. Neither is there
a fixed set of binary operations: instead the expression contains the
appropriate function itself.
›
type_synonym 'v binop = "'v ⇒ 'v ⇒ 'v"