import java.util.*; public abstract class Expression { public static Expression parse(Scanner tokens) throws Exception { if (tokens.hasNext("\\(")) { // if next token is a left paren return FunCall.parse(tokens); // then it must be a FunCall } else { return Literal.parse(tokens); // else it must be a Literal } } abstract public double eval() throws Exception; public void accept(ExpVisitor v) { } }