Getting Started

Using the online web client

The easiest way to get started with Babelfish is to try the online web client where you can write or paste your code and run the parser to see the generated UAST.

Installing bblfshd locally

After playing with the web client, you will probably want to get Babelfish running locally. The first thing to do for that is to setup and run the bblfshd command. Once the server is running, you can connect to it using any of the available clients.

Prerequisites

Running with Docker (recommended)

The easiest way to run the bblfshd daemon is using Docker. You can do it in stateless mode, meaning that all installed drivers will be wiped out once you remove the container, or using a Docker volume to store part of the container internal filesystem and thus add persistence.

Notes on command line parameters to "docker run"

The only mandatory flag is --privileged. bblfshd uses containers itself to run language drivers, which currently requires it to run in privileged mode.

Exposing the port (9432) with -p 9432:9432 makes it easier to connect to the gRPC server from outside the container.

If you are behind an HTTP or HTTPS proxy server, for example in corporate settings, you will need to add the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables in the docker run command to configure HTTP or HTTPS proxy behavior.

Use this only for testing the installation; if you want to do any real parsing with files in your local filesystem you should use one of the clients which would also allow you to run XPath queries over the results.

Running standalone

A standalone distribution of bblfshd and bblfshctl can be found at the GitHub release page. This will contain a single binary that can be run anywhere but it depends on the ostree library as explained in the readme.

bblfshd is only provided for Linux distributions, since it relies on Linux containers to run language drivers. And bblfshctl can be found for Windows, macOS and Linux.

Using bblfshctl

The bblfshd daemon comes with a command line tool called bblfshctl, which can be used to monitor and manage the daemon.

If you are using the Docker image then the command line tool is provided with the bblfsh/bblfshd image and can be used with a docker exec command.

$ docker exec -it bblfshd bblfshctl --help

Usage:
bblfshctl [OPTIONS] <command>
Help Options:
-h, --help Show this help message
Available commands:
driver Manage drivers: install, remove and list
instances List the driver instances running on the daemon
parse Parse a file and prints the UAST or AST
status List all the pools of driver instances running

Driver management

The bblfshd's drivers can be installed, updated and removed with the driver command and its subcommands. Remember to prefix all these commands with docker exec -it bblfshd if you are running bblfshd from a Docker image.