Skip to content

CS606 - Compiler Construction

2 Topics 68 Posts
  • 0 Votes
    3 Posts
    1k Views
    zareenZ
    @zareen said in CS606 Assignment 2 Solution and Discussion: Assignment Marks 20 Question: X -> aZ X -> c Y -> bX Z -> Ya Z -> XbY a) Find First sets for above grammar. (10 Marks) b) Find Follow sets for above grammar. (10 Marks) Solution: a) Find First sets for above grammar. (10 Marks) First (X)= a, c First (Y)= b First (Z)= a, b, c b) Find Follow sets for above grammar. (10 Marks) Follow (X)= a, b, $ Follow (Y)= a, b, $ Follow(Z)= a, b, $
  • CS606 Assignment 2 Solution and Discussion

    Solved cs606 assignment 2 solution discussion fall 2019
    2
    0 Votes
    2 Posts
    1k Views
    zareenZ
    Ideas Solution Q No 01 Solution: NP -> Adj NP The draw parse trees for above given grammar: [image: cR7P0Ng.png] The above given grammar have only one parse tree so it is non-ambiguous grammar. NP -> NP Conj NP The draw parse trees for above given grammar: [image: wflQD6P.png] The above grammar has two different parse trees therefore the given grammar is ambiguous. NP -> Adj N The draw parse trees for above given grammar: [image: IueNDrQ.png] The above given grammar have only one parse tree so it is non-ambiguous grammar. NP ->N The draw parse trees for above given grammar: [image: zjft37X.png] The above given grammar have only one parse tree so it is non-ambiguous grammar. Adj -> Young The draw parse trees for above given grammar: [image: zylKfdU.png] The above given grammar have only one parse tree so it is non-ambiguous grammar. Conj -> and The draw parse trees for above given grammar: [image: 4UWakYM.png] The above given grammar have only one parse tree so it is non-ambiguous grammar. N -> Boys | Girls The draw parse trees for above given grammar: [image: m7DKSyn.png] The above given grammar have only one parse tree so it is non-ambiguous grammar. Q No 02 Solution: The given grammar is S -> S + S | S / S | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 The draw parse trees for above given grammar: Parse Trees: [image: hamteDh.png] The above grammar has two different parse trees therefore the given grammar is ambiguous. THE END!
How to Build a $1,000/Month PAK VS BAN Live Live Cricket Streaming
File Sharing

2

Online

3.0k

Users

2.8k

Topics

8.2k

Posts
| |