--- trunk/src/mdParser/SimplePreprocessor.hpp 2005/12/02 15:38:03 770 +++ trunk/src/mdParser/SimplePreprocessor.hpp 2006/04/17 21:49:12 938 @@ -44,13 +44,18 @@ #include #include #include +#include #include "utils/StringTokenizer.hpp" #include "utils/Trim.hpp" +#include "utils/OOPSEException.hpp" +#include "utils/simError.h" + + /** * @class SimplePreprocessor * @brief A simple preprocessor. - * @note only support #include #ifdef, #ifndef, #endif, #define and #undef, c-like multiple line - * comment is not support, macro substitude is not support. + * @note only supports #include #ifdef, #ifndef, #endif, #define and #undef, c-like multiple line + * comment is not supported, macro substitute is not supported. */ namespace oopse { class SimplePreprocessor { @@ -66,7 +71,19 @@ class SimplePreprocessor { private: bool doPreprocess(const std::string& filename, ostream& os, std::set& defineSet, std::stack& ifStates) { std::ifstream input(filename.c_str()); - + if (!input.is_open()) { + std::stringstream ss; + ss << "Can not open " << filename << " for preprocessing\n"; + + sprintf(painCave.errMsg, + "Can not open (%s) for processing. \n" + "\tPlease check md file name syntax.\n", filename.c_str()); + + painCave.isFatal = 1; + simError(); + + throw OOPSEException(ss.str()); + } int lineNo =1; os << "#line " << lineNo << " \"" << filename << "\"\n"; while(input.getline(buffer, bufferSize)) { @@ -118,7 +135,7 @@ class SimplePreprocessor { } os << std::endl; } else { - std::cout << tokens[0] << " is not support" << std::endl; + std::cout << tokens[0] << " is not supported (yet)." << std::endl; return false; } }else {