SYNTAX ANALYSIS
ROLE OF THE PARSER
|
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
|
Semantic analysis
|
|
|
Syntax analysis
|
|
|
Code optimization
|
|
|
Code generation
|
Detailed explanation-1: -is the 2nd phase of the compiler, which checks the given input string is the correct syntax of the programming language.
Detailed explanation-2: -The grammar of the programming is checked at Syntax analysis phase of the compiler.
Detailed explanation-3: -Therefore, this phase uses context-free grammar (CFG), which is recognized by push-down automata. It implies that every Regular Grammar is also context-free, but there exists some problems, which are beyond the scope of Regular Grammar. CFG is a helpful tool in describing the syntax of programming languages.
Detailed explanation-4: -Syntax Analysis: Basically, in the second phase, it analyses the syntactical structure and inspects if the given input is correct or not in terms of programming syntax. It accepts tokens as input and provides a parse tree as output. It is also known as parsing in a compiler.
Detailed explanation-5: -A context-free grammar (CFG) is a certain type of formal grammar, which is a set of production rules that describe all possible strings in a given formal language. CFG is used to specify the syntax of a language.