1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:38:10 +00:00

LibSQL: Fix parsing of lists of common-table-expression

Misread the graph: In the "WITH [RECURSIVE] common-table-expression"
section, common-table-expression is actually a repeating list. This
changes the parser to correctly parse this section as a list. Create a
new AST node, CommonTableExpressionList, to store both this list and the
boolean RECURSIVE attribute (because every statement that uses this list
also includes the RECURSIVE attribute beforehand).
This commit is contained in:
Timothy Flynn 2021-04-21 16:56:19 -04:00 committed by Andreas Kling
parent f54a6d273e
commit 6a7d7624a7
4 changed files with 65 additions and 28 deletions

View file

@ -112,11 +112,20 @@ NonnullRefPtr<Delete> Parser::parse_delete_statement()
{
// https://sqlite.org/lang_delete.html
bool recursive = false;
RefPtr<CommonTableExpression> common_table_expression;
RefPtr<CommonTableExpressionList> common_table_expression_list;
if (consume_if(TokenType::With)) {
recursive = consume_if(TokenType::Recursive);
common_table_expression = parse_common_table_expression();
NonnullRefPtrVector<CommonTableExpression> common_table_expression;
bool recursive = consume_if(TokenType::Recursive);
do {
common_table_expression.append(parse_common_table_expression());
if (!match(TokenType::Comma))
break;
consume(TokenType::Comma);
} while (!match(TokenType::Eof));
common_table_expression_list = create_ast_node<CommonTableExpressionList>(recursive, move(common_table_expression));
}
consume(TokenType::Delete);
@ -133,7 +142,7 @@ NonnullRefPtr<Delete> Parser::parse_delete_statement()
consume(TokenType::SemiColon);
return create_ast_node<Delete>(recursive, move(common_table_expression), move(qualified_table_name), move(where_clause), move(returning_clause));
return create_ast_node<Delete>(move(common_table_expression_list), move(qualified_table_name), move(where_clause), move(returning_clause));
}
NonnullRefPtr<Expression> Parser::parse_expression()