I've looked through the example of "Interpreter" coming with the JavaCC package. It allows the syntax of parallel relational expression but it didn't give the correct answer.
boolean a; a = 1<2<3; write a; This will give the ClassCastException because the interpreter process "1<2" and put the boolean into the stack while the third variable, 3, is an integer so it is not comparable with a boolean.
I try changing the ASTLTNode.java which contains
public class ASTLTNode extends SimpleNode { public ASTLTNode(int id) { super(id); } public ASTLTNode(ShawaParser p, int id) { super(p, id); } public void interpret() { jjtGetChild(0).interpret(); jjtGetChild(1).interpret(); stack[--top] = new Boolean(((Integer)stack[top]).intValue() < ((Integer)stack[top + 1]).intValue()); } } If I add the "top++" at the end of interpret(), the stack will keep the last value but when process done, it will show the last digit not a boolean.
Do you guys have any ideas of doing this? Thanks a lot.