Ilya Lakhin
Ilya Lakhin

Reputation: 1944

Java parser written in JavaScript

I'm looking for implementation of Java source code parser written in JavaScript language. Do you know any?

Upvotes: 10

Views: 5696

Answers (4)

Oleg Mazko
Oleg Mazko

Reputation: 1830

Here is Java 1.7 parser http://mazko.github.io/jsjavaparser/ using PEG grammar by Roman R Redziejowski http://www.romanredz.se/Mouse/Java.1.7.peg

Upvotes: 5

Chris Dennett
Chris Dennett

Reputation: 22721

Have a look at ANTLR which can have Javascript as a target, with the Java 1.5 grammar at http://www.antlr.org/grammar/1152141644268/Java.g

Edit: link stopped working - try https://github.com/antlr/grammars-v4/blob/master/java/Java.g4 :)

Upvotes: 11

Stephen C
Stephen C

Reputation: 718826

I don't know of a Java parser per se, but here are some parser generators for Javascript:

If is one of these is ready for prime-time, you should be able to translate the grammar for Java into the requisite form and then use the PGS's to generate a Java parser in Javascript.

Of course, that will only give you a parser. If you want to do type analysis (as your comment seems to be saying), that's not what a parser does.

Upvotes: 3

WEFX
WEFX

Reputation: 8562

Try the Rhino engine?

Upvotes: -3

Related Questions