I'm using JavaCC for the first time and I'm noticing it's generating a lot of dead code. There are many lines that look like (pardon the spacing, it's automatic):
{if ("" != null) return result;}
throw new Error("Missing return statement in function");
}
Is it possible to avoid generating this dead code? It causes tens of compiler warnings that are hopefully avoidable.
Thanks!
Here's a full minimal example from the .jj file:
Statement UseStatement():
{
String dbName;
}
{
<USE> dbName=DbObjectName()
{
return new UseStatement(dbName);
}
}
Which generates:
final public Statement UseStatement() throws ParseException {String dbName;
jj_consume_token(USE);
dbName = DbObjectName();
{if ("" != null) return new UseStatement(dbName);}
throw new Error("Missing return statement in function");
}
Additionally JavaCC is generating a ParserTokenManager file which throws a TokenMgrError - but the code doesn't compile. It declares a protected int curChar where it should declare it a char. Googling this phrase shows many examples where it is correctly declared a char - is this just a lot of people hand-editing the result?