Sandboxing and parsing jQuery in 100ms

gaz Heyes gazheyes at
Wed Nov 7 08:53:28 PST 2012

Hi all

Check this out:

I have written a complete parser/sandbox based on tracking opening and
closing characters (I will be writing a paper on this in more detail) it
works by using the opening and closing states to store the current state.
For example:


Here my parser looks at the state before "{" and labels it as a object
literal. I track that state and when a "}" is encountered I can use the
balanced nature of javascript to my advantage by looking up the current
count of characters which allows me to identify that "}" is in fact a
closing object literal. It isn't that simple I here you say and there are
complicated cases such as:
var xyz, xyz

Here my parser takes an additional step using the characters it tracks such
as "{" and "(" etc I can use that to uniquely identify the var statement
context by using indexes of these characters to know the comma is in fact
part of a var statement. Lets look at another example and I'll illustrate
with comments how the tracking works.

//C = curly
//P = Paren

//C 1
function x
  var x, y // C2 + P0 = Var statement
  ; // C2 + P0 = '';

By using these reference points no matter how many nested expressions you
have you can still know the statement it's part of or the character should
be a particular state. Please let me know your comments and I'll post the
paper when it's done.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list