Intermediate representations span the gap between source and target languages by being closer to the target language while remaining mostly machine independent. This allows optimizations to be performed in a machine-independent way.
There are two main types of intermediate languages: high-level representations like syntax trees that are close to the source language, and low-level representations like three-address code that are closer to the target machine. Syntax trees separate parsing from subsequent processing while three-address code translates expressions into single assignment form using temporaries.
Semantic analysis enforces static semantic rules by constructing a syntax tree, evaluating attributes, and checking properties that can be analyzed at compile time. Attribute grammars annotate syntax rules with semantic attributes to define meaning while dynamic