You are on page 1of 6
2020~ WOFKDOOK @| Detailed Explanations of a Try Yourself Questions Computer Science & IT Compiler Design i Introduction and Lexical Analysis Detalled Explanation a i Try Yourself Questions Deed (a) Lexical analyzer produces an error when an illegal character appears in the string pattern that makes invalidl token, wwwmadeeasypublications.org MADE ERSY © Copyright ) Parsing and Syntex Directed Translation Detalled Explanation f Try Yourself Questions f Berry (b) For any particular string: #parse trees = #LMD's = #RMD's b= Per Dery (d) In L-attributed, al attributes follow synthesized attributed notation or restricted inherited attribute notation (parent or left sibling) In S-attribute, all attributes follow synthesized attribute notation only. F (8G {Fval = Eval = G.val) This notation is not in L-attributed, and also nol S-attributed. (a) Recursive descent parser can not use left recursive grammar but it can use right recursive grammar. © copyright MADE EASY wonwmadeeasypublications org 4 Computer Science & IT © Compiler Design MADE EASY Pours (a) For string : “IF TRUE THEN IF TRUE THEN ELSE END" has two parse troos, ww a eS “en wen @) Peo TRUE ie ~e TRUE The given grammar is ambiguous, hence its not LL(1) and also not LR(1). (a) Set 1 has RR conflict. Aaa. (b} B baa, (b, c} {b} Afb, chao Grammar produces RR conflict for CLR (1). @ > ( wwrwmadeeasypublications org MADE ERSY © Copyright | MADE EASY Workbook 5 Poesy (a) Set 3 contain $ —- as reduced item, low (S) =), $} In row 3, entry for column’) and '$' will be E= ty &= [eo b:Soe) In set 5, on Sit goes to set 6. In row 5, entry for non-terminals ‘S’ is state 6. &=-6 [- ©) 95@) E, = mE =f,and E,=6 (ce) FOLLOW (A) = LFOLLOW(A) = RFOLLOW(A) The set of terminals followed by A are same in all sentential forms. Peed (a) (a) An unambiguous grammar can have different leftmost and rightmost derivation. However, an unambiguous grammar has only one derivation tree. So option (a) is false. (b) LL(1) is a top-down parser. (¢) LALRis more powerful than SLR. (¢) For any parser, grammar should be unambiguous, (a) For Input string: ab LR parser reduces aS to S to parse the string ab when stack has aS. (© copyright MADE ERSY wor madeeasypublications org ) Runtime Environment @ Detalled Explanation of Try Yourself Questions eed (b) Activ ote. Diner (d) n record maintains: Frame pointer, Access link, Local variables, Return address, Return value, / —l a i FRAME Access POINT: ins Given calling sequence from the program is: Main > Al» A2> A21 > AN Aland A2 are defined in Main, so A1 and A2 access links are pointed to Main, ‘A21 definition is available in A2, hence A21 access link points to A2, wwwmadeeasypublications.org MADE ERSY © Copyright )

You might also like