I'm writing a lexigraphical analyser. It takes an English string, and converts it into a set of latitude/longitude co-ordinates. It's a bit like Google Earth.
Anyway, I've written my symbol tables and grammar, and it's happily parsing formatted data.
struct LatLongDegrees
{
std::string dirLat_;
double degLat_;
std::string dirLong_;
double degLong_;
}
For example: {"North", 23.59, "East", -30.82}
Here is my grammar:
basic =(latitude >> ' ' >> double_ >> ' ' >> longitude >> ' ' >> double_);
Where latitude and longitude are symbol tables that map from shorthand compass directions to strings (eg "e" to "East")
So, on to my question:
I want to add the following rule to my grammar, where the latitude and longitude symbols are in the opposite positions:
reversed = (longitude >> ' ' >> double_ >> ' ' >> latitude >> double_ )
This parses, BUT the degLat_ and degLong_ values are not reversed along with string values. They are simply parsed directly into the struct, without regard for the string labels.
How do I build a struct (or boost::fusion vector) when the data to be parsed is not sequential?