mirror of https://gitee.com/bigwinds/arangodb
removed unused files that remained after merge
This commit is contained in:
parent
efd48664ef
commit
b11b358a0b
|
@ -1,241 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Ahuacatl, parser nodes
|
||||
///
|
||||
/// @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
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Ahuacatl/ahuacatl-node.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Ahuacatl
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline const bool TRI_IsTopLevelTypeAql (const TRI_aql_node_type_e type) {
|
||||
if (type == TRI_AQL_NODE_SCOPE_START ||
|
||||
type == TRI_AQL_NODE_SCOPE_END ||
|
||||
type == TRI_AQL_NODE_SUBQUERY ||
|
||||
type == TRI_AQL_NODE_EXPAND ||
|
||||
type == TRI_AQL_NODE_FOR ||
|
||||
type == TRI_AQL_NODE_FILTER ||
|
||||
type == TRI_AQL_NODE_LET ||
|
||||
type == TRI_AQL_NODE_SORT ||
|
||||
type == TRI_AQL_NODE_LIMIT ||
|
||||
type == TRI_AQL_NODE_COLLECT ||
|
||||
type == TRI_AQL_NODE_RETURN) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the "nice" name of an AST node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const char* TRI_NodeNameAql (const TRI_aql_node_type_e type) {
|
||||
switch (type) {
|
||||
case TRI_AQL_NODE_NOP:
|
||||
return "nop";
|
||||
case TRI_AQL_NODE_SCOPE_START:
|
||||
return "scope start";
|
||||
case TRI_AQL_NODE_SCOPE_END:
|
||||
return "scope end";
|
||||
case TRI_AQL_NODE_FOR:
|
||||
return "for";
|
||||
case TRI_AQL_NODE_LET:
|
||||
return "let";
|
||||
case TRI_AQL_NODE_FILTER:
|
||||
return "filter";
|
||||
case TRI_AQL_NODE_RETURN:
|
||||
return "return";
|
||||
case TRI_AQL_NODE_COLLECT:
|
||||
return "collect";
|
||||
case TRI_AQL_NODE_SORT:
|
||||
return "sort";
|
||||
case TRI_AQL_NODE_SORT_ELEMENT:
|
||||
return "sort element";
|
||||
case TRI_AQL_NODE_LIMIT:
|
||||
return "limit";
|
||||
case TRI_AQL_NODE_VARIABLE:
|
||||
return "variable";
|
||||
case TRI_AQL_NODE_COLLECTION:
|
||||
return "collection";
|
||||
case TRI_AQL_NODE_REFERENCE:
|
||||
return "reference";
|
||||
case TRI_AQL_NODE_ATTRIBUTE:
|
||||
return "attribute";
|
||||
case TRI_AQL_NODE_ASSIGN:
|
||||
return "assign";
|
||||
case TRI_AQL_NODE_OPERATOR_UNARY_PLUS:
|
||||
return "uplus";
|
||||
case TRI_AQL_NODE_OPERATOR_UNARY_MINUS:
|
||||
return "uminus";
|
||||
case TRI_AQL_NODE_OPERATOR_UNARY_NOT:
|
||||
return "unot";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_AND:
|
||||
return "and";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_OR:
|
||||
return "or";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_PLUS:
|
||||
return "plus";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_MINUS:
|
||||
return "minus";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_TIMES:
|
||||
return "times";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_DIV:
|
||||
return "div";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_MOD:
|
||||
return "mod";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_EQ:
|
||||
return "eq";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_NE:
|
||||
return "ne";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_LT:
|
||||
return "lt";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_LE:
|
||||
return "le";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_GT:
|
||||
return "gt";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_GE:
|
||||
return "ge";
|
||||
case TRI_AQL_NODE_OPERATOR_BINARY_IN:
|
||||
return "in";
|
||||
case TRI_AQL_NODE_OPERATOR_TERNARY:
|
||||
return "ternary";
|
||||
case TRI_AQL_NODE_SUBQUERY:
|
||||
return "subquery";
|
||||
case TRI_AQL_NODE_ATTRIBUTE_ACCESS:
|
||||
return "attribute access";
|
||||
case TRI_AQL_NODE_INDEXED:
|
||||
return "indexed";
|
||||
case TRI_AQL_NODE_EXPAND:
|
||||
return "expand";
|
||||
case TRI_AQL_NODE_VALUE:
|
||||
return "value";
|
||||
case TRI_AQL_NODE_LIST:
|
||||
return "list";
|
||||
case TRI_AQL_NODE_ARRAY:
|
||||
return "array";
|
||||
case TRI_AQL_NODE_ARRAY_ELEMENT:
|
||||
return "array element";
|
||||
case TRI_AQL_NODE_PARAMETER:
|
||||
return "parameter";
|
||||
case TRI_AQL_NODE_FCALL:
|
||||
return "function call";
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return "undefined";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return true if a node is a list node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline const bool TRI_IsListNodeAql (const TRI_aql_node_t* const node) {
|
||||
return (node->_type == TRI_AQL_NODE_LIST);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check if a node is a constant
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsConstantValueNodeAql (const TRI_aql_node_t* const node) {
|
||||
assert(node);
|
||||
|
||||
if (node->_type != TRI_AQL_NODE_VALUE &&
|
||||
node->_type != TRI_AQL_NODE_LIST &&
|
||||
node->_type != TRI_AQL_NODE_ARRAY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node->_type == TRI_AQL_NODE_LIST) {
|
||||
// inspect all list elements
|
||||
size_t i;
|
||||
size_t n = node->_members._length;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
TRI_aql_node_t* member = TRI_AQL_NODE_MEMBER(node, i);
|
||||
|
||||
if (!TRI_IsConstantValueNodeAql(member)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (node->_type == TRI_AQL_NODE_ARRAY) {
|
||||
// inspect all array elements
|
||||
size_t i;
|
||||
size_t n = node->_members._length;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
TRI_aql_node_t* member = TRI_AQL_NODE_MEMBER(node, i);
|
||||
TRI_aql_node_t* value = TRI_AQL_NODE_MEMBER(member, 0);
|
||||
|
||||
if (!TRI_IsConstantValueNodeAql(value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief checks if a node value is numeric
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline bool TRI_IsNumericValueNodeAql (const TRI_aql_node_t* const node) {
|
||||
assert(node);
|
||||
|
||||
if (node->_type != TRI_AQL_NODE_VALUE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (node->_value._type == TRI_AQL_TYPE_INT ||
|
||||
node->_value._type == TRI_AQL_TYPE_DOUBLE);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief checks if a node value is boolean
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline bool TRI_IsBooleanValueNodeAql (const TRI_aql_node_t* const node) {
|
||||
assert(node);
|
||||
|
||||
return (node->_type == TRI_AQL_NODE_VALUE && node->_value._type == TRI_AQL_TYPE_BOOL);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
||||
// End:
|
|
@ -1,293 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Ahuacatl, parser nodes
|
||||
///
|
||||
/// @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_NODE_H
|
||||
#define TRIAGENS_DURHAM_AHUACATL_NODE_H 1
|
||||
|
||||
#include <BasicsC/common.h>
|
||||
#include <BasicsC/vector.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public macros
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Ahuacatl
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief indexes of node members and their meanings
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_AQL_IDX_FOR_VARIABLE 0
|
||||
#define TRI_AQL_IDX_FOR_EXPRESSION 1
|
||||
#define TRI_AQL_IDX_LET_VARIABLE 0
|
||||
#define TRI_AQL_IDX_LET_EXPRESSION 1
|
||||
#define TRI_AQL_IDX_FILTER_EXPRESSION 0
|
||||
#define TRI_AQL_IDX_COLLECT_LIST 0
|
||||
#define TRI_AQL_IDX_COLLECT_INTO 1
|
||||
#define TRI_AQL_IDX_RETURN_EXPRESSION 0
|
||||
#define TRI_AQL_IDX_SORT_LIST 0
|
||||
#define TRI_AQL_IDX_SORT_ELEMENT_EXPRESSION 0
|
||||
#define TRI_AQL_IDX_ATTRIBUTE_ACCESS_ACCESSED 0
|
||||
#define TRI_AQL_IDX_INDEXED_ACCESSED 0
|
||||
#define TRI_AQL_IDX_INDEXED_INDEX 1
|
||||
#define TRI_AQL_IDX_EXPAND_VARIABLE1 0
|
||||
#define TRI_AQL_IDX_EXPAND_VARIABLE2 1
|
||||
#define TRI_AQL_IDX_EXPAND_EXPANDED 2
|
||||
#define TRI_AQL_IDX_EXPAND_EXPANSION 3
|
||||
#define TRI_AQL_IDX_ASSIGN_VARIABLE 0
|
||||
#define TRI_AQL_IDX_ASSIGN_EXPRESSION 1
|
||||
#define TRI_AQL_IDX_UNARY_OPERAND 0
|
||||
#define TRI_AQL_IDX_BINARY_LHS 0
|
||||
#define TRI_AQL_IDX_BINARY_RHS 1
|
||||
#define TRI_AQL_IDX_TERNARY_CONDITION 0
|
||||
#define TRI_AQL_IDX_TERNARY_TRUEPART 1
|
||||
#define TRI_AQL_IDX_TERNARY_FALSEPART 2
|
||||
#define TRI_AQL_IDX_SUBQUERY_VARIABLE 0
|
||||
#define TRI_AQL_IDX_FCALL_PARAMETERS 0
|
||||
#define TRI_AQL_IDX_ARRAY_ELEMENT_SUBNODE 0
|
||||
#define TRI_AQL_IDX_ARRAY_VALUES 0
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief access the int value of a node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_AQL_NODE_INT(node) node->_value._value._int
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief access the double value of a node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_AQL_NODE_DOUBLE(node) node->_value._value._double
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief access the bool value of a node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_AQL_NODE_BOOL(node) node->_value._value._bool
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief access the string value of a node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_AQL_NODE_STRING(node) node->_value._value._string
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief access the data value of a node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_AQL_NODE_DATA(node) node->_value._value._data
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief access the value type of a node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_AQL_NODE_TYPE(node) node->_value._type
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief access the nth subnode of a node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_AQL_NODE_MEMBER(node, n) (TRI_aql_node_t*) node->_members._buffer[n]
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Ahuacatl
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief enumeration of AST node types
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef enum {
|
||||
TRI_AQL_NODE_NOP = 0,
|
||||
TRI_AQL_NODE_SCOPE_START,
|
||||
TRI_AQL_NODE_SCOPE_END,
|
||||
TRI_AQL_NODE_FOR,
|
||||
TRI_AQL_NODE_LET,
|
||||
TRI_AQL_NODE_FILTER,
|
||||
TRI_AQL_NODE_RETURN,
|
||||
TRI_AQL_NODE_COLLECT,
|
||||
TRI_AQL_NODE_SORT,
|
||||
TRI_AQL_NODE_SORT_ELEMENT,
|
||||
TRI_AQL_NODE_LIMIT,
|
||||
TRI_AQL_NODE_VARIABLE,
|
||||
TRI_AQL_NODE_ASSIGN,
|
||||
TRI_AQL_NODE_OPERATOR_UNARY_PLUS,
|
||||
TRI_AQL_NODE_OPERATOR_UNARY_MINUS,
|
||||
TRI_AQL_NODE_OPERATOR_UNARY_NOT,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_AND,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_OR,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_PLUS,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_MINUS,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_TIMES,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_DIV,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_MOD,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_EQ,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_NE,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_LT,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_LE,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_GT,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_GE,
|
||||
TRI_AQL_NODE_OPERATOR_BINARY_IN,
|
||||
TRI_AQL_NODE_OPERATOR_TERNARY,
|
||||
TRI_AQL_NODE_SUBQUERY,
|
||||
TRI_AQL_NODE_ATTRIBUTE_ACCESS,
|
||||
TRI_AQL_NODE_INDEXED,
|
||||
TRI_AQL_NODE_EXPAND,
|
||||
TRI_AQL_NODE_VALUE,
|
||||
TRI_AQL_NODE_LIST,
|
||||
TRI_AQL_NODE_ARRAY,
|
||||
TRI_AQL_NODE_ARRAY_ELEMENT,
|
||||
TRI_AQL_NODE_COLLECTION,
|
||||
TRI_AQL_NODE_REFERENCE,
|
||||
TRI_AQL_NODE_ATTRIBUTE,
|
||||
TRI_AQL_NODE_PARAMETER,
|
||||
TRI_AQL_NODE_FCALL
|
||||
}
|
||||
TRI_aql_node_type_e;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief enumeration of AST value types
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef enum {
|
||||
TRI_AQL_TYPE_FAIL = 0,
|
||||
TRI_AQL_TYPE_NULL,
|
||||
TRI_AQL_TYPE_INT,
|
||||
TRI_AQL_TYPE_DOUBLE,
|
||||
TRI_AQL_TYPE_BOOL,
|
||||
TRI_AQL_TYPE_STRING
|
||||
}
|
||||
TRI_aql_value_type_e;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief typedef for an AQL value
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_aql_value_s {
|
||||
union {
|
||||
int64_t _int;
|
||||
double _double;
|
||||
bool _bool;
|
||||
char* _string;
|
||||
void* _data;
|
||||
} _value;
|
||||
TRI_aql_value_type_e _type;
|
||||
}
|
||||
TRI_aql_value_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief an abstract AST node type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_aql_node_s {
|
||||
TRI_vector_pointer_t _members;
|
||||
TRI_aql_node_type_e _type;
|
||||
TRI_aql_value_t _value;
|
||||
}
|
||||
TRI_aql_node_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Ahuacatl
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Ahuacatl
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const bool TRI_IsTopLevelTypeAql (const TRI_aql_node_type_e);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the "nice" name of an AST node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const char* TRI_NodeNameAql (const TRI_aql_node_type_e);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return true if a node is a list node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const bool TRI_IsListNodeAql (const TRI_aql_node_t* const);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check if a node is a constant
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsConstantValueNodeAql (const TRI_aql_node_t* const);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief checks if a node value is numeric
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsNumericValueNodeAql (const TRI_aql_node_t* const);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief checks if a node value is boolean
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsBooleanValueNodeAql (const TRI_aql_node_t* const);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
||||
// End:
|
|
@ -1,202 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Ahuacatl, statement list walking
|
||||
///
|
||||
/// @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
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Ahuacatl/ahuacatl-statement-walker.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- statement list walker
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Ahuacatl
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief process a statement
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void VisitStatement (TRI_aql_statement_walker_t* const walker,
|
||||
const size_t position,
|
||||
TRI_aql_visit_statement_f func) {
|
||||
TRI_aql_node_t* node;
|
||||
TRI_aql_node_t* modified;
|
||||
|
||||
node = (TRI_aql_node_t*) TRI_AtVectorPointer(&walker->_statements->_statements, position);
|
||||
assert(node);
|
||||
|
||||
modified = func(walker->_data, node);
|
||||
if (walker->_canModify && modified != node) {
|
||||
if (modified == NULL) {
|
||||
modified = TRI_GetNopNodeAql();
|
||||
}
|
||||
|
||||
walker->_statements->_statements._buffer[position] = modified;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief process a node's members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void VisitMembers (TRI_aql_statement_walker_t* const walker,
|
||||
TRI_aql_node_t* const node) {
|
||||
size_t i, n;
|
||||
|
||||
assert(node);
|
||||
|
||||
n = node->_members._length;
|
||||
for (i = 0; i < n; ++i) {
|
||||
TRI_aql_node_t* member;
|
||||
TRI_aql_node_t* modified;
|
||||
|
||||
member = (TRI_aql_node_t*) TRI_AtVectorPointer(&node->_members, i);
|
||||
|
||||
if (!member) {
|
||||
continue;
|
||||
}
|
||||
|
||||
VisitMembers(walker, member);
|
||||
|
||||
modified = walker->visitMember(walker->_data, member);
|
||||
if (walker->_canModify && modified != member) {
|
||||
if (modified == NULL) {
|
||||
modified = TRI_GetNopNodeAql();
|
||||
}
|
||||
|
||||
node->_members._buffer[i] = modified;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief actually walk the statements in the list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void RunWalk (TRI_aql_statement_walker_t* const walker) {
|
||||
size_t i, n;
|
||||
|
||||
assert(walker);
|
||||
n = walker->_statements->_statements._length;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
TRI_aql_node_t* node;
|
||||
|
||||
node = (TRI_aql_node_t*) TRI_AtVectorPointer(&walker->_statements->_statements, i);
|
||||
|
||||
if (walker->preVisitStatement != NULL) {
|
||||
// this might change the node ptr
|
||||
VisitStatement(walker, i, walker->preVisitStatement);
|
||||
node = walker->_statements->_statements._buffer[i];
|
||||
}
|
||||
|
||||
// process node's members first
|
||||
if (walker->visitMember != NULL) {
|
||||
VisitMembers(walker, node);
|
||||
}
|
||||
|
||||
if (walker->postVisitStatement != NULL) {
|
||||
VisitStatement(walker, i, walker->postVisitStatement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Ahuacatl
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create a statement walker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_aql_statement_walker_t* TRI_CreateStatementWalkerAql (void* data,
|
||||
const bool canModify,
|
||||
TRI_aql_visit_node_f visitMember,
|
||||
TRI_aql_visit_statement_f preVisitStatement,
|
||||
TRI_aql_visit_statement_f postVisitStatement) {
|
||||
TRI_aql_statement_walker_t* walker;
|
||||
|
||||
walker = (TRI_aql_statement_walker_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_aql_statement_walker_t), false);
|
||||
if (walker == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
walker->_data = data;
|
||||
walker->_canModify = canModify;
|
||||
|
||||
walker->visitMember = visitMember;
|
||||
walker->preVisitStatement = preVisitStatement;
|
||||
walker->postVisitStatement = postVisitStatement;
|
||||
|
||||
return walker;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief free a statement walker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_FreeStatementWalkerAql (TRI_aql_statement_walker_t* const walker) {
|
||||
assert(walker);
|
||||
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, walker);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief run the statement list walk
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_WalkStatementsAql (TRI_aql_statement_walker_t* const walker,
|
||||
TRI_aql_statement_list_t* const list) {
|
||||
assert(walker);
|
||||
assert(list);
|
||||
|
||||
walker->_statements = list;
|
||||
|
||||
RunWalk(walker);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
||||
// End:
|
|
@ -1,135 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Ahuacatl, statement list walking
|
||||
///
|
||||
/// @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_STATEMENTLIST_WALKER_H
|
||||
#define TRIAGENS_DURHAM_AHUACATL_STATEMENTLIST_WALKER_H 1
|
||||
|
||||
#include <BasicsC/common.h>
|
||||
#include <BasicsC/strings.h>
|
||||
#include <BasicsC/hashes.h>
|
||||
#include <BasicsC/vector.h>
|
||||
#include <BasicsC/associative.h>
|
||||
#include <BasicsC/json.h>
|
||||
|
||||
#include "Ahuacatl/ahuacatl-ast-node.h"
|
||||
#include "Ahuacatl/ahuacatl-context.h"
|
||||
#include "Ahuacatl/ahuacatl-statementlist.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- modifiying statement list walker
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Ahuacatl
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief typedef for node visitation function
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef TRI_aql_node_t* (*TRI_aql_visit_node_f)(void*, TRI_aql_node_t*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief typedef for statement visitation function
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef TRI_aql_node_t* (*TRI_aql_visit_statement_f)(void*, TRI_aql_node_t*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tree walker container
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_aql_statement_walker_s {
|
||||
void* _data;
|
||||
bool _canModify;
|
||||
TRI_aql_statement_list_t* _statements;
|
||||
|
||||
TRI_aql_visit_node_f visitMember;
|
||||
TRI_aql_visit_statement_f preVisitStatement;
|
||||
TRI_aql_visit_statement_f postVisitStatement;
|
||||
}
|
||||
TRI_aql_statement_walker_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Ahuacatl
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create a statement walker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_aql_statement_walker_t* TRI_CreateStatementWalkerAql (void*,
|
||||
const bool,
|
||||
TRI_aql_visit_node_f,
|
||||
TRI_aql_visit_statement_f,
|
||||
TRI_aql_visit_statement_f);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief free a statement walker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_FreeStatementWalkerAql (TRI_aql_statement_walker_t* const);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief run the statement list walk
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_WalkStatementsAql (TRI_aql_statement_walker_t* const,
|
||||
TRI_aql_statement_list_t*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
||||
// End:
|
|
@ -1,142 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Ahuacatl, statement list
|
||||
///
|
||||
/// @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_STATEMENTLIST_H
|
||||
#define TRIAGENS_DURHAM_AHUACATL_STATEMENTLIST_H 1
|
||||
|
||||
#include <BasicsC/common.h>
|
||||
#include <BasicsC/vector.h>
|
||||
|
||||
#include "Ahuacatl/ahuacatl-node.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Ahuacatl
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_aql_statement_list_s {
|
||||
TRI_vector_pointer_t _statements;
|
||||
size_t _currentLevel;
|
||||
}
|
||||
TRI_aql_statement_list_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors / destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Ahuacatl
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief init the no-op node at program start
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_InitStatementListAql (void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create and initialize a statement list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_aql_statement_list_t* TRI_CreateStatementListAql (void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief free a statement list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_FreeStatementListAql (TRI_aql_statement_list_t* const);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Ahuacatl
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the address of the non-op node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_aql_node_t* TRI_GetNopNodeAql (void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief remove all non-ops from the statement list
|
||||
///
|
||||
/// this is achieved by skipping over all nop nodes in the statement list
|
||||
/// the resulting statement list will contain the remaining nodes only
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_CompactStatementListAql (TRI_aql_statement_list_t* const);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief invalidate all statements in current scope and subscopes
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_InvalidateStatementListAql (TRI_aql_statement_list_t* const,
|
||||
const size_t);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief add a statement to the statement list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_AddStatementListAql (TRI_aql_statement_list_t* const list,
|
||||
TRI_aql_node_t* const);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
||||
// End:
|
Loading…
Reference in New Issue