blob: 21c8403dbe71c14a6462dd40bc70e1364427bd17 [file] [log] [blame]
Pavol Vican9a3a7212016-03-23 10:04:00 +01001/**
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 Vican802af1e2016-03-23 20:42:26 +010015%define api.pure full
Pavol Vican8760bb72016-04-07 09:44:01 +020016%locations
Pavol Vican802af1e2016-03-23 20:42:26 +010017
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 Vican6418deb2015-10-28 19:41:26 +010027%{
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 Vican021488a2016-01-25 23:56:12 +010034#include "common.h"
35#include "parser_yang.h"
Pavol Vican802af1e2016-03-23 20:42:26 +010036#include "parser_yang_lex.h"
Pavol Vican92fa0dc2016-03-02 14:20:39 +010037#include "parser.h"
Pavol Vican6418deb2015-10-28 19:41:26 +010038
Pavol Vican7a92f532016-03-10 10:12:03 +010039/* only syntax rules */
40#define EXTENSION_ARG 0x01
41#define EXTENSION_STA 0x02
42#define EXTENSION_DSC 0x04
43#define EXTENSION_REF 0x08
Pavol Vican4fb66c92016-03-17 10:32:27 +010044#define DISABLE_INHERIT 0
45#define ENABLE_INHERIT 0x01
Pavol Vican7a92f532016-03-10 10:12:03 +010046
Pavol Vican8760bb72016-04-07 09:44:01 +020047void yyerror(YYLTYPE *yylloc, void *scanner, ...);
Pavol Vican191613a2016-02-26 16:21:32 +010048char *s, *tmp_s;
Pavol Vican9b89dda2016-03-09 15:36:55 +010049char rev[LY_REV_SIZE];
Pavol Vican22afbdd2016-03-09 11:10:26 +010050struct lys_module *trg;
Pavol Vicand946c0d2016-03-23 12:53:08 +010051/* temporary pointer for the check extension nacm */
Pavol Vicanf4717e62016-03-16 11:30:01 +010052struct lys_node *data_node;
Pavol Vicand946c0d2016-03-23 12:53:08 +010053/* pointer on the current parsed element*/
Pavol Vican6eb14e82016-02-03 12:27:13 +010054void *actual;
Pavol Vican4fb66c92016-03-17 10:32:27 +010055int config_inherit;
Pavol Vican6eb14e82016-02-03 12:27:13 +010056int actual_type;
Pavol Vican9887c682016-02-29 11:32:01 +010057int64_t cnt_val;
Pavol Vican6418deb2015-10-28 19:41:26 +010058%}
59
Pavol Vicanbf805472016-01-26 14:24:56 +010060%union {
Pavol Vican79a763d2016-02-25 15:41:27 +010061 int32_t i;
Pavol Vicanbeecbb02016-02-11 16:43:11 +010062 uint32_t uint;
Pavol Vican6eb14e82016-02-03 12:27:13 +010063 char *str;
Pavol Vican73e7c992016-02-24 12:18:05 +010064 void *v;
Pavol Vican9b89dda2016-03-09 15:36:55 +010065 struct lys_module *inc;
Pavol Vicanf37eeaa2016-02-09 20:54:06 +010066 union {
67 uint32_t index;
68 struct lys_node_container *container;
Pavol Vican8c82fa82016-02-10 13:13:24 +010069 struct lys_node_anyxml *anyxml;
Pavol Vican1f06ba82016-02-10 17:39:50 +010070 struct type_choice choice;
Pavol Vicand946c0d2016-03-23 12:53:08 +010071 struct type_node node;
Pavol Vicanbd098132016-02-11 10:56:49 +010072 struct lys_node_case *cs;
Pavol Vican12f53c32016-02-11 11:40:00 +010073 struct lys_node_grp *grouping;
Pavol Vican4fb66c92016-03-17 10:32:27 +010074 struct type_uses uses;
Pavol Vican1003ead2016-03-02 12:24:52 +010075 struct lys_refine *refine;
Pavol Vican41267fd2016-03-03 10:47:42 +010076 struct lys_node_notif *notif;
Pavol Vican220e5a12016-03-03 14:19:43 +010077 struct type_deviation *deviation;
Pavol Vicanf37eeaa2016-02-09 20:54:06 +010078 } nodes;
Pavol Vicanbf805472016-01-26 14:24:56 +010079}
80
Pavol Vicana4f045a2016-02-29 15:01:20 +010081%token UNION_KEYWORD
Pavol Vican6418deb2015-10-28 19:41:26 +010082%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 Vican6418deb2015-10-28 19:41:26 +010098%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 Vican6418deb2015-10-28 19:41:26 +0100167%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 Vicanbeecbb02016-02-11 16:43:11 +0100175%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 Vican1c203db2016-02-24 14:05:23 +0100181%type <uint> decimal_string_restrictions
Pavol Vican07ea68d2016-02-25 12:01:37 +0100182%type <uint> fraction_digits_arg_str
Pavol Vican9887c682016-02-29 11:32:01 +0100183%type <uint> position_value_arg_str
Pavol Vican7a92f532016-03-10 10:12:03 +0100184%type <uint> extension_opt_stmt
Pavol Vicanbf805472016-01-26 14:24:56 +0100185%type <i> module_header_stmts
Pavol Vican35f4a8a2016-03-09 16:20:06 +0100186%type <i> submodule_header_stmts
Pavol Vican6eb14e82016-02-03 12:27:13 +0100187%type <str> tmp_identifier_arg_str
Pavol Vican9bcd7c62016-03-17 19:36:35 +0100188%type <str> message_opt_stmt
Pavol Vicane2368982016-03-19 14:37:56 +0100189%type <str> identity_opt_stmt
Pavol Vicane1354e92016-02-09 14:02:09 +0100190%type <i> status_stmt
Pavol Vican8658f4c2016-03-20 09:38:28 +0100191%type <i> status_read_stmt
Pavol Vicane1354e92016-02-09 14:02:09 +0100192%type <i> status_arg_str
Pavol Vicanb5687112016-02-09 22:35:59 +0100193%type <i> config_stmt
Pavol Vican4fb66c92016-03-17 10:32:27 +0100194%type <i> config_read_stmt
Pavol Vicanb5687112016-02-09 22:35:59 +0100195%type <i> config_arg_str
Pavol Vican8c82fa82016-02-10 13:13:24 +0100196%type <i> mandatory_stmt
Pavol Vicane4084022016-03-19 13:12:52 +0100197%type <i> mandatory_read_stmt
Pavol Vican8c82fa82016-02-10 13:13:24 +0100198%type <i> mandatory_arg_str
Pavol Vicanbe057c02016-02-11 19:08:08 +0100199%type <i> ordered_by_stmt
200%type <i> ordered_by_arg_str
Pavol Vican79a763d2016-02-25 15:41:27 +0100201%type <i> integer_value_arg_str
202%type <i> integer_value
Pavol Vican8658f4c2016-03-20 09:38:28 +0100203%type <i> feature_opt_stmt
Pavol Vican73e7c992016-02-24 12:18:05 +0100204%type <v> length_arg_str
Pavol Vican1c203db2016-02-24 14:05:23 +0100205%type <v> pattern_arg_str
Pavol Vicanaff5c802016-02-24 15:56:45 +0100206%type <v> range_arg_str
Pavol Vican79a763d2016-02-25 15:41:27 +0100207%type <v> enum_arg_str
Pavol Vican9887c682016-02-29 11:32:01 +0100208%type <v> bit_arg_str
Pavol Vicana4f045a2016-02-29 15:01:20 +0100209%type <v> union_spec
Pavol Vican0df02b02016-03-01 10:28:50 +0100210%type <v> typedef_arg_str
Pavol Vicanf37eeaa2016-02-09 20:54:06 +0100211%type <nodes> container_opt_stmt
Pavol Vican8c82fa82016-02-10 13:13:24 +0100212%type <nodes> anyxml_opt_stmt
Pavol Vican1f06ba82016-02-10 17:39:50 +0100213%type <nodes> choice_opt_stmt
Pavol Vicanbd098132016-02-11 10:56:49 +0100214%type <nodes> case_opt_stmt
Pavol Vican12f53c32016-02-11 11:40:00 +0100215%type <nodes> grouping_opt_stmt
Pavol Vican096c6db2016-02-11 15:08:10 +0100216%type <nodes> leaf_opt_stmt
Pavol Vican339d4ad2016-02-12 12:49:22 +0100217%type <nodes> leaf_list_opt_stmt
Pavol Vican5de33492016-02-22 14:03:24 +0100218%type <nodes> list_opt_stmt
Pavol Vican0df02b02016-03-01 10:28:50 +0100219%type <nodes> type_opt_stmt
Pavol Vican14b18562016-03-01 16:04:29 +0100220%type <nodes> uses_opt_stmt
Pavol Vican1003ead2016-03-02 12:24:52 +0100221%type <nodes> refine_body_opt_stmts
Pavol Vican92fa0dc2016-03-02 14:20:39 +0100222%type <nodes> augment_opt_stmt
Pavol Vican52ed67d2016-03-02 17:46:15 +0100223%type <nodes> rpc_opt_stmt
Pavol Vican531a9132016-03-03 10:10:09 +0100224%type <nodes> input_output_opt_stmt
Pavol Vican41267fd2016-03-03 10:47:42 +0100225%type <nodes> notification_opt_stmt
Pavol Vican220e5a12016-03-03 14:19:43 +0100226%type <nodes> deviation_opt_stmt
Pavol Vican85f12022016-03-05 16:30:35 +0100227%type <nodes> deviate_add_opt_stmt
Pavol Vicanc1f5a502016-03-06 16:51:26 +0100228%type <nodes> deviate_delete_opt_stmt
Pavol Vican4766aca2016-03-07 12:42:36 +0100229%type <nodes> deviate_replace_opt_stmt
Pavol Vican9b89dda2016-03-09 15:36:55 +0100230%type <inc> include_stmt
Pavol Vican6106f9c2016-03-24 08:08:53 +0100231%type <inc> import_stmt
Pavol Vican6eb14e82016-02-03 12:27:13 +0100232
233%destructor { free($$); } tmp_identifier_arg_str
Pavol Vican1f06ba82016-02-10 17:39:50 +0100234%destructor { if (read_all && $$.choice.s) { free($$.choice.s); } } choice_opt_stmt
Pavol Vican220e5a12016-03-03 14:19:43 +0100235%destructor { if (read_all) {
236 free($$.deviation);
237 }
238 } deviation_opt_stmt
Pavol Vicanbf805472016-01-26 14:24:56 +0100239
Pavol Vican6418deb2015-10-28 19:41:26 +0100240%%
241
Pavol Vican22afbdd2016-03-09 11:10:26 +0100242/* to simplify code, store the module/submodule being processed as trg */
243
Pavol Vicancae54882016-03-30 12:24:43 +0200244start: module_stmt
Pavol Vican0adf01d2016-03-22 12:29:33 +0100245 | submodule_stmt { if (read_all && lyp_propagate_submodule(module, submodule)) {
Pavol Vican75dbc5c2016-03-09 16:34:58 +0100246 YYERROR;
247 }
248 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100249
250
Pavol Vican1eeb1992016-02-09 11:10:45 +0100251string_1: STRING { if (read_all) {
Pavol Vican8760bb72016-04-07 09:44:01 +0200252 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 Vican1eeb1992016-02-09 11:10:45 +0100264 }
265 }
266 }
267optsep string_2
Pavol Vican6418deb2015-10-28 19:41:26 +0100268
269
Pavol Vicancae54882016-03-30 12:24:43 +0200270string_2: @EMPTYDIR@
271 | string_2 '+' optsep
Pavol Vican1c203db2016-02-24 14:05:23 +0100272 STRING { if (read_all){
Pavol Vican8760bb72016-04-07 09:44:01 +0200273 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 Vican1eeb1992016-02-09 11:10:45 +0100288 } else {
Pavol Vican8760bb72016-04-07 09:44:01 +0200289 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 Vican1eeb1992016-02-09 11:10:45 +0100298 }
299 }
300 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100301 optsep;
302
Pavol Vican22afbdd2016-03-09 11:10:26 +0100303module_stmt: optsep MODULE_KEYWORD sep identifier_arg_str { if (read_all) {
304 if (submodule) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100305 LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "module");
Pavol Vican22afbdd2016-03-09 11:10:26 +0100306 YYERROR;
307 }
308 trg = module;
Pavol Vican0adf01d2016-03-22 12:29:33 +0100309 yang_read_common(trg,s,MODULE_KEYWORD);
Pavol Vican22afbdd2016-03-09 11:10:26 +0100310 s = NULL;
Pavol Vican4fb66c92016-03-17 10:32:27 +0100311 config_inherit = ENABLE_INHERIT;
Pavol Vican22afbdd2016-03-09 11:10:26 +0100312 }
313 }
Pavol Vican1ca072c2016-02-03 13:03:56 +0100314 '{' stmtsep
Pavol Vican0adf01d2016-03-22 12:29:33 +0100315 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 Vican1ca072c2016-02-03 13:03:56 +0100317 }
Pavol Vican1eeb1992016-02-09 11:10:45 +0100318 linkage_stmts
Pavol Vican1ca072c2016-02-03 13:03:56 +0100319 meta_stmts
Pavol Vican1eeb1992016-02-09 11:10:45 +0100320 revision_stmts
Pavol Vican1ca072c2016-02-03 13:03:56 +0100321 body_stmts
322 '}' optsep
Pavol Vican6418deb2015-10-28 19:41:26 +0100323
Pavol Vicancae54882016-03-30 12:24:43 +0200324module_header_stmts: @EMPTYDIR@ { $$ = 0; }
Pavol Vican0adf01d2016-03-22 12:29:33 +0100325 | 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 Vican6418deb2015-10-28 19:41:26 +0100328 ;
329
Pavol Vican75dbc5c2016-03-09 16:34:58 +0100330submodule_stmt: optsep SUBMODULE_KEYWORD sep identifier_arg_str { if (read_all) {
331 if (!submodule) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100332 LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "submodule");
Pavol Vican75dbc5c2016-03-09 16:34:58 +0100333 YYERROR;
334 }
335 trg = (struct lys_module *)submodule;
Pavol Vican0adf01d2016-03-22 12:29:33 +0100336 yang_read_common(trg,s,MODULE_KEYWORD);
Pavol Vican75dbc5c2016-03-09 16:34:58 +0100337 s = NULL;
Pavol Vican4fb66c92016-03-17 10:32:27 +0100338 config_inherit = ENABLE_INHERIT;
Pavol Vican75dbc5c2016-03-09 16:34:58 +0100339 }
340 }
Pavol Vican35f4a8a2016-03-09 16:20:06 +0100341 '{' stmtsep
342 submodule_header_stmts { if (read_all && !submodule->prefix) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100343 LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "belongs-to", "submodule");
Pavol Vican35f4a8a2016-03-09 16:20:06 +0100344 YYERROR;
345 }
346 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100347 linkage_stmts
Pavol Vican75dbc5c2016-03-09 16:34:58 +0100348 meta_stmts
Pavol Vican6418deb2015-10-28 19:41:26 +0100349 revision_stmts
350 body_stmts
351 '}' optsep
352
Pavol Vicancae54882016-03-30 12:24:43 +0200353submodule_header_stmts: @EMPTYDIR@ { $$ = 0; }
Pavol Vican35f4a8a2016-03-09 16:20:06 +0100354 | submodule_header_stmts yang_version_stmt { if ($1) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100355 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "yang version", "submodule");
Pavol Vican35f4a8a2016-03-09 16:20:06 +0100356 YYERROR;
357 }
358 $$ = 1;
359 }
360 | submodule_header_stmts { if (read_all) {
361 if (submodule->prefix) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100362 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "belongs-to", "submodule");
Pavol Vican35f4a8a2016-03-09 16:20:06 +0100363 YYERROR;
364 }
365 }
366 }
367 belongs_to_stmt
Pavol Vicancae54882016-03-30 12:24:43 +0200368
Pavol Vican6418deb2015-10-28 19:41:26 +0100369yang_version_stmt: YANG_VERSION_KEYWORD sep yang_version_arg_str stmtend;
370
Pavol Vican802af1e2016-03-23 20:42:26 +0100371yang_version_arg_str: NON_NEGATIVE_INTEGER { if (strlen(yyget_text(scanner))!=1 || yyget_text(scanner)[0]!='1') {
372 YYERROR;
373 }
374 } optsep
Pavol Vican796d1fd2016-03-21 08:49:39 +0100375 | string_1 { if (read_all) {
376 if (strlen(s)!=1 || s[0]!='1') {
377 free(s);
378 YYERROR;
379 }
380 }
381 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100382
Pavol Vican1d684102016-03-23 10:18:54 +0100383namespace_stmt: NAMESPACE_KEYWORD sep string stmtend;
Pavol Vican6418deb2015-10-28 19:41:26 +0100384
Pavol Vicancae54882016-03-30 12:24:43 +0200385linkage_stmts: @EMPTYDIR@ { if (read_all) {
Pavol Vican9b89dda2016-03-09 15:36:55 +0100386 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 Vican1eeb1992016-02-09 11:10:45 +0100406 }
407 }
Pavol Vicancae54882016-03-30 12:24:43 +0200408 | linkage_stmts import_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +0100409 | linkage_stmts include_stmt
410 ;
411
Pavol Vican6eb14e82016-02-03 12:27:13 +0100412import_stmt: IMPORT_KEYWORD sep tmp_identifier_arg_str {
Pavol Vican1eeb1992016-02-09 11:10:45 +0100413 if (!read_all) {
414 size_arrays->imp++;
415 } else {
Pavol Vican22afbdd2016-03-09 11:10:26 +0100416 actual = &trg->imp[trg->imp_size];
Pavol Vican1eeb1992016-02-09 11:10:45 +0100417 }
Pavol Vican6eb14e82016-02-03 12:27:13 +0100418 }
419 '{' stmtsep
Pavol Vican1eeb1992016-02-09 11:10:45 +0100420 prefix_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100421 if (yang_read_prefix(trg, actual, s, IMPORT_KEYWORD)) {YYERROR;}
Pavol Vican1eeb1992016-02-09 11:10:45 +0100422 s=NULL;
423 actual_type=IMPORT_KEYWORD;
424 }
425 }
Pavol Vican6eb14e82016-02-03 12:27:13 +0100426 revision_date_opt
Pavol Vican6106f9c2016-03-24 08:08:53 +0100427 '}' 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 Vican6eb14e82016-02-03 12:27:13 +0100436
437tmp_identifier_arg_str: identifier_arg_str { $$ = s; s = NULL; }
Pavol Vican6418deb2015-10-28 19:41:26 +0100438
Pavol Vican55870412016-03-10 12:36:21 +0100439include_stmt: INCLUDE_KEYWORD sep identifier_arg_str { if (read_all) {
Pavol Vican9b89dda2016-03-09 15:36:55 +0100440 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 Vican0adf01d2016-03-22 12:29:33 +0100449 if (yang_fill_include(module, submodule, s, rev, size_arrays->inc, unres)) {
Pavol Vican9b89dda2016-03-09 15:36:55 +0100450 YYERROR;
451 }
452 size_arrays->inc++;
Pavol Vican55870412016-03-10 12:36:21 +0100453 s = NULL;
Pavol Vican9b89dda2016-03-09 15:36:55 +0100454 trg = $$;
Pavol Vican6106f9c2016-03-24 08:08:53 +0100455 config_inherit = ENABLE_INHERIT;
Pavol Vican9b89dda2016-03-09 15:36:55 +0100456 }
457 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100458
459include_end: ';'
460 | '{' stmtsep
Pavol Vicancae54882016-03-30 12:24:43 +0200461 revision_date_opt
Pavol Vican6418deb2015-10-28 19:41:26 +0100462 '}'
Pavol Vican6418deb2015-10-28 19:41:26 +0100463
Pavol Vicancae54882016-03-30 12:24:43 +0200464revision_date_opt: @EMPTYDIR@
Pavol Vican6418deb2015-10-28 19:41:26 +0100465 | revision_date_stmt;
466
Pavol Vican6eb14e82016-02-03 12:27:13 +0100467revision_date_stmt: REVISION_DATE_KEYWORD sep revision_date optsep stmtend;
468
Pavol Vican1eeb1992016-02-09 11:10:45 +0100469revision_date: REVISION_DATE { if (read_all) {
470 if (actual_type==IMPORT_KEYWORD) {
Pavol Vican802af1e2016-03-23 20:42:26 +0100471 memcpy(((struct lys_import *)actual)->rev, yyget_text(scanner), LY_REV_SIZE-1);
Pavol Vican1eeb1992016-02-09 11:10:45 +0100472 } else { // INCLUDE KEYWORD
Pavol Vican802af1e2016-03-23 20:42:26 +0100473 memcpy(rev, yyget_text(scanner), LY_REV_SIZE - 1);
Pavol Vican1eeb1992016-02-09 11:10:45 +0100474 }
Pavol Vican6eb14e82016-02-03 12:27:13 +0100475 }
476 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100477
Pavol Vican6a2f0672016-03-09 15:52:18 +0100478belongs_to_stmt: BELONGS_TO_KEYWORD sep identifier_arg_str { if (read_all) {
Pavol Vican1835e792016-03-21 09:13:53 +0100479 if (!ly_strequal(s, submodule->belongsto->name, 0)) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100480 LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "belongs-to");
Pavol Vican6a2f0672016-03-09 15:52:18 +0100481 free(s);
482 YYERROR;
483 }
484 free(s);
485 s = NULL;
486 }
487 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100488 '{' stmtsep
Pavol Vican6a2f0672016-03-09 15:52:18 +0100489 prefix_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100490 if (yang_read_prefix(trg, NULL, s, MODULE_KEYWORD)) {
Pavol Vican6a2f0672016-03-09 15:52:18 +0100491 YYERROR;
492 }
Pavol Vican6a2f0672016-03-09 15:52:18 +0100493 s = NULL;
494 }
495 }
Pavol Vican2d59b7e2016-03-09 21:32:51 +0100496 '}' stmtsep
Pavol Vican6418deb2015-10-28 19:41:26 +0100497
498prefix_stmt: PREFIX_KEYWORD sep prefix_arg_str stmtend;
499
Pavol Vicancae54882016-03-30 12:24:43 +0200500meta_stmts: @EMPTYDIR@
Pavol Vican0adf01d2016-03-22 12:29:33 +0100501 | 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 Vican9bcd7c62016-03-17 19:36:35 +0100504 YYERROR;
505 }
506 s = NULL;
507 }
Pavol Vican0adf01d2016-03-22 12:29:33 +0100508 | meta_stmts reference_stmt { if (read_all && yang_read_reference(trg, NULL, s, NULL)) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +0100509 YYERROR;
510 }
511 s=NULL;
512 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100513
514organization_stmt: ORGANIZATION_KEYWORD sep string stmtend;
515
516contact_stmt: CONTACT_KEYWORD sep string stmtend;
517
518description_stmt: DESCRIPTION_KEYWORD sep string stmtend;
519
520reference_stmt: REFERENCE_KEYWORD sep string stmtend;
521
Pavol Vicancae54882016-03-30 12:24:43 +0200522revision_stmts: @EMPTYDIR@ { if (read_all && size_arrays->rev) {
Pavol Vican22afbdd2016-03-09 11:10:26 +0100523 trg->rev = calloc(size_arrays->rev, sizeof *trg->rev);
Pavol Vicanfb8ded62016-03-21 09:43:58 +0100524 if (!trg->rev) {
525 LOGMEM;
526 YYERROR;
527 }
Pavol Vican1eeb1992016-02-09 11:10:45 +0100528 }
529 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100530 | revision_stmts revision_stmt stmtsep;
531
Pavol Vican1eeb1992016-02-09 11:10:45 +0100532
533revision_stmt: REVISION_KEYWORD sep date_arg_str { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +0100534 if(!(actual=yang_read_revision(trg,s))) {YYERROR;}
Pavol Vican1eeb1992016-02-09 11:10:45 +0100535 s=NULL;
536 } else {
537 size_arrays->rev++;
538 }
539 }
Pavol Vicanbedff692016-02-03 14:29:17 +0100540 revision_end;
Pavol Vican6418deb2015-10-28 19:41:26 +0100541
542revision_end: ';'
Pavol Vicanbedff692016-02-03 14:29:17 +0100543 | '{' stmtsep { actual_type = REVISION_KEYWORD; }
Pavol Vican9bcd7c62016-03-17 19:36:35 +0100544 revision_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +0100545 '}'
546 ;
547
Pavol Vicancae54882016-03-30 12:24:43 +0200548revision_opt_stmt: @EMPTYDIR@
Pavol Vican0adf01d2016-03-22 12:29:33 +0100549 | revision_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, "revision")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +0100550 YYERROR;
551 }
552 s = NULL;
553 }
Pavol Vican0adf01d2016-03-22 12:29:33 +0100554 | revision_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, "revision")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +0100555 YYERROR;
556 }
557 s = NULL;
558 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100559 ;
560
Pavol Vican1eeb1992016-02-09 11:10:45 +0100561date_arg_str: REVISION_DATE { if (read_all) {
Pavol Vican802af1e2016-03-23 20:42:26 +0100562 s = strdup(yyget_text(scanner));
Pavol Vican1eeb1992016-02-09 11:10:45 +0100563 if (!s) {
564 LOGMEM;
565 YYERROR;
566 }
567 }
568 }
569 optsep
Pavol Vican0adf01d2016-03-22 12:29:33 +0100570 | string_1 { if (read_all && lyp_check_date(s)) {
Pavol Vican796d1fd2016-03-21 08:49:39 +0100571 free(s);
572 YYERROR;
573 }
574 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100575
Pavol Vicancae54882016-03-30 12:24:43 +0200576body_stmts: @EMPTYDIR@ { if (read_all) {
Pavol Vican9f989972016-03-02 14:44:11 +0100577 if (size_arrays->features) {
Pavol Vican22afbdd2016-03-09 11:10:26 +0100578 trg->features = calloc(size_arrays->features,sizeof *trg->features);
579 if (!trg->features) {
Pavol Vican9f989972016-03-02 14:44:11 +0100580 LOGMEM;
581 YYERROR;
582 }
583 }
584 if (size_arrays->ident) {
Pavol Vican22afbdd2016-03-09 11:10:26 +0100585 trg->ident = calloc(size_arrays->ident,sizeof *trg->ident);
586 if (!trg->ident) {
Pavol Vican9f989972016-03-02 14:44:11 +0100587 LOGMEM;
588 YYERROR;
589 }
590 }
591 if (size_arrays->augment) {
Pavol Vican22afbdd2016-03-09 11:10:26 +0100592 trg->augment = calloc(size_arrays->augment,sizeof *trg->augment);
593 if (!trg->augment) {
Pavol Vican9f989972016-03-02 14:44:11 +0100594 LOGMEM;
595 YYERROR;
596 }
597 }
Pavol Vican0df02b02016-03-01 10:28:50 +0100598 if (size_arrays->tpdf) {
Pavol Vican22afbdd2016-03-09 11:10:26 +0100599 trg->tpdf = calloc(size_arrays->tpdf, sizeof *trg->tpdf);
600 if (!trg->tpdf) {
Pavol Vican0df02b02016-03-01 10:28:50 +0100601 LOGMEM;
602 YYERROR;
603 }
604 }
Pavol Vican220e5a12016-03-03 14:19:43 +0100605 if (size_arrays->deviation) {
Pavol Vican22afbdd2016-03-09 11:10:26 +0100606 trg->deviation = calloc(size_arrays->deviation, sizeof *trg->deviation);
607 if (!trg->deviation) {
Pavol Vican220e5a12016-03-03 14:19:43 +0100608 LOGMEM;
609 YYERROR;
610 }
Pavol Vican2d59b7e2016-03-09 21:32:51 +0100611 /* module with deviation - must be implemented (description of /ietf-yang-library:modules-state/module/deviation) */
612 module->implemented = 1;
Pavol Vican220e5a12016-03-03 14:19:43 +0100613 }
Pavol Vican5de33492016-02-22 14:03:24 +0100614 actual = NULL;
Pavol Vicane1354e92016-02-09 14:02:09 +0100615 }
616 }
Pavol Vicanf37eeaa2016-02-09 20:54:06 +0100617 | body_stmts body_stmt stmtsep { actual = NULL; }
Pavol Vican6418deb2015-10-28 19:41:26 +0100618
Pavol Vicane1354e92016-02-09 14:02:09 +0100619
Pavol Vican6418deb2015-10-28 19:41:26 +0100620body_stmt: extension_stmt
621 | feature_stmt
622 | identity_stmt
Pavol Vican0df02b02016-03-01 10:28:50 +0100623 | typedef_stmt { if (!read_all) { size_arrays->tpdf++; } }
Pavol Vican6418deb2015-10-28 19:41:26 +0100624 | grouping_stmt
625 | data_def_stmt
Pavol Vican4fb66c92016-03-17 10:32:27 +0100626 | augment_stmt { if (!read_all) {
627 size_arrays->augment++;
628 } else {
629 config_inherit = ENABLE_INHERIT;
630 }
631 }
Pavol Vicancae54882016-03-30 12:24:43 +0200632 | rpc_stmt
633 | notification_stmt
Pavol Vican220e5a12016-03-03 14:19:43 +0100634 | deviation_stmt { if (!read_all) { size_arrays->deviation++; } }
Pavol Vican6418deb2015-10-28 19:41:26 +0100635
Pavol Vican7a92f532016-03-10 10:12:03 +0100636extension_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 Vican6418deb2015-10-28 19:41:26 +0100654
Pavol Vicancae54882016-03-30 12:24:43 +0200655extension_end: ';'
Pavol Vican7a92f532016-03-10 10:12:03 +0100656 | '{' stmtsep
657 extension_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +0100658 '}'
Pavol Vican6418deb2015-10-28 19:41:26 +0100659
Pavol Vicancae54882016-03-30 12:24:43 +0200660extension_opt_stmt: @EMPTYDIR@ { $$ = 0; }
Pavol Vican7a92f532016-03-10 10:12:03 +0100661 | extension_opt_stmt argument_stmt { if ($1 & EXTENSION_ARG) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100662 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "argument", "extension");
Pavol Vican7a92f532016-03-10 10:12:03 +0100663 YYERROR;
664 }
665 $1 |= EXTENSION_ARG;
666 $$ = $1;
667 }
668 | extension_opt_stmt status_stmt { if ($1 & EXTENSION_STA) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100669 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "status", "extension");
Pavol Vican7a92f532016-03-10 10:12:03 +0100670 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 Vican0adf01d2016-03-22 12:29:33 +0100680 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "description", "extension");
Pavol Vican7a92f532016-03-10 10:12:03 +0100681 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 Vican0adf01d2016-03-22 12:29:33 +0100691 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "reference", "extension");
Pavol Vican7a92f532016-03-10 10:12:03 +0100692 YYERROR;
693 }
694 $1 |= EXTENSION_REF;
695 $$ = $1;
696 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100697
Pavol Vican7a92f532016-03-10 10:12:03 +0100698argument_stmt: ARGUMENT_KEYWORD sep identifier_arg_str { free(s); s = NULL; } argument_end stmtsep;
Pavol Vicancae54882016-03-30 12:24:43 +0200699
Pavol Vican6418deb2015-10-28 19:41:26 +0100700argument_end: ';'
701 | '{' stmtsep
702 yin_element_stmt
703 '}'
Pavol Vican6418deb2015-10-28 19:41:26 +0100704
705yin_element_stmt: YIN_ELEMENT_KEYWORD sep yin_element_arg_str stmtend;
706
707yin_element_arg_str: TRUE_KEYWORD optsep
708 | FALSE_KEYWORD optsep
Pavol Vican7a92f532016-03-10 10:12:03 +0100709 | string_1 { if (read_all) {
710 if (strcmp(s, "true") && strcmp(s, "false")) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100711 LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, s);
Pavol Vican7a92f532016-03-10 10:12:03 +0100712 free(s);
713 YYERROR;
714 }
715 free(s);
716 s = NULL;
717 }
718 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100719
Pavol Vicane1354e92016-02-09 14:02:09 +0100720status_stmt: STATUS_KEYWORD sep status_arg_str stmtend { $$ = $3; }
Pavol Vican6418deb2015-10-28 19:41:26 +0100721
Pavol Vican8658f4c2016-03-20 09:38:28 +0100722status_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 Vicane1354e92016-02-09 14:02:09 +0100726status_arg_str: CURRENT_KEYWORD optsep { $$ = LYS_STATUS_CURR; }
727 | OBSOLETE_KEYWORD optsep { $$ = LYS_STATUS_OBSLT; }
728 | DEPRECATED_KEYWORD optsep { $$ = LYS_STATUS_DEPRC; }
Pavol Vican7a92f532016-03-10 10:12:03 +0100729 | 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 Vican0adf01d2016-03-22 12:29:33 +0100737 LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, s);
Pavol Vican7a92f532016-03-10 10:12:03 +0100738 free(s);
739 YYERROR;
740 }
741 free(s);
742 s = NULL;
743 }
744 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100745
Pavol Vicane1354e92016-02-09 14:02:09 +0100746feature_stmt: FEATURE_KEYWORD sep identifier_arg_str { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100747 if (!(actual = yang_read_feature(trg, s))) {YYERROR;}
Pavol Vicancae54882016-03-30 12:24:43 +0200748 s=NULL;
Pavol Vicane1354e92016-02-09 14:02:09 +0100749 } else {
750 size_arrays->features++;
Pavol Vicane1354e92016-02-09 14:02:09 +0100751 }
752 }
Pavol Vicana55cbb42016-03-21 20:15:26 +0100753 feature_end
Pavol Vican6418deb2015-10-28 19:41:26 +0100754
Pavol Vicancae54882016-03-30 12:24:43 +0200755feature_end: ';'
Pavol Vicane1354e92016-02-09 14:02:09 +0100756 | '{' stmtsep
Pavol Vicanf37eeaa2016-02-09 20:54:06 +0100757 feature_opt_stmt
Pavol Vicancae54882016-03-30 12:24:43 +0200758 '}'
Pavol Vican6418deb2015-10-28 19:41:26 +0100759 ;
760
Pavol Vicancae54882016-03-30 12:24:43 +0200761feature_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vican8658f4c2016-03-20 09:38:28 +0100762 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 Vicane1354e92016-02-09 14:02:09 +0100769 }
Pavol Vican8658f4c2016-03-20 09:38:28 +0100770 store_flags((struct lys_node *)actual, size_arrays->node[size_arrays->next].flags, 0);
Pavol Vicana55cbb42016-03-21 20:15:26 +0100771 size_arrays->next++;
Pavol Vican8658f4c2016-03-20 09:38:28 +0100772 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +0100773 $$ = size_arrays->size;
774 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
775 LOGMEM;
776 YYERROR;
777 }
Pavol Vicancae54882016-03-30 12:24:43 +0200778 }
Pavol Vicane1354e92016-02-09 14:02:09 +0100779 }
780 | feature_opt_stmt if_feature_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100781 if (yang_read_if_feature(trg, actual, s, unres, FEATURE_KEYWORD)) {YYERROR;}
Pavol Vicancae54882016-03-30 12:24:43 +0200782 s=NULL;
Pavol Vicane1354e92016-02-09 14:02:09 +0100783 } else {
Pavol Vican8658f4c2016-03-20 09:38:28 +0100784 size_arrays->node[$1].if_features++;
Pavol Vicane1354e92016-02-09 14:02:09 +0100785 }
786 }
Pavol Vican8658f4c2016-03-20 09:38:28 +0100787 | feature_opt_stmt status_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100788 if (yang_check_flags(&size_arrays->node[$1].flags, LYS_STATUS_MASK, "status", "feature", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +0100789 YYERROR;
790 }
791 }
792 }
Pavol Vican0adf01d2016-03-22 12:29:33 +0100793 | feature_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, "feature")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +0100794 YYERROR;
795 }
796 s = NULL;
797 }
Pavol Vican0adf01d2016-03-22 12:29:33 +0100798 | feature_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, "feature")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +0100799 YYERROR;
800 }
801 s = NULL;
802 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100803
804if_feature_stmt: IF_FEATURE_KEYWORD sep identifier_ref_arg_str stmtend;
805
Pavol Vicanbbdef532016-02-09 14:52:12 +0100806identity_stmt: IDENTITY_KEYWORD sep identifier_arg_str { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +0100807 if (!(actual = yang_read_identity(trg,s))) {YYERROR;}
Pavol Vicanbbdef532016-02-09 14:52:12 +0100808 s = NULL;
809 } else {
810 size_arrays->ident++;
811 }
812 }
813 identity_end;
Pavol Vican6418deb2015-10-28 19:41:26 +0100814
Pavol Vicancae54882016-03-30 12:24:43 +0200815identity_end: ';'
Pavol Vicanbbdef532016-02-09 14:52:12 +0100816 | '{' stmtsep
Pavol Vican0adf01d2016-03-22 12:29:33 +0100817 identity_opt_stmt { if (read_all && yang_read_base(module, actual, $3, unres)) {
Pavol Vicane2368982016-03-19 14:37:56 +0100818 YYERROR;
819 }
820 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100821 '}'
822 ;
823
Pavol Vicancae54882016-03-30 12:24:43 +0200824identity_opt_stmt: @EMPTYDIR@ { $$ = NULL; }
Pavol Vicane2368982016-03-19 14:37:56 +0100825 | identity_opt_stmt base_stmt { if (read_all) {
826 if ($1) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100827 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "base", "identity");
Pavol Vicane2368982016-03-19 14:37:56 +0100828 free(s);
829 free($1);
830 YYERROR;
831 }
832 $$ = s;
Pavol Vicane2368982016-03-19 14:37:56 +0100833 s = NULL;
834 }
835 }
Pavol Vican8658f4c2016-03-20 09:38:28 +0100836 | identity_opt_stmt status_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100837 if (yang_check_flags(&((struct lys_ident *)actual)->flags, LYS_STATUS_MASK, "status", "identity", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +0100838 YYERROR;
839 }
Pavol Vicane2368982016-03-19 14:37:56 +0100840 }
841 }
Pavol Vican0adf01d2016-03-22 12:29:33 +0100842 | identity_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, "identity")) {
Pavol Vicane2368982016-03-19 14:37:56 +0100843 free($1);
Pavol Vican9bcd7c62016-03-17 19:36:35 +0100844 YYERROR;
845 }
846 s = NULL;
847 }
Pavol Vican0adf01d2016-03-22 12:29:33 +0100848 | identity_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, "identity")) {
Pavol Vicane2368982016-03-19 14:37:56 +0100849 free($1);
Pavol Vicanf5fe9662016-03-17 20:00:16 +0100850 YYERROR;
851 }
852 s = NULL;
853 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100854
855base_stmt: BASE_KEYWORD sep identifier_ref_arg_str stmtend;
856
Pavol Vican0df02b02016-03-01 10:28:50 +0100857typedef_stmt: TYPEDEF_KEYWORD sep typedef_arg_str
858 '{' stmtsep
859 type_opt_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +0100860 if (!($6.node.flag & LYS_TYPE_DEF)) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100861 LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "type", "typedef");
Pavol Vican0df02b02016-03-01 10:28:50 +0100862 YYERROR;
863 }
Pavol Vicand946c0d2016-03-23 12:53:08 +0100864 if (unres_schema_add_node(trg, unres, &$6.node.ptr_tpdf->type, UNRES_TYPE_DER,(struct lys_node *) $3)) {
Pavol Vican0df02b02016-03-01 10:28:50 +0100865 YYERROR;
866 }
867 actual = $3;
868
869 /* check default value */
Pavol Vicand946c0d2016-03-23 12:53:08 +0100870 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 Vican0df02b02016-03-01 10:28:50 +0100872 YYERROR;
873 }
874 }
875 }
876 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100877 '}' ;
Pavol Vican0df02b02016-03-01 10:28:50 +0100878
879typedef_arg_str: identifier_arg_str { if (read_all) {
880 $$ = actual;
Pavol Vican0adf01d2016-03-22 12:29:33 +0100881 if (!(actual = yang_read_typedef(trg, actual, s))) {
Pavol Vican0df02b02016-03-01 10:28:50 +0100882 YYERROR;
883 }
884 s = NULL;
885 actual_type = TYPEDEF_KEYWORD;
886 }
887 }
Pavol Vicancae54882016-03-30 12:24:43 +0200888
Pavol Vican0adf01d2016-03-22 12:29:33 +0100889type_stmt: TYPE_KEYWORD sep identifier_ref_arg_str { if (read_all && !(actual = yang_read_type(trg, actual, s, actual_type))) {
Pavol Vican73e7c992016-02-24 12:18:05 +0100890 YYERROR;
891 }
892 s = NULL;
893 }
Pavol Vicanf4717e62016-03-16 11:30:01 +0100894 type_end;
Pavol Vican6418deb2015-10-28 19:41:26 +0100895
Pavol Vicancae54882016-03-30 12:24:43 +0200896type_opt_stmt: @EMPTYDIR@ { $$.node.ptr_tpdf = actual;
Pavol Vican802af1e2016-03-23 20:42:26 +0100897 $$.node.flag = 0;
898 }
Pavol Vicand946c0d2016-03-23 12:53:08 +0100899 | 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 Vican0df02b02016-03-01 10:28:50 +0100901 YYERROR;
902 }
903 }
Pavol Vicanf4717e62016-03-16 11:30:01 +0100904 type_stmt stmtsep { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +0100905 actual = $1.node.ptr_tpdf;
Pavol Vican0df02b02016-03-01 10:28:50 +0100906 actual_type = TYPEDEF_KEYWORD;
Pavol Vicand946c0d2016-03-23 12:53:08 +0100907 $1.node.flag |= LYS_TYPE_DEF;
Pavol Vican0df02b02016-03-01 10:28:50 +0100908 $$ = $1;
909 }
910 }
Pavol Vicand946c0d2016-03-23 12:53:08 +0100911 | 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 Vican0df02b02016-03-01 10:28:50 +0100913 YYERROR;
914 }
915 s = NULL;
Pavol Vican0df02b02016-03-01 10:28:50 +0100916 $$ = $1;
917 }
Pavol Vican8658f4c2016-03-20 09:38:28 +0100918 | type_opt_stmt status_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +0100919 if (yang_check_flags(&$1.node.ptr_tpdf->flags, LYS_STATUS_MASK, "status", "typedef", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +0100920 YYERROR;
921 }
922 }
923 }
Pavol Vicand946c0d2016-03-23 12:53:08 +0100924 | type_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.node.ptr_tpdf, s, "typedef")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +0100925 YYERROR;
926 }
927 s = NULL;
928 }
Pavol Vicand946c0d2016-03-23 12:53:08 +0100929 | type_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.node.ptr_tpdf, s, "typedef")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +0100930 YYERROR;
931 }
932 s = NULL;
933 }
Pavol Vican6418deb2015-10-28 19:41:26 +0100934
Pavol Vicancae54882016-03-30 12:24:43 +0200935type_end: ';'
Pavol Vican1c203db2016-02-24 14:05:23 +0100936 | '{' stmtsep
937 type_body_stmts
Pavol Vican6418deb2015-10-28 19:41:26 +0100938 '}'
939 ;
940
941
Pavol Vicana4f045a2016-02-29 15:01:20 +0100942type_body_stmts: decimal_string_restrictions
Pavol Vicancae54882016-03-30 12:24:43 +0200943 | enum_specification
Pavol Vican191613a2016-02-26 16:21:32 +0100944 | path_stmt { /*leafref_specification */
945 if (read_all) {
Pavol Vican6b072512016-04-04 10:50:21 +0200946 ((struct yang_type *)actual)->base = LY_TYPE_LEAFREF;
Pavol Vican22afbdd2016-03-09 11:10:26 +0100947 ((struct yang_type *)actual)->type->info.lref.path = lydict_insert_zc(trg->ctx, s);
Pavol Vican191613a2016-02-26 16:21:32 +0100948 s = NULL;
949 }
950 }
Pavol Vican1ff0e222016-02-26 12:27:01 +0100951 | base_stmt { /*identityref_specification */
952 if (read_all) {
953 ((struct yang_type *)actual)->flags |= LYS_TYPE_BASE;
Pavol Vican6b072512016-04-04 10:50:21 +0200954 ((struct yang_type *)actual)->base = LY_TYPE_LEAFREF;
Pavol Vican22afbdd2016-03-09 11:10:26 +0100955 ((struct yang_type *)actual)->type->info.lref.path = lydict_insert_zc(trg->ctx, s);
Pavol Vican1ff0e222016-02-26 12:27:01 +0100956 s = NULL;
957 }
958 }
Pavol Vican7dddedc2016-02-26 16:54:03 +0100959 | require_instance_stmt { /*instance_identifier_specification */
960 if (read_all) {
Pavol Vican6b072512016-04-04 10:50:21 +0200961 ((struct yang_type *)actual)->base = LY_TYPE_INST;
Pavol Vican7dddedc2016-02-26 16:54:03 +0100962 }
963 }
Pavol Vicancae54882016-03-30 12:24:43 +0200964 | bits_specification
Pavol Vican6418deb2015-10-28 19:41:26 +0100965 ;
966
967
Pavol Vicancae54882016-03-30 12:24:43 +0200968decimal_string_restrictions: @EMPTYDIR@ { if (read_all) {
Pavol Vicana55cbb42016-03-21 20:15:26 +0100969 if (size_arrays->node[size_arrays->next].uni && size_arrays->node[size_arrays->next].pattern) {
Pavol Vican0adf01d2016-03-22 12:29:33 +0100970 LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid restriction in type \"%s\".", ((struct yang_type *)actual)->type->parent->name);
Pavol Vicana4f045a2016-02-29 15:01:20 +0100971 YYERROR;
972 }
Pavol Vicana55cbb42016-03-21 20:15:26 +0100973 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 Vican1c203db2016-02-24 14:05:23 +0100975 if (!((struct yang_type *)actual)->type->info.str.patterns) {
976 LOGMEM;
977 YYERROR;
978 }
Pavol Vican6b072512016-04-04 10:50:21 +0200979 ((struct yang_type *)actual)->base = LY_TYPE_STRING;
Pavol Vican1c203db2016-02-24 14:05:23 +0100980 }
Pavol Vicana55cbb42016-03-21 20:15:26 +0100981 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 Vicana4f045a2016-02-29 15:01:20 +0100983 if (!((struct yang_type *)actual)->type->info.uni.types) {
984 LOGMEM;
985 YYERROR;
986 }
Pavol Vican6b072512016-04-04 10:50:21 +0200987 ((struct yang_type *)actual)->base = LY_TYPE_UNION;
Pavol Vicana4f045a2016-02-29 15:01:20 +0100988 }
989 size_arrays->next++;
Pavol Vican1c203db2016-02-24 14:05:23 +0100990 } 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 Vican73e7c992016-02-24 12:18:05 +0100998 | decimal_string_restrictions length_stmt
Pavol Vican1c203db2016-02-24 14:05:23 +0100999 | decimal_string_restrictions pattern_stmt { if (!read_all) {
Pavol Vicana55cbb42016-03-21 20:15:26 +01001000 size_arrays->node[$1].pattern++; /* count of pattern*/
Pavol Vican1c203db2016-02-24 14:05:23 +01001001 }
1002 }
Pavol Vican73e7c992016-02-24 12:18:05 +01001003 | decimal_string_restrictions fraction_digits_stmt
1004 | decimal_string_restrictions range_stmt stmtsep
Pavol Vicanf4717e62016-03-16 11:30:01 +01001005 | decimal_string_restrictions union_spec type_stmt stmtsep { if (read_all) {
Pavol Vicana55cbb42016-03-21 20:15:26 +01001006 actual = $2;
1007 } else {
1008 size_arrays->node[$1].uni++; /* count of union*/
1009 }
1010 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001011 ;
1012
Pavol Vicancae54882016-03-30 12:24:43 +02001013 union_spec: @EMPTYDIR@ { if (read_all) {
Pavol Vicana4f045a2016-02-29 15:01:20 +01001014 struct yang_type *typ;
1015 struct lys_type *type;
Pavol Vican6418deb2015-10-28 19:41:26 +01001016
Pavol Vicana4f045a2016-02-29 15:01:20 +01001017 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 Vican6418deb2015-10-28 19:41:26 +01001025
Pavol Vican07ea68d2016-02-25 12:01:37 +01001026fraction_digits_stmt: FRACTION_DIGITS_KEYWORD sep fraction_digits_arg_str
Pavol Vican0adf01d2016-03-22 12:29:33 +01001027 stmtend { if (read_all && yang_read_fraction(actual, $3)) {
Pavol Vican07ea68d2016-02-25 12:01:37 +01001028 YYERROR;
1029 }
1030 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001031
Pavol Vican07ea68d2016-02-25 12:01:37 +01001032fraction_digits_arg_str: positive_integer_value optsep { $$ = $1; }
1033 | string_1 { if (read_all) {
Pavol Vican07ea68d2016-02-25 12:01:37 +01001034 char *endptr = NULL;
1035 unsigned long val;
1036
1037 val = strtoul(s, &endptr, 10);
Pavol Vican802af1e2016-03-23 20:42:26 +01001038 if (*endptr || s[0] == '-' || val == 0 || val > UINT32_MAX) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001039 LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "fraction-digits");
Pavol Vican07ea68d2016-02-25 12:01:37 +01001040 free(s);
1041 s = NULL;
1042 YYERROR;
1043 }
1044 $$ = (uint32_t) val;
1045 free(s);
1046 s =NULL;
1047 }
1048 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001049 ;
1050
Pavol Vican73e7c992016-02-24 12:18:05 +01001051length_stmt: LENGTH_KEYWORD sep length_arg_str length_end stmtsep { actual = $3;
1052 actual_type = TYPE_KEYWORD;
1053 }
1054
1055length_arg_str: string { if (read_all) {
1056 $$ = actual;
Pavol Vican0adf01d2016-03-22 12:29:33 +01001057 if (!(actual = yang_read_length(trg, actual, s))) {
Pavol Vican73e7c992016-02-24 12:18:05 +01001058 YYERROR;
1059 }
1060 actual_type = LENGTH_KEYWORD;
Pavol Vican1c203db2016-02-24 14:05:23 +01001061 s = NULL;
Pavol Vican73e7c992016-02-24 12:18:05 +01001062 }
1063 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001064
Pavol Vicancae54882016-03-30 12:24:43 +02001065length_end: ';'
Pavol Vican73e7c992016-02-24 12:18:05 +01001066 | '{' stmtsep
1067 message_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01001068 '}'
Pavol Vicancae54882016-03-30 12:24:43 +02001069 ;
Pavol Vican6418deb2015-10-28 19:41:26 +01001070
Pavol Vicancae54882016-03-30 12:24:43 +02001071message_opt_stmt: @EMPTYDIR@ { switch (actual_type) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01001072 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 Vican0adf01d2016-03-22 12:29:33 +01001086 | message_opt_stmt error_message_stmt { if (read_all && yang_read_message(trg, actual, s, $1, ERROR_MESSAGE_KEYWORD)) {
Pavol Vicana3436942016-03-21 09:25:52 +01001087 YYERROR;
1088 }
1089 s = NULL;
1090 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01001091 | message_opt_stmt error_app_tag_stmt { if (yang_read_message(trg, actual, s, $1, ERROR_APP_TAG_KEYWORD)) {
Pavol Vicana3436942016-03-21 09:25:52 +01001092 YYERROR;
1093 }
1094 s = NULL;
1095 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01001096 | message_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, $1)) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01001097 YYERROR;
1098 }
1099 s = NULL;
1100 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01001101 | message_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, $1)) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01001102 YYERROR;
1103 }
1104 s = NULL;
1105 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001106
Pavol Vican1c203db2016-02-24 14:05:23 +01001107pattern_stmt: PATTERN_KEYWORD sep pattern_arg_str pattern_end stmtsep { actual = $3;
1108 actual_type = TYPE_KEYWORD;
1109 }
1110
1111pattern_arg_str: string { if (read_all) {
1112 $$ = actual;
Pavol Vican0adf01d2016-03-22 12:29:33 +01001113 if (!(actual = yang_read_pattern(trg, actual, s))) {
Pavol Vican1c203db2016-02-24 14:05:23 +01001114 YYERROR;
1115 }
1116 actual_type = PATTERN_KEYWORD;
1117 s = NULL;
1118 }
1119 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001120
1121pattern_end: ';'
Pavol Vican1c203db2016-02-24 14:05:23 +01001122 | '{' stmtsep
1123 message_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01001124 '}'
Pavol Vicancae54882016-03-30 12:24:43 +02001125 ;
Pavol Vican6418deb2015-10-28 19:41:26 +01001126
Pavol Vican79a763d2016-02-25 15:41:27 +01001127enum_specification: { if (read_all) {
Pavol Vicana55cbb42016-03-21 20:15:26 +01001128 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 Vicanfb8ded62016-03-21 09:43:58 +01001130 if (!((struct yang_type *)actual)->type->info.enums.enm) {
1131 LOGMEM;
1132 YYERROR;
1133 }
Pavol Vican79a763d2016-02-25 15:41:27 +01001134 }
Pavol Vican6b072512016-04-04 10:50:21 +02001135 ((struct yang_type *)actual)->base = LY_TYPE_ENUM;
Pavol Vican9887c682016-02-29 11:32:01 +01001136 cnt_val = 0;
Pavol Vican79a763d2016-02-25 15:41:27 +01001137 } 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 Vican6418deb2015-10-28 19:41:26 +01001144
Pavol Vicancae54882016-03-30 12:24:43 +02001145enum_stmts: @EMPTYDIR@
Pavol Vican79a763d2016-02-25 15:41:27 +01001146 | enum_stmts enum_stmt stmtsep;
Pavol Vican6418deb2015-10-28 19:41:26 +01001147
1148
Pavol Vican79a763d2016-02-25 15:41:27 +01001149enum_stmt: ENUM_KEYWORD sep enum_arg_str enum_end
1150 { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001151 if (yang_check_enum($3, actual, &cnt_val, actual_type)) {
Pavol Vican79a763d2016-02-25 15:41:27 +01001152 YYERROR;
1153 }
1154 actual = $3;
1155 actual_type = TYPE_KEYWORD;
1156 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01001157 size_arrays->node[size_arrays->size-1].enm++; /* count of enum*/
Pavol Vican79a763d2016-02-25 15:41:27 +01001158 }
1159 }
1160
1161enum_arg_str: string { if (read_all) {
1162 $$ = actual;
Pavol Vican0adf01d2016-03-22 12:29:33 +01001163 if (!(actual = yang_read_enum(trg, actual, s))) {
Pavol Vican79a763d2016-02-25 15:41:27 +01001164 YYERROR;
1165 }
1166 s = NULL;
1167 actual_type = 0;
1168 }
1169 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001170
1171enum_end: ';'
Pavol Vican79a763d2016-02-25 15:41:27 +01001172 | '{' stmtsep
1173 enum_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01001174 '}'
1175 ;
1176
Pavol Vicancae54882016-03-30 12:24:43 +02001177enum_opt_stmt: @EMPTYDIR@
Pavol Vican79a763d2016-02-25 15:41:27 +01001178 | 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 Vican0adf01d2016-03-22 12:29:33 +01001181 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "value", "enum");
Pavol Vican79a763d2016-02-25 15:41:27 +01001182 YYERROR;
1183 }
1184 actual_type = 1;
1185 }
1186 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01001187 | enum_opt_stmt status_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001188 if (yang_check_flags(&((struct lys_type_enum *)actual)->flags, LYS_STATUS_MASK, "status", "enum", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +01001189 YYERROR;
1190 }
1191 }
1192 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01001193 | enum_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, "enum")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01001194 YYERROR;
1195 }
1196 s = NULL;
1197 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01001198 | enum_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, "enum")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01001199 YYERROR;
1200 }
1201 s = NULL;
1202 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001203
Pavol Vican79a763d2016-02-25 15:41:27 +01001204value_stmt: VALUE_KEYWORD sep integer_value_arg_str
1205 stmtend { if (read_all) {
1206 ((struct lys_type_enum *)actual)->value = $3;
Pavol Vican6418deb2015-10-28 19:41:26 +01001207
Pavol Vican79a763d2016-02-25 15:41:27 +01001208 /* keep the highest enum value for automatic increment */
Pavol Vican9887c682016-02-29 11:32:01 +01001209 if ($3 > cnt_val) {
1210 cnt_val = $3;
Pavol Vican79a763d2016-02-25 15:41:27 +01001211 }
Pavol Vican9887c682016-02-29 11:32:01 +01001212 cnt_val++;
Pavol Vican79a763d2016-02-25 15:41:27 +01001213 }
1214 }
1215
1216integer_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 Vican0adf01d2016-03-22 12:29:33 +01001224 LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "value");
Pavol Vican79a763d2016-02-25 15:41:27 +01001225 free(s);
1226 YYERROR;
1227 }
1228 free(s);
1229 s = NULL;
1230 $$ = (int32_t) val;
1231 }
1232 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001233 ;
1234
Pavol Vicanaff5c802016-02-24 15:56:45 +01001235range_stmt: RANGE_KEYWORD sep range_arg_str range_end { actual = $3;
1236 actual_type = RANGE_KEYWORD;
1237 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001238
1239
1240range_end: ';'
Pavol Vicanaff5c802016-02-24 15:56:45 +01001241 | '{' stmtsep
1242 message_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01001243 '}'
1244 ;
1245
Pavol Vicancae54882016-03-30 12:24:43 +02001246path_stmt: PATH_KEYWORD sep path_arg_str stmtend;
Pavol Vican6418deb2015-10-28 19:41:26 +01001247
1248require_instance_stmt: REQUIRE_INSTANCE_KEYWORD sep require_instance_arg_str stmtend;
1249
Pavol Vican7dddedc2016-02-26 16:54:03 +01001250require_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 Vican0adf01d2016-03-22 12:29:33 +01001264 LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "require-instance");
Pavol Vican7dddedc2016-02-26 16:54:03 +01001265 free(s);
1266 YYERROR;
1267 }
1268 free(s);
1269 }
1270 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001271 ;
1272
Pavol Vican9887c682016-02-29 11:32:01 +01001273bits_specification: { if (read_all) {
Pavol Vicana55cbb42016-03-21 20:15:26 +01001274 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 Vicanfb8ded62016-03-21 09:43:58 +01001276 if (!((struct yang_type *)actual)->type->info.bits.bit) {
1277 LOGMEM;
1278 YYERROR;
1279 }
Pavol Vican9887c682016-02-29 11:32:01 +01001280 }
Pavol Vican6b072512016-04-04 10:50:21 +02001281 ((struct yang_type *)actual)->base = LY_TYPE_BITS;
Pavol Vican9887c682016-02-29 11:32:01 +01001282 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 Vican6418deb2015-10-28 19:41:26 +01001290
Pavol Vicancae54882016-03-30 12:24:43 +02001291bit_stmts: @EMPTYDIR@
Pavol Vican6418deb2015-10-28 19:41:26 +01001292 | bit_stmts bit_stmt;
1293
Pavol Vican9887c682016-02-29 11:32:01 +01001294bit_stmt: BIT_KEYWORD sep bit_arg_str bit_end
1295 stmtsep { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001296 if (yang_check_bit($3, actual, &cnt_val, actual_type)) {
Pavol Vican9887c682016-02-29 11:32:01 +01001297 YYERROR;
1298 }
1299 actual = $3;
1300 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01001301 size_arrays->node[size_arrays->size-1].bit++; /* count of bit*/
Pavol Vican9887c682016-02-29 11:32:01 +01001302 }
1303 }
1304
1305bit_arg_str: identifier_arg_str { if (read_all) {
1306 $$ = actual;
Pavol Vican0adf01d2016-03-22 12:29:33 +01001307 if (!(actual = yang_read_bit(trg, actual, s))) {
Pavol Vican9887c682016-02-29 11:32:01 +01001308 YYERROR;
1309 }
1310 s = NULL;
1311 actual_type = 0;
1312 }
1313 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001314
1315bit_end: ';'
Pavol Vican7a92f532016-03-10 10:12:03 +01001316 | '{' stmtsep
1317 bit_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01001318 '}'
1319 ;
1320
Pavol Vicancae54882016-03-30 12:24:43 +02001321bit_opt_stmt: @EMPTYDIR@
Pavol Vican9887c682016-02-29 11:32:01 +01001322 | 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 Vican0adf01d2016-03-22 12:29:33 +01001325 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "position", "bit");
Pavol Vican9887c682016-02-29 11:32:01 +01001326 YYERROR;
1327 }
1328 actual_type = 1;
1329 }
1330 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01001331 | bit_opt_stmt status_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001332 if (yang_check_flags(&((struct lys_type_bit *)actual)->flags, LYS_STATUS_MASK, "status", "bit", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +01001333 YYERROR;
1334 }
1335 }
1336 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01001337 | bit_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, "bit")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01001338 YYERROR;
1339 }
1340 s = NULL;
1341 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01001342 | bit_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, "bit")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01001343 YYERROR;
1344 }
1345 s = NULL;
1346 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001347
Pavol Vican9887c682016-02-29 11:32:01 +01001348position_stmt: POSITION_KEYWORD sep position_value_arg_str
1349 stmtend { if (read_all) {
1350 ((struct lys_type_bit *)actual)->pos = $3;
Pavol Vican6418deb2015-10-28 19:41:26 +01001351
Pavol Vican9887c682016-02-29 11:32:01 +01001352 /* keep the highest position value for automatic increment */
1353 if ($3 > cnt_val) {
1354 cnt_val = $3;
1355 }
1356 cnt_val++;
1357 }
1358 }
1359
1360position_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 Vican0adf01d2016-03-22 12:29:33 +01001367 LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "position");
Pavol Vican9887c682016-02-29 11:32:01 +01001368 free(s);
1369 YYERROR;
1370 }
1371 free(s);
1372 s = NULL;
1373 $$ = (uint32_t) val;
1374 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001375
Pavol Vican6418deb2015-10-28 19:41:26 +01001376error_message_stmt: ERROR_MESSAGE_KEYWORD sep string stmtend;
1377
1378error_app_tag_stmt: ERROR_APP_TAG_KEYWORD sep string stmtend;
1379
1380units_stmt: UNITS_KEYWORD sep string stmtend;
1381
1382default_stmt: DEFAULT_KEYWORD sep string stmtend;
1383
Pavol Vican12f53c32016-02-11 11:40:00 +01001384grouping_stmt: GROUPING_KEYWORD sep identifier_arg_str { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +01001385 if (!(actual = yang_read_node(trg,actual,s,LYS_GROUPING,sizeof(struct lys_node_grp)))) {YYERROR;}
Pavol Vican12f53c32016-02-11 11:40:00 +01001386 s=NULL;
Pavol Vican12f53c32016-02-11 11:40:00 +01001387 }
1388 }
1389 grouping_end;
Pavol Vican6418deb2015-10-28 19:41:26 +01001390
Pavol Vicana55cbb42016-03-21 20:15:26 +01001391grouping_end: ';'
Pavol Vican12f53c32016-02-11 11:40:00 +01001392 | '{' stmtsep
1393 grouping_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01001394 '}'
1395 ;
1396
Pavol Vicancae54882016-03-30 12:24:43 +02001397grouping_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vican12f53c32016-02-11 11:40:00 +01001398 $$.grouping = actual;
1399 actual_type = GROUPING_KEYWORD;
Pavol Vican8658f4c2016-03-20 09:38:28 +01001400 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 Vican12f53c32016-02-11 11:40:00 +01001406 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01001407 store_flags((struct lys_node *)$$.grouping, size_arrays->node[size_arrays->next].flags, 0);
Pavol Vican12f53c32016-02-11 11:40:00 +01001408 size_arrays->next++;
1409 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01001410 $$.index = size_arrays->size;
1411 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
1412 LOGMEM;
1413 YYERROR;
1414 }
Pavol Vican12f53c32016-02-11 11:40:00 +01001415 }
1416 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01001417 | grouping_opt_stmt status_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001418 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "grouping", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +01001419 YYERROR;
1420 }
1421 }
1422 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01001423 | grouping_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.grouping, s, "grouping")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01001424 YYERROR;
1425 }
1426 s = NULL;
1427 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01001428 | grouping_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.grouping, s, "grouping")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01001429 YYERROR;
1430 }
1431 s = NULL;
1432 }
Pavol Vican21238f52016-03-01 12:39:52 +01001433 | 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 Vican12f53c32016-02-11 11:40:00 +01001441 | grouping_opt_stmt data_def_stmt stmtsep { actual = $1.grouping; actual_type = GROUPING_KEYWORD; }
Pavol Vican6418deb2015-10-28 19:41:26 +01001442 ;
1443
Pavol Vican6418deb2015-10-28 19:41:26 +01001444data_def_stmt: container_stmt
1445 | leaf_stmt
Pavol Vicancae54882016-03-30 12:24:43 +02001446 | leaf_list_stmt
1447 | list_stmt
1448 | choice_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01001449 | anyxml_stmt
1450 | uses_stmt
1451 ;
1452
Pavol Vicanf37eeaa2016-02-09 20:54:06 +01001453container_stmt: CONTAINER_KEYWORD sep identifier_arg_str { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +01001454 if (!(actual = yang_read_node(trg,actual,s,LYS_CONTAINER,sizeof(struct lys_node_container)))) {YYERROR;}
Pavol Vicanf4717e62016-03-16 11:30:01 +01001455 data_node = actual;
Pavol Vicanf37eeaa2016-02-09 20:54:06 +01001456 s=NULL;
Pavol Vicanf37eeaa2016-02-09 20:54:06 +01001457 }
1458 }
1459 container_end ;
Pavol Vican6418deb2015-10-28 19:41:26 +01001460
Pavol Vicana55cbb42016-03-21 20:15:26 +01001461container_end: ';'
Pavol Vican7c8ae122016-02-10 11:01:50 +01001462 | '{' stmtsep
1463 container_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01001464 '}'
Pavol Vicancae54882016-03-30 12:24:43 +02001465 ;
Pavol Vican6418deb2015-10-28 19:41:26 +01001466
Pavol Vicancae54882016-03-30 12:24:43 +02001467container_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vicanf37eeaa2016-02-09 20:54:06 +01001468 $$.container = actual;
1469 actual_type = CONTAINER_KEYWORD;
Pavol Vican535d50e2016-03-01 13:05:33 +01001470 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 Vicanf37eeaa2016-02-09 20:54:06 +01001490 }
Pavol Vican4fb66c92016-03-17 10:32:27 +01001491 store_flags((struct lys_node *)$$.container, size_arrays->node[size_arrays->next].flags, config_inherit);
Pavol Vicanf37eeaa2016-02-09 20:54:06 +01001492 size_arrays->next++;
1493 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01001494 $$.index = size_arrays->size;
1495 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
1496 LOGMEM;
1497 YYERROR;
1498 }
Pavol Vicanf37eeaa2016-02-09 20:54:06 +01001499 }
1500 }
Pavol Vican235dbd42016-02-10 10:34:19 +01001501 | container_opt_stmt when_stmt { actual = $1.container; actual_type = CONTAINER_KEYWORD; }
Pavol Vicanf4717e62016-03-16 11:30:01 +01001502 stmtsep
Pavol Vicanf37eeaa2016-02-09 20:54:06 +01001503 | container_opt_stmt if_feature_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001504 if (yang_read_if_feature(trg, $1.container, s, unres, CONTAINER_KEYWORD)) {YYERROR;}
Pavol Vicanf37eeaa2016-02-09 20:54:06 +01001505 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 Vicanf4717e62016-03-16 11:30:01 +01001517 stmtsep
Pavol Vican0adf01d2016-03-22 12:29:33 +01001518 | container_opt_stmt presence_stmt { if (read_all && yang_read_presence(trg, $1.container, s)) {YYERROR;} s=NULL; }
Pavol Vican4fb66c92016-03-17 10:32:27 +01001519 | container_opt_stmt config_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001520 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_CONFIG_MASK, "config", "container", $2)) {
Pavol Vican4fb66c92016-03-17 10:32:27 +01001521 YYERROR;
1522 }
1523 }
1524 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01001525 | container_opt_stmt status_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001526 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "container", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +01001527 YYERROR;
1528 }
1529 }
1530 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01001531 | container_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.container, s, "container")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01001532 YYERROR;
1533 }
1534 s = NULL;
1535 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01001536 | container_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.container, s, "container")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01001537 YYERROR;
1538 }
1539 s = NULL;
1540 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01001541 | 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 Vican535d50e2016-03-01 13:05:33 +01001547 actual = $1.container;
1548 actual_type = CONTAINER_KEYWORD;
1549 } else {
1550 size_arrays->node[$1.index].tpdf++;
1551 }
1552 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01001553 stmtsep
1554 | container_opt_stmt data_def_stmt { actual = $1.container;
1555 actual_type = CONTAINER_KEYWORD;
1556 data_node = actual;
1557 }
1558 stmtsep
Pavol Vican6418deb2015-10-28 19:41:26 +01001559 ;
1560
Pavol Vican096c6db2016-02-11 15:08:10 +01001561leaf_stmt: LEAF_KEYWORD sep identifier_arg_str { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +01001562 if (!(actual = yang_read_node(trg,actual,s,LYS_LEAF,sizeof(struct lys_node_leaf)))) {YYERROR;}
Pavol Vicanf4717e62016-03-16 11:30:01 +01001563 data_node = actual;
Pavol Vican096c6db2016-02-11 15:08:10 +01001564 s=NULL;
Pavol Vican096c6db2016-02-11 15:08:10 +01001565 }
1566 }
Pavol Vican73e7c992016-02-24 12:18:05 +01001567 '{' stmtsep
Pavol Vican6295f122016-02-26 12:53:33 +01001568 leaf_opt_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001569 if (!($7.node.flag & LYS_TYPE_DEF)) {
1570 LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_LYS, $7.node.ptr_leaf, "type", "leaf");
Pavol Vican6295f122016-02-26 12:53:33 +01001571 YYERROR;
1572 } else {
Pavol Vican7cbc3e72016-04-07 15:22:03 +02001573 if (unres_schema_add_node(trg, unres, &$7.node.ptr_leaf->type, UNRES_TYPE_DER,(struct lys_node *) $7.node.ptr_leaf->parent)) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001574 $7.node.ptr_leaf->type.der = NULL;
Pavol Vican6295f122016-02-26 12:53:33 +01001575 YYERROR;
1576 }
1577 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001578 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 Vicanfdf81c42016-04-05 15:55:31 +02001581 LOGVAL(LYE_INCHILDSTMT, LY_VLOG_LYS, $7.node.ptr_leaf, "mandatory", "leaf");
Pavol Vicand946c0d2016-03-23 12:53:08 +01001582 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 Vican096c6db2016-02-11 15:08:10 +01001588 }
1589 }
Pavol Vican096c6db2016-02-11 15:08:10 +01001590 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001591 '}' ;
Pavol Vican6418deb2015-10-28 19:41:26 +01001592
Pavol Vicancae54882016-03-30 12:24:43 +02001593 leaf_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001594 $$.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 Vican73e7c992016-02-24 12:18:05 +01001616 LOGMEM;
1617 YYERROR;
1618 }
1619 }
Pavol Vican096c6db2016-02-11 15:08:10 +01001620 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001621 | 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 Vican096c6db2016-02-11 15:08:10 +01001629 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001630 | 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 Vican73e7c992016-02-24 12:18:05 +01001634 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001635 type_stmt { if (read_all) {
1636 actual = $1.node.ptr_leaf;
1637 actual_type = LEAF_KEYWORD;
1638 $1.node.flag |= LYS_TYPE_DEF;
Pavol Vican73e7c992016-02-24 12:18:05 +01001639 }
Pavol Vican73e7c992016-02-24 12:18:05 +01001640 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001641 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 Vican096c6db2016-02-11 15:08:10 +01001649 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001650 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 Vican4fb66c92016-03-17 10:32:27 +01001662 YYERROR;
1663 }
1664 }
1665 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001666 | 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 Vican8658f4c2016-03-20 09:38:28 +01001670 }
1671 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001672 | 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 Vican9bcd7c62016-03-17 19:36:35 +01001678 YYERROR;
1679 }
1680 s = NULL;
1681 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001682
Pavol Vicand946c0d2016-03-23 12:53:08 +01001683 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 Vican339d4ad2016-02-12 12:49:22 +01001688 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001689 '{' 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 Vican339d4ad2016-02-12 12:49:22 +01001696 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001697 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 Vican339d4ad2016-02-12 12:49:22 +01001699 YYERROR;
1700 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001701 if (!($7.node.flag & LYS_TYPE_DEF)) {
1702 LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_LYS, $7.node.ptr_leaflist, "type", "leaf-list");
Pavol Vicana55992a2016-03-01 13:37:17 +01001703 YYERROR;
1704 } else {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001705 if (unres_schema_add_node(trg, unres, &$7.node.ptr_leaflist->type, UNRES_TYPE_DER,
Pavol Vican7cbc3e72016-04-07 15:22:03 +02001706 (struct lys_node *) $7.node.ptr_leaflist->parent)) {
Pavol Vicana55992a2016-03-01 13:37:17 +01001707 YYERROR;
1708 }
1709 }
Pavol Vican339d4ad2016-02-12 12:49:22 +01001710 }
1711 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001712 '}' ;
1713
Pavol Vicancae54882016-03-30 12:24:43 +02001714leaf_list_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001715 $$.node.ptr_leaflist = actual;
1716 $$.node.flag = 0;
Pavol Vican339d4ad2016-02-12 12:49:22 +01001717 actual_type = LEAF_LIST_KEYWORD;
Pavol Vicana55992a2016-03-01 13:37:17 +01001718 if (size_arrays->node[size_arrays->next].if_features) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001719 $$.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 Vicana55992a2016-03-01 13:37:17 +01001721 LOGMEM;
1722 YYERROR;
1723 }
1724 }
1725 if (size_arrays->node[size_arrays->next].must) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001726 $$.node.ptr_leaflist->must = calloc(size_arrays->node[size_arrays->next].must, sizeof *$$.node.ptr_leaflist->must);
1727 if (!$$.node.ptr_leaflist->must) {
Pavol Vicana55992a2016-03-01 13:37:17 +01001728 LOGMEM;
1729 YYERROR;
1730 }
Pavol Vican339d4ad2016-02-12 12:49:22 +01001731 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001732 store_flags((struct lys_node *)$$.node.ptr_leaflist, size_arrays->node[size_arrays->next].flags, config_inherit);
Pavol Vican339d4ad2016-02-12 12:49:22 +01001733 size_arrays->next++;
1734 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01001735 $$.index = size_arrays->size;
1736 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
1737 LOGMEM;
1738 YYERROR;
1739 }
Pavol Vican339d4ad2016-02-12 12:49:22 +01001740 }
1741 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001742 | leaf_list_opt_stmt when_stmt { actual = $1.node.ptr_leaflist; actual_type = LEAF_LIST_KEYWORD; }
Pavol Vicanf4717e62016-03-16 11:30:01 +01001743 stmtsep
Pavol Vican339d4ad2016-02-12 12:49:22 +01001744 | leaf_list_opt_stmt if_feature_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001745 if (yang_read_if_feature(trg, $1.node.ptr_leaflist, s, unres, LEAF_LIST_KEYWORD)) {YYERROR;}
Pavol Vican339d4ad2016-02-12 12:49:22 +01001746 s=NULL;
1747 } else {
1748 size_arrays->node[$1.index].if_features++;
1749 }
1750 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001751 | 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 Vicana55992a2016-03-01 13:37:17 +01001753 YYERROR;
1754 }
1755 }
1756 type_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001757 actual = $1.node.ptr_leaflist;
Pavol Vicana55992a2016-03-01 13:37:17 +01001758 actual_type = LEAF_LIST_KEYWORD;
Pavol Vicand946c0d2016-03-23 12:53:08 +01001759 $1.node.flag |= LYS_TYPE_DEF;
Pavol Vicana55992a2016-03-01 13:37:17 +01001760 }
1761 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01001762 stmtsep { $$ = $1; }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001763 | 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 Vican339d4ad2016-02-12 12:49:22 +01001764 | leaf_list_opt_stmt must_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001765 actual = $1.node.ptr_leaflist;
Pavol Vican339d4ad2016-02-12 12:49:22 +01001766 actual_type = LEAF_LIST_KEYWORD;
1767 } else {
1768 size_arrays->node[$1.index].must++;
1769 }
1770 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01001771 stmtsep
Pavol Vican4fb66c92016-03-17 10:32:27 +01001772 | leaf_list_opt_stmt config_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001773 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_CONFIG_MASK, "config", "leaf-list", $2)) {
Pavol Vican4fb66c92016-03-17 10:32:27 +01001774 YYERROR;
1775 }
1776 }
1777 }
Pavol Vican339d4ad2016-02-12 12:49:22 +01001778 | leaf_list_opt_stmt min_elements_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001779 if ($1.node.flag & LYS_MIN_ELEMENTS) {
1780 LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_leaflist, "min-elements", "leaf-list");
Pavol Vican339d4ad2016-02-12 12:49:22 +01001781 YYERROR;
1782 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001783 $1.node.ptr_leaflist->min = $2;
1784 $1.node.flag |= LYS_MIN_ELEMENTS;
Pavol Vican339d4ad2016-02-12 12:49:22 +01001785 $$ = $1;
Pavol Vicand946c0d2016-03-23 12:53:08 +01001786 if ($1.node.ptr_leaflist->max && ($1.node.ptr_leaflist->min > $1.node.ptr_leaflist->max)) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001787 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 Vican723de602016-03-21 15:13:20 +01001789 }
Pavol Vican339d4ad2016-02-12 12:49:22 +01001790 }
1791 }
1792 | leaf_list_opt_stmt max_elements_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001793 if ($1.node.flag & LYS_MAX_ELEMENTS) {
1794 LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_leaflist, "max-elements", "leaf-list");
Pavol Vican339d4ad2016-02-12 12:49:22 +01001795 YYERROR;
1796 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001797 $1.node.ptr_leaflist->max = $2;
1798 $1.node.flag |= LYS_MAX_ELEMENTS;
Pavol Vican339d4ad2016-02-12 12:49:22 +01001799 $$ = $1;
Pavol Vicand946c0d2016-03-23 12:53:08 +01001800 if ($1.node.ptr_leaflist->min > $1.node.ptr_leaflist->max) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001801 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 Vican723de602016-03-21 15:13:20 +01001803 }
Pavol Vican339d4ad2016-02-12 12:49:22 +01001804 }
1805 }
1806 | leaf_list_opt_stmt ordered_by_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001807 if ($1.node.flag & LYS_ORDERED_MASK) {
1808 LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_leaflist, "ordered by", "leaf-list");
Pavol Vican339d4ad2016-02-12 12:49:22 +01001809 YYERROR;
1810 }
1811 if ($2 & LYS_USERORDERED) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001812 $1.node.ptr_leaflist->flags |= LYS_USERORDERED;
Pavol Vican339d4ad2016-02-12 12:49:22 +01001813 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001814 $1.node.flag |= $2;
Pavol Vican339d4ad2016-02-12 12:49:22 +01001815 $$ = $1;
1816 }
1817 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01001818 | leaf_list_opt_stmt status_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001819 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "leaf-list", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +01001820 YYERROR;
1821 }
1822 }
1823 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001824 | leaf_list_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.node.ptr_leaflist, s, "leaf-list")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01001825 YYERROR;
1826 }
1827 s = NULL;
1828 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001829 | leaf_list_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.node.ptr_leaflist, s, "leaf-list")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01001830 YYERROR;
1831 }
1832 s = NULL;
1833 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001834
Pavol Vican5de33492016-02-22 14:03:24 +01001835list_stmt: LIST_KEYWORD sep identifier_arg_str { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +01001836 if (!(actual = yang_read_node(trg,actual,s,LYS_LIST,sizeof(struct lys_node_list)))) {YYERROR;}
Pavol Vicanf4717e62016-03-16 11:30:01 +01001837 data_node = actual;
Pavol Vican5de33492016-02-22 14:03:24 +01001838 s=NULL;
Pavol Vican5de33492016-02-22 14:03:24 +01001839 }
1840 }
1841 '{' stmtsep
1842 list_opt_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001843 if ($7.node.ptr_list->flags & LYS_CONFIG_R) {
Pavol Vican5de33492016-02-22 14:03:24 +01001844 /* RFC 6020, 7.7.5 - ignore ordering when the list represents state data
1845 * ignore oredering MASK - 0x7F
1846 */
Pavol Vicand946c0d2016-03-23 12:53:08 +01001847 $7.node.ptr_list->flags &= 0x7F;
Pavol Vican5de33492016-02-22 14:03:24 +01001848 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001849 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 Vican5de33492016-02-22 14:03:24 +01001851 YYERROR;
1852 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001853 if ($7.node.ptr_list->keys && yang_read_key(trg, $7.node.ptr_list, unres)) {
Pavol Vican5de33492016-02-22 14:03:24 +01001854 YYERROR;
1855 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001856 if (!($7.node.flag & LYS_DATADEF)) {
1857 LOGVAL(LYE_SPEC, LY_VLOG_LYS, $7.node.ptr_list, "data-def statement missing.");
Pavol Vican5de33492016-02-22 14:03:24 +01001858 YYERROR;
1859 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001860 if (yang_read_unique(trg, $7.node.ptr_list, unres)) {
Pavol Vican5de33492016-02-22 14:03:24 +01001861 YYERROR;
1862 }
1863 }
1864 }
Pavol Vican6418deb2015-10-28 19:41:26 +01001865 '}' ;
1866
Pavol Vicancae54882016-03-30 12:24:43 +02001867list_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001868 $$.node.ptr_list = actual;
1869 $$.node.flag = 0;
Pavol Vican5de33492016-02-22 14:03:24 +01001870 if (size_arrays->node[size_arrays->next].if_features) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001871 $$.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 Vican5de33492016-02-22 14:03:24 +01001873 LOGMEM;
1874 YYERROR;
1875 }
1876 }
1877 if (size_arrays->node[size_arrays->next].must) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001878 $$.node.ptr_list->must = calloc(size_arrays->node[size_arrays->next].must, sizeof *$$.node.ptr_list->must);
1879 if (!$$.node.ptr_list->must) {
Pavol Vican5de33492016-02-22 14:03:24 +01001880 LOGMEM;
1881 YYERROR;
1882 }
1883 }
1884 if (size_arrays->node[size_arrays->next].tpdf) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001885 $$.node.ptr_list->tpdf = calloc(size_arrays->node[size_arrays->next].tpdf, sizeof *$$.node.ptr_list->tpdf);
1886 if (!$$.node.ptr_list->tpdf) {
Pavol Vican5de33492016-02-22 14:03:24 +01001887 LOGMEM;
1888 YYERROR;
1889 }
1890 }
1891 if (size_arrays->node[size_arrays->next].unique) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001892 $$.node.ptr_list->unique = calloc(size_arrays->node[size_arrays->next].unique, sizeof *$$.node.ptr_list->unique);
1893 if (!$$.node.ptr_list->unique) {
Pavol Vican5de33492016-02-22 14:03:24 +01001894 LOGMEM;
1895 YYERROR;
1896 }
1897 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001898 store_flags((struct lys_node *)$$.node.ptr_list, size_arrays->node[size_arrays->next].flags, config_inherit);
Pavol Vican5de33492016-02-22 14:03:24 +01001899 size_arrays->next++;
1900 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01001901 $$.index = size_arrays->size;
1902 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
1903 LOGMEM;
1904 YYERROR;
1905 }
Pavol Vican5de33492016-02-22 14:03:24 +01001906 }
1907 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001908 | list_opt_stmt when_stmt { actual = $1.node.ptr_list; actual_type = LIST_KEYWORD; }
Pavol Vicanf4717e62016-03-16 11:30:01 +01001909 stmtsep
Pavol Vican5de33492016-02-22 14:03:24 +01001910 | list_opt_stmt if_feature_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001911 if (yang_read_if_feature(trg, $1.node.ptr_list, s, unres, LIST_KEYWORD)) {YYERROR;}
Pavol Vican5de33492016-02-22 14:03:24 +01001912 s=NULL;
1913 } else {
1914 size_arrays->node[$1.index].if_features++;
1915 }
1916 }
1917 | list_opt_stmt must_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001918 actual = $1.node.ptr_list;
Pavol Vican5de33492016-02-22 14:03:24 +01001919 actual_type = LIST_KEYWORD;
1920 } else {
1921 size_arrays->node[$1.index].must++;
1922 }
1923 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01001924 stmtsep
Pavol Vican5de33492016-02-22 14:03:24 +01001925 | list_opt_stmt key_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001926 if ($1.node.ptr_list->keys) {
1927 LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_list, "key", "list");
Pavol Vican5de33492016-02-22 14:03:24 +01001928 YYERROR;
1929 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001930 $1.node.ptr_list->keys = (struct lys_node_leaf **)s;
Pavol Vican5de33492016-02-22 14:03:24 +01001931 $$ = $1;
1932 s=NULL;
1933 }
1934 }
1935 | list_opt_stmt unique_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001936 $1.node.ptr_list->unique[$1.node.ptr_list->unique_size++].expr = (const char **)s;
Pavol Vican5de33492016-02-22 14:03:24 +01001937 $$ = $1;
Pavol Vican5de33492016-02-22 14:03:24 +01001938 s = NULL;
1939 } else {
1940 size_arrays->node[$1.index].unique++;
1941 }
1942 }
Pavol Vican4fb66c92016-03-17 10:32:27 +01001943 | list_opt_stmt config_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001944 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_CONFIG_MASK, "config", "list", $2)) {
Pavol Vican4fb66c92016-03-17 10:32:27 +01001945 YYERROR;
1946 }
1947 }
1948 }
Pavol Vican5de33492016-02-22 14:03:24 +01001949 | list_opt_stmt min_elements_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001950 if ($1.node.flag & LYS_MIN_ELEMENTS) {
1951 LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_list, "min-elements", "list");
Pavol Vican5de33492016-02-22 14:03:24 +01001952 YYERROR;
1953 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001954 $1.node.ptr_list->min = $2;
1955 $1.node.flag |= LYS_MIN_ELEMENTS;
Pavol Vican5de33492016-02-22 14:03:24 +01001956 $$ = $1;
Pavol Vicand946c0d2016-03-23 12:53:08 +01001957 if ($1.node.ptr_list->max && ($1.node.ptr_list->min > $1.node.ptr_list->max)) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001958 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 Vican723de602016-03-21 15:13:20 +01001960 }
Pavol Vican5de33492016-02-22 14:03:24 +01001961 }
1962 }
1963 | list_opt_stmt max_elements_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001964 if ($1.node.flag & LYS_MAX_ELEMENTS) {
1965 LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_list, "max-elements", "list");
Pavol Vican5de33492016-02-22 14:03:24 +01001966 YYERROR;
1967 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001968 $1.node.ptr_list->max = $2;
1969 $1.node.flag |= LYS_MAX_ELEMENTS;
Pavol Vican5de33492016-02-22 14:03:24 +01001970 $$ = $1;
Pavol Vicand946c0d2016-03-23 12:53:08 +01001971 if ($1.node.ptr_list->min > $1.node.ptr_list->max) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001972 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 Vican723de602016-03-21 15:13:20 +01001974 }
Pavol Vican5de33492016-02-22 14:03:24 +01001975 }
1976 }
1977 | list_opt_stmt ordered_by_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001978 if ($1.node.flag & LYS_ORDERED_MASK) {
1979 LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.node.ptr_list, "ordered by", "list");
Pavol Vican5de33492016-02-22 14:03:24 +01001980 YYERROR;
1981 }
1982 if ($2 & LYS_USERORDERED) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01001983 $1.node.ptr_list->flags |= LYS_USERORDERED;
Pavol Vican5de33492016-02-22 14:03:24 +01001984 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001985 $1.node.flag |= $2;
Pavol Vican5de33492016-02-22 14:03:24 +01001986 $$ = $1;
1987 }
1988 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01001989 | list_opt_stmt status_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01001990 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "list", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +01001991 YYERROR;
1992 }
1993 }
1994 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01001995 | list_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.node.ptr_list, s, "list")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01001996 YYERROR;
1997 }
1998 s = NULL;
1999 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01002000 | list_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.node.ptr_list, s, "list")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01002001 YYERROR;
2002 }
2003 s = NULL;
2004 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002005 | list_opt_stmt typedef_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002006 actual = $1.node.ptr_list;
Pavol Vican09f04b82016-03-01 14:02:28 +01002007 actual_type = LIST_KEYWORD;
Pavol Vican5de33492016-02-22 14:03:24 +01002008 } else {
2009 size_arrays->node[$1.index].tpdf++;
2010 }
2011 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002012 stmtsep
Pavol Vicand946c0d2016-03-23 12:53:08 +01002013 | list_opt_stmt grouping_stmt { actual = $1.node.ptr_list;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002014 actual_type = LIST_KEYWORD;
2015 data_node = actual;
2016 }
2017 stmtsep
Pavol Vicand946c0d2016-03-23 12:53:08 +01002018 | list_opt_stmt data_def_stmt { actual = $1.node.ptr_list;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002019 actual_type = LIST_KEYWORD;
Pavol Vicand946c0d2016-03-23 12:53:08 +01002020 $1.node.flag |= LYS_DATADEF;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002021 data_node = actual;
2022 }
2023 stmtsep { $$ = $1; }
Pavol Vican6418deb2015-10-28 19:41:26 +01002024 ;
2025
Pavol Vican1f06ba82016-02-10 17:39:50 +01002026choice_stmt: CHOICE_KEYWORD sep identifier_arg_str { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +01002027 if (!(actual = yang_read_node(trg,actual,s,LYS_CHOICE,sizeof(struct lys_node_choice)))) {YYERROR;}
Pavol Vicanf4717e62016-03-16 11:30:01 +01002028 data_node = actual;
2029 if (data_node->parent && (data_node->parent->nodetype == LYS_GROUPING)) {
2030 data_node = NULL;
2031 }
Pavol Vican1f06ba82016-02-10 17:39:50 +01002032 s=NULL;
Pavol Vican1f06ba82016-02-10 17:39:50 +01002033 }
2034 }
2035 choice_end;
Pavol Vican6418deb2015-10-28 19:41:26 +01002036
Pavol Vicana55cbb42016-03-21 20:15:26 +01002037choice_end: ';'
Pavol Vican1f06ba82016-02-10 17:39:50 +01002038 | '{' stmtsep
2039 choice_opt_stmt { if (read_all) {
2040 if ($3.choice.s && ($3.choice.ptr_choice->flags & LYS_MAND_TRUE)) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002041 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 Vican1f06ba82016-02-10 17:39:50 +01002043 YYERROR;
2044 }
2045 /* link default with the case */
2046 if ($3.choice.s) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002047 if (unres_schema_add_str(trg, unres, $3.choice.ptr_choice, UNRES_CHOICE_DFLT, $3.choice.s) == -1) {
Pavol Vican1f06ba82016-02-10 17:39:50 +01002048 YYERROR;
2049 }
2050 free($3.choice.s);
2051 }
2052 }
2053 }
Pavol Vican6418deb2015-10-28 19:41:26 +01002054 '}' ;
2055
Pavol Vicancae54882016-03-30 12:24:43 +02002056choice_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vican1f06ba82016-02-10 17:39:50 +01002057 $$.choice.ptr_choice = actual;
2058 $$.choice.s = NULL;
Pavol Vican339d4ad2016-02-12 12:49:22 +01002059 actual_type = CHOICE_KEYWORD;
Pavol Vicanfb8ded62016-03-21 09:43:58 +01002060 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 Vican1f06ba82016-02-10 17:39:50 +01002066 }
Pavol Vican4fb66c92016-03-17 10:32:27 +01002067 store_flags((struct lys_node *)$$.choice.ptr_choice, size_arrays->node[size_arrays->next].flags, config_inherit);
Pavol Vican1f06ba82016-02-10 17:39:50 +01002068 size_arrays->next++;
2069 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01002070 $$.index = size_arrays->size;
2071 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
2072 LOGMEM;
2073 YYERROR;
2074 }
Pavol Vican1f06ba82016-02-10 17:39:50 +01002075 }
2076 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002077 | choice_opt_stmt when_stmt { actual = $1.choice.ptr_choice; actual_type = CHOICE_KEYWORD; }
2078 stmtsep { $$ = $1; }
Pavol Vican1f06ba82016-02-10 17:39:50 +01002079 | choice_opt_stmt if_feature_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002080 if (yang_read_if_feature(trg, $1.choice.ptr_choice,s, unres, CHOICE_KEYWORD)) {
Pavol Vican3bd188d2016-03-01 15:18:46 +01002081 if ($1.choice.s) {
2082 free($1.choice.s);
2083 }
2084 YYERROR;
2085 }
Pavol Vican1f06ba82016-02-10 17:39:50 +01002086 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 Vican0adf01d2016-03-22 12:29:33 +01002094 LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, $1.choice.ptr_choice, "default", "choice");
Pavol Vican1f06ba82016-02-10 17:39:50 +01002095 free($1.choice.s);
2096 free(s);
2097 YYERROR;
2098 }
2099 $1.choice.s = s;
2100 s = NULL;
2101 $$ = $1;
2102 }
2103 }
Pavol Vican4fb66c92016-03-17 10:32:27 +01002104 | choice_opt_stmt config_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002105 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_CONFIG_MASK, "config", "choice", $2)) {
Pavol Vican4fb66c92016-03-17 10:32:27 +01002106 YYERROR;
2107 }
2108 } else {
2109 $$ = $1;
2110 }
2111 }
Pavol Vicane4084022016-03-19 13:12:52 +01002112| choice_opt_stmt mandatory_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002113 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_MAND_MASK, "mandatory", "choice", $2)) {
Pavol Vicane4084022016-03-19 13:12:52 +01002114 YYERROR;
Pavol Vican3bd188d2016-03-01 15:18:46 +01002115 }
Pavol Vicane4084022016-03-19 13:12:52 +01002116 } else {
Pavol Vican3bd188d2016-03-01 15:18:46 +01002117 $$ = $1;
2118 }
2119 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01002120 | choice_opt_stmt status_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002121 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "choice", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +01002122 YYERROR;
2123 }
2124 } else {
2125 $$ = $1;
2126 }
2127 }
Pavol Vican39284612016-03-20 14:44:24 +01002128 | choice_opt_stmt description_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002129 if (yang_read_description(trg, $1.choice.ptr_choice, s, "choice")) {
Pavol Vican3bd188d2016-03-01 15:18:46 +01002130 free($1.choice.s);
2131 YYERROR;
2132 }
2133 s = NULL;
2134 $$ = $1;
2135 }
2136 }
Pavol Vican39284612016-03-20 14:44:24 +01002137 | choice_opt_stmt reference_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002138 if (yang_read_reference(trg, $1.choice.ptr_choice, s, "choice")) {
Pavol Vican3bd188d2016-03-01 15:18:46 +01002139 free($1.choice.s);
2140 YYERROR;
2141 }
2142 s = NULL;
2143 $$ = $1;
2144 }
2145 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002146 | 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 Vican6418deb2015-10-28 19:41:26 +01002154 ;
2155
Pavol Vicanf4717e62016-03-16 11:30:01 +01002156short_case_case_stmt: short_case_stmt
2157 | case_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01002158 ;
2159
2160short_case_stmt: container_stmt
2161 | leaf_stmt
2162 | leaf_list_stmt
2163 | list_stmt
2164 | anyxml_stmt
2165 ;
2166
Pavol Vicanbd098132016-02-11 10:56:49 +01002167case_stmt: CASE_KEYWORD sep identifier_arg_str { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +01002168 if (!(actual = yang_read_node(trg,actual,s,LYS_CASE,sizeof(struct lys_node_case)))) {YYERROR;}
Pavol Vicanf4717e62016-03-16 11:30:01 +01002169 data_node = actual;
Pavol Vicanbd098132016-02-11 10:56:49 +01002170 s=NULL;
Pavol Vicanbd098132016-02-11 10:56:49 +01002171 }
2172 }
2173 case_end;
Pavol Vican6418deb2015-10-28 19:41:26 +01002174
2175case_end: ';'
Pavol Vicanbd098132016-02-11 10:56:49 +01002176 | '{' stmtsep
2177 case_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01002178 '}' ;
2179
Pavol Vicancae54882016-03-30 12:24:43 +02002180case_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vicanbd098132016-02-11 10:56:49 +01002181 $$.cs = actual;
2182 actual_type = CASE_KEYWORD;
Pavol Vicanfb8ded62016-03-21 09:43:58 +01002183 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 Vicanbd098132016-02-11 10:56:49 +01002189 }
Pavol Vican4fb66c92016-03-17 10:32:27 +01002190 store_flags((struct lys_node *)$$.cs, size_arrays->node[size_arrays->next].flags, 1);
Pavol Vicanbd098132016-02-11 10:56:49 +01002191 size_arrays->next++;
2192 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01002193 $$.index = size_arrays->size;
2194 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
2195 LOGMEM;
2196 YYERROR;
2197 }
Pavol Vicanbd098132016-02-11 10:56:49 +01002198 }
2199 }
2200 | case_opt_stmt when_stmt { actual = $1.cs; actual_type = CASE_KEYWORD; }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002201 stmtsep
Pavol Vicanbd098132016-02-11 10:56:49 +01002202 | case_opt_stmt if_feature_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002203 if (yang_read_if_feature(trg, $1.cs, s, unres, CASE_KEYWORD)) {YYERROR;}
Pavol Vicanbd098132016-02-11 10:56:49 +01002204 s=NULL;
2205 } else {
2206 size_arrays->node[$1.index].if_features++;
2207 }
2208 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01002209 | case_opt_stmt status_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002210 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "case", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +01002211 YYERROR;
2212 }
2213 }
2214 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01002215 | case_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.cs, s, "case")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01002216 YYERROR;
2217 }
2218 s = NULL;
2219 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01002220 | case_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.cs, s, "case")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01002221 YYERROR;
2222 }
2223 s = NULL;
2224 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002225 | case_opt_stmt data_def_stmt { actual = $1.cs;
2226 actual_type = CASE_KEYWORD;
2227 data_node = actual;
2228 }
2229 stmtsep
Pavol Vican6418deb2015-10-28 19:41:26 +01002230 ;
2231
Pavol Vican8c82fa82016-02-10 13:13:24 +01002232anyxml_stmt: ANYXML_KEYWORD sep identifier_arg_str { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +01002233 if (!(actual = yang_read_node(trg,actual,s,LYS_ANYXML,sizeof(struct lys_node_anyxml)))) {YYERROR;}
Pavol Vicanf4717e62016-03-16 11:30:01 +01002234 data_node = actual;
2235 if (data_node->parent && (data_node->parent->nodetype == LYS_GROUPING)) {
2236 data_node = NULL;
2237 }
Pavol Vican8c82fa82016-02-10 13:13:24 +01002238 s=NULL;
Pavol Vican8c82fa82016-02-10 13:13:24 +01002239 }
2240 }
2241 anyxml_end;
Pavol Vican6418deb2015-10-28 19:41:26 +01002242
Pavol Vicana55cbb42016-03-21 20:15:26 +01002243anyxml_end: ';'
Pavol Vican8c82fa82016-02-10 13:13:24 +01002244 | '{' stmtsep
2245 anyxml_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01002246 '}' ;
2247
Pavol Vicancae54882016-03-30 12:24:43 +02002248anyxml_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vican8c82fa82016-02-10 13:13:24 +01002249 $$.anyxml = actual;
2250 actual_type = ANYXML_KEYWORD;
Pavol Vicanfb8ded62016-03-21 09:43:58 +01002251 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 Vican8c82fa82016-02-10 13:13:24 +01002264 }
Pavol Vican4fb66c92016-03-17 10:32:27 +01002265 store_flags((struct lys_node *)$$.anyxml, size_arrays->node[size_arrays->next].flags, config_inherit);
Pavol Vican8c82fa82016-02-10 13:13:24 +01002266 size_arrays->next++;
2267 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01002268 $$.index = size_arrays->size;
2269 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
2270 LOGMEM;
2271 YYERROR;
2272 }
Pavol Vican8c82fa82016-02-10 13:13:24 +01002273 }
2274 }
2275 | anyxml_opt_stmt when_stmt { actual = $1.anyxml; actual_type = ANYXML_KEYWORD; }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002276 stmtsep
Pavol Vican8c82fa82016-02-10 13:13:24 +01002277 | anyxml_opt_stmt if_feature_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002278 if (yang_read_if_feature(trg, $1.anyxml, s, unres, ANYXML_KEYWORD)) {YYERROR;}
Pavol Vican8c82fa82016-02-10 13:13:24 +01002279 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 Vicanf4717e62016-03-16 11:30:01 +01002291 stmtsep
Pavol Vican4fb66c92016-03-17 10:32:27 +01002292 | anyxml_opt_stmt config_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002293 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_CONFIG_MASK, "config", "anyxml", $2)) {
Pavol Vican4fb66c92016-03-17 10:32:27 +01002294 YYERROR;
2295 }
2296 }
2297 }
Pavol Vicane4084022016-03-19 13:12:52 +01002298 | anyxml_opt_stmt mandatory_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002299 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_MAND_MASK, "mandatory", "anyxml", $2)) {
Pavol Vicane4084022016-03-19 13:12:52 +01002300 YYERROR;
2301 }
2302 }
2303 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01002304 | anyxml_opt_stmt status_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002305 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "anyxml", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +01002306 YYERROR;
2307 }
2308 }
2309 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01002310 | anyxml_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.anyxml, s, "anyxml")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01002311 YYERROR;
2312 }
2313 s = NULL;
2314 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01002315 | anyxml_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.anyxml, s, "anyxml")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01002316 YYERROR;
2317 }
2318 s = NULL;
2319 }
Pavol Vican6418deb2015-10-28 19:41:26 +01002320
Pavol Vican14b18562016-03-01 16:04:29 +01002321uses_stmt: USES_KEYWORD sep identifier_ref_arg_str { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +01002322 if (!(actual = yang_read_node(trg,actual,s,LYS_USES,sizeof(struct lys_node_uses)))) {YYERROR;}
Pavol Vicanf4717e62016-03-16 11:30:01 +01002323 data_node = actual;
2324 if (data_node->parent && (data_node->parent->nodetype == LYS_GROUPING)) {
2325 data_node = NULL;
2326 }
Pavol Vican14b18562016-03-01 16:04:29 +01002327 s=NULL;
Pavol Vican14b18562016-03-01 16:04:29 +01002328 }
2329 }
2330 uses_end { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002331 if (unres_schema_add_node(trg, unres, actual, UNRES_USES, NULL) == -1) {
Pavol Vican14b18562016-03-01 16:04:29 +01002332 YYERROR;
2333 }
2334 }
2335 }
Pavol Vican6418deb2015-10-28 19:41:26 +01002336
Pavol Vicana55cbb42016-03-21 20:15:26 +01002337uses_end: ';'
Pavol Vican14b18562016-03-01 16:04:29 +01002338 | '{' stmtsep
2339 uses_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01002340 '}' ;
2341
Pavol Vicancae54882016-03-30 12:24:43 +02002342uses_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vican4fb66c92016-03-17 10:32:27 +01002343 $$.uses.ptr_uses = actual;
2344 $$.uses.config_inherit = config_inherit;
Pavol Vican14b18562016-03-01 16:04:29 +01002345 actual_type = USES_KEYWORD;
2346 if (size_arrays->node[size_arrays->next].if_features) {
Pavol Vican4fb66c92016-03-17 10:32:27 +01002347 $$.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 Vican14b18562016-03-01 16:04:29 +01002349 LOGMEM;
2350 YYERROR;
2351 }
2352 }
2353 if (size_arrays->node[size_arrays->next].refine) {
Pavol Vican4fb66c92016-03-17 10:32:27 +01002354 $$.uses.ptr_uses->refine = calloc(size_arrays->node[size_arrays->next].refine, sizeof *$$.uses.ptr_uses->refine);
2355 if (!$$.uses.ptr_uses->refine) {
Pavol Vican14b18562016-03-01 16:04:29 +01002356 LOGMEM;
2357 YYERROR;
2358 }
2359 }
2360 if (size_arrays->node[size_arrays->next].augment) {
Pavol Vican4fb66c92016-03-17 10:32:27 +01002361 $$.uses.ptr_uses->augment = calloc(size_arrays->node[size_arrays->next].augment, sizeof *$$.uses.ptr_uses->augment);
2362 if (!$$.uses.ptr_uses->augment) {
Pavol Vican14b18562016-03-01 16:04:29 +01002363 LOGMEM;
2364 YYERROR;
2365 }
2366 }
Pavol Vican4fb66c92016-03-17 10:32:27 +01002367 store_flags((struct lys_node *)$$.uses.ptr_uses, size_arrays->node[size_arrays->next].flags, config_inherit);
Pavol Vican14b18562016-03-01 16:04:29 +01002368 size_arrays->next++;
2369 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01002370 $$.index = size_arrays->size;
2371 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
2372 LOGMEM;
2373 YYERROR;
2374 }
Pavol Vican14b18562016-03-01 16:04:29 +01002375 }
2376 }
Pavol Vican4fb66c92016-03-17 10:32:27 +01002377 | uses_opt_stmt when_stmt { actual = $1.uses.ptr_uses; actual_type = USES_KEYWORD; }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002378 stmtsep
Pavol Vican14b18562016-03-01 16:04:29 +01002379 | uses_opt_stmt if_feature_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002380 if (yang_read_if_feature(trg, $1.uses.ptr_uses, s, unres, USES_KEYWORD)) {YYERROR;}
Pavol Vican14b18562016-03-01 16:04:29 +01002381 s=NULL;
2382 } else {
2383 size_arrays->node[$1.index].if_features++;
2384 }
2385 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01002386 | uses_opt_stmt status_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002387 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "uses", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +01002388 YYERROR;
2389 }
2390 }
2391 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01002392 | uses_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.uses.ptr_uses, s, "uses")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01002393 YYERROR;
2394 }
2395 s = NULL;
2396 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01002397 | uses_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.uses.ptr_uses, s, "uses")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01002398 YYERROR;
2399 }
2400 s = NULL;
2401 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002402 | uses_opt_stmt refine_stmt { if (read_all) {
Pavol Vican4fb66c92016-03-17 10:32:27 +01002403 actual = $1.uses.ptr_uses;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002404 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 Vican4fb66c92016-03-17 10:32:27 +01002411 actual = $1.uses.ptr_uses;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002412 actual_type = USES_KEYWORD;
2413 data_node = actual;
2414 if (data_node->parent && (data_node->parent->nodetype == LYS_GROUPING)) {
2415 data_node = NULL;
Pavol Vican14b18562016-03-01 16:04:29 +01002416 }
Pavol Vican4fb66c92016-03-17 10:32:27 +01002417 config_inherit = $1.uses.config_inherit;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002418 } else {
2419 size_arrays->node[$1.index].augment++;
Pavol Vican14b18562016-03-01 16:04:29 +01002420 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002421 }
2422 stmtsep
Pavol Vican6418deb2015-10-28 19:41:26 +01002423 ;
2424
Pavol Vican1003ead2016-03-02 12:24:52 +01002425refine_stmt: REFINE_KEYWORD sep refine_arg_str { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002426 if (!(actual = yang_read_refine(trg, actual, s))) {
Pavol Vican1003ead2016-03-02 12:24:52 +01002427 YYERROR;
2428 }
2429 s = NULL;
Pavol Vican1003ead2016-03-02 12:24:52 +01002430 }
2431 }
2432 refine_end;
Pavol Vican6418deb2015-10-28 19:41:26 +01002433
2434refine_end: ';'
Pavol Vican1003ead2016-03-02 12:24:52 +01002435 | '{' stmtsep
2436 refine_body_opt_stmts
Pavol Vican6418deb2015-10-28 19:41:26 +01002437 '}' ;
2438
2439
Pavol Vicancae54882016-03-30 12:24:43 +02002440refine_arg_str: descendant_schema_nodeid optsep
Pavol Vican6418deb2015-10-28 19:41:26 +01002441 | string_1
2442 ;
2443
Pavol Vicancae54882016-03-30 12:24:43 +02002444refine_body_opt_stmts: @EMPTYDIR@ { if (read_all) {
Pavol Vican1003ead2016-03-02 12:24:52 +01002445 $$.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 Vicana55cbb42016-03-21 20:15:26 +01002457 $$.index = size_arrays->size;
2458 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
2459 LOGMEM;
2460 YYERROR;
2461 }
Pavol Vican1003ead2016-03-02 12:24:52 +01002462 }
2463 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002464 | refine_body_opt_stmts must_stmt stmtsep { if (read_all) {
Pavol Vican1003ead2016-03-02 12:24:52 +01002465 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 Vican0adf01d2016-03-22 12:29:33 +01002475 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "presence", "refine");
Pavol Vican1003ead2016-03-02 12:24:52 +01002476 free(s);
2477 YYERROR;
2478 }
2479 $1.refine->target_type = LYS_CONTAINER;
Pavol Vican22afbdd2016-03-09 11:10:26 +01002480 $1.refine->mod.presence = lydict_insert_zc(trg->ctx, s);
Pavol Vican1003ead2016-03-02 12:24:52 +01002481 } else {
2482 free(s);
Pavol Vican0adf01d2016-03-22 12:29:33 +01002483 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 Vican1003ead2016-03-02 12:24:52 +01002485 YYERROR;
2486 }
2487 } else {
2488 $1.refine->target_type = LYS_CONTAINER;
Pavol Vican22afbdd2016-03-09 11:10:26 +01002489 $1.refine->mod.presence = lydict_insert_zc(trg->ctx, s);
Pavol Vican1003ead2016-03-02 12:24:52 +01002490 }
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 Vican0adf01d2016-03-22 12:29:33 +01002500 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "default", "refine");
Pavol Vican1003ead2016-03-02 12:24:52 +01002501 free(s);
2502 YYERROR;
2503 }
Pavol Vican22afbdd2016-03-09 11:10:26 +01002504 $1.refine->mod.dflt = lydict_insert_zc(trg->ctx, s);
Pavol Vican1003ead2016-03-02 12:24:52 +01002505 } else {
2506 free(s);
Pavol Vican0adf01d2016-03-22 12:29:33 +01002507 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 Vican1003ead2016-03-02 12:24:52 +01002509 YYERROR;
2510 }
2511 } else {
2512 $1.refine->target_type = LYS_LEAF | LYS_CHOICE;
Pavol Vican22afbdd2016-03-09 11:10:26 +01002513 $1.refine->mod.dflt = lydict_insert_zc(trg->ctx, s);
Pavol Vican1003ead2016-03-02 12:24:52 +01002514 }
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 Vican0adf01d2016-03-22 12:29:33 +01002523 if (yang_check_flags(&$1.refine->flags, LYS_CONFIG_MASK, "config", "refine", $2)) {
Pavol Vican1003ead2016-03-02 12:24:52 +01002524 YYERROR;
2525 }
2526 } else {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002527 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 Vican1003ead2016-03-02 12:24:52 +01002529 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 Vican0adf01d2016-03-22 12:29:33 +01002542 if (yang_check_flags(&$1.refine->flags, LYS_MAND_MASK, "mandatory", "refine", $2)) {
Pavol Vican1003ead2016-03-02 12:24:52 +01002543 YYERROR;
2544 }
2545 } else {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002546 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 Vican1003ead2016-03-02 12:24:52 +01002548 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 Vican0adf01d2016-03-22 12:29:33 +01002563 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "min-elements", "refine");
Pavol Vican1003ead2016-03-02 12:24:52 +01002564 YYERROR;
2565 }
2566 $1.refine->flags |= 0x04;
2567 $1.refine->mod.list.min = $2;
2568 } else {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002569 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 Vican1003ead2016-03-02 12:24:52 +01002571 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 Vican0adf01d2016-03-22 12:29:33 +01002588 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "max-elements", "refine");
Pavol Vican1003ead2016-03-02 12:24:52 +01002589 YYERROR;
2590 }
2591 $1.refine->flags |= 0x08;
2592 $1.refine->mod.list.max = $2;
2593 } else {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002594 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 Vican1003ead2016-03-02 12:24:52 +01002596 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 Vican0adf01d2016-03-22 12:29:33 +01002607 | refine_body_opt_stmts description_stmt { if (read_all && yang_read_description(trg, $1.refine, s, "refine")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01002608 YYERROR;
2609 }
2610 s = NULL;
2611 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01002612 | refine_body_opt_stmts reference_stmt { if (read_all && yang_read_reference(trg, $1.refine, s, "refine")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01002613 YYERROR;
2614 }
2615 s = NULL;
2616 }
Pavol Vican6418deb2015-10-28 19:41:26 +01002617
Pavol Vican92fa0dc2016-03-02 14:20:39 +01002618uses_augment_stmt: AUGMENT_KEYWORD sep uses_augment_arg_str { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002619 if (!(actual = yang_read_augment(trg, actual, s))) {
Pavol Vican92fa0dc2016-03-02 14:20:39 +01002620 YYERROR;
2621 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002622 data_node = actual;
Pavol Vican92fa0dc2016-03-02 14:20:39 +01002623 s = NULL;
Pavol Vican92fa0dc2016-03-02 14:20:39 +01002624 }
2625 }
2626 '{' stmtsep
Pavol Vicand946c0d2016-03-23 12:53:08 +01002627 augment_opt_stmt { if (read_all && !($7.node.flag & LYS_DATADEF)){
Pavol Vican0adf01d2016-03-22 12:29:33 +01002628 LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "data-def or case", "uses/augment");
Pavol Vican92fa0dc2016-03-02 14:20:39 +01002629 YYERROR;
2630 }
2631 }
Pavol Vican6418deb2015-10-28 19:41:26 +01002632 '}' ;
2633
Pavol Vicancae54882016-03-30 12:24:43 +02002634uses_augment_arg_str: descendant_schema_nodeid optsep
2635 | string_1
2636 ;
Pavol Vican6418deb2015-10-28 19:41:26 +01002637
Pavol Vican9f989972016-03-02 14:44:11 +01002638augment_stmt: AUGMENT_KEYWORD sep augment_arg_str { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002639 if (!(actual = yang_read_augment(trg, NULL, s))) {
Pavol Vican9f989972016-03-02 14:44:11 +01002640 YYERROR;
2641 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002642 data_node = actual;
Pavol Vican9f989972016-03-02 14:44:11 +01002643 s = NULL;
Pavol Vican9f989972016-03-02 14:44:11 +01002644 }
2645 }
2646 '{' stmtsep
2647 augment_opt_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002648 if (!($7.node.flag & LYS_DATADEF)){
Pavol Vican0adf01d2016-03-22 12:29:33 +01002649 LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "data-def or case", "augment");
Pavol Vican9f989972016-03-02 14:44:11 +01002650 YYERROR;
2651 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01002652 if (unres_schema_add_node(trg, unres, actual, UNRES_AUGMENT, NULL) == -1) {
Pavol Vican9f989972016-03-02 14:44:11 +01002653 YYERROR;
2654 }
2655 }
2656 }
Pavol Vican6418deb2015-10-28 19:41:26 +01002657 '}' ;
2658
Pavol Vicancae54882016-03-30 12:24:43 +02002659augment_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002660 $$.node.ptr_augment = actual;
2661 $$.node.flag = 0;
Pavol Vican92fa0dc2016-03-02 14:20:39 +01002662 actual_type = AUGMENT_KEYWORD;
2663 if (size_arrays->node[size_arrays->next].if_features) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002664 $$.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 Vican92fa0dc2016-03-02 14:20:39 +01002666 LOGMEM;
2667 YYERROR;
2668 }
2669 }
Pavol Vican4fb66c92016-03-17 10:32:27 +01002670 config_inherit = DISABLE_INHERIT;
Pavol Vican92fa0dc2016-03-02 14:20:39 +01002671 size_arrays->next++;
2672 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01002673 $$.index = size_arrays->size;
2674 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
2675 LOGMEM;
2676 YYERROR;
2677 }
Pavol Vican92fa0dc2016-03-02 14:20:39 +01002678 }
2679 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01002680 | augment_opt_stmt when_stmt { actual = $1.node.ptr_augment; actual_type = AUGMENT_KEYWORD; }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002681 stmtsep
Pavol Vican92fa0dc2016-03-02 14:20:39 +01002682 | augment_opt_stmt if_feature_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002683 if (yang_read_if_feature(trg, $1.node.ptr_augment, s, unres, AUGMENT_KEYWORD)) {YYERROR;}
Pavol Vican92fa0dc2016-03-02 14:20:39 +01002684 s=NULL;
2685 } else {
2686 size_arrays->node[$1.index].if_features++;
2687 }
2688 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01002689 | augment_opt_stmt status_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002690 if (yang_check_flags(&$1.node.ptr_augment->flags, LYS_STATUS_MASK, "status", "augment", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +01002691 YYERROR;
2692 }
2693 }
2694 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01002695 | augment_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.node.ptr_augment, s, "augment")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01002696 YYERROR;
2697 }
2698 s = NULL;
2699 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01002700 | augment_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.node.ptr_augment, s, "augment")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01002701 YYERROR;
2702 }
2703 s = NULL;
2704 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002705 | augment_opt_stmt data_def_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002706 actual = $1.node.ptr_augment;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002707 actual_type = AUGMENT_KEYWORD;
Pavol Vicand946c0d2016-03-23 12:53:08 +01002708 $1.node.flag |= LYS_DATADEF;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002709 data_node = actual;
2710 }
2711 }
2712 stmtsep { $$ = $1; }
2713 | augment_opt_stmt case_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002714 actual = $1.node.ptr_augment;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002715 actual_type = AUGMENT_KEYWORD;
Pavol Vicand946c0d2016-03-23 12:53:08 +01002716 $1.node.flag |= LYS_DATADEF;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002717 data_node = actual;
2718 }
2719 }
2720 stmtsep { $$ = $1; }
Pavol Vican6418deb2015-10-28 19:41:26 +01002721 ;
2722
2723augment_arg_str: absolute_schema_nodeids optsep
2724 | string_1
Pavol Vicancae54882016-03-30 12:24:43 +02002725 ;
Pavol Vican6418deb2015-10-28 19:41:26 +01002726
Pavol Vican52ed67d2016-03-02 17:46:15 +01002727rpc_stmt: RPC_KEYWORD sep identifier_arg_str { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +01002728 if (!(actual = yang_read_node(trg, NULL, s, LYS_RPC, sizeof(struct lys_node_rpc)))) {
Pavol Vican52ed67d2016-03-02 17:46:15 +01002729 YYERROR;
2730 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002731 data_node = actual;
Pavol Vican52ed67d2016-03-02 17:46:15 +01002732 s = NULL;
Pavol Vican52ed67d2016-03-02 17:46:15 +01002733 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01002734 config_inherit = DISABLE_INHERIT;
Pavol Vican52ed67d2016-03-02 17:46:15 +01002735 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01002736 rpc_end { config_inherit = ENABLE_INHERIT; }
Pavol Vican6418deb2015-10-28 19:41:26 +01002737
Pavol Vicana55cbb42016-03-21 20:15:26 +01002738rpc_end: ';'
Pavol Vican52ed67d2016-03-02 17:46:15 +01002739 | '{' stmtsep
2740 rpc_opt_stmt
2741 '}'
Pavol Vican6418deb2015-10-28 19:41:26 +01002742
Pavol Vican52ed67d2016-03-02 17:46:15 +01002743
Pavol Vicancae54882016-03-30 12:24:43 +02002744rpc_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002745 $$.node.ptr_rpc = actual;
2746 $$.node.flag = 0;
Pavol Vican52ed67d2016-03-02 17:46:15 +01002747 actual_type = RPC_KEYWORD;
2748 if (size_arrays->node[size_arrays->next].if_features) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002749 $$.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 Vican52ed67d2016-03-02 17:46:15 +01002751 LOGMEM;
2752 YYERROR;
2753 }
2754 }
2755 if (size_arrays->node[size_arrays->next].tpdf) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002756 $$.node.ptr_rpc->tpdf = calloc(size_arrays->node[size_arrays->next].tpdf, sizeof *$$.node.ptr_rpc->tpdf);
2757 if (!$$.node.ptr_rpc->tpdf) {
Pavol Vican52ed67d2016-03-02 17:46:15 +01002758 LOGMEM;
2759 YYERROR;
2760 }
2761 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01002762 store_flags((struct lys_node *)$$.node.ptr_rpc, size_arrays->node[size_arrays->next].flags, 0);
Pavol Vican52ed67d2016-03-02 17:46:15 +01002763 size_arrays->next++;
2764 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01002765 $$.index = size_arrays->size;
2766 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
2767 LOGMEM;
2768 YYERROR;
2769 }
Pavol Vican52ed67d2016-03-02 17:46:15 +01002770 }
2771 }
2772 | rpc_opt_stmt if_feature_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002773 if (yang_read_if_feature(trg, $1.node.ptr_rpc, s, unres, RPC_KEYWORD)) {YYERROR;}
Pavol Vican52ed67d2016-03-02 17:46:15 +01002774 s=NULL;
2775 } else {
2776 size_arrays->node[$1.index].if_features++;
2777 }
2778 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01002779 | rpc_opt_stmt status_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002780 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "rpc", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +01002781 YYERROR;
2782 }
2783 }
2784 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01002785 | rpc_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.node.ptr_rpc, s, "rpc")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01002786 YYERROR;
2787 }
2788 s = NULL;
2789 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01002790 | rpc_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.node.ptr_rpc, s, "rpc")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01002791 YYERROR;
2792 }
2793 s = NULL;
2794 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002795 | rpc_opt_stmt typedef_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002796 actual = $1.node.ptr_rpc;
Pavol Vican52ed67d2016-03-02 17:46:15 +01002797 actual_type = RPC_KEYWORD;
2798 } else {
2799 size_arrays->node[$1.index].tpdf++;
2800 }
2801 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002802 stmtsep
Pavol Vicand946c0d2016-03-23 12:53:08 +01002803 | rpc_opt_stmt grouping_stmt { actual = $1.node.ptr_rpc;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002804 actual_type = RPC_KEYWORD;
2805 data_node = actual;
2806 }
2807 stmtsep
Pavol Vican948aff82016-04-08 10:31:14 +02002808 | 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 Vican52ed67d2016-03-02 17:46:15 +01002817 }
Pavol Vican52ed67d2016-03-02 17:46:15 +01002818 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002819 stmtsep { $$ = $1; }
Pavol Vican948aff82016-04-08 10:31:14 +02002820 | 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 Vican52ed67d2016-03-02 17:46:15 +01002829 }
Pavol Vican52ed67d2016-03-02 17:46:15 +01002830 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002831 stmtsep { $$ = $1; }
Pavol Vican6418deb2015-10-28 19:41:26 +01002832
Pavol Vican531a9132016-03-03 10:10:09 +01002833input_stmt: INPUT_KEYWORD optsep { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +01002834 if (!(actual = yang_read_node(trg, actual, NULL, LYS_INPUT, sizeof(struct lys_node_rpc_inout)))) {
Pavol Vican531a9132016-03-03 10:10:09 +01002835 YYERROR;
2836 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002837 data_node = actual;
Pavol Vican531a9132016-03-03 10:10:09 +01002838 }
2839 }
2840 '{' stmtsep
Pavol Vicand946c0d2016-03-23 12:53:08 +01002841 input_output_opt_stmt { if (read_all && !($6.node.flag & LYS_DATADEF)) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002842 LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, "data-def", "input");
Pavol Vican531a9132016-03-03 10:10:09 +01002843 YYERROR;
2844 }
2845 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002846 '}'
Pavol Vican6418deb2015-10-28 19:41:26 +01002847
Pavol Vicancae54882016-03-30 12:24:43 +02002848input_output_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002849 $$.node.ptr_inout = actual;
2850 $$.node.flag = 0;
Pavol Vican531a9132016-03-03 10:10:09 +01002851 actual_type = INPUT_KEYWORD;
2852 if (size_arrays->node[size_arrays->next].tpdf) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002853 $$.node.ptr_inout->tpdf = calloc(size_arrays->node[size_arrays->next].tpdf, sizeof *$$.node.ptr_inout->tpdf);
2854 if (!$$.node.ptr_inout->tpdf) {
Pavol Vican531a9132016-03-03 10:10:09 +01002855 LOGMEM;
2856 YYERROR;
2857 }
2858 }
2859 size_arrays->next++;
2860 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01002861 $$.index = size_arrays->size;
2862 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
2863 LOGMEM;
2864 YYERROR;
2865 }
Pavol Vican531a9132016-03-03 10:10:09 +01002866 }
2867 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002868 | input_output_opt_stmt typedef_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002869 actual = $1.node.ptr_inout;
Pavol Vican531a9132016-03-03 10:10:09 +01002870 actual_type = INPUT_KEYWORD;
2871 } else {
2872 size_arrays->node[$1.index].tpdf++;
2873 }
2874 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002875 stmtsep
Pavol Vicand946c0d2016-03-23 12:53:08 +01002876 | input_output_opt_stmt grouping_stmt { actual = $1.node.ptr_inout;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002877 actual_type = INPUT_KEYWORD;
2878 data_node = actual;
2879 }
2880 stmtsep
2881 | input_output_opt_stmt data_def_stmt { if (read_all) {
Pavol Vicand946c0d2016-03-23 12:53:08 +01002882 actual = $1.node.ptr_inout;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002883 actual_type = INPUT_KEYWORD;
Pavol Vicand946c0d2016-03-23 12:53:08 +01002884 $1.node.flag |= LYS_DATADEF;
Pavol Vicanf4717e62016-03-16 11:30:01 +01002885 data_node = actual;
2886 }
2887 }
2888 stmtsep { $$ = $1; }
Pavol Vican6418deb2015-10-28 19:41:26 +01002889 ;
2890
Pavol Vican531a9132016-03-03 10:10:09 +01002891output_stmt: OUTPUT_KEYWORD optsep { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +01002892 if (!(actual = yang_read_node(trg, actual, NULL, LYS_OUTPUT, sizeof(struct lys_node_rpc_inout)))) {
Pavol Vican531a9132016-03-03 10:10:09 +01002893 YYERROR;
2894 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002895 data_node = actual;
Pavol Vican531a9132016-03-03 10:10:09 +01002896 }
2897 }
2898 '{' stmtsep
Pavol Vicand946c0d2016-03-23 12:53:08 +01002899 input_output_opt_stmt { if (read_all && !($6.node.flag & LYS_DATADEF)) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002900 LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, "data-def", "output");
Pavol Vican531a9132016-03-03 10:10:09 +01002901 YYERROR;
2902 }
2903 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002904 '}'
Pavol Vican6418deb2015-10-28 19:41:26 +01002905
Pavol Vican41267fd2016-03-03 10:47:42 +01002906notification_stmt: NOTIFICATION_KEYWORD sep identifier_arg_str { if (read_all) {
Pavol Vican22afbdd2016-03-09 11:10:26 +01002907 if (!(actual = yang_read_node(trg, NULL, s, LYS_NOTIF, sizeof(struct lys_node_notif)))) {
Pavol Vican41267fd2016-03-03 10:47:42 +01002908 YYERROR;
2909 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002910 data_node = actual;
Pavol Vican41267fd2016-03-03 10:47:42 +01002911 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01002912 config_inherit = DISABLE_INHERIT;
Pavol Vican41267fd2016-03-03 10:47:42 +01002913 }
Pavol Vicand946c0d2016-03-23 12:53:08 +01002914 notification_end { config_inherit = ENABLE_INHERIT; }
Pavol Vican6418deb2015-10-28 19:41:26 +01002915
Pavol Vican41267fd2016-03-03 10:47:42 +01002916notification_end: ';' { if (read_all) {
2917 size_arrays->next++;
2918 }
2919 }
2920 | '{' stmtsep
2921 notification_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01002922 '}' ;
2923
Pavol Vican41267fd2016-03-03 10:47:42 +01002924
Pavol Vicancae54882016-03-30 12:24:43 +02002925notification_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vican41267fd2016-03-03 10:47:42 +01002926 $$.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 Vican8658f4c2016-03-20 09:38:28 +01002942 store_flags((struct lys_node *)$$.notif, size_arrays->node[size_arrays->next].flags, 0);
Pavol Vican41267fd2016-03-03 10:47:42 +01002943 size_arrays->next++;
2944 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01002945 $$.index = size_arrays->size;
2946 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
2947 LOGMEM;
2948 YYERROR;
2949 }
Pavol Vican41267fd2016-03-03 10:47:42 +01002950 }
2951 }
2952 | notification_opt_stmt if_feature_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002953 if (yang_read_if_feature(trg, $1.notif, s, unres, NOTIFICATION_KEYWORD)) {YYERROR;}
Pavol Vican41267fd2016-03-03 10:47:42 +01002954 s=NULL;
2955 } else {
2956 size_arrays->node[$1.index].if_features++;
2957 }
2958 }
Pavol Vican8658f4c2016-03-20 09:38:28 +01002959 | notification_opt_stmt status_read_stmt { if (!read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002960 if (yang_check_flags(&size_arrays->node[$1.index].flags, LYS_STATUS_MASK, "status", "notification", $2)) {
Pavol Vican8658f4c2016-03-20 09:38:28 +01002961 YYERROR;
2962 }
2963 }
2964 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01002965 | notification_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.notif, s, "notification")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01002966 YYERROR;
2967 }
2968 s = NULL;
2969 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01002970 | notification_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.notif, s, "notification")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01002971 YYERROR;
2972 }
2973 s = NULL;
2974 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002975 | notification_opt_stmt typedef_stmt { if (read_all) {
Pavol Vican41267fd2016-03-03 10:47:42 +01002976 actual = $1.notif;
2977 actual_type = NOTIFICATION_KEYWORD;
2978 } else {
2979 size_arrays->node[$1.index].tpdf++;
2980 }
2981 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01002982 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 Vican6418deb2015-10-28 19:41:26 +01002993 ;
2994
Pavol Vican220e5a12016-03-03 14:19:43 +01002995deviation_stmt: DEVIATION_KEYWORD sep deviation_arg_str { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01002996 if (!(actual = yang_read_deviation(trg, s))) {
Pavol Vican220e5a12016-03-03 14:19:43 +01002997 YYERROR;
2998 }
2999 s = NULL;
Pavol Vican22afbdd2016-03-09 11:10:26 +01003000 trg->deviation_size++;
Pavol Vican220e5a12016-03-03 14:19:43 +01003001 }
3002 }
3003 '{' stmtsep
3004 deviation_opt_stmt { if (read_all) {
3005 if (actual_type == DEVIATION_KEYWORD) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003006 LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "deviate", "deviation");
Pavol Vican220e5a12016-03-03 14:19:43 +01003007 YYERROR;
3008 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01003009 if (yang_check_deviation(trg, actual, unres)) {
Pavol Vicane92421d2016-03-08 10:12:33 +01003010 YYERROR;
3011 }
Pavol Vican220e5a12016-03-03 14:19:43 +01003012 free($7.deviation);
3013 }
3014 }
Pavol Vican85f12022016-03-05 16:30:35 +01003015 '}'
Pavol Vican6418deb2015-10-28 19:41:26 +01003016
Pavol Vicancae54882016-03-30 12:24:43 +02003017deviation_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vican220e5a12016-03-03 14:19:43 +01003018 $$.deviation = actual;
3019 actual_type = DEVIATION_KEYWORD;
Pavol Vicana55cbb42016-03-21 20:15:26 +01003020 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 Vican220e5a12016-03-03 14:19:43 +01003022 if (!$$.deviation->deviation->deviate) {
3023 LOGMEM;
3024 YYERROR;
3025 }
3026 }
3027 size_arrays->next++;
3028 } else {
Pavol Vicana55cbb42016-03-21 20:15:26 +01003029 $$.index = size_arrays->size;
3030 if (yang_add_elem(&size_arrays->node, &size_arrays->size)) {
3031 LOGMEM;
3032 YYERROR;
3033 }
Pavol Vican220e5a12016-03-03 14:19:43 +01003034 }
3035 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01003036 | deviation_opt_stmt description_stmt { if (read_all && yang_read_description(trg, $1.deviation->deviation, s, "deviation")) {
Pavol Vican220e5a12016-03-03 14:19:43 +01003037 free($1.deviation);
3038 YYERROR;
3039 }
3040 s = NULL;
3041 $$ = $1;
3042 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01003043 | deviation_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, $1.deviation->deviation, s, "deviation")) {
Pavol Vican220e5a12016-03-03 14:19:43 +01003044 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 Vicana55cbb42016-03-21 20:15:26 +01003056 size_arrays->node[$1.index].deviate++;
Pavol Vican220e5a12016-03-03 14:19:43 +01003057 }
3058 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003059
3060deviation_arg_str: absolute_schema_nodeids optsep
3061 | string_1
Pavol Vican6418deb2015-10-28 19:41:26 +01003062
3063deviate_body_stmt: deviate_not_supported_stmt
Pavol Vican0adf01d2016-03-22 12:29:33 +01003064 { if (read_all && yang_read_deviate_unsupported(actual)) {
Pavol Vican4c90c642016-03-03 15:06:47 +01003065 YYERROR;
3066 }
3067 }
Pavol Vican85f12022016-03-05 16:30:35 +01003068 | deviate_stmts optsep
Pavol Vican6418deb2015-10-28 19:41:26 +01003069
3070deviate_stmts: deviate_add_stmt
3071 | deviate_replace_stmt
3072 | deviate_delete_stmt
3073 ;
3074
3075deviate_not_supported_stmt: NOT_SUPPORTED_KEYWORD optsep stmtend;
3076
Pavol Vican0adf01d2016-03-22 12:29:33 +01003077deviate_add_stmt: ADD_KEYWORD optsep { if (read_all && yang_read_deviate(actual, LY_DEVIATE_ADD)) {
Pavol Vican85f12022016-03-05 16:30:35 +01003078 YYERROR;
3079 }
3080 }
3081 deviate_add_end
Pavol Vican6418deb2015-10-28 19:41:26 +01003082
3083deviate_add_end: ';'
Pavol Vican85f12022016-03-05 16:30:35 +01003084 | '{' stmtsep
3085 deviate_add_opt_stmt
3086 '}'
Pavol Vican6418deb2015-10-28 19:41:26 +01003087
Pavol Vicancae54882016-03-30 12:24:43 +02003088deviate_add_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vican85f12022016-03-05 16:30:35 +01003089 $$.deviation = actual;
3090 actual_type = ADD_KEYWORD;
3091 if (size_arrays->node[size_arrays->next].must) {
Pavol Vican974377b2016-03-23 00:38:53 +01003092 if (yang_read_deviate_must(actual, size_arrays->node[size_arrays->next].must)) {
Pavol Vican85f12022016-03-05 16:30:35 +01003093 YYERROR;
3094 }
3095 }
3096 if (size_arrays->node[size_arrays->next].unique) {
Pavol Vican974377b2016-03-23 00:38:53 +01003097 if (yang_read_deviate_unique(actual, size_arrays->node[size_arrays->next].unique)) {
Pavol Vican85f12022016-03-05 16:30:35 +01003098 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 Vican0adf01d2016-03-22 12:29:33 +01003111 if (yang_read_deviate_units(trg->ctx, $1.deviation, s)) {
Pavol Vican85f12022016-03-05 16:30:35 +01003112 YYERROR;
3113 }
3114 s = NULL;
3115 $$ = $1;
3116 }
3117 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01003118 | deviate_add_opt_stmt must_stmt stmtsep { if (read_all) {
Pavol Vican85f12022016-03-05 16:30:35 +01003119 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 Vican0adf01d2016-03-22 12:29:33 +01003130 if (yang_fill_unique(trg, list, &list->unique[list->unique_size], s, NULL)) {
Pavol Vican85f12022016-03-05 16:30:35 +01003131 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 Vican0adf01d2016-03-22 12:29:33 +01003143 if (yang_read_deviate_default(trg->ctx, $1.deviation, s)) {
Pavol Vican85f12022016-03-05 16:30:35 +01003144 YYERROR;
3145 }
3146 s = NULL;
3147 $$ = $1;
3148 }
3149 }
3150 | deviate_add_opt_stmt config_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003151 if (yang_read_deviate_config($1.deviation, $2)) {
Pavol Vican85f12022016-03-05 16:30:35 +01003152 YYERROR;
3153 }
3154 $$ = $1;
3155 }
3156 }
3157 | deviate_add_opt_stmt mandatory_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003158 if (yang_read_deviate_mandatory($1.deviation, $2)) {
Pavol Vican85f12022016-03-05 16:30:35 +01003159 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 Vican0adf01d2016-03-22 12:29:33 +01003166 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "min-elements", "deviation");
Pavol Vican85f12022016-03-05 16:30:35 +01003167 YYERROR;
3168 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01003169 if (yang_read_deviate_minmax($1.deviation, $2, 0)) {
Pavol Vican85f12022016-03-05 16:30:35 +01003170 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 Vican0adf01d2016-03-22 12:29:33 +01003177 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "max-elements", "deviation");
Pavol Vican85f12022016-03-05 16:30:35 +01003178 YYERROR;
3179 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01003180 if (yang_read_deviate_minmax($1.deviation, $2, 1)) {
Pavol Vican85f12022016-03-05 16:30:35 +01003181 YYERROR;
3182 }
3183 $$ = $1;
3184 }
3185 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003186
Pavol Vican0adf01d2016-03-22 12:29:33 +01003187deviate_delete_stmt: DELETE_KEYWORD optsep { if (read_all && yang_read_deviate(actual, LY_DEVIATE_DEL)) {
Pavol Vicanc1f5a502016-03-06 16:51:26 +01003188 YYERROR;
3189 }
3190 }
3191 deviate_delete_end
Pavol Vican6418deb2015-10-28 19:41:26 +01003192
3193deviate_delete_end: ';'
Pavol Vicanc1f5a502016-03-06 16:51:26 +01003194 | '{' stmtsep
3195 deviate_delete_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01003196 '}' ;
3197
Pavol Vicancae54882016-03-30 12:24:43 +02003198deviate_delete_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vicanc1f5a502016-03-06 16:51:26 +01003199 $$.deviation = actual;
3200 actual_type = DELETE_KEYWORD;
3201 if (size_arrays->node[size_arrays->next].must) {
Pavol Vican974377b2016-03-23 00:38:53 +01003202 if (yang_read_deviate_must(actual, size_arrays->node[size_arrays->next].must)) {
Pavol Vicanc1f5a502016-03-06 16:51:26 +01003203 YYERROR;
3204 }
3205 }
3206 if (size_arrays->node[size_arrays->next].unique) {
Pavol Vican974377b2016-03-23 00:38:53 +01003207 if (yang_read_deviate_unique(actual, size_arrays->node[size_arrays->next].unique)) {
Pavol Vicanc1f5a502016-03-06 16:51:26 +01003208 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 Vican0adf01d2016-03-22 12:29:33 +01003221 if (yang_read_deviate_units(trg->ctx, $1.deviation, s)) {
Pavol Vicanc1f5a502016-03-06 16:51:26 +01003222 YYERROR;
3223 }
3224 s = NULL;
3225 $$ = $1;
3226 }
3227 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01003228 | deviate_delete_opt_stmt must_stmt stmtsep { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003229 if (yang_check_deviate_must(trg->ctx, $1.deviation)) {
Pavol Vicanc1f5a502016-03-06 16:51:26 +01003230 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 Vican0adf01d2016-03-22 12:29:33 +01003240 if (yang_check_deviate_unique(trg, $1.deviation, s)) {
Pavol Vicanc1f5a502016-03-06 16:51:26 +01003241 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 Vican0adf01d2016-03-22 12:29:33 +01003250 if (yang_read_deviate_default(trg->ctx, $1.deviation, s)) {
Pavol Vicanc1f5a502016-03-06 16:51:26 +01003251 YYERROR;
3252 }
3253 s = NULL;
3254 $$ = $1;
3255 }
3256 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003257
Pavol Vican0adf01d2016-03-22 12:29:33 +01003258deviate_replace_stmt: REPLACE_KEYWORD optsep { if (read_all && yang_read_deviate(actual, LY_DEVIATE_RPL)) {
Pavol Vican4766aca2016-03-07 12:42:36 +01003259 YYERROR;
3260 }
3261 }
3262 deviate_replace_end
Pavol Vican6418deb2015-10-28 19:41:26 +01003263
3264deviate_replace_end: ';'
Pavol Vican4766aca2016-03-07 12:42:36 +01003265 | '{' stmtsep
3266 deviate_replace_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01003267 '}' ;
3268
Pavol Vicancae54882016-03-30 12:24:43 +02003269deviate_replace_opt_stmt: @EMPTYDIR@ { if (read_all) {
Pavol Vican4766aca2016-03-07 12:42:36 +01003270 $$.deviation = actual;
3271 actual_type = REPLACE_KEYWORD;
3272 }
3273 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01003274 | deviate_replace_opt_stmt type_stmt stmtsep { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003275 if (unres_schema_add_node(trg, unres, $1.deviation->deviate->type, UNRES_TYPE_DER, $1.deviation->target)) {
Pavol Vican4766aca2016-03-07 12:42:36 +01003276 YYERROR;
3277 }
3278 }
3279 }
3280 | deviate_replace_opt_stmt units_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003281 if (yang_read_deviate_units(trg->ctx, $1.deviation, s)) {
Pavol Vican4766aca2016-03-07 12:42:36 +01003282 YYERROR;
3283 }
3284 s = NULL;
3285 $$ = $1;
3286 }
3287 }
3288 | deviate_replace_opt_stmt default_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003289 if (yang_read_deviate_default(trg->ctx, $1.deviation, s)) {
Pavol Vican4766aca2016-03-07 12:42:36 +01003290 YYERROR;
3291 }
3292 s = NULL;
3293 $$ = $1;
3294 }
3295 }
3296 | deviate_replace_opt_stmt config_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003297 if (yang_read_deviate_config($1.deviation, $2)) {
Pavol Vican4766aca2016-03-07 12:42:36 +01003298 YYERROR;
3299 }
3300 $$ = $1;
3301 }
3302 }
3303 | deviate_replace_opt_stmt mandatory_stmt { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003304 if (yang_read_deviate_mandatory($1.deviation, $2)) {
Pavol Vican4766aca2016-03-07 12:42:36 +01003305 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 Vican0adf01d2016-03-22 12:29:33 +01003312 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "min-elements", "deviate");
Pavol Vican4766aca2016-03-07 12:42:36 +01003313 YYERROR;
3314 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01003315 if (yang_read_deviate_minmax($1.deviation, $2, 0)) {
Pavol Vican4766aca2016-03-07 12:42:36 +01003316 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 Vican0adf01d2016-03-22 12:29:33 +01003323 LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "max-elements", "deviate");
Pavol Vican4766aca2016-03-07 12:42:36 +01003324 YYERROR;
3325 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01003326 if (yang_read_deviate_minmax($1.deviation, $2, 1)) {
Pavol Vican4766aca2016-03-07 12:42:36 +01003327 YYERROR;
3328 }
3329 $$ = $1;
3330 }
3331 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003332
Pavol Vican0adf01d2016-03-22 12:29:33 +01003333when_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 Vicanf4717e62016-03-16 11:30:01 +01003334 when_end;
Pavol Vican6418deb2015-10-28 19:41:26 +01003335
3336when_end: ';'
Pavol Vicanaccd8872016-04-04 10:53:27 +02003337 | '{' stmtsep
Pavol Vican9bcd7c62016-03-17 19:36:35 +01003338 when_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01003339 '}'
Pavol Vican9bcd7c62016-03-17 19:36:35 +01003340
Pavol Vicancae54882016-03-30 12:24:43 +02003341when_opt_stmt: @EMPTYDIR@
Pavol Vican0adf01d2016-03-22 12:29:33 +01003342 | when_opt_stmt description_stmt { if (read_all && yang_read_description(trg, actual, s, "when")) {
Pavol Vican9bcd7c62016-03-17 19:36:35 +01003343 YYERROR;
3344 }
3345 s = NULL;
3346 }
Pavol Vican0adf01d2016-03-22 12:29:33 +01003347 | when_opt_stmt reference_stmt { if (read_all && yang_read_reference(trg, actual, s, "when")) {
Pavol Vicanf5fe9662016-03-17 20:00:16 +01003348 YYERROR;
3349 }
3350 s = NULL;
3351 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003352
Pavol Vicanb5687112016-02-09 22:35:59 +01003353config_stmt: CONFIG_KEYWORD sep config_arg_str stmtend { $$ = $3; }
Pavol Vican6418deb2015-10-28 19:41:26 +01003354
Pavol Vicane4084022016-03-19 13:12:52 +01003355config_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 Vican4fb66c92016-03-17 10:32:27 +01003357 stmtend { $$ = $4; }
3358
Pavol Vicanb5687112016-02-09 22:35:59 +01003359config_arg_str: TRUE_KEYWORD optsep { $$ = LYS_CONFIG_W; }
3360 | FALSE_KEYWORD optsep { $$ = LYS_CONFIG_R; }
Pavol Vican4fb66c92016-03-17 10:32:27 +01003361 | 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 Vican0adf01d2016-03-22 12:29:33 +01003367 LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "config");
Pavol Vican4fb66c92016-03-17 10:32:27 +01003368 free(s);
3369 YYERROR;
3370 }
3371 free(s);
3372 s = NULL;
3373 }
3374 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003375
Pavol Vican8c82fa82016-02-10 13:13:24 +01003376mandatory_stmt: MANDATORY_KEYWORD sep mandatory_arg_str stmtend { $$ = $3; }
Pavol Vican6418deb2015-10-28 19:41:26 +01003377
Pavol Vicane4084022016-03-19 13:12:52 +01003378mandatory_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 Vican8c82fa82016-02-10 13:13:24 +01003382mandatory_arg_str: TRUE_KEYWORD optsep { $$ = LYS_MAND_TRUE; }
3383 | FALSE_KEYWORD optsep { $$ = LYS_MAND_FALSE; }
Pavol Vicane4084022016-03-19 13:12:52 +01003384 | 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 Vican0adf01d2016-03-22 12:29:33 +01003390 LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "mandatory");
Pavol Vicane4084022016-03-19 13:12:52 +01003391 free(s);
3392 YYERROR;
3393 }
3394 free(s);
3395 s = NULL;
3396 }
3397 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003398
3399presence_stmt: PRESENCE_KEYWORD sep string stmtend;
3400
Pavol Vicanbeecbb02016-02-11 16:43:11 +01003401min_elements_stmt: MIN_ELEMENTS_KEYWORD sep min_value_arg_str stmtend { $$ = $3; }
Pavol Vican6418deb2015-10-28 19:41:26 +01003402
Pavol Vicanbeecbb02016-02-11 16:43:11 +01003403min_value_arg_str: non_negative_integer_value optsep { $$ = $1; }
Pavol Vican796d1fd2016-03-21 08:49:39 +01003404 | 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 Vican802af1e2016-03-23 20:42:26 +01003412 val = strtoul(yyget_text(scanner), &endptr, 10);
Pavol Vican796d1fd2016-03-21 08:49:39 +01003413 if (val > UINT32_MAX || *endptr) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003414 LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "min-elements");
Pavol Vican796d1fd2016-03-21 08:49:39 +01003415 free(s);
3416 YYERROR;
3417 }
3418 $$ = (uint32_t) val;
3419 }
3420 free(s);
3421 s = NULL;
3422 }
3423 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003424
Pavol Vicanbeecbb02016-02-11 16:43:11 +01003425max_elements_stmt: MAX_ELEMENTS_KEYWORD sep max_value_arg_str stmtend { $$ = $3; }
Pavol Vican6418deb2015-10-28 19:41:26 +01003426
Pavol Vican796d1fd2016-03-21 08:49:39 +01003427max_value_arg_str: UNBOUNDED_KEYWORD optsep { $$ = 0; }
Pavol Vicanbeecbb02016-02-11 16:43:11 +01003428 | positive_integer_value optsep { $$ = $1; }
Pavol Vican796d1fd2016-03-21 08:49:39 +01003429 | 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 Vican802af1e2016-03-23 20:42:26 +01003437 val = strtoul(yyget_text(scanner), &endptr, 10);
Pavol Vican796d1fd2016-03-21 08:49:39 +01003438 if (val > UINT32_MAX || *endptr) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003439 LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, s, "max-elements");
Pavol Vican796d1fd2016-03-21 08:49:39 +01003440 free(s);
3441 YYERROR;
3442 }
3443 $$ = (uint32_t) val;
3444 }
3445 free(s);
3446 s = NULL;
3447 }
3448 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003449
Pavol Vicanbe057c02016-02-11 19:08:08 +01003450ordered_by_stmt: ORDERED_BY_KEYWORD sep ordered_by_arg_str stmtend { $$ = $3; }
Pavol Vican6418deb2015-10-28 19:41:26 +01003451
Pavol Vicanbe057c02016-02-11 19:08:08 +01003452ordered_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 Vican6418deb2015-10-28 19:41:26 +01003465
Pavol Vicanf37eeaa2016-02-09 20:54:06 +01003466must_stmt: MUST_KEYWORD sep string { if (read_all) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003467 if (!(actual=yang_read_must(trg, actual, s, actual_type))) {YYERROR;}
Pavol Vicanf37eeaa2016-02-09 20:54:06 +01003468 s=NULL;
3469 actual_type=MUST_KEYWORD;
3470 }
3471 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01003472 must_end;
Pavol Vican6418deb2015-10-28 19:41:26 +01003473
3474must_end: ';'
Pavol Vican8c82fa82016-02-10 13:13:24 +01003475 | '{' stmtsep
3476 message_opt_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01003477 '}'
3478 ;
3479
Pavol Vicancae54882016-03-30 12:24:43 +02003480unique_stmt: UNIQUE_KEYWORD sep unique_arg_str;
Pavol Vican6418deb2015-10-28 19:41:26 +01003481
Pavol Vicancae54882016-03-30 12:24:43 +02003482unique_arg_str: descendant_schema_nodeid unique_arg
Pavol Vican6418deb2015-10-28 19:41:26 +01003483 | string_1 stmtend;
3484
3485unique_arg: sep descendant_schema_nodeid unique_arg
3486 | stmtend;
3487
Pavol Vicancae54882016-03-30 12:24:43 +02003488key_stmt: KEY_KEYWORD sep key_arg_str;
Pavol Vican6418deb2015-10-28 19:41:26 +01003489
Pavol Vican5de33492016-02-22 14:03:24 +01003490key_arg_str: node_identifier { if (read_all){
Pavol Vican802af1e2016-03-23 20:42:26 +01003491 s = strdup(yyget_text(scanner));
Pavol Vican5de33492016-02-22 14:03:24 +01003492 if (!s) {
3493 LOGMEM;
3494 YYERROR;
3495 }
3496 }
3497 }
3498 key_opt
Pavol Vican6418deb2015-10-28 19:41:26 +01003499 | string_1 stmtend
3500 ;
3501
Pavol Vican5de33492016-02-22 14:03:24 +01003502key_opt: sep node_identifier { if (read_all) {
Pavol Vican802af1e2016-03-23 20:42:26 +01003503 s = ly_realloc(s,strlen(s) + yyget_leng(scanner) + 2);
Pavol Vican5de33492016-02-22 14:03:24 +01003504 if (!s) {
3505 LOGMEM;
3506 YYERROR;
3507 }
3508 strcat(s," ");
Pavol Vican802af1e2016-03-23 20:42:26 +01003509 strcat(s, yyget_text(scanner));
Pavol Vican5de33492016-02-22 14:03:24 +01003510 }
3511 }
3512 key_opt
Pavol Vicancae54882016-03-30 12:24:43 +02003513 | stmtend
Pavol Vican6418deb2015-10-28 19:41:26 +01003514 ;
3515
Pavol Vicanaff5c802016-02-24 15:56:45 +01003516range_arg_str: string { if (read_all) {
3517 $$ = actual;
Pavol Vican0adf01d2016-03-22 12:29:33 +01003518 if (!(actual = yang_read_range(trg, actual, s))) {
Pavol Vicanaff5c802016-02-24 15:56:45 +01003519 YYERROR;
3520 }
3521 actual_type = RANGE_KEYWORD;
3522 s = NULL;
3523 }
3524 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003525
Pavol Vican57032c02016-02-26 15:24:00 +01003526absolute_schema_nodeid: '/' node_identifier { if (read_all) {
Pavol Vican5de33492016-02-22 14:03:24 +01003527 if (s) {
Pavol Vican802af1e2016-03-23 20:42:26 +01003528 s = ly_realloc(s,strlen(s) + yyget_leng(scanner) + 2);
Pavol Vican5de33492016-02-22 14:03:24 +01003529 if (!s) {
3530 LOGMEM;
3531 YYERROR;
3532 }
3533 strcat(s,"/");
Pavol Vican802af1e2016-03-23 20:42:26 +01003534 strcat(s, yyget_text(scanner));
Pavol Vican5de33492016-02-22 14:03:24 +01003535 } else {
Pavol Vican802af1e2016-03-23 20:42:26 +01003536 s = malloc(yyget_leng(scanner) + 2);
Pavol Vican5de33492016-02-22 14:03:24 +01003537 if (!s) {
3538 LOGMEM;
3539 YYERROR;
3540 }
3541 s[0]='/';
Pavol Vican802af1e2016-03-23 20:42:26 +01003542 memcpy(s + 1, yyget_text(scanner), yyget_leng(scanner) + 1);
Pavol Vican5de33492016-02-22 14:03:24 +01003543 }
3544 }
3545 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003546
3547absolute_schema_nodeids: absolute_schema_nodeid absolute_schema_nodeid_opt;
3548
Pavol Vicancae54882016-03-30 12:24:43 +02003549absolute_schema_nodeid_opt: @EMPTYDIR@
Pavol Vican6418deb2015-10-28 19:41:26 +01003550 | absolute_schema_nodeid_opt absolute_schema_nodeid
3551 ;
3552
Pavol Vican5de33492016-02-22 14:03:24 +01003553descendant_schema_nodeid: node_identifier { if (read_all) {
3554 if (s) {
Pavol Vican802af1e2016-03-23 20:42:26 +01003555 s = ly_realloc(s,strlen(s) + yyget_leng(scanner) + 1);
Pavol Vican5de33492016-02-22 14:03:24 +01003556 if (!s) {
3557 LOGMEM;
3558 YYERROR;
3559 }
Pavol Vican802af1e2016-03-23 20:42:26 +01003560 strcat(s, yyget_text(scanner));
Pavol Vican5de33492016-02-22 14:03:24 +01003561 } else {
Pavol Vican802af1e2016-03-23 20:42:26 +01003562 s = strdup(yyget_text(scanner));
Pavol Vican5de33492016-02-22 14:03:24 +01003563 if (!s) {
3564 LOGMEM;
3565 YYERROR;
3566 }
3567 }
3568 }
3569 }
3570 absolute_schema_nodeid_opt;
Pavol Vican6418deb2015-10-28 19:41:26 +01003571
Pavol Vican802af1e2016-03-23 20:42:26 +01003572path_arg_str: { tmp_s = yyget_text(scanner); } absolute_paths { if (read_all) {
Pavol Vican191613a2016-02-26 16:21:32 +01003573 s = strdup(tmp_s);
3574 if (!s) {
3575 LOGMEM;
3576 YYERROR;
3577 }
3578 s[strlen(s) - 1] = '\0';
3579 }
3580 }
Pavol Vican802af1e2016-03-23 20:42:26 +01003581 | { tmp_s = yyget_text(scanner); } relative_path { if (read_all) {
Pavol Vican191613a2016-02-26 16:21:32 +01003582 s = strdup(tmp_s);
3583 if (!s) {
3584 LOGMEM;
3585 YYERROR;
3586 }
3587 s[strlen(s) - 1] = '\0';
3588 }
3589 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003590 | string_1
3591 ;
3592
Pavol Vican57032c02016-02-26 15:24:00 +01003593absolute_path: '/' node_identifier path_predicate
Pavol Vican6418deb2015-10-28 19:41:26 +01003594
3595absolute_paths: absolute_path absolute_path_opt
3596
Pavol Vicancae54882016-03-30 12:24:43 +02003597absolute_path_opt: @EMPTYDIR@
Pavol Vican6418deb2015-10-28 19:41:26 +01003598 | absolute_path_opt absolute_path;
3599
3600relative_path: relative_path_part1 relative_path_part1_opt descendant_path
3601
Pavol Vican57032c02016-02-26 15:24:00 +01003602relative_path_part1: DOUBLEDOT '/';
Pavol Vican6418deb2015-10-28 19:41:26 +01003603
Pavol Vicancae54882016-03-30 12:24:43 +02003604relative_path_part1_opt: @EMPTYDIR@
Pavol Vican6418deb2015-10-28 19:41:26 +01003605 | relative_path_part1_opt relative_path_part1;
3606
3607descendant_path: node_identifier descendant_path_opt
3608
Pavol Vicancae54882016-03-30 12:24:43 +02003609descendant_path_opt: @EMPTYDIR@
Pavol Vican6418deb2015-10-28 19:41:26 +01003610 | path_predicate absolute_paths;
3611
Pavol Vicancae54882016-03-30 12:24:43 +02003612path_predicate: @EMPTYDIR@
Pavol Vican57032c02016-02-26 15:24:00 +01003613 | path_predicate '[' whitespace_opt path_equality_expr whitespace_opt ']'
Pavol Vican6418deb2015-10-28 19:41:26 +01003614
Pavol Vican57032c02016-02-26 15:24:00 +01003615path_equality_expr: node_identifier whitespace_opt '=' whitespace_opt path_key_expr
Pavol Vican6418deb2015-10-28 19:41:26 +01003616
Pavol Vican57032c02016-02-26 15:24:00 +01003617path_key_expr: current_function_invocation whitespace_opt '/' whitespace_opt
Pavol Vican6418deb2015-10-28 19:41:26 +01003618 rel_path_keyexpr
3619
3620rel_path_keyexpr: rel_path_keyexpr_part1 rel_path_keyexpr_part1_opt
3621 node_identifier rel_path_keyexpr_part2
3622 node_identifier
3623
Pavol Vican57032c02016-02-26 15:24:00 +01003624rel_path_keyexpr_part1: DOUBLEDOT whitespace_opt '/' whitespace_opt;
Pavol Vican6418deb2015-10-28 19:41:26 +01003625
Pavol Vicancae54882016-03-30 12:24:43 +02003626rel_path_keyexpr_part1_opt: @EMPTYDIR@
Pavol Vican6418deb2015-10-28 19:41:26 +01003627 | rel_path_keyexpr_part1_opt rel_path_keyexpr_part1;
3628
Pavol Vicancae54882016-03-30 12:24:43 +02003629rel_path_keyexpr_part2: @EMPTYDIR@
Pavol Vican57032c02016-02-26 15:24:00 +01003630 | rel_path_keyexpr_part2 whitespace_opt '/' whitespace_opt node_identifier;
Pavol Vican6418deb2015-10-28 19:41:26 +01003631
Pavol Vican57032c02016-02-26 15:24:00 +01003632current_function_invocation: CURRENT_KEYWORD whitespace_opt '(' whitespace_opt ')'
Pavol Vican6418deb2015-10-28 19:41:26 +01003633
Pavol Vicanbeecbb02016-02-11 16:43:11 +01003634positive_integer_value: NON_NEGATIVE_INTEGER { /* convert it to uint32_t */
3635 unsigned long val;
3636
Pavol Vican802af1e2016-03-23 20:42:26 +01003637 val = strtoul(yyget_text(scanner), NULL, 10);
Pavol Vicanbeecbb02016-02-11 16:43:11 +01003638 if (val > UINT32_MAX) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003639 LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Converted number is very long.");
Pavol Vicanbeecbb02016-02-11 16:43:11 +01003640 YYERROR;
3641 }
3642 $$ = (uint32_t) val;
3643 }
3644
3645non_negative_integer_value: ZERO { $$ = 0; }
3646 | positive_integer_value { $$ = $1; }
Pavol Vican6418deb2015-10-28 19:41:26 +01003647 ;
3648
Pavol Vican79a763d2016-02-25 15:41:27 +01003649integer_value: ZERO { $$ = 0; }
3650 | integer_value_convert { /* convert it to int32_t */
3651 int64_t val;
3652
Pavol Vican802af1e2016-03-23 20:42:26 +01003653 val = strtoll(yyget_text(scanner), NULL, 10);
Pavol Vican79a763d2016-02-25 15:41:27 +01003654 if (val < INT32_MIN || val > INT32_MAX) {
Pavol Vican0adf01d2016-03-22 12:29:33 +01003655 LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "The number is not in the correct range (INT32_MIN..INT32_MAX): \"%d\"",val);
Pavol Vican79a763d2016-02-25 15:41:27 +01003656 YYERROR;
3657 }
3658 $$ = (int32_t) val;
3659 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003660 ;
3661
Pavol Vican79a763d2016-02-25 15:41:27 +01003662integer_value_convert: INTEGER
3663 | NON_NEGATIVE_INTEGER
3664
Pavol Vican6418deb2015-10-28 19:41:26 +01003665prefix_arg_str: string_1
Pavol Vican021488a2016-01-25 23:56:12 +01003666 | identifiers optsep;
Pavol Vican6418deb2015-10-28 19:41:26 +01003667
Pavol Vicancae54882016-03-30 12:24:43 +02003668identifier_arg_str: identifiers optsep
Pavol Vican0adf01d2016-03-22 12:29:33 +01003669 | string_1 { if (read_all && lyp_check_identifier(s, LY_IDENT_SIMPLE, trg, NULL)) {
Pavol Vican796d1fd2016-03-21 08:49:39 +01003670 free(s);
3671 YYERROR;
3672 }
3673 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003674
Pavol Vican5de33492016-02-22 14:03:24 +01003675node_identifier: identifier
3676 | IDENTIFIERPREFIX
Pavol Vicancae54882016-03-30 12:24:43 +02003677 ;
Pavol Vican6418deb2015-10-28 19:41:26 +01003678
Pavol Vican021488a2016-01-25 23:56:12 +01003679identifier_ref_arg_str: identifiers optsep
Pavol Vicanbbdef532016-02-09 14:52:12 +01003680 | identifiers_ref optsep
Pavol Vican796d1fd2016-03-21 08:49:39 +01003681 | string_1 { if (read_all) {
3682 char *tmp;
3683
3684 if ((tmp = strchr(s, ':'))) {
3685 *tmp = '\0';
3686 /* check prefix */
Pavol Vican0adf01d2016-03-22 12:29:33 +01003687 if (lyp_check_identifier(s, LY_IDENT_SIMPLE, trg, NULL)) {
Pavol Vican796d1fd2016-03-21 08:49:39 +01003688 free(s);
3689 YYERROR;
3690 }
3691 /* check identifier */
Pavol Vican0adf01d2016-03-22 12:29:33 +01003692 if (lyp_check_identifier(tmp + 1, LY_IDENT_SIMPLE, trg, NULL)) {
Pavol Vican796d1fd2016-03-21 08:49:39 +01003693 free(s);
3694 YYERROR;
3695 }
3696 *tmp = ':';
3697 } else {
Pavol Vican0da132e2016-03-21 12:03:03 +01003698 /* check identifier */
Pavol Vican0adf01d2016-03-22 12:29:33 +01003699 if (lyp_check_identifier(s, LY_IDENT_SIMPLE, trg, NULL)) {
Pavol Vican796d1fd2016-03-21 08:49:39 +01003700 free(s);
3701 YYERROR;
3702 }
3703 }
3704 }
3705 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003706
3707stmtend: ';' stmtsep
3708 | '{' stmtsep '}' stmtsep
3709 ;
3710
Pavol Vicancae54882016-03-30 12:24:43 +02003711stmtsep: @EMPTYDIR@
3712 | stmtsep sep_stmt
Pavol Vican6418deb2015-10-28 19:41:26 +01003713 | stmtsep unknown_statement
3714 ;
3715
Pavol Vicana302aa62016-03-17 10:45:35 +01003716unknown_statement: IDENTIFIERPREFIX { if (read_all ) {
Pavol Vican802af1e2016-03-23 20:42:26 +01003717 if (yang_use_extension(trg, data_node, actual, yyget_text(scanner))) {
Pavol Vicanf4717e62016-03-16 11:30:01 +01003718 YYERROR;
3719 }
Pavol Vicanf4717e62016-03-16 11:30:01 +01003720 }
3721 }
3722 string_opt unknown_statement_end
Pavol Vican6418deb2015-10-28 19:41:26 +01003723
Pavol Vican14bd3182016-03-16 12:37:10 +01003724string_opt: string_opt_part1 string_opt_part2
3725
Pavol Vicancae54882016-03-30 12:24:43 +02003726string_opt_part1: @EMPTYDIR@
Pavol Vican14bd3182016-03-16 12:37:10 +01003727 | sep
3728
Pavol Vicancae54882016-03-30 12:24:43 +02003729string_opt_part2: @EMPTYDIR@
Pavol Vican14bd3182016-03-16 12:37:10 +01003730 | STRING optsep string_opt_part3
3731
Pavol Vicancae54882016-03-30 12:24:43 +02003732string_opt_part3: @EMPTYDIR@
Pavol Vican14bd3182016-03-16 12:37:10 +01003733 | string_opt_part3 '+' optsep STRING optsep
Pavol Vican6418deb2015-10-28 19:41:26 +01003734
Pavol Vicancae54882016-03-30 12:24:43 +02003735unknown_statement_end: ';'
Pavol Vican6418deb2015-10-28 19:41:26 +01003736 | '{' optsep unknown_statement2_opt '}'
3737
Pavol Vicancae54882016-03-30 12:24:43 +02003738unknown_statement2_opt: @EMPTYDIR@
Pavol Vican6418deb2015-10-28 19:41:26 +01003739 | node_identifier string_opt unknown_statement2_end;
3740
3741unknown_statement2_end: ';' optsep
3742 | '{' optsep unknown_statement2_opt '}' optsep
3743
3744sep_stmt: WHITESPACE
3745 | EOL
3746 ;
3747
Pavol Vicancae54882016-03-30 12:24:43 +02003748optsep: @EMPTYDIR@
Pavol Vican6418deb2015-10-28 19:41:26 +01003749 | optsep sep_stmt
Pavol Vicancae54882016-03-30 12:24:43 +02003750 ;
Pavol Vican6418deb2015-10-28 19:41:26 +01003751
3752sep: sep_stmt optsep;
3753
Pavol Vicancae54882016-03-30 12:24:43 +02003754whitespace_opt: @EMPTYDIR@
Pavol Vican6418deb2015-10-28 19:41:26 +01003755 | WHITESPACE
3756 ;
3757
3758
Pavol Vican305a6332016-03-09 21:08:09 +01003759string: strings { if (read_all){
Pavol Vican802af1e2016-03-23 20:42:26 +01003760 s = strdup(yyget_text(scanner));
Pavol Vican73e7c992016-02-24 12:18:05 +01003761 if (!s) {
3762 LOGMEM;
3763 YYERROR;
3764 }
3765 }
3766 }
3767 optsep
Pavol Vican305a6332016-03-09 21:08:09 +01003768 | string_1
3769
3770strings: STRINGS
3771 | REVISION_DATE
3772 | identifier
3773 | IDENTIFIERPREFIX
3774 | ZERO
3775 | INTEGER
3776 | NON_NEGATIVE_INTEGER
Pavol Vican6418deb2015-10-28 19:41:26 +01003777
3778identifier: 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 Vican6418deb2015-10-28 19:41:26 +01003849 | NOT_SUPPORTED_KEYWORD
3850 | OBSOLETE_KEYWORD
3851 | REPLACE_KEYWORD
3852 | SYSTEM_KEYWORD
3853 | TRUE_KEYWORD
3854 | UNBOUNDED_KEYWORD
3855 | USER_KEYWORD
3856 ;
3857
Pavol Vican1eeb1992016-02-09 11:10:45 +01003858identifiers: identifier { if (read_all) {
Pavol Vican802af1e2016-03-23 20:42:26 +01003859 s = strdup(yyget_text(scanner));
Pavol Vican1eeb1992016-02-09 11:10:45 +01003860 if (!s) {
3861 LOGMEM;
3862 YYERROR;
3863 }
3864 }
3865 }
Pavol Vican6418deb2015-10-28 19:41:26 +01003866
Pavol Vicanbbdef532016-02-09 14:52:12 +01003867identifiers_ref: IDENTIFIERPREFIX { if (read_all) {
Pavol Vican802af1e2016-03-23 20:42:26 +01003868 s = strdup(yyget_text(scanner));
Pavol Vicanbbdef532016-02-09 14:52:12 +01003869 if (!s) {
3870 LOGMEM;
3871 YYERROR;
3872 }
3873 }
3874 }
3875
Pavol Vican6418deb2015-10-28 19:41:26 +01003876%%
3877
Pavol Vican8760bb72016-04-07 09:44:01 +02003878void yyerror(YYLTYPE *yylloc, void *scanner, ...){
Pavol Vican6418deb2015-10-28 19:41:26 +01003879
Pavol Vican8760bb72016-04-07 09:44:01 +02003880 (void)yylloc; /* unused */
Pavol Vican802af1e2016-03-23 20:42:26 +01003881 LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, yyget_text(scanner));
Pavol Vican6418deb2015-10-28 19:41:26 +01003882}