* @return the parsed tree
* @throws JexlException if any error occured during parsing
*/
protected ASTJexlScript parse(CharSequence expression, JexlInfo info, Scope frame) {
String expr = cleanExpression(expression);
ASTJexlScript script = null;
JexlInfo dbgInfo = null;
synchronized (parser) {
if (cache != null) {
script = cache.get(expr);
if (script != null) {
Scope f = script.getScope();
if ((f == null && frame == null) || (f != null && f.equals(frame))) {
return script;
}
}
}
try {
Reader reader = new StringReader(expr);
// use first calling method of JexlEngine as debug info
if (info == null) {
dbgInfo = debugInfo();
} else {
dbgInfo = info.debugInfo();
}
parser.setFrame(frame);
script = parser.parse(reader, dbgInfo);
// reaccess in case local variables have been declared
frame = parser.getFrame();
if (frame != null) {
script.setScope(frame);
}
if (cache != null) {
cache.put(expr, script);
}
} catch (TokenMgrError xtme) {