allow expressions to end in a $ eg. in PHP "test$" is valid, no longer throwing an error if expression cant be parsed, just log the error and return expression literally

This commit is contained in:
Ralf Becker 2014-02-14 09:03:12 +00:00
parent 420234cb46
commit efa9c562bb

View File

@ -64,6 +64,12 @@
str += '$$';
break;
}
// check for '$' as last char, as in PHP "test$" === 'test$', $ as last char is NOT expanded
if (_p.pos == _p.expr.length)
{
str += '$';
break;
}
if (str)
{
_tree.push(str); str = "";
@ -401,6 +407,7 @@
_vars = [];
}
try {
// Initialize the parser object and create the syntax tree for the given
// expression
var parser = _php_parser(_expr);
@ -415,7 +422,13 @@
// Log the successfull compiling
egw.debug("log", "Compiled PHP " + _expr + " --> " + js);
}
catch(e) {
// if expression does NOT compile use it literally and log an error, but not stop execution
egw.debug("error", "Error compiling PHP "+_expr+" --> using it literally ("+
(typeof e == 'string' ? e : e.message)+")!");
return function(){ return _expr; };
}
// Prepate the attributes for the function constuctor
var attrs = [];
for (var i = 0; i < _vars.length; i++)