retagged by
14,307 views
26 votes
26 votes

Consider the following statements.

  1. Symbol table is accessed only during lexical analysis and syntax analysis.
  2. Compilers for programming languages that support recursion necessarily need heap storage for memory allocation in the run-time environment.
  3. 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?

  1. I only
  2. I and III only
  3. Ⅱ only
  4. None of  Ⅰ, Ⅱ and  Ⅲ
retagged by

4 Answers

Best answer
25 votes
25 votes

1. False.

The symbol table is accessed by most phases of a compiler, beginning with lexical analysis, and continuing through optimization.

Symbol table is accessed during other stages also.

Ref: https://en.m.wikipedia.org/wiki/Symbol_table

2. Not essential, any one of heap and stack is enough to support recursion.  Dynamic allocation of activation records is essential to implement recursion. Remember the stack size can also grow dynamical (see C memory layout).

3. Syntax analyser uses CFL which cannot check for this, we need power of Context sensitive language which is available in semantic analysis phase. So this error is detected only during semantic analysis phase.

So D is correct.

selected by
13 votes
13 votes
Answer : D

Symbol tables is accessed by Other Phases also , not only by Lexical and Syntax analyses. So, false,

Heap is necessary for recursion, can be done via stack.  So, false

Variable declare before its use must be done by Semantic analyses. So, false,
edited by
7 votes
7 votes
i) symbol table may be used in other phases.Therefore False.

ii) for recursion we need stack. Therefore False

iii) Syntax analysis can only work on DCFG. variable declared before use wcw is not in DCFG. Therfore false.

option is  D) None of the above
0 votes
0 votes

None of the statements are true.

  • Symbol table is a data structure used by compilers to store information about the variables, functions, and other entities in a program. It is accessed during both lexical analysis and syntax analysis, but may also be used by later stages of the compilation process, such as code generation.
  • Compilers for programming languages that support recursion may or may not need heap storage for memory allocation in the run-time environment. The decision to use heap storage or not depends on the specific implementation of the compiler and the features of the programming language.
  • Errors violating the condition 'any variable must be declared before its use' are typically detected during the semantic analysis phase of compilation, not during syntax analysis. Syntax analysis checks the structure of the program to ensure it follows the rules of the programming language's grammar, while semantic analysis checks the meaning of the program to ensure it is semantically correct.
Answer:

Related questions

19 votes
19 votes
2 answers
1
Arjun asked Feb 12, 2020
12,337 views
Consider the following grammar.$S \rightarrow aSB \mid d$$B \rightarrow b$The number of reduction steps taken by a bottom-up parser while accepting the string $aaadbbb$ ...
21 votes
21 votes
7 answers
3
Arjun asked Feb 18, 2021
16,941 views
Consider the following $\text{ANSI C}$ program:int main () { Integer x; return 0; }Which one of the following phases in a seven-phase $C$ compiler will throw an error?Lex...