I am a beginner of antlr. I was trying to use visitor in my code and following the instruction on the net. However, I found out that the visitor was not entering the method
You have to call super
if you want ANTLR4 to visit children. Like this:
@Override
public Integer visitPgm_body(@NotNull MicroParser.Pgm_bodyContext ctx){
super.visitPgm_body(ctx);
System.out.println(ctx.getText());
return 467;
}
@Override
public Integer visitProgram(@NotNull MicroParser.ProgramContext ctx){
super.visitProgram(ctx);
System.out.println("11");
return 456;
}
You have to think about where to put your logic: before super
or after.