Giter Site home page Giter Site logo

lib's Introduction

Babelfish library

This is a PoC of a future Babelfish lib. It includes a C++ gRPC client, a minimal C API wrapper over this C++ code and a Python example on top of this C API.

Have a look at the DESIGN document for more information about why C++ was chosen.

It may be interesting to use SWIG to generate bindings instead of doing it by hand. Alternatively python bindings could be constructed with CFFI too.

Build

You need gRPC for C++ installed. You may want to look at its documentation.

If you have problems with GCC7, use an older version or clang instead.

If you have problems with OpenSSL 1.1, switch to OpenSSL 1.0:

PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig make

Note that if gRPC is built from sources, you may need to setup the environment properly, i.e.:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=/usr/local/lib

With gRPC properly installed, make should work:

> PKG_CONFIG_PATH=/usr/local/lib/pkgconfig make
protoc --cpp_out src github.com/gogo/protobuf/gogoproto/gogo.proto
g++ -Isrc -fPIC -std=c++11 -I/usr/local/include -pthread  -c -o gogo.pb.o src/github.com/gogo/protobuf/gogoproto/gogo.pb.cc
protoc --cpp_out src github.com/bblfsh/sdk/uast/generated.proto
g++ -Isrc -fPIC -std=c++11 -I/usr/local/include -pthread  -c -o uast.pb.o src/github.com/bblfsh/sdk/uast/generated.pb.cc
protoc --cpp_out src github.com/bblfsh/sdk/protocol/generated.proto
g++ -Isrc -fPIC -std=c++11 -I/usr/local/include -pthread  -c -o protocol.pb.o src/github.com/bblfsh/sdk/protocol/generated.pb.cc
protoc --grpc_out src --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` github.com/bblfsh/sdk/protocol/generated.proto
g++ -Isrc -fPIC -std=c++11 -I/usr/local/include -pthread  -c -o protocol.grpc.pb.o src/github.com/bblfsh/sdk/protocol/generated.grpc.pb.cc
g++ -Isrc -fPIC -shared src/bblfsh.cc -o libbblfsh.so `pkg-config --cflags --libs grpc++ libprotobuf-c` protocol.grpc.pb.o protocol.pb.o uast.pb.o gogo.pb.o

Run

Make sure bblfsh server is running.

You can look at the documentation for instructions on how to build and run bblfsh server.

Once the server is running, just call the python sample client:

python2 main.py filename

where filename is the path to the file to parse. For example:

> python2 main.py main.py
gRPC call worked!
Module
Import
Import.names
...

lib's People

Contributors

abeaumont avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.