MIDTERM COM 1205 Winter 2003 Tuesday, February 11 Karl Lieberherr YOUR NAME: Open book and open notes. Question 1: 71 Question 2: 20 Question 3. 40 131 points Question 1: ================================================== UNKNOWN1 = TraversalAspectName UNKNOWN2 = Ident UNKNOWN3 = Traversals UNKNOWN4 = Decl UNKNOWN5 = item UNKNOWN6 = NamedStrat UNKNOWN7 = strategyname UNKNOWN8 = StrategyName UNKNOWN9 = eachCommand UNKNOWN10 = from Commands to Command UNKNOWN11 = interpret UNKNOWN12 = CompoundFile UNKNOWN13 = cd UNKNOWN14 = strategyname UNKNOWN15 = StrategyName UNKNOWN16 = ident UNKNOWN17 = Ident UNKNOWN18 = eachCommand UNKNOWN19 = classname UNKNOWN20 = ClassName UNKNOWN21 = ident UNKNOWN22 = Ident UNKNOWN23 = Interpreter UNKNOWN24 = CompoundFile UNKNOWN25 = Interpreter UNKNOWN26 = done: from Aspect to ClassName UNKNOWN27 = CompoundFile UNKNOWN28 = done: from Aspect via MethodSignature to ClassName Question 2: ================================================== UNKNOWN1 = Visitor v = new Visitor() { void before (ClassName host) { System.out.println(host.get_ident().toString()); } }; cg.traverse(m, "from Aspect to ClassName", v); cg.traverse(m, "from Aspect via MethodSignature to ClassName", v); Even better: void printClassNames(String whereToGo) { Visitor v = new Visitor() { void before (ClassName host) { System.out.println(host.get_ident().toString()); } }; cg.traverse(m, whereToGo, v); }; // and call: printClassNames("from Aspect to ClassName"); printClassNames("from Aspect via MethodSignature to ClassName"); Question 3: ================================================== UNKNOWN1 = // any number of formal parameters MethodSignature = "void" MethodName "(" [ CList(FormalArgument)] ")". ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ CList(S) ~ S {"," S}. // Semicolon becomes a terminator of an item: SList(S) ~ "{" { S } "}". Decl = "declare" Item ";".