We have been using pyparsing for a generic config file parser for some time now. The inner blocks of the config parser look something like this:
{
key1 = [ value1.1, value1.2, value1.3 ];
key2 = [ value2.1, value2.2, value2.3 ];
}
Using dictOf and delimitedList, we end up with the equivalent of a dictionary mapping keys (key1 and key2) to the corresponding list of value tokens.
Recently, I was hoping to extend the parser to support:
{
key1 = [ value1.1, value1.2, value1.3 ];
key1 += [ value1.4, value1.5 ];
key2 = [ value2.1, value2.2, value2.3 ];
}
In this example, I want the resulting dict to map key1 to [ value1.1, value1.2, value1.3, value1.4, value1.5 ]. Looking at the pyparsing options available, I didn't see any clear way to do this. A Google search didn't appear to turn up anything either. (Although it is possible I didn't know which search words to use for this.)
Is there some hook for this that I am missing? Is there some post processing combine functionality I should be doing? Can anyone suggest what the best "pyparsing way" of approaching this would be?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We have been using pyparsing for a generic config file parser for some time now. The inner blocks of the config parser look something like this:
{
key1 = [ value1.1, value1.2, value1.3 ];
key2 = [ value2.1, value2.2, value2.3 ];
}
Using dictOf and delimitedList, we end up with the equivalent of a dictionary mapping keys (key1 and key2) to the corresponding list of value tokens.
Recently, I was hoping to extend the parser to support:
{
key1 = [ value1.1, value1.2, value1.3 ];
key1 += [ value1.4, value1.5 ];
key2 = [ value2.1, value2.2, value2.3 ];
}
In this example, I want the resulting dict to map key1 to [ value1.1, value1.2, value1.3, value1.4, value1.5 ]. Looking at the pyparsing options available, I didn't see any clear way to do this. A Google search didn't appear to turn up anything either. (Although it is possible I didn't know which search words to use for this.)
Is there some hook for this that I am missing? Is there some post processing combine functionality I should be doing? Can anyone suggest what the best "pyparsing way" of approaching this would be?