-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Making compatibility with actions and predicates in Go better #3174
Conversation
@@ -325,6 +325,9 @@ func (l *<lexer.name>) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex | |||
*/ | |||
RuleActionFunction(r, actions) ::= << | |||
func (l *<lexer.name>) <r.name; format="cap">_Action(localctx <if(r.factory.grammar.lexer)>antlr.RuleContext<else>*<r.ctxType><endif>, actionIndex int) { | |||
this := l | |||
_ = this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment to _
is needed so that Go does not complain if this
does not end up used at the end.
Looks good to me 👍🏽 |
Not sure why CI is failing. That should be fixed on master, no? |
Master is failing too on AppVeyor: -> thousands of the above |
I thought that was fixed with #3176? |
Try running |
I think, and this might be wrong, but I think that the problem is that the testing environment doesn't set up the main module, i.e., the package of the tests isn't a part of a module, so trying to use modules makes the go tool complain. I think I overlooked that part in my own PR |
Care to then make a new PR fixing Go tests on master and then I can rebase here? |
Awesome! Thanks! |
I just rebased the branch. |
Running tests now... |
Yay! everything passed :) |
Thanks! |
This change is a simple workaround which makes grammars which use actions and predicates calling something on
this
work also in Go.See antlr/grammars-v4#2177 for a bit of background. This change would allow compiling JavaScript grammar with antlr with a bit less manually patching. (There are few more steps to do to get it working.)