Brendan Whelan
Brendan Whelan

Reputation:

Can ANTLR generate a parser class that is final?

I'm using ANTLR 3.1 and ANTLRWorks to generate a parser class in Java. The parser performs better if I mark the generated class with the Java final keyword. The problem is: I am adding this keyword manually after each time I re-generated the code from the ANTLR grammar. Is there anyway, in the grammar, of telling ANTLR to add the final keyword to the generated parser class definition?

Upvotes: 1

Views: 353

Answers (2)

Brendan Whelan
Brendan Whelan

Reputation:

From this thread (oops- my bad), it looks like it's not possible to do it yet. :(

Upvotes: 0

Pete Kirkham
Pete Kirkham

Reputation: 49311

What version of Java are you using? The more recent ones should detect leaf classes automatically, as should any since 1.3 in -server mode.

Upvotes: 1

Related Questions