#include #include #include #define BOOST_SPIRIT_DEBUG #include //#include using namespace boost::spirit; using namespace std; #include "configgrammar.h" //#include "typeinfo.h" // todo: // try this with filescanner .... this complicates the skip parser // try this with tree parser // try this with string parser // int main(int argc, char **argv) { std::string filename= argv[1]; std::ifstream in(filename.c_str()); if (!in) { cerr << "Could not open input file: " << filename << endl; return 1; } in.unsetf(ios::skipws); // Turn of white space skipping on the stream typedef std::vector CharVector; typedef CharVector::const_iterator CharIterator; CharVector vec; std::copy( istream_iterator(in), istream_iterator(), std::back_inserter(vec)); CharIterator start = vec.begin(); CharIterator end = vec.end(); configreader reader; parse_info result = parse(start, end, reader); if (result.full) { cerr << filename << " Parses OK" << endl; return 0; } else { cerr << filename << " Fails Parsing" << endl; for (int i = 0; i < 50; i++) { if (result.stop == end) break; cerr << *result.stop++; } cerr << endl; return 1; } }