Consider the following statements.
- Symbol table is accessed only during lexical analysis and syntax analysis.
- Compilers for programming languages that support recursion necessarily need heap storage for memory allocation in the run-time environment.
- Errors violating the condition ‘any variable must be declared before its use’ are detected during syntax analysis.
Which of the above statements is/are TRUE?
View worked solution
Answer: D
Let us analyze each statement individually:
-
Statement I: "Symbol table is accessed only during lexical analysis and syntax analysis."
FALSE. The symbol table is a central data structure accessed by almost all phases of a compiler. It is used during semantic analysis (for type checking and scope verification), intermediate code generation, code optimization, and target code generation to store and retrieve information about identifiers. -
Statement II: "Compilers for programming languages that support recursion necessarily need heap storage for memory allocation in the run-time environment."
FALSE. Recursion requires a run-time stack to manage activation records (which store return addresses, parameters, and local variables for each active function call). Heap storage is used for dynamic memory allocation (e.g., usingmallocornew) and is not a requirement for recursion. -
Statement III: "Errors violating the condition ‘any variable must be declared before its use’ are detected during syntax analysis."
FALSE. Checking whether a variable has been declared before its use is a context-sensitive check. Since syntax analysis is based on Context-Free Grammars (CFGs), it cannot enforce such rules. This check is performed during the semantic analysis phase.
Since all three statements are false, the correct option is D (None of Ⅰ, Ⅱ and Ⅲ).
Free practice · Your answers on this page are not saved.
