Syntax Analysis MCQs

1. What is Syntax Analysis?

A) The process of checking the meanings of a program
B) The process of verifying the correctness of a program’s syntax
C) The process of optimizing a program’s code
D) The process of executing a program

Answer: B) The process of verifying the correctness of a program’s syntax


2. Which of the following is NOT part of syntax analysis?

A) Parsing
B) Tokenization
C) Syntax tree generation
D) Lexical analysis

Answer: D) Lexical analysis


3. Which data structure is commonly used by parsers during syntax analysis?

A) Stack
B) Queue
C) Linked list
D) Binary tree

Answer: A) Stack


4. What is the primary function of a parser in syntax analysis?

A) To check if a program is semantically correct
B) To translate source code into machine code
C) To determine if the program follows the syntax rules of the programming language
D) To optimize the program’s code

Answer: C) To determine if the program follows the syntax rules of the programming language


5. Which type of grammar is typically used by parsers in syntax analysis?

A) Context-Free Grammar (CFG)
B) Regular Grammar
C) Context-Sensitive Grammar
D) Unrestricted Grammar

Answer: A) Context-Free Grammar (CFG)


6. In a syntax tree, what does each internal node represent?

A) A terminal symbol
B) A non-terminal symbol
C) A statement
D) A function

Answer: B) A non-terminal symbol


7. Which of the following parsing techniques is based on recursive descent?

A) LL Parsing
B) SLR Parsing
C) LALR Parsing
D) LR Parsing

Answer: A) LL Parsing


8. Which of the following is a characteristic of top-down parsing?

A) It begins parsing from the root of the syntax tree.
B) It parses the input from left to right.
C) It is always faster than bottom-up parsing.
D) It does not require backtracking.

Answer: A) It begins parsing from the root of the syntax tree.


9. In a Bottom-up parsing approach, what does a parser attempt to reduce?

A) Non-terminal symbols
B) Terminal symbols
C) Sentences in the language
D) Expressions

Answer: A) Non-terminal symbols


10. What does an ambiguity in a grammar mean in syntax analysis?

A) The grammar can produce multiple correct parse trees for the same input.
B) The grammar cannot be parsed at all.
C) The grammar is not context-free.
D) The grammar has infinite recursion.

Answer: A) The grammar can produce multiple correct parse trees for the same input.

Leave a Comment

All copyrights Reserved by MCQsAnswers.com - Powered By T4Tutorials