bblfsh / documentation

Babelfish documentation (GitBook)
https://docs.sourced.tech/babelfish
Creative Commons Attribution Share Alike 4.0 International
41 stars 30 forks source link

Update the "Writing a driver" section #269

Closed dennwc closed 5 years ago

dennwc commented 5 years ago

Update the "Writing a driver" section. The purpose of the PR is not to make it perfect, but at least to make it closer to the current state.

There are still a lot of TODOs which should be addressed in the following PRs.

With those changes, you should be able to build a basic "echo" driver and know how to run the build system and the tests.

Signed-off-by: Denys Smirnov denys@sourced.tech


This change is Reviewable

ncordon commented 5 years ago

writing-a-driver/babelfish-sdk.md, line 25 at r1 (raw file):

This will fetch the SDK repository to the modules cache and will install the bblfsh-sdk CLI to $GOPATH/bin/bblfsh-sdk.

This is not working for me:

mkdir driver-from-scratch
cd driver-from-scratch
go mod init driver
go get -u -v github.com/bblfsh/sdk/v3/...
# go: finding github.com/bblfsh/sdk/v3/... latest
# Fetching https://github.com?go-get=1
# Parsing meta tags from https://github.com?go-get=1 (status code 200)
# go get github.com/bblfsh/sdk/v3/...: no matching versions for query "latest"

and ~/go/bin/ dos not contain bblfsh-sdk

Maybe it's my fault that this does not work, but I want to make sure install instructions are correct

ncordon commented 5 years ago

writing-a-driver/babelfish-sdk.md, line 25 at r1 (raw file):

Previously, ncordon (Nacho Cordón) wrote…
This is not working for me: ``` mkdir driver-from-scratch cd driver-from-scratch go mod init driver go get -u -v github.com/bblfsh/sdk/v3/... # go: finding github.com/bblfsh/sdk/v3/... latest # Fetching https://github.com?go-get=1 # Parsing meta tags from https://github.com?go-get=1 (status code 200) # go get github.com/bblfsh/sdk/v3/...: no matching versions for query "latest" ``` and `~/go/bin/` dos not contain `bblfsh-sdk` Maybe it's my fault that this does not work, but I want to make sure install instructions are correct

According to https://github.com/golang/go/issues/27215, for Go version 1.12 you have to do

go get -u -v github.com/bblfsh/sdk/v3/
go get -u -v github.com/bblfsh/sdk/v3/...

for it to work, but Go 1.13 is still in beta (?) so it may be worth it to update install instructions

ncordon commented 5 years ago

writing-a-driver/babelfish-sdk.md, line 25 at r1 (raw file):

go get -u -v github.com/bblfsh/sdk/v3/ At least when I do that, I do not get the bblfsh-sdk in $GOPATH/bin/. I need to type both commands

ncordon commented 5 years ago

writing-a-driver/babelfish-sdk.md, line 92 at r1 (raw file):

When the driver executes the parser, the former entry point should run a main loop similar to the example below. It should read requests from standard input \(which contain a string with the contents of the source to parse\), parse it generating the native AST and write a response to the standard output.

Requests and responses must be serialized in JSON format on a single line finished with a Unix newline character \('\n'\) so the driver can iterate over the standard input line by line. This means so the language selected to implement the parser should support it in the standard library or any third party module.

Does the JSON response have to comply with some format?

ncordon commented 5 years ago

writing-a-driver/babelfish-sdk.md, line 25 at r1 (raw file):

Previously, dennwc (Denys Smirnov) wrote…
Interesting. I'll try to reproduce it.

go version returns go1.12.6 linux/amd64 for me

I am pretty sure if I am having this error probably all of Arch based systems are going to have it, since installation of packages in Arch through pacman is pretty robust and consistent from one Arch to another Arch system. I do not know if it may be due to the go version...

ncordon commented 5 years ago

writing-a-driver/babelfish-sdk.md, line 25 at r1 (raw file):

go install github.com/bblfsh/sdk/v3/cmd/...

Yes it does