Exercise 5 Name __________________ Score __/30
| class ex5 { public static void main(String [] args) { System.out.println((new B()).bm(10, 20, 30)); } } class A { int aglobal1; int aglobal2; public int am1(int am1parm1, int am1parm2, int am1parm3) { int am1local1; int am1local2; return aglobal1; } public int am2(int am2parm1, int am2parm2, int am2parm3) { int am2local1; int am2local2; return aglobal1; } } class B extends A { int bglobal; public int bm(int bparm1, int bparm2, int bparm3) { int bmlocal1; int bmlocal2; bmlocal2 = 40; return bmlocal2; } } |
| Abstract Syntax Tree program = main_class class_decl*; main_class = [classname]:id [arg]:id statement; class_decl = id var_decl* method_decl* | {extends} [classname]:id [extend]:id var_decl* method_decl*; var_decl = type id; method_decl = type id formal_list var_decl* statement* exp; statement = {statementlist} statement* | {if} exp [true]:statement [false]:statement | {while} exp statement | {println} exp | {assign} id exp | {array_assign} id [index]:exp [r]:exp; formal_list = type id formal_rest* | {empty}; formal_rest = type id; type= {int_array} | {boolean} | {int} | {id} id; exp = {and} [l]:exp [r]:exp | {lt} [l]:exp [r]:exp | {plus} [l]:exp [r]:exp | {minus} [l]:exp [r]:exp | {times} [l]:exp [r]:exp | {length} exp | {arrayindex} [array]:exp [index]:exp | {methodcall} exp id exp_list | {integerliteral} integer_literal | {trueliteral} true | {falseliteral} false | {id} id | {this} this | {new} id | {newarray} exp | {not} exp ; exp_list = exp*; |