lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Oct 1, 2010 at 20:30, John Passaniti <john@japanisshinto.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.

...

My 2c:

We have a small Lua-based DSL, where message structures are described like this:

api:call "/something"
{
  doc:description [[A synthetic example]];

  api:input
  {
    input:ACCOUNT_ID "u";
    input:SESSION_ID "s";
    input:DB_ID "id"
    {
       doc:comment [[Pass 0 for all]];
    };
  };

  api:output
  {
    output:ROOT_NODE "result"
    {
      output:INTEGER "count";
    };
  };
}

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
descriptions.

HTH,
Alexander.