1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 15:57:34 +00:00

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -8,11 +8,11 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/NonnullRefPtr.h>
#include <AK/NonnullRefPtrVector.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/String.h>
#include <LibSQL/AST/Token.h>
#include <LibSQL/Forward.h>
#include <LibSQL/Result.h>
@ -55,53 +55,53 @@ private:
class TypeName : public ASTNode {
public:
TypeName(String name, NonnullRefPtrVector<SignedNumber> signed_numbers)
TypeName(DeprecatedString name, NonnullRefPtrVector<SignedNumber> signed_numbers)
: m_name(move(name))
, m_signed_numbers(move(signed_numbers))
{
VERIFY(m_signed_numbers.size() <= 2);
}
String const& name() const { return m_name; }
DeprecatedString const& name() const { return m_name; }
NonnullRefPtrVector<SignedNumber> const& signed_numbers() const { return m_signed_numbers; }
private:
String m_name;
DeprecatedString m_name;
NonnullRefPtrVector<SignedNumber> m_signed_numbers;
};
class ColumnDefinition : public ASTNode {
public:
ColumnDefinition(String name, NonnullRefPtr<TypeName> type_name)
ColumnDefinition(DeprecatedString name, NonnullRefPtr<TypeName> type_name)
: m_name(move(name))
, m_type_name(move(type_name))
{
}
String const& name() const { return m_name; }
DeprecatedString const& name() const { return m_name; }
NonnullRefPtr<TypeName> const& type_name() const { return m_type_name; }
private:
String m_name;
DeprecatedString m_name;
NonnullRefPtr<TypeName> m_type_name;
};
class CommonTableExpression : public ASTNode {
public:
CommonTableExpression(String table_name, Vector<String> column_names, NonnullRefPtr<Select> select_statement)
CommonTableExpression(DeprecatedString table_name, Vector<DeprecatedString> column_names, NonnullRefPtr<Select> select_statement)
: m_table_name(move(table_name))
, m_column_names(move(column_names))
, m_select_statement(move(select_statement))
{
}
String const& table_name() const { return m_table_name; }
Vector<String> const& column_names() const { return m_column_names; }
DeprecatedString const& table_name() const { return m_table_name; }
Vector<DeprecatedString> const& column_names() const { return m_column_names; }
NonnullRefPtr<Select> const& select_statement() const { return m_select_statement; }
private:
String m_table_name;
Vector<String> m_column_names;
DeprecatedString m_table_name;
Vector<DeprecatedString> m_column_names;
NonnullRefPtr<Select> m_select_statement;
};
@ -124,28 +124,28 @@ private:
class QualifiedTableName : public ASTNode {
public:
QualifiedTableName(String schema_name, String table_name, String alias)
QualifiedTableName(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString alias)
: m_schema_name(move(schema_name))
, m_table_name(move(table_name))
, m_alias(move(alias))
{
}
String const& schema_name() const { return m_schema_name; }
String const& table_name() const { return m_table_name; }
String const& alias() const { return m_alias; }
DeprecatedString const& schema_name() const { return m_schema_name; }
DeprecatedString const& table_name() const { return m_table_name; }
DeprecatedString const& alias() const { return m_alias; }
private:
String m_schema_name;
String m_table_name;
String m_alias;
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
DeprecatedString m_alias;
};
class ReturningClause : public ASTNode {
public:
struct ColumnClause {
NonnullRefPtr<Expression> expression;
String column_alias;
DeprecatedString column_alias;
};
ReturningClause() = default;
@ -172,13 +172,13 @@ class ResultColumn : public ASTNode {
public:
ResultColumn() = default;
explicit ResultColumn(String table_name)
explicit ResultColumn(DeprecatedString table_name)
: m_type(ResultType::Table)
, m_table_name(move(table_name))
{
}
ResultColumn(NonnullRefPtr<Expression> expression, String column_alias)
ResultColumn(NonnullRefPtr<Expression> expression, DeprecatedString column_alias)
: m_type(ResultType::Expression)
, m_expression(move(expression))
, m_column_alias(move(column_alias))
@ -188,19 +188,19 @@ public:
ResultType type() const { return m_type; }
bool select_from_table() const { return !m_table_name.is_null(); }
String const& table_name() const { return m_table_name; }
DeprecatedString const& table_name() const { return m_table_name; }
bool select_from_expression() const { return !m_expression.is_null(); }
RefPtr<Expression> const& expression() const { return m_expression; }
String const& column_alias() const { return m_column_alias; }
DeprecatedString const& column_alias() const { return m_column_alias; }
private:
ResultType m_type { ResultType::All };
String m_table_name {};
DeprecatedString m_table_name {};
RefPtr<Expression> m_expression {};
String m_column_alias {};
DeprecatedString m_column_alias {};
};
class GroupByClause : public ASTNode {
@ -224,7 +224,7 @@ class TableOrSubquery : public ASTNode {
public:
TableOrSubquery() = default;
TableOrSubquery(String schema_name, String table_name, String table_alias)
TableOrSubquery(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString table_alias)
: m_is_table(true)
, m_schema_name(move(schema_name))
, m_table_name(move(table_name))
@ -239,18 +239,18 @@ public:
}
bool is_table() const { return m_is_table; }
String const& schema_name() const { return m_schema_name; }
String const& table_name() const { return m_table_name; }
String const& table_alias() const { return m_table_alias; }
DeprecatedString const& schema_name() const { return m_schema_name; }
DeprecatedString const& table_name() const { return m_table_name; }
DeprecatedString const& table_alias() const { return m_table_alias; }
bool is_subquery() const { return m_is_subquery; }
NonnullRefPtrVector<TableOrSubquery> const& subqueries() const { return m_subqueries; }
private:
bool m_is_table { false };
String m_schema_name {};
String m_table_name {};
String m_table_alias {};
DeprecatedString m_schema_name {};
DeprecatedString m_table_name {};
DeprecatedString m_table_alias {};
bool m_is_subquery { false };
NonnullRefPtrVector<TableOrSubquery> m_subqueries {};
@ -258,7 +258,7 @@ private:
class OrderingTerm : public ASTNode {
public:
OrderingTerm(NonnullRefPtr<Expression> expression, String collation_name, Order order, Nulls nulls)
OrderingTerm(NonnullRefPtr<Expression> expression, DeprecatedString collation_name, Order order, Nulls nulls)
: m_expression(move(expression))
, m_collation_name(move(collation_name))
, m_order(order)
@ -267,13 +267,13 @@ public:
}
NonnullRefPtr<Expression> const& expression() const { return m_expression; }
String const& collation_name() const { return m_collation_name; }
DeprecatedString const& collation_name() const { return m_collation_name; }
Order order() const { return m_order; }
Nulls nulls() const { return m_nulls; }
private:
NonnullRefPtr<Expression> m_expression;
String m_collation_name;
DeprecatedString m_collation_name;
Order m_order;
Nulls m_nulls;
};
@ -331,29 +331,29 @@ private:
class StringLiteral : public Expression {
public:
explicit StringLiteral(String value)
explicit StringLiteral(DeprecatedString value)
: m_value(move(value))
{
}
String const& value() const { return m_value; }
DeprecatedString const& value() const { return m_value; }
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
private:
String m_value;
DeprecatedString m_value;
};
class BlobLiteral : public Expression {
public:
explicit BlobLiteral(String value)
explicit BlobLiteral(DeprecatedString value)
: m_value(move(value))
{
}
String const& value() const { return m_value; }
DeprecatedString const& value() const { return m_value; }
private:
String m_value;
DeprecatedString m_value;
};
class NullLiteral : public Expression {
@ -425,22 +425,22 @@ private:
class ColumnNameExpression : public Expression {
public:
ColumnNameExpression(String schema_name, String table_name, String column_name)
ColumnNameExpression(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString column_name)
: m_schema_name(move(schema_name))
, m_table_name(move(table_name))
, m_column_name(move(column_name))
{
}
String const& schema_name() const { return m_schema_name; }
String const& table_name() const { return m_table_name; }
String const& column_name() const { return m_column_name; }
DeprecatedString const& schema_name() const { return m_schema_name; }
DeprecatedString const& table_name() const { return m_table_name; }
DeprecatedString const& column_name() const { return m_column_name; }
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
private:
String m_schema_name;
String m_table_name;
String m_column_name;
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
DeprecatedString m_column_name;
};
#define __enum_UnaryOperator(S) \
@ -611,16 +611,16 @@ private:
class CollateExpression : public NestedExpression {
public:
CollateExpression(NonnullRefPtr<Expression> expression, String collation_name)
CollateExpression(NonnullRefPtr<Expression> expression, DeprecatedString collation_name)
: NestedExpression(move(expression))
, m_collation_name(move(collation_name))
{
}
String const& collation_name() const { return m_collation_name; }
DeprecatedString const& collation_name() const { return m_collation_name; }
private:
String m_collation_name;
DeprecatedString m_collation_name;
};
enum class MatchOperator {
@ -708,19 +708,19 @@ private:
class InTableExpression : public InvertibleNestedExpression {
public:
InTableExpression(NonnullRefPtr<Expression> expression, String schema_name, String table_name, bool invert_expression)
InTableExpression(NonnullRefPtr<Expression> expression, DeprecatedString schema_name, DeprecatedString table_name, bool invert_expression)
: InvertibleNestedExpression(move(expression), invert_expression)
, m_schema_name(move(schema_name))
, m_table_name(move(table_name))
{
}
String const& schema_name() const { return m_schema_name; }
String const& table_name() const { return m_table_name; }
DeprecatedString const& schema_name() const { return m_schema_name; }
DeprecatedString const& table_name() const { return m_table_name; }
private:
String m_schema_name;
String m_table_name;
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
};
//==================================================================================================
@ -742,25 +742,25 @@ class ErrorStatement final : public Statement {
class CreateSchema : public Statement {
public:
CreateSchema(String schema_name, bool is_error_if_schema_exists)
CreateSchema(DeprecatedString schema_name, bool is_error_if_schema_exists)
: m_schema_name(move(schema_name))
, m_is_error_if_schema_exists(is_error_if_schema_exists)
{
}
String const& schema_name() const { return m_schema_name; }
DeprecatedString const& schema_name() const { return m_schema_name; }
bool is_error_if_schema_exists() const { return m_is_error_if_schema_exists; }
ResultOr<ResultSet> execute(ExecutionContext&) const override;
private:
String m_schema_name;
DeprecatedString m_schema_name;
bool m_is_error_if_schema_exists;
};
class CreateTable : public Statement {
public:
CreateTable(String schema_name, String table_name, RefPtr<Select> select_statement, bool is_temporary, bool is_error_if_table_exists)
CreateTable(DeprecatedString schema_name, DeprecatedString table_name, RefPtr<Select> select_statement, bool is_temporary, bool is_error_if_table_exists)
: m_schema_name(move(schema_name))
, m_table_name(move(table_name))
, m_select_statement(move(select_statement))
@ -769,7 +769,7 @@ public:
{
}
CreateTable(String schema_name, String table_name, NonnullRefPtrVector<ColumnDefinition> columns, bool is_temporary, bool is_error_if_table_exists)
CreateTable(DeprecatedString schema_name, DeprecatedString table_name, NonnullRefPtrVector<ColumnDefinition> columns, bool is_temporary, bool is_error_if_table_exists)
: m_schema_name(move(schema_name))
, m_table_name(move(table_name))
, m_columns(move(columns))
@ -778,8 +778,8 @@ public:
{
}
String const& schema_name() const { return m_schema_name; }
String const& table_name() const { return m_table_name; }
DeprecatedString const& schema_name() const { return m_schema_name; }
DeprecatedString const& table_name() const { return m_table_name; }
bool has_selection() const { return !m_select_statement.is_null(); }
RefPtr<Select> const& select_statement() const { return m_select_statement; }
@ -793,8 +793,8 @@ public:
ResultOr<ResultSet> execute(ExecutionContext&) const override;
private:
String m_schema_name;
String m_table_name;
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
RefPtr<Select> m_select_statement;
NonnullRefPtrVector<ColumnDefinition> m_columns;
bool m_is_temporary;
@ -803,55 +803,55 @@ private:
class AlterTable : public Statement {
public:
String const& schema_name() const { return m_schema_name; }
String const& table_name() const { return m_table_name; }
DeprecatedString const& schema_name() const { return m_schema_name; }
DeprecatedString const& table_name() const { return m_table_name; }
protected:
AlterTable(String schema_name, String table_name)
AlterTable(DeprecatedString schema_name, DeprecatedString table_name)
: m_schema_name(move(schema_name))
, m_table_name(move(table_name))
{
}
private:
String m_schema_name;
String m_table_name;
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
};
class RenameTable : public AlterTable {
public:
RenameTable(String schema_name, String table_name, String new_table_name)
RenameTable(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString new_table_name)
: AlterTable(move(schema_name), move(table_name))
, m_new_table_name(move(new_table_name))
{
}
String const& new_table_name() const { return m_new_table_name; }
DeprecatedString const& new_table_name() const { return m_new_table_name; }
private:
String m_new_table_name;
DeprecatedString m_new_table_name;
};
class RenameColumn : public AlterTable {
public:
RenameColumn(String schema_name, String table_name, String column_name, String new_column_name)
RenameColumn(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString column_name, DeprecatedString new_column_name)
: AlterTable(move(schema_name), move(table_name))
, m_column_name(move(column_name))
, m_new_column_name(move(new_column_name))
{
}
String const& column_name() const { return m_column_name; }
String const& new_column_name() const { return m_new_column_name; }
DeprecatedString const& column_name() const { return m_column_name; }
DeprecatedString const& new_column_name() const { return m_new_column_name; }
private:
String m_column_name;
String m_new_column_name;
DeprecatedString m_column_name;
DeprecatedString m_new_column_name;
};
class AddColumn : public AlterTable {
public:
AddColumn(String schema_name, String table_name, NonnullRefPtr<ColumnDefinition> column)
AddColumn(DeprecatedString schema_name, DeprecatedString table_name, NonnullRefPtr<ColumnDefinition> column)
: AlterTable(move(schema_name), move(table_name))
, m_column(move(column))
{
@ -865,34 +865,34 @@ private:
class DropColumn : public AlterTable {
public:
DropColumn(String schema_name, String table_name, String column_name)
DropColumn(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString column_name)
: AlterTable(move(schema_name), move(table_name))
, m_column_name(move(column_name))
{
}
String const& column_name() const { return m_column_name; }
DeprecatedString const& column_name() const { return m_column_name; }
private:
String m_column_name;
DeprecatedString m_column_name;
};
class DropTable : public Statement {
public:
DropTable(String schema_name, String table_name, bool is_error_if_table_does_not_exist)
DropTable(DeprecatedString schema_name, DeprecatedString table_name, bool is_error_if_table_does_not_exist)
: m_schema_name(move(schema_name))
, m_table_name(move(table_name))
, m_is_error_if_table_does_not_exist(is_error_if_table_does_not_exist)
{
}
String const& schema_name() const { return m_schema_name; }
String const& table_name() const { return m_table_name; }
DeprecatedString const& schema_name() const { return m_schema_name; }
DeprecatedString const& table_name() const { return m_table_name; }
bool is_error_if_table_does_not_exist() const { return m_is_error_if_table_does_not_exist; }
private:
String m_schema_name;
String m_table_name;
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
bool m_is_error_if_table_does_not_exist;
};
@ -906,7 +906,7 @@ enum class ConflictResolution {
class Insert : public Statement {
public:
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, String schema_name, String table_name, String alias, Vector<String> column_names, NonnullRefPtrVector<ChainedExpression> chained_expressions)
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString alias, Vector<DeprecatedString> column_names, NonnullRefPtrVector<ChainedExpression> chained_expressions)
: m_common_table_expression_list(move(common_table_expression_list))
, m_conflict_resolution(conflict_resolution)
, m_schema_name(move(schema_name))
@ -917,7 +917,7 @@ public:
{
}
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, String schema_name, String table_name, String alias, Vector<String> column_names, RefPtr<Select> select_statement)
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString alias, Vector<DeprecatedString> column_names, RefPtr<Select> select_statement)
: m_common_table_expression_list(move(common_table_expression_list))
, m_conflict_resolution(conflict_resolution)
, m_schema_name(move(schema_name))
@ -928,7 +928,7 @@ public:
{
}
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, String schema_name, String table_name, String alias, Vector<String> column_names)
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString alias, Vector<DeprecatedString> column_names)
: m_common_table_expression_list(move(common_table_expression_list))
, m_conflict_resolution(conflict_resolution)
, m_schema_name(move(schema_name))
@ -940,10 +940,10 @@ public:
RefPtr<CommonTableExpressionList> const& common_table_expression_list() const { return m_common_table_expression_list; }
ConflictResolution conflict_resolution() const { return m_conflict_resolution; }
String const& schema_name() const { return m_schema_name; }
String const& table_name() const { return m_table_name; }
String const& alias() const { return m_alias; }
Vector<String> const& column_names() const { return m_column_names; }
DeprecatedString const& schema_name() const { return m_schema_name; }
DeprecatedString const& table_name() const { return m_table_name; }
DeprecatedString const& alias() const { return m_alias; }
Vector<DeprecatedString> const& column_names() const { return m_column_names; }
bool default_values() const { return !has_expressions() && !has_selection(); };
@ -958,10 +958,10 @@ public:
private:
RefPtr<CommonTableExpressionList> m_common_table_expression_list;
ConflictResolution m_conflict_resolution;
String m_schema_name;
String m_table_name;
String m_alias;
Vector<String> m_column_names;
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
DeprecatedString m_alias;
Vector<DeprecatedString> m_column_names;
NonnullRefPtrVector<ChainedExpression> m_chained_expressions;
RefPtr<Select> m_select_statement;
};
@ -969,7 +969,7 @@ private:
class Update : public Statement {
public:
struct UpdateColumns {
Vector<String> column_names;
Vector<DeprecatedString> column_names;
NonnullRefPtr<Expression> expression;
};

View file

@ -46,7 +46,7 @@ ResultOr<ResultSet> Insert::execute(ExecutionContext& context) const
auto values = row_value.to_vector().release_value();
if (m_column_names.is_empty() && values.size() != row.size())
return Result { SQLCommand::Insert, SQLErrorCode::InvalidNumberOfValues, String::empty() };
return Result { SQLCommand::Insert, SQLErrorCode::InvalidNumberOfValues, DeprecatedString::empty() };
for (auto ix = 0u; ix < values.size(); ix++) {
auto input_value_type = values[ix].type();

View file

@ -11,9 +11,9 @@
namespace SQL::AST {
HashMap<String, TokenType> Lexer::s_keywords;
HashMap<DeprecatedString, TokenType> Lexer::s_keywords;
HashMap<char, TokenType> Lexer::s_one_char_tokens;
HashMap<String, TokenType> Lexer::s_two_char_tokens;
HashMap<DeprecatedString, TokenType> Lexer::s_two_char_tokens;
Lexer::Lexer(StringView source)
: m_source(source)

View file

@ -8,8 +8,8 @@
#pragma once
#include "Token.h"
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/String.h>
#include <AK/StringView.h>
namespace SQL::AST {
@ -46,9 +46,9 @@ private:
bool is_line_break() const;
bool is_eof() const;
static HashMap<String, TokenType> s_keywords;
static HashMap<DeprecatedString, TokenType> s_keywords;
static HashMap<char, TokenType> s_one_char_tokens;
static HashMap<String, TokenType> s_two_char_tokens;
static HashMap<DeprecatedString, TokenType> s_two_char_tokens;
StringView m_source;
size_t m_line_number { 1 };

View file

@ -91,7 +91,7 @@ NonnullRefPtr<CreateSchema> Parser::parse_create_schema_statement()
is_error_if_exists = false;
}
String schema_name = consume(TokenType::Identifier).value();
DeprecatedString schema_name = consume(TokenType::Identifier).value();
return create_ast_node<CreateSchema>(move(schema_name), is_error_if_exists);
}
@ -112,8 +112,8 @@ NonnullRefPtr<CreateTable> Parser::parse_create_table_statement()
is_error_if_table_exists = false;
}
String schema_name;
String table_name;
DeprecatedString schema_name;
DeprecatedString table_name;
parse_schema_and_table_name(schema_name, table_name);
if (consume_if(TokenType::As)) {
@ -135,8 +135,8 @@ NonnullRefPtr<AlterTable> Parser::parse_alter_table_statement()
consume(TokenType::Alter);
consume(TokenType::Table);
String schema_name;
String table_name;
DeprecatedString schema_name;
DeprecatedString table_name;
parse_schema_and_table_name(schema_name, table_name);
if (consume_if(TokenType::Add)) {
@ -177,8 +177,8 @@ NonnullRefPtr<DropTable> Parser::parse_drop_table_statement()
is_error_if_table_does_not_exist = false;
}
String schema_name;
String table_name;
DeprecatedString schema_name;
DeprecatedString table_name;
parse_schema_and_table_name(schema_name, table_name);
return create_ast_node<DropTable>(move(schema_name), move(table_name), is_error_if_table_does_not_exist);
@ -201,15 +201,15 @@ NonnullRefPtr<Insert> Parser::parse_insert_statement(RefPtr<CommonTableExpressio
auto conflict_resolution = parse_conflict_resolution();
consume(TokenType::Into);
String schema_name;
String table_name;
DeprecatedString schema_name;
DeprecatedString table_name;
parse_schema_and_table_name(schema_name, table_name);
String alias;
DeprecatedString alias;
if (consume_if(TokenType::As))
alias = consume(TokenType::Identifier).value();
Vector<String> column_names;
Vector<DeprecatedString> column_names;
if (match(TokenType::ParenOpen))
parse_comma_separated_list(true, [&]() { column_names.append(consume(TokenType::Identifier).value()); });
@ -260,7 +260,7 @@ NonnullRefPtr<Update> Parser::parse_update_statement(RefPtr<CommonTableExpressio
Vector<Update::UpdateColumns> update_columns;
parse_comma_separated_list(false, [&]() {
Vector<String> column_names;
Vector<DeprecatedString> column_names;
if (match(TokenType::ParenOpen)) {
parse_comma_separated_list(true, [&]() { column_names.append(consume(TokenType::Identifier).value()); });
} else {
@ -391,7 +391,7 @@ RefPtr<CommonTableExpressionList> Parser::parse_common_table_expression_list()
NonnullRefPtr<Expression> Parser::parse_expression()
{
if (++m_parser_state.m_current_expression_depth > Limits::maximum_expression_tree_depth) {
syntax_error(String::formatted("Exceeded maximum expression tree depth of {}", Limits::maximum_expression_tree_depth));
syntax_error(DeprecatedString::formatted("Exceeded maximum expression tree depth of {}", Limits::maximum_expression_tree_depth));
return create_ast_node<ErrorExpression>();
}
@ -528,23 +528,23 @@ RefPtr<Expression> Parser::parse_literal_value_expression()
return {};
}
RefPtr<Expression> Parser::parse_column_name_expression(String with_parsed_identifier, bool with_parsed_period)
RefPtr<Expression> Parser::parse_column_name_expression(DeprecatedString with_parsed_identifier, bool with_parsed_period)
{
if (with_parsed_identifier.is_null() && !match(TokenType::Identifier))
return {};
String first_identifier;
DeprecatedString first_identifier;
if (with_parsed_identifier.is_null())
first_identifier = consume(TokenType::Identifier).value();
else
first_identifier = move(with_parsed_identifier);
String schema_name;
String table_name;
String column_name;
DeprecatedString schema_name;
DeprecatedString table_name;
DeprecatedString column_name;
if (with_parsed_period || consume_if(TokenType::Period)) {
String second_identifier = consume(TokenType::Identifier).value();
DeprecatedString second_identifier = consume(TokenType::Identifier).value();
if (consume_if(TokenType::Period)) {
schema_name = move(first_identifier);
@ -726,7 +726,7 @@ RefPtr<Expression> Parser::parse_collate_expression(NonnullRefPtr<Expression> ex
return {};
consume();
String collation_name = consume(TokenType::Identifier).value();
DeprecatedString collation_name = consume(TokenType::Identifier).value();
return create_ast_node<CollateExpression>(move(expression), move(collation_name));
}
@ -843,8 +843,8 @@ RefPtr<Expression> Parser::parse_in_expression(NonnullRefPtr<Expression> express
return create_ast_node<InChainedExpression>(move(expression), move(chain), invert_expression);
}
String schema_name;
String table_name;
DeprecatedString schema_name;
DeprecatedString table_name;
parse_schema_and_table_name(schema_name, table_name);
if (match(TokenType::ParenOpen)) {
@ -912,7 +912,7 @@ NonnullRefPtr<CommonTableExpression> Parser::parse_common_table_expression()
// https://sqlite.org/syntax/common-table-expression.html
auto table_name = consume(TokenType::Identifier).value();
Vector<String> column_names;
Vector<DeprecatedString> column_names;
if (match(TokenType::ParenOpen))
parse_comma_separated_list(true, [&]() { column_names.append(consume(TokenType::Identifier).value()); });
@ -927,11 +927,11 @@ NonnullRefPtr<CommonTableExpression> Parser::parse_common_table_expression()
NonnullRefPtr<QualifiedTableName> Parser::parse_qualified_table_name()
{
// https://sqlite.org/syntax/qualified-table-name.html
String schema_name;
String table_name;
DeprecatedString schema_name;
DeprecatedString table_name;
parse_schema_and_table_name(schema_name, table_name);
String alias;
DeprecatedString alias;
if (consume_if(TokenType::As))
alias = consume(TokenType::Identifier).value();
@ -955,7 +955,7 @@ NonnullRefPtr<ReturningClause> Parser::parse_returning_clause()
parse_comma_separated_list(false, [&]() {
auto expression = parse_expression();
String column_alias;
DeprecatedString column_alias;
if (consume_if(TokenType::As) || match(TokenType::Identifier))
column_alias = consume(TokenType::Identifier).value();
@ -974,7 +974,7 @@ NonnullRefPtr<ResultColumn> Parser::parse_result_column()
// If we match an identifier now, we don't know whether it is a table-name of the form "table-name.*", or if it is the start of a
// column-name-expression, until we try to parse the asterisk. So if we consume an identifier and a period, but don't find an
// asterisk, hold onto that information to form a column-name-expression later.
String table_name;
DeprecatedString table_name;
bool parsed_period = false;
if (match(TokenType::Identifier)) {
@ -988,7 +988,7 @@ NonnullRefPtr<ResultColumn> Parser::parse_result_column()
? parse_expression()
: static_cast<NonnullRefPtr<Expression>>(*parse_column_name_expression(move(table_name), parsed_period));
String column_alias;
DeprecatedString column_alias;
if (consume_if(TokenType::As) || match(TokenType::Identifier))
column_alias = consume(TokenType::Identifier).value();
@ -998,17 +998,17 @@ NonnullRefPtr<ResultColumn> Parser::parse_result_column()
NonnullRefPtr<TableOrSubquery> Parser::parse_table_or_subquery()
{
if (++m_parser_state.m_current_subquery_depth > Limits::maximum_subquery_depth)
syntax_error(String::formatted("Exceeded maximum subquery depth of {}", Limits::maximum_subquery_depth));
syntax_error(DeprecatedString::formatted("Exceeded maximum subquery depth of {}", Limits::maximum_subquery_depth));
ScopeGuard guard([&]() { --m_parser_state.m_current_subquery_depth; });
// https://sqlite.org/syntax/table-or-subquery.html
if (match(TokenType::Identifier)) {
String schema_name;
String table_name;
DeprecatedString schema_name;
DeprecatedString table_name;
parse_schema_and_table_name(schema_name, table_name);
String table_alias;
DeprecatedString table_alias;
if (consume_if(TokenType::As) || match(TokenType::Identifier))
table_alias = consume(TokenType::Identifier).value();
@ -1028,7 +1028,7 @@ NonnullRefPtr<OrderingTerm> Parser::parse_ordering_term()
// https://sqlite.org/syntax/ordering-term.html
auto expression = parse_expression();
String collation_name;
DeprecatedString collation_name;
if (is<CollateExpression>(*expression)) {
auto const& collate = static_cast<CollateExpression const&>(*expression);
collation_name = collate.collation_name();
@ -1053,9 +1053,9 @@ NonnullRefPtr<OrderingTerm> Parser::parse_ordering_term()
return create_ast_node<OrderingTerm>(move(expression), move(collation_name), order, nulls);
}
void Parser::parse_schema_and_table_name(String& schema_name, String& table_name)
void Parser::parse_schema_and_table_name(DeprecatedString& schema_name, DeprecatedString& table_name)
{
String schema_or_table_name = consume(TokenType::Identifier).value();
DeprecatedString schema_or_table_name = consume(TokenType::Identifier).value();
if (consume_if(TokenType::Period)) {
schema_name = move(schema_or_table_name);
@ -1117,10 +1117,10 @@ bool Parser::match(TokenType type) const
void Parser::expected(StringView what)
{
syntax_error(String::formatted("Unexpected token {}, expected {}", m_parser_state.m_token.name(), what));
syntax_error(DeprecatedString::formatted("Unexpected token {}, expected {}", m_parser_state.m_token.name(), what));
}
void Parser::syntax_error(String message)
void Parser::syntax_error(DeprecatedString message)
{
m_parser_state.m_errors.append({ move(message), position() });
}

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringView.h>
#include <LibSQL/AST/AST.h>
#include <LibSQL/AST/Lexer.h>
@ -23,12 +23,12 @@ constexpr size_t maximum_subquery_depth = 100;
class Parser {
struct Error {
String message;
DeprecatedString message;
SourcePosition position;
String to_string() const
DeprecatedString to_string() const
{
return String::formatted("{} (line: {}, column: {})", message, position.line, position.column);
return DeprecatedString::formatted("{} (line: {}, column: {})", message, position.line, position.column);
}
};
@ -71,7 +71,7 @@ private:
NonnullRefPtr<Expression> parse_secondary_expression(NonnullRefPtr<Expression> primary);
bool match_secondary_expression() const;
RefPtr<Expression> parse_literal_value_expression();
RefPtr<Expression> parse_column_name_expression(String with_parsed_identifier = {}, bool with_parsed_period = false);
RefPtr<Expression> parse_column_name_expression(DeprecatedString with_parsed_identifier = {}, bool with_parsed_period = false);
RefPtr<Expression> parse_unary_operator_expression();
RefPtr<Expression> parse_binary_operator_expression(NonnullRefPtr<Expression> lhs);
RefPtr<Expression> parse_chained_expression();
@ -94,7 +94,7 @@ private:
NonnullRefPtr<ResultColumn> parse_result_column();
NonnullRefPtr<TableOrSubquery> parse_table_or_subquery();
NonnullRefPtr<OrderingTerm> parse_ordering_term();
void parse_schema_and_table_name(String& schema_name, String& table_name);
void parse_schema_and_table_name(DeprecatedString& schema_name, DeprecatedString& table_name);
ConflictResolution parse_conflict_resolution();
template<typename ParseCallback>
@ -122,7 +122,7 @@ private:
bool match(TokenType type) const;
void expected(StringView what);
void syntax_error(String message);
void syntax_error(DeprecatedString message);
SourcePosition position() const;

View file

@ -6,7 +6,7 @@
#include "Token.h"
#include <AK/Assertions.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <stdlib.h>
namespace SQL::AST {
@ -40,7 +40,7 @@ TokenCategory Token::category(TokenType type)
double Token::double_value() const
{
VERIFY(type() == TokenType::NumericLiteral);
String value(m_value);
DeprecatedString value(m_value);
if (value[0] == '0' && value.length() >= 2) {
if (value[1] == 'x' || value[1] == 'X')

View file

@ -8,8 +8,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/String.h>
#include <AK/StringView.h>
namespace SQL::AST {
@ -221,7 +221,7 @@ struct SourcePosition {
class Token {
public:
Token(TokenType type, String value, SourcePosition start_position, SourcePosition end_position)
Token(TokenType type, DeprecatedString value, SourcePosition start_position, SourcePosition end_position)
: m_type(type)
, m_value(move(value))
, m_start_position(start_position)
@ -236,7 +236,7 @@ public:
TokenType type() const { return m_type; }
TokenCategory category() const { return category(m_type); }
String const& value() const { return m_value; }
DeprecatedString const& value() const { return m_value; }
double double_value() const;
SourcePosition const& start_position() const { return m_start_position; }
@ -244,7 +244,7 @@ public:
private:
TokenType m_type;
String m_value;
DeprecatedString m_value;
SourcePosition m_start_position;
SourcePosition m_end_position;
};