28 lines
637 B
C++
28 lines
637 B
C++
|
|
#include "SqlAstSelectList.h"
|
|||
|
|
#include "SqlAstSelectListEntry.h"
|
|||
|
|
#include "SqlParser.h"
|
|||
|
|
|
|||
|
|
using namespace SqlAst;
|
|||
|
|
|
|||
|
|
std::shared_ptr<SqlAst::SelectList> parseSelectList(SqlParser &parser)
|
|||
|
|
{
|
|||
|
|
// parse select element
|
|||
|
|
// whats next?
|
|||
|
|
// comma -> parse an element
|
|||
|
|
// something else return and let caller figure it out
|
|||
|
|
auto ast_select_list = std::make_shared<SelectList>();
|
|||
|
|
while (1) {
|
|||
|
|
auto ast_select_elem = parseSelectListEntry(parser);
|
|||
|
|
if (ast_select_elem) {
|
|||
|
|
ast_select_list->add(ast_select_elem);
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
// todo error
|
|||
|
|
}
|
|||
|
|
if (!parser.expectToken(BasicTokenType::Comma)) {
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return ast_select_list;
|
|||
|
|
}
|