Identifying ECMAScript identifiers

gaz Heyes gazheyes at
Fri Mar 8 02:49:20 PST 2013

On 8 March 2013 10:35, Yusuke SUZUKI <utatane.tea at> wrote:

> Yeah. We, Esprima developers, parse UnicodeData.txt to generate identifier
> identification functions.
> I wrote simple UnicodeData.txt parser and generated RegExp[1]. These
> functions are also used in Acorn.

RegEx is slower. I suggest using if statements on char codes and < and > to
check it's within the range of z-a etc and then separate functions to
handle higher ascii variables only when needed and then compare the char
codes are within the ranges of allowed identifiers.

I still have to optimize that function further by removing <= and >= and
maybe separating each identifier range into their own function since higher
non-alpha variables take longer to parse since they are at the end of the
if statement.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list