void Parser::delete_stmt(){ match("DELETE"); match("FROM"); match("ID"); where_clause(); match(";"); }
void Parser::query_stmt() { match("SELECT"); select_list(); match("FROM"); match("ID"); where_clause(); match(";"); }
const Delete &delete_stmt() { if (lookahead == DELETE) { // delete_stmt -> DELETE FROM id where_clause SEMICOLON match(DELETE); match(FROM); string table_id = id(); Expr where = where_clause(); match(SEMICOLON); return Delete(table_id, where); } else { throw ParseError("Syntax error"); } }
const Query &query_stmt() { if (lookahead == SELECT) { // query_stmt -> SELECT select_list FROM id where_clause SEMICOLON vector<string> columns; match(SELECT); select_list(columns); match(FROM); string table_id = id(); Expr where = where_clause(); match(SEMICOLON); return Query(table_id, columns, where); } else { throw ParseError("Syntax error"); } }
where_clause &select_query::where(const string &value) { where_ = where_clause(value); return where_; }