OvermindDL1 wrote:
One of my main current interests is parsing. Trying to decide among the choices:
- Regex - Spirit - Xpressive
Depends on what you are wanting to parse. If you want to do, say, a search and replace in a file, Xpressive is best, if you want to parse data structures and you want the absolute best speed and a completely unambiguous grammar, Spirit2.1 for sure. Do not bother with Regex itself as Xpressive can do everything Regex can, but more and better.
Thanks so much!, OvermindDL1...
Allow me to describe my target data. I initially had a bunch of files
with lines like this:
Variable Name = Variable Value
These are some examples:
--------------------------------------------------------------------
My Favorite Baseball Player = George Herman "Babe" Ruth
What did you do on Christmas = I rested, computed the % mortgage and
visited my brother + sister.
(the above should be in a single line)
Favorite Curse = That umpire is a #&*%!
--------------------------------------------------------------------
I quickly solved the above parsing with Regex like this:
string variable = "([A-Za-z0-9][\\w\\h\\(\\)\\-\\.,/&]*)";
char equal_sign = '=';
string value = "(.+)";
assignment = variable + equal_sign + value;
After retrieving the LHS and the RHS I store them for subsequent use in
a map