In the first part of the tutorial, we created a GWT compatible parser module using JavaCC. In this second tutorial, we will wire up the GWT module to a basic GWT project.
This tutorial makes heavy use of animated gifs, which I make no apologies for - but sorry.
Step 7 - Create a Web Application (GWT) Project (using Eclipse)
Step 8 - Strip out the sample HTML from the generated project (Example1UI,html).\
Step 9 - Add the parser GWT module jarfile OR the pre-requisite parser project (** shown in the gif below) to the Java Build path of the GWT Project
Step 10 - Reference the parser GWT module from the newly created GWT UI project .gwt.xml file.
Step 11 - Write code in Example1UI project to use the parser on the client side. The code can be found here.
Step 12 - Compile GWT Project
To compile, simple right click the Eclipse1UI project, go to "Google" then click "GWT Compile" and click the "Compile" button.
JavaCC is certainly not the best parser generator looking at the quality of the generated code but it is (almost uniquely) excellent at generating small parsers with no external dependencies therefore it was the ideal candidate to adapt for GWT.
Building a runtime that avoids non-emulated GWT classes can be a challenge, but it is achievable. Also achievable are C# parsers generated from the same codebase translated via sharpen, but that is a significantly more complex tutorial.
- Source corresponding to this tutorial has been posted on github here. This includes 6.1.0 Release Candidate 1 of JavaCC and corresponding license files for the sake of convenience.