![]() |
mutable
A Database System for Research and Fast Prototyping
|
#include <Sema.hpp>
Data Structures | |
struct | RequireContext |
Helper class to create a context when one is required but does not yet exist. More... | |
struct | SemaContext |
Holds context information used by semantic analysis of a single statement. More... | |
Public Types | |
template<typename T > | |
using | Const = ASTExprVisitor::Const< T > |
Public Member Functions | |
Sema (Diagnostic &diag) | |
std::unique_ptr< DatabaseCommand > | analyze (std::unique_ptr< ast::Command > ast) |
Perform semantic analysis of an ast::Command . | |
M_AST_EXPR_LIST (DECLARE) M_AST_CLAUSE_LIST(DECLARE) M_AST_COMMAND_LIST(DECLARE) private | |
SemaContext | pop_context () |
SemaContext & | get_context () |
const SemaContext & | get_context () const |
bool | is_nested () const |
Returns true iff the current statement, that is being analyzed, is a nested statement. | |
std::unique_ptr< Designator > | create_designator (ThreadSafePooledString name, Token tok, const Expr &target) |
Creates a fresh Designator with the given name at location tok and with target target . | |
std::unique_ptr< Designator > | create_designator (const Expr &name, const Expr &target, bool drop_table_name=false) |
Creates a fresh Designator with the same syntactical representation as name (except the table name if drop_table_name ) and with target target . | |
std::unique_ptr< Designator > | create_designator (Position pos, ThreadSafePooledString table_name, ThreadSafePooledString attr_name, typename Designator::target_type target, const Type *type) |
Creates an entirely new Designator . | |
void | replace_by_fresh_designator_to (std::unique_ptr< Expr > &to_replace, const Expr &target) |
Replaces to_replace by a fresh Designator , that has the same syntactical representation as to_replace and targets target . | |
bool | is_composable_of (const ast::Expr &expr, const std::vector< std::reference_wrapper< ast::Expr > > components) |
Computes whether the bound parts of expr are composable of elements in components . | |
void | compose_of (std::unique_ptr< ast::Expr > &ptr, const std::vector< std::reference_wrapper< ast::Expr > > components) |
Recursively analyzes the ast::Expr referenced by ptr and replaces subexpressions that can be composed of the elements in components . | |
ThreadSafePooledOptionalString | make_unique_id_from_binding_path (context_stack_t::reverse_iterator current_ctx, context_stack_t::reverse_iterator binding_ctx) |
Creates a unique ID from a sequence of SemaContext s by concatenating their aliases. | |
Data Fields | |
Diagnostic & | diag |
Private Types | |
using | context_stack_t = std::vector< SemaContext * > |
| |
Private Attributes | |
context_stack_t | contexts_ |
std::ostringstream | oss |
| |
std::unique_ptr< DatabaseCommand > | command_ |
| |
|
inherited |
|
private |
|
inline |
std::unique_ptr< DatabaseCommand > Sema::analyze | ( | std::unique_ptr< ast::Command > | ast | ) |
Perform semantic analysis of an ast::Command
.
Returns an m::DatabaseCommand
to execute when no semantic errors occurred, nullptr
otherwise.
Definition at line 15 of file Sema.cpp.
References command_.
Referenced by m::command_from_string(), main(), and m::SerialScheduler::schedule_thread().
void Sema::compose_of | ( | std::unique_ptr< ast::Expr > & | ptr, |
const std::vector< std::reference_wrapper< ast::Expr > > | components | ||
) |
Recursively analyzes the ast::Expr
referenced by ptr
and replaces subexpressions that can be composed of the elements in components
.
Definition at line 115 of file Sema.cpp.
References m::and, is_composable_of(), replace_by_fresh_designator_to(), and m::visit().
std::unique_ptr< Designator > Sema::create_designator | ( | const Expr & | name, |
const Expr & | target, | ||
bool | drop_table_name = false |
||
) |
Creates a fresh Designator
with the same syntactical representation as name
(except the table name if drop_table_name
) and with target target
.
Definition at line 41 of file Sema.cpp.
References m::ast::Token::CreateArtificial(), m::Catalog::Get(), oss, m::ast::Token::pos, m::ast::Expr::tok, and m::ast::Expr::type().
|
inline |
Creates an entirely new Designator
.
This method is used to introduce artificial Designator
s to expand an anti-projection (SELECT
with asterisk *
).
std::unique_ptr< Designator > Sema::create_designator | ( | ThreadSafePooledString | name, |
Token | tok, | ||
const Expr & | target | ||
) |
Creates a fresh Designator
with the given name
at location tok
and with target target
.
Definition at line 32 of file Sema.cpp.
References m::ast::Token::CreateArtificial(), m::ast::Token::pos, and m::ast::Expr::type().
Referenced by replace_by_fresh_designator_to().
|
inline |
|
inline |
bool Sema::is_composable_of | ( | const ast::Expr & | expr, |
const std::vector< std::reference_wrapper< ast::Expr > > | components | ||
) |
Computes whether the bound parts of expr
are composable of elements in components
.
Definition at line 88 of file Sema.cpp.
References m::and, is_composable_of(), and m::visit().
Referenced by compose_of(), and is_composable_of().
bool Sema::is_nested | ( | ) | const |
ThreadSafePooledOptionalString Sema::make_unique_id_from_binding_path | ( | context_stack_t::reverse_iterator | current_ctx, |
context_stack_t::reverse_iterator | binding_ctx | ||
) |
Creates a unique ID from a sequence of SemaContext
s by concatenating their aliases.
Definition at line 72 of file Sema.cpp.
References m::Catalog::Get(), M_insist, and oss.
|
inline |
Definition at line 129 of file Sema.hpp.
Referenced by m::ast::Sema::RequireContext::~RequireContext().
void Sema::replace_by_fresh_designator_to | ( | std::unique_ptr< Expr > & | to_replace, |
const Expr & | target | ||
) |
Replaces to_replace
by a fresh Designator
, that has the same syntactical representation as to_replace
and targets target
.
Definition at line 61 of file Sema.cpp.
References create_designator().
Referenced by compose_of().
|
private |
|
private |
Definition at line 101 of file Sema.hpp.
Referenced by is_nested().
Diagnostic& m::ast::Sema::diag |
|
private |
used to create textual representation of complex AST objects, e.g. expressions
Definition at line 103 of file Sema.hpp.
Referenced by create_designator(), and make_unique_id_from_binding_path().