I need to parse and generate some texts from and to c++ objects.
The syntax is:
command #param #param #param
There is set of commands some of them have no params etc.
Params are mainly numbers.
The question is: Should I use Boost Spirit for this task? Or just simply tokenize each line evaluate function to call from string compare with command, read additional parameters and create cpp object from it?
If you suggest using Spirit or any other solution it would be nice if you could provide some examples similiar to my problem. I’ve read and tried all examples from Boost Spirit doc.
I implemented more or less precisely this in a previous answer to the question ” Using boost::bind with boost::function: retrieve binded variable type “.
The complete working sample program (which expects a very similar grammar) using Boost Spirit is here: https://gist.github.com/1314900. You’d just want to remove the
/executeliterals for your grammar, so edit Line 41 fromto
The example script
Now results in the following output after execution:
Full Code
For archival purposes: