Lexical → Spelling (words are valid?)
✨ Example: @var ❌ (invalid identifier).
Syntax → Grammar (sentence is correct?)
✨ Example: if(x > 0 { ❌ (missing )).
Semantic → Meaning (logic makes sense?)
✨ Example: int x; x = "Hello"; ❌ (type mismatch).
Intermediate Code → Draft copy (safe middle form?)
👉 Ensures no invalid operation is created.
✨ Example: Detects 10 / 0 ❌ (divide by zero).
Optimization → Make it smart (remove waste)
👉 Removes useless or unreachable code.
✨ Example:
if(false) {
x = 5;
}
❌ Dead code → Removed.
Code Generation → Final output (machine ready)
👉 Reports hardware problems like not enough registers or wrong instructions.
✨ Example: Too many variables to fit in registers ❌.
👉 Just think:
Word → Grammar → Meaning → Draft → Smart → Final
Top comments (0)