/** * Static service to get a term from its string representation, providing a specific operator * manager */ public static Term parseSingleTerm(String st, OperatorManager op) throws InvalidTermException { try { Parser p = new Parser(op, st); Token t = p.tokenizer.readToken(); if (t.isEOF()) throw new InvalidTermException("Term starts with EOF"); p.tokenizer.unreadToken(t); Term term = p.expr(false); if (term == null) throw new InvalidTermException("Term is null"); if (!p.tokenizer.readToken().isEOF()) throw new InvalidTermException("The entire string could not be read as one term"); term.resolveTerm(); return term; } catch (IOException ex) { throw new InvalidTermException("An I/O error occured"); } }