Symbol Table in Compiler Design: Choosing the Correct Option
A symbol table is used by a compiler to store and retrieve information about program identifiers and their attributes (e.g., type, scope, memory location).3 Therefore, for the given options, the correct answer is (iii) Identifiers and their attributes.3
Footnotes
-
Symbol Table in Compiler - GeeksforGeeks - Defines symbol table contents and roles; stores name/type/scope/memory location of identifiers. ↩ ↩2
-
Lecture 7: Semantic Analysis (Types and Symbol Tables) - Compiler Design Course - States each symbol table entry contains name plus additional info like kind/type/size/scope. ↩ ↩2
-
Semantic Analysis in Compiler Design - csegyan.com - Notes symbol table stores identifier info including type and scope used in semantic analysis. ↩ ↩2
Symbol Table in Compiler Design (Role & What It Stores)
Why the other options are incorrect
- (i) Only variables — A symbol table typically stores information for many kinds of identifiers, not just variables (it can include functions, constants, parameters, etc.).2
- (ii) Only functions — Same reason: symbol tables cover multiple categories of identifiers, not only functions.2
- (iv) Syntax errors — Syntax errors are primarily detected during the parsing/syntax-analysis phase; symbol tables store semantic information about identifiers used for later checks (e.g., scope/type resolution), not the syntax-error list directly.2
Footnotes
-
Symbol Table in Compiler - GeeksforGeeks - Defines symbol table contents and roles; stores name/type/scope/memory location of identifiers. ↩ ↩2 ↩3
-
Lecture 7: Semantic Analysis (Types and Symbol Tables) - Compiler Design Course - States each symbol table entry contains name plus additional info like kind/type/size/scope. ↩ ↩2
-
Semantic Analysis in Compiler Design - csegyan.com - Notes symbol table stores identifier info including type and scope used in semantic analysis. ↩
How a compiler uses the symbol table (to reject the wrong options)
- 1Step 1
During compilation, identifiers (variables, functions, constants, parameters) are entered into the symbol table so their declarations can be tracked.2
Footnotes
-
Symbol Table in Compiler - GeeksforGeeks - Defines symbol table contents and roles; stores name/type/scope/memory location of identifiers. ↩
-
Semantic Analysis in Compiler Design - csegyan.com - Notes symbol table stores identifier info including type and scope used in semantic analysis. ↩
-
- 2Step 2
The compiler records attributes such as the identifier’s type and scope, along with other relevant details (e.g., memory location information).3
Footnotes
-
Symbol Table in Compiler - GeeksforGeeks - Defines symbol table contents and roles; stores name/type/scope/memory location of identifiers. ↩
-
Lecture 7: Semantic Analysis (Types and Symbol Tables) - Compiler Design Course - States each symbol table entry contains name plus additional info like kind/type/size/scope. ↩
-
7.0 Semantic Analysis Symbol Tables - WPI CS544 - Describes attributes of names and typical stored attributes like type/storage allocation and scope. ↩
-
- 3Step 3
Later phases (notably semantic analysis) consult the symbol table for type/scope related checks rather than for reporting syntax errors directly.2
Footnotes
-
Symbol Table in Compiler - GeeksforGeeks - Defines symbol table contents and roles; stores name/type/scope/memory location of identifiers. ↩
-
Semantic Analysis in Compiler Design - csegyan.com - Notes symbol table stores identifier info including type and scope used in semantic analysis. ↩
-
- 4Step 4
Because the symbol table stores identifier-specific semantic attributes, the only option that matches is (iii).3
Footnotes
-
Symbol Table in Compiler - GeeksforGeeks - Defines symbol table contents and roles; stores name/type/scope/memory location of identifiers. ↩
-
Lecture 7: Semantic Analysis (Types and Symbol Tables) - Compiler Design Course - States each symbol table entry contains name plus additional info like kind/type/size/scope. ↩
-
Semantic Analysis in Compiler Design - csegyan.com - Notes symbol table stores identifier info including type and scope used in semantic analysis. ↩
-
Option Match vs. What Symbol Table Stores
Scores reflect how well each option aligns with typical compiler definitions.
Quick FAQ
Pro Tip
When MCQs mention “symbol table” plus “stores information,” look for wording like identifiers and attributes (type/scope/memory). That combination is the canonical phrasing in compiler references.3
Footnotes
-
Symbol Table in Compiler - GeeksforGeeks - Defines symbol table contents and roles; stores name/type/scope/memory location of identifiers. ↩
-
Lecture 7: Semantic Analysis (Types and Symbol Tables) - Compiler Design Course - States each symbol table entry contains name plus additional info like kind/type/size/scope. ↩
-
7.0 Semantic Analysis Symbol Tables - WPI CS544 - Describes attributes of names and typical stored attributes like type/storage allocation and scope. ↩
Common Exam Trap
Don’t confuse symbol tables (semantic info about identifiers) with error handling outputs. Syntax errors come from parsing; symbol tables are consulted to resolve identifier meaning for semantic checks.2
Footnotes
-
Symbol Table in Compiler - GeeksforGeeks - Defines symbol table contents and roles; stores name/type/scope/memory location of identifiers. ↩
-
Semantic Analysis in Compiler Design - csegyan.com - Notes symbol table stores identifier info including type and scope used in semantic analysis. ↩
Knowledge Check
The symbol table stores information about: