1. What is parsing?

  • A)  The process of dividing a string into individual words
  • B) The process of analyzing a string of symbols according to the rules of a formal grammar
  • C) The process of generating machine code from source code
  • D) The process of debugging code for errors
B) The process of analyzing a string of symbols according to the rules of a formal grammar Explanation

2. Which of the following is a widely used compiler-compiler tool for generating parsers?

  • A) Lex
  • B) GCC
  • C) Yacc
  • D) Make
C) Yacc Explanation

3. Which type of grammar is typically used to define the syntax of programming languages for parsers?

  • A) Regular Grammar
  • B) Context-Free Grammar
  • C) Context-Sensitive Grammar
  • D) Unrestricted Grammar
B) Context-Free Grammar Explanation

4. In what type of parsing are lexical analysis and parsing combined?

  • A) Recursive parsing  
  • B) Context-sensitive parsing
  • C) Scannerless parsing
  • D) Syntactic parsing
C) Scannerless parsing Explanation

5. Which algorithm is commonly used for parsing context-free grammars in polynomial time?

  • A) CYK algorithm
  • B) Dijkstra's algorithm
  • C) A* algorithm
  • D) Kruskal's algorithm
A) CYK algorithm Explanation

6. Which type of parser uses the Shift-Reduce method?

  • A) Top-down parser
  • B) LL parser
  • C) Bottom-up parser
  • D) Recursive-descent parser
C) Bottom-up parser Explanation

7. What data structure is typically created by the parsing process in a compiler?

  • A) Hash Table
  • B) Abstract Syntax Tree (AST)
  • C) Linked List
  • D) Queue
B) Abstract Syntax Tree (AST) Explanation

8. What is the result of a parse tree when the grammar is ambiguous?

  • A) A single unique parse tree for each sentence
  • B) The parse tree is guaranteed to be minimal
  • C) No parse tree can be constructed
  • D) Multiple distinct parse trees for the same sentence
D) Multiple distinct parse trees for the same sentence Explanation

9. Which of the following parsers cannot accommodate left-recursive production rules?

  • A) LR parsers
  • B) Top-down parsers
  • C) Bottom-up parsers
  • D) Shift-reduce parsers
B) Top-down parsers Explanation

10. In the context of parsers, what is a “fix-up” mechanism?

  • A)  A way to handle forward declarations or references
  • B) A method to improve parsing speed
  • C) A tool to optimize token generation
  • D) A technique to combine lexing and parsing
A) A way to handle forward declarations or references Explanation