blob: df5823ff104e9b785b5aa382f00d86dfd4cf32d2 [file] [log] [blame]
Radek Krejci70853c52018-10-15 14:46:16 +02001/**
2 * @file tree_schema_internal.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
4 * @brief internal functions for YANG schema trees.
5 *
6 * Copyright (c) 2015 - 2018 CESNET, z.s.p.o.
7 *
8 * This source code is licensed under BSD 3-Clause License (the "License").
9 * You may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * https://opensource.org/licenses/BSD-3-Clause
13 */
14
15#ifndef LY_TREE_SCHEMA_INTERNAL_H_
16#define LY_TREE_SCHEMA_INTERNAL_H_
17
18/**
Radek Krejcie3846472018-10-15 15:24:51 +020019 * @brief List of YANG statement groups - the (sub)module's substatements
20 */
21enum yang_module_stmt {
22 Y_MOD_MODULE_HEADER,
23 Y_MOD_LINKAGE,
24 Y_MOD_META,
25 Y_MOD_REVISION,
26 Y_MOD_BODY
27};
28
29/**
30 * @brief Types of arguments of YANG statements
31 */
32enum yang_arg {
33 Y_IDENTIF_ARG, /**< YANG "identifier-arg-str" rule */
34 Y_PREF_IDENTIF_ARG, /**< YANG "identifier-ref-arg-str" rule */
35 Y_STR_ARG, /**< YANG "string" rule */
36 Y_MAYBE_STR_ARG /**< optional YANG "string" rule */
37};
38
39/**
Radek Krejci70853c52018-10-15 14:46:16 +020040 * @brief internal context for schema parsers
41 */
42struct ly_parser_ctx {
43 struct ly_ctx *ctx;
44 uint64_t line; /* line number */
45 uint64_t indent; /* current position on the line for YANG indentation */
46};
47
48/**
49 * @brief Check the currently present prefixes in the module for collision with the new one.
50 *
51 * @param[in] ctx yang parser context.
52 * @param[in] module Schema tree to check.
53 * @param[in] value Newly added prefix value (including its location to distinguish collision with itself).
54 * @return LY_EEXIST when prefix is already used in the module, LY_SUCCESS otherwise
55 */
56LY_ERR lysp_check_prefix(struct ly_parser_ctx *ctx, struct lysp_module *module, const char **value);
57
58#endif /* LY_TREE_SCHEMA_INTERNAL_H_ */