MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / AST_Build

Function AST_Build

src/ast/ast.c:396–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394}
395
396AST *AST_Build
397(
398 cypher_parse_result_t *parse_result
399) {
400 AST *ast = rm_malloc(sizeof(AST));
401
402 ast->free_root = false;
403 ast->ref_count = rm_malloc(sizeof(uint));
404 ast->parse_result = parse_result;
405 ast->referenced_entities = NULL;
406 ast->params_parse_result = NULL;
407 ast->anot_ctx_collection = AST_AnnotationCtxCollection_New();
408
409 *(ast->ref_count) = 1;
410
411 // retrieve the AST root node from a parsed query
412 const cypher_astnode_t *statement = _AST_parse_result_root(parse_result);
413
414 // we are parsing with the CYPHER_PARSE_ONLY_STATEMENTS flag,
415 // and double-checking this in AST validations
416 ASSERT(cypher_astnode_type(statement) == CYPHER_AST_STATEMENT);
417 ast->root = cypher_ast_statement_get_body(statement);
418
419 // empty queries should be captured by AST validations
420 ASSERT(ast->root);
421
422 // set thread-local AST
423 QueryCtx_SetAST(ast);
424
425 // augment the AST with annotations for naming entities
426 // and populating WITH/RETURN * projections
427 AST_Enrich(ast);
428
429 return ast;
430}
431
432AST *AST_NewSegment
433(

Callers 6

_ExecutionCtx_ParseASTFunction · 0.85
build_ast_and_planFunction · 0.85
_build_astFunction · 0.85
buildASTFunction · 0.85

Calls 5

rm_mallocFunction · 0.85
_AST_parse_result_rootFunction · 0.85
QueryCtx_SetASTFunction · 0.85
AST_EnrichFunction · 0.85

Tested by 5

build_ast_and_planFunction · 0.68
_build_astFunction · 0.68
buildASTFunction · 0.68