---
title: "Semantic Analysis and the Intermediate Representation"
description: "A tree that parses can still be wrong: an undeclared name, a type mismatch, a call with the wrong arity. After those checks the compiler lowers the tree into a simpler representation, which is what le"
canonical: https://lightmysky.com/learn/computing/semantic-analysis-and-the-intermediate-representation-mt_f2z_WQxfiw
source: https://lightmysky.com/learn/computing/semantic-analysis-and-the-intermediate-representation-mt_f2z_WQxfiw.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Semantic Analysis and the Intermediate Representation

A tree that parses can still be wrong: an undeclared name, a type mismatch, a call with the wrong arity. After those checks the compiler lowers the tree into a simpler representation, which is what lets one front end serve several targets.

Subject: Computing · Area: Computer Systems · Ages 21 to 22
Page: https://lightmysky.com/learn/computing/semantic-analysis-and-the-intermediate-representation-mt_f2z_WQxfiw

## Ready when they can

- Name three errors a parser accepts and a semantic pass rejects
- Explain what a symbol table holds and when it is consulted
- Say why lowering to an intermediate form is worth the extra pass

## Lesson: It parses, but is it right

You already know a parser builds a tree from source text. A tree that parses can still be wrong. Calling a function with two arguments when it takes three, using a name nobody declared, or mixing types all sail through parsing.

**Example.** The call paint(red) parses fine, yet paint expects three numbers. The semantic pass catches it by consulting the symbol table, which recorded paint with three parameters at its declaration. Parseable is not the same as meaningful.

The symbol table maps each name to its facts: kind, type, scope, and parameters. The compiler writes an entry at every declaration and reads it back at every use. Undeclared names and mismatches surface exactly there.

**Tip.** After checking, the compiler lowers the tree into a simpler intermediate form. That extra pass is worth it because one front end can then serve many targets: each target only learns the simple form, not every language.

**Recap.** Parsing accepts structure, the symbol table checks meaning, and a simpler middle form serves every target.

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [Lexing and Parsing: From Text to a Syntax Tree](https://lightmysky.com/learn/computing/lexing-and-parsing-from-text-to-a-syntax-tree-mt_-ZlCxZ3SOh)
- [Return Values and Variable Scope](https://lightmysky.com/learn/computing/return-values-and-variable-scope-mt_jivtTHpZc7)

## Opens up

- [Code Generation and What an Optimiser May Change](https://lightmysky.com/learn/computing/code-generation-and-what-an-optimiser-may-change-mt__ZSPwP4hfA)
- [Type Soundness: Progress and Preservation](https://lightmysky.com/learn/computing/type-soundness-progress-and-preservation-mt_nAAHVPNaVJ)
