Q25.Marks: +2.0UGC NET Paper 2: Computer Science 2nd January 2026 Shift 1
A phase of a compiler which produce the symbol table is
1.Syntax analysis✓ Correct
2.Semantic analysis
3.Target code generation
4.Code optimization
Solution
The correct answer is Syntax analysis.
Key Points
Syntax analysis, also known as parsing, is a phase of a compiler where the source code is analyzed to check its grammatical structure according to the programming language's syntax rules.
During this phase, the compiler generates a symbol table, which is a data structure used to store information about variables, functions, objects, and other identifiers in the program.
The symbol table helps in keeping track of the scope and binding of names, as well as providing support for semantic analysis and code generation phases.
Syntax analysis takes the tokenized input from the lexical analysis phase and organizes it into a parse tree or abstract syntax tree (AST) based on the grammar of the language.
This phase ensures that the program adheres to the structural rules of the language, which is crucial for further stages of compilation.
Additional Information
Role of Symbol Table:
Stores information about identifiers such as variable names, data types, scope, and memory locations.
Acts as a reference for the compiler during semantic analysis, intermediate code generation, and optimization stages.
Facilitates error detection by ensuring proper usage of variables and functions.
Phases of a Compiler:
Lexical Analysis: Breaks the source code into tokens.
Syntax Analysis: Checks the grammatical structure and generates the symbol table.
Semantic Analysis: Ensures the meaning of the program is correct.
Intermediate Code Generation: Converts the program into an intermediate representation.
Code Optimization: Optimizes the intermediate code for efficiency.
Target Code Generation: Produces the final machine code for execution.
Important Points:
Syntax analysis is critical for detecting structural errors in the program.
The symbol table plays a central role in linking variables, functions, and other entities during compilation.
Proper syntax analysis ensures that the program can move seamlessly to subsequent stages of compilation.