How do I change the parent class in ANTLR-3?
-
27-09-2019 - |
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?
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