Identifying ECMAScript identifiers

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


On 8 March 2013 10:35, Yusuke SUZUKI <utatane.tea at gmail.com> 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.

https://code.google.com/p/mentaljs/source/browse/trunk/MentalJS/javascript/Mental.js#504

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: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130308/8666f35c/attachment.html>


More information about the es-discuss mailing list