I "inherited" a project that uses JJTree from JavaCC to implement a simple language parser. Since the code was over 5 years old, I decided to update all dependencies, including JavaCC, to the latest release before I do any actual development.
Therefore, I deleted all the files generated by JJTree/JavaCC and used the latest version (5.0) to rebuild them. The resulting files, however, seem to miss fields and methods that were previously present and the code does not compile any more.
I assumed that something changed in JavaCC that requires me to update the grammar file, so I tried out the Interpretter example from the current JavaCC distribution, with the same results: missing class fields that do not allow the code to compile.
For example, here is a definition from SPL.jjt of the Interpretter example:
void Id() : { Token t; } { t = <IDENTIFIER> { jjtThis.name = t.image; } } The folder for this example contains an ASTId.java file which originally had this content:
public class ASTId extends SimpleNode { String name; public ASTId(int id) { super(id); } public ASTId(SPLParser p, int id) { super(p, id); } public void interpret() { stack[++top] = symtab.get(name); } } After I regenerated the AST*.java files, the content changed:
public class ASTId extends SimpleNode { public ASTId(int id) { super(id); } public ASTId(SPLParser p, int id) { super(p, id); } } There is a lot missing here and as a result the SPLParser.java generated file does not compile because it uses fields that are not defined in the corresponding classes.
What am I missing? Is there a JJTree or JavaCC option that I have to use? Perhaps a modification to make in the grammar file? Or, as I don't really know if the original files have been edited, am I supposed to directly modify the generated files and add the missing bits manually?
I have no experience with JavaCC, so I would appreciate any hints to resolve this issue.