starscope
starscope copied to clipboard
Proper Go Parser
This has been floating at the back of my mind for a while, but it really wouldn't be too difficult to hand-write a proper lexer/parser for Go since the syntax is so uniform and simple (possibly eventually as a separate gem).
This would permit proper parsing of all the weird corner cases that the current version breaks on, and much better recognition of variable uses, etc. Go provides a very nice spec with a full formal grammar etc (https://golang.org/ref/spec) so the information is available, I just need to bother to write it.
I don't have a clear understanding of what starscope requires, but doesn't go already provide most of what you'd need, well beyond just the spec. See, for example: https://golang.org/pkg/go/ast/#example_Inspect
Is the problem that code for starscope would have to be in ruby?
code for starscope would have to be in ruby?
Yes. I've thought about writing a small tool in Go and then having starscope spawn it to get the AST, but on many files that would probably be too slow, since spawning processes is expensive.