static
| 11 | |
| 12 | // static |
| 13 | bool SQLParser::parse(const std::string& sql, SQLParserResult* result) { |
| 14 | yyscan_t scanner; |
| 15 | YY_BUFFER_STATE state; |
| 16 | |
| 17 | if (hsql_lex_init(&scanner)) { |
| 18 | // Couldn't initialize the lexer. |
| 19 | fprintf(stderr, "SQLParser: Error when initializing lexer!\n"); |
| 20 | return false; |
| 21 | } |
| 22 | const char* text = sql.c_str(); |
| 23 | state = hsql__scan_string(text, scanner); |
| 24 | |
| 25 | // Parse the tokens. |
| 26 | // If parsing fails, the result will contain an error object. |
| 27 | int ret = hsql_parse(result, scanner); |
| 28 | bool success = (ret == 0); |
| 29 | result->setIsValid(success); |
| 30 | |
| 31 | hsql__delete_buffer(state, scanner); |
| 32 | hsql_lex_destroy(scanner); |
| 33 | |
| 34 | return true; |
| 35 | } |
| 36 | |
| 37 | // static |
| 38 | bool SQLParser::parseSQLString(const char* sql, SQLParserResult* result) { return parse(sql, result); } |
no test coverage detected