Foundationপ্রথম নীতি থেকে
LEVEL 5 · Compilers

Abstract Syntax Tree

অ্যাবস্ট্রাক্ট সিনট্যাক্স ট্রি

Source-এর structure-only tree রূপ — paren, semicolon মতো surface syntax ফেলে দিয়ে শুধু program-এর অর্থবহ shape।

also: AST

1 + 2 * 3 → precedence ইতিমধ্যে tree-তে baked:

    (+)
   /   \
 1     (*)
      /   \
     2     3
  • Abstract = concrete parse tree থেকে পার্থক্য: grouping punctuation নেই, sugar desugar হয়ে যায়
  • Design decision সব pass-কে জুড়ে দেয়: node-এ position রাখবেন (error message), type slot রাখবেন (checker), parent pointer রাখবেন কি?
  • Immutable AST + visitor বনাম mutable AST + in-place rewrite — optimization pass design-এর ভিত্তি
  • LSP/IDE, formatter, linter — সবাই AST-ই consume করে