Project ForgeSign up free
Compiler Design
Lexical Analysis & Parsing
GATE 2008
Expert

Match the following:

(E) Checking that identifiers are declared before their use (F) Number of formal parameters in the declaration of a function agrees with the number of actual parameters in a use of that function (G) Arithmetic expressions with matched pairs of parentheses (H) Palindromes

(P) L = {aⁿbᵐcⁿdᵐ | n≥1, m≥1} (Q) X → XbX | XcX | dXf | g (R) L = {wcw | w ∈ (a|b)*} (S) X → bXb | cXc | ε

  • AE-P, F-R, G-Q, H-S
  • E-R, F-P, G-S, H-Q
  • CE-R, F-P, G-Q, H-S
  • DE-P, F-R, G-S, H-Q

Explanation

G (balanced/matched parentheses) is the classic CFG X→bXb|cXc|ε, matching S. E (checking a declared identifier's name matches its use) requires comparing two arbitrary-length copies of the same string — the classic non-context-free 'copy language' wcw, matching R. F (matching a count of formal params to actual params at two separate points) parallels the count-matching pattern aⁿbᵐcⁿdᵐ, matching P. By elimination, H (palindromes) matches Q.

Source: GATE CS 2008 (2008)

This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.

Start revising free