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:
service and rpc keywords. However, since the service runtime is not provided, it may not be that helpful to use the generated service "stub" code in native language.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.
git clone git://github.com/yesme/protobuf-parser.git
cd protobuf-parser
./bootstrap.sh
make
After that, a sample parser will be built.
This project includes 3 components:
dsl: Antlr grammar for Protocol Bufferprotos: Sample Proto files basically covered most of the (normal and) corner cases defining a Protocol Buffer filesampleparser: A sample protobuf parser implementationTherefore make will
sampleparser against the generated DSL source codeFor 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.