コード例 #1
0
ファイル: xppParser.cpp プロジェクト: miscco/xppParser
/**
 * @brief xppParser::xppParser Default constructor of the parser object
 *
 * @param fn string representing the file name of the ode file
 *
 * This constructs the parser object of a given ode file. First unneeded
 * content is discarded, and a basic correctness check is don. Later arrays are
 * expanded and special constructs like markov processes and tables are handled.
 * Finally, the different keywords are parsed and put into the opts arrays.
 */
xppParser::xppParser(const std::string &fn)
    : fileName(fn)
{
    try {
        /* Initially read in the ode file */
        readFile();

        /* Initialize the keyword tries for command parsing */
        initializeTries();

        /* Check for incorrect brackets */
        checkBrackets();

        /* Remove all comments */
        removeComments();

        /* Remove unnecessary whitespaces */
        removeWhitespace();

        /* Expand array descriptions */
        expandArrays();

        /* Extract exports to dlls */
        extractExport();

        /* Extract markov processes */
        extractMarkov();

        /* Extract table definitions */
        extractTable();

        /* Extract wiener processes */
        extractWiener();

        /* Extract globals */
        extractGlobal();

        /* Extract all other definitions */
        extractDefinition();

        /* Catch errors */
    } catch (xppParserException& e) {
        std::cerr << e.what();
    } catch (std::runtime_error& e) {
        std::cerr << e.what();
    } catch (std::exception& e) {
        std::cerr << e.what();
    } catch (...) {
        std::cerr << "Unexpected error\n";
        throw;
    }
}
コード例 #2
0
int main(int argc, char* argv[])
{
	if ( argc > 1)
	{
		std::string brackets( argv[1] );
		if ( checkBrackets(brackets) )
		{
			std::cout << "Check passed" << std::endl;
		}
		else
		{
			std::cout << "Check failed" << std::endl;
		}
	}

	return 0;
}