Final Exam CSU 670 Fall 2005 Karl Lieberherr Answer Form Question 1: 10 * 4 = 40 ================================================== UNKNOWN1 = "from CGraph via Body to ClassName" UNKNOWN2 = current = host.get_lhs(); or current = (ClassName) cg.fetch(host,"from ClassDef via ->*,lhs,* to ClassName"); UNKNOWN3 = numberOfParts = host.get_parts().size(); or numberOfParts = cg.gather(host,"from Body to Part").size(); UNKNOWN4 = current UNKNOWN5 = host UNKNOWN6 = get_ident UNKNOWN7 = new Ident("Ident") UNKNOWN8 = new Ident("String") UNKNOWN9 = equals UNKNOWN10 = equals Question 2: 16 * 3 = 48 ================================================== UNKNOWN1 = Concrete UNKNOWN2 = Part UNKNOWN3 = "." UNKNOWN4 = "=" UNKNOWN5 = BarList(ClassName) [BarList(Part) is technically correct but wrong in intent] UNKNOWN6 = Common UNKNOWN7 = | UNKNOWN8 = from CGraph via Body to ClassName UNKNOWN9 = ClassDef UNKNOWN10 = lhs UNKNOWN11 = ClassName UNKNOWN12 = numberOfParts = host.get_parts().size(); UNKNOWN13 = numberOfParts = 0; // prepare for future evolution UNKNOWN14 = ((numberOfParts > 1) && (host.isTerminal())) UNKNOWN15 = current UNKNOWN16 = host Question 3: 8*3 = 24 ================================================== UNKNOWN1 = ClassSpec UNKNOWN2 = ClassSpec UNKNOWN3 = "from CGraph via Body bypassing ->*,params,* to ClassName" UNKNOWN4 = "from ClassDef via -> *,lhs,* bypassing ->*,params,* to ClassName" or from ClassDef bypassing {Part, Params} to ClassName UNKNOWN5 = numberOfParts = host.get_parts().size(); UNKNOWN6 = ((numberOfParts > 1) && (host.isTerminal())) UNKNOWN7 = current UNKNOWN8 = host Question 4: 15 * 3 = 45 ================================================== UNKNOWN1 = ClassSpec UNKNOWN2 = Concrete UNKNOWN3 = Part {ClassSpec is technically correct but wrong in intent) UNKNOWN4 = "." UNKNOWN5 = "=" UNKNOWN6 = BarList(ClassSpec) UNKNOWN7 = Common UNKNOWN8 = ClassSpec UNKNOWN9 = "|" UNKNOWN10 = "from CGraph via Body bypassing ->*,params,* to ClassName" UNKNOWN11 = "from ClassDef via -> *,lhs,* bypassing ->*,params,* to ClassName" UNKNOWN12 = numberOfParts = host.get_parts().size(); UNKNOWN13 = ((numberOfParts > 1) && (host.isTerminal())) UNKNOWN14 = current UNKNOWN15 = host Question 5: 30 ================================================== UNKNOWN1 = The Part is illegal because " List(Syntax)" is a Part. After that we can have an optional part. But the remaining three lines are illegal: Body = "=" List(Syntax) [ OptPart] // Part List(Part) // [ OptPart] // List(Syntax) "." . ===================== Actually, as pointed out by a student, it is easy to make the class dictionary self describing: Rewrite Body as follows: Parts = [ OptPart] Part List(Part) [ OptPart]. Syntaxes = List(Syntax). Body = "=" Syntaxes Parts Syntaxes ".". Question 6: 5 * 3 = 15 ================================================== UNKNOWN1 = PL UNKNOWN2 = (datatype UNKNOWN3 = ) UNKNOWN4 = L(TypedField) UNKNOWN5 = "(" FieldName TypeName ")" Question 7: 10 ================================================== Question 8: 10 ==================================================