Sorry for the delay, I took some time to think about this. I've decided to enforce functions by using a semi-colon at the beginning and the end.
So for example :-
function x(){}
becomes:-
;function x(){};
Function expressions are modified with parens
so:
1,function x(){}
becomes:
1,(function x(){})
Which should enforce expressions without breaking anything. This way the syntax will break but should not result in a sandbox escape. I can then fix the syntax errors once the vector has been eliminated.
Syntax checking is hard and although it was a really nice idea I'm not sure it will be possible since it would require me to backtrack the code or look forward and parse multiple times. Patterns such as:-
(function(){
})();
Will always result in a syntax error unless the whole code is checked each time, I could store various locations where I placed a semi-colon and remove them before the final eval but it would be too slow IMO.
------------------------------------------------------------------------------------------------------------
"People who say it cannot be done should not interrupt those who are doing it.";
labs : [
www.businessinfo.co.uk]
blog : [
www.thespanner.co.uk]
Hackvertor : [
hackvertor.co.uk]
Edited 1 time(s). Last edit at 08/01/2011 11:52AM by Gareth Heyes.