Is there a version of Javacc that outputs javascript code?

I am looking for a parser generator that accepts a Javacc grammar file (.jj) and generates a parser in Javascript (instead of Java). Is there such a thing? Alternatively, how difficult would it be to convert the .jj file to what ANTLR (which Javascript can output) can understand?

+4
source share
3 answers

I am looking for a parser generator that accepts a Javacc grammar file (.jj) and generates a parser in Javascript (instead of Java). Is there such a thing?

Apparently not.

Alternatively, how difficult would it be to convert the .jj file to what ANTLR (which Javascript can output) can understand?

That would be nontrivial, and you would need to do it manually. But the real degree of difficulty probably depends on the grammar you are trying to convert.


It is worth noting that there are other parser generators that output parsers in Javascript. (And no, I will not list them or recommend!)

Obviously, the input language will be different from Javacc input.

+3
source

Google GWT compiles Java code for JavaScript if only a specific subset of the JDK is used. I'm also not sure how many GWT-specific tricks. But it could be: using javacc to generate java code, and then GWT to translate it into JavaScript.

+1
source

I recently added support for the Java compatible goal of GWT compatibility (no dependency on Java IO classes). I recently wrote a couple of blogs on how to use JavaCC so that a JavaScript parser can be generated via GWT. Link below:

Creating parsers for the web using JavaCC and GWT (post on my blog)

JavaCC 6.1 Development Build

0
source

Source: https://habr.com/ru/post/1441781/


All Articles