Open jonlundy opened 3 months ago
func (is *InputStream) GetTextFromInterval(i Interval) string {
return is.GetText(i.Start, i.Stop)
}
...
func (c *CommonTokenStream) GetTextFromInterval(interval Interval) string {
CharStream is an interface. Can you elaborate on what you mean?
I might be hitting this. I'm following this example: https://blog.gopheracademy.com/advent-2017/parsing-with-antlr4-and-go/
And, I'm hitting this error:
cannot use is (variable of type *"github.com/antlr4-go/antlr".InputStream) as "github.com/antlr4-go/antlr/v4".CharStream value in argument to parser.NewCalcLexer: *"github.com/antlr4-go/antlr".InputStream does not implement "github.com/antlr4-go/antlr/v4".CharStream (wrong type for method GetTextFromInterval)
have GetTextFromInterval(*"github.com/antlr4-go/antlr".Interval) string
want GetTextFromInterval("github.com/antlr4-go/antlr/v4".Interval) string compiler[InvalidIfaceAssign](https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#InvalidIfaceAssign)
AFAICT, the only difference between what it has and what it wants is the "v4" at the end.
The article is out of date. please read the go README and switch to the new repo for importing the go runtime module. You also need antlr 4.13.1
Sorry for the false alarm! I'm learning Go and Antlr at the same time, and made a silly mistake. Thanks for pointing me in the right direction!
Hi, the commit here: https://github.com/antlr/antlr4/commit/c96c9ccea0be86f5dbc473052893674759dcc881
the
CharStream
signature forGetTextFromInterval(Interval) string
https://github.com/antlr/antlr4/blob/dev/runtime/Go/antlr/v4/char_stream.go#L11seems to have missed changing the pointer for
NewInputStream(data string) *InputStream
https://github.com/antlr/antlr4/blob/dev/runtime/Go/antlr/v4/input_stream.go#L48