I've got a situation where I'm parsing input into a map of vectors boost::Spirit.
It works well, but I've run into a situation where I need to provide a fixed string internally for a certain case of user input, so that the internal string is parsed in lieu of the user input.
Here's a sample of the grammar:
input_pair =
key( std::string("__input")) >> valid_input % ','
;
where:
key =
qi::attr( _r1 )
;
and "valid_input" is a simple rule that tests for specific strings / character patterns, etc.
This grammar pairs the input with a pre-defined internal key and stores it in a map as a vector. If the input contains the specified delimiter, input is appropriately parsed into separate elements of the receiving vector.
The problem I've encountered, however, is providing a pre-defined string for "valid_input".
My first inclination is to do what I did with the map key:
input_pair =
key( std::string("__input")) >> key ( std::string("A, B, C")) % ','
;
But, of course,the entire string is inserted as the first element of the vector. That is, the comma delimiters in "A, B, C" are not recognized as I'd hoped they would.
Thus my question:
Given a boost::Spirit parser whose grammar parses input into a map of vectors, is there any way to parse a fixed string defined within the parser itself into a vector?