GATE Exam  >  GATE Questions  >  Choose the correct option to fill the empty b... Start Learning for Free
Choose the correct option to fill the empty blanks in below statement :If variables are declared previously, then __________ is responsible for generation of symbol table but if variables are not declared then symbol table will be generated by __________.
  • a)
    Lexical Analyzer, Semantic Analyzer
  • b)
    Semantic Analyzer, Lexical Analyzer
  • c)
    Lexical Analyzer, Syntax Analyzer
  • d)
    Syntax Analyzer, Semantic Analyzer
Correct answer is option 'B'. Can you explain this answer?
Verified Answer
Choose the correct option to fill the empty blanks in below statement ...
If variables are declared previously, then semantic analyzer is responsible for generation of symbol table.
If variables are not declared, then lexical analyzer will generate the symbol table.
Hence option b is correct.
View all questions of this test
Most Upvoted Answer
Choose the correct option to fill the empty blanks in below statement ...
Explanation:

In a programming language, variables can be declared previously or not declared at all. The process of generating a symbol table depends on whether the variables are declared or not.

Symbol Table:
A symbol table is a data structure used by compilers and interpreters to store information about the variables, functions, and objects used in a program. It contains the names of the symbols and their associated attributes, such as type, scope, and memory location.

Declaration:
In programming languages, variables are declared to allocate memory for them and define their type. This allows the compiler to understand the program's structure and enforce type safety. Variable declaration is done using appropriate syntax and keywords specific to the programming language.

Lexical Analyzer:
The lexical analyzer is responsible for tokenizing the input program into a sequence of lexemes. It identifies keywords, identifiers, operators, literals, and other tokens. It does not have information about the types or attributes of the tokens.

Semantic Analyzer:
The semantic analyzer performs a deeper analysis of the program and checks for semantic errors. It verifies that the program follows the rules and restrictions of the programming language. It also assigns types to the variables and expressions, checks for type compatibility, and builds the symbol table.

Syntax Analyzer:
The syntax analyzer (also known as the parser) checks the syntactic structure of the program. It ensures that the program follows the grammar rules of the programming language. It builds a parse tree or an abstract syntax tree.

Explanation of the answer:
If variables are declared previously, it means that their types and attributes are known, and the symbol table can be generated by the semantic analyzer. The semantic analyzer assigns types to the variables and adds them to the symbol table.

If variables are not declared, it means that their types and attributes are unknown. In this case, the lexical analyzer will generate a symbol table by assigning default types (such as 'int' for integers or 'float' for floating-point numbers) to the variables. The symbol table generated by the lexical analyzer may not be accurate or complete, as it lacks information about the variables' intended types and attributes.

Therefore, the correct option to fill the empty blanks is:
Semantic Analyzer, Lexical Analyzer
Explore Courses for GATE exam

Similar GATE Doubts

Choose the correct option to fill the empty blanks in below statement :If variables are declared previously, then __________ is responsible for generation of symbol table but if variables are not declared then symbol table will be generated by __________.a)Lexical Analyzer, Semantic Analyzerb)Semantic Analyzer, Lexical Analyzerc)Lexical Analyzer, Syntax Analyzerd)Syntax Analyzer, Semantic AnalyzerCorrect answer is option 'B'. Can you explain this answer?
Question Description
Choose the correct option to fill the empty blanks in below statement :If variables are declared previously, then __________ is responsible for generation of symbol table but if variables are not declared then symbol table will be generated by __________.a)Lexical Analyzer, Semantic Analyzerb)Semantic Analyzer, Lexical Analyzerc)Lexical Analyzer, Syntax Analyzerd)Syntax Analyzer, Semantic AnalyzerCorrect answer is option 'B'. Can you explain this answer? for GATE 2024 is part of GATE preparation. The Question and answers have been prepared according to the GATE exam syllabus. Information about Choose the correct option to fill the empty blanks in below statement :If variables are declared previously, then __________ is responsible for generation of symbol table but if variables are not declared then symbol table will be generated by __________.a)Lexical Analyzer, Semantic Analyzerb)Semantic Analyzer, Lexical Analyzerc)Lexical Analyzer, Syntax Analyzerd)Syntax Analyzer, Semantic AnalyzerCorrect answer is option 'B'. Can you explain this answer? covers all topics & solutions for GATE 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Choose the correct option to fill the empty blanks in below statement :If variables are declared previously, then __________ is responsible for generation of symbol table but if variables are not declared then symbol table will be generated by __________.a)Lexical Analyzer, Semantic Analyzerb)Semantic Analyzer, Lexical Analyzerc)Lexical Analyzer, Syntax Analyzerd)Syntax Analyzer, Semantic AnalyzerCorrect answer is option 'B'. Can you explain this answer?.
Solutions for Choose the correct option to fill the empty blanks in below statement :If variables are declared previously, then __________ is responsible for generation of symbol table but if variables are not declared then symbol table will be generated by __________.a)Lexical Analyzer, Semantic Analyzerb)Semantic Analyzer, Lexical Analyzerc)Lexical Analyzer, Syntax Analyzerd)Syntax Analyzer, Semantic AnalyzerCorrect answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for GATE. Download more important topics, notes, lectures and mock test series for GATE Exam by signing up for free.
Here you can find the meaning of Choose the correct option to fill the empty blanks in below statement :If variables are declared previously, then __________ is responsible for generation of symbol table but if variables are not declared then symbol table will be generated by __________.a)Lexical Analyzer, Semantic Analyzerb)Semantic Analyzer, Lexical Analyzerc)Lexical Analyzer, Syntax Analyzerd)Syntax Analyzer, Semantic AnalyzerCorrect answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Choose the correct option to fill the empty blanks in below statement :If variables are declared previously, then __________ is responsible for generation of symbol table but if variables are not declared then symbol table will be generated by __________.a)Lexical Analyzer, Semantic Analyzerb)Semantic Analyzer, Lexical Analyzerc)Lexical Analyzer, Syntax Analyzerd)Syntax Analyzer, Semantic AnalyzerCorrect answer is option 'B'. Can you explain this answer?, a detailed solution for Choose the correct option to fill the empty blanks in below statement :If variables are declared previously, then __________ is responsible for generation of symbol table but if variables are not declared then symbol table will be generated by __________.a)Lexical Analyzer, Semantic Analyzerb)Semantic Analyzer, Lexical Analyzerc)Lexical Analyzer, Syntax Analyzerd)Syntax Analyzer, Semantic AnalyzerCorrect answer is option 'B'. Can you explain this answer? has been provided alongside types of Choose the correct option to fill the empty blanks in below statement :If variables are declared previously, then __________ is responsible for generation of symbol table but if variables are not declared then symbol table will be generated by __________.a)Lexical Analyzer, Semantic Analyzerb)Semantic Analyzer, Lexical Analyzerc)Lexical Analyzer, Syntax Analyzerd)Syntax Analyzer, Semantic AnalyzerCorrect answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Choose the correct option to fill the empty blanks in below statement :If variables are declared previously, then __________ is responsible for generation of symbol table but if variables are not declared then symbol table will be generated by __________.a)Lexical Analyzer, Semantic Analyzerb)Semantic Analyzer, Lexical Analyzerc)Lexical Analyzer, Syntax Analyzerd)Syntax Analyzer, Semantic AnalyzerCorrect answer is option 'B'. Can you explain this answer? tests, examples and also practice GATE tests.
Explore Courses for GATE exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev