GATE / CS ARCHIVE

GATE CSE 2009 / QUESTION 42

Compiler implementation statements

Compiler Design · Other / Mixed Topics · Full GATE CSE 2009 paper

GATE 2009, Q42 2 marks · MCQ
Report issue

Other / Mixed Topics

Question 42, GATE 2009: Assess I some programming-language parsers have complexity below Θ(n³); II recursion can be implemented with static storage allocation; III no L-attributed definition can be evaluated bottom-up; IV optimization can occur at source and intermediate-code levels. A I/II; B I/IV; C III/IV; D I/III/IV.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

I is true: LL/LR parsing for suitable grammars runs in linear time, below the general cubic CFL bound. II is false for unrestricted recursion under static allocation of activation records, since simultaneous recursive calls need distinct storage. III is false because S-attributed definitions are also L-attributed and can be evaluated bottom-up. IV is true: optimizations may occur at source and intermediate-code levels. Thus I and IV, B. Tail-recursive/bounded special cases do not justify the unrestricted static-allocation claim.

LL/LR parsers for suitable grammars run in linear time, establishing I without claiming every CFG can be parsed that way. Unbounded recursive activation records cannot all be assigned one fixed static location, so II is false in the intended general model. S-attributed definitions are a subclass of L-attributed ones and can be evaluated bottom-up, disproving III’s universal negative. Algebraic source rewrites and intermediate-code optimizations illustrate IV. Therefore I and IV are true.

Original paper, page 9