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

Re: Greetings and comments on MCP 2.1



"Ken Fox" <fox@mars.org> writes:

> I strongly oppose this proposal to eliminate _data-tag.  In my
> parser, this would greatly _complicate_ things.

Let me give an algorithm for _data-tag less parsing of multiline data
so that you can see how simple it is.

For Java, the obvious internal representation of an MCPMessage is a
hash table.  The value associated with a multiline key-value pair is
an array of strings.  The interline parser state is a pair of hash
tables.  One table maps the data tag of incomplete multiline key-value
pairs to vectors of strings, and the other maps the same data tag to
an MCPMessageParseState object which is a pair consisting of an
incomplete MCPMessage and a hash table mapping incomplete data tags to
argument names.  There are three cases to consider when parsing a
message line:

Case of a start message line:

    Parse the line creating an MCPMessageParseState object.  If the
    message argument hash table in this object is empty, there were no
    multiline key-value pairs, so return the MCPMessage.  Otherwise,
    create an empty vector for each data tag and add a map from the data
    tag to the vector to the vector hash table.  For each data tag, add
    a map from the data tag to the MCPMessageParseState object to the
    parse state hash table.  Return nothing. 

Case of a continuation line:

    If the data tag is not in the vector hash table, ignore the
    message line.  Otherwise append the line's data to the vector in
    the vector hash table associated with the data tag.

Case of an end message argument line:

    If the data tag is not in the vector hash table, ignore the
    message line.  Otherwise convert vector in the vector hash table
    to an array of strings and delete the vector hash table entry
    associated with the data tag.  Extract the MCPMessageParseState
    object from the state hash table and delete the entry.  Retrieve
    the message argument associated with the data tag from the
    argument hash table in the MCPMessageParseState and delete the
    entry.  Associate the message argument with the array of strings
    in the MCPMessage object.  If the message argument hash table is
    empty, the parse of the message is complete, so return the
    MCPMessage object.  Otherwise, return nothing.

John