aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Functions/JSONPath/Parsers/ParserJSONPath.cpp
blob: 003e97af38bbe30b1943ce6eba74edf8fdd6aa05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <Functions/JSONPath/ASTs/ASTJSONPath.h>
#include <Functions/JSONPath/ASTs/ASTJSONPathMemberAccess.h>
#include <Functions/JSONPath/Parsers/ParserJSONPath.h>
#include <Functions/JSONPath/Parsers/ParserJSONPathQuery.h>

namespace DB
{
/**
 * Entry parser for JSONPath
 */
bool ParserJSONPath::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
{
    auto ast_jsonpath = std::make_shared<ASTJSONPath>();
    ParserJSONPathQuery parser_jsonpath_query;

    /// Push back dot AST and brackets AST to query->children
    ASTPtr query;

    bool res = parser_jsonpath_query.parse(pos, query, expected);

    if (res)
    {
        /// Set ASTJSONPathQuery of ASTJSONPath
        ast_jsonpath->set(ast_jsonpath->jsonpath_query, query);
    }

    node = ast_jsonpath;
    return res;
}

}