Definition

Parsers build a parse tree either starting from the root (top-down) or from the leaves (bottom-up).

Key Points

Example

For input id + id with E → E + T | T, T → id:

📌 CSS Frequency: High — trace-based numeric questions ("parse this string using both approaches") are common.

Model Answer (short)

"Top-down parsers construct the parse tree from the start symbol downward by predicting productions, and require the grammar to be free of left recursion; examples include recursive-descent and predictive (LL) parsers. Bottom-up parsers construct the tree from the input tokens upward by repeatedly reducing substrings, naturally handle left recursion, and are more powerful — LR parsing is the standard bottom-up technique used by parser generators."