mirror of https://gitee.com/bigwinds/arangodb
153 lines
5.5 KiB
C
153 lines
5.5 KiB
C
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief Ahuacatl, scopes
|
|
///
|
|
/// @file
|
|
///
|
|
/// DISCLAIMER
|
|
///
|
|
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
|
///
|
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|
/// you may not use this file except in compliance with the License.
|
|
/// You may obtain a copy of the License at
|
|
///
|
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
|
///
|
|
/// Unless required by applicable law or agreed to in writing, software
|
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
/// See the License for the specific language governing permissions and
|
|
/// limitations under the License.
|
|
///
|
|
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
|
///
|
|
/// @author Jan Steemann
|
|
/// @author Copyright 2012, triagens GmbH, Cologne, Germany
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef TRIAGENS_DURHAM_AHUACATL_SCOPE_H
|
|
#define TRIAGENS_DURHAM_AHUACATL_SCOPE_H 1
|
|
|
|
#include <BasicsC/associative.h>
|
|
|
|
#include "Ahuacatl/ahuacatl-ast-node.h"
|
|
#include "Ahuacatl/ahuacatl-context.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- public types
|
|
// -----------------------------------------------------------------------------
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @addtogroup Ahuacatl
|
|
/// @{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief scope types used by various components
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
typedef enum {
|
|
TRI_AQL_SCOPE_MAIN,
|
|
TRI_AQL_SCOPE_SUBQUERY,
|
|
TRI_AQL_SCOPE_FOR,
|
|
TRI_AQL_SCOPE_FOR_NESTED,
|
|
TRI_AQL_SCOPE_FUNCTION,
|
|
TRI_AQL_SCOPE_EXPAND
|
|
}
|
|
TRI_aql_scope_e;
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief scope type
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
typedef struct TRI_aql_scope_s {
|
|
TRI_associative_pointer_t _variables;
|
|
TRI_vector_pointer_t* _ranges;
|
|
TRI_aql_scope_e _type;
|
|
bool _selfContained;
|
|
size_t _id;
|
|
}
|
|
TRI_aql_scope_t;
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- public functions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @addtogroup Ahuacatl
|
|
/// @{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief get the name of a scope type
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
const char* TRI_TypeNameScopeAql (const TRI_aql_scope_e);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief init scopes
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
bool TRI_InitScopesAql (TRI_aql_context_t* const);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief free all scopes
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void TRI_FreeScopesAql (TRI_aql_context_t* const);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief add a new scope
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
bool TRI_StartScopeAql (TRI_aql_context_t* const, const TRI_aql_scope_e);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief end the current scope, only 1
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
bool TRI_EndScopeAql (TRI_aql_context_t* const);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief end the current scopes, 0 .. n
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
bool TRI_EndScopeByReturnAql (TRI_aql_context_t* const);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief checks if a variable is defined in the current scope or above
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
bool TRI_VariableExistsScopeAql (TRI_aql_context_t* const, const char* const);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief push a variable into the current scope's symbol table
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
bool TRI_AddVariableScopeAql (TRI_aql_context_t* const,
|
|
const char*,
|
|
TRI_aql_node_t* const);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
// Local Variables:
|
|
// mode: outline-minor
|
|
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
|
// End:
|