求助 写一个java 表达式编译器
如题:有一个Map型的context,里面存有上下文中的值,
Student s = new Student();
Teacher t = new Teacher();
t.setStudent(s);
Map m = new HashMap();
m.put("stu",s);
m.put("tea",t);
context.put("stu",s),
context.put("tea",t),
context.put("map1",);
给定一个表达式:"abc\"ddd".indexOf(2)+map1.stu.getStudent()
把这个表达式翻译成为代码: "abc\"ddd".indexOf(2)+(Student)((Teacher)((java.util.Map) context.get("map1")).get("stu")).getStudent().
表达式要求:能支持类导航(比如说是map类型的,你去调用get方法,如果是一般类,则调用
方法调用
java的运算符,+,-,*,/ !=等
大家给点思路吧,怎样把表达式,翻译成为代码了!