[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Protocol Specification in Lua
- From: Alexander Gladysh <agladysh@...>
- Date: Sun, 3 Oct 2010 00:04:12 +0400
On Fri, Oct 1, 2010 at 20:30, John Passaniti <email@example.com> wrote:
> I'm looking for a little design inspiration from others. I have a
> basic approach (which I'll describe, below), but chances are good that
> someone here has already implemented something like this or can see a
> better solution.
> I have a UDP-based communications protocol for controlling a device.
> The protocol is implemented in C and specified in a tedious Microsoft
> Word document. The base protocol is simple and extensible and isn't
> interesting. What is interesting is there are a large number of
> binary messages, each with a unique structure. I'm bothered that when
> I change the C code to add a new message, I also have to update the
> Word document. The two are separate things.
We have a small Lua-based DSL, where message structures are described like this:
doc:description [[A synthetic example]];
doc:comment [[Pass 0 for all]];
This description is translated to server-side protocol handlers code
(in several formats, XML, JSON etc.) and client side protocol-handling
code (in several languages). Also a special tool generates a fancy PDF
file with the full protocol specification, based on the same