question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Grammar Name Conflict Golang with SPARQL issue

See original GitHub issue

Hi! So im trying to build a simple sparql parser for golang. Got the grammar for it from here: https://github.com/antlr/grammars-v4/tree/master/sparql

Then i ran this command to generate the code: java -jar antlr-4.10.1-complete.jar -Dlanguage=Go -o parser Sparql.g4

Now, after i included it into a Go program, without even using it, it errors out with this:

parser/sparql_parser.go:9806:9: cannot use s (variable of type *RdfLiteralContext) as type antlr.RuleContext in return statement:
	*RdfLiteralContext does not implement antlr.RuleContext (wrong type for String method)
		have String() IStringContext
		want String([]string, antlr.RuleContext) string
parser/sparql_parser.go:9829:13: cannot use NewRdfLiteralContext(p, p.GetParserRuleContext(), p.GetState()) (value of type *RdfLiteralContext) as type IRdfLiteralContext in assignment:
	*RdfLiteralContext does not implement IRdfLiteralContext (wrong type for String method)
		have String() IStringContext
		want String([]string, antlr.RuleContext) string

From what i’ve seen in another issue, i think this might be related to some grammar name conflicts with the code generation, but i dont know how to fix it. If someone recognizes the problem, i’ll be glad to make the changes myself and open a pull request.

Thanks 😃

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jimidlecommented, Aug 23, 2022

go.mod is updated and go.sum is added to the repo. We can close this when the PR is merged.

@parrt There are I think 3 outstanding PRs to fix go runtime bugs. I could merge them but do not have permissions (which also means I cannot get a free Github copilot license 😉

1reaction
jimidlecommented, Aug 22, 2022

Cool. Thanks for the verify.

On Mon, Aug 22, 2022 at 21:00 Ken Domino @.***> wrote:

@jimidle https://github.com/jimidle Yes, your fix works (git clone https://github.com/jimidle/antlr4.git; cd antlr4; git checkout feature/3758; …, but with the caveat that I need to “cd antlr4/runtime/Go/antlr4; go get golang.org/x/exp/slices”).

— Reply to this email directly, view it on GitHub https://github.com/antlr/antlr4/issues/3758#issuecomment-1222326262, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ7TMF5XHKCQPBCN23CZF3V2N2XDANCNFSM5ZOFG7ZQ . You are receiving this because you were mentioned.Message ID: @.***>

Read more comments on GitHub >

github_iconTop Results From Across the Web

antlr4 - Go Packages
Package antlr4 provides pre-compiled parsers for Go using the antlr4 generator. Example ¶. Example shows how to use the JSON lexer and parser....
Read more >
go - Conflict in repo name and module name - Stack Overflow
The issue is that you are using this file structure: qjson/engine.go qjson/errors.go. When you should just be putting them at the top level, ......
Read more >
Antlr4 Versions - Open Source Agenda
... Grammar Name Conflict Golang with SPARQL issue (target:go, type:cleanup) ... Augment error message during testing to include full cause of problem.
Read more >
SPARQL Query Language for RDF - W3C
abc identify the same variable. The possible names for variables are given in the SPARQL grammar. Grammar rules: [44], Var ...
Read more >
How do you deal with package name conflicts? - Google Groups
It is possible to customize the name under which you refer to an imported package. e.g. import myhttp "my/http". See http://golang.org/doc/go_spec.html# ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found