lua-users home
lua-l archive

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

On Fri, Oct 01, 2010 at 12:30:36PM -0400, John Passaniti 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.

When I have run into this kind of a problem, I've broken them up into
a two part solution:

1. Write a script (Perl, Python, Ruby, Lua) to parse a text version of
the Word file and output an intermedia format (JSON, Lua, YAML, XML?)

2. Write a script to read the generated representation from the intermediate
format above and produce required format.

A couple of notes:

In my case, the input document usually has a consistent enough structure
that the intermediate "parser" script is quite amenable. Otherwise it will
be painful.

I usually use catdoc or antiword to convert the Word format to plaintext

'repeated' and 'optional' are both metadata and could each be represented by
an optional key in the message table:

      OPT_MUTE = {
          option = 0x02,
          read = true,
          write = true,
          message = {
                  name = "type",
                  type = OutputInput,
                  desc = "Channel Type"
                  name = "number"
                  type = ChannelNumber,
                  desc = "Channel Number"
                  name = "mute"
                  type = OffOn,
                  desc = "Mute Status"
              repeated = { "number" },
              optional = { "mute" }

Handling this in the payload depends on your wire protocol.
Note that by using tags to represent each message component ala protocol buffers or
thrift, determining the presence of optional or repeated elements just falls
to the generated code: check type and skip for optional, loop, check type and
skip for repeated.


I am easily satisfied with the very best.
	--Winston Churchill