Protobuf Parser

Overview

The goal of this project is to provide an open-sourced, easy-to-use Protocol Buffer parser for further usage. Protocol Buffer is "Google's data interchange format", which is generously open-sourced. It is widely used as the wire-format for RPC and structure data record. For extended reading on this topic, please refer to its documentation.

The offical Protocol Buffer distribution generally includes 3 components:

This project provides a fully-compatible Protocol Buffer parser based on Antlr 3. It enables developers to:

This project is inspired by sirikata's ProtoJs project which uses Antlr as well, but fully rewrote.

Install

git clone git://github.com/yesme/protobuf-parser.git
cd protobuf-parser
./bootstrap.sh
make

After that, a sample parser will be built.

How does it work

This project includes 3 components:

Therefore make will

  1. build the DSL grammar into Java source code
  2. build sampleparser against the generated DSL source code

For the one who wants to provide Protocol Buffer implementation, or provide Service implementation, please take a look at sampleparser/SampleParser.java - it's a sample shows how to use it.

In order to test the compatibility with protoc (Google's Protocol Buffer Compiler), run the following command:

make testprotos

In order to test the current parser, run the following commands. It will translate the input proto file into AST (Abstract Syntax Tree).

make testparsersimple  # simply test if the parser works
make testparserverbose # run the parser and print out the AST

For any question, please feel free to mail jacky.chao.wang@gmail.com for more information.