Skip to content
uencoder

Abstract Syntax Tree

An AST is a tree-shaped abstract representation of the syntactic structure of source code, where each node represents a syntactic construct — the compiler's core data structure.

Purpose

A standard representation of program structure, used for compilation, analysis, transformation, and tooling.

Mechanism

The parser builds the AST from a token stream. Node types include declarations, expressions, statements, and patterns. AST traversal is used for type checking, optimization, and code generation. Babel/ESLint transform and analyze JS via the AST.

Use cases

  • Compiler implementation
  • Code tooling
  • Static analysis

Related tools

References