Question

By default, a parser generated using ANTLR-3 extends from org.antlr.runtime.Parser. How do I have it extend my custom class instead?

Was it helpful?

Solution

You can do that by using the superClass option in your grammar:

grammar G;

options {
  superClass = YourCustomClass;
}

parse
  :  ...
  ;

which will generate:

public class GParser extends YourCustomClass {

    // ...

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top