rbNarcissus - A JavaScript Parser ported to Ruby @ idontsmoke.co.uk

By

rbNarcissus is a port of the Mozilla Foundation's Narcissus JavaScript parser written in Ruby. It currently only consists of a parser and does not interpret JavaScript.

Get the source! »

Feel free to download, use and abuse the script. Because it's derived from the original Narcissus source code the tri-licence remains and you are able to choose from the MPL 1.1, GPL 2.0 and LGPL 2.1 licences, you lucky people.

Useage

To parse some JavaScript you need to call the parse function with three parameters; source, filename and line. The first is a String containing the JavaScript, the second is a String with the name of the file the script came from and the third is the line to start parsing from.

An example script which makes use of the parser is available: parse.rb. The script accepts two arguments, the first a filename and the second a function name. If the function name is omitted the file is parsed and a list of the functions contained in the file is printed to standard out and if a function name is passed in the source of the function is printed to standard out.

Bug Reports, Comments and Communication

If you encounter anything unexpected please send me a bug report and please include the script or an example which shows the flaw if you are able.

Version History

v0.2 2006-04-25
Numerous bugfixes making the parser fairly robust
v0.1 2005-08-04
Initial release

Have at it!