Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Go] Add Super property for Base*Visitor struct #3087

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

terwey
Copy link

@terwey terwey commented Feb 17, 2021

Add a super property to the Base*Visitor generated code allowing to only override the required Visitors vs implementing each one in its entirety.

Example code:

	type fooVisitor struct {
		*parser.BaseFooVisitor
	}

	is := antlr.NewInputStream("4+6")
	lexer := parser.NewAnalyzerLexer(is)
	stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)
	p := parser.NewAnalyzerParser(stream)

	fv := &fooVisitor{}
	fv.BaseFooVisitor = &parser.BaseFooVisitor{}
	
	// this is new
	fv.BaseAnalyzerVisitor.SetSuper(fooVisitor)
	fv.Visit(p.Prog())

Add a super property to the Base*Visitor generated code allowing to only override the required Visitors vs implementing each one in its entirety.
@terwey terwey changed the title Add Super property [Go] Add Super property for Base*Visitor struct Feb 17, 2021
@terwey terwey marked this pull request as ready for review February 17, 2021 16:57
@mitar
Copy link
Contributor

mitar commented May 4, 2021

This is pretty interesting approach.

@parrt
Copy link
Member

parrt commented Dec 28, 2021

@terwey is this superseded by #3299 ?

@dragonfax dragonfax mentioned this pull request Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants