//JSONparser.go
type TreeShapeListener struct {
*parser.BaseJSONListener
}
func NewTreeShapeListener() *TreeShapeListener {
return new(TreeShapeListener)
}
func (this *TreeShapeListener) EnterEveryRule(ctx antlr.ParserRuleContext) {
fmt.Println(ctx.GetText())
}
The method ```EnterEveryRule``` is called for every rule. How can I overwrite the method for the other listener events, such as `func (s *BaseJSONListener) EnterObj(ctx *ObjContext) {}`?
I've tried appending the following to `JSONParser.go`, but the listener event is either not triggered or my function definition is wrong:
func (this *TreeShapeListener) EnterJson(ctx antlr.ParserRuleContext) {
fmt.Println("entered object!!")
}
Note that defining the function within the generated code works, however is obviously overwritten when I regenerate code with ANTLR.
Thanks,
Kit