Hi,
I'd like to share my experience of using a SableCC-generated parser with Google Web Toolkit. For those who don't know, GWT is a Java-to-Javascript compiler that allows developing client-side web applications using Java. I faced some issues when attempting to compile the parser with GWT.
1. SableCC-generated parser uses some classes from
java.io that are absent in GWT JRE Emulation Library:
PushbackReader
DataInputStream
BufferedInputStream
2. It also uses getClass().getResourceAsStream() which is absent as well.
3. Class Node implements Cloneable interface which is not supported as well.
4. It uses class Hashtable which is absent as well (although HashMap is supported).
Here is how I defeated them:
1. Rewrote Lexer and Parser to get their data tables from memory instead of .dat files. Basically, wrote a DataInputStream that accepts a byte array as a constructor parameter and has methods readInt(), readChar(), and close(). Wrote a generator program that surgically changes the generated Parser and Lexer classes to use the new class every time sablecc is run.
2. Added classes called PushbackReader, Hashtable (extends HashMap), and interface Cloneable and added them to the packages from which they are referenced. This tricked the compiler into loading those classes instead of the JRE classes.
I admit that this is a big hack but the good news is that it's possible to change SableCC to generate GWT-compliant parser. I am not sure if anyone else is interested in this feature though.
Alexander