Pavol Vican | 9a3a721 | 2016-03-23 10:04:00 +0100 | [diff] [blame] | 1 | /**
|
| 2 | * @file yang.y
|
| 3 | * @author Pavol Vican
|
| 4 | * @brief YANG parser for libyang (bison grammar)
|
| 5 | *
|
| 6 | * Copyright (c) 2015 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 |
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 15 | %define api.pure full
|
Pavol Vican | 8760bb7 | 2016-04-07 09:44:01 +0200 | [diff] [blame] | 16 | %locations
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 17 |
|
| 18 | %parse-param {void *scanner}
|
| 19 | %parse-param {struct lys_module *module}
|
| 20 | %parse-param {struct lys_submodule *submodule}
|
| 21 | %parse-param {struct unres_schema *unres}
|
| 22 | %parse-param {struct lys_array_size *size_arrays}
|
| 23 | %parse-param {int read_all}
|
| 24 |
|
| 25 | %lex-param {void *scanner}
|
| 26 |
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 27 | %{
|
| 28 | #include <stdio.h>
|
| 29 | #include <stdarg.h>
|
| 30 | #include <string.h>
|
| 31 | #include <stdlib.h>
|
| 32 | #include "context.h"
|
| 33 | #include "resolve.h"
|
Pavol Vican | 021488a | 2016-01-25 23:56:12 +0100 | [diff] [blame] | 34 | #include "common.h"
|
| 35 | #include "parser_yang.h"
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 36 | #include "parser_yang_lex.h"
|
Pavol Vican | 92fa0dc | 2016-03-02 14:20:39 +0100 | [diff] [blame] | 37 | #include "parser.h"
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 38 |
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 39 | /* only syntax rules */
|
| 40 | #define EXTENSION_ARG 0x01
|
| 41 | #define EXTENSION_STA 0x02
|
| 42 | #define EXTENSION_DSC 0x04
|
| 43 | #define EXTENSION_REF 0x08
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 44 | #define DISABLE_INHERIT 0
|
| 45 | #define ENABLE_INHERIT 0x01
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 46 |
|
Pavol Vican | 8760bb7 | 2016-04-07 09:44:01 +0200 | [diff] [blame] | 47 | void yyerror(YYLTYPE *yylloc, void *scanner, ...);
|
Pavol Vican | 191613a | 2016-02-26 16:21:32 +0100 | [diff] [blame] | 48 | char *s, *tmp_s;
|
Pavol Vican | 9b89dda | 2016-03-09 15:36:55 +0100 | [diff] [blame] | 49 | char rev[LY_REV_SIZE];
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 50 | struct lys_module *trg;
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 51 | /* temporary pointer for the check extension nacm */
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 52 | struct lys_node *data_node;
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 53 | /* pointer on the current parsed element*/
|
Pavol Vican | 6eb14e8 | 2016-02-03 12:27:13 +0100 | [diff] [blame] | 54 | void *actual;
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 55 | int config_inherit;
|
Pavol Vican | 6eb14e8 | 2016-02-03 12:27:13 +0100 | [diff] [blame] | 56 | int actual_type;
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 57 | int64_t cnt_val;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 58 | %}
|
| 59 |
|
Pavol Vican | bf80547 | 2016-01-26 14:24:56 +0100 | [diff] [blame] | 60 | %union {
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 61 | int32_t i;
|
Pavol Vican | beecbb0 | 2016-02-11 16:43:11 +0100 | [diff] [blame] | 62 | uint32_t uint;
|
Pavol Vican | 6eb14e8 | 2016-02-03 12:27:13 +0100 | [diff] [blame] | 63 | char *str;
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 64 | void *v;
|
Pavol Vican | 9b89dda | 2016-03-09 15:36:55 +0100 | [diff] [blame] | 65 | struct lys_module *inc;
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 66 | union {
|
| 67 | uint32_t index;
|
| 68 | struct lys_node_container *container;
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 69 | struct lys_node_anyxml *anyxml;
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 70 | struct type_choice choice;
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 71 | struct type_node node;
|
Pavol Vican | bd09813 | 2016-02-11 10:56:49 +0100 | [diff] [blame] | 72 | struct lys_node_case *cs;
|
Pavol Vican | 12f53c3 | 2016-02-11 11:40:00 +0100 | [diff] [blame] | 73 | struct lys_node_grp *grouping;
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 74 | struct type_uses uses;
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 75 | struct lys_refine *refine;
|
Pavol Vican | 41267fd | 2016-03-03 10:47:42 +0100 | [diff] [blame] | 76 | struct lys_node_notif *notif;
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 77 | struct type_deviation *deviation;
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 78 | } nodes;
|
Pavol Vican | bf80547 | 2016-01-26 14:24:56 +0100 | [diff] [blame] | 79 | }
|
| 80 |
|
Pavol Vican | a4f045a | 2016-02-29 15:01:20 +0100 | [diff] [blame] | 81 | %token UNION_KEYWORD
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 82 | %token ANYXML_KEYWORD
|
| 83 | %token WHITESPACE
|
| 84 | %token ERROR
|
| 85 | %token EOL
|
| 86 | %token STRING
|
| 87 | %token STRINGS
|
| 88 | %token IDENTIFIER
|
| 89 | %token IDENTIFIERPREFIX
|
| 90 | %token REVISION_DATE
|
| 91 | %token TAB
|
| 92 | %token DOUBLEDOT
|
| 93 | %token URI
|
| 94 | %token INTEGER
|
| 95 | %token NON_NEGATIVE_INTEGER
|
| 96 | %token ZERO
|
| 97 | %token DECIMAL
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 98 | %token ARGUMENT_KEYWORD
|
| 99 | %token AUGMENT_KEYWORD
|
| 100 | %token BASE_KEYWORD
|
| 101 | %token BELONGS_TO_KEYWORD
|
| 102 | %token BIT_KEYWORD
|
| 103 | %token CASE_KEYWORD
|
| 104 | %token CHOICE_KEYWORD
|
| 105 | %token CONFIG_KEYWORD
|
| 106 | %token CONTACT_KEYWORD
|
| 107 | %token CONTAINER_KEYWORD
|
| 108 | %token DEFAULT_KEYWORD
|
| 109 | %token DESCRIPTION_KEYWORD
|
| 110 | %token ENUM_KEYWORD
|
| 111 | %token ERROR_APP_TAG_KEYWORD
|
| 112 | %token ERROR_MESSAGE_KEYWORD
|
| 113 | %token EXTENSION_KEYWORD
|
| 114 | %token DEVIATION_KEYWORD
|
| 115 | %token DEVIATE_KEYWORD
|
| 116 | %token FEATURE_KEYWORD
|
| 117 | %token FRACTION_DIGITS_KEYWORD
|
| 118 | %token GROUPING_KEYWORD
|
| 119 | %token IDENTITY_KEYWORD
|
| 120 | %token IF_FEATURE_KEYWORD
|
| 121 | %token IMPORT_KEYWORD
|
| 122 | %token INCLUDE_KEYWORD
|
| 123 | %token INPUT_KEYWORD
|
| 124 | %token KEY_KEYWORD
|
| 125 | %token LEAF_KEYWORD
|
| 126 | %token LEAF_LIST_KEYWORD
|
| 127 | %token LENGTH_KEYWORD
|
| 128 | %token LIST_KEYWORD
|
| 129 | %token MANDATORY_KEYWORD
|
| 130 | %token MAX_ELEMENTS_KEYWORD
|
| 131 | %token MIN_ELEMENTS_KEYWORD
|
| 132 | %token MODULE_KEYWORD
|
| 133 | %token MUST_KEYWORD
|
| 134 | %token NAMESPACE_KEYWORD
|
| 135 | %token NOTIFICATION_KEYWORD
|
| 136 | %token ORDERED_BY_KEYWORD
|
| 137 | %token ORGANIZATION_KEYWORD
|
| 138 | %token OUTPUT_KEYWORD
|
| 139 | %token PATH_KEYWORD
|
| 140 | %token PATTERN_KEYWORD
|
| 141 | %token POSITION_KEYWORD
|
| 142 | %token PREFIX_KEYWORD
|
| 143 | %token PRESENCE_KEYWORD
|
| 144 | %token RANGE_KEYWORD
|
| 145 | %token REFERENCE_KEYWORD
|
| 146 | %token REFINE_KEYWORD
|
| 147 | %token REQUIRE_INSTANCE_KEYWORD
|
| 148 | %token REVISION_KEYWORD
|
| 149 | %token REVISION_DATE_KEYWORD
|
| 150 | %token RPC_KEYWORD
|
| 151 | %token STATUS_KEYWORD
|
| 152 | %token SUBMODULE_KEYWORD
|
| 153 | %token TYPE_KEYWORD
|
| 154 | %token TYPEDEF_KEYWORD
|
| 155 | %token UNIQUE_KEYWORD
|
| 156 | %token UNITS_KEYWORD
|
| 157 | %token USES_KEYWORD
|
| 158 | %token VALUE_KEYWORD
|
| 159 | %token WHEN_KEYWORD
|
| 160 | %token YANG_VERSION_KEYWORD
|
| 161 | %token YIN_ELEMENT_KEYWORD
|
| 162 | %token ADD_KEYWORD
|
| 163 | %token CURRENT_KEYWORD
|
| 164 | %token DELETE_KEYWORD
|
| 165 | %token DEPRECATED_KEYWORD
|
| 166 | %token FALSE_KEYWORD
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 167 | %token NOT_SUPPORTED_KEYWORD
|
| 168 | %token OBSOLETE_KEYWORD
|
| 169 | %token REPLACE_KEYWORD
|
| 170 | %token SYSTEM_KEYWORD
|
| 171 | %token TRUE_KEYWORD
|
| 172 | %token UNBOUNDED_KEYWORD
|
| 173 | %token USER_KEYWORD
|
| 174 |
|
Pavol Vican | beecbb0 | 2016-02-11 16:43:11 +0100 | [diff] [blame] | 175 | %type <uint> positive_integer_value
|
| 176 | %type <uint> non_negative_integer_value
|
| 177 | %type <uint> max_value_arg_str
|
| 178 | %type <uint> max_elements_stmt
|
| 179 | %type <uint> min_value_arg_str
|
| 180 | %type <uint> min_elements_stmt
|
Pavol Vican | 1c203db | 2016-02-24 14:05:23 +0100 | [diff] [blame] | 181 | %type <uint> decimal_string_restrictions
|
Pavol Vican | 07ea68d | 2016-02-25 12:01:37 +0100 | [diff] [blame] | 182 | %type <uint> fraction_digits_arg_str
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 183 | %type <uint> position_value_arg_str
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 184 | %type <uint> extension_opt_stmt
|
Pavol Vican | bf80547 | 2016-01-26 14:24:56 +0100 | [diff] [blame] | 185 | %type <i> module_header_stmts
|
Pavol Vican | 35f4a8a | 2016-03-09 16:20:06 +0100 | [diff] [blame] | 186 | %type <i> submodule_header_stmts
|
Pavol Vican | 6eb14e8 | 2016-02-03 12:27:13 +0100 | [diff] [blame] | 187 | %type <str> tmp_identifier_arg_str
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 188 | %type <str> message_opt_stmt
|
Pavol Vican | e236898 | 2016-03-19 14:37:56 +0100 | [diff] [blame] | 189 | %type <str> identity_opt_stmt
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 190 | %type <i> status_stmt
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 191 | %type <i> status_read_stmt
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 192 | %type <i> status_arg_str
|
Pavol Vican | b568711 | 2016-02-09 22:35:59 +0100 | [diff] [blame] | 193 | %type <i> config_stmt
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 194 | %type <i> config_read_stmt
|
Pavol Vican | b568711 | 2016-02-09 22:35:59 +0100 | [diff] [blame] | 195 | %type <i> config_arg_str
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 196 | %type <i> mandatory_stmt
|
Pavol Vican | e408402 | 2016-03-19 13:12:52 +0100 | [diff] [blame] | 197 | %type <i> mandatory_read_stmt
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 198 | %type <i> mandatory_arg_str
|
Pavol Vican | be057c0 | 2016-02-11 19:08:08 +0100 | [diff] [blame] | 199 | %type <i> ordered_by_stmt
|
| 200 | %type <i> ordered_by_arg_str
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 201 | %type <i> integer_value_arg_str
|
| 202 | %type <i> integer_value
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 203 | %type <i> feature_opt_stmt
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 204 | %type <v> length_arg_str
|
Pavol Vican | 1c203db | 2016-02-24 14:05:23 +0100 | [diff] [blame] | 205 | %type <v> pattern_arg_str
|
Pavol Vican | aff5c80 | 2016-02-24 15:56:45 +0100 | [diff] [blame] | 206 | %type <v> range_arg_str
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 207 | %type <v> enum_arg_str
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 208 | %type <v> bit_arg_str
|
Pavol Vican | a4f045a | 2016-02-29 15:01:20 +0100 | [diff] [blame] | 209 | %type <v> union_spec
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 210 | %type <v> typedef_arg_str
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 211 | %type <nodes> container_opt_stmt
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 212 | %type <nodes> anyxml_opt_stmt
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 213 | %type <nodes> choice_opt_stmt
|
Pavol Vican | bd09813 | 2016-02-11 10:56:49 +0100 | [diff] [blame] | 214 | %type <nodes> case_opt_stmt
|
Pavol Vican | 12f53c3 | 2016-02-11 11:40:00 +0100 | [diff] [blame] | 215 | %type <nodes> grouping_opt_stmt
|
Pavol Vican | 096c6db | 2016-02-11 15:08:10 +0100 | [diff] [blame] | 216 | %type <nodes> leaf_opt_stmt
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 217 | %type <nodes> leaf_list_opt_stmt
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 218 | %type <nodes> list_opt_stmt
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 219 | %type <nodes> type_opt_stmt
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 220 | %type <nodes> uses_opt_stmt
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 221 | %type <nodes> refine_body_opt_stmts
|
Pavol Vican | 92fa0dc | 2016-03-02 14:20:39 +0100 | [diff] [blame] | 222 | %type <nodes> augment_opt_stmt
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 223 | %type <nodes> rpc_opt_stmt
|
Pavol Vican | 531a913 | 2016-03-03 10:10:09 +0100 | [diff] [blame] | 224 | %type <nodes> input_output_opt_stmt
|
Pavol Vican | 41267fd | 2016-03-03 10:47:42 +0100 | [diff] [blame] | 225 | %type <nodes> notification_opt_stmt
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 226 | %type <nodes> deviation_opt_stmt
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 227 | %type <nodes> deviate_add_opt_stmt
|
Pavol Vican | c1f5a50 | 2016-03-06 16:51:26 +0100 | [diff] [blame] | 228 | %type <nodes> deviate_delete_opt_stmt
|
Pavol Vican | 4766aca | 2016-03-07 12:42:36 +0100 | [diff] [blame] | 229 | %type <nodes> deviate_replace_opt_stmt
|
Pavol Vican | 9b89dda | 2016-03-09 15:36:55 +0100 | [diff] [blame] | 230 | %type <inc> include_stmt
|
Pavol Vican | 6106f9c | 2016-03-24 08:08:53 +0100 | [diff] [blame] | 231 | %type <inc> import_stmt
|
Pavol Vican | 6eb14e8 | 2016-02-03 12:27:13 +0100 | [diff] [blame] | 232 |
|
| 233 | %destructor { free($$); } tmp_identifier_arg_str
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 234 | %destructor { if (read_all && $$.choice.s) { free($$.choice.s); } } choice_opt_stmt
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 235 | %destructor { if (read_all) {
|
| 236 | free($$.deviation);
|
| 237 | }
|
| 238 | } deviation_opt_stmt
|
Pavol Vican | bf80547 | 2016-01-26 14:24:56 +0100 | [diff] [blame] | 239 |
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 240 | %%
|
| 241 |
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 242 | /* to simplify code, store the module/submodule being processed as trg */
|
| 243 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 244 | start: module_stmt
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 245 | | submodule_stmt { if (read_all && lyp_propagate_submodule(module, submodule)) {
|
Pavol Vican | 75dbc5c | 2016-03-09 16:34:58 +0100 | [diff] [blame] | 246 | YYERROR;
|
| 247 | }
|
| 248 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 249 |
|
| 250 |
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 251 | string_1: STRING { if (read_all) {
|
Pavol Vican | 8760bb7 | 2016-04-07 09:44:01 +0200 | [diff] [blame] | 252 | if (yyget_text(scanner)[0] == '"') {
|
| 253 | s = yang_read_string(yyget_text(scanner) + 1, yyget_leng(scanner) - 2, yylloc.first_column);
|
| 254 | if (!s) {
|
| 255 | YYERROR;
|
| 256 | }
|
| 257 | } else {
|
| 258 | s = calloc(1, yyget_leng(scanner) - 1);
|
| 259 | if (!s) {
|
| 260 | LOGMEM;
|
| 261 | YYERROR;
|
| 262 | }
|
| 263 | memcpy(s, yyget_text(scanner) + 1, yyget_leng(scanner) - 2);
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 264 | }
|
| 265 | }
|
| 266 | }
|
| 267 | optsep string_2
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 268 |
|
| 269 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 270 | string_2: @EMPTYDIR@
|
| 271 | | string_2 '+' optsep
|
Pavol Vican | 1c203db | 2016-02-24 14:05:23 +0100 | [diff] [blame] | 272 | STRING { if (read_all){
|
Pavol Vican | 8760bb7 | 2016-04-07 09:44:01 +0200 | [diff] [blame] | 273 | char *temp;
|
| 274 | if (yyget_text(scanner)[0] == '"') {
|
| 275 | temp = yang_read_string(yyget_text(scanner) + 1, yyget_leng(scanner) - 2, yylloc.first_column);
|
| 276 | if (!temp) {
|
| 277 | YYERROR;
|
| 278 | }
|
| 279 | s = ly_realloc(s, strlen(temp) + strlen(s) + 1);
|
| 280 | if (s) {
|
| 281 | strcat(s, temp);
|
| 282 | free(temp);
|
| 283 | } else {
|
| 284 | free(temp);
|
| 285 | LOGMEM;
|
| 286 | YYERROR;
|
| 287 | }
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 288 | } else {
|
Pavol Vican | 8760bb7 | 2016-04-07 09:44:01 +0200 | [diff] [blame] | 289 | int length = yyget_leng(scanner) - 2 + strlen(s) + 1;
|
| 290 | s = ly_realloc(s, length);
|
| 291 | if (s) {
|
| 292 | memcpy(s + strlen(s), yyget_text(scanner) + 1, yyget_leng(scanner) - 2);
|
| 293 | s[length - 1] = '\0';
|
| 294 | } else {
|
| 295 | LOGMEM;
|
| 296 | YYERROR;
|
| 297 | }
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 298 | }
|
| 299 | }
|
| 300 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 301 | optsep;
|
| 302 |
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 303 | module_stmt: optsep MODULE_KEYWORD sep identifier_arg_str { if (read_all) {
|
| 304 | if (submodule) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 305 | LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "module");
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 306 | YYERROR;
|
| 307 | }
|
| 308 | trg = module;
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 309 | yang_read_common(trg,s,MODULE_KEYWORD);
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 310 | s = NULL;
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 311 | config_inherit = ENABLE_INHERIT;
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 312 | }
|
| 313 | }
|
Pavol Vican | 1ca072c | 2016-02-03 13:03:56 +0100 | [diff] [blame] | 314 | '{' stmtsep
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 315 | module_header_stmts { if (read_all && !module->ns) { LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "namespace", "module"); YYERROR; }
|
| 316 | if (read_all && !module->prefix) { LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "prefix", "module"); YYERROR; }
|
Pavol Vican | 1ca072c | 2016-02-03 13:03:56 +0100 | [diff] [blame] | 317 | }
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 318 | linkage_stmts
|
Pavol Vican | 1ca072c | 2016-02-03 13:03:56 +0100 | [diff] [blame] | 319 | meta_stmts
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 320 | revision_stmts
|
Pavol Vican | 1ca072c | 2016-02-03 13:03:56 +0100 | [diff] [blame] | 321 | body_stmts
|
| 322 | '}' optsep
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 323 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 324 | module_header_stmts: @EMPTYDIR@ { $$ = 0; }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 325 | | module_header_stmts yang_version_stmt { if ($1) { LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "yang version", "module"); YYERROR; } $$ = 1; }
|
| 326 | | module_header_stmts namespace_stmt { if (read_all && yang_read_common(module, s, NAMESPACE_KEYWORD)) {YYERROR;} s=NULL; }
|
| 327 | | module_header_stmts prefix_stmt { if (read_all && yang_read_prefix(module, NULL, s, MODULE_KEYWORD)) {YYERROR;} s=NULL; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 328 | ;
|
| 329 |
|
Pavol Vican | 75dbc5c | 2016-03-09 16:34:58 +0100 | [diff] [blame] | 330 | submodule_stmt: optsep SUBMODULE_KEYWORD sep identifier_arg_str { if (read_all) {
|
| 331 | if (!submodule) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 332 | LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "submodule");
|
Pavol Vican | 75dbc5c | 2016-03-09 16:34:58 +0100 | [diff] [blame] | 333 | YYERROR;
|
| 334 | }
|
| 335 | trg = (struct lys_module *)submodule;
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 336 | yang_read_common(trg,s,MODULE_KEYWORD);
|
Pavol Vican | 75dbc5c | 2016-03-09 16:34:58 +0100 | [diff] [blame] | 337 | s = NULL;
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 338 | config_inherit = ENABLE_INHERIT;
|
Pavol Vican | 75dbc5c | 2016-03-09 16:34:58 +0100 | [diff] [blame] | 339 | }
|
| 340 | }
|
Pavol Vican | 35f4a8a | 2016-03-09 16:20:06 +0100 | [diff] [blame] | 341 | '{' stmtsep
|
| 342 | submodule_header_stmts { if (read_all && !submodule->prefix) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 343 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "belongs-to", "submodule");
|
Pavol Vican | 35f4a8a | 2016-03-09 16:20:06 +0100 | [diff] [blame] | 344 | YYERROR;
|
| 345 | }
|
| 346 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 347 | linkage_stmts
|
Pavol Vican | 75dbc5c | 2016-03-09 16:34:58 +0100 | [diff] [blame] | 348 | meta_stmts
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 349 | revision_stmts
|
| 350 | body_stmts
|
| 351 | '}' optsep
|
| 352 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 353 | submodule_header_stmts: @EMPTYDIR@ { $$ = 0; }
|
Pavol Vican | 35f4a8a | 2016-03-09 16:20:06 +0100 | [diff] [blame] | 354 | | submodule_header_stmts yang_version_stmt { if ($1) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 355 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "yang version", "submodule");
|
Pavol Vican | 35f4a8a | 2016-03-09 16:20:06 +0100 | [diff] [blame] | 356 | YYERROR;
|
| 357 | }
|
| 358 | $$ = 1;
|
| 359 | }
|
| 360 | | submodule_header_stmts { if (read_all) {
|
| 361 | if (submodule->prefix) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 362 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "belongs-to", "submodule");
|
Pavol Vican | 35f4a8a | 2016-03-09 16:20:06 +0100 | [diff] [blame] | 363 | YYERROR;
|
| 364 | }
|
| 365 | }
|
| 366 | }
|
| 367 | belongs_to_stmt
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 368 |
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 369 | yang_version_stmt: YANG_VERSION_KEYWORD sep yang_version_arg_str stmtend;
|
| 370 |
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 371 | yang_version_arg_str: NON_NEGATIVE_INTEGER { if (strlen(yyget_text(scanner))!=1 || yyget_text(scanner)[0]!='1') {
|
| 372 | YYERROR;
|
| 373 | }
|
| 374 | } optsep
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 375 | | string_1 { if (read_all) {
|
| 376 | if (strlen(s)!=1 || s[0]!='1') {
|
| 377 | free(s);
|
| 378 | YYERROR;
|
| 379 | }
|
| 380 | }
|
| 381 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 382 |
|
Pavol Vican | 1d68410 | 2016-03-23 10:18:54 +0100 | [diff] [blame] | 383 | namespace_stmt: NAMESPACE_KEYWORD sep string stmtend;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 384 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 385 | linkage_stmts: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | 9b89dda | 2016-03-09 15:36:55 +0100 | [diff] [blame] | 386 | if (size_arrays->imp) {
|
| 387 | trg->imp = calloc(size_arrays->imp, sizeof *trg->imp);
|
| 388 | if (!trg->imp) {
|
| 389 | LOGMEM;
|
| 390 | YYERROR;
|
| 391 | }
|
| 392 | }
|
| 393 | if (size_arrays->inc) {
|
| 394 | trg->inc = calloc(size_arrays->inc, sizeof *trg->inc);
|
| 395 | if (!trg->inc) {
|
| 396 | LOGMEM;
|
| 397 | YYERROR;
|
| 398 | }
|
| 399 | trg->inc_size = size_arrays->inc;
|
| 400 | size_arrays->inc = 0;
|
| 401 | /* trg->inc_size can be updated by the included submodules,
|
| 402 | * so we will use size_arrays->inc here, trg->inc_size stores the
|
| 403 | * target size of the array
|
| 404 | */
|
| 405 | }
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 406 | }
|
| 407 | }
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 408 | | linkage_stmts import_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 409 | | linkage_stmts include_stmt
|
| 410 | ;
|
| 411 |
|
Pavol Vican | 6eb14e8 | 2016-02-03 12:27:13 +0100 | [diff] [blame] | 412 | import_stmt: IMPORT_KEYWORD sep tmp_identifier_arg_str {
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 413 | if (!read_all) {
|
| 414 | size_arrays->imp++;
|
| 415 | } else {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 416 | actual = &trg->imp[trg->imp_size];
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 417 | }
|
Pavol Vican | 6eb14e8 | 2016-02-03 12:27:13 +0100 | [diff] [blame] | 418 | }
|
| 419 | '{' stmtsep
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 420 | prefix_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 421 | if (yang_read_prefix(trg, actual, s, IMPORT_KEYWORD)) {YYERROR;}
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 422 | s=NULL;
|
| 423 | actual_type=IMPORT_KEYWORD;
|
| 424 | }
|
| 425 | }
|
Pavol Vican | 6eb14e8 | 2016-02-03 12:27:13 +0100 | [diff] [blame] | 426 | revision_date_opt
|
Pavol Vican | 6106f9c | 2016-03-24 08:08:53 +0100 | [diff] [blame] | 427 | '}' stmtsep { if (read_all) {
|
| 428 | $$ = trg;
|
| 429 | if (yang_fill_import(trg, actual, $3)) {
|
| 430 | YYERROR;
|
| 431 | }
|
| 432 | trg = $$;
|
| 433 | config_inherit = ENABLE_INHERIT;
|
| 434 | }
|
| 435 | }
|
Pavol Vican | 6eb14e8 | 2016-02-03 12:27:13 +0100 | [diff] [blame] | 436 |
|
| 437 | tmp_identifier_arg_str: identifier_arg_str { $$ = s; s = NULL; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 438 |
|
Pavol Vican | 5587041 | 2016-03-10 12:36:21 +0100 | [diff] [blame] | 439 | include_stmt: INCLUDE_KEYWORD sep identifier_arg_str { if (read_all) {
|
Pavol Vican | 9b89dda | 2016-03-09 15:36:55 +0100 | [diff] [blame] | 440 | memset(rev, 0, LY_REV_SIZE);
|
| 441 | actual_type = INCLUDE_KEYWORD;
|
| 442 | }
|
| 443 | else {
|
| 444 | size_arrays->inc++;
|
| 445 | }
|
| 446 | }
|
| 447 | include_end stmtsep { if (read_all) {
|
| 448 | $$ = trg;
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 449 | if (yang_fill_include(module, submodule, s, rev, size_arrays->inc, unres)) {
|
Pavol Vican | 9b89dda | 2016-03-09 15:36:55 +0100 | [diff] [blame] | 450 | YYERROR;
|
| 451 | }
|
| 452 | size_arrays->inc++;
|
Pavol Vican | 5587041 | 2016-03-10 12:36:21 +0100 | [diff] [blame] | 453 | s = NULL;
|
Pavol Vican | 9b89dda | 2016-03-09 15:36:55 +0100 | [diff] [blame] | 454 | trg = $$;
|
Pavol Vican | 6106f9c | 2016-03-24 08:08:53 +0100 | [diff] [blame] | 455 | config_inherit = ENABLE_INHERIT;
|
Pavol Vican | 9b89dda | 2016-03-09 15:36:55 +0100 | [diff] [blame] | 456 | }
|
| 457 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 458 |
|
| 459 | include_end: ';'
|
| 460 | | '{' stmtsep
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 461 | revision_date_opt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 462 | '}'
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 463 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 464 | revision_date_opt: @EMPTYDIR@
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 465 | | revision_date_stmt;
|
| 466 |
|
Pavol Vican | 6eb14e8 | 2016-02-03 12:27:13 +0100 | [diff] [blame] | 467 | revision_date_stmt: REVISION_DATE_KEYWORD sep revision_date optsep stmtend;
|
| 468 |
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 469 | revision_date: REVISION_DATE { if (read_all) {
|
| 470 | if (actual_type==IMPORT_KEYWORD) {
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 471 | memcpy(((struct lys_import *)actual)->rev, yyget_text(scanner), LY_REV_SIZE-1);
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 472 | } else { // INCLUDE KEYWORD
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 473 | memcpy(rev, yyget_text(scanner), LY_REV_SIZE - 1);
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 474 | }
|
Pavol Vican | 6eb14e8 | 2016-02-03 12:27:13 +0100 | [diff] [blame] | 475 | }
|
| 476 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 477 |
|
Pavol Vican | 6a2f067 | 2016-03-09 15:52:18 +0100 | [diff] [blame] | 478 | belongs_to_stmt: BELONGS_TO_KEYWORD sep identifier_arg_str { if (read_all) {
|
Pavol Vican | 1835e79 | 2016-03-21 09:13:53 +0100 | [diff] [blame] | 479 | if (!ly_strequal(s, submodule->belongsto->name, 0)) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 480 | LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "belongs-to");
|
Pavol Vican | 6a2f067 | 2016-03-09 15:52:18 +0100 | [diff] [blame] | 481 | free(s);
|
| 482 | YYERROR;
|
| 483 | }
|
| 484 | free(s);
|
| 485 | s = NULL;
|
| 486 | }
|
| 487 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 488 | '{' stmtsep
|
Pavol Vican | 6a2f067 | 2016-03-09 15:52:18 +0100 | [diff] [blame] | 489 | prefix_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 490 | if (yang_read_prefix(trg, NULL, s, MODULE_KEYWORD)) {
|
Pavol Vican | 6a2f067 | 2016-03-09 15:52:18 +0100 | [diff] [blame] | 491 | YYERROR;
|
| 492 | }
|
Pavol Vican | 6a2f067 | 2016-03-09 15:52:18 +0100 | [diff] [blame] | 493 | s = NULL;
|
| 494 | }
|
| 495 | }
|
Pavol Vican | 2d59b7e | 2016-03-09 21:32:51 +0100 | [diff] [blame] | 496 | '}' stmtsep
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 497 |
|
| 498 | prefix_stmt: PREFIX_KEYWORD sep prefix_arg_str stmtend;
|
| 499 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 500 | meta_stmts: @EMPTYDIR@
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 501 | | meta_stmts organization_stmt { if (read_all && yang_read_common(trg, s, ORGANIZATION_KEYWORD)) {YYERROR;} s=NULL; }
|
| 502 | | meta_stmts contact_stmt { if (read_all && yang_read_common(trg, s, CONTACT_KEYWORD)) {YYERROR;} s=NULL; }
|
| 503 | | meta_stmts description_stmt { if (read_all && yang_read_description(trg, NULL, s, NULL)) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 504 | YYERROR;
|
| 505 | }
|
| 506 | s = NULL;
|
| 507 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 508 | | meta_stmts reference_stmt { if (read_all && yang_read_reference(trg, NULL, s, NULL)) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 509 | YYERROR;
|
| 510 | }
|
| 511 | s=NULL;
|
| 512 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 513 |
|
| 514 | organization_stmt: ORGANIZATION_KEYWORD sep string stmtend;
|
| 515 |
|
| 516 | contact_stmt: CONTACT_KEYWORD sep string stmtend;
|
| 517 |
|
| 518 | description_stmt: DESCRIPTION_KEYWORD sep string stmtend;
|
| 519 |
|
| 520 | reference_stmt: REFERENCE_KEYWORD sep string stmtend;
|
| 521 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 522 | revision_stmts: @EMPTYDIR@ { if (read_all && size_arrays->rev) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 523 | trg->rev = calloc(size_arrays->rev, sizeof *trg->rev);
|
Pavol Vican | fb8ded6 | 2016-03-21 09:43:58 +0100 | [diff] [blame] | 524 | if (!trg->rev) {
|
| 525 | LOGMEM;
|
| 526 | YYERROR;
|
| 527 | }
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 528 | }
|
| 529 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 530 | | revision_stmts revision_stmt stmtsep;
|
| 531 |
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 532 |
|
| 533 | revision_stmt: REVISION_KEYWORD sep date_arg_str { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 534 | if(!(actual=yang_read_revision(trg,s))) {YYERROR;}
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 535 | s=NULL;
|
| 536 | } else {
|
| 537 | size_arrays->rev++;
|
| 538 | }
|
| 539 | }
|
Pavol Vican | bedff69 | 2016-02-03 14:29:17 +0100 | [diff] [blame] | 540 | revision_end;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 541 |
|
| 542 | revision_end: ';'
|
Pavol Vican | bedff69 | 2016-02-03 14:29:17 +0100 | [diff] [blame] | 543 | | '{' stmtsep { actual_type = REVISION_KEYWORD; }
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 544 | revision_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 545 | '}'
|
| 546 | ;
|
| 547 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 548 | revision_opt_stmt: @EMPTYDIR@
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 549 | | revision_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, "revision")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 550 | YYERROR;
|
| 551 | }
|
| 552 | s = NULL;
|
| 553 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 554 | | revision_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, "revision")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 555 | YYERROR;
|
| 556 | }
|
| 557 | s = NULL;
|
| 558 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 559 | ;
|
| 560 |
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 561 | date_arg_str: REVISION_DATE { if (read_all) {
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 562 | s = strdup(yyget_text(scanner));
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 563 | if (!s) {
|
| 564 | LOGMEM;
|
| 565 | YYERROR;
|
| 566 | }
|
| 567 | }
|
| 568 | }
|
| 569 | optsep
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 570 | | string_1 { if (read_all && lyp_check_date(s)) {
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 571 | free(s);
|
| 572 | YYERROR;
|
| 573 | }
|
| 574 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 575 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 576 | body_stmts: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | 9f98997 | 2016-03-02 14:44:11 +0100 | [diff] [blame] | 577 | if (size_arrays->features) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 578 | trg->features = calloc(size_arrays->features,sizeof *trg->features);
|
| 579 | if (!trg->features) {
|
Pavol Vican | 9f98997 | 2016-03-02 14:44:11 +0100 | [diff] [blame] | 580 | LOGMEM;
|
| 581 | YYERROR;
|
| 582 | }
|
| 583 | }
|
| 584 | if (size_arrays->ident) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 585 | trg->ident = calloc(size_arrays->ident,sizeof *trg->ident);
|
| 586 | if (!trg->ident) {
|
Pavol Vican | 9f98997 | 2016-03-02 14:44:11 +0100 | [diff] [blame] | 587 | LOGMEM;
|
| 588 | YYERROR;
|
| 589 | }
|
| 590 | }
|
| 591 | if (size_arrays->augment) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 592 | trg->augment = calloc(size_arrays->augment,sizeof *trg->augment);
|
| 593 | if (!trg->augment) {
|
Pavol Vican | 9f98997 | 2016-03-02 14:44:11 +0100 | [diff] [blame] | 594 | LOGMEM;
|
| 595 | YYERROR;
|
| 596 | }
|
| 597 | }
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 598 | if (size_arrays->tpdf) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 599 | trg->tpdf = calloc(size_arrays->tpdf, sizeof *trg->tpdf);
|
| 600 | if (!trg->tpdf) {
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 601 | LOGMEM;
|
| 602 | YYERROR;
|
| 603 | }
|
| 604 | }
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 605 | if (size_arrays->deviation) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 606 | trg->deviation = calloc(size_arrays->deviation, sizeof *trg->deviation);
|
| 607 | if (!trg->deviation) {
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 608 | LOGMEM;
|
| 609 | YYERROR;
|
| 610 | }
|
Pavol Vican | 2d59b7e | 2016-03-09 21:32:51 +0100 | [diff] [blame] | 611 | /* module with deviation - must be implemented (description of /ietf-yang-library:modules-state/module/deviation) */
|
| 612 | module->implemented = 1;
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 613 | }
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 614 | actual = NULL;
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 615 | }
|
| 616 | }
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 617 | | body_stmts body_stmt stmtsep { actual = NULL; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 618 |
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 619 |
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 620 | body_stmt: extension_stmt
|
| 621 | | feature_stmt
|
| 622 | | identity_stmt
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 623 | | typedef_stmt { if (!read_all) { size_arrays->tpdf++; } }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 624 | | grouping_stmt
|
| 625 | | data_def_stmt
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 626 | | augment_stmt { if (!read_all) {
|
| 627 | size_arrays->augment++;
|
| 628 | } else {
|
| 629 | config_inherit = ENABLE_INHERIT;
|
| 630 | }
|
| 631 | }
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 632 | | rpc_stmt
|
| 633 | | notification_stmt
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 634 | | deviation_stmt { if (!read_all) { size_arrays->deviation++; } }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 635 |
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 636 | extension_stmt: EXTENSION_KEYWORD sep identifier_arg_str { if (read_all) {
|
| 637 | /* we have the following supported (hardcoded) extensions: */
|
| 638 | /* ietf-netconf's get-filter-element-attributes */
|
| 639 | if (!strcmp(module->ns, LY_NSNC) && !strcmp(s, "get-filter-element-attributes")) {
|
| 640 | LOGDBG("NETCONF filter extension found");
|
| 641 | /* NACM's default-deny-write and default-deny-all */
|
| 642 | } else if (!strcmp(module->ns, LY_NSNACM) &&
|
| 643 | (!strcmp(s, "default-deny-write") || !strcmp(s, "default-deny-all"))) {
|
| 644 | LOGDBG("NACM extension found");
|
| 645 | /* other extensions are not supported, so inform about such an extension */
|
| 646 | } else {
|
| 647 | LOGWRN("Not supported \"%s\" extension statement found, ignoring.", s);
|
| 648 | }
|
| 649 | free(s);
|
| 650 | s = NULL;
|
| 651 | }
|
| 652 | }
|
| 653 | extension_end
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 654 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 655 | extension_end: ';'
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 656 | | '{' stmtsep
|
| 657 | extension_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 658 | '}'
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 659 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 660 | extension_opt_stmt: @EMPTYDIR@ { $$ = 0; }
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 661 | | extension_opt_stmt argument_stmt { if ($1 & EXTENSION_ARG) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 662 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "argument", "extension");
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 663 | YYERROR;
|
| 664 | }
|
| 665 | $1 |= EXTENSION_ARG;
|
| 666 | $$ = $1;
|
| 667 | }
|
| 668 | | extension_opt_stmt status_stmt { if ($1 & EXTENSION_STA) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 669 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "status", "extension");
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 670 | YYERROR;
|
| 671 | }
|
| 672 | $1 |= EXTENSION_STA;
|
| 673 | $$ = $1;
|
| 674 | }
|
| 675 | | extension_opt_stmt description_stmt { if (read_all) {
|
| 676 | free(s);
|
| 677 | s= NULL;
|
| 678 | }
|
| 679 | if ($1 & EXTENSION_DSC) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 680 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "description", "extension");
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 681 | YYERROR;
|
| 682 | }
|
| 683 | $1 |= EXTENSION_DSC;
|
| 684 | $$ = $1;
|
| 685 | }
|
| 686 | | extension_opt_stmt reference_stmt { if (read_all) {
|
| 687 | free(s);
|
| 688 | s = NULL;
|
| 689 | }
|
| 690 | if ($1 & EXTENSION_REF) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 691 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "reference", "extension");
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 692 | YYERROR;
|
| 693 | }
|
| 694 | $1 |= EXTENSION_REF;
|
| 695 | $$ = $1;
|
| 696 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 697 |
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 698 | argument_stmt: ARGUMENT_KEYWORD sep identifier_arg_str { free(s); s = NULL; } argument_end stmtsep;
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 699 |
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 700 | argument_end: ';'
|
| 701 | | '{' stmtsep
|
| 702 | yin_element_stmt
|
| 703 | '}'
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 704 |
|
| 705 | yin_element_stmt: YIN_ELEMENT_KEYWORD sep yin_element_arg_str stmtend;
|
| 706 |
|
| 707 | yin_element_arg_str: TRUE_KEYWORD optsep
|
| 708 | | FALSE_KEYWORD optsep
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 709 | | string_1 { if (read_all) {
|
| 710 | if (strcmp(s, "true") && strcmp(s, "false")) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 711 | LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, s);
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 712 | free(s);
|
| 713 | YYERROR;
|
| 714 | }
|
| 715 | free(s);
|
| 716 | s = NULL;
|
| 717 | }
|
| 718 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 719 |
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 720 | status_stmt: STATUS_KEYWORD sep status_arg_str stmtend { $$ = $3; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 721 |
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 722 | status_read_stmt: STATUS_KEYWORD sep { read_all = (read_all) ? LY_READ_ONLY_SIZE : LY_READ_ALL; }
|
| 723 | status_arg_str { read_all = (read_all) ? LY_READ_ONLY_SIZE : LY_READ_ALL; }
|
| 724 | stmtend { $$ = $4; }
|
| 725 |
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 726 | status_arg_str: CURRENT_KEYWORD optsep { $$ = LYS_STATUS_CURR; }
|
| 727 | | OBSOLETE_KEYWORD optsep { $$ = LYS_STATUS_OBSLT; }
|
| 728 | | DEPRECATED_KEYWORD optsep { $$ = LYS_STATUS_DEPRC; }
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 729 | | string_1 { if (read_all) {
|
| 730 | if (!strcmp(s, "current")) {
|
| 731 | $$ = LYS_STATUS_CURR;
|
| 732 | } else if (!strcmp(s, "obsolete")) {
|
| 733 | $$ = LYS_STATUS_OBSLT;
|
| 734 | } else if (!strcmp(s, "deprecated")) {
|
| 735 | $$ = LYS_STATUS_DEPRC;
|
| 736 | } else {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 737 | LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, s);
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 738 | free(s);
|
| 739 | YYERROR;
|
| 740 | }
|
| 741 | free(s);
|
| 742 | s = NULL;
|
| 743 | }
|
| 744 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 745 |
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 746 | feature_stmt: FEATURE_KEYWORD sep identifier_arg_str { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 747 | if (!(actual = yang_read_feature(trg, s))) {YYERROR;}
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 748 | s=NULL;
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 749 | } else {
|
| 750 | size_arrays->features++;
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 751 | }
|
| 752 | }
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 753 | feature_end
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 754 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 755 | feature_end: ';'
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 756 | | '{' stmtsep
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 757 | feature_opt_stmt
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 758 | '}'
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 759 | ;
|
| 760 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 761 | feature_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 762 | if (size_arrays->node[size_arrays->next].if_features) {
|
| 763 | ((struct lys_feature*)actual)->features = calloc(size_arrays->node[size_arrays->next].if_features,
|
| 764 | sizeof *((struct lys_feature*)actual)->features);
|
| 765 | if (!((struct lys_feature*)actual)->features) {
|
| 766 | LOGMEM;
|
| 767 | YYERROR;
|
| 768 | }
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 769 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 770 | store_flags((struct lys_node *)actual, size_arrays->node[size_arrays->next].flags, 0);
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 771 | size_arrays->next++;
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 772 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 773 | $$ = size_arrays->size;
|
| 774 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 775 | LOGMEM;
|
| 776 | YYERROR;
|
| 777 | }
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 778 | }
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 779 | }
|
| 780 | | feature_opt_stmt if_feature_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 781 | if (yang_read_if_feature(trg, actual, s, unres, FEATURE_KEYWORD)) {YYERROR;}
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 782 | s=NULL;
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 783 | } else {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 784 | size_arrays->node[$1].if_features++;
|
Pavol Vican | e1354e9 | 2016-02-09 14:02:09 +0100 | [diff] [blame] | 785 | }
|
| 786 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 787 | | feature_opt_stmt status_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 788 | if (yang_check_flags(&size_arrays->node[$1].flags, LYS_STATUS_MASK, "status", "feature", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 789 | YYERROR;
|
| 790 | }
|
| 791 | }
|
| 792 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 793 | | feature_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, "feature")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 794 | YYERROR;
|
| 795 | }
|
| 796 | s = NULL;
|
| 797 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 798 | | feature_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, "feature")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 799 | YYERROR;
|
| 800 | }
|
| 801 | s = NULL;
|
| 802 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 803 |
|
| 804 | if_feature_stmt: IF_FEATURE_KEYWORD sep identifier_ref_arg_str stmtend;
|
| 805 |
|
Pavol Vican | bbdef53 | 2016-02-09 14:52:12 +0100 | [diff] [blame] | 806 | identity_stmt: IDENTITY_KEYWORD sep identifier_arg_str { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 807 | if (!(actual = yang_read_identity(trg,s))) {YYERROR;}
|
Pavol Vican | bbdef53 | 2016-02-09 14:52:12 +0100 | [diff] [blame] | 808 | s = NULL;
|
| 809 | } else {
|
| 810 | size_arrays->ident++;
|
| 811 | }
|
| 812 | }
|
| 813 | identity_end;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 814 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 815 | identity_end: ';'
|
Pavol Vican | bbdef53 | 2016-02-09 14:52:12 +0100 | [diff] [blame] | 816 | | '{' stmtsep
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 817 | identity_opt_stmt { if (read_all && yang_read_base(module, actual, $3, unres)) {
|
Pavol Vican | e236898 | 2016-03-19 14:37:56 +0100 | [diff] [blame] | 818 | YYERROR;
|
| 819 | }
|
| 820 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 821 | '}'
|
| 822 | ;
|
| 823 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 824 | identity_opt_stmt: @EMPTYDIR@ { $$ = NULL; }
|
Pavol Vican | e236898 | 2016-03-19 14:37:56 +0100 | [diff] [blame] | 825 | | identity_opt_stmt base_stmt { if (read_all) {
|
| 826 | if ($1) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 827 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "base", "identity");
|
Pavol Vican | e236898 | 2016-03-19 14:37:56 +0100 | [diff] [blame] | 828 | free(s);
|
| 829 | free($1);
|
| 830 | YYERROR;
|
| 831 | }
|
| 832 | $$ = s;
|
Pavol Vican | e236898 | 2016-03-19 14:37:56 +0100 | [diff] [blame] | 833 | s = NULL;
|
| 834 | }
|
| 835 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 836 | | identity_opt_stmt status_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 837 | if (yang_check_flags(&((struct lys_ident *)actual)->flags, LYS_STATUS_MASK, "status", "identity", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 838 | YYERROR;
|
| 839 | }
|
Pavol Vican | e236898 | 2016-03-19 14:37:56 +0100 | [diff] [blame] | 840 | }
|
| 841 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 842 | | identity_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, "identity")) {
|
Pavol Vican | e236898 | 2016-03-19 14:37:56 +0100 | [diff] [blame] | 843 | free($1);
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 844 | YYERROR;
|
| 845 | }
|
| 846 | s = NULL;
|
| 847 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 848 | | identity_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, "identity")) {
|
Pavol Vican | e236898 | 2016-03-19 14:37:56 +0100 | [diff] [blame] | 849 | free($1);
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 850 | YYERROR;
|
| 851 | }
|
| 852 | s = NULL;
|
| 853 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 854 |
|
| 855 | base_stmt: BASE_KEYWORD sep identifier_ref_arg_str stmtend;
|
| 856 |
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 857 | typedef_stmt: TYPEDEF_KEYWORD sep typedef_arg_str
|
| 858 | '{' stmtsep
|
| 859 | type_opt_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 860 | if (!($6.node.flag & LYS_TYPE_DEF)) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 861 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "type", "typedef");
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 862 | YYERROR;
|
| 863 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 864 | if (unres_schema_add_node(trg, unres, &$6.node.ptr_tpdf->type, UNRES_TYPE_DER,(struct lys_node *) $3)) {
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 865 | YYERROR;
|
| 866 | }
|
| 867 | actual = $3;
|
| 868 |
|
| 869 | /* check default value */
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 870 | if ($6.node.ptr_tpdf->dflt) {
|
| 871 | if (unres_schema_add_str(trg, unres, &$6.node.ptr_tpdf->type, UNRES_TYPE_DFLT, $6.node.ptr_tpdf->dflt) == -1) {
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 872 | YYERROR;
|
| 873 | }
|
| 874 | }
|
| 875 | }
|
| 876 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 877 | '}' ;
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 878 |
|
| 879 | typedef_arg_str: identifier_arg_str { if (read_all) {
|
| 880 | $$ = actual;
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 881 | if (!(actual = yang_read_typedef(trg, actual, s))) {
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 882 | YYERROR;
|
| 883 | }
|
| 884 | s = NULL;
|
| 885 | actual_type = TYPEDEF_KEYWORD;
|
| 886 | }
|
| 887 | }
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 888 |
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 889 | type_stmt: TYPE_KEYWORD sep identifier_ref_arg_str { if (read_all && !(actual = yang_read_type(trg, actual, s, actual_type))) {
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 890 | YYERROR;
|
| 891 | }
|
| 892 | s = NULL;
|
| 893 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 894 | type_end;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 895 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 896 | type_opt_stmt: @EMPTYDIR@ { $$.node.ptr_tpdf = actual;
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 897 | $$.node.flag = 0;
|
| 898 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 899 | | type_opt_stmt { if (read_all && ($1.node.flag & LYS_TYPE_DEF)) {
|
| 900 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, $1.node.ptr_tpdf, "type", "typedef");
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 901 | YYERROR;
|
| 902 | }
|
| 903 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 904 | type_stmt stmtsep { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 905 | actual = $1.node.ptr_tpdf;
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 906 | actual_type = TYPEDEF_KEYWORD;
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 907 | $1.node.flag |= LYS_TYPE_DEF;
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 908 | $$ = $1;
|
| 909 | }
|
| 910 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 911 | | type_opt_stmt units_stmt { if (read_all && yang_read_units(trg, $1.node.ptr_tpdf, s, TYPEDEF_KEYWORD)) {YYERROR;} s = NULL; }
|
| 912 | | type_opt_stmt default_stmt { if (read_all && yang_read_default(trg, $1.node.ptr_tpdf, s, TYPEDEF_KEYWORD)) {
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 913 | YYERROR;
|
| 914 | }
|
| 915 | s = NULL;
|
Pavol Vican | 0df02b0 | 2016-03-01 10:28:50 +0100 | [diff] [blame] | 916 | $$ = $1;
|
| 917 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 918 | | type_opt_stmt status_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 919 | if (yang_check_flags(&$1.node.ptr_tpdf->flags, LYS_STATUS_MASK, "status", "typedef", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 920 | YYERROR;
|
| 921 | }
|
| 922 | }
|
| 923 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 924 | | type_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.node.ptr_tpdf, s, "typedef")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 925 | YYERROR;
|
| 926 | }
|
| 927 | s = NULL;
|
| 928 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 929 | | type_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.node.ptr_tpdf, s, "typedef")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 930 | YYERROR;
|
| 931 | }
|
| 932 | s = NULL;
|
| 933 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 934 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 935 | type_end: ';'
|
Pavol Vican | 1c203db | 2016-02-24 14:05:23 +0100 | [diff] [blame] | 936 | | '{' stmtsep
|
| 937 | type_body_stmts
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 938 | '}'
|
| 939 | ;
|
| 940 |
|
| 941 |
|
Pavol Vican | a4f045a | 2016-02-29 15:01:20 +0100 | [diff] [blame] | 942 | type_body_stmts: decimal_string_restrictions
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 943 | | enum_specification
|
Pavol Vican | 191613a | 2016-02-26 16:21:32 +0100 | [diff] [blame] | 944 | | path_stmt { /*leafref_specification */
|
| 945 | if (read_all) {
|
Pavol Vican | 6b07251 | 2016-04-04 10:50:21 +0200 | [diff] [blame] | 946 | ((struct yang_type *)actual)->base = LY_TYPE_LEAFREF;
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 947 | ((struct yang_type *)actual)->type->info.lref.path = lydict_insert_zc(trg->ctx, s);
|
Pavol Vican | 191613a | 2016-02-26 16:21:32 +0100 | [diff] [blame] | 948 | s = NULL;
|
| 949 | }
|
| 950 | }
|
Pavol Vican | 1ff0e22 | 2016-02-26 12:27:01 +0100 | [diff] [blame] | 951 | | base_stmt { /*identityref_specification */
|
| 952 | if (read_all) {
|
| 953 | ((struct yang_type *)actual)->flags |= LYS_TYPE_BASE;
|
Pavol Vican | 6b07251 | 2016-04-04 10:50:21 +0200 | [diff] [blame] | 954 | ((struct yang_type *)actual)->base = LY_TYPE_LEAFREF;
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 955 | ((struct yang_type *)actual)->type->info.lref.path = lydict_insert_zc(trg->ctx, s);
|
Pavol Vican | 1ff0e22 | 2016-02-26 12:27:01 +0100 | [diff] [blame] | 956 | s = NULL;
|
| 957 | }
|
| 958 | }
|
Pavol Vican | 7dddedc | 2016-02-26 16:54:03 +0100 | [diff] [blame] | 959 | | require_instance_stmt { /*instance_identifier_specification */
|
| 960 | if (read_all) {
|
Pavol Vican | 6b07251 | 2016-04-04 10:50:21 +0200 | [diff] [blame] | 961 | ((struct yang_type *)actual)->base = LY_TYPE_INST;
|
Pavol Vican | 7dddedc | 2016-02-26 16:54:03 +0100 | [diff] [blame] | 962 | }
|
| 963 | }
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 964 | | bits_specification
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 965 | ;
|
| 966 |
|
| 967 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 968 | decimal_string_restrictions: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 969 | if (size_arrays->node[size_arrays->next].uni && size_arrays->node[size_arrays->next].pattern) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 970 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid restriction in type \"%s\".", ((struct yang_type *)actual)->type->parent->name);
|
Pavol Vican | a4f045a | 2016-02-29 15:01:20 +0100 | [diff] [blame] | 971 | YYERROR;
|
| 972 | }
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 973 | if (size_arrays->node[size_arrays->next].pattern) {
|
| 974 | ((struct yang_type *)actual)->type->info.str.patterns = calloc(size_arrays->node[size_arrays->next].pattern, sizeof(struct lys_restr));
|
Pavol Vican | 1c203db | 2016-02-24 14:05:23 +0100 | [diff] [blame] | 975 | if (!((struct yang_type *)actual)->type->info.str.patterns) {
|
| 976 | LOGMEM;
|
| 977 | YYERROR;
|
| 978 | }
|
Pavol Vican | 6b07251 | 2016-04-04 10:50:21 +0200 | [diff] [blame] | 979 | ((struct yang_type *)actual)->base = LY_TYPE_STRING;
|
Pavol Vican | 1c203db | 2016-02-24 14:05:23 +0100 | [diff] [blame] | 980 | }
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 981 | if (size_arrays->node[size_arrays->next].uni) {
|
| 982 | ((struct yang_type *)actual)->type->info.uni.types = calloc(size_arrays->node[size_arrays->next].uni, sizeof(struct lys_type));
|
Pavol Vican | a4f045a | 2016-02-29 15:01:20 +0100 | [diff] [blame] | 983 | if (!((struct yang_type *)actual)->type->info.uni.types) {
|
| 984 | LOGMEM;
|
| 985 | YYERROR;
|
| 986 | }
|
Pavol Vican | 6b07251 | 2016-04-04 10:50:21 +0200 | [diff] [blame] | 987 | ((struct yang_type *)actual)->base = LY_TYPE_UNION;
|
Pavol Vican | a4f045a | 2016-02-29 15:01:20 +0100 | [diff] [blame] | 988 | }
|
| 989 | size_arrays->next++;
|
Pavol Vican | 1c203db | 2016-02-24 14:05:23 +0100 | [diff] [blame] | 990 | } else {
|
| 991 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 992 | LOGMEM;
|
| 993 | YYERROR;
|
| 994 | }
|
| 995 | $$ = size_arrays->size-1;
|
| 996 | }
|
| 997 | }
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 998 | | decimal_string_restrictions length_stmt
|
Pavol Vican | 1c203db | 2016-02-24 14:05:23 +0100 | [diff] [blame] | 999 | | decimal_string_restrictions pattern_stmt { if (!read_all) {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 1000 | size_arrays->node[$1].pattern++; /* count of pattern*/
|
Pavol Vican | 1c203db | 2016-02-24 14:05:23 +0100 | [diff] [blame] | 1001 | }
|
| 1002 | }
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 1003 | | decimal_string_restrictions fraction_digits_stmt
|
| 1004 | | decimal_string_restrictions range_stmt stmtsep
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 1005 | | decimal_string_restrictions union_spec type_stmt stmtsep { if (read_all) {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 1006 | actual = $2;
|
| 1007 | } else {
|
| 1008 | size_arrays->node[$1].uni++; /* count of union*/
|
| 1009 | }
|
| 1010 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1011 | ;
|
| 1012 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1013 | union_spec: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | a4f045a | 2016-02-29 15:01:20 +0100 | [diff] [blame] | 1014 | struct yang_type *typ;
|
| 1015 | struct lys_type *type;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1016 |
|
Pavol Vican | a4f045a | 2016-02-29 15:01:20 +0100 | [diff] [blame] | 1017 | typ = (struct yang_type *)actual;
|
| 1018 | $$ = actual;
|
| 1019 | type = &typ->type->info.uni.types[typ->type->info.uni.count++];
|
| 1020 | type->parent = typ->type->parent;
|
| 1021 | actual = type;
|
| 1022 | actual_type = UNION_KEYWORD;
|
| 1023 | }
|
| 1024 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1025 |
|
Pavol Vican | 07ea68d | 2016-02-25 12:01:37 +0100 | [diff] [blame] | 1026 | fraction_digits_stmt: FRACTION_DIGITS_KEYWORD sep fraction_digits_arg_str
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1027 | stmtend { if (read_all && yang_read_fraction(actual, $3)) {
|
Pavol Vican | 07ea68d | 2016-02-25 12:01:37 +0100 | [diff] [blame] | 1028 | YYERROR;
|
| 1029 | }
|
| 1030 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1031 |
|
Pavol Vican | 07ea68d | 2016-02-25 12:01:37 +0100 | [diff] [blame] | 1032 | fraction_digits_arg_str: positive_integer_value optsep { $$ = $1; }
|
| 1033 | | string_1 { if (read_all) {
|
Pavol Vican | 07ea68d | 2016-02-25 12:01:37 +0100 | [diff] [blame] | 1034 | char *endptr = NULL;
|
| 1035 | unsigned long val;
|
| 1036 |
|
| 1037 | val = strtoul(s, &endptr, 10);
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 1038 | if (*endptr || s[0] == '-' || val == 0 || val > UINT32_MAX) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1039 | LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "fraction-digits");
|
Pavol Vican | 07ea68d | 2016-02-25 12:01:37 +0100 | [diff] [blame] | 1040 | free(s);
|
| 1041 | s = NULL;
|
| 1042 | YYERROR;
|
| 1043 | }
|
| 1044 | $$ = (uint32_t) val;
|
| 1045 | free(s);
|
| 1046 | s =NULL;
|
| 1047 | }
|
| 1048 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1049 | ;
|
| 1050 |
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 1051 | length_stmt: LENGTH_KEYWORD sep length_arg_str length_end stmtsep { actual = $3;
|
| 1052 | actual_type = TYPE_KEYWORD;
|
| 1053 | }
|
| 1054 |
|
| 1055 | length_arg_str: string { if (read_all) {
|
| 1056 | $$ = actual;
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1057 | if (!(actual = yang_read_length(trg, actual, s))) {
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 1058 | YYERROR;
|
| 1059 | }
|
| 1060 | actual_type = LENGTH_KEYWORD;
|
Pavol Vican | 1c203db | 2016-02-24 14:05:23 +0100 | [diff] [blame] | 1061 | s = NULL;
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 1062 | }
|
| 1063 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1064 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1065 | length_end: ';'
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 1066 | | '{' stmtsep
|
| 1067 | message_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1068 | '}'
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1069 | ;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1070 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1071 | message_opt_stmt: @EMPTYDIR@ { switch (actual_type) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 1072 | case MUST_KEYWORD:
|
| 1073 | $$ = "must";
|
| 1074 | break;
|
| 1075 | case LENGTH_KEYWORD:
|
| 1076 | $$ = "length";
|
| 1077 | break;
|
| 1078 | case PATTERN_KEYWORD:
|
| 1079 | $$ = "pattern";
|
| 1080 | break;
|
| 1081 | case RANGE_KEYWORD:
|
| 1082 | $$ = "range";
|
| 1083 | break;
|
| 1084 | }
|
| 1085 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1086 | | message_opt_stmt error_message_stmt { if (read_all && yang_read_message(trg, actual, s, $1, ERROR_MESSAGE_KEYWORD)) {
|
Pavol Vican | a343694 | 2016-03-21 09:25:52 +0100 | [diff] [blame] | 1087 | YYERROR;
|
| 1088 | }
|
| 1089 | s = NULL;
|
| 1090 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1091 | | message_opt_stmt error_app_tag_stmt { if (yang_read_message(trg, actual, s, $1, ERROR_APP_TAG_KEYWORD)) {
|
Pavol Vican | a343694 | 2016-03-21 09:25:52 +0100 | [diff] [blame] | 1092 | YYERROR;
|
| 1093 | }
|
| 1094 | s = NULL;
|
| 1095 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1096 | | message_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, $1)) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 1097 | YYERROR;
|
| 1098 | }
|
| 1099 | s = NULL;
|
| 1100 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1101 | | message_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, $1)) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 1102 | YYERROR;
|
| 1103 | }
|
| 1104 | s = NULL;
|
| 1105 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1106 |
|
Pavol Vican | 1c203db | 2016-02-24 14:05:23 +0100 | [diff] [blame] | 1107 | pattern_stmt: PATTERN_KEYWORD sep pattern_arg_str pattern_end stmtsep { actual = $3;
|
| 1108 | actual_type = TYPE_KEYWORD;
|
| 1109 | }
|
| 1110 |
|
| 1111 | pattern_arg_str: string { if (read_all) {
|
| 1112 | $$ = actual;
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1113 | if (!(actual = yang_read_pattern(trg, actual, s))) {
|
Pavol Vican | 1c203db | 2016-02-24 14:05:23 +0100 | [diff] [blame] | 1114 | YYERROR;
|
| 1115 | }
|
| 1116 | actual_type = PATTERN_KEYWORD;
|
| 1117 | s = NULL;
|
| 1118 | }
|
| 1119 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1120 |
|
| 1121 | pattern_end: ';'
|
Pavol Vican | 1c203db | 2016-02-24 14:05:23 +0100 | [diff] [blame] | 1122 | | '{' stmtsep
|
| 1123 | message_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1124 | '}'
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1125 | ;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1126 |
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1127 | enum_specification: { if (read_all) {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 1128 | if (size_arrays->node[size_arrays->next].enm) {
|
| 1129 | ((struct yang_type *)actual)->type->info.enums.enm = calloc(size_arrays->node[size_arrays->next++].enm, sizeof(struct lys_type_enum));
|
Pavol Vican | fb8ded6 | 2016-03-21 09:43:58 +0100 | [diff] [blame] | 1130 | if (!((struct yang_type *)actual)->type->info.enums.enm) {
|
| 1131 | LOGMEM;
|
| 1132 | YYERROR;
|
| 1133 | }
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1134 | }
|
Pavol Vican | 6b07251 | 2016-04-04 10:50:21 +0200 | [diff] [blame] | 1135 | ((struct yang_type *)actual)->base = LY_TYPE_ENUM;
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1136 | cnt_val = 0;
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1137 | } else {
|
| 1138 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 1139 | LOGMEM;
|
| 1140 | YYERROR;
|
| 1141 | }
|
| 1142 | }
|
| 1143 | } enum_stmt stmtsep enum_stmts;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1144 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1145 | enum_stmts: @EMPTYDIR@
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1146 | | enum_stmts enum_stmt stmtsep;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1147 |
|
| 1148 |
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1149 | enum_stmt: ENUM_KEYWORD sep enum_arg_str enum_end
|
| 1150 | { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1151 | if (yang_check_enum($3, actual, &cnt_val, actual_type)) {
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1152 | YYERROR;
|
| 1153 | }
|
| 1154 | actual = $3;
|
| 1155 | actual_type = TYPE_KEYWORD;
|
| 1156 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 1157 | size_arrays->node[size_arrays->size-1].enm++; /* count of enum*/
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1158 | }
|
| 1159 | }
|
| 1160 |
|
| 1161 | enum_arg_str: string { if (read_all) {
|
| 1162 | $$ = actual;
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1163 | if (!(actual = yang_read_enum(trg, actual, s))) {
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1164 | YYERROR;
|
| 1165 | }
|
| 1166 | s = NULL;
|
| 1167 | actual_type = 0;
|
| 1168 | }
|
| 1169 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1170 |
|
| 1171 | enum_end: ';'
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1172 | | '{' stmtsep
|
| 1173 | enum_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1174 | '}'
|
| 1175 | ;
|
| 1176 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1177 | enum_opt_stmt: @EMPTYDIR@
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1178 | | enum_opt_stmt value_stmt { /* actual_type - it is used to check value of enum statement*/
|
| 1179 | if (read_all) {
|
| 1180 | if (actual_type) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1181 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "value", "enum");
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1182 | YYERROR;
|
| 1183 | }
|
| 1184 | actual_type = 1;
|
| 1185 | }
|
| 1186 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1187 | | enum_opt_stmt status_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1188 | if (yang_check_flags(&((struct lys_type_enum *)actual)->flags, LYS_STATUS_MASK, "status", "enum", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1189 | YYERROR;
|
| 1190 | }
|
| 1191 | }
|
| 1192 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1193 | | enum_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, "enum")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 1194 | YYERROR;
|
| 1195 | }
|
| 1196 | s = NULL;
|
| 1197 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1198 | | enum_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, "enum")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 1199 | YYERROR;
|
| 1200 | }
|
| 1201 | s = NULL;
|
| 1202 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1203 |
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1204 | value_stmt: VALUE_KEYWORD sep integer_value_arg_str
|
| 1205 | stmtend { if (read_all) {
|
| 1206 | ((struct lys_type_enum *)actual)->value = $3;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1207 |
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1208 | /* keep the highest enum value for automatic increment */
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1209 | if ($3 > cnt_val) {
|
| 1210 | cnt_val = $3;
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1211 | }
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1212 | cnt_val++;
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1213 | }
|
| 1214 | }
|
| 1215 |
|
| 1216 | integer_value_arg_str: integer_value optsep { $$ = $1; }
|
| 1217 | | string_1 { if (read_all) {
|
| 1218 | /* convert it to int32_t */
|
| 1219 | int64_t val;
|
| 1220 | char *endptr;
|
| 1221 |
|
| 1222 | val = strtoll(s, &endptr, 10);
|
| 1223 | if (val < INT32_MIN || val > INT32_MAX || *endptr) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1224 | LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "value");
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 1225 | free(s);
|
| 1226 | YYERROR;
|
| 1227 | }
|
| 1228 | free(s);
|
| 1229 | s = NULL;
|
| 1230 | $$ = (int32_t) val;
|
| 1231 | }
|
| 1232 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1233 | ;
|
| 1234 |
|
Pavol Vican | aff5c80 | 2016-02-24 15:56:45 +0100 | [diff] [blame] | 1235 | range_stmt: RANGE_KEYWORD sep range_arg_str range_end { actual = $3;
|
| 1236 | actual_type = RANGE_KEYWORD;
|
| 1237 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1238 |
|
| 1239 |
|
| 1240 | range_end: ';'
|
Pavol Vican | aff5c80 | 2016-02-24 15:56:45 +0100 | [diff] [blame] | 1241 | | '{' stmtsep
|
| 1242 | message_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1243 | '}'
|
| 1244 | ;
|
| 1245 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1246 | path_stmt: PATH_KEYWORD sep path_arg_str stmtend;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1247 |
|
| 1248 | require_instance_stmt: REQUIRE_INSTANCE_KEYWORD sep require_instance_arg_str stmtend;
|
| 1249 |
|
Pavol Vican | 7dddedc | 2016-02-26 16:54:03 +0100 | [diff] [blame] | 1250 | require_instance_arg_str: TRUE_KEYWORD optsep { if (read_all) {
|
| 1251 | ((struct yang_type *)actual)->type->info.inst.req = 1;
|
| 1252 | }
|
| 1253 | }
|
| 1254 | | FALSE_KEYWORD optsep { if (read_all) {
|
| 1255 | ((struct yang_type *)actual)->type->info.inst.req = -1;
|
| 1256 | }
|
| 1257 | }
|
| 1258 | | string_1 { if (read_all) {
|
| 1259 | if (!strcmp(s,"true")) {
|
| 1260 | ((struct yang_type *)actual)->type->info.inst.req = 1;
|
| 1261 | } else if (!strcmp(s,"false")) {
|
| 1262 | ((struct yang_type *)actual)->type->info.inst.req = -1;
|
| 1263 | } else {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1264 | LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "require-instance");
|
Pavol Vican | 7dddedc | 2016-02-26 16:54:03 +0100 | [diff] [blame] | 1265 | free(s);
|
| 1266 | YYERROR;
|
| 1267 | }
|
| 1268 | free(s);
|
| 1269 | }
|
| 1270 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1271 | ;
|
| 1272 |
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1273 | bits_specification: { if (read_all) {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 1274 | if (size_arrays->node[size_arrays->next].bit) {
|
| 1275 | ((struct yang_type *)actual)->type->info.bits.bit = calloc(size_arrays->node[size_arrays->next++].bit, sizeof(struct lys_type_bit));
|
Pavol Vican | fb8ded6 | 2016-03-21 09:43:58 +0100 | [diff] [blame] | 1276 | if (!((struct yang_type *)actual)->type->info.bits.bit) {
|
| 1277 | LOGMEM;
|
| 1278 | YYERROR;
|
| 1279 | }
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1280 | }
|
Pavol Vican | 6b07251 | 2016-04-04 10:50:21 +0200 | [diff] [blame] | 1281 | ((struct yang_type *)actual)->base = LY_TYPE_BITS;
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1282 | cnt_val = 0;
|
| 1283 | } else {
|
| 1284 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 1285 | LOGMEM;
|
| 1286 | YYERROR;
|
| 1287 | }
|
| 1288 | }
|
| 1289 | } bit_stmt bit_stmts
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1290 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1291 | bit_stmts: @EMPTYDIR@
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1292 | | bit_stmts bit_stmt;
|
| 1293 |
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1294 | bit_stmt: BIT_KEYWORD sep bit_arg_str bit_end
|
| 1295 | stmtsep { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1296 | if (yang_check_bit($3, actual, &cnt_val, actual_type)) {
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1297 | YYERROR;
|
| 1298 | }
|
| 1299 | actual = $3;
|
| 1300 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 1301 | size_arrays->node[size_arrays->size-1].bit++; /* count of bit*/
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1302 | }
|
| 1303 | }
|
| 1304 |
|
| 1305 | bit_arg_str: identifier_arg_str { if (read_all) {
|
| 1306 | $$ = actual;
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1307 | if (!(actual = yang_read_bit(trg, actual, s))) {
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1308 | YYERROR;
|
| 1309 | }
|
| 1310 | s = NULL;
|
| 1311 | actual_type = 0;
|
| 1312 | }
|
| 1313 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1314 |
|
| 1315 | bit_end: ';'
|
Pavol Vican | 7a92f53 | 2016-03-10 10:12:03 +0100 | [diff] [blame] | 1316 | | '{' stmtsep
|
| 1317 | bit_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1318 | '}'
|
| 1319 | ;
|
| 1320 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1321 | bit_opt_stmt: @EMPTYDIR@
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1322 | | bit_opt_stmt position_stmt { /* actual_type - it is used to check position of bit statement*/
|
| 1323 | if (read_all) {
|
| 1324 | if (actual_type) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1325 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "position", "bit");
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1326 | YYERROR;
|
| 1327 | }
|
| 1328 | actual_type = 1;
|
| 1329 | }
|
| 1330 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1331 | | bit_opt_stmt status_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1332 | if (yang_check_flags(&((struct lys_type_bit *)actual)->flags, LYS_STATUS_MASK, "status", "bit", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1333 | YYERROR;
|
| 1334 | }
|
| 1335 | }
|
| 1336 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1337 | | bit_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, "bit")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 1338 | YYERROR;
|
| 1339 | }
|
| 1340 | s = NULL;
|
| 1341 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1342 | | bit_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, "bit")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 1343 | YYERROR;
|
| 1344 | }
|
| 1345 | s = NULL;
|
| 1346 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1347 |
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1348 | position_stmt: POSITION_KEYWORD sep position_value_arg_str
|
| 1349 | stmtend { if (read_all) {
|
| 1350 | ((struct lys_type_bit *)actual)->pos = $3;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1351 |
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1352 | /* keep the highest position value for automatic increment */
|
| 1353 | if ($3 > cnt_val) {
|
| 1354 | cnt_val = $3;
|
| 1355 | }
|
| 1356 | cnt_val++;
|
| 1357 | }
|
| 1358 | }
|
| 1359 |
|
| 1360 | position_value_arg_str: non_negative_integer_value optsep { $$ = $1; }
|
| 1361 | | string_1 { /* convert it to uint32_t */
|
| 1362 | unsigned long val;
|
| 1363 | char *endptr;
|
| 1364 |
|
| 1365 | val = strtoul(s, &endptr, 10);
|
| 1366 | if (val > UINT32_MAX || s[0] == '-' || *endptr) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1367 | LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "position");
|
Pavol Vican | 9887c68 | 2016-02-29 11:32:01 +0100 | [diff] [blame] | 1368 | free(s);
|
| 1369 | YYERROR;
|
| 1370 | }
|
| 1371 | free(s);
|
| 1372 | s = NULL;
|
| 1373 | $$ = (uint32_t) val;
|
| 1374 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1375 |
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1376 | error_message_stmt: ERROR_MESSAGE_KEYWORD sep string stmtend;
|
| 1377 |
|
| 1378 | error_app_tag_stmt: ERROR_APP_TAG_KEYWORD sep string stmtend;
|
| 1379 |
|
| 1380 | units_stmt: UNITS_KEYWORD sep string stmtend;
|
| 1381 |
|
| 1382 | default_stmt: DEFAULT_KEYWORD sep string stmtend;
|
| 1383 |
|
Pavol Vican | 12f53c3 | 2016-02-11 11:40:00 +0100 | [diff] [blame] | 1384 | grouping_stmt: GROUPING_KEYWORD sep identifier_arg_str { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 1385 | if (!(actual = yang_read_node(trg,actual,s,LYS_GROUPING,sizeof(struct lys_node_grp)))) {YYERROR;}
|
Pavol Vican | 12f53c3 | 2016-02-11 11:40:00 +0100 | [diff] [blame] | 1386 | s=NULL;
|
Pavol Vican | 12f53c3 | 2016-02-11 11:40:00 +0100 | [diff] [blame] | 1387 | }
|
| 1388 | }
|
| 1389 | grouping_end;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1390 |
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 1391 | grouping_end: ';'
|
Pavol Vican | 12f53c3 | 2016-02-11 11:40:00 +0100 | [diff] [blame] | 1392 | | '{' stmtsep
|
| 1393 | grouping_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1394 | '}'
|
| 1395 | ;
|
| 1396 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1397 | grouping_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | 12f53c3 | 2016-02-11 11:40:00 +0100 | [diff] [blame] | 1398 | $$.grouping = actual;
|
| 1399 | actual_type = GROUPING_KEYWORD;
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1400 | if (size_arrays->node[size_arrays->next].tpdf) {
|
| 1401 | $$.grouping->tpdf = calloc(size_arrays->node[size_arrays->next].tpdf, sizeof *$$.grouping->tpdf);
|
| 1402 | if (!$$.grouping->tpdf) {
|
| 1403 | LOGMEM;
|
| 1404 | YYERROR;
|
| 1405 | }
|
Pavol Vican | 12f53c3 | 2016-02-11 11:40:00 +0100 | [diff] [blame] | 1406 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1407 | store_flags((struct lys_node *)$$.grouping, size_arrays->node[size_arrays->next].flags, 0);
|
Pavol Vican | 12f53c3 | 2016-02-11 11:40:00 +0100 | [diff] [blame] | 1408 | size_arrays->next++;
|
| 1409 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 1410 | $$.index = size_arrays->size;
|
| 1411 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 1412 | LOGMEM;
|
| 1413 | YYERROR;
|
| 1414 | }
|
Pavol Vican | 12f53c3 | 2016-02-11 11:40:00 +0100 | [diff] [blame] | 1415 | }
|
| 1416 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1417 | | grouping_opt_stmt status_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1418 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "grouping", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1419 | YYERROR;
|
| 1420 | }
|
| 1421 | }
|
| 1422 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1423 | | grouping_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.grouping, s, "grouping")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 1424 | YYERROR;
|
| 1425 | }
|
| 1426 | s = NULL;
|
| 1427 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1428 | | grouping_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.grouping, s, "grouping")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 1429 | YYERROR;
|
| 1430 | }
|
| 1431 | s = NULL;
|
| 1432 | }
|
Pavol Vican | 21238f5 | 2016-03-01 12:39:52 +0100 | [diff] [blame] | 1433 | | grouping_opt_stmt grouping_stmt stmtsep { actual = $1.grouping; actual_type = GROUPING_KEYWORD; }
|
| 1434 | | grouping_opt_stmt typedef_stmt stmtsep { if (read_all) {
|
| 1435 | actual = $1.grouping;
|
| 1436 | actual_type = GROUPING_KEYWORD;
|
| 1437 | } else {
|
| 1438 | size_arrays->node[$1.index].tpdf++;
|
| 1439 | }
|
| 1440 | }
|
Pavol Vican | 12f53c3 | 2016-02-11 11:40:00 +0100 | [diff] [blame] | 1441 | | grouping_opt_stmt data_def_stmt stmtsep { actual = $1.grouping; actual_type = GROUPING_KEYWORD; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1442 | ;
|
| 1443 |
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1444 | data_def_stmt: container_stmt
|
| 1445 | | leaf_stmt
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1446 | | leaf_list_stmt
|
| 1447 | | list_stmt
|
| 1448 | | choice_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1449 | | anyxml_stmt
|
| 1450 | | uses_stmt
|
| 1451 | ;
|
| 1452 |
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 1453 | container_stmt: CONTAINER_KEYWORD sep identifier_arg_str { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 1454 | if (!(actual = yang_read_node(trg,actual,s,LYS_CONTAINER,sizeof(struct lys_node_container)))) {YYERROR;}
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 1455 | data_node = actual;
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 1456 | s=NULL;
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 1457 | }
|
| 1458 | }
|
| 1459 | container_end ;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1460 |
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 1461 | container_end: ';'
|
Pavol Vican | 7c8ae12 | 2016-02-10 11:01:50 +0100 | [diff] [blame] | 1462 | | '{' stmtsep
|
| 1463 | container_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1464 | '}'
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1465 | ;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1466 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1467 | container_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 1468 | $$.container = actual;
|
| 1469 | actual_type = CONTAINER_KEYWORD;
|
Pavol Vican | 535d50e | 2016-03-01 13:05:33 +0100 | [diff] [blame] | 1470 | if (size_arrays->node[size_arrays->next].if_features) {
|
| 1471 | $$.container->features = calloc(size_arrays->node[size_arrays->next].if_features, sizeof *$$.container->features);
|
| 1472 | if (!$$.container->features) {
|
| 1473 | LOGMEM;
|
| 1474 | YYERROR;
|
| 1475 | }
|
| 1476 | }
|
| 1477 | if (size_arrays->node[size_arrays->next].must) {
|
| 1478 | $$.container->must = calloc(size_arrays->node[size_arrays->next].must, sizeof *$$.container->must);
|
| 1479 | if (!$$.container->must) {
|
| 1480 | LOGMEM;
|
| 1481 | YYERROR;
|
| 1482 | }
|
| 1483 | }
|
| 1484 | if (size_arrays->node[size_arrays->next].tpdf) {
|
| 1485 | $$.container->tpdf = calloc(size_arrays->node[size_arrays->next].tpdf, sizeof *$$.container->tpdf);
|
| 1486 | if (!$$.container->tpdf) {
|
| 1487 | LOGMEM;
|
| 1488 | YYERROR;
|
| 1489 | }
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 1490 | }
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 1491 | store_flags((struct lys_node *)$$.container, size_arrays->node[size_arrays->next].flags, config_inherit);
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 1492 | size_arrays->next++;
|
| 1493 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 1494 | $$.index = size_arrays->size;
|
| 1495 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 1496 | LOGMEM;
|
| 1497 | YYERROR;
|
| 1498 | }
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 1499 | }
|
| 1500 | }
|
Pavol Vican | 235dbd4 | 2016-02-10 10:34:19 +0100 | [diff] [blame] | 1501 | | container_opt_stmt when_stmt { actual = $1.container; actual_type = CONTAINER_KEYWORD; }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 1502 | stmtsep
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 1503 | | container_opt_stmt if_feature_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1504 | if (yang_read_if_feature(trg, $1.container, s, unres, CONTAINER_KEYWORD)) {YYERROR;}
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 1505 | s=NULL;
|
| 1506 | } else {
|
| 1507 | size_arrays->node[$1.index].if_features++;
|
| 1508 | }
|
| 1509 | }
|
| 1510 | | container_opt_stmt must_stmt { if (read_all) {
|
| 1511 | actual = $1.container;
|
| 1512 | actual_type = CONTAINER_KEYWORD;
|
| 1513 | } else {
|
| 1514 | size_arrays->node[$1.index].must++;
|
| 1515 | }
|
| 1516 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 1517 | stmtsep
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1518 | | container_opt_stmt presence_stmt { if (read_all && yang_read_presence(trg, $1.container, s)) {YYERROR;} s=NULL; }
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 1519 | | container_opt_stmt config_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1520 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_CONFIG_MASK, "config", "container", $2)) {
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 1521 | YYERROR;
|
| 1522 | }
|
| 1523 | }
|
| 1524 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1525 | | container_opt_stmt status_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1526 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "container", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1527 | YYERROR;
|
| 1528 | }
|
| 1529 | }
|
| 1530 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1531 | | container_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.container, s, "container")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 1532 | YYERROR;
|
| 1533 | }
|
| 1534 | s = NULL;
|
| 1535 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1536 | | container_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.container, s, "container")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 1537 | YYERROR;
|
| 1538 | }
|
| 1539 | s = NULL;
|
| 1540 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 1541 | | container_opt_stmt grouping_stmt { actual = $1.container;
|
| 1542 | actual_type = CONTAINER_KEYWORD;
|
| 1543 | data_node = actual;
|
| 1544 | }
|
| 1545 | stmtsep
|
| 1546 | | container_opt_stmt typedef_stmt { if (read_all) {
|
Pavol Vican | 535d50e | 2016-03-01 13:05:33 +0100 | [diff] [blame] | 1547 | actual = $1.container;
|
| 1548 | actual_type = CONTAINER_KEYWORD;
|
| 1549 | } else {
|
| 1550 | size_arrays->node[$1.index].tpdf++;
|
| 1551 | }
|
| 1552 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 1553 | stmtsep
|
| 1554 | | container_opt_stmt data_def_stmt { actual = $1.container;
|
| 1555 | actual_type = CONTAINER_KEYWORD;
|
| 1556 | data_node = actual;
|
| 1557 | }
|
| 1558 | stmtsep
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1559 | ;
|
| 1560 |
|
Pavol Vican | 096c6db | 2016-02-11 15:08:10 +0100 | [diff] [blame] | 1561 | leaf_stmt: LEAF_KEYWORD sep identifier_arg_str { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 1562 | if (!(actual = yang_read_node(trg,actual,s,LYS_LEAF,sizeof(struct lys_node_leaf)))) {YYERROR;}
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 1563 | data_node = actual;
|
Pavol Vican | 096c6db | 2016-02-11 15:08:10 +0100 | [diff] [blame] | 1564 | s=NULL;
|
Pavol Vican | 096c6db | 2016-02-11 15:08:10 +0100 | [diff] [blame] | 1565 | }
|
| 1566 | }
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 1567 | '{' stmtsep
|
Pavol Vican | 6295f12 | 2016-02-26 12:53:33 +0100 | [diff] [blame] | 1568 | leaf_opt_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1569 | if (!($7.node.flag & LYS_TYPE_DEF)) {
|
| 1570 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_LYS, $7.node.ptr_leaf, "type", "leaf");
|
Pavol Vican | 6295f12 | 2016-02-26 12:53:33 +0100 | [diff] [blame] | 1571 | YYERROR;
|
| 1572 | } else {
|
Pavol Vican | 7cbc3e7 | 2016-04-07 15:22:03 +0200 | [diff] [blame] | 1573 | if (unres_schema_add_node(trg, unres, &$7.node.ptr_leaf->type, UNRES_TYPE_DER,(struct lys_node *) $7.node.ptr_leaf->parent)) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1574 | $7.node.ptr_leaf->type.der = NULL;
|
Pavol Vican | 6295f12 | 2016-02-26 12:53:33 +0100 | [diff] [blame] | 1575 | YYERROR;
|
| 1576 | }
|
| 1577 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1578 | if ($7.node.ptr_leaf->dflt) {
|
| 1579 | if ($7.node.ptr_leaf->flags & LYS_MAND_TRUE) {
|
| 1580 | /* RFC 6020, 7.6.4 - default statement must not with mandatory true */
|
Pavol Vican | fdf81c4 | 2016-04-05 15:55:31 +0200 | [diff] [blame] | 1581 | LOGVAL(LYE_INCHILDSTMT, LY_VLOG_LYS, $7.node.ptr_leaf, "mandatory", "leaf");
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1582 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "The \"mandatory\" statement is forbidden on leaf with \"default\".");
|
| 1583 | YYERROR;
|
| 1584 | }
|
| 1585 | if (unres_schema_add_str(trg, unres, &$7.node.ptr_leaf->type, UNRES_TYPE_DFLT, $7.node.ptr_leaf->dflt) == -1) {
|
| 1586 | YYERROR;
|
| 1587 | }
|
Pavol Vican | 096c6db | 2016-02-11 15:08:10 +0100 | [diff] [blame] | 1588 | }
|
| 1589 | }
|
Pavol Vican | 096c6db | 2016-02-11 15:08:10 +0100 | [diff] [blame] | 1590 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1591 | '}' ;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1592 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1593 | leaf_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1594 | $$.node.ptr_leaf = actual;
|
| 1595 | $$.node.flag = 0;
|
| 1596 | actual_type = LEAF_KEYWORD;
|
| 1597 | if (size_arrays->node[size_arrays->next].if_features) {
|
| 1598 | $$.node.ptr_leaf->features = calloc(size_arrays->node[size_arrays->next].if_features, sizeof *$$.node.ptr_leaf->features);
|
| 1599 | if (!$$.node.ptr_leaf->features) {
|
| 1600 | LOGMEM;
|
| 1601 | YYERROR;
|
| 1602 | }
|
| 1603 | }
|
| 1604 | if (size_arrays->node[size_arrays->next].must) {
|
| 1605 | $$.node.ptr_leaf->must = calloc(size_arrays->node[size_arrays->next].must, sizeof *$$.node.ptr_leaf->must);
|
| 1606 | if (!$$.node.ptr_leaf->must) {
|
| 1607 | LOGMEM;
|
| 1608 | YYERROR;
|
| 1609 | }
|
| 1610 | }
|
| 1611 | store_flags((struct lys_node *)$$.node.ptr_leaf, size_arrays->node[size_arrays->next].flags, config_inherit);
|
| 1612 | size_arrays->next++;
|
| 1613 | } else {
|
| 1614 | $$.index = size_arrays->size;
|
| 1615 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 1616 | LOGMEM;
|
| 1617 | YYERROR;
|
| 1618 | }
|
| 1619 | }
|
Pavol Vican | 096c6db | 2016-02-11 15:08:10 +0100 | [diff] [blame] | 1620 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1621 | | leaf_opt_stmt when_stmt { actual = $1.node.ptr_leaf; actual_type = LEAF_KEYWORD; }
|
| 1622 | stmtsep
|
| 1623 | | leaf_opt_stmt if_feature_stmt { if (read_all) {
|
| 1624 | if (yang_read_if_feature(trg, $1.node.ptr_leaf, s, unres, LEAF_KEYWORD)) {YYERROR;}
|
| 1625 | s=NULL;
|
| 1626 | } else {
|
| 1627 | size_arrays->node[$1.index].if_features++;
|
| 1628 | }
|
Pavol Vican | 096c6db | 2016-02-11 15:08:10 +0100 | [diff] [blame] | 1629 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1630 | | leaf_opt_stmt { if (read_all && ($1.node.flag & LYS_TYPE_DEF)) {
|
| 1631 | LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_leaf, "type", "leaf");
|
| 1632 | YYERROR;
|
| 1633 | }
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 1634 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1635 | type_stmt { if (read_all) {
|
| 1636 | actual = $1.node.ptr_leaf;
|
| 1637 | actual_type = LEAF_KEYWORD;
|
| 1638 | $1.node.flag |= LYS_TYPE_DEF;
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 1639 | }
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 1640 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1641 | stmtsep { $$ = $1;}
|
| 1642 | | leaf_opt_stmt units_stmt { if (read_all && yang_read_units(trg, $1.node.ptr_leaf, s, LEAF_KEYWORD)) {YYERROR;} s = NULL; }
|
| 1643 | | leaf_opt_stmt must_stmt { if (read_all) {
|
| 1644 | actual = $1.node.ptr_leaf;
|
| 1645 | actual_type = LEAF_KEYWORD;
|
| 1646 | } else {
|
| 1647 | size_arrays->node[$1.index].must++;
|
| 1648 | }
|
Pavol Vican | 096c6db | 2016-02-11 15:08:10 +0100 | [diff] [blame] | 1649 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1650 | stmtsep
|
| 1651 | | leaf_opt_stmt default_stmt { if (read_all && yang_read_default(trg, $1.node.ptr_leaf, s, LEAF_KEYWORD)) {YYERROR;}
|
| 1652 | s = NULL;
|
| 1653 | }
|
| 1654 | | leaf_opt_stmt config_read_stmt { if (!read_all) {
|
| 1655 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_CONFIG_MASK, "config", "leaf", $2)) {
|
| 1656 | YYERROR;
|
| 1657 | }
|
| 1658 | }
|
| 1659 | }
|
| 1660 | | leaf_opt_stmt mandatory_read_stmt { if (!read_all) {
|
| 1661 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_MAND_MASK, "mandatory", "leaf", $2)) {
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 1662 | YYERROR;
|
| 1663 | }
|
| 1664 | }
|
| 1665 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1666 | | leaf_opt_stmt status_read_stmt { if (!read_all) {
|
| 1667 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "leaf", $2)) {
|
| 1668 | YYERROR;
|
| 1669 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1670 | }
|
| 1671 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1672 | | leaf_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.node.ptr_leaf, s, "leaf")) {
|
| 1673 | YYERROR;
|
| 1674 | }
|
| 1675 | s = NULL;
|
| 1676 | }
|
| 1677 | | leaf_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.node.ptr_leaf, s, "leaf")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 1678 | YYERROR;
|
| 1679 | }
|
| 1680 | s = NULL;
|
| 1681 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1682 |
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1683 | leaf_list_stmt: LEAF_LIST_KEYWORD sep identifier_arg_str { if (read_all) {
|
| 1684 | if (!(actual = yang_read_node(trg,actual,s,LYS_LEAFLIST,sizeof(struct lys_node_leaflist)))) {YYERROR;}
|
| 1685 | data_node = actual;
|
| 1686 | s=NULL;
|
| 1687 | }
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1688 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1689 | '{' stmtsep
|
| 1690 | leaf_list_opt_stmt { if (read_all) {
|
| 1691 | if ($7.node.ptr_leaflist->flags & LYS_CONFIG_R) {
|
| 1692 | /* RFC 6020, 7.7.5 - ignore ordering when the list represents state data
|
| 1693 | * ignore oredering MASK - 0x7F
|
| 1694 | */
|
| 1695 | $7.node.ptr_leaflist->flags &= 0x7F;
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1696 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1697 | if ($7.node.ptr_leaflist->max && $7.node.ptr_leaflist->min > $7.node.ptr_leaflist->max) {
|
| 1698 | LOGVAL(LYE_SPEC, LY_VLOG_LYS, $7.node.ptr_leaflist, "\"min-elements\" is bigger than \"max-elements\".");
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1699 | YYERROR;
|
| 1700 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1701 | if (!($7.node.flag & LYS_TYPE_DEF)) {
|
| 1702 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_LYS, $7.node.ptr_leaflist, "type", "leaf-list");
|
Pavol Vican | a55992a | 2016-03-01 13:37:17 +0100 | [diff] [blame] | 1703 | YYERROR;
|
| 1704 | } else {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1705 | if (unres_schema_add_node(trg, unres, &$7.node.ptr_leaflist->type, UNRES_TYPE_DER,
|
Pavol Vican | 7cbc3e7 | 2016-04-07 15:22:03 +0200 | [diff] [blame] | 1706 | (struct lys_node *) $7.node.ptr_leaflist->parent)) {
|
Pavol Vican | a55992a | 2016-03-01 13:37:17 +0100 | [diff] [blame] | 1707 | YYERROR;
|
| 1708 | }
|
| 1709 | }
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1710 | }
|
| 1711 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1712 | '}' ;
|
| 1713 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1714 | leaf_list_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1715 | $$.node.ptr_leaflist = actual;
|
| 1716 | $$.node.flag = 0;
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1717 | actual_type = LEAF_LIST_KEYWORD;
|
Pavol Vican | a55992a | 2016-03-01 13:37:17 +0100 | [diff] [blame] | 1718 | if (size_arrays->node[size_arrays->next].if_features) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1719 | $$.node.ptr_leaflist->features = calloc(size_arrays->node[size_arrays->next].if_features, sizeof *$$.node.ptr_leaflist->features);
|
| 1720 | if (!$$.node.ptr_leaflist->features) {
|
Pavol Vican | a55992a | 2016-03-01 13:37:17 +0100 | [diff] [blame] | 1721 | LOGMEM;
|
| 1722 | YYERROR;
|
| 1723 | }
|
| 1724 | }
|
| 1725 | if (size_arrays->node[size_arrays->next].must) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1726 | $$.node.ptr_leaflist->must = calloc(size_arrays->node[size_arrays->next].must, sizeof *$$.node.ptr_leaflist->must);
|
| 1727 | if (!$$.node.ptr_leaflist->must) {
|
Pavol Vican | a55992a | 2016-03-01 13:37:17 +0100 | [diff] [blame] | 1728 | LOGMEM;
|
| 1729 | YYERROR;
|
| 1730 | }
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1731 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1732 | store_flags((struct lys_node *)$$.node.ptr_leaflist, size_arrays->node[size_arrays->next].flags, config_inherit);
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1733 | size_arrays->next++;
|
| 1734 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 1735 | $$.index = size_arrays->size;
|
| 1736 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 1737 | LOGMEM;
|
| 1738 | YYERROR;
|
| 1739 | }
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1740 | }
|
| 1741 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1742 | | leaf_list_opt_stmt when_stmt { actual = $1.node.ptr_leaflist; actual_type = LEAF_LIST_KEYWORD; }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 1743 | stmtsep
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1744 | | leaf_list_opt_stmt if_feature_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1745 | if (yang_read_if_feature(trg, $1.node.ptr_leaflist, s, unres, LEAF_LIST_KEYWORD)) {YYERROR;}
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1746 | s=NULL;
|
| 1747 | } else {
|
| 1748 | size_arrays->node[$1.index].if_features++;
|
| 1749 | }
|
| 1750 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1751 | | leaf_list_opt_stmt { if (read_all && ($1.node.flag & LYS_TYPE_DEF)) {
|
| 1752 | LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_leaflist, "type", "leaf-list");
|
Pavol Vican | a55992a | 2016-03-01 13:37:17 +0100 | [diff] [blame] | 1753 | YYERROR;
|
| 1754 | }
|
| 1755 | }
|
| 1756 | type_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1757 | actual = $1.node.ptr_leaflist;
|
Pavol Vican | a55992a | 2016-03-01 13:37:17 +0100 | [diff] [blame] | 1758 | actual_type = LEAF_LIST_KEYWORD;
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1759 | $1.node.flag |= LYS_TYPE_DEF;
|
Pavol Vican | a55992a | 2016-03-01 13:37:17 +0100 | [diff] [blame] | 1760 | }
|
| 1761 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 1762 | stmtsep { $$ = $1; }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1763 | | leaf_list_opt_stmt units_stmt { if (read_all && yang_read_units(trg, $1.node.ptr_leaflist, s, LEAF_LIST_KEYWORD)) {YYERROR;} s = NULL; }
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1764 | | leaf_list_opt_stmt must_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1765 | actual = $1.node.ptr_leaflist;
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1766 | actual_type = LEAF_LIST_KEYWORD;
|
| 1767 | } else {
|
| 1768 | size_arrays->node[$1.index].must++;
|
| 1769 | }
|
| 1770 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 1771 | stmtsep
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 1772 | | leaf_list_opt_stmt config_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1773 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_CONFIG_MASK, "config", "leaf-list", $2)) {
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 1774 | YYERROR;
|
| 1775 | }
|
| 1776 | }
|
| 1777 | }
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1778 | | leaf_list_opt_stmt min_elements_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1779 | if ($1.node.flag & LYS_MIN_ELEMENTS) {
|
| 1780 | LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_leaflist, "min-elements", "leaf-list");
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1781 | YYERROR;
|
| 1782 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1783 | $1.node.ptr_leaflist->min = $2;
|
| 1784 | $1.node.flag |= LYS_MIN_ELEMENTS;
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1785 | $$ = $1;
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1786 | if ($1.node.ptr_leaflist->max && ($1.node.ptr_leaflist->min > $1.node.ptr_leaflist->max)) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1787 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid value \"%d\" of \"%s\".", $2, "min-elements");
|
| 1788 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "\"min-elements\" is bigger than \"max-elements\".");
|
Pavol Vican | 723de60 | 2016-03-21 15:13:20 +0100 | [diff] [blame] | 1789 | }
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1790 | }
|
| 1791 | }
|
| 1792 | | leaf_list_opt_stmt max_elements_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1793 | if ($1.node.flag & LYS_MAX_ELEMENTS) {
|
| 1794 | LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_leaflist, "max-elements", "leaf-list");
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1795 | YYERROR;
|
| 1796 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1797 | $1.node.ptr_leaflist->max = $2;
|
| 1798 | $1.node.flag |= LYS_MAX_ELEMENTS;
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1799 | $$ = $1;
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1800 | if ($1.node.ptr_leaflist->min > $1.node.ptr_leaflist->max) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1801 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid value \"%d\" of \"%s\".", $2, "max-elements");
|
| 1802 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "\"max-elements\" is smaller than \"min-elements\".");
|
Pavol Vican | 723de60 | 2016-03-21 15:13:20 +0100 | [diff] [blame] | 1803 | }
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1804 | }
|
| 1805 | }
|
| 1806 | | leaf_list_opt_stmt ordered_by_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1807 | if ($1.node.flag & LYS_ORDERED_MASK) {
|
| 1808 | LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_leaflist, "ordered by", "leaf-list");
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1809 | YYERROR;
|
| 1810 | }
|
| 1811 | if ($2 & LYS_USERORDERED) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1812 | $1.node.ptr_leaflist->flags |= LYS_USERORDERED;
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1813 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1814 | $1.node.flag |= $2;
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 1815 | $$ = $1;
|
| 1816 | }
|
| 1817 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1818 | | leaf_list_opt_stmt status_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1819 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "leaf-list", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1820 | YYERROR;
|
| 1821 | }
|
| 1822 | }
|
| 1823 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1824 | | leaf_list_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.node.ptr_leaflist, s, "leaf-list")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 1825 | YYERROR;
|
| 1826 | }
|
| 1827 | s = NULL;
|
| 1828 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1829 | | leaf_list_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.node.ptr_leaflist, s, "leaf-list")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 1830 | YYERROR;
|
| 1831 | }
|
| 1832 | s = NULL;
|
| 1833 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1834 |
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1835 | list_stmt: LIST_KEYWORD sep identifier_arg_str { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 1836 | if (!(actual = yang_read_node(trg,actual,s,LYS_LIST,sizeof(struct lys_node_list)))) {YYERROR;}
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 1837 | data_node = actual;
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1838 | s=NULL;
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1839 | }
|
| 1840 | }
|
| 1841 | '{' stmtsep
|
| 1842 | list_opt_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1843 | if ($7.node.ptr_list->flags & LYS_CONFIG_R) {
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1844 | /* RFC 6020, 7.7.5 - ignore ordering when the list represents state data
|
| 1845 | * ignore oredering MASK - 0x7F
|
| 1846 | */
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1847 | $7.node.ptr_list->flags &= 0x7F;
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1848 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1849 | if (($7.node.ptr_list->flags & LYS_CONFIG_W) && !$7.node.ptr_list->keys) {
|
| 1850 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_LYS, $7.node.ptr_list, "key", "list");
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1851 | YYERROR;
|
| 1852 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1853 | if ($7.node.ptr_list->keys && yang_read_key(trg, $7.node.ptr_list, unres)) {
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1854 | YYERROR;
|
| 1855 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1856 | if (!($7.node.flag & LYS_DATADEF)) {
|
| 1857 | LOGVAL(LYE_SPEC, LY_VLOG_LYS, $7.node.ptr_list, "data-def statement missing.");
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1858 | YYERROR;
|
| 1859 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1860 | if (yang_read_unique(trg, $7.node.ptr_list, unres)) {
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1861 | YYERROR;
|
| 1862 | }
|
| 1863 | }
|
| 1864 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 1865 | '}' ;
|
| 1866 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 1867 | list_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1868 | $$.node.ptr_list = actual;
|
| 1869 | $$.node.flag = 0;
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1870 | if (size_arrays->node[size_arrays->next].if_features) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1871 | $$.node.ptr_list->features = calloc(size_arrays->node[size_arrays->next].if_features, sizeof *$$.node.ptr_list->features);
|
| 1872 | if (!$$.node.ptr_list->features) {
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1873 | LOGMEM;
|
| 1874 | YYERROR;
|
| 1875 | }
|
| 1876 | }
|
| 1877 | if (size_arrays->node[size_arrays->next].must) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1878 | $$.node.ptr_list->must = calloc(size_arrays->node[size_arrays->next].must, sizeof *$$.node.ptr_list->must);
|
| 1879 | if (!$$.node.ptr_list->must) {
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1880 | LOGMEM;
|
| 1881 | YYERROR;
|
| 1882 | }
|
| 1883 | }
|
| 1884 | if (size_arrays->node[size_arrays->next].tpdf) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1885 | $$.node.ptr_list->tpdf = calloc(size_arrays->node[size_arrays->next].tpdf, sizeof *$$.node.ptr_list->tpdf);
|
| 1886 | if (!$$.node.ptr_list->tpdf) {
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1887 | LOGMEM;
|
| 1888 | YYERROR;
|
| 1889 | }
|
| 1890 | }
|
| 1891 | if (size_arrays->node[size_arrays->next].unique) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1892 | $$.node.ptr_list->unique = calloc(size_arrays->node[size_arrays->next].unique, sizeof *$$.node.ptr_list->unique);
|
| 1893 | if (!$$.node.ptr_list->unique) {
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1894 | LOGMEM;
|
| 1895 | YYERROR;
|
| 1896 | }
|
| 1897 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1898 | store_flags((struct lys_node *)$$.node.ptr_list, size_arrays->node[size_arrays->next].flags, config_inherit);
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1899 | size_arrays->next++;
|
| 1900 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 1901 | $$.index = size_arrays->size;
|
| 1902 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 1903 | LOGMEM;
|
| 1904 | YYERROR;
|
| 1905 | }
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1906 | }
|
| 1907 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1908 | | list_opt_stmt when_stmt { actual = $1.node.ptr_list; actual_type = LIST_KEYWORD; }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 1909 | stmtsep
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1910 | | list_opt_stmt if_feature_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1911 | if (yang_read_if_feature(trg, $1.node.ptr_list, s, unres, LIST_KEYWORD)) {YYERROR;}
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1912 | s=NULL;
|
| 1913 | } else {
|
| 1914 | size_arrays->node[$1.index].if_features++;
|
| 1915 | }
|
| 1916 | }
|
| 1917 | | list_opt_stmt must_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1918 | actual = $1.node.ptr_list;
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1919 | actual_type = LIST_KEYWORD;
|
| 1920 | } else {
|
| 1921 | size_arrays->node[$1.index].must++;
|
| 1922 | }
|
| 1923 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 1924 | stmtsep
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1925 | | list_opt_stmt key_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1926 | if ($1.node.ptr_list->keys) {
|
| 1927 | LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_list, "key", "list");
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1928 | YYERROR;
|
| 1929 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1930 | $1.node.ptr_list->keys = (struct lys_node_leaf **)s;
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1931 | $$ = $1;
|
| 1932 | s=NULL;
|
| 1933 | }
|
| 1934 | }
|
| 1935 | | list_opt_stmt unique_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1936 | $1.node.ptr_list->unique[$1.node.ptr_list->unique_size++].expr = (const char **)s;
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1937 | $$ = $1;
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1938 | s = NULL;
|
| 1939 | } else {
|
| 1940 | size_arrays->node[$1.index].unique++;
|
| 1941 | }
|
| 1942 | }
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 1943 | | list_opt_stmt config_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1944 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_CONFIG_MASK, "config", "list", $2)) {
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 1945 | YYERROR;
|
| 1946 | }
|
| 1947 | }
|
| 1948 | }
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1949 | | list_opt_stmt min_elements_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1950 | if ($1.node.flag & LYS_MIN_ELEMENTS) {
|
| 1951 | LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_list, "min-elements", "list");
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1952 | YYERROR;
|
| 1953 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1954 | $1.node.ptr_list->min = $2;
|
| 1955 | $1.node.flag |= LYS_MIN_ELEMENTS;
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1956 | $$ = $1;
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1957 | if ($1.node.ptr_list->max && ($1.node.ptr_list->min > $1.node.ptr_list->max)) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1958 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid value \"%d\" of \"%s\".", $2, "min-elements");
|
| 1959 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "\"min-elements\" is bigger than \"max-elements\".");
|
Pavol Vican | 723de60 | 2016-03-21 15:13:20 +0100 | [diff] [blame] | 1960 | }
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1961 | }
|
| 1962 | }
|
| 1963 | | list_opt_stmt max_elements_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1964 | if ($1.node.flag & LYS_MAX_ELEMENTS) {
|
| 1965 | LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_list, "max-elements", "list");
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1966 | YYERROR;
|
| 1967 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1968 | $1.node.ptr_list->max = $2;
|
| 1969 | $1.node.flag |= LYS_MAX_ELEMENTS;
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1970 | $$ = $1;
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1971 | if ($1.node.ptr_list->min > $1.node.ptr_list->max) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1972 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid value \"%d\" of \"%s\".", $2, "min-elements");
|
| 1973 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "\"max-elements\" is smaller than \"min-elements\".");
|
Pavol Vican | 723de60 | 2016-03-21 15:13:20 +0100 | [diff] [blame] | 1974 | }
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1975 | }
|
| 1976 | }
|
| 1977 | | list_opt_stmt ordered_by_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1978 | if ($1.node.flag & LYS_ORDERED_MASK) {
|
| 1979 | LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_list, "ordered by", "list");
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1980 | YYERROR;
|
| 1981 | }
|
| 1982 | if ($2 & LYS_USERORDERED) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1983 | $1.node.ptr_list->flags |= LYS_USERORDERED;
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1984 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1985 | $1.node.flag |= $2;
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 1986 | $$ = $1;
|
| 1987 | }
|
| 1988 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1989 | | list_opt_stmt status_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 1990 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "list", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 1991 | YYERROR;
|
| 1992 | }
|
| 1993 | }
|
| 1994 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 1995 | | list_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.node.ptr_list, s, "list")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 1996 | YYERROR;
|
| 1997 | }
|
| 1998 | s = NULL;
|
| 1999 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2000 | | list_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.node.ptr_list, s, "list")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 2001 | YYERROR;
|
| 2002 | }
|
| 2003 | s = NULL;
|
| 2004 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2005 | | list_opt_stmt typedef_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2006 | actual = $1.node.ptr_list;
|
Pavol Vican | 09f04b8 | 2016-03-01 14:02:28 +0100 | [diff] [blame] | 2007 | actual_type = LIST_KEYWORD;
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 2008 | } else {
|
| 2009 | size_arrays->node[$1.index].tpdf++;
|
| 2010 | }
|
| 2011 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2012 | stmtsep
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2013 | | list_opt_stmt grouping_stmt { actual = $1.node.ptr_list;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2014 | actual_type = LIST_KEYWORD;
|
| 2015 | data_node = actual;
|
| 2016 | }
|
| 2017 | stmtsep
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2018 | | list_opt_stmt data_def_stmt { actual = $1.node.ptr_list;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2019 | actual_type = LIST_KEYWORD;
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2020 | $1.node.flag |= LYS_DATADEF;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2021 | data_node = actual;
|
| 2022 | }
|
| 2023 | stmtsep { $$ = $1; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2024 | ;
|
| 2025 |
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 2026 | choice_stmt: CHOICE_KEYWORD sep identifier_arg_str { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 2027 | if (!(actual = yang_read_node(trg,actual,s,LYS_CHOICE,sizeof(struct lys_node_choice)))) {YYERROR;}
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2028 | data_node = actual;
|
| 2029 | if (data_node->parent && (data_node->parent->nodetype == LYS_GROUPING)) {
|
| 2030 | data_node = NULL;
|
| 2031 | }
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 2032 | s=NULL;
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 2033 | }
|
| 2034 | }
|
| 2035 | choice_end;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2036 |
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 2037 | choice_end: ';'
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 2038 | | '{' stmtsep
|
| 2039 | choice_opt_stmt { if (read_all) {
|
| 2040 | if ($3.choice.s && ($3.choice.ptr_choice->flags & LYS_MAND_TRUE)) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2041 | LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "default", "choice");
|
| 2042 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "The \"default\" statement is forbidden on choices with \"mandatory\".");
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 2043 | YYERROR;
|
| 2044 | }
|
| 2045 | /* link default with the case */
|
| 2046 | if ($3.choice.s) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2047 | if (unres_schema_add_str(trg, unres, $3.choice.ptr_choice, UNRES_CHOICE_DFLT, $3.choice.s) == -1) {
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 2048 | YYERROR;
|
| 2049 | }
|
| 2050 | free($3.choice.s);
|
| 2051 | }
|
| 2052 | }
|
| 2053 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2054 | '}' ;
|
| 2055 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 2056 | choice_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 2057 | $$.choice.ptr_choice = actual;
|
| 2058 | $$.choice.s = NULL;
|
Pavol Vican | 339d4ad | 2016-02-12 12:49:22 +0100 | [diff] [blame] | 2059 | actual_type = CHOICE_KEYWORD;
|
Pavol Vican | fb8ded6 | 2016-03-21 09:43:58 +0100 | [diff] [blame] | 2060 | if (size_arrays->node[size_arrays->next].if_features) {
|
| 2061 | $$.choice.ptr_choice->features = calloc(size_arrays->node[size_arrays->next].if_features, sizeof *$$.choice.ptr_choice->features);
|
| 2062 | if (!$$.choice.ptr_choice->features) {
|
| 2063 | LOGMEM;
|
| 2064 | YYERROR;
|
| 2065 | }
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 2066 | }
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2067 | store_flags((struct lys_node *)$$.choice.ptr_choice, size_arrays->node[size_arrays->next].flags, config_inherit);
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 2068 | size_arrays->next++;
|
| 2069 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 2070 | $$.index = size_arrays->size;
|
| 2071 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 2072 | LOGMEM;
|
| 2073 | YYERROR;
|
| 2074 | }
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 2075 | }
|
| 2076 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2077 | | choice_opt_stmt when_stmt { actual = $1.choice.ptr_choice; actual_type = CHOICE_KEYWORD; }
|
| 2078 | stmtsep { $$ = $1; }
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 2079 | | choice_opt_stmt if_feature_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2080 | if (yang_read_if_feature(trg, $1.choice.ptr_choice,s, unres, CHOICE_KEYWORD)) {
|
Pavol Vican | 3bd188d | 2016-03-01 15:18:46 +0100 | [diff] [blame] | 2081 | if ($1.choice.s) {
|
| 2082 | free($1.choice.s);
|
| 2083 | }
|
| 2084 | YYERROR;
|
| 2085 | }
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 2086 | s=NULL;
|
| 2087 | $$ = $1;
|
| 2088 | } else {
|
| 2089 | size_arrays->node[$1.index].if_features++;
|
| 2090 | }
|
| 2091 | }
|
| 2092 | | choice_opt_stmt default_stmt { if (read_all) {
|
| 2093 | if ($1.choice.s) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2094 | LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.choice.ptr_choice, "default", "choice");
|
Pavol Vican | 1f06ba8 | 2016-02-10 17:39:50 +0100 | [diff] [blame] | 2095 | free($1.choice.s);
|
| 2096 | free(s);
|
| 2097 | YYERROR;
|
| 2098 | }
|
| 2099 | $1.choice.s = s;
|
| 2100 | s = NULL;
|
| 2101 | $$ = $1;
|
| 2102 | }
|
| 2103 | }
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2104 | | choice_opt_stmt config_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2105 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_CONFIG_MASK, "config", "choice", $2)) {
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2106 | YYERROR;
|
| 2107 | }
|
| 2108 | } else {
|
| 2109 | $$ = $1;
|
| 2110 | }
|
| 2111 | }
|
Pavol Vican | e408402 | 2016-03-19 13:12:52 +0100 | [diff] [blame] | 2112 | | choice_opt_stmt mandatory_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2113 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_MAND_MASK, "mandatory", "choice", $2)) {
|
Pavol Vican | e408402 | 2016-03-19 13:12:52 +0100 | [diff] [blame] | 2114 | YYERROR;
|
Pavol Vican | 3bd188d | 2016-03-01 15:18:46 +0100 | [diff] [blame] | 2115 | }
|
Pavol Vican | e408402 | 2016-03-19 13:12:52 +0100 | [diff] [blame] | 2116 | } else {
|
Pavol Vican | 3bd188d | 2016-03-01 15:18:46 +0100 | [diff] [blame] | 2117 | $$ = $1;
|
| 2118 | }
|
| 2119 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2120 | | choice_opt_stmt status_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2121 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "choice", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2122 | YYERROR;
|
| 2123 | }
|
| 2124 | } else {
|
| 2125 | $$ = $1;
|
| 2126 | }
|
| 2127 | }
|
Pavol Vican | 3928461 | 2016-03-20 14:44:24 +0100 | [diff] [blame] | 2128 | | choice_opt_stmt description_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2129 | if (yang_read_description(trg, $1.choice.ptr_choice, s, "choice")) {
|
Pavol Vican | 3bd188d | 2016-03-01 15:18:46 +0100 | [diff] [blame] | 2130 | free($1.choice.s);
|
| 2131 | YYERROR;
|
| 2132 | }
|
| 2133 | s = NULL;
|
| 2134 | $$ = $1;
|
| 2135 | }
|
| 2136 | }
|
Pavol Vican | 3928461 | 2016-03-20 14:44:24 +0100 | [diff] [blame] | 2137 | | choice_opt_stmt reference_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2138 | if (yang_read_reference(trg, $1.choice.ptr_choice, s, "choice")) {
|
Pavol Vican | 3bd188d | 2016-03-01 15:18:46 +0100 | [diff] [blame] | 2139 | free($1.choice.s);
|
| 2140 | YYERROR;
|
| 2141 | }
|
| 2142 | s = NULL;
|
| 2143 | $$ = $1;
|
| 2144 | }
|
| 2145 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2146 | | choice_opt_stmt short_case_case_stmt { actual = $1.choice.ptr_choice;
|
| 2147 | actual_type = CHOICE_KEYWORD;
|
| 2148 | data_node = actual;
|
| 2149 | if (read_all && data_node->parent && (data_node->parent->nodetype == LYS_GROUPING)) {
|
| 2150 | data_node = NULL;
|
| 2151 | }
|
| 2152 | }
|
| 2153 | stmtsep { $$ = $1; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2154 | ;
|
| 2155 |
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2156 | short_case_case_stmt: short_case_stmt
|
| 2157 | | case_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2158 | ;
|
| 2159 |
|
| 2160 | short_case_stmt: container_stmt
|
| 2161 | | leaf_stmt
|
| 2162 | | leaf_list_stmt
|
| 2163 | | list_stmt
|
| 2164 | | anyxml_stmt
|
| 2165 | ;
|
| 2166 |
|
Pavol Vican | bd09813 | 2016-02-11 10:56:49 +0100 | [diff] [blame] | 2167 | case_stmt: CASE_KEYWORD sep identifier_arg_str { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 2168 | if (!(actual = yang_read_node(trg,actual,s,LYS_CASE,sizeof(struct lys_node_case)))) {YYERROR;}
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2169 | data_node = actual;
|
Pavol Vican | bd09813 | 2016-02-11 10:56:49 +0100 | [diff] [blame] | 2170 | s=NULL;
|
Pavol Vican | bd09813 | 2016-02-11 10:56:49 +0100 | [diff] [blame] | 2171 | }
|
| 2172 | }
|
| 2173 | case_end;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2174 |
|
| 2175 | case_end: ';'
|
Pavol Vican | bd09813 | 2016-02-11 10:56:49 +0100 | [diff] [blame] | 2176 | | '{' stmtsep
|
| 2177 | case_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2178 | '}' ;
|
| 2179 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 2180 | case_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | bd09813 | 2016-02-11 10:56:49 +0100 | [diff] [blame] | 2181 | $$.cs = actual;
|
| 2182 | actual_type = CASE_KEYWORD;
|
Pavol Vican | fb8ded6 | 2016-03-21 09:43:58 +0100 | [diff] [blame] | 2183 | if (size_arrays->node[size_arrays->next].if_features) {
|
| 2184 | $$.cs->features = calloc(size_arrays->node[size_arrays->next].if_features, sizeof *$$.cs->features);
|
| 2185 | if (!$$.cs->features) {
|
| 2186 | LOGMEM;
|
| 2187 | YYERROR;
|
| 2188 | }
|
Pavol Vican | bd09813 | 2016-02-11 10:56:49 +0100 | [diff] [blame] | 2189 | }
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2190 | store_flags((struct lys_node *)$$.cs, size_arrays->node[size_arrays->next].flags, 1);
|
Pavol Vican | bd09813 | 2016-02-11 10:56:49 +0100 | [diff] [blame] | 2191 | size_arrays->next++;
|
| 2192 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 2193 | $$.index = size_arrays->size;
|
| 2194 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 2195 | LOGMEM;
|
| 2196 | YYERROR;
|
| 2197 | }
|
Pavol Vican | bd09813 | 2016-02-11 10:56:49 +0100 | [diff] [blame] | 2198 | }
|
| 2199 | }
|
| 2200 | | case_opt_stmt when_stmt { actual = $1.cs; actual_type = CASE_KEYWORD; }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2201 | stmtsep
|
Pavol Vican | bd09813 | 2016-02-11 10:56:49 +0100 | [diff] [blame] | 2202 | | case_opt_stmt if_feature_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2203 | if (yang_read_if_feature(trg, $1.cs, s, unres, CASE_KEYWORD)) {YYERROR;}
|
Pavol Vican | bd09813 | 2016-02-11 10:56:49 +0100 | [diff] [blame] | 2204 | s=NULL;
|
| 2205 | } else {
|
| 2206 | size_arrays->node[$1.index].if_features++;
|
| 2207 | }
|
| 2208 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2209 | | case_opt_stmt status_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2210 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "case", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2211 | YYERROR;
|
| 2212 | }
|
| 2213 | }
|
| 2214 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2215 | | case_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.cs, s, "case")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 2216 | YYERROR;
|
| 2217 | }
|
| 2218 | s = NULL;
|
| 2219 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2220 | | case_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.cs, s, "case")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 2221 | YYERROR;
|
| 2222 | }
|
| 2223 | s = NULL;
|
| 2224 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2225 | | case_opt_stmt data_def_stmt { actual = $1.cs;
|
| 2226 | actual_type = CASE_KEYWORD;
|
| 2227 | data_node = actual;
|
| 2228 | }
|
| 2229 | stmtsep
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2230 | ;
|
| 2231 |
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 2232 | anyxml_stmt: ANYXML_KEYWORD sep identifier_arg_str { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 2233 | if (!(actual = yang_read_node(trg,actual,s,LYS_ANYXML,sizeof(struct lys_node_anyxml)))) {YYERROR;}
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2234 | data_node = actual;
|
| 2235 | if (data_node->parent && (data_node->parent->nodetype == LYS_GROUPING)) {
|
| 2236 | data_node = NULL;
|
| 2237 | }
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 2238 | s=NULL;
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 2239 | }
|
| 2240 | }
|
| 2241 | anyxml_end;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2242 |
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 2243 | anyxml_end: ';'
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 2244 | | '{' stmtsep
|
| 2245 | anyxml_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2246 | '}' ;
|
| 2247 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 2248 | anyxml_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 2249 | $$.anyxml = actual;
|
| 2250 | actual_type = ANYXML_KEYWORD;
|
Pavol Vican | fb8ded6 | 2016-03-21 09:43:58 +0100 | [diff] [blame] | 2251 | if (size_arrays->node[size_arrays->next].if_features) {
|
| 2252 | $$.anyxml->features = calloc(size_arrays->node[size_arrays->next].if_features, sizeof *$$.anyxml->features);
|
| 2253 | if (!$$.anyxml->features) {
|
| 2254 | LOGMEM;
|
| 2255 | YYERROR;
|
| 2256 | }
|
| 2257 | }
|
| 2258 | if (size_arrays->node[size_arrays->next].must) {
|
| 2259 | $$.anyxml->must = calloc(size_arrays->node[size_arrays->next].must, sizeof *$$.anyxml->must);
|
| 2260 | if (!$$.anyxml->features || !$$.anyxml->must) {
|
| 2261 | LOGMEM;
|
| 2262 | YYERROR;
|
| 2263 | }
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 2264 | }
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2265 | store_flags((struct lys_node *)$$.anyxml, size_arrays->node[size_arrays->next].flags, config_inherit);
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 2266 | size_arrays->next++;
|
| 2267 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 2268 | $$.index = size_arrays->size;
|
| 2269 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 2270 | LOGMEM;
|
| 2271 | YYERROR;
|
| 2272 | }
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 2273 | }
|
| 2274 | }
|
| 2275 | | anyxml_opt_stmt when_stmt { actual = $1.anyxml; actual_type = ANYXML_KEYWORD; }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2276 | stmtsep
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 2277 | | anyxml_opt_stmt if_feature_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2278 | if (yang_read_if_feature(trg, $1.anyxml, s, unres, ANYXML_KEYWORD)) {YYERROR;}
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 2279 | s=NULL;
|
| 2280 | } else {
|
| 2281 | size_arrays->node[$1.index].if_features++;
|
| 2282 | }
|
| 2283 | }
|
| 2284 | | anyxml_opt_stmt must_stmt { if (read_all) {
|
| 2285 | actual = $1.anyxml;
|
| 2286 | actual_type = ANYXML_KEYWORD;
|
| 2287 | } else {
|
| 2288 | size_arrays->node[$1.index].must++;
|
| 2289 | }
|
| 2290 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2291 | stmtsep
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2292 | | anyxml_opt_stmt config_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2293 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_CONFIG_MASK, "config", "anyxml", $2)) {
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2294 | YYERROR;
|
| 2295 | }
|
| 2296 | }
|
| 2297 | }
|
Pavol Vican | e408402 | 2016-03-19 13:12:52 +0100 | [diff] [blame] | 2298 | | anyxml_opt_stmt mandatory_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2299 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_MAND_MASK, "mandatory", "anyxml", $2)) {
|
Pavol Vican | e408402 | 2016-03-19 13:12:52 +0100 | [diff] [blame] | 2300 | YYERROR;
|
| 2301 | }
|
| 2302 | }
|
| 2303 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2304 | | anyxml_opt_stmt status_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2305 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "anyxml", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2306 | YYERROR;
|
| 2307 | }
|
| 2308 | }
|
| 2309 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2310 | | anyxml_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.anyxml, s, "anyxml")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 2311 | YYERROR;
|
| 2312 | }
|
| 2313 | s = NULL;
|
| 2314 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2315 | | anyxml_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.anyxml, s, "anyxml")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 2316 | YYERROR;
|
| 2317 | }
|
| 2318 | s = NULL;
|
| 2319 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2320 |
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2321 | uses_stmt: USES_KEYWORD sep identifier_ref_arg_str { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 2322 | if (!(actual = yang_read_node(trg,actual,s,LYS_USES,sizeof(struct lys_node_uses)))) {YYERROR;}
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2323 | data_node = actual;
|
| 2324 | if (data_node->parent && (data_node->parent->nodetype == LYS_GROUPING)) {
|
| 2325 | data_node = NULL;
|
| 2326 | }
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2327 | s=NULL;
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2328 | }
|
| 2329 | }
|
| 2330 | uses_end { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2331 | if (unres_schema_add_node(trg, unres, actual, UNRES_USES, NULL) == -1) {
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2332 | YYERROR;
|
| 2333 | }
|
| 2334 | }
|
| 2335 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2336 |
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 2337 | uses_end: ';'
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2338 | | '{' stmtsep
|
| 2339 | uses_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2340 | '}' ;
|
| 2341 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 2342 | uses_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2343 | $$.uses.ptr_uses = actual;
|
| 2344 | $$.uses.config_inherit = config_inherit;
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2345 | actual_type = USES_KEYWORD;
|
| 2346 | if (size_arrays->node[size_arrays->next].if_features) {
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2347 | $$.uses.ptr_uses->features = calloc(size_arrays->node[size_arrays->next].if_features, sizeof *$$.uses.ptr_uses->features);
|
| 2348 | if (!$$.uses.ptr_uses->features) {
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2349 | LOGMEM;
|
| 2350 | YYERROR;
|
| 2351 | }
|
| 2352 | }
|
| 2353 | if (size_arrays->node[size_arrays->next].refine) {
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2354 | $$.uses.ptr_uses->refine = calloc(size_arrays->node[size_arrays->next].refine, sizeof *$$.uses.ptr_uses->refine);
|
| 2355 | if (!$$.uses.ptr_uses->refine) {
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2356 | LOGMEM;
|
| 2357 | YYERROR;
|
| 2358 | }
|
| 2359 | }
|
| 2360 | if (size_arrays->node[size_arrays->next].augment) {
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2361 | $$.uses.ptr_uses->augment = calloc(size_arrays->node[size_arrays->next].augment, sizeof *$$.uses.ptr_uses->augment);
|
| 2362 | if (!$$.uses.ptr_uses->augment) {
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2363 | LOGMEM;
|
| 2364 | YYERROR;
|
| 2365 | }
|
| 2366 | }
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2367 | store_flags((struct lys_node *)$$.uses.ptr_uses, size_arrays->node[size_arrays->next].flags, config_inherit);
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2368 | size_arrays->next++;
|
| 2369 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 2370 | $$.index = size_arrays->size;
|
| 2371 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 2372 | LOGMEM;
|
| 2373 | YYERROR;
|
| 2374 | }
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2375 | }
|
| 2376 | }
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2377 | | uses_opt_stmt when_stmt { actual = $1.uses.ptr_uses; actual_type = USES_KEYWORD; }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2378 | stmtsep
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2379 | | uses_opt_stmt if_feature_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2380 | if (yang_read_if_feature(trg, $1.uses.ptr_uses, s, unres, USES_KEYWORD)) {YYERROR;}
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2381 | s=NULL;
|
| 2382 | } else {
|
| 2383 | size_arrays->node[$1.index].if_features++;
|
| 2384 | }
|
| 2385 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2386 | | uses_opt_stmt status_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2387 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "uses", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2388 | YYERROR;
|
| 2389 | }
|
| 2390 | }
|
| 2391 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2392 | | uses_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.uses.ptr_uses, s, "uses")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 2393 | YYERROR;
|
| 2394 | }
|
| 2395 | s = NULL;
|
| 2396 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2397 | | uses_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.uses.ptr_uses, s, "uses")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 2398 | YYERROR;
|
| 2399 | }
|
| 2400 | s = NULL;
|
| 2401 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2402 | | uses_opt_stmt refine_stmt { if (read_all) {
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2403 | actual = $1.uses.ptr_uses;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2404 | actual_type = USES_KEYWORD;
|
| 2405 | } else {
|
| 2406 | size_arrays->node[$1.index].refine++;
|
| 2407 | }
|
| 2408 | }
|
| 2409 | stmtsep
|
| 2410 | | uses_opt_stmt uses_augment_stmt { if (read_all) {
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2411 | actual = $1.uses.ptr_uses;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2412 | actual_type = USES_KEYWORD;
|
| 2413 | data_node = actual;
|
| 2414 | if (data_node->parent && (data_node->parent->nodetype == LYS_GROUPING)) {
|
| 2415 | data_node = NULL;
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2416 | }
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2417 | config_inherit = $1.uses.config_inherit;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2418 | } else {
|
| 2419 | size_arrays->node[$1.index].augment++;
|
Pavol Vican | 14b1856 | 2016-03-01 16:04:29 +0100 | [diff] [blame] | 2420 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2421 | }
|
| 2422 | stmtsep
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2423 | ;
|
| 2424 |
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2425 | refine_stmt: REFINE_KEYWORD sep refine_arg_str { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2426 | if (!(actual = yang_read_refine(trg, actual, s))) {
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2427 | YYERROR;
|
| 2428 | }
|
| 2429 | s = NULL;
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2430 | }
|
| 2431 | }
|
| 2432 | refine_end;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2433 |
|
| 2434 | refine_end: ';'
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2435 | | '{' stmtsep
|
| 2436 | refine_body_opt_stmts
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2437 | '}' ;
|
| 2438 |
|
| 2439 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 2440 | refine_arg_str: descendant_schema_nodeid optsep
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2441 | | string_1
|
| 2442 | ;
|
| 2443 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 2444 | refine_body_opt_stmts: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2445 | $$.refine = actual;
|
| 2446 | actual_type = REFINE_KEYWORD;
|
| 2447 | if (size_arrays->node[size_arrays->next].must) {
|
| 2448 | $$.refine->must = calloc(size_arrays->node[size_arrays->next].must, sizeof *$$.refine->must);
|
| 2449 | if (!$$.refine->must) {
|
| 2450 | LOGMEM;
|
| 2451 | YYERROR;
|
| 2452 | }
|
| 2453 | $$.refine->target_type = LYS_LIST | LYS_LEAFLIST | LYS_CONTAINER | LYS_ANYXML;
|
| 2454 | }
|
| 2455 | size_arrays->next++;
|
| 2456 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 2457 | $$.index = size_arrays->size;
|
| 2458 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 2459 | LOGMEM;
|
| 2460 | YYERROR;
|
| 2461 | }
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2462 | }
|
| 2463 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2464 | | refine_body_opt_stmts must_stmt stmtsep { if (read_all) {
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2465 | actual = $1.refine;
|
| 2466 | actual_type = REFINE_KEYWORD;
|
| 2467 | } else {
|
| 2468 | size_arrays->node[$1.index].must++;
|
| 2469 | }
|
| 2470 | }
|
| 2471 | | refine_body_opt_stmts presence_stmt { if (read_all) {
|
| 2472 | if ($1.refine->target_type) {
|
| 2473 | if ($1.refine->target_type & LYS_CONTAINER) {
|
| 2474 | if ($1.refine->mod.presence) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2475 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "presence", "refine");
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2476 | free(s);
|
| 2477 | YYERROR;
|
| 2478 | }
|
| 2479 | $1.refine->target_type = LYS_CONTAINER;
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 2480 | $1.refine->mod.presence = lydict_insert_zc(trg->ctx, s);
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2481 | } else {
|
| 2482 | free(s);
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2483 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "presence", "refine");
|
| 2484 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2485 | YYERROR;
|
| 2486 | }
|
| 2487 | } else {
|
| 2488 | $1.refine->target_type = LYS_CONTAINER;
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 2489 | $1.refine->mod.presence = lydict_insert_zc(trg->ctx, s);
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2490 | }
|
| 2491 | s = NULL;
|
| 2492 | $$ = $1;
|
| 2493 | }
|
| 2494 | }
|
| 2495 | | refine_body_opt_stmts default_stmt { if (read_all) {
|
| 2496 | if ($1.refine->target_type) {
|
| 2497 | if ($1.refine->target_type & (LYS_LEAF | LYS_CHOICE)) {
|
| 2498 | $1.refine->target_type &= (LYS_LEAF | LYS_CHOICE);
|
| 2499 | if ($1.refine->mod.dflt) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2500 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "default", "refine");
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2501 | free(s);
|
| 2502 | YYERROR;
|
| 2503 | }
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 2504 | $1.refine->mod.dflt = lydict_insert_zc(trg->ctx, s);
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2505 | } else {
|
| 2506 | free(s);
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2507 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "default", "refine");
|
| 2508 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2509 | YYERROR;
|
| 2510 | }
|
| 2511 | } else {
|
| 2512 | $1.refine->target_type = LYS_LEAF | LYS_CHOICE;
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 2513 | $1.refine->mod.dflt = lydict_insert_zc(trg->ctx, s);
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2514 | }
|
| 2515 | s = NULL;
|
| 2516 | $$ = $1;
|
| 2517 | }
|
| 2518 | }
|
| 2519 | | refine_body_opt_stmts config_stmt { if (read_all) {
|
| 2520 | if ($1.refine->target_type) {
|
| 2521 | if ($1.refine->target_type & (LYS_LEAF | LYS_CHOICE | LYS_LIST | LYS_CONTAINER | LYS_LEAFLIST)) {
|
| 2522 | $1.refine->target_type &= (LYS_LEAF | LYS_CHOICE | LYS_LIST | LYS_CONTAINER | LYS_LEAFLIST);
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2523 | if (yang_check_flags(&$1.refine->flags, LYS_CONFIG_MASK, "config", "refine", $2)) {
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2524 | YYERROR;
|
| 2525 | }
|
| 2526 | } else {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2527 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "config", "refine");
|
| 2528 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2529 | YYERROR;
|
| 2530 | }
|
| 2531 | } else {
|
| 2532 | $1.refine->target_type = LYS_LEAF | LYS_CHOICE | LYS_LIST | LYS_CONTAINER | LYS_LEAFLIST;
|
| 2533 | $1.refine->flags |= $2;
|
| 2534 | }
|
| 2535 | $$ = $1;
|
| 2536 | }
|
| 2537 | }
|
| 2538 | | refine_body_opt_stmts mandatory_stmt { if (read_all) {
|
| 2539 | if ($1.refine->target_type) {
|
| 2540 | if ($1.refine->target_type & (LYS_LEAF | LYS_CHOICE | LYS_ANYXML)) {
|
| 2541 | $1.refine->target_type &= (LYS_LEAF | LYS_CHOICE | LYS_ANYXML);
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2542 | if (yang_check_flags(&$1.refine->flags, LYS_MAND_MASK, "mandatory", "refine", $2)) {
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2543 | YYERROR;
|
| 2544 | }
|
| 2545 | } else {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2546 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "mandatory", "refine");
|
| 2547 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2548 | YYERROR;
|
| 2549 | }
|
| 2550 | } else {
|
| 2551 | $1.refine->target_type = LYS_LEAF | LYS_CHOICE | LYS_ANYXML;
|
| 2552 | $1.refine->flags |= $2;
|
| 2553 | }
|
| 2554 | $$ = $1;
|
| 2555 | }
|
| 2556 | }
|
| 2557 | | refine_body_opt_stmts min_elements_stmt { if (read_all) {
|
| 2558 | if ($1.refine->target_type) {
|
| 2559 | if ($1.refine->target_type & (LYS_LIST | LYS_LEAFLIST)) {
|
| 2560 | $1.refine->target_type &= (LYS_LIST | LYS_LEAFLIST);
|
| 2561 | /* magic - bit 3 in flags means min set */
|
| 2562 | if ($1.refine->flags & 0x04) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2563 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "min-elements", "refine");
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2564 | YYERROR;
|
| 2565 | }
|
| 2566 | $1.refine->flags |= 0x04;
|
| 2567 | $1.refine->mod.list.min = $2;
|
| 2568 | } else {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2569 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "min-elements", "refine");
|
| 2570 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2571 | YYERROR;
|
| 2572 | }
|
| 2573 | } else {
|
| 2574 | $1.refine->target_type = LYS_LIST | LYS_LEAFLIST;
|
| 2575 | /* magic - bit 3 in flags means min set */
|
| 2576 | $1.refine->flags |= 0x04;
|
| 2577 | $1.refine->mod.list.min = $2;
|
| 2578 | }
|
| 2579 | $$ = $1;
|
| 2580 | }
|
| 2581 | }
|
| 2582 | | refine_body_opt_stmts max_elements_stmt { if (read_all) {
|
| 2583 | if ($1.refine->target_type) {
|
| 2584 | if ($1.refine->target_type & (LYS_LIST | LYS_LEAFLIST)) {
|
| 2585 | $1.refine->target_type &= (LYS_LIST | LYS_LEAFLIST);
|
| 2586 | /* magic - bit 4 in flags means max set */
|
| 2587 | if ($1.refine->flags & 0x08) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2588 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "max-elements", "refine");
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2589 | YYERROR;
|
| 2590 | }
|
| 2591 | $1.refine->flags |= 0x08;
|
| 2592 | $1.refine->mod.list.max = $2;
|
| 2593 | } else {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2594 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "max-elements", "refine");
|
| 2595 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
|
Pavol Vican | 1003ead | 2016-03-02 12:24:52 +0100 | [diff] [blame] | 2596 | YYERROR;
|
| 2597 | }
|
| 2598 | } else {
|
| 2599 | $1.refine->target_type = LYS_LIST | LYS_LEAFLIST;
|
| 2600 | /* magic - bit 4 in flags means max set */
|
| 2601 | $1.refine->flags |= 0x08;
|
| 2602 | $1.refine->mod.list.max = $2;
|
| 2603 | }
|
| 2604 | $$ = $1;
|
| 2605 | }
|
| 2606 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2607 | | refine_body_opt_stmts description_stmt { if (read_all && yang_read_description(trg, $1.refine, s, "refine")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 2608 | YYERROR;
|
| 2609 | }
|
| 2610 | s = NULL;
|
| 2611 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2612 | | refine_body_opt_stmts reference_stmt { if (read_all && yang_read_reference(trg, $1.refine, s, "refine")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 2613 | YYERROR;
|
| 2614 | }
|
| 2615 | s = NULL;
|
| 2616 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2617 |
|
Pavol Vican | 92fa0dc | 2016-03-02 14:20:39 +0100 | [diff] [blame] | 2618 | uses_augment_stmt: AUGMENT_KEYWORD sep uses_augment_arg_str { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2619 | if (!(actual = yang_read_augment(trg, actual, s))) {
|
Pavol Vican | 92fa0dc | 2016-03-02 14:20:39 +0100 | [diff] [blame] | 2620 | YYERROR;
|
| 2621 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2622 | data_node = actual;
|
Pavol Vican | 92fa0dc | 2016-03-02 14:20:39 +0100 | [diff] [blame] | 2623 | s = NULL;
|
Pavol Vican | 92fa0dc | 2016-03-02 14:20:39 +0100 | [diff] [blame] | 2624 | }
|
| 2625 | }
|
| 2626 | '{' stmtsep
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2627 | augment_opt_stmt { if (read_all && !($7.node.flag & LYS_DATADEF)){
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2628 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "data-def or case", "uses/augment");
|
Pavol Vican | 92fa0dc | 2016-03-02 14:20:39 +0100 | [diff] [blame] | 2629 | YYERROR;
|
| 2630 | }
|
| 2631 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2632 | '}' ;
|
| 2633 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 2634 | uses_augment_arg_str: descendant_schema_nodeid optsep
|
| 2635 | | string_1
|
| 2636 | ;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2637 |
|
Pavol Vican | 9f98997 | 2016-03-02 14:44:11 +0100 | [diff] [blame] | 2638 | augment_stmt: AUGMENT_KEYWORD sep augment_arg_str { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2639 | if (!(actual = yang_read_augment(trg, NULL, s))) {
|
Pavol Vican | 9f98997 | 2016-03-02 14:44:11 +0100 | [diff] [blame] | 2640 | YYERROR;
|
| 2641 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2642 | data_node = actual;
|
Pavol Vican | 9f98997 | 2016-03-02 14:44:11 +0100 | [diff] [blame] | 2643 | s = NULL;
|
Pavol Vican | 9f98997 | 2016-03-02 14:44:11 +0100 | [diff] [blame] | 2644 | }
|
| 2645 | }
|
| 2646 | '{' stmtsep
|
| 2647 | augment_opt_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2648 | if (!($7.node.flag & LYS_DATADEF)){
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2649 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "data-def or case", "augment");
|
Pavol Vican | 9f98997 | 2016-03-02 14:44:11 +0100 | [diff] [blame] | 2650 | YYERROR;
|
| 2651 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2652 | if (unres_schema_add_node(trg, unres, actual, UNRES_AUGMENT, NULL) == -1) {
|
Pavol Vican | 9f98997 | 2016-03-02 14:44:11 +0100 | [diff] [blame] | 2653 | YYERROR;
|
| 2654 | }
|
| 2655 | }
|
| 2656 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2657 | '}' ;
|
| 2658 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 2659 | augment_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2660 | $$.node.ptr_augment = actual;
|
| 2661 | $$.node.flag = 0;
|
Pavol Vican | 92fa0dc | 2016-03-02 14:20:39 +0100 | [diff] [blame] | 2662 | actual_type = AUGMENT_KEYWORD;
|
| 2663 | if (size_arrays->node[size_arrays->next].if_features) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2664 | $$.node.ptr_augment->features = calloc(size_arrays->node[size_arrays->next].if_features, sizeof *$$.node.ptr_augment->features);
|
| 2665 | if (!$$.node.ptr_augment->features) {
|
Pavol Vican | 92fa0dc | 2016-03-02 14:20:39 +0100 | [diff] [blame] | 2666 | LOGMEM;
|
| 2667 | YYERROR;
|
| 2668 | }
|
| 2669 | }
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 2670 | config_inherit = DISABLE_INHERIT;
|
Pavol Vican | 92fa0dc | 2016-03-02 14:20:39 +0100 | [diff] [blame] | 2671 | size_arrays->next++;
|
| 2672 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 2673 | $$.index = size_arrays->size;
|
| 2674 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 2675 | LOGMEM;
|
| 2676 | YYERROR;
|
| 2677 | }
|
Pavol Vican | 92fa0dc | 2016-03-02 14:20:39 +0100 | [diff] [blame] | 2678 | }
|
| 2679 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2680 | | augment_opt_stmt when_stmt { actual = $1.node.ptr_augment; actual_type = AUGMENT_KEYWORD; }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2681 | stmtsep
|
Pavol Vican | 92fa0dc | 2016-03-02 14:20:39 +0100 | [diff] [blame] | 2682 | | augment_opt_stmt if_feature_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2683 | if (yang_read_if_feature(trg, $1.node.ptr_augment, s, unres, AUGMENT_KEYWORD)) {YYERROR;}
|
Pavol Vican | 92fa0dc | 2016-03-02 14:20:39 +0100 | [diff] [blame] | 2684 | s=NULL;
|
| 2685 | } else {
|
| 2686 | size_arrays->node[$1.index].if_features++;
|
| 2687 | }
|
| 2688 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2689 | | augment_opt_stmt status_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2690 | if (yang_check_flags(&$1.node.ptr_augment->flags, LYS_STATUS_MASK, "status", "augment", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2691 | YYERROR;
|
| 2692 | }
|
| 2693 | }
|
| 2694 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2695 | | augment_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.node.ptr_augment, s, "augment")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 2696 | YYERROR;
|
| 2697 | }
|
| 2698 | s = NULL;
|
| 2699 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2700 | | augment_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.node.ptr_augment, s, "augment")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 2701 | YYERROR;
|
| 2702 | }
|
| 2703 | s = NULL;
|
| 2704 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2705 | | augment_opt_stmt data_def_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2706 | actual = $1.node.ptr_augment;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2707 | actual_type = AUGMENT_KEYWORD;
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2708 | $1.node.flag |= LYS_DATADEF;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2709 | data_node = actual;
|
| 2710 | }
|
| 2711 | }
|
| 2712 | stmtsep { $$ = $1; }
|
| 2713 | | augment_opt_stmt case_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2714 | actual = $1.node.ptr_augment;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2715 | actual_type = AUGMENT_KEYWORD;
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2716 | $1.node.flag |= LYS_DATADEF;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2717 | data_node = actual;
|
| 2718 | }
|
| 2719 | }
|
| 2720 | stmtsep { $$ = $1; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2721 | ;
|
| 2722 |
|
| 2723 | augment_arg_str: absolute_schema_nodeids optsep
|
| 2724 | | string_1
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 2725 | ;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2726 |
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2727 | rpc_stmt: RPC_KEYWORD sep identifier_arg_str { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 2728 | if (!(actual = yang_read_node(trg, NULL, s, LYS_RPC, sizeof(struct lys_node_rpc)))) {
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2729 | YYERROR;
|
| 2730 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2731 | data_node = actual;
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2732 | s = NULL;
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2733 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2734 | config_inherit = DISABLE_INHERIT;
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2735 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2736 | rpc_end { config_inherit = ENABLE_INHERIT; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2737 |
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 2738 | rpc_end: ';'
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2739 | | '{' stmtsep
|
| 2740 | rpc_opt_stmt
|
| 2741 | '}'
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2742 |
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2743 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 2744 | rpc_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2745 | $$.node.ptr_rpc = actual;
|
| 2746 | $$.node.flag = 0;
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2747 | actual_type = RPC_KEYWORD;
|
| 2748 | if (size_arrays->node[size_arrays->next].if_features) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2749 | $$.node.ptr_rpc->features = calloc(size_arrays->node[size_arrays->next].if_features, sizeof *$$.node.ptr_rpc->features);
|
| 2750 | if (!$$.node.ptr_rpc->features) {
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2751 | LOGMEM;
|
| 2752 | YYERROR;
|
| 2753 | }
|
| 2754 | }
|
| 2755 | if (size_arrays->node[size_arrays->next].tpdf) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2756 | $$.node.ptr_rpc->tpdf = calloc(size_arrays->node[size_arrays->next].tpdf, sizeof *$$.node.ptr_rpc->tpdf);
|
| 2757 | if (!$$.node.ptr_rpc->tpdf) {
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2758 | LOGMEM;
|
| 2759 | YYERROR;
|
| 2760 | }
|
| 2761 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2762 | store_flags((struct lys_node *)$$.node.ptr_rpc, size_arrays->node[size_arrays->next].flags, 0);
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2763 | size_arrays->next++;
|
| 2764 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 2765 | $$.index = size_arrays->size;
|
| 2766 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 2767 | LOGMEM;
|
| 2768 | YYERROR;
|
| 2769 | }
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2770 | }
|
| 2771 | }
|
| 2772 | | rpc_opt_stmt if_feature_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2773 | if (yang_read_if_feature(trg, $1.node.ptr_rpc, s, unres, RPC_KEYWORD)) {YYERROR;}
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2774 | s=NULL;
|
| 2775 | } else {
|
| 2776 | size_arrays->node[$1.index].if_features++;
|
| 2777 | }
|
| 2778 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2779 | | rpc_opt_stmt status_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2780 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "rpc", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2781 | YYERROR;
|
| 2782 | }
|
| 2783 | }
|
| 2784 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2785 | | rpc_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.node.ptr_rpc, s, "rpc")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 2786 | YYERROR;
|
| 2787 | }
|
| 2788 | s = NULL;
|
| 2789 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2790 | | rpc_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.node.ptr_rpc, s, "rpc")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 2791 | YYERROR;
|
| 2792 | }
|
| 2793 | s = NULL;
|
| 2794 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2795 | | rpc_opt_stmt typedef_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2796 | actual = $1.node.ptr_rpc;
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2797 | actual_type = RPC_KEYWORD;
|
| 2798 | } else {
|
| 2799 | size_arrays->node[$1.index].tpdf++;
|
| 2800 | }
|
| 2801 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2802 | stmtsep
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2803 | | rpc_opt_stmt grouping_stmt { actual = $1.node.ptr_rpc;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2804 | actual_type = RPC_KEYWORD;
|
| 2805 | data_node = actual;
|
| 2806 | }
|
| 2807 | stmtsep
|
Pavol Vican | 948aff8 | 2016-04-08 10:31:14 +0200 | [diff] [blame^] | 2808 | | rpc_opt_stmt input_stmt { if (read_all) {
|
| 2809 | if ($1.node.flag & LYS_RPC_INPUT) {
|
| 2810 | LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_rpc, "input", "rpc");
|
| 2811 | YYERROR;
|
| 2812 | }
|
| 2813 | $1.node.flag |= LYS_RPC_INPUT;
|
| 2814 | actual = $1.node.ptr_rpc;
|
| 2815 | actual_type = RPC_KEYWORD;
|
| 2816 | data_node = actual;
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2817 | }
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2818 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2819 | stmtsep { $$ = $1; }
|
Pavol Vican | 948aff8 | 2016-04-08 10:31:14 +0200 | [diff] [blame^] | 2820 | | rpc_opt_stmt output_stmt { if (read_all) {
|
| 2821 | if ($1.node.flag & LYS_RPC_OUTPUT) {
|
| 2822 | LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_rpc, "output", "rpc");
|
| 2823 | YYERROR;
|
| 2824 | }
|
| 2825 | $1.node.flag |= LYS_RPC_OUTPUT;
|
| 2826 | actual = $1.node.ptr_rpc;
|
| 2827 | actual_type = RPC_KEYWORD;
|
| 2828 | data_node = actual;
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2829 | }
|
Pavol Vican | 52ed67d | 2016-03-02 17:46:15 +0100 | [diff] [blame] | 2830 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2831 | stmtsep { $$ = $1; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2832 |
|
Pavol Vican | 531a913 | 2016-03-03 10:10:09 +0100 | [diff] [blame] | 2833 | input_stmt: INPUT_KEYWORD optsep { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 2834 | if (!(actual = yang_read_node(trg, actual, NULL, LYS_INPUT, sizeof(struct lys_node_rpc_inout)))) {
|
Pavol Vican | 531a913 | 2016-03-03 10:10:09 +0100 | [diff] [blame] | 2835 | YYERROR;
|
| 2836 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2837 | data_node = actual;
|
Pavol Vican | 531a913 | 2016-03-03 10:10:09 +0100 | [diff] [blame] | 2838 | }
|
| 2839 | }
|
| 2840 | '{' stmtsep
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2841 | input_output_opt_stmt { if (read_all && !($6.node.flag & LYS_DATADEF)) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2842 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, "data-def", "input");
|
Pavol Vican | 531a913 | 2016-03-03 10:10:09 +0100 | [diff] [blame] | 2843 | YYERROR;
|
| 2844 | }
|
| 2845 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2846 | '}'
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2847 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 2848 | input_output_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2849 | $$.node.ptr_inout = actual;
|
| 2850 | $$.node.flag = 0;
|
Pavol Vican | 531a913 | 2016-03-03 10:10:09 +0100 | [diff] [blame] | 2851 | actual_type = INPUT_KEYWORD;
|
| 2852 | if (size_arrays->node[size_arrays->next].tpdf) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2853 | $$.node.ptr_inout->tpdf = calloc(size_arrays->node[size_arrays->next].tpdf, sizeof *$$.node.ptr_inout->tpdf);
|
| 2854 | if (!$$.node.ptr_inout->tpdf) {
|
Pavol Vican | 531a913 | 2016-03-03 10:10:09 +0100 | [diff] [blame] | 2855 | LOGMEM;
|
| 2856 | YYERROR;
|
| 2857 | }
|
| 2858 | }
|
| 2859 | size_arrays->next++;
|
| 2860 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 2861 | $$.index = size_arrays->size;
|
| 2862 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 2863 | LOGMEM;
|
| 2864 | YYERROR;
|
| 2865 | }
|
Pavol Vican | 531a913 | 2016-03-03 10:10:09 +0100 | [diff] [blame] | 2866 | }
|
| 2867 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2868 | | input_output_opt_stmt typedef_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2869 | actual = $1.node.ptr_inout;
|
Pavol Vican | 531a913 | 2016-03-03 10:10:09 +0100 | [diff] [blame] | 2870 | actual_type = INPUT_KEYWORD;
|
| 2871 | } else {
|
| 2872 | size_arrays->node[$1.index].tpdf++;
|
| 2873 | }
|
| 2874 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2875 | stmtsep
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2876 | | input_output_opt_stmt grouping_stmt { actual = $1.node.ptr_inout;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2877 | actual_type = INPUT_KEYWORD;
|
| 2878 | data_node = actual;
|
| 2879 | }
|
| 2880 | stmtsep
|
| 2881 | | input_output_opt_stmt data_def_stmt { if (read_all) {
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2882 | actual = $1.node.ptr_inout;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2883 | actual_type = INPUT_KEYWORD;
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2884 | $1.node.flag |= LYS_DATADEF;
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2885 | data_node = actual;
|
| 2886 | }
|
| 2887 | }
|
| 2888 | stmtsep { $$ = $1; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2889 | ;
|
| 2890 |
|
Pavol Vican | 531a913 | 2016-03-03 10:10:09 +0100 | [diff] [blame] | 2891 | output_stmt: OUTPUT_KEYWORD optsep { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 2892 | if (!(actual = yang_read_node(trg, actual, NULL, LYS_OUTPUT, sizeof(struct lys_node_rpc_inout)))) {
|
Pavol Vican | 531a913 | 2016-03-03 10:10:09 +0100 | [diff] [blame] | 2893 | YYERROR;
|
| 2894 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2895 | data_node = actual;
|
Pavol Vican | 531a913 | 2016-03-03 10:10:09 +0100 | [diff] [blame] | 2896 | }
|
| 2897 | }
|
| 2898 | '{' stmtsep
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2899 | input_output_opt_stmt { if (read_all && !($6.node.flag & LYS_DATADEF)) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2900 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, "data-def", "output");
|
Pavol Vican | 531a913 | 2016-03-03 10:10:09 +0100 | [diff] [blame] | 2901 | YYERROR;
|
| 2902 | }
|
| 2903 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2904 | '}'
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2905 |
|
Pavol Vican | 41267fd | 2016-03-03 10:47:42 +0100 | [diff] [blame] | 2906 | notification_stmt: NOTIFICATION_KEYWORD sep identifier_arg_str { if (read_all) {
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 2907 | if (!(actual = yang_read_node(trg, NULL, s, LYS_NOTIF, sizeof(struct lys_node_notif)))) {
|
Pavol Vican | 41267fd | 2016-03-03 10:47:42 +0100 | [diff] [blame] | 2908 | YYERROR;
|
| 2909 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2910 | data_node = actual;
|
Pavol Vican | 41267fd | 2016-03-03 10:47:42 +0100 | [diff] [blame] | 2911 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2912 | config_inherit = DISABLE_INHERIT;
|
Pavol Vican | 41267fd | 2016-03-03 10:47:42 +0100 | [diff] [blame] | 2913 | }
|
Pavol Vican | d946c0d | 2016-03-23 12:53:08 +0100 | [diff] [blame] | 2914 | notification_end { config_inherit = ENABLE_INHERIT; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2915 |
|
Pavol Vican | 41267fd | 2016-03-03 10:47:42 +0100 | [diff] [blame] | 2916 | notification_end: ';' { if (read_all) {
|
| 2917 | size_arrays->next++;
|
| 2918 | }
|
| 2919 | }
|
| 2920 | | '{' stmtsep
|
| 2921 | notification_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2922 | '}' ;
|
| 2923 |
|
Pavol Vican | 41267fd | 2016-03-03 10:47:42 +0100 | [diff] [blame] | 2924 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 2925 | notification_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | 41267fd | 2016-03-03 10:47:42 +0100 | [diff] [blame] | 2926 | $$.notif = actual;
|
| 2927 | actual_type = NOTIFICATION_KEYWORD;
|
| 2928 | if (size_arrays->node[size_arrays->next].if_features) {
|
| 2929 | $$.notif->features = calloc(size_arrays->node[size_arrays->next].if_features, sizeof *$$.notif->features);
|
| 2930 | if (!$$.notif->features) {
|
| 2931 | LOGMEM;
|
| 2932 | YYERROR;
|
| 2933 | }
|
| 2934 | }
|
| 2935 | if (size_arrays->node[size_arrays->next].tpdf) {
|
| 2936 | $$.notif->tpdf = calloc(size_arrays->node[size_arrays->next].tpdf, sizeof *$$.notif->tpdf);
|
| 2937 | if (!$$.notif->tpdf) {
|
| 2938 | LOGMEM;
|
| 2939 | YYERROR;
|
| 2940 | }
|
| 2941 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2942 | store_flags((struct lys_node *)$$.notif, size_arrays->node[size_arrays->next].flags, 0);
|
Pavol Vican | 41267fd | 2016-03-03 10:47:42 +0100 | [diff] [blame] | 2943 | size_arrays->next++;
|
| 2944 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 2945 | $$.index = size_arrays->size;
|
| 2946 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 2947 | LOGMEM;
|
| 2948 | YYERROR;
|
| 2949 | }
|
Pavol Vican | 41267fd | 2016-03-03 10:47:42 +0100 | [diff] [blame] | 2950 | }
|
| 2951 | }
|
| 2952 | | notification_opt_stmt if_feature_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2953 | if (yang_read_if_feature(trg, $1.notif, s, unres, NOTIFICATION_KEYWORD)) {YYERROR;}
|
Pavol Vican | 41267fd | 2016-03-03 10:47:42 +0100 | [diff] [blame] | 2954 | s=NULL;
|
| 2955 | } else {
|
| 2956 | size_arrays->node[$1.index].if_features++;
|
| 2957 | }
|
| 2958 | }
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2959 | | notification_opt_stmt status_read_stmt { if (!read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2960 | if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "notification", $2)) {
|
Pavol Vican | 8658f4c | 2016-03-20 09:38:28 +0100 | [diff] [blame] | 2961 | YYERROR;
|
| 2962 | }
|
| 2963 | }
|
| 2964 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2965 | | notification_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.notif, s, "notification")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 2966 | YYERROR;
|
| 2967 | }
|
| 2968 | s = NULL;
|
| 2969 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2970 | | notification_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.notif, s, "notification")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 2971 | YYERROR;
|
| 2972 | }
|
| 2973 | s = NULL;
|
| 2974 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2975 | | notification_opt_stmt typedef_stmt { if (read_all) {
|
Pavol Vican | 41267fd | 2016-03-03 10:47:42 +0100 | [diff] [blame] | 2976 | actual = $1.notif;
|
| 2977 | actual_type = NOTIFICATION_KEYWORD;
|
| 2978 | } else {
|
| 2979 | size_arrays->node[$1.index].tpdf++;
|
| 2980 | }
|
| 2981 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 2982 | stmtsep
|
| 2983 | | notification_opt_stmt grouping_stmt { actual = $1.notif;
|
| 2984 | actual_type = NOTIFICATION_KEYWORD;
|
| 2985 | data_node = actual;
|
| 2986 | }
|
| 2987 | stmtsep
|
| 2988 | | notification_opt_stmt data_def_stmt { actual = $1.notif;
|
| 2989 | actual_type = NOTIFICATION_KEYWORD;
|
| 2990 | data_node = actual;
|
| 2991 | }
|
| 2992 | stmtsep
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 2993 | ;
|
| 2994 |
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 2995 | deviation_stmt: DEVIATION_KEYWORD sep deviation_arg_str { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 2996 | if (!(actual = yang_read_deviation(trg, s))) {
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 2997 | YYERROR;
|
| 2998 | }
|
| 2999 | s = NULL;
|
Pavol Vican | 22afbdd | 2016-03-09 11:10:26 +0100 | [diff] [blame] | 3000 | trg->deviation_size++;
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 3001 | }
|
| 3002 | }
|
| 3003 | '{' stmtsep
|
| 3004 | deviation_opt_stmt { if (read_all) {
|
| 3005 | if (actual_type == DEVIATION_KEYWORD) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3006 | LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "deviate", "deviation");
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 3007 | YYERROR;
|
| 3008 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3009 | if (yang_check_deviation(trg, actual, unres)) {
|
Pavol Vican | e92421d | 2016-03-08 10:12:33 +0100 | [diff] [blame] | 3010 | YYERROR;
|
| 3011 | }
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 3012 | free($7.deviation);
|
| 3013 | }
|
| 3014 | }
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3015 | '}'
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3016 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3017 | deviation_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 3018 | $$.deviation = actual;
|
| 3019 | actual_type = DEVIATION_KEYWORD;
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 3020 | if (size_arrays->node[size_arrays->next].deviate) {
|
| 3021 | $$.deviation->deviation->deviate = calloc(size_arrays->node[size_arrays->next].deviate, sizeof *$$.deviation->deviation->deviate);
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 3022 | if (!$$.deviation->deviation->deviate) {
|
| 3023 | LOGMEM;
|
| 3024 | YYERROR;
|
| 3025 | }
|
| 3026 | }
|
| 3027 | size_arrays->next++;
|
| 3028 | } else {
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 3029 | $$.index = size_arrays->size;
|
| 3030 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 3031 | LOGMEM;
|
| 3032 | YYERROR;
|
| 3033 | }
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 3034 | }
|
| 3035 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3036 | | deviation_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.deviation->deviation, s, "deviation")) {
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 3037 | free($1.deviation);
|
| 3038 | YYERROR;
|
| 3039 | }
|
| 3040 | s = NULL;
|
| 3041 | $$ = $1;
|
| 3042 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3043 | | deviation_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.deviation->deviation, s, "deviation")) {
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 3044 | free($1.deviation);
|
| 3045 | YYERROR;
|
| 3046 | }
|
| 3047 | s = NULL;
|
| 3048 | $$ = $1;
|
| 3049 | }
|
| 3050 | | deviation_opt_stmt DEVIATE_KEYWORD sep deviate_body_stmt { if (read_all) {
|
| 3051 | actual = $1.deviation;
|
| 3052 | actual_type = DEVIATE_KEYWORD;
|
| 3053 | $$ = $1;
|
| 3054 | } else {
|
| 3055 | /* count of deviate statemenet */
|
Pavol Vican | a55cbb4 | 2016-03-21 20:15:26 +0100 | [diff] [blame] | 3056 | size_arrays->node[$1.index].deviate++;
|
Pavol Vican | 220e5a1 | 2016-03-03 14:19:43 +0100 | [diff] [blame] | 3057 | }
|
| 3058 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3059 |
|
| 3060 | deviation_arg_str: absolute_schema_nodeids optsep
|
| 3061 | | string_1
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3062 |
|
| 3063 | deviate_body_stmt: deviate_not_supported_stmt
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3064 | { if (read_all && yang_read_deviate_unsupported(actual)) {
|
Pavol Vican | 4c90c64 | 2016-03-03 15:06:47 +0100 | [diff] [blame] | 3065 | YYERROR;
|
| 3066 | }
|
| 3067 | }
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3068 | | deviate_stmts optsep
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3069 |
|
| 3070 | deviate_stmts: deviate_add_stmt
|
| 3071 | | deviate_replace_stmt
|
| 3072 | | deviate_delete_stmt
|
| 3073 | ;
|
| 3074 |
|
| 3075 | deviate_not_supported_stmt: NOT_SUPPORTED_KEYWORD optsep stmtend;
|
| 3076 |
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3077 | deviate_add_stmt: ADD_KEYWORD optsep { if (read_all && yang_read_deviate(actual, LY_DEVIATE_ADD)) {
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3078 | YYERROR;
|
| 3079 | }
|
| 3080 | }
|
| 3081 | deviate_add_end
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3082 |
|
| 3083 | deviate_add_end: ';'
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3084 | | '{' stmtsep
|
| 3085 | deviate_add_opt_stmt
|
| 3086 | '}'
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3087 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3088 | deviate_add_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3089 | $$.deviation = actual;
|
| 3090 | actual_type = ADD_KEYWORD;
|
| 3091 | if (size_arrays->node[size_arrays->next].must) {
|
Pavol Vican | 974377b | 2016-03-23 00:38:53 +0100 | [diff] [blame] | 3092 | if (yang_read_deviate_must(actual, size_arrays->node[size_arrays->next].must)) {
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3093 | YYERROR;
|
| 3094 | }
|
| 3095 | }
|
| 3096 | if (size_arrays->node[size_arrays->next].unique) {
|
Pavol Vican | 974377b | 2016-03-23 00:38:53 +0100 | [diff] [blame] | 3097 | if (yang_read_deviate_unique(actual, size_arrays->node[size_arrays->next].unique)) {
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3098 | YYERROR;
|
| 3099 | }
|
| 3100 | }
|
| 3101 | size_arrays->next++;
|
| 3102 | } else {
|
| 3103 | $$.index = size_arrays->size;
|
| 3104 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 3105 | LOGMEM;
|
| 3106 | YYERROR;
|
| 3107 | }
|
| 3108 | }
|
| 3109 | }
|
| 3110 | | deviate_add_opt_stmt units_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3111 | if (yang_read_deviate_units(trg->ctx, $1.deviation, s)) {
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3112 | YYERROR;
|
| 3113 | }
|
| 3114 | s = NULL;
|
| 3115 | $$ = $1;
|
| 3116 | }
|
| 3117 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 3118 | | deviate_add_opt_stmt must_stmt stmtsep { if (read_all) {
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3119 | actual = $1.deviation;
|
| 3120 | actual_type = ADD_KEYWORD;
|
| 3121 | $$ = $1;
|
| 3122 | } else {
|
| 3123 | size_arrays->node[$1.index].must++;
|
| 3124 | }
|
| 3125 | }
|
| 3126 | | deviate_add_opt_stmt unique_stmt { if (read_all) {
|
| 3127 | struct lys_node_list *list;
|
| 3128 |
|
| 3129 | list = (struct lys_node_list *)$1.deviation->target;
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3130 | if (yang_fill_unique(trg, list, &list->unique[list->unique_size], s, NULL)) {
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3131 | list->unique_size++;
|
| 3132 | YYERROR;
|
| 3133 | }
|
| 3134 | list->unique_size++;
|
| 3135 | free(s);
|
| 3136 | s = NULL;
|
| 3137 | $$ = $1;
|
| 3138 | } else {
|
| 3139 | size_arrays->node[$1.index].unique++;
|
| 3140 | }
|
| 3141 | }
|
| 3142 | | deviate_add_opt_stmt default_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3143 | if (yang_read_deviate_default(trg->ctx, $1.deviation, s)) {
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3144 | YYERROR;
|
| 3145 | }
|
| 3146 | s = NULL;
|
| 3147 | $$ = $1;
|
| 3148 | }
|
| 3149 | }
|
| 3150 | | deviate_add_opt_stmt config_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3151 | if (yang_read_deviate_config($1.deviation, $2)) {
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3152 | YYERROR;
|
| 3153 | }
|
| 3154 | $$ = $1;
|
| 3155 | }
|
| 3156 | }
|
| 3157 | | deviate_add_opt_stmt mandatory_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3158 | if (yang_read_deviate_mandatory($1.deviation, $2)) {
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3159 | YYERROR;
|
| 3160 | }
|
| 3161 | $$ = $1;
|
| 3162 | }
|
| 3163 | }
|
| 3164 | | deviate_add_opt_stmt min_elements_stmt { if (read_all) {
|
| 3165 | if ($1.deviation->deviate->min_set) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3166 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "min-elements", "deviation");
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3167 | YYERROR;
|
| 3168 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3169 | if (yang_read_deviate_minmax($1.deviation, $2, 0)) {
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3170 | YYERROR;
|
| 3171 | }
|
| 3172 | $$ = $1;
|
| 3173 | }
|
| 3174 | }
|
| 3175 | | deviate_add_opt_stmt max_elements_stmt { if (read_all) {
|
| 3176 | if ($1.deviation->deviate->max_set) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3177 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "max-elements", "deviation");
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3178 | YYERROR;
|
| 3179 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3180 | if (yang_read_deviate_minmax($1.deviation, $2, 1)) {
|
Pavol Vican | 85f1202 | 2016-03-05 16:30:35 +0100 | [diff] [blame] | 3181 | YYERROR;
|
| 3182 | }
|
| 3183 | $$ = $1;
|
| 3184 | }
|
| 3185 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3186 |
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3187 | deviate_delete_stmt: DELETE_KEYWORD optsep { if (read_all && yang_read_deviate(actual, LY_DEVIATE_DEL)) {
|
Pavol Vican | c1f5a50 | 2016-03-06 16:51:26 +0100 | [diff] [blame] | 3188 | YYERROR;
|
| 3189 | }
|
| 3190 | }
|
| 3191 | deviate_delete_end
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3192 |
|
| 3193 | deviate_delete_end: ';'
|
Pavol Vican | c1f5a50 | 2016-03-06 16:51:26 +0100 | [diff] [blame] | 3194 | | '{' stmtsep
|
| 3195 | deviate_delete_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3196 | '}' ;
|
| 3197 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3198 | deviate_delete_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | c1f5a50 | 2016-03-06 16:51:26 +0100 | [diff] [blame] | 3199 | $$.deviation = actual;
|
| 3200 | actual_type = DELETE_KEYWORD;
|
| 3201 | if (size_arrays->node[size_arrays->next].must) {
|
Pavol Vican | 974377b | 2016-03-23 00:38:53 +0100 | [diff] [blame] | 3202 | if (yang_read_deviate_must(actual, size_arrays->node[size_arrays->next].must)) {
|
Pavol Vican | c1f5a50 | 2016-03-06 16:51:26 +0100 | [diff] [blame] | 3203 | YYERROR;
|
| 3204 | }
|
| 3205 | }
|
| 3206 | if (size_arrays->node[size_arrays->next].unique) {
|
Pavol Vican | 974377b | 2016-03-23 00:38:53 +0100 | [diff] [blame] | 3207 | if (yang_read_deviate_unique(actual, size_arrays->node[size_arrays->next].unique)) {
|
Pavol Vican | c1f5a50 | 2016-03-06 16:51:26 +0100 | [diff] [blame] | 3208 | YYERROR;
|
| 3209 | }
|
| 3210 | }
|
| 3211 | size_arrays->next++;
|
| 3212 | } else {
|
| 3213 | $$.index = size_arrays->size;
|
| 3214 | if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
|
| 3215 | LOGMEM;
|
| 3216 | YYERROR;
|
| 3217 | }
|
| 3218 | }
|
| 3219 | }
|
| 3220 | | deviate_delete_opt_stmt units_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3221 | if (yang_read_deviate_units(trg->ctx, $1.deviation, s)) {
|
Pavol Vican | c1f5a50 | 2016-03-06 16:51:26 +0100 | [diff] [blame] | 3222 | YYERROR;
|
| 3223 | }
|
| 3224 | s = NULL;
|
| 3225 | $$ = $1;
|
| 3226 | }
|
| 3227 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 3228 | | deviate_delete_opt_stmt must_stmt stmtsep { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3229 | if (yang_check_deviate_must(trg->ctx, $1.deviation)) {
|
Pavol Vican | c1f5a50 | 2016-03-06 16:51:26 +0100 | [diff] [blame] | 3230 | YYERROR;
|
| 3231 | }
|
| 3232 | actual = $1.deviation;
|
| 3233 | actual_type = DELETE_KEYWORD;
|
| 3234 | $$ = $1;
|
| 3235 | } else {
|
| 3236 | size_arrays->node[$1.index].must++;
|
| 3237 | }
|
| 3238 | }
|
| 3239 | | deviate_delete_opt_stmt unique_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3240 | if (yang_check_deviate_unique(trg, $1.deviation, s)) {
|
Pavol Vican | c1f5a50 | 2016-03-06 16:51:26 +0100 | [diff] [blame] | 3241 | YYERROR;
|
| 3242 | }
|
| 3243 | s = NULL;
|
| 3244 | $$ = $1;
|
| 3245 | } else {
|
| 3246 | size_arrays->node[$1.index].unique++;
|
| 3247 | }
|
| 3248 | }
|
| 3249 | | deviate_delete_opt_stmt default_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3250 | if (yang_read_deviate_default(trg->ctx, $1.deviation, s)) {
|
Pavol Vican | c1f5a50 | 2016-03-06 16:51:26 +0100 | [diff] [blame] | 3251 | YYERROR;
|
| 3252 | }
|
| 3253 | s = NULL;
|
| 3254 | $$ = $1;
|
| 3255 | }
|
| 3256 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3257 |
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3258 | deviate_replace_stmt: REPLACE_KEYWORD optsep { if (read_all && yang_read_deviate(actual, LY_DEVIATE_RPL)) {
|
Pavol Vican | 4766aca | 2016-03-07 12:42:36 +0100 | [diff] [blame] | 3259 | YYERROR;
|
| 3260 | }
|
| 3261 | }
|
| 3262 | deviate_replace_end
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3263 |
|
| 3264 | deviate_replace_end: ';'
|
Pavol Vican | 4766aca | 2016-03-07 12:42:36 +0100 | [diff] [blame] | 3265 | | '{' stmtsep
|
| 3266 | deviate_replace_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3267 | '}' ;
|
| 3268 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3269 | deviate_replace_opt_stmt: @EMPTYDIR@ { if (read_all) {
|
Pavol Vican | 4766aca | 2016-03-07 12:42:36 +0100 | [diff] [blame] | 3270 | $$.deviation = actual;
|
| 3271 | actual_type = REPLACE_KEYWORD;
|
| 3272 | }
|
| 3273 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 3274 | | deviate_replace_opt_stmt type_stmt stmtsep { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3275 | if (unres_schema_add_node(trg, unres, $1.deviation->deviate->type, UNRES_TYPE_DER, $1.deviation->target)) {
|
Pavol Vican | 4766aca | 2016-03-07 12:42:36 +0100 | [diff] [blame] | 3276 | YYERROR;
|
| 3277 | }
|
| 3278 | }
|
| 3279 | }
|
| 3280 | | deviate_replace_opt_stmt units_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3281 | if (yang_read_deviate_units(trg->ctx, $1.deviation, s)) {
|
Pavol Vican | 4766aca | 2016-03-07 12:42:36 +0100 | [diff] [blame] | 3282 | YYERROR;
|
| 3283 | }
|
| 3284 | s = NULL;
|
| 3285 | $$ = $1;
|
| 3286 | }
|
| 3287 | }
|
| 3288 | | deviate_replace_opt_stmt default_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3289 | if (yang_read_deviate_default(trg->ctx, $1.deviation, s)) {
|
Pavol Vican | 4766aca | 2016-03-07 12:42:36 +0100 | [diff] [blame] | 3290 | YYERROR;
|
| 3291 | }
|
| 3292 | s = NULL;
|
| 3293 | $$ = $1;
|
| 3294 | }
|
| 3295 | }
|
| 3296 | | deviate_replace_opt_stmt config_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3297 | if (yang_read_deviate_config($1.deviation, $2)) {
|
Pavol Vican | 4766aca | 2016-03-07 12:42:36 +0100 | [diff] [blame] | 3298 | YYERROR;
|
| 3299 | }
|
| 3300 | $$ = $1;
|
| 3301 | }
|
| 3302 | }
|
| 3303 | | deviate_replace_opt_stmt mandatory_stmt { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3304 | if (yang_read_deviate_mandatory($1.deviation, $2)) {
|
Pavol Vican | 4766aca | 2016-03-07 12:42:36 +0100 | [diff] [blame] | 3305 | YYERROR;
|
| 3306 | }
|
| 3307 | $$ = $1;
|
| 3308 | }
|
| 3309 | }
|
| 3310 | | deviate_replace_opt_stmt min_elements_stmt { if (read_all) {
|
| 3311 | if ($1.deviation->deviate->min_set) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3312 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "min-elements", "deviate");
|
Pavol Vican | 4766aca | 2016-03-07 12:42:36 +0100 | [diff] [blame] | 3313 | YYERROR;
|
| 3314 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3315 | if (yang_read_deviate_minmax($1.deviation, $2, 0)) {
|
Pavol Vican | 4766aca | 2016-03-07 12:42:36 +0100 | [diff] [blame] | 3316 | YYERROR;
|
| 3317 | }
|
| 3318 | $$ = $1;
|
| 3319 | }
|
| 3320 | }
|
| 3321 | | deviate_replace_opt_stmt max_elements_stmt { if (read_all) {
|
| 3322 | if ($1.deviation->deviate->max_set) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3323 | LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "max-elements", "deviate");
|
Pavol Vican | 4766aca | 2016-03-07 12:42:36 +0100 | [diff] [blame] | 3324 | YYERROR;
|
| 3325 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3326 | if (yang_read_deviate_minmax($1.deviation, $2, 1)) {
|
Pavol Vican | 4766aca | 2016-03-07 12:42:36 +0100 | [diff] [blame] | 3327 | YYERROR;
|
| 3328 | }
|
| 3329 | $$ = $1;
|
| 3330 | }
|
| 3331 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3332 |
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3333 | when_stmt: WHEN_KEYWORD sep string { if (read_all && !(actual=yang_read_when(trg, actual, actual_type, s))) {YYERROR;} s=NULL; actual_type=WHEN_KEYWORD;}
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 3334 | when_end;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3335 |
|
| 3336 | when_end: ';'
|
Pavol Vican | accd887 | 2016-04-04 10:53:27 +0200 | [diff] [blame] | 3337 | | '{' stmtsep
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 3338 | when_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3339 | '}'
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 3340 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3341 | when_opt_stmt: @EMPTYDIR@
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3342 | | when_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, "when")) {
|
Pavol Vican | 9bcd7c6 | 2016-03-17 19:36:35 +0100 | [diff] [blame] | 3343 | YYERROR;
|
| 3344 | }
|
| 3345 | s = NULL;
|
| 3346 | }
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3347 | | when_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, "when")) {
|
Pavol Vican | f5fe966 | 2016-03-17 20:00:16 +0100 | [diff] [blame] | 3348 | YYERROR;
|
| 3349 | }
|
| 3350 | s = NULL;
|
| 3351 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3352 |
|
Pavol Vican | b568711 | 2016-02-09 22:35:59 +0100 | [diff] [blame] | 3353 | config_stmt: CONFIG_KEYWORD sep config_arg_str stmtend { $$ = $3; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3354 |
|
Pavol Vican | e408402 | 2016-03-19 13:12:52 +0100 | [diff] [blame] | 3355 | config_read_stmt: CONFIG_KEYWORD sep { read_all = (read_all) ? LY_READ_ONLY_SIZE : LY_READ_ALL; }
|
| 3356 | config_arg_str { read_all = (read_all) ? LY_READ_ONLY_SIZE : LY_READ_ALL; }
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 3357 | stmtend { $$ = $4; }
|
| 3358 |
|
Pavol Vican | b568711 | 2016-02-09 22:35:59 +0100 | [diff] [blame] | 3359 | config_arg_str: TRUE_KEYWORD optsep { $$ = LYS_CONFIG_W; }
|
| 3360 | | FALSE_KEYWORD optsep { $$ = LYS_CONFIG_R; }
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 3361 | | string_1 { if (read_all) {
|
| 3362 | if (!strcmp(s, "true")) {
|
| 3363 | $$ = LYS_CONFIG_W;
|
| 3364 | } else if (!strcmp(s, "false")) {
|
| 3365 | $$ = LYS_CONFIG_R;
|
| 3366 | } else {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3367 | LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "config");
|
Pavol Vican | 4fb66c9 | 2016-03-17 10:32:27 +0100 | [diff] [blame] | 3368 | free(s);
|
| 3369 | YYERROR;
|
| 3370 | }
|
| 3371 | free(s);
|
| 3372 | s = NULL;
|
| 3373 | }
|
| 3374 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3375 |
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 3376 | mandatory_stmt: MANDATORY_KEYWORD sep mandatory_arg_str stmtend { $$ = $3; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3377 |
|
Pavol Vican | e408402 | 2016-03-19 13:12:52 +0100 | [diff] [blame] | 3378 | mandatory_read_stmt: MANDATORY_KEYWORD sep { read_all = (read_all) ? LY_READ_ONLY_SIZE : LY_READ_ALL; }
|
| 3379 | mandatory_arg_str { read_all = (read_all) ? LY_READ_ONLY_SIZE : LY_READ_ALL; }
|
| 3380 | stmtend { $$ = $4; }
|
| 3381 |
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 3382 | mandatory_arg_str: TRUE_KEYWORD optsep { $$ = LYS_MAND_TRUE; }
|
| 3383 | | FALSE_KEYWORD optsep { $$ = LYS_MAND_FALSE; }
|
Pavol Vican | e408402 | 2016-03-19 13:12:52 +0100 | [diff] [blame] | 3384 | | string_1 { if (read_all) {
|
| 3385 | if (!strcmp(s, "true")) {
|
| 3386 | $$ = LYS_MAND_TRUE;
|
| 3387 | } else if (!strcmp(s, "false")) {
|
| 3388 | $$ = LYS_MAND_FALSE;
|
| 3389 | } else {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3390 | LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "mandatory");
|
Pavol Vican | e408402 | 2016-03-19 13:12:52 +0100 | [diff] [blame] | 3391 | free(s);
|
| 3392 | YYERROR;
|
| 3393 | }
|
| 3394 | free(s);
|
| 3395 | s = NULL;
|
| 3396 | }
|
| 3397 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3398 |
|
| 3399 | presence_stmt: PRESENCE_KEYWORD sep string stmtend;
|
| 3400 |
|
Pavol Vican | beecbb0 | 2016-02-11 16:43:11 +0100 | [diff] [blame] | 3401 | min_elements_stmt: MIN_ELEMENTS_KEYWORD sep min_value_arg_str stmtend { $$ = $3; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3402 |
|
Pavol Vican | beecbb0 | 2016-02-11 16:43:11 +0100 | [diff] [blame] | 3403 | min_value_arg_str: non_negative_integer_value optsep { $$ = $1; }
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 3404 | | string_1 { if (read_all) {
|
| 3405 | if (strlen(s) == 1 && s[0] == '0') {
|
| 3406 | $$ = 0;
|
| 3407 | } else {
|
| 3408 | /* convert it to uint32_t */
|
| 3409 | uint64_t val;
|
| 3410 | char *endptr;
|
| 3411 |
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3412 | val = strtoul(yyget_text(scanner), &endptr, 10);
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 3413 | if (val > UINT32_MAX || *endptr) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3414 | LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "min-elements");
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 3415 | free(s);
|
| 3416 | YYERROR;
|
| 3417 | }
|
| 3418 | $$ = (uint32_t) val;
|
| 3419 | }
|
| 3420 | free(s);
|
| 3421 | s = NULL;
|
| 3422 | }
|
| 3423 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3424 |
|
Pavol Vican | beecbb0 | 2016-02-11 16:43:11 +0100 | [diff] [blame] | 3425 | max_elements_stmt: MAX_ELEMENTS_KEYWORD sep max_value_arg_str stmtend { $$ = $3; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3426 |
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 3427 | max_value_arg_str: UNBOUNDED_KEYWORD optsep { $$ = 0; }
|
Pavol Vican | beecbb0 | 2016-02-11 16:43:11 +0100 | [diff] [blame] | 3428 | | positive_integer_value optsep { $$ = $1; }
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 3429 | | string_1 { if (read_all) {
|
| 3430 | if (!strcmp(s, "unbounded")) {
|
| 3431 | $$ = 0;
|
| 3432 | } else {
|
| 3433 | /* convert it to uint32_t */
|
| 3434 | uint64_t val;
|
| 3435 | char *endptr;
|
| 3436 |
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3437 | val = strtoul(yyget_text(scanner), &endptr, 10);
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 3438 | if (val > UINT32_MAX || *endptr) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3439 | LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "max-elements");
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 3440 | free(s);
|
| 3441 | YYERROR;
|
| 3442 | }
|
| 3443 | $$ = (uint32_t) val;
|
| 3444 | }
|
| 3445 | free(s);
|
| 3446 | s = NULL;
|
| 3447 | }
|
| 3448 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3449 |
|
Pavol Vican | be057c0 | 2016-02-11 19:08:08 +0100 | [diff] [blame] | 3450 | ordered_by_stmt: ORDERED_BY_KEYWORD sep ordered_by_arg_str stmtend { $$ = $3; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3451 |
|
Pavol Vican | be057c0 | 2016-02-11 19:08:08 +0100 | [diff] [blame] | 3452 | ordered_by_arg_str: USER_KEYWORD optsep { $$ = LYS_USERORDERED; }
|
| 3453 | | SYSTEM_KEYWORD optsep { $$ = LYS_SYSTEMORDERED; }
|
| 3454 | | string_1 { if (!strcmp(s, "user")) {
|
| 3455 | $$ = LYS_USERORDERED;
|
| 3456 | } else if (!strcmp(s, "system")) {
|
| 3457 | $$ = LYS_SYSTEMORDERED;
|
| 3458 | } else {
|
| 3459 | free(s);
|
| 3460 | YYERROR;
|
| 3461 | }
|
| 3462 | free(s);
|
| 3463 | s=NULL;
|
| 3464 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3465 |
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 3466 | must_stmt: MUST_KEYWORD sep string { if (read_all) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3467 | if (!(actual=yang_read_must(trg, actual, s, actual_type))) {YYERROR;}
|
Pavol Vican | f37eeaa | 2016-02-09 20:54:06 +0100 | [diff] [blame] | 3468 | s=NULL;
|
| 3469 | actual_type=MUST_KEYWORD;
|
| 3470 | }
|
| 3471 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 3472 | must_end;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3473 |
|
| 3474 | must_end: ';'
|
Pavol Vican | 8c82fa8 | 2016-02-10 13:13:24 +0100 | [diff] [blame] | 3475 | | '{' stmtsep
|
| 3476 | message_opt_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3477 | '}'
|
| 3478 | ;
|
| 3479 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3480 | unique_stmt: UNIQUE_KEYWORD sep unique_arg_str;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3481 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3482 | unique_arg_str: descendant_schema_nodeid unique_arg
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3483 | | string_1 stmtend;
|
| 3484 |
|
| 3485 | unique_arg: sep descendant_schema_nodeid unique_arg
|
| 3486 | | stmtend;
|
| 3487 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3488 | key_stmt: KEY_KEYWORD sep key_arg_str;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3489 |
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3490 | key_arg_str: node_identifier { if (read_all){
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3491 | s = strdup(yyget_text(scanner));
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3492 | if (!s) {
|
| 3493 | LOGMEM;
|
| 3494 | YYERROR;
|
| 3495 | }
|
| 3496 | }
|
| 3497 | }
|
| 3498 | key_opt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3499 | | string_1 stmtend
|
| 3500 | ;
|
| 3501 |
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3502 | key_opt: sep node_identifier { if (read_all) {
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3503 | s = ly_realloc(s,strlen(s) + yyget_leng(scanner) + 2);
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3504 | if (!s) {
|
| 3505 | LOGMEM;
|
| 3506 | YYERROR;
|
| 3507 | }
|
| 3508 | strcat(s," ");
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3509 | strcat(s, yyget_text(scanner));
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3510 | }
|
| 3511 | }
|
| 3512 | key_opt
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3513 | | stmtend
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3514 | ;
|
| 3515 |
|
Pavol Vican | aff5c80 | 2016-02-24 15:56:45 +0100 | [diff] [blame] | 3516 | range_arg_str: string { if (read_all) {
|
| 3517 | $$ = actual;
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3518 | if (!(actual = yang_read_range(trg, actual, s))) {
|
Pavol Vican | aff5c80 | 2016-02-24 15:56:45 +0100 | [diff] [blame] | 3519 | YYERROR;
|
| 3520 | }
|
| 3521 | actual_type = RANGE_KEYWORD;
|
| 3522 | s = NULL;
|
| 3523 | }
|
| 3524 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3525 |
|
Pavol Vican | 57032c0 | 2016-02-26 15:24:00 +0100 | [diff] [blame] | 3526 | absolute_schema_nodeid: '/' node_identifier { if (read_all) {
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3527 | if (s) {
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3528 | s = ly_realloc(s,strlen(s) + yyget_leng(scanner) + 2);
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3529 | if (!s) {
|
| 3530 | LOGMEM;
|
| 3531 | YYERROR;
|
| 3532 | }
|
| 3533 | strcat(s,"/");
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3534 | strcat(s, yyget_text(scanner));
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3535 | } else {
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3536 | s = malloc(yyget_leng(scanner) + 2);
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3537 | if (!s) {
|
| 3538 | LOGMEM;
|
| 3539 | YYERROR;
|
| 3540 | }
|
| 3541 | s[0]='/';
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3542 | memcpy(s + 1, yyget_text(scanner), yyget_leng(scanner) + 1);
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3543 | }
|
| 3544 | }
|
| 3545 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3546 |
|
| 3547 | absolute_schema_nodeids: absolute_schema_nodeid absolute_schema_nodeid_opt;
|
| 3548 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3549 | absolute_schema_nodeid_opt: @EMPTYDIR@
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3550 | | absolute_schema_nodeid_opt absolute_schema_nodeid
|
| 3551 | ;
|
| 3552 |
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3553 | descendant_schema_nodeid: node_identifier { if (read_all) {
|
| 3554 | if (s) {
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3555 | s = ly_realloc(s,strlen(s) + yyget_leng(scanner) + 1);
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3556 | if (!s) {
|
| 3557 | LOGMEM;
|
| 3558 | YYERROR;
|
| 3559 | }
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3560 | strcat(s, yyget_text(scanner));
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3561 | } else {
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3562 | s = strdup(yyget_text(scanner));
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3563 | if (!s) {
|
| 3564 | LOGMEM;
|
| 3565 | YYERROR;
|
| 3566 | }
|
| 3567 | }
|
| 3568 | }
|
| 3569 | }
|
| 3570 | absolute_schema_nodeid_opt;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3571 |
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3572 | path_arg_str: { tmp_s = yyget_text(scanner); } absolute_paths { if (read_all) {
|
Pavol Vican | 191613a | 2016-02-26 16:21:32 +0100 | [diff] [blame] | 3573 | s = strdup(tmp_s);
|
| 3574 | if (!s) {
|
| 3575 | LOGMEM;
|
| 3576 | YYERROR;
|
| 3577 | }
|
| 3578 | s[strlen(s) - 1] = '\0';
|
| 3579 | }
|
| 3580 | }
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3581 | | { tmp_s = yyget_text(scanner); } relative_path { if (read_all) {
|
Pavol Vican | 191613a | 2016-02-26 16:21:32 +0100 | [diff] [blame] | 3582 | s = strdup(tmp_s);
|
| 3583 | if (!s) {
|
| 3584 | LOGMEM;
|
| 3585 | YYERROR;
|
| 3586 | }
|
| 3587 | s[strlen(s) - 1] = '\0';
|
| 3588 | }
|
| 3589 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3590 | | string_1
|
| 3591 | ;
|
| 3592 |
|
Pavol Vican | 57032c0 | 2016-02-26 15:24:00 +0100 | [diff] [blame] | 3593 | absolute_path: '/' node_identifier path_predicate
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3594 |
|
| 3595 | absolute_paths: absolute_path absolute_path_opt
|
| 3596 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3597 | absolute_path_opt: @EMPTYDIR@
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3598 | | absolute_path_opt absolute_path;
|
| 3599 |
|
| 3600 | relative_path: relative_path_part1 relative_path_part1_opt descendant_path
|
| 3601 |
|
Pavol Vican | 57032c0 | 2016-02-26 15:24:00 +0100 | [diff] [blame] | 3602 | relative_path_part1: DOUBLEDOT '/';
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3603 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3604 | relative_path_part1_opt: @EMPTYDIR@
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3605 | | relative_path_part1_opt relative_path_part1;
|
| 3606 |
|
| 3607 | descendant_path: node_identifier descendant_path_opt
|
| 3608 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3609 | descendant_path_opt: @EMPTYDIR@
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3610 | | path_predicate absolute_paths;
|
| 3611 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3612 | path_predicate: @EMPTYDIR@
|
Pavol Vican | 57032c0 | 2016-02-26 15:24:00 +0100 | [diff] [blame] | 3613 | | path_predicate '[' whitespace_opt path_equality_expr whitespace_opt ']'
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3614 |
|
Pavol Vican | 57032c0 | 2016-02-26 15:24:00 +0100 | [diff] [blame] | 3615 | path_equality_expr: node_identifier whitespace_opt '=' whitespace_opt path_key_expr
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3616 |
|
Pavol Vican | 57032c0 | 2016-02-26 15:24:00 +0100 | [diff] [blame] | 3617 | path_key_expr: current_function_invocation whitespace_opt '/' whitespace_opt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3618 | rel_path_keyexpr
|
| 3619 |
|
| 3620 | rel_path_keyexpr: rel_path_keyexpr_part1 rel_path_keyexpr_part1_opt
|
| 3621 | node_identifier rel_path_keyexpr_part2
|
| 3622 | node_identifier
|
| 3623 |
|
Pavol Vican | 57032c0 | 2016-02-26 15:24:00 +0100 | [diff] [blame] | 3624 | rel_path_keyexpr_part1: DOUBLEDOT whitespace_opt '/' whitespace_opt;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3625 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3626 | rel_path_keyexpr_part1_opt: @EMPTYDIR@
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3627 | | rel_path_keyexpr_part1_opt rel_path_keyexpr_part1;
|
| 3628 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3629 | rel_path_keyexpr_part2: @EMPTYDIR@
|
Pavol Vican | 57032c0 | 2016-02-26 15:24:00 +0100 | [diff] [blame] | 3630 | | rel_path_keyexpr_part2 whitespace_opt '/' whitespace_opt node_identifier;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3631 |
|
Pavol Vican | 57032c0 | 2016-02-26 15:24:00 +0100 | [diff] [blame] | 3632 | current_function_invocation: CURRENT_KEYWORD whitespace_opt '(' whitespace_opt ')'
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3633 |
|
Pavol Vican | beecbb0 | 2016-02-11 16:43:11 +0100 | [diff] [blame] | 3634 | positive_integer_value: NON_NEGATIVE_INTEGER { /* convert it to uint32_t */
|
| 3635 | unsigned long val;
|
| 3636 |
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3637 | val = strtoul(yyget_text(scanner), NULL, 10);
|
Pavol Vican | beecbb0 | 2016-02-11 16:43:11 +0100 | [diff] [blame] | 3638 | if (val > UINT32_MAX) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3639 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Converted number is very long.");
|
Pavol Vican | beecbb0 | 2016-02-11 16:43:11 +0100 | [diff] [blame] | 3640 | YYERROR;
|
| 3641 | }
|
| 3642 | $$ = (uint32_t) val;
|
| 3643 | }
|
| 3644 |
|
| 3645 | non_negative_integer_value: ZERO { $$ = 0; }
|
| 3646 | | positive_integer_value { $$ = $1; }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3647 | ;
|
| 3648 |
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 3649 | integer_value: ZERO { $$ = 0; }
|
| 3650 | | integer_value_convert { /* convert it to int32_t */
|
| 3651 | int64_t val;
|
| 3652 |
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3653 | val = strtoll(yyget_text(scanner), NULL, 10);
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 3654 | if (val < INT32_MIN || val > INT32_MAX) {
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3655 | LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "The number is not in the correct range (INT32_MIN..INT32_MAX): \"%d\"",val);
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 3656 | YYERROR;
|
| 3657 | }
|
| 3658 | $$ = (int32_t) val;
|
| 3659 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3660 | ;
|
| 3661 |
|
Pavol Vican | 79a763d | 2016-02-25 15:41:27 +0100 | [diff] [blame] | 3662 | integer_value_convert: INTEGER
|
| 3663 | | NON_NEGATIVE_INTEGER
|
| 3664 |
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3665 | prefix_arg_str: string_1
|
Pavol Vican | 021488a | 2016-01-25 23:56:12 +0100 | [diff] [blame] | 3666 | | identifiers optsep;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3667 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3668 | identifier_arg_str: identifiers optsep
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3669 | | string_1 { if (read_all && lyp_check_identifier(s, LY_IDENT_SIMPLE, trg, NULL)) {
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 3670 | free(s);
|
| 3671 | YYERROR;
|
| 3672 | }
|
| 3673 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3674 |
|
Pavol Vican | 5de3349 | 2016-02-22 14:03:24 +0100 | [diff] [blame] | 3675 | node_identifier: identifier
|
| 3676 | | IDENTIFIERPREFIX
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3677 | ;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3678 |
|
Pavol Vican | 021488a | 2016-01-25 23:56:12 +0100 | [diff] [blame] | 3679 | identifier_ref_arg_str: identifiers optsep
|
Pavol Vican | bbdef53 | 2016-02-09 14:52:12 +0100 | [diff] [blame] | 3680 | | identifiers_ref optsep
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 3681 | | string_1 { if (read_all) {
|
| 3682 | char *tmp;
|
| 3683 |
|
| 3684 | if ((tmp = strchr(s, ':'))) {
|
| 3685 | *tmp = '\0';
|
| 3686 | /* check prefix */
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3687 | if (lyp_check_identifier(s, LY_IDENT_SIMPLE, trg, NULL)) {
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 3688 | free(s);
|
| 3689 | YYERROR;
|
| 3690 | }
|
| 3691 | /* check identifier */
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3692 | if (lyp_check_identifier(tmp + 1, LY_IDENT_SIMPLE, trg, NULL)) {
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 3693 | free(s);
|
| 3694 | YYERROR;
|
| 3695 | }
|
| 3696 | *tmp = ':';
|
| 3697 | } else {
|
Pavol Vican | 0da132e | 2016-03-21 12:03:03 +0100 | [diff] [blame] | 3698 | /* check identifier */
|
Pavol Vican | 0adf01d | 2016-03-22 12:29:33 +0100 | [diff] [blame] | 3699 | if (lyp_check_identifier(s, LY_IDENT_SIMPLE, trg, NULL)) {
|
Pavol Vican | 796d1fd | 2016-03-21 08:49:39 +0100 | [diff] [blame] | 3700 | free(s);
|
| 3701 | YYERROR;
|
| 3702 | }
|
| 3703 | }
|
| 3704 | }
|
| 3705 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3706 |
|
| 3707 | stmtend: ';' stmtsep
|
| 3708 | | '{' stmtsep '}' stmtsep
|
| 3709 | ;
|
| 3710 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3711 | stmtsep: @EMPTYDIR@
|
| 3712 | | stmtsep sep_stmt
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3713 | | stmtsep unknown_statement
|
| 3714 | ;
|
| 3715 |
|
Pavol Vican | a302aa6 | 2016-03-17 10:45:35 +0100 | [diff] [blame] | 3716 | unknown_statement: IDENTIFIERPREFIX { if (read_all ) {
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3717 | if (yang_use_extension(trg, data_node, actual, yyget_text(scanner))) {
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 3718 | YYERROR;
|
| 3719 | }
|
Pavol Vican | f4717e6 | 2016-03-16 11:30:01 +0100 | [diff] [blame] | 3720 | }
|
| 3721 | }
|
| 3722 | string_opt unknown_statement_end
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3723 |
|
Pavol Vican | 14bd318 | 2016-03-16 12:37:10 +0100 | [diff] [blame] | 3724 | string_opt: string_opt_part1 string_opt_part2
|
| 3725 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3726 | string_opt_part1: @EMPTYDIR@
|
Pavol Vican | 14bd318 | 2016-03-16 12:37:10 +0100 | [diff] [blame] | 3727 | | sep
|
| 3728 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3729 | string_opt_part2: @EMPTYDIR@
|
Pavol Vican | 14bd318 | 2016-03-16 12:37:10 +0100 | [diff] [blame] | 3730 | | STRING optsep string_opt_part3
|
| 3731 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3732 | string_opt_part3: @EMPTYDIR@
|
Pavol Vican | 14bd318 | 2016-03-16 12:37:10 +0100 | [diff] [blame] | 3733 | | string_opt_part3 '+' optsep STRING optsep
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3734 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3735 | unknown_statement_end: ';'
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3736 | | '{' optsep unknown_statement2_opt '}'
|
| 3737 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3738 | unknown_statement2_opt: @EMPTYDIR@
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3739 | | node_identifier string_opt unknown_statement2_end;
|
| 3740 |
|
| 3741 | unknown_statement2_end: ';' optsep
|
| 3742 | | '{' optsep unknown_statement2_opt '}' optsep
|
| 3743 |
|
| 3744 | sep_stmt: WHITESPACE
|
| 3745 | | EOL
|
| 3746 | ;
|
| 3747 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3748 | optsep: @EMPTYDIR@
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3749 | | optsep sep_stmt
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3750 | ;
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3751 |
|
| 3752 | sep: sep_stmt optsep;
|
| 3753 |
|
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 3754 | whitespace_opt: @EMPTYDIR@
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3755 | | WHITESPACE
|
| 3756 | ;
|
| 3757 |
|
| 3758 |
|
Pavol Vican | 305a633 | 2016-03-09 21:08:09 +0100 | [diff] [blame] | 3759 | string: strings { if (read_all){
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3760 | s = strdup(yyget_text(scanner));
|
Pavol Vican | 73e7c99 | 2016-02-24 12:18:05 +0100 | [diff] [blame] | 3761 | if (!s) {
|
| 3762 | LOGMEM;
|
| 3763 | YYERROR;
|
| 3764 | }
|
| 3765 | }
|
| 3766 | }
|
| 3767 | optsep
|
Pavol Vican | 305a633 | 2016-03-09 21:08:09 +0100 | [diff] [blame] | 3768 | | string_1
|
| 3769 |
|
| 3770 | strings: STRINGS
|
| 3771 | | REVISION_DATE
|
| 3772 | | identifier
|
| 3773 | | IDENTIFIERPREFIX
|
| 3774 | | ZERO
|
| 3775 | | INTEGER
|
| 3776 | | NON_NEGATIVE_INTEGER
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3777 |
|
| 3778 | identifier: IDENTIFIER
|
| 3779 | | ANYXML_KEYWORD
|
| 3780 | | ARGUMENT_KEYWORD
|
| 3781 | | AUGMENT_KEYWORD
|
| 3782 | | BASE_KEYWORD
|
| 3783 | | BELONGS_TO_KEYWORD
|
| 3784 | | BIT_KEYWORD
|
| 3785 | | CASE_KEYWORD
|
| 3786 | | CHOICE_KEYWORD
|
| 3787 | | CONFIG_KEYWORD
|
| 3788 | | CONTACT_KEYWORD
|
| 3789 | | CONTAINER_KEYWORD
|
| 3790 | | DEFAULT_KEYWORD
|
| 3791 | | DESCRIPTION_KEYWORD
|
| 3792 | | ENUM_KEYWORD
|
| 3793 | | ERROR_APP_TAG_KEYWORD
|
| 3794 | | ERROR_MESSAGE_KEYWORD
|
| 3795 | | EXTENSION_KEYWORD
|
| 3796 | | DEVIATION_KEYWORD
|
| 3797 | | DEVIATE_KEYWORD
|
| 3798 | | FEATURE_KEYWORD
|
| 3799 | | FRACTION_DIGITS_KEYWORD
|
| 3800 | | GROUPING_KEYWORD
|
| 3801 | | IDENTITY_KEYWORD
|
| 3802 | | IF_FEATURE_KEYWORD
|
| 3803 | | IMPORT_KEYWORD
|
| 3804 | | INCLUDE_KEYWORD
|
| 3805 | | INPUT_KEYWORD
|
| 3806 | | KEY_KEYWORD
|
| 3807 | | LEAF_KEYWORD
|
| 3808 | | LEAF_LIST_KEYWORD
|
| 3809 | | LENGTH_KEYWORD
|
| 3810 | | LIST_KEYWORD
|
| 3811 | | MANDATORY_KEYWORD
|
| 3812 | | MAX_ELEMENTS_KEYWORD
|
| 3813 | | MIN_ELEMENTS_KEYWORD
|
| 3814 | | MODULE_KEYWORD
|
| 3815 | | MUST_KEYWORD
|
| 3816 | | NAMESPACE_KEYWORD
|
| 3817 | | NOTIFICATION_KEYWORD
|
| 3818 | | ORDERED_BY_KEYWORD
|
| 3819 | | ORGANIZATION_KEYWORD
|
| 3820 | | OUTPUT_KEYWORD
|
| 3821 | | PATH_KEYWORD
|
| 3822 | | PATTERN_KEYWORD
|
| 3823 | | POSITION_KEYWORD
|
| 3824 | | PREFIX_KEYWORD
|
| 3825 | | PRESENCE_KEYWORD
|
| 3826 | | RANGE_KEYWORD
|
| 3827 | | REFERENCE_KEYWORD
|
| 3828 | | REFINE_KEYWORD
|
| 3829 | | REQUIRE_INSTANCE_KEYWORD
|
| 3830 | | REVISION_KEYWORD
|
| 3831 | | REVISION_DATE_KEYWORD
|
| 3832 | | RPC_KEYWORD
|
| 3833 | | STATUS_KEYWORD
|
| 3834 | | SUBMODULE_KEYWORD
|
| 3835 | | TYPE_KEYWORD
|
| 3836 | | TYPEDEF_KEYWORD
|
| 3837 | | UNIQUE_KEYWORD
|
| 3838 | | UNITS_KEYWORD
|
| 3839 | | USES_KEYWORD
|
| 3840 | | VALUE_KEYWORD
|
| 3841 | | WHEN_KEYWORD
|
| 3842 | | YANG_VERSION_KEYWORD
|
| 3843 | | YIN_ELEMENT_KEYWORD
|
| 3844 | | ADD_KEYWORD
|
| 3845 | | CURRENT_KEYWORD
|
| 3846 | | DELETE_KEYWORD
|
| 3847 | | DEPRECATED_KEYWORD
|
| 3848 | | FALSE_KEYWORD
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3849 | | NOT_SUPPORTED_KEYWORD
|
| 3850 | | OBSOLETE_KEYWORD
|
| 3851 | | REPLACE_KEYWORD
|
| 3852 | | SYSTEM_KEYWORD
|
| 3853 | | TRUE_KEYWORD
|
| 3854 | | UNBOUNDED_KEYWORD
|
| 3855 | | USER_KEYWORD
|
| 3856 | ;
|
| 3857 |
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 3858 | identifiers: identifier { if (read_all) {
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3859 | s = strdup(yyget_text(scanner));
|
Pavol Vican | 1eeb199 | 2016-02-09 11:10:45 +0100 | [diff] [blame] | 3860 | if (!s) {
|
| 3861 | LOGMEM;
|
| 3862 | YYERROR;
|
| 3863 | }
|
| 3864 | }
|
| 3865 | }
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3866 |
|
Pavol Vican | bbdef53 | 2016-02-09 14:52:12 +0100 | [diff] [blame] | 3867 | identifiers_ref: IDENTIFIERPREFIX { if (read_all) {
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3868 | s = strdup(yyget_text(scanner));
|
Pavol Vican | bbdef53 | 2016-02-09 14:52:12 +0100 | [diff] [blame] | 3869 | if (!s) {
|
| 3870 | LOGMEM;
|
| 3871 | YYERROR;
|
| 3872 | }
|
| 3873 | }
|
| 3874 | }
|
| 3875 |
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3876 | %%
|
| 3877 |
|
Pavol Vican | 8760bb7 | 2016-04-07 09:44:01 +0200 | [diff] [blame] | 3878 | void yyerror(YYLTYPE *yylloc, void *scanner, ...){
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3879 |
|
Pavol Vican | 8760bb7 | 2016-04-07 09:44:01 +0200 | [diff] [blame] | 3880 | (void)yylloc; /* unused */
|
Pavol Vican | 802af1e | 2016-03-23 20:42:26 +0100 | [diff] [blame] | 3881 | LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, yyget_text(scanner));
|
Pavol Vican | 6418deb | 2015-10-28 19:41:26 +0100 | [diff] [blame] | 3882 | }
|