Exemplo n.º 1
0
void TraceEvaluationTest::RunTest() {
    AbstractSyntaxTree parseResult;
    Parser parser(query);

    if (!parser.parse(parseResult)) {
        MS_throw(multiscale::TestException, ERR_MSG_TEST);
    }

    evaluationResult = parseResult.evaluate(trace, multiscaleArchitectureGraph);
}
Exemplo n.º 2
0
//  Main program
int main(int argc, char **argv) {
    std::string test;
    SpatialTemporalTrace trace;
    MultiscaleArchitectureGraph multiscaleArchitectureGraph;
    AbstractSyntaxTree result;

    initializeTrace(trace);

    std::cout << "/////////////////////////////////////////////////////////\n\n";
    std::cout << "\tA multiscale multidimensional logic query parser and evaluator...\n\n";
    std::cout << "/////////////////////////////////////////////////////////\n\n";

    std::cout
        << "Please enter a multiscale multidimensional logic query (or \"q\" to exit):" << std::endl
        << std::endl;


    while (getline(std::cin, test)) {
        if (test.compare("q") == 0) {
            break;
        }

        Parser parser(test);

        try {
            if (parser.parse(result)) {
                std::cout << "-----------------------------------------------------" << std::endl;
                std::cout << " Parsing succeeded"
                          << " and the AST evaluates to " 
                          << (result.evaluate(trace, multiscaleArchitectureGraph) ? "true" : "false")
                          << "!" << std::endl;
                std::cout << "-----------------------------------------------------" << std::endl << std::endl;
            } else {
                std::cout << "-----------------------------------------------------" << std::endl;
                std::cout << " Parsing failed!" << std::endl;
                std::cout << "-----------------------------------------------------" << std::endl << std::endl;
            }
        } catch(const std::exception &e) {
            ExceptionHandler::printDetailedErrorMessage(e);

            return EXEC_ERR_CODE;
        } catch(...) {
            std::cerr << "Exception of unknown type!" << std::endl;
        }
    }

    return -1;
}
Exemplo n.º 3
0
void
NumericCsvModelCheckingPerformanceTest::EvaluateLogicProperties(
    const std::vector<std::string> &logicProperties,
    SpatialTemporalTrace &timeSeries
) {
    AbstractSyntaxTree abstractSyntaxTree;
    MultiscaleArchitectureGraph multiscaleArchitectureGraph;

    for (const std::string &logicProperty : logicProperties) {
        // Create a new parser for the provided logic property
        Parser parser(logicProperty);

        // Parse the logic property and create the corresponding abstract syntax tree
        parser.parse(abstractSyntaxTree);

        // Evaluate the abstract syntax tree considering the provided time series data
        abstractSyntaxTree.evaluate(timeSeries, multiscaleArchitectureGraph);
    }
}