{"action":"created","issue":{"url":"https://api.github.com/repos/antlr/antlr4/issues/1459","repository_url":"https://api.github.com/repos/antlr/antlr4","labels_url":"https://api.github.com/repos/antlr/antlr4/issues/1459/labels{/name}","comments_url":"https://api.github.com/repos/antlr/antlr4/issues/1459/comments","events_url":"https://api.github.com/repos/antlr/antlr4/issues/1459/events","html_url":"https://github.com/antlr/antlr4/issues/1459","id":194204760,"number":1459,"title":"[golang target]  Specific grammar generates code that fails to compile","user":{"login":"syn-ful","id":10391779,"avatar_url":"https://avatars.githubusercontent.com/u/10391779?v=3","gravatar_id":"","url":"https://api.github.com/users/syn-ful","html_url":"https://github.com/syn-ful","followers_url":"https://api.github.com/users/syn-ful/followers","following_url":"https://api.github.com/users/syn-ful/following{/other_user}","gists_url":"https://api.github.com/users/syn-ful/gists{/gist_id}","starred_url":"https://api.github.com/users/syn-ful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syn-ful/subscriptions","organizations_url":"https://api.github.com/users/syn-ful/orgs","repos_url":"https://api.github.com/users/syn-ful/repos","events_url":"https://api.github.com/users/syn-ful/events{/privacy}","received_events_url":"https://api.github.com/users/syn-ful/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-07T23:32:24Z","updated_at":"2016-12-07T23:41:16Z","closed_at":null,"body":"  Before submitting an issue to ANTLR, please check off these boxes:\r\n \r\n- [x] I am not submitting a question on how to use ANTLR; instead, go to [antlr4-discussion google group](https://groups.google.com/forum/#!forum/antlr-discussion) or ask at [stackoverflow](http://stackoverflow.com/questions/tagged/antlr4)\r\n- [x] I have done a search of the existing issues to make sure I'm not sending in a duplicate\r\n\r\nPlease include information about the expected behavior, actual behavior, and the smallest grammar or code that reproduces the behavior. If appropriate, please indicate the code generation targets such as Java, C#, ...  Pointers into offending code regions are also very welcome.\r\n\r\n### Expected behavior\r\nGo code that successfully compiles.\r\n\r\n### Actual behavior\r\nWhen trying to compile Golang code from a grammar that has a mixture of non-greedy subrules and two or more \"?\" wildcard characters, the code fails to compile.  I'm using this grammar successfully with a Python2 target.\r\n\r\n```\r\n$ go run test_parse.go test.txt \r\n# _/Users/ccrook/git-repos/config_parser/antlr_playground/go_parser\r\ngo_parser/test_parser.go:337: no new variables on left side of :=\r\n```\r\n\r\n### Steps to reproduce the behavior\r\n\r\nDirectory structure:\r\n```\r\n├── Test.g4\r\n├── go_parser\r\n│   ├── Test.tokens\r\n│   ├── TestLexer.tokens\r\n│   ├── test_base_listener.go\r\n│   ├── test_lexer.go\r\n│   ├── test_listener.go\r\n│   └── test_parser.go\r\n├── test.txt\r\n├── test_parse.go\r\n```\r\n\r\nGrammar:\r\n  ***Notice multiple \"?\" wildcard chars in the `foo` parser rule.***\r\n\r\n```\r\ngrammar Test;\r\n\r\ninit\r\n  : .*? (foo .*?)+ ;\r\n\r\nfoo\r\n  : 'A' 'B'? 'C'?\r\n  ;\r\n```\r\n\r\nANLTR4 command: \r\n***Note: I'm pointing to a 4.6 version of the code (compiled from source 12/6).***\r\n```\r\njava -jar ../lib/antlr4-4.6-SNAPSHOT.jar -Dlanguage=Go -o go_parser Test.g4\r\n```\r\n\r\nAttempt to complile/run go code:\r\n```\r\n$ go run test_parse.go test.txt \r\n# _/Users/ccrook/git-repos/config_parser/antlr_playground/go_parser\r\ngo_parser/test_parser.go:337: no new variables on left side of :=\r\n```\r\n\r\nThe compiled go code attempts to declare the \"la_\" variable multiple times:\r\n```\r\n\tla_ := p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 3, p.GetParserRuleContext())\r\n\r\n\tif la_ == 1 {\r\n\t\t{\r\n\t\t\tp.SetState(22)\r\n\t\t\tp.Match(TestParserT__1)\r\n\t\t}\r\n\r\n\t}\r\n\tp.SetState(26)\r\n\tp.GetErrorHandler().Sync(p)\r\n\tla_ := p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 4, p.GetParserRuleContext())\r\n\r\n\tif la_ == 1 {\r\n\t\t{\r\n\t\t\tp.SetState(25)\r\n\t\t\tp.Match(TestParserT__2)\r\n\t\t}\r\n\r\n\t}\r\n\r\n\treturn localctx\r\n}\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/antlr/antlr4/issues/comments/265609280","html_url":"https://github.com/antlr/antlr4/issues/1459#issuecomment-265609280","issue_url":"https://api.github.com/repos/antlr/antlr4/issues/1459","id":265609280,"user":{"login":"syn-ful","id":10391779,"avatar_url":"https://avatars.githubusercontent.com/u/10391779?v=3","gravatar_id":"","url":"https://api.github.com/users/syn-ful","html_url":"https://github.com/syn-ful","followers_url":"https://api.github.com/users/syn-ful/followers","following_url":"https://api.github.com/users/syn-ful/following{/other_user}","gists_url":"https://api.github.com/users/syn-ful/gists{/gist_id}","starred_url":"https://api.github.com/users/syn-ful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syn-ful/subscriptions","organizations_url":"https://api.github.com/users/syn-ful/orgs","repos_url":"https://api.github.com/users/syn-ful/repos","events_url":"https://api.github.com/users/syn-ful/events{/privacy}","received_events_url":"https://api.github.com/users/syn-ful/received_events","type":"User","site_admin":false},"created_at":"2016-12-07T23:41:16Z","updated_at":"2016-12-07T23:41:16Z","body":"@pboyer - First off, thanks for all your hard work on the Golang target.  I think my parsing use-case hits on some uncommon grammar edge-cases.  But, I'm really excited to use ANTLR4 to solve some problems my team is facing.\r\n\r\nI'm currently testing against ANLTR4 4.6 code, which includes fixes https://github.com/antlr/antlr4/pull/1423 & https://github.com/antlr/antlr4/pull/1436\r\n"}}
{"actor":{"display_login":"syn-ful"}}