Re: [GD-General] Text file parsing
Brought to you by:
vexxed72
From: Ivan-Assen I. <as...@ha...> - 2002-12-11 17:02:07
|
Text file parsingBy the way, if you are feeling TRULY adventurous, you might try Spirit (http://spirit.sourceforge.net). It's a framework? library? metalibrary? for creating parsers by describing the grammer directly within C++ code via a mindboggling amount of template trickery. here's their "hello world" example - a parser which takes a comma-separated list of floats and stuffs them into a std::vector: bool parse_numbers(char const* str, vector<double>& v) { return parse(str, // Begin grammar ( real_p[append(v)] >> *(',' >> real_p[append(v)]) ) , // End grammar space_p).full; } Translation: >> means "followed by", and is just whitespace in BNF; the Kleene star *, means what it usually means, but by obvious reasons has to be put IN FRONT of the subexpression. |