Using Nashorn for a general-purpose JavaScript AST handler?

A. Sundararajan sundararajan.athijegannathan at oracle.com
Tue Feb 10 02:03:08 UTC 2015


Hi,

Nashorn parser API (http://openjdk.java.net/jeps/236)  will be pushed 
shortly to jdk9.  That should help with these use cases.

In the meanwhile, there is script API for parsing. This is loaded and 
called using

     load("nashorn:parser.js")

and calling top level function "parse".

For a sample, please try this one: 
http://hg.openjdk.java.net/jdk9/dev/nashorn/file/2feff3616ba7/samples/astviewer.js

Hope this helps,
-Sundar

On Tuesday 10 February 2015 03:16 AM, KARR, DAVID wrote:
>  From time to time, I've looked at using PMD for various metadata scanners for Java code.  It's very easy to define callbacks for various syntax elements and then gather data from those found elements.  I'm starting to see people looking at doing similar things for JavaScript code.  Is there a straightforward way to use Nashorn to do this kind of thing?



More information about the nashorn-dev mailing list