Skip to content

Grammar Name Conflict Golang with SPARQL issue #3758

@saucesaft

Description

@saucesaft

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 :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions