Wednesday, April 14, 2010

Google's Protocol Buffers implemented in Xtext

Eat your own dog food is an excellent advice. So do I and therefore I use Xtext to implement languages from time to time. Usually these are languages we either implement for one of our open source projects (examples or the recently added MWE2 language I developed together with Sebastian) or for customer projects.

A couple of weeks ago I implemented the DSL of Google's Protocol Buffers using Xtext. I don't want to add it as an example to Xtext, because it doesn't add any specific value over the existing examples nor do I have the time to start a new project or maintain it in any way. However, I thought there might be some people who want to have a look as an example or want to take it over and extend/maintain it further.

I didn't know Protocol Buffers so I had to learn the language using the documentation and the unit tests they have. The concepts of the language (scoping, imports) are very close to Xtext's defaults so that it took me only 3 hours to implement it. Most of the time was spent to get the lexing part right, which was not so close to the defaults :-).

If you want to have a look, here are the two Eclipse projects. Feel free to do whatever you want with that code. I of course would love to see someone creating a new open source project for it or adding it to an existing. In any case I'll be glad to help you getting started with the code.

The code should work with every post-M6-milestone as well as the final Xtext 1.0.0 release which will be published in June.

I also recorded a short screen cast demoing the result:

6 comments:

  1. Geez, what a coincidence, I also submitted a Xtext based Eclipse editor for Google's Protocol Buffers two weeks ago:
    http://code.google.com/p/protobuf4e/

    ReplyDelete
  2. Cool stuff, I really like XText.

    Your blog brought me to the idea of doing the same for Apache Etch
    https://cwiki.apache.org/ETCH/

    Using the current helios release it worked like a charm :)

    Have a look here:
    http://github.com/grandyho/Etchclipse

    ReplyDelete
  3. Thats absolutely fantastic!

    The link to the source is not resolving for me, I would be exceptionally greatful if you could share the eclipse projects....
    Thanks.

    ReplyDelete
  4. I'm sorry, but I don't have the code anymore. I suggest you try Cedric's project over at google code:
    http://code.google.com/p/protobuf4e/

    ReplyDelete
  5. Sven, sorry to hear you removed the project. I was just looking around at what's out there. Too bad.

    ReplyDelete
  6. The screaming sea gulls in the background are awesome! ;-D
    I was a little confused for a moment wondering what these birds are doing here in Frankfurt...

    ReplyDelete