

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Class: Compilers; Subject: Engineering Computer Science; University: University of California - Davis; Term: Spring 1997;
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!


s0: [S’ -> .SL] [SL -> .SL; S] [SL -> .] goto(s0, SL) = s1; s1: [S’ -> SL.] [SL -> SL.;S] goto(s1, ;) = s2; s2: [SL -> SL;.S] [S -> .stmt] goto(s2, S) = s3; s3: [SL-> SL; S.] goto(s2, stmt) = s s4: [S -> stmt.]
Follow(S’) = { $ }, Follow(SL) = {; $}, Follow(S) = { ;, $} | ; | stmt | $ | SL | S |
[ A -> id := .A] [ A -> .id := A] [ A ->.E] [ A -> .P] [ P ->.id] [ P -> .(A)]
[ A -> id. := A] [ P ->id.]
BinTree -> num { BinTree.num = num; } BinTree { if (BinTree1.tree == null) BinTree.min = num; else BinTree.balanced = BinTree1.balanced && binTree.num > BinTree1.max; BinTree.min = BinTree1.min; BinTree.tree = nonnull; } BinTree { if (BinTree1.tree = null) BinTree.max = num; else BinTree.balanced = BinTree2.balanced && binTree.num < BinTree2.min; BinTree.max = BinTree2.max } BinTree -> empty {BinTree.balanced = true; BinTree.tree = null}
DS -> {D.count = 0} D D -> a { D1.count = D.count + 1; cout << ’a’; } D b { cout << ’b’;} D -> { C.acount = D.count; C.bcount = D.count} C C -> c {C1.acount = C.acount - 1; if (C1.acount > 0) count << ’a’ else count << ’c’;} C1 {C1.bcount = C.bcount-1; if (C1.bcount > 0) count << ’b’ else count << ’d’;} d