if your going to write a parser
Whats the point in talking about it if you don't get it done?
I think a DOM type OO structure
If you want it to be as generic as you have written up then yes. Secretly I was hoping it was going to be much simpler then that.
If we merely returned a string then we could end up encapsulating this whole spec inside that string again leading to lots of wasteful processing and various competing standards at varying layers to think of
I was kind of thinking that this is what was going to happen anyways. Regardless of any constraints we place on the system, or how deep we parse, the parser is never going to know what the data in the string means. It is going to have to leave it in a string, both the key and the data are going to have to be left as strings.
Now we could use a Map instead of a Vector to store the key/value, which is fine by me, but the return value (and key) is going to be left as a string.
Once the return value gets passed back to the AI it is going to have to parse it itself based upon the message that it sent.
[EDIT:] I realise this sounds like I am saying this is the only way, I am not. This is a possible way to do it. If you would like a more DOM way to do it then we could have Results, messages, etc also be parsed as strings and mapped to their held values. Regardless, the parser doesn't know anything about the data still.
The parser is going to do the following:
Break up the return message into three sections:
results
messages
errors
Results will be the same size as the messages array that was passed to lua. Results[0] will correspond to whatever the AI sent Lua in the 0th position.
Messages will be arbitrary size.
Errors will be arbitrary size.
Results, Messages and Errors will be maps keyed off of strings that lua sends. Either we can make it so that people will use map iterators and the map variables directly or we write functions that return key/value pairs.
What to do with the strings will be the responsibility of the AI.