Vidyashree Rama
Committed by Gerrit Code Review

YANG sub module linking + unsupported yang construct + defect fix

Change-Id: I224c8c14ee2111f6844278cb540c48651544f59b
Showing 55 changed files with 1914 additions and 613 deletions
...@@ -57,6 +57,11 @@ public class YangBelongsTo implements Parsable { ...@@ -57,6 +57,11 @@ public class YangBelongsTo implements Parsable {
57 private String belongsToModuleName; 57 private String belongsToModuleName;
58 58
59 /** 59 /**
60 + * Module node to which sub-module belongs to.
61 + */
62 + private YangNode moduleNode;
63 +
64 + /**
60 * Reference RFC 6020. 65 * Reference RFC 6020.
61 * 66 *
62 * The mandatory "prefix" substatement assigns a prefix for the module to 67 * The mandatory "prefix" substatement assigns a prefix for the module to
...@@ -110,6 +115,24 @@ public class YangBelongsTo implements Parsable { ...@@ -110,6 +115,24 @@ public class YangBelongsTo implements Parsable {
110 } 115 }
111 116
112 /** 117 /**
118 + * Returns the module data model node.
119 + *
120 + * @return the module data model node
121 + */
122 + public YangNode getModuleNode() {
123 + return moduleNode;
124 + }
125 +
126 + /**
127 + * Sets the module node.
128 + *
129 + * @param moduleNode module data model node
130 + */
131 + public void setModuleNode(YangNode moduleNode) {
132 + this.moduleNode = moduleNode;
133 + }
134 +
135 + /**
113 * Returns the type of the data as belongs-to. 136 * Returns the type of the data as belongs-to.
114 * 137 *
115 * @return ParsedDataType returns BELONGS_TO_DATA 138 * @return ParsedDataType returns BELONGS_TO_DATA
......
...@@ -135,6 +135,12 @@ public class YangChoice extends YangNode ...@@ -135,6 +135,12 @@ public class YangChoice extends YangNode
135 private YangStatusType status; 135 private YangStatusType status;
136 136
137 /** 137 /**
138 + * Default value in string, needs to be converted to the target object,
139 + * based on the type.
140 + */
141 + private String defaultValueInString;
142 +
143 + /**
138 * Create a choice node. 144 * Create a choice node.
139 */ 145 */
140 public YangChoice() { 146 public YangChoice() {
...@@ -276,6 +282,24 @@ public class YangChoice extends YangNode ...@@ -276,6 +282,24 @@ public class YangChoice extends YangNode
276 } 282 }
277 283
278 /** 284 /**
285 + * Returns the default value.
286 + *
287 + * @return the default value
288 + */
289 + public String getDefaultValueInString() {
290 + return defaultValueInString;
291 + }
292 +
293 + /**
294 + * Sets the default value.
295 + *
296 + * @param defaultValueInString the default value
297 + */
298 + public void setDefaultValueInString(String defaultValueInString) {
299 + this.defaultValueInString = defaultValueInString;
300 + }
301 +
302 + /**
279 * Returns the type of the data. 303 * Returns the type of the data.
280 * 304 *
281 * @return choice data 305 * @return choice data
......
...@@ -101,6 +101,12 @@ public class YangLeaf ...@@ -101,6 +101,12 @@ public class YangLeaf
101 private YangType<?> dataType; 101 private YangType<?> dataType;
102 102
103 /** 103 /**
104 + * Default value in string, needs to be converted to the target object,
105 + * based on the type.
106 + */
107 + private String defaultValueInString;
108 +
109 + /**
104 * Creates a YANG leaf. 110 * Creates a YANG leaf.
105 */ 111 */
106 public YangLeaf() { 112 public YangLeaf() {
...@@ -239,6 +245,24 @@ public class YangLeaf ...@@ -239,6 +245,24 @@ public class YangLeaf
239 } 245 }
240 246
241 /** 247 /**
248 + * Returns the default value.
249 + *
250 + * @return the default value
251 + */
252 + public String getDefaultValueInString() {
253 + return defaultValueInString;
254 + }
255 +
256 + /**
257 + * Sets the default value.
258 + *
259 + * @param defaultValueInString the default value
260 + */
261 + public void setDefaultValueInString(String defaultValueInString) {
262 + this.defaultValueInString = defaultValueInString;
263 + }
264 +
265 + /**
242 * Returns the data type. 266 * Returns the data type.
243 * 267 *
244 * @return the data type 268 * @return the data type
......
...@@ -445,16 +445,10 @@ public class YangList extends YangNode ...@@ -445,16 +445,10 @@ public class YangList extends YangNode
445 445
446 /* A list must have atleast one key leaf if config is true */ 446 /* A list must have atleast one key leaf if config is true */
447 if (isConfig 447 if (isConfig
448 - && (keys == null || leaves == null && leafLists == null)) { 448 + && (keys == null || leaves == null && leafLists == null && !isUsesPresentInList())) {
449 throw new DataModelException("A list must have atleast one key leaf if config is true;"); 449 throw new DataModelException("A list must have atleast one key leaf if config is true;");
450 } else if (keys != null) { 450 } else if (keys != null) {
451 - if (leaves != null) { 451 + validateKey(leaves, leafLists, keys);
452 - validateLeafKey(leaves, keys);
453 - }
454 -
455 - if (leafLists != null) {
456 - validateLeafListKey(leafLists, keys);
457 - }
458 } 452 }
459 } 453 }
460 454
...@@ -528,18 +522,22 @@ public class YangList extends YangNode ...@@ -528,18 +522,22 @@ public class YangList extends YangNode
528 * Validates key statement of list. 522 * Validates key statement of list.
529 * 523 *
530 * @param leaves list of leaf attributes of list 524 * @param leaves list of leaf attributes of list
525 + * @param leafLists list of leaf-list attributes of list
531 * @param keys list of key attributes of list 526 * @param keys list of key attributes of list
532 * @throws DataModelException a violation of data model rules 527 * @throws DataModelException a violation of data model rules
533 */ 528 */
534 - private void validateLeafKey(List<YangLeaf> leaves, List<String> keys) throws DataModelException { 529 + private void validateKey(List<YangLeaf> leaves, List<YangLeafList> leafLists, List<String> keys) throws
530 + DataModelException {
535 boolean leafFound = false; 531 boolean leafFound = false;
536 List<YangLeaf> keyLeaves = new LinkedList<>(); 532 List<YangLeaf> keyLeaves = new LinkedList<>();
533 + List<YangLeafList> keyLeafLists = new LinkedList<>();
537 534
538 /* 535 /*
539 * 1. Leaf identifier must refer to a child leaf of the list 2. A leaf 536 * 1. Leaf identifier must refer to a child leaf of the list 2. A leaf
540 * that is part of the key must not be the built-in type "empty". 537 * that is part of the key must not be the built-in type "empty".
541 */ 538 */
542 for (String key : keys) { 539 for (String key : keys) {
540 + if (leaves != null && !leaves.isEmpty()) {
543 for (YangLeaf leaf : leaves) { 541 for (YangLeaf leaf : leaves) {
544 if (key.equals(leaf.getName())) { 542 if (key.equals(leaf.getName())) {
545 if (leaf.getDataType().getDataType() == YangDataTypes.EMPTY) { 543 if (leaf.getDataType().getDataType() == YangDataTypes.EMPTY) {
...@@ -551,53 +549,24 @@ public class YangList extends YangNode ...@@ -551,53 +549,24 @@ public class YangList extends YangNode
551 break; 549 break;
552 } 550 }
553 } 551 }
554 - if (!leafFound) {
555 - throw new DataModelException("Leaf identifier must refer to a child leaf of the list");
556 - }
557 - leafFound = false;
558 - }
559 -
560 - /*
561 - * All key leafs in a list MUST have the same value for their "config"
562 - * as the list itself.
563 - */
564 - for (YangLeaf keyLeaf : keyLeaves) {
565 - if (isConfig != keyLeaf.isConfig()) {
566 - throw new DataModelException("All key leafs in a list must have the same value for their" +
567 - " \"config\" as the list itself.");
568 - }
569 - }
570 } 552 }
571 553
572 - /** 554 + if (leafLists != null && !leafLists.isEmpty()) {
573 - * Validates key statement of list.
574 - *
575 - * @param leafLists list of leaf-list attributes of list
576 - * @param keys list of key attributes of list
577 - * @throws DataModelException a violation of data model rules
578 - */
579 - private void validateLeafListKey(List<YangLeafList> leafLists, List<String> keys) throws DataModelException {
580 - boolean leafFound = false;
581 - List<YangLeafList> keyLeafLists = new LinkedList<>();
582 -
583 - /*
584 - * 1. Leaf identifier must refer to a child leaf of the list 2. A leaf
585 - * that is part of the key must not be the built-in type "empty".
586 - */
587 - for (String key : keys) {
588 for (YangLeafList leafList : leafLists) { 555 for (YangLeafList leafList : leafLists) {
589 if (key.equals(leafList.getName())) { 556 if (key.equals(leafList.getName())) {
590 if (leafList.getDataType().getDataType() == YangDataTypes.EMPTY) { 557 if (leafList.getDataType().getDataType() == YangDataTypes.EMPTY) {
591 - throw new DataModelException(" A leaf-list that is part of the key must not be the built-in " + 558 + throw new DataModelException(" A leaf-list that is part of the key" +
592 - "type \"empty\"."); 559 + " must not be the built-in type \"empty\".");
593 } 560 }
594 leafFound = true; 561 leafFound = true;
595 keyLeafLists.add(leafList); 562 keyLeafLists.add(leafList);
596 break; 563 break;
597 } 564 }
598 } 565 }
599 - if (!leafFound) { 566 + }
600 - throw new DataModelException("Leaf-list identifier must refer to a child leaf of the list"); 567 +
568 + if (!leafFound && !isUsesPresentInList()) {
569 + throw new DataModelException("An identifier, in key, must refer to a child leaf of the list");
601 } 570 }
602 leafFound = false; 571 leafFound = false;
603 } 572 }
...@@ -606,6 +575,17 @@ public class YangList extends YangNode ...@@ -606,6 +575,17 @@ public class YangList extends YangNode
606 * All key leafs in a list MUST have the same value for their "config" 575 * All key leafs in a list MUST have the same value for their "config"
607 * as the list itself. 576 * as the list itself.
608 */ 577 */
578 + for (YangLeaf keyLeaf : keyLeaves) {
579 + if (isConfig != keyLeaf.isConfig()) {
580 + throw new DataModelException("All key leafs in a list must have the same value for their" +
581 + " \"config\" as the list itself.");
582 + }
583 + }
584 +
585 + /*
586 + * All key leafs in a list MUST have the same value for their "config"
587 + * as the list itself.
588 + */
609 for (YangLeafList keyLeafList : keyLeafLists) { 589 for (YangLeafList keyLeafList : keyLeafLists) {
610 if (isConfig() != keyLeafList.isConfig()) { 590 if (isConfig() != keyLeafList.isConfig()) {
611 throw new DataModelException("All key leaf-lists in a list must have the same value for their" + 591 throw new DataModelException("All key leaf-lists in a list must have the same value for their" +
...@@ -627,4 +607,16 @@ public class YangList extends YangNode ...@@ -627,4 +607,16 @@ public class YangList extends YangNode
627 getName() + "\""); 607 getName() + "\"");
628 } 608 }
629 } 609 }
610 +
611 + private boolean isUsesPresentInList() {
612 + YangNode node = this.getChild();
613 + while (node != null) {
614 + if (node instanceof YangUses) {
615 + return true;
616 + }
617 + node = node.getNextSibling();
618 + }
619 + return false;
620 + }
621 +
630 } 622 }
......
...@@ -19,6 +19,8 @@ package org.onosproject.yangutils.datamodel; ...@@ -19,6 +19,8 @@ package org.onosproject.yangutils.datamodel;
19 import java.util.LinkedList; 19 import java.util.LinkedList;
20 import java.util.List; 20 import java.util.List;
21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 +import org.onosproject.yangutils.parser.Parsable;
23 +import org.onosproject.yangutils.utils.YangConstructType;
22 import org.onosproject.yangutils.utils.builtindatatype.YangBuiltInDataTypeInfo; 24 import org.onosproject.yangutils.utils.builtindatatype.YangBuiltInDataTypeInfo;
23 25
24 import static org.onosproject.yangutils.utils.builtindatatype.BuiltInTypeObjectFactory.getDataObjectFromString; 26 import static org.onosproject.yangutils.utils.builtindatatype.BuiltInTypeObjectFactory.getDataObjectFromString;
...@@ -55,7 +57,7 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -55,7 +57,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
55 * @param <T> range type (data type) 57 * @param <T> range type (data type)
56 */ 58 */
57 public class YangRangeRestriction<T extends YangBuiltInDataTypeInfo<T>> 59 public class YangRangeRestriction<T extends YangBuiltInDataTypeInfo<T>>
58 - implements YangDesc, YangReference, YangAppErrorInfo { 60 + implements YangDesc, YangReference, YangAppErrorInfo, Parsable {
59 61
60 /** 62 /**
61 * Ascending list of range interval restriction. If the restriction is a 63 * Ascending list of range interval restriction. If the restriction is a
...@@ -311,4 +313,19 @@ public class YangRangeRestriction<T extends YangBuiltInDataTypeInfo<T>> ...@@ -311,4 +313,19 @@ public class YangRangeRestriction<T extends YangBuiltInDataTypeInfo<T>>
311 public void setErrorAppTag(String errTag) { 313 public void setErrorAppTag(String errTag) {
312 errorAppTag = errTag; 314 errorAppTag = errTag;
313 } 315 }
316 +
317 + @Override
318 + public YangConstructType getYangConstructType() {
319 + return YangConstructType.RANGE_DATA;
320 + }
321 +
322 + @Override
323 + public void validateDataOnEntry() throws DataModelException {
324 + //TODO: implement the method.
325 + }
326 +
327 + @Override
328 + public void validateDataOnExit() throws DataModelException {
329 + //TODO: implement the method.
330 + }
314 } 331 }
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
16 16
17 package org.onosproject.yangutils.datamodel; 17 package org.onosproject.yangutils.datamodel;
18 18
19 +import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 +import org.onosproject.yangutils.parser.Parsable;
21 +import org.onosproject.yangutils.utils.YangConstructType;
19 import org.onosproject.yangutils.utils.builtindatatype.YangUint64; 22 import org.onosproject.yangutils.utils.builtindatatype.YangUint64;
20 23
21 /*- 24 /*-
...@@ -28,7 +31,7 @@ import org.onosproject.yangutils.utils.builtindatatype.YangUint64; ...@@ -28,7 +31,7 @@ import org.onosproject.yangutils.utils.builtindatatype.YangUint64;
28 /** 31 /**
29 * Represents the restriction for string data type. 32 * Represents the restriction for string data type.
30 */ 33 */
31 -public class YangStringRestriction { 34 +public class YangStringRestriction implements YangDesc, YangReference, YangAppErrorInfo, Parsable {
32 35
33 /*- 36 /*-
34 * Reference RFC 6020. 37 * Reference RFC 6020.
...@@ -77,6 +80,26 @@ public class YangStringRestriction { ...@@ -77,6 +80,26 @@ public class YangStringRestriction {
77 private YangPatternRestriction patternRestriction; 80 private YangPatternRestriction patternRestriction;
78 81
79 /** 82 /**
83 + * Textual reference.
84 + */
85 + private String reference;
86 +
87 + /**
88 + * Application's error message, to be used for data error.
89 + */
90 + private String errorMessage;
91 +
92 + /**
93 + * Application's error tag, to be filled in data validation error response.
94 + */
95 + private String errorAppTag;
96 +
97 + /**
98 + * Textual description.
99 + */
100 + private String description;
101 +
102 + /**
80 * Creates a YANG string restriction object. 103 * Creates a YANG string restriction object.
81 */ 104 */
82 public YangStringRestriction() { 105 public YangStringRestriction() {
...@@ -129,4 +152,101 @@ public class YangStringRestriction { ...@@ -129,4 +152,101 @@ public class YangStringRestriction {
129 } 152 }
130 getPatternRestriction().addPattern(newPattern); 153 getPatternRestriction().addPattern(newPattern);
131 } 154 }
155 +
156 + /**
157 + * Returns the textual reference of the string restriction.
158 + *
159 + * @return textual reference of the string restriction
160 + */
161 + @Override
162 + public String getReference() {
163 + return reference;
164 + }
165 +
166 + /**
167 + * Sets the textual reference of the string restriction.
168 + *
169 + * @param ref textual reference of the string restriction
170 + */
171 + @Override
172 + public void setReference(String ref) {
173 + reference = ref;
174 + }
175 +
176 + /**
177 + * Returns the description of the string restriction.
178 + *
179 + * @return description of the string restriction
180 + */
181 + @Override
182 + public String getDescription() {
183 + return description;
184 + }
185 +
186 + /**
187 + * Sets the description of the string restriction.
188 + *
189 + * @param desc description of the string restriction
190 + */
191 + @Override
192 + public void setDescription(String desc) {
193 + description = desc;
194 +
195 + }
196 +
197 + /**
198 + * Returns application's error message, to be used for data error.
199 + *
200 + * @return Application's error message, to be used for data error
201 + */
202 + @Override
203 + public String getGetErrorMessage() {
204 + return errorMessage;
205 + }
206 +
207 + /**
208 + * Sets Application's error message, to be used for data error.
209 + *
210 + * @param errMsg Application's error message, to be used for data error
211 + */
212 + @Override
213 + public void setErrorMessage(String errMsg) {
214 + errorMessage = errMsg;
215 +
216 + }
217 +
218 + /**
219 + * Returns application's error tag, to be used for data error.
220 + *
221 + * @return application's error tag, to be used for data error
222 + */
223 + @Override
224 + public String getGetErrorAppTag() {
225 + return errorAppTag;
226 + }
227 +
228 + /**
229 + * Sets application's error tag, to be used for data error.
230 + *
231 + * @param errTag application's error tag, to be used for data error.
232 + */
233 + @Override
234 + public void setErrorAppTag(String errTag) {
235 + errorAppTag = errTag;
236 + }
237 +
238 + @Override
239 + public YangConstructType getYangConstructType() {
240 + return YangConstructType.PATTERN_DATA;
241 + }
242 +
243 + @Override
244 + public void validateDataOnEntry() throws DataModelException {
245 + //TODO: implement the method.
246 + }
247 +
248 + @Override
249 + public void validateDataOnExit() throws DataModelException {
250 + //TODO: implement the method.
251 + }
132 } 252 }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 16
17 package org.onosproject.yangutils.datamodel.utils; 17 package org.onosproject.yangutils.datamodel.utils;
18 18
19 +import java.util.Iterator;
19 import java.util.List; 20 import java.util.List;
20 21
21 import org.onosproject.yangutils.datamodel.CollisionDetector; 22 import org.onosproject.yangutils.datamodel.CollisionDetector;
...@@ -29,6 +30,7 @@ import org.onosproject.yangutils.datamodel.YangResolutionInfo; ...@@ -29,6 +30,7 @@ import org.onosproject.yangutils.datamodel.YangResolutionInfo;
29 import org.onosproject.yangutils.datamodel.YangRpc; 30 import org.onosproject.yangutils.datamodel.YangRpc;
30 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 31 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
31 import org.onosproject.yangutils.parser.Parsable; 32 import org.onosproject.yangutils.parser.Parsable;
33 +import org.onosproject.yangutils.plugin.manager.YangFileInfo;
32 import org.onosproject.yangutils.utils.YangConstructType; 34 import org.onosproject.yangutils.utils.YangConstructType;
33 35
34 /** 36 /**
...@@ -240,4 +242,26 @@ public final class DataModelUtils { ...@@ -240,4 +242,26 @@ public final class DataModelUtils {
240 } 242 }
241 return false; 243 return false;
242 } 244 }
245 +
246 + /**
247 + * Returns module's data model node to which sub-module belongs to.
248 + *
249 + * @param yangFileInfo YANG file information
250 + * @param belongsToModuleName name of the module to which sub-module belongs to
251 + * @return module node to which sub-module belongs to
252 + * @throws DataModelException when belongs to module node is not found
253 + */
254 + public static YangNode findBelongsToModuleNode(List<YangFileInfo> yangFileInfo,
255 + String belongsToModuleName) throws DataModelException {
256 + Iterator<YangFileInfo> yangFileIterator = yangFileInfo.iterator();
257 + while (yangFileIterator.hasNext()) {
258 + YangFileInfo yangFile = yangFileIterator.next();
259 + YangNode yangNode = yangFile.getRootNode();
260 + if (yangNode.getName().equals(belongsToModuleName)) {
261 + return yangNode;
262 + }
263 + }
264 + throw new DataModelException("YANG file error : Module " + belongsToModuleName + " to which sub-module " +
265 + "belongs to is not found.");
266 + }
243 } 267 }
......
...@@ -75,6 +75,11 @@ import org.onosproject.yangutils.parser.impl.listeners.UnitsListener; ...@@ -75,6 +75,11 @@ import org.onosproject.yangutils.parser.impl.listeners.UnitsListener;
75 import org.onosproject.yangutils.parser.impl.listeners.UsesListener; 75 import org.onosproject.yangutils.parser.impl.listeners.UsesListener;
76 import org.onosproject.yangutils.parser.impl.listeners.ValueListener; 76 import org.onosproject.yangutils.parser.impl.listeners.ValueListener;
77 import org.onosproject.yangutils.parser.impl.listeners.VersionListener; 77 import org.onosproject.yangutils.parser.impl.listeners.VersionListener;
78 +import org.onosproject.yangutils.utils.YangConstructType;
79 +
80 +import static org.onosproject.yangutils.utils.UtilConstants.UNSUPPORTED_YANG_CONSTRUCT;
81 +import static org.onosproject.yangutils.utils.UtilConstants.CURRENTLY_UNSUPPORTED;
82 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.handleUnsupportedYangConstruct;
78 83
79 /** 84 /**
80 * Represents ANTLR generates parse-tree. ANTLR generates a parse-tree listener interface that responds to events 85 * Represents ANTLR generates parse-tree. ANTLR generates a parse-tree listener interface that responds to events
...@@ -148,62 +153,62 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -148,62 +153,62 @@ public class TreeWalkListener implements GeneratedYangListener {
148 153
149 @Override 154 @Override
150 public void enterModuleBody(GeneratedYangParser.ModuleBodyContext ctx) { 155 public void enterModuleBody(GeneratedYangParser.ModuleBodyContext ctx) {
151 - // TODO: implement the method. 156 + // do nothing.
152 } 157 }
153 158
154 @Override 159 @Override
155 public void exitModuleBody(GeneratedYangParser.ModuleBodyContext ctx) { 160 public void exitModuleBody(GeneratedYangParser.ModuleBodyContext ctx) {
156 - // TODO: implement the method. 161 + // do nothing.
157 } 162 }
158 163
159 @Override 164 @Override
160 public void enterModuleHeaderStatement(GeneratedYangParser.ModuleHeaderStatementContext ctx) { 165 public void enterModuleHeaderStatement(GeneratedYangParser.ModuleHeaderStatementContext ctx) {
161 - // TODO: implement the method. 166 + // do nothing.
162 } 167 }
163 168
164 @Override 169 @Override
165 public void exitModuleHeaderStatement(GeneratedYangParser.ModuleHeaderStatementContext ctx) { 170 public void exitModuleHeaderStatement(GeneratedYangParser.ModuleHeaderStatementContext ctx) {
166 - // TODO: implement the method. 171 + // do nothing.
167 } 172 }
168 173
169 @Override 174 @Override
170 public void enterLinkageStatements(GeneratedYangParser.LinkageStatementsContext ctx) { 175 public void enterLinkageStatements(GeneratedYangParser.LinkageStatementsContext ctx) {
171 - // TODO: implement the method. 176 + // do nothing.
172 } 177 }
173 178
174 @Override 179 @Override
175 public void exitLinkageStatements(GeneratedYangParser.LinkageStatementsContext ctx) { 180 public void exitLinkageStatements(GeneratedYangParser.LinkageStatementsContext ctx) {
176 - // TODO: implement the method. 181 + // do nothing.
177 } 182 }
178 183
179 @Override 184 @Override
180 public void enterMetaStatements(GeneratedYangParser.MetaStatementsContext ctx) { 185 public void enterMetaStatements(GeneratedYangParser.MetaStatementsContext ctx) {
181 - // TODO: implement the method. 186 + // do nothing.
182 } 187 }
183 188
184 @Override 189 @Override
185 public void exitMetaStatements(GeneratedYangParser.MetaStatementsContext ctx) { 190 public void exitMetaStatements(GeneratedYangParser.MetaStatementsContext ctx) {
186 - // TODO: implement the method. 191 + // do nothing.
187 } 192 }
188 193
189 @Override 194 @Override
190 public void enterRevisionStatements(GeneratedYangParser.RevisionStatementsContext ctx) { 195 public void enterRevisionStatements(GeneratedYangParser.RevisionStatementsContext ctx) {
191 - // TODO: implement the method. 196 + // do nothing.
192 } 197 }
193 198
194 @Override 199 @Override
195 public void exitRevisionStatements(GeneratedYangParser.RevisionStatementsContext ctx) { 200 public void exitRevisionStatements(GeneratedYangParser.RevisionStatementsContext ctx) {
196 - // TODO: implement the method. 201 + // do nothing.
197 } 202 }
198 203
199 @Override 204 @Override
200 public void enterBodyStatements(GeneratedYangParser.BodyStatementsContext ctx) { 205 public void enterBodyStatements(GeneratedYangParser.BodyStatementsContext ctx) {
201 - // TODO: implement the method. 206 + // do nothing.
202 } 207 }
203 208
204 @Override 209 @Override
205 public void exitBodyStatements(GeneratedYangParser.BodyStatementsContext ctx) { 210 public void exitBodyStatements(GeneratedYangParser.BodyStatementsContext ctx) {
206 - // TODO: implement the method. 211 + // do nothing.
207 } 212 }
208 213
209 @Override 214 @Override
...@@ -213,7 +218,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -213,7 +218,7 @@ public class TreeWalkListener implements GeneratedYangListener {
213 218
214 @Override 219 @Override
215 public void exitYangVersionStatement(GeneratedYangParser.YangVersionStatementContext ctx) { 220 public void exitYangVersionStatement(GeneratedYangParser.YangVersionStatementContext ctx) {
216 - // TODO: implement the method. 221 + // do nothing.
217 } 222 }
218 223
219 @Override 224 @Override
...@@ -223,7 +228,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -223,7 +228,7 @@ public class TreeWalkListener implements GeneratedYangListener {
223 228
224 @Override 229 @Override
225 public void exitNamespaceStatement(GeneratedYangParser.NamespaceStatementContext ctx) { 230 public void exitNamespaceStatement(GeneratedYangParser.NamespaceStatementContext ctx) {
226 - // TODO: implement the method. 231 + // do nothing.
227 } 232 }
228 233
229 @Override 234 @Override
...@@ -233,7 +238,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -233,7 +238,7 @@ public class TreeWalkListener implements GeneratedYangListener {
233 238
234 @Override 239 @Override
235 public void exitPrefixStatement(GeneratedYangParser.PrefixStatementContext ctx) { 240 public void exitPrefixStatement(GeneratedYangParser.PrefixStatementContext ctx) {
236 - // TODO: implement the method. 241 + // do nothing.
237 } 242 }
238 243
239 @Override 244 @Override
...@@ -248,12 +253,12 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -248,12 +253,12 @@ public class TreeWalkListener implements GeneratedYangListener {
248 253
249 @Override 254 @Override
250 public void enterImportStatementBody(GeneratedYangParser.ImportStatementBodyContext ctx) { 255 public void enterImportStatementBody(GeneratedYangParser.ImportStatementBodyContext ctx) {
251 - // TODO: implement the method. 256 + // do nothing.
252 } 257 }
253 258
254 @Override 259 @Override
255 public void exitImportStatementBody(GeneratedYangParser.ImportStatementBodyContext ctx) { 260 public void exitImportStatementBody(GeneratedYangParser.ImportStatementBodyContext ctx) {
256 - // TODO: implement the method. 261 + // do nothing.
257 } 262 }
258 263
259 @Override 264 @Override
...@@ -263,7 +268,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -263,7 +268,7 @@ public class TreeWalkListener implements GeneratedYangListener {
263 268
264 @Override 269 @Override
265 public void exitRevisionDateStatement(GeneratedYangParser.RevisionDateStatementContext ctx) { 270 public void exitRevisionDateStatement(GeneratedYangParser.RevisionDateStatementContext ctx) {
266 - // TODO: implement the method. 271 + // do nothing.
267 } 272 }
268 273
269 @Override 274 @Override
...@@ -283,7 +288,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -283,7 +288,7 @@ public class TreeWalkListener implements GeneratedYangListener {
283 288
284 @Override 289 @Override
285 public void exitOrganizationStatement(GeneratedYangParser.OrganizationStatementContext ctx) { 290 public void exitOrganizationStatement(GeneratedYangParser.OrganizationStatementContext ctx) {
286 - // TODO: implement the method. 291 + // do nothing.
287 } 292 }
288 293
289 @Override 294 @Override
...@@ -293,7 +298,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -293,7 +298,7 @@ public class TreeWalkListener implements GeneratedYangListener {
293 298
294 @Override 299 @Override
295 public void exitContactStatement(GeneratedYangParser.ContactStatementContext ctx) { 300 public void exitContactStatement(GeneratedYangParser.ContactStatementContext ctx) {
296 - // TODO: implement the method. 301 + // do nothing.
297 } 302 }
298 303
299 @Override 304 @Override
...@@ -303,7 +308,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -303,7 +308,7 @@ public class TreeWalkListener implements GeneratedYangListener {
303 308
304 @Override 309 @Override
305 public void exitDescriptionStatement(GeneratedYangParser.DescriptionStatementContext ctx) { 310 public void exitDescriptionStatement(GeneratedYangParser.DescriptionStatementContext ctx) {
306 - // TODO: implement the method. 311 + // do nothing.
307 } 312 }
308 313
309 @Override 314 @Override
...@@ -313,7 +318,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -313,7 +318,7 @@ public class TreeWalkListener implements GeneratedYangListener {
313 318
314 @Override 319 @Override
315 public void exitReferenceStatement(GeneratedYangParser.ReferenceStatementContext ctx) { 320 public void exitReferenceStatement(GeneratedYangParser.ReferenceStatementContext ctx) {
316 - // TODO: implement the method. 321 + // do nothing.
317 } 322 }
318 323
319 @Override 324 @Override
...@@ -328,12 +333,12 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -328,12 +333,12 @@ public class TreeWalkListener implements GeneratedYangListener {
328 333
329 @Override 334 @Override
330 public void enterRevisionStatementBody(GeneratedYangParser.RevisionStatementBodyContext ctx) { 335 public void enterRevisionStatementBody(GeneratedYangParser.RevisionStatementBodyContext ctx) {
331 - // TODO: implement the method. 336 + // do nothing.
332 } 337 }
333 338
334 @Override 339 @Override
335 public void exitRevisionStatementBody(GeneratedYangParser.RevisionStatementBodyContext ctx) { 340 public void exitRevisionStatementBody(GeneratedYangParser.RevisionStatementBodyContext ctx) {
336 - // TODO: implement the method. 341 + // do nothing.
337 } 342 }
338 343
339 @Override 344 @Override
...@@ -348,22 +353,22 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -348,22 +353,22 @@ public class TreeWalkListener implements GeneratedYangListener {
348 353
349 @Override 354 @Override
350 public void enterSubmoduleBody(GeneratedYangParser.SubmoduleBodyContext ctx) { 355 public void enterSubmoduleBody(GeneratedYangParser.SubmoduleBodyContext ctx) {
351 - // TODO: implement the method. 356 + // do nothing.
352 } 357 }
353 358
354 @Override 359 @Override
355 public void exitSubmoduleBody(GeneratedYangParser.SubmoduleBodyContext ctx) { 360 public void exitSubmoduleBody(GeneratedYangParser.SubmoduleBodyContext ctx) {
356 - // TODO: implement the method. 361 + // do nothing.
357 } 362 }
358 363
359 @Override 364 @Override
360 public void enterSubmoduleHeaderStatement(GeneratedYangParser.SubmoduleHeaderStatementContext ctx) { 365 public void enterSubmoduleHeaderStatement(GeneratedYangParser.SubmoduleHeaderStatementContext ctx) {
361 - // TODO: implement the method. 366 + // do nothing.
362 } 367 }
363 368
364 @Override 369 @Override
365 public void exitSubmoduleHeaderStatement(GeneratedYangParser.SubmoduleHeaderStatementContext ctx) { 370 public void exitSubmoduleHeaderStatement(GeneratedYangParser.SubmoduleHeaderStatementContext ctx) {
366 - // TODO: implement the method. 371 + // do nothing.
367 } 372 }
368 373
369 @Override 374 @Override
...@@ -378,132 +383,132 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -378,132 +383,132 @@ public class TreeWalkListener implements GeneratedYangListener {
378 383
379 @Override 384 @Override
380 public void enterBelongstoStatementBody(GeneratedYangParser.BelongstoStatementBodyContext ctx) { 385 public void enterBelongstoStatementBody(GeneratedYangParser.BelongstoStatementBodyContext ctx) {
381 - // TODO: implement the method. 386 + // do nothing.
382 } 387 }
383 388
384 @Override 389 @Override
385 public void exitBelongstoStatementBody(GeneratedYangParser.BelongstoStatementBodyContext ctx) { 390 public void exitBelongstoStatementBody(GeneratedYangParser.BelongstoStatementBodyContext ctx) {
386 - // TODO: implement the method. 391 + // do nothing.
387 } 392 }
388 393
389 @Override 394 @Override
390 public void enterExtensionStatement(GeneratedYangParser.ExtensionStatementContext ctx) { 395 public void enterExtensionStatement(GeneratedYangParser.ExtensionStatementContext ctx) {
391 - // TODO: implement the method. 396 + handleUnsupportedYangConstruct(YangConstructType.EXTENSION_DATA, ctx, UNSUPPORTED_YANG_CONSTRUCT);
392 } 397 }
393 398
394 @Override 399 @Override
395 public void exitExtensionStatement(GeneratedYangParser.ExtensionStatementContext ctx) { 400 public void exitExtensionStatement(GeneratedYangParser.ExtensionStatementContext ctx) {
396 - // TODO: implement the method. 401 + // do nothing
397 } 402 }
398 403
399 @Override 404 @Override
400 public void enterExtensionBody(GeneratedYangParser.ExtensionBodyContext ctx) { 405 public void enterExtensionBody(GeneratedYangParser.ExtensionBodyContext ctx) {
401 - // TODO: implement the method. 406 + // do nothing.
402 } 407 }
403 408
404 @Override 409 @Override
405 public void exitExtensionBody(GeneratedYangParser.ExtensionBodyContext ctx) { 410 public void exitExtensionBody(GeneratedYangParser.ExtensionBodyContext ctx) {
406 - // TODO: implement the method. 411 + // do nothing.
407 } 412 }
408 413
409 @Override 414 @Override
410 public void enterArgumentStatement(GeneratedYangParser.ArgumentStatementContext ctx) { 415 public void enterArgumentStatement(GeneratedYangParser.ArgumentStatementContext ctx) {
411 - // TODO: implement the method. 416 + // do nothing.
412 } 417 }
413 418
414 @Override 419 @Override
415 public void exitArgumentStatement(GeneratedYangParser.ArgumentStatementContext ctx) { 420 public void exitArgumentStatement(GeneratedYangParser.ArgumentStatementContext ctx) {
416 - // TODO: implement the method. 421 + // do nothing.
417 } 422 }
418 423
419 @Override 424 @Override
420 public void enterArgumentBody(GeneratedYangParser.ArgumentBodyContext ctx) { 425 public void enterArgumentBody(GeneratedYangParser.ArgumentBodyContext ctx) {
421 - // TODO: implement the method. 426 + // do nothing.
422 } 427 }
423 428
424 @Override 429 @Override
425 public void exitArgumentBody(GeneratedYangParser.ArgumentBodyContext ctx) { 430 public void exitArgumentBody(GeneratedYangParser.ArgumentBodyContext ctx) {
426 - // TODO: implement the method. 431 + // do nothing.
427 } 432 }
428 433
429 @Override 434 @Override
430 public void enterYinElementStatement(GeneratedYangParser.YinElementStatementContext ctx) { 435 public void enterYinElementStatement(GeneratedYangParser.YinElementStatementContext ctx) {
431 - // TODO: implement the method. 436 + // do nothing.
432 } 437 }
433 438
434 @Override 439 @Override
435 public void exitYinElementStatement(GeneratedYangParser.YinElementStatementContext ctx) { 440 public void exitYinElementStatement(GeneratedYangParser.YinElementStatementContext ctx) {
436 - // TODO: implement the method. 441 + // do nothing.
437 } 442 }
438 443
439 @Override 444 @Override
440 public void enterIdentityStatement(GeneratedYangParser.IdentityStatementContext ctx) { 445 public void enterIdentityStatement(GeneratedYangParser.IdentityStatementContext ctx) {
441 - // TODO: implement the method. 446 + handleUnsupportedYangConstruct(YangConstructType.IDENTITY_DATA, ctx, CURRENTLY_UNSUPPORTED);
442 } 447 }
443 448
444 @Override 449 @Override
445 public void exitIdentityStatement(GeneratedYangParser.IdentityStatementContext ctx) { 450 public void exitIdentityStatement(GeneratedYangParser.IdentityStatementContext ctx) {
446 - // TODO: implement the method. 451 + // do nothing.
447 } 452 }
448 453
449 @Override 454 @Override
450 public void enterIdentityBody(GeneratedYangParser.IdentityBodyContext ctx) { 455 public void enterIdentityBody(GeneratedYangParser.IdentityBodyContext ctx) {
451 - // TODO: implement the method. 456 + // do nothing.
452 } 457 }
453 458
454 @Override 459 @Override
455 public void exitIdentityBody(GeneratedYangParser.IdentityBodyContext ctx) { 460 public void exitIdentityBody(GeneratedYangParser.IdentityBodyContext ctx) {
456 - // TODO: implement the method. 461 + // do nothing.
457 } 462 }
458 463
459 @Override 464 @Override
460 public void enterBaseStatement(GeneratedYangParser.BaseStatementContext ctx) { 465 public void enterBaseStatement(GeneratedYangParser.BaseStatementContext ctx) {
461 - // TODO: implement the method. 466 + handleUnsupportedYangConstruct(YangConstructType.BASE_DATA, ctx, CURRENTLY_UNSUPPORTED);
462 } 467 }
463 468
464 @Override 469 @Override
465 public void exitBaseStatement(GeneratedYangParser.BaseStatementContext ctx) { 470 public void exitBaseStatement(GeneratedYangParser.BaseStatementContext ctx) {
466 - // TODO: implement the method. 471 + // do nothing.
467 } 472 }
468 473
469 @Override 474 @Override
470 public void enterFeatureStatement(GeneratedYangParser.FeatureStatementContext ctx) { 475 public void enterFeatureStatement(GeneratedYangParser.FeatureStatementContext ctx) {
471 - // TODO: implement the method. 476 + handleUnsupportedYangConstruct(YangConstructType.FEATURE_DATA, ctx, CURRENTLY_UNSUPPORTED);
472 } 477 }
473 478
474 @Override 479 @Override
475 public void exitFeatureStatement(GeneratedYangParser.FeatureStatementContext ctx) { 480 public void exitFeatureStatement(GeneratedYangParser.FeatureStatementContext ctx) {
476 - // TODO: implement the method. 481 + //TODO: to be implemented
477 } 482 }
478 483
479 @Override 484 @Override
480 public void enterFeatureBody(GeneratedYangParser.FeatureBodyContext ctx) { 485 public void enterFeatureBody(GeneratedYangParser.FeatureBodyContext ctx) {
481 - // TODO: implement the method. 486 + //TODO : to be implemented
482 } 487 }
483 488
484 @Override 489 @Override
485 public void exitFeatureBody(GeneratedYangParser.FeatureBodyContext ctx) { 490 public void exitFeatureBody(GeneratedYangParser.FeatureBodyContext ctx) {
486 - // TODO: implement the method. 491 + //TODO : to be implemented
487 } 492 }
488 493
489 @Override 494 @Override
490 public void enterDataDefStatement(GeneratedYangParser.DataDefStatementContext ctx) { 495 public void enterDataDefStatement(GeneratedYangParser.DataDefStatementContext ctx) {
491 - // TODO: implement the method. 496 + // do nothing.
492 } 497 }
493 498
494 @Override 499 @Override
495 public void exitDataDefStatement(GeneratedYangParser.DataDefStatementContext ctx) { 500 public void exitDataDefStatement(GeneratedYangParser.DataDefStatementContext ctx) {
496 - // TODO: implement the method. 501 + // do nothing.
497 } 502 }
498 503
499 @Override 504 @Override
500 public void enterIfFeatureStatement(GeneratedYangParser.IfFeatureStatementContext ctx) { 505 public void enterIfFeatureStatement(GeneratedYangParser.IfFeatureStatementContext ctx) {
501 - // TODO: implement the method. 506 + // TODO: to be implemented
502 } 507 }
503 508
504 @Override 509 @Override
505 public void exitIfFeatureStatement(GeneratedYangParser.IfFeatureStatementContext ctx) { 510 public void exitIfFeatureStatement(GeneratedYangParser.IfFeatureStatementContext ctx) {
506 - // TODO: implement the method. 511 + // TODO: to be implemented
507 } 512 }
508 513
509 @Override 514 @Override
...@@ -513,7 +518,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -513,7 +518,7 @@ public class TreeWalkListener implements GeneratedYangListener {
513 518
514 @Override 519 @Override
515 public void exitUnitsStatement(GeneratedYangParser.UnitsStatementContext ctx) { 520 public void exitUnitsStatement(GeneratedYangParser.UnitsStatementContext ctx) {
516 - // TODO: implement the method. 521 + // do nothing.
517 } 522 }
518 523
519 @Override 524 @Override
...@@ -538,22 +543,32 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -538,22 +543,32 @@ public class TreeWalkListener implements GeneratedYangListener {
538 543
539 @Override 544 @Override
540 public void enterTypeBodyStatements(GeneratedYangParser.TypeBodyStatementsContext ctx) { 545 public void enterTypeBodyStatements(GeneratedYangParser.TypeBodyStatementsContext ctx) {
541 - // TODO: implement the method. 546 + // do nothing.
542 } 547 }
543 548
544 @Override 549 @Override
545 public void exitTypeBodyStatements(GeneratedYangParser.TypeBodyStatementsContext ctx) { 550 public void exitTypeBodyStatements(GeneratedYangParser.TypeBodyStatementsContext ctx) {
551 + // do nothing.
552 + }
553 +
554 + @Override
555 + public void enterDecimal64Specification(GeneratedYangParser.Decimal64SpecificationContext ctx) {
546 // TODO: implement the method. 556 // TODO: implement the method.
547 } 557 }
548 558
549 @Override 559 @Override
550 - public void enterNumericalRestrictions(GeneratedYangParser.NumericalRestrictionsContext ctx) { 560 + public void exitDecimal64Specification(GeneratedYangParser.Decimal64SpecificationContext ctx) {
551 // TODO: implement the method. 561 // TODO: implement the method.
552 } 562 }
553 563
554 @Override 564 @Override
565 + public void enterNumericalRestrictions(GeneratedYangParser.NumericalRestrictionsContext ctx) {
566 + // do nothing.
567 + }
568 +
569 + @Override
555 public void exitNumericalRestrictions(GeneratedYangParser.NumericalRestrictionsContext ctx) { 570 public void exitNumericalRestrictions(GeneratedYangParser.NumericalRestrictionsContext ctx) {
556 - // TODO: implement the method. 571 + // do nothing.
557 } 572 }
558 573
559 @Override 574 @Override
...@@ -563,27 +578,27 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -563,27 +578,27 @@ public class TreeWalkListener implements GeneratedYangListener {
563 578
564 @Override 579 @Override
565 public void exitRangeStatement(GeneratedYangParser.RangeStatementContext ctx) { 580 public void exitRangeStatement(GeneratedYangParser.RangeStatementContext ctx) {
566 - // TODO: implement the method. 581 + RangeRestrictionListener.processRangeRestrictionExit(this, ctx);
567 } 582 }
568 583
569 @Override 584 @Override
570 public void enterCommonStatements(GeneratedYangParser.CommonStatementsContext ctx) { 585 public void enterCommonStatements(GeneratedYangParser.CommonStatementsContext ctx) {
571 - // TODO: implement the method. 586 + // do nothing.
572 } 587 }
573 588
574 @Override 589 @Override
575 public void exitCommonStatements(GeneratedYangParser.CommonStatementsContext ctx) { 590 public void exitCommonStatements(GeneratedYangParser.CommonStatementsContext ctx) {
576 - // TODO: implement the method. 591 + // do nothing.
577 } 592 }
578 593
579 @Override 594 @Override
580 public void enterStringRestrictions(GeneratedYangParser.StringRestrictionsContext ctx) { 595 public void enterStringRestrictions(GeneratedYangParser.StringRestrictionsContext ctx) {
581 - // TODO: implement the method. 596 + // do nothing.
582 } 597 }
583 598
584 @Override 599 @Override
585 public void exitStringRestrictions(GeneratedYangParser.StringRestrictionsContext ctx) { 600 public void exitStringRestrictions(GeneratedYangParser.StringRestrictionsContext ctx) {
586 - // TODO: implement the method. 601 + // do nothing.
587 } 602 }
588 603
589 @Override 604 @Override
...@@ -593,7 +608,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -593,7 +608,7 @@ public class TreeWalkListener implements GeneratedYangListener {
593 608
594 @Override 609 @Override
595 public void exitLengthStatement(GeneratedYangParser.LengthStatementContext ctx) { 610 public void exitLengthStatement(GeneratedYangParser.LengthStatementContext ctx) {
596 - // TODO: implement the method. 611 + LengthRestrictionListener.processLengthRestrictionExit(this, ctx);
597 } 612 }
598 613
599 @Override 614 @Override
...@@ -603,7 +618,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -603,7 +618,7 @@ public class TreeWalkListener implements GeneratedYangListener {
603 618
604 @Override 619 @Override
605 public void exitPatternStatement(GeneratedYangParser.PatternStatementContext ctx) { 620 public void exitPatternStatement(GeneratedYangParser.PatternStatementContext ctx) {
606 - // TODO: implement the method. 621 + PatternRestrictionListener.processPatternRestrictionExit(this, ctx);
607 } 622 }
608 623
609 @Override 624 @Override
...@@ -613,7 +628,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -613,7 +628,7 @@ public class TreeWalkListener implements GeneratedYangListener {
613 628
614 @Override 629 @Override
615 public void exitDefaultStatement(GeneratedYangParser.DefaultStatementContext ctx) { 630 public void exitDefaultStatement(GeneratedYangParser.DefaultStatementContext ctx) {
616 - // TODO: implement the method. 631 + // do nothing.
617 } 632 }
618 633
619 @Override 634 @Override
...@@ -638,62 +653,62 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -638,62 +653,62 @@ public class TreeWalkListener implements GeneratedYangListener {
638 653
639 @Override 654 @Override
640 public void enterEnumStatementBody(GeneratedYangParser.EnumStatementBodyContext ctx) { 655 public void enterEnumStatementBody(GeneratedYangParser.EnumStatementBodyContext ctx) {
641 - // TODO: implement the method. 656 + // do nothing.
642 } 657 }
643 658
644 @Override 659 @Override
645 public void exitEnumStatementBody(GeneratedYangParser.EnumStatementBodyContext ctx) { 660 public void exitEnumStatementBody(GeneratedYangParser.EnumStatementBodyContext ctx) {
646 - // TODO: implement the method. 661 + // do nothing.
647 } 662 }
648 663
649 @Override 664 @Override
650 public void enterLeafrefSpecification(GeneratedYangParser.LeafrefSpecificationContext ctx) { 665 public void enterLeafrefSpecification(GeneratedYangParser.LeafrefSpecificationContext ctx) {
651 - // TODO: implement the method. 666 + // do nothing.
652 } 667 }
653 668
654 @Override 669 @Override
655 public void exitLeafrefSpecification(GeneratedYangParser.LeafrefSpecificationContext ctx) { 670 public void exitLeafrefSpecification(GeneratedYangParser.LeafrefSpecificationContext ctx) {
656 - // TODO: implement the method. 671 + // do nothing.
657 } 672 }
658 673
659 @Override 674 @Override
660 public void enterPathStatement(GeneratedYangParser.PathStatementContext ctx) { 675 public void enterPathStatement(GeneratedYangParser.PathStatementContext ctx) {
661 - // TODO: implement the method. 676 + handleUnsupportedYangConstruct(YangConstructType.PATH_DATA, ctx, CURRENTLY_UNSUPPORTED);
662 } 677 }
663 678
664 @Override 679 @Override
665 public void exitPathStatement(GeneratedYangParser.PathStatementContext ctx) { 680 public void exitPathStatement(GeneratedYangParser.PathStatementContext ctx) {
666 - // TODO: implement the method. 681 + // do nothing.
667 } 682 }
668 683
669 @Override 684 @Override
670 public void enterRequireInstanceStatement(GeneratedYangParser.RequireInstanceStatementContext ctx) { 685 public void enterRequireInstanceStatement(GeneratedYangParser.RequireInstanceStatementContext ctx) {
671 - // TODO: implement the method. 686 + handleUnsupportedYangConstruct(YangConstructType.REQUIRE_INSTANCE_DATA, ctx, UNSUPPORTED_YANG_CONSTRUCT);
672 } 687 }
673 688
674 @Override 689 @Override
675 public void exitRequireInstanceStatement(GeneratedYangParser.RequireInstanceStatementContext ctx) { 690 public void exitRequireInstanceStatement(GeneratedYangParser.RequireInstanceStatementContext ctx) {
676 - // TODO: implement the method. 691 + // do nothing.
677 } 692 }
678 693
679 @Override 694 @Override
680 public void enterInstanceIdentifierSpecification(GeneratedYangParser.InstanceIdentifierSpecificationContext ctx) { 695 public void enterInstanceIdentifierSpecification(GeneratedYangParser.InstanceIdentifierSpecificationContext ctx) {
681 - // TODO: implement the method. 696 + // do nothing.
682 } 697 }
683 698
684 @Override 699 @Override
685 public void exitInstanceIdentifierSpecification(GeneratedYangParser.InstanceIdentifierSpecificationContext ctx) { 700 public void exitInstanceIdentifierSpecification(GeneratedYangParser.InstanceIdentifierSpecificationContext ctx) {
686 - // TODO: implement the method. 701 + // do nothing.
687 } 702 }
688 703
689 @Override 704 @Override
690 public void enterIdentityrefSpecification(GeneratedYangParser.IdentityrefSpecificationContext ctx) { 705 public void enterIdentityrefSpecification(GeneratedYangParser.IdentityrefSpecificationContext ctx) {
691 - // TODO: implement the method. 706 + // do nothing.
692 } 707 }
693 708
694 @Override 709 @Override
695 public void exitIdentityrefSpecification(GeneratedYangParser.IdentityrefSpecificationContext ctx) { 710 public void exitIdentityrefSpecification(GeneratedYangParser.IdentityrefSpecificationContext ctx) {
696 - // TODO: implement the method. 711 + // do nothing.
697 } 712 }
698 713
699 @Override 714 @Override
...@@ -728,12 +743,12 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -728,12 +743,12 @@ public class TreeWalkListener implements GeneratedYangListener {
728 743
729 @Override 744 @Override
730 public void enterBitBodyStatement(GeneratedYangParser.BitBodyStatementContext ctx) { 745 public void enterBitBodyStatement(GeneratedYangParser.BitBodyStatementContext ctx) {
731 - // TODO: implement the method. 746 + // do nothing.
732 } 747 }
733 748
734 @Override 749 @Override
735 public void exitBitBodyStatement(GeneratedYangParser.BitBodyStatementContext ctx) { 750 public void exitBitBodyStatement(GeneratedYangParser.BitBodyStatementContext ctx) {
736 - // TODO: implement the method. 751 + // do nothing.
737 } 752 }
738 753
739 @Override 754 @Override
...@@ -743,7 +758,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -743,7 +758,7 @@ public class TreeWalkListener implements GeneratedYangListener {
743 758
744 @Override 759 @Override
745 public void exitPositionStatement(GeneratedYangParser.PositionStatementContext ctx) { 760 public void exitPositionStatement(GeneratedYangParser.PositionStatementContext ctx) {
746 - // TODO: implement the method. 761 + // do nothing.
747 } 762 }
748 763
749 @Override 764 @Override
...@@ -753,7 +768,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -753,7 +768,7 @@ public class TreeWalkListener implements GeneratedYangListener {
753 768
754 @Override 769 @Override
755 public void exitStatusStatement(GeneratedYangParser.StatusStatementContext ctx) { 770 public void exitStatusStatement(GeneratedYangParser.StatusStatementContext ctx) {
756 - // TODO: implement the method. 771 + // do nothing.
757 } 772 }
758 773
759 @Override 774 @Override
...@@ -763,7 +778,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -763,7 +778,7 @@ public class TreeWalkListener implements GeneratedYangListener {
763 778
764 @Override 779 @Override
765 public void exitConfigStatement(GeneratedYangParser.ConfigStatementContext ctx) { 780 public void exitConfigStatement(GeneratedYangParser.ConfigStatementContext ctx) {
766 - // TODO: implement the method. 781 + // do nothing.
767 } 782 }
768 783
769 @Override 784 @Override
...@@ -773,7 +788,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -773,7 +788,7 @@ public class TreeWalkListener implements GeneratedYangListener {
773 788
774 @Override 789 @Override
775 public void exitMandatoryStatement(GeneratedYangParser.MandatoryStatementContext ctx) { 790 public void exitMandatoryStatement(GeneratedYangParser.MandatoryStatementContext ctx) {
776 - // TODO: implement the method. 791 + // do nothing.
777 } 792 }
778 793
779 @Override 794 @Override
...@@ -783,47 +798,47 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -783,47 +798,47 @@ public class TreeWalkListener implements GeneratedYangListener {
783 798
784 @Override 799 @Override
785 public void exitPresenceStatement(GeneratedYangParser.PresenceStatementContext ctx) { 800 public void exitPresenceStatement(GeneratedYangParser.PresenceStatementContext ctx) {
786 - // TODO: implement the method. 801 + // do nothing.
787 } 802 }
788 803
789 @Override 804 @Override
790 public void enterOrderedByStatement(GeneratedYangParser.OrderedByStatementContext ctx) { 805 public void enterOrderedByStatement(GeneratedYangParser.OrderedByStatementContext ctx) {
791 - // TODO: implement the method. 806 + handleUnsupportedYangConstruct(YangConstructType.ORDERED_BY_DATA, ctx, CURRENTLY_UNSUPPORTED);
792 } 807 }
793 808
794 @Override 809 @Override
795 public void exitOrderedByStatement(GeneratedYangParser.OrderedByStatementContext ctx) { 810 public void exitOrderedByStatement(GeneratedYangParser.OrderedByStatementContext ctx) {
796 - // TODO: implement the method. 811 + // do nothing.
797 } 812 }
798 813
799 @Override 814 @Override
800 public void enterMustStatement(GeneratedYangParser.MustStatementContext ctx) { 815 public void enterMustStatement(GeneratedYangParser.MustStatementContext ctx) {
801 - // TODO: implement the method. 816 + // TODO: to be implemented
802 } 817 }
803 818
804 @Override 819 @Override
805 public void exitMustStatement(GeneratedYangParser.MustStatementContext ctx) { 820 public void exitMustStatement(GeneratedYangParser.MustStatementContext ctx) {
806 - // TODO: implement the method. 821 + // TODO: to be implemented
807 } 822 }
808 823
809 @Override 824 @Override
810 public void enterErrorMessageStatement(GeneratedYangParser.ErrorMessageStatementContext ctx) { 825 public void enterErrorMessageStatement(GeneratedYangParser.ErrorMessageStatementContext ctx) {
811 - // TODO: implement the method. 826 + handleUnsupportedYangConstruct(YangConstructType.ERROR_MESSAGE_DATA, ctx, CURRENTLY_UNSUPPORTED);
812 } 827 }
813 828
814 @Override 829 @Override
815 public void exitErrorMessageStatement(GeneratedYangParser.ErrorMessageStatementContext ctx) { 830 public void exitErrorMessageStatement(GeneratedYangParser.ErrorMessageStatementContext ctx) {
816 - // TODO: implement the method. 831 + // do nothing.
817 } 832 }
818 833
819 @Override 834 @Override
820 public void enterErrorAppTagStatement(GeneratedYangParser.ErrorAppTagStatementContext ctx) { 835 public void enterErrorAppTagStatement(GeneratedYangParser.ErrorAppTagStatementContext ctx) {
821 - // TODO: implement the method. 836 + handleUnsupportedYangConstruct(YangConstructType.ERROR_APP_TAG_DATA, ctx, CURRENTLY_UNSUPPORTED);
822 } 837 }
823 838
824 @Override 839 @Override
825 public void exitErrorAppTagStatement(GeneratedYangParser.ErrorAppTagStatementContext ctx) { 840 public void exitErrorAppTagStatement(GeneratedYangParser.ErrorAppTagStatementContext ctx) {
826 - // TODO: implement the method. 841 + //do nothing
827 } 842 }
828 843
829 @Override 844 @Override
...@@ -833,7 +848,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -833,7 +848,7 @@ public class TreeWalkListener implements GeneratedYangListener {
833 848
834 @Override 849 @Override
835 public void exitMinElementsStatement(GeneratedYangParser.MinElementsStatementContext ctx) { 850 public void exitMinElementsStatement(GeneratedYangParser.MinElementsStatementContext ctx) {
836 - // TODO: implement the method. 851 + // do nothing.
837 } 852 }
838 853
839 @Override 854 @Override
...@@ -843,7 +858,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -843,7 +858,7 @@ public class TreeWalkListener implements GeneratedYangListener {
843 858
844 @Override 859 @Override
845 public void exitMaxElementsStatement(GeneratedYangParser.MaxElementsStatementContext ctx) { 860 public void exitMaxElementsStatement(GeneratedYangParser.MaxElementsStatementContext ctx) {
846 - // TODO: implement the method. 861 + // do nothing.
847 } 862 }
848 863
849 @Override 864 @Override
...@@ -853,7 +868,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -853,7 +868,7 @@ public class TreeWalkListener implements GeneratedYangListener {
853 868
854 @Override 869 @Override
855 public void exitValueStatement(GeneratedYangParser.ValueStatementContext ctx) { 870 public void exitValueStatement(GeneratedYangParser.ValueStatementContext ctx) {
856 - // TODO: implement the method. 871 + // do nothing.
857 } 872 }
858 873
859 @Override 874 @Override
...@@ -913,17 +928,17 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -913,17 +928,17 @@ public class TreeWalkListener implements GeneratedYangListener {
913 928
914 @Override 929 @Override
915 public void exitKeyStatement(GeneratedYangParser.KeyStatementContext ctx) { 930 public void exitKeyStatement(GeneratedYangParser.KeyStatementContext ctx) {
916 - // TODO: implement the method. 931 + // do nothing.
917 } 932 }
918 933
919 @Override 934 @Override
920 public void enterUniqueStatement(GeneratedYangParser.UniqueStatementContext ctx) { 935 public void enterUniqueStatement(GeneratedYangParser.UniqueStatementContext ctx) {
921 - // TODO: implement the method. 936 + handleUnsupportedYangConstruct(YangConstructType.UNIQUE_DATA, ctx, CURRENTLY_UNSUPPORTED);
922 } 937 }
923 938
924 @Override 939 @Override
925 public void exitUniqueStatement(GeneratedYangParser.UniqueStatementContext ctx) { 940 public void exitUniqueStatement(GeneratedYangParser.UniqueStatementContext ctx) {
926 - // TODO: implement the method. 941 + // do nothing.
927 } 942 }
928 943
929 @Override 944 @Override
...@@ -957,6 +972,16 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -957,6 +972,16 @@ public class TreeWalkListener implements GeneratedYangListener {
957 } 972 }
958 973
959 @Override 974 @Override
975 + public void enterAnyxmlStatement(GeneratedYangParser.AnyxmlStatementContext ctx) {
976 + handleUnsupportedYangConstruct(YangConstructType.ANYXML_DATA, ctx, UNSUPPORTED_YANG_CONSTRUCT);
977 + }
978 +
979 + @Override
980 + public void exitAnyxmlStatement(GeneratedYangParser.AnyxmlStatementContext ctx) {
981 + // do nothing.
982 + }
983 +
984 + @Override
960 public void enterUsesStatement(GeneratedYangParser.UsesStatementContext ctx) { 985 public void enterUsesStatement(GeneratedYangParser.UsesStatementContext ctx) {
961 UsesListener.processUsesEntry(this, ctx); 986 UsesListener.processUsesEntry(this, ctx);
962 } 987 }
...@@ -968,82 +993,82 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -968,82 +993,82 @@ public class TreeWalkListener implements GeneratedYangListener {
968 993
969 @Override 994 @Override
970 public void enterRefineStatement(GeneratedYangParser.RefineStatementContext ctx) { 995 public void enterRefineStatement(GeneratedYangParser.RefineStatementContext ctx) {
971 - // TODO: implement the method. 996 + handleUnsupportedYangConstruct(YangConstructType.REFINE_DATA, ctx, UNSUPPORTED_YANG_CONSTRUCT);
972 } 997 }
973 998
974 @Override 999 @Override
975 public void exitRefineStatement(GeneratedYangParser.RefineStatementContext ctx) { 1000 public void exitRefineStatement(GeneratedYangParser.RefineStatementContext ctx) {
976 - // TODO: implement the method. 1001 + // do nothing.
977 } 1002 }
978 1003
979 @Override 1004 @Override
980 public void enterRefineContainerStatements(GeneratedYangParser.RefineContainerStatementsContext ctx) { 1005 public void enterRefineContainerStatements(GeneratedYangParser.RefineContainerStatementsContext ctx) {
981 - // TODO: implement the method. 1006 + // do nothing.
982 } 1007 }
983 1008
984 @Override 1009 @Override
985 public void exitRefineContainerStatements(GeneratedYangParser.RefineContainerStatementsContext ctx) { 1010 public void exitRefineContainerStatements(GeneratedYangParser.RefineContainerStatementsContext ctx) {
986 - // TODO: implement the method. 1011 + // do nothing.
987 } 1012 }
988 1013
989 @Override 1014 @Override
990 public void enterRefineLeafStatements(GeneratedYangParser.RefineLeafStatementsContext ctx) { 1015 public void enterRefineLeafStatements(GeneratedYangParser.RefineLeafStatementsContext ctx) {
991 - // TODO: implement the method. 1016 + // do nothing.
992 } 1017 }
993 1018
994 @Override 1019 @Override
995 public void exitRefineLeafStatements(GeneratedYangParser.RefineLeafStatementsContext ctx) { 1020 public void exitRefineLeafStatements(GeneratedYangParser.RefineLeafStatementsContext ctx) {
996 - // TODO: implement the method. 1021 + // do nothing.
997 } 1022 }
998 1023
999 @Override 1024 @Override
1000 public void enterRefineLeafListStatements(GeneratedYangParser.RefineLeafListStatementsContext ctx) { 1025 public void enterRefineLeafListStatements(GeneratedYangParser.RefineLeafListStatementsContext ctx) {
1001 - // TODO: implement the method. 1026 + // do nothing.
1002 } 1027 }
1003 1028
1004 @Override 1029 @Override
1005 public void exitRefineLeafListStatements(GeneratedYangParser.RefineLeafListStatementsContext ctx) { 1030 public void exitRefineLeafListStatements(GeneratedYangParser.RefineLeafListStatementsContext ctx) {
1006 - // TODO: implement the method. 1031 + // do nothing.
1007 } 1032 }
1008 1033
1009 @Override 1034 @Override
1010 public void enterRefineListStatements(GeneratedYangParser.RefineListStatementsContext ctx) { 1035 public void enterRefineListStatements(GeneratedYangParser.RefineListStatementsContext ctx) {
1011 - // TODO: implement the method. 1036 + // do nothing.
1012 } 1037 }
1013 1038
1014 @Override 1039 @Override
1015 public void exitRefineListStatements(GeneratedYangParser.RefineListStatementsContext ctx) { 1040 public void exitRefineListStatements(GeneratedYangParser.RefineListStatementsContext ctx) {
1016 - // TODO: implement the method. 1041 + // do nothing.
1017 } 1042 }
1018 1043
1019 @Override 1044 @Override
1020 public void enterRefineChoiceStatements(GeneratedYangParser.RefineChoiceStatementsContext ctx) { 1045 public void enterRefineChoiceStatements(GeneratedYangParser.RefineChoiceStatementsContext ctx) {
1021 - // TODO: implement the method. 1046 + // do nothing.
1022 } 1047 }
1023 1048
1024 @Override 1049 @Override
1025 public void exitRefineChoiceStatements(GeneratedYangParser.RefineChoiceStatementsContext ctx) { 1050 public void exitRefineChoiceStatements(GeneratedYangParser.RefineChoiceStatementsContext ctx) {
1026 - // TODO: implement the method. 1051 + // do nothing.
1027 } 1052 }
1028 1053
1029 @Override 1054 @Override
1030 public void enterRefineCaseStatements(GeneratedYangParser.RefineCaseStatementsContext ctx) { 1055 public void enterRefineCaseStatements(GeneratedYangParser.RefineCaseStatementsContext ctx) {
1031 - // TODO: implement the method. 1056 + // do nothing.
1032 } 1057 }
1033 1058
1034 @Override 1059 @Override
1035 public void exitRefineCaseStatements(GeneratedYangParser.RefineCaseStatementsContext ctx) { 1060 public void exitRefineCaseStatements(GeneratedYangParser.RefineCaseStatementsContext ctx) {
1036 - // TODO: implement the method. 1061 + // do nothing.
1037 } 1062 }
1038 1063
1039 @Override 1064 @Override
1040 - public void enterUsesAugmentStatement(GeneratedYangParser.UsesAugmentStatementContext ctx) { 1065 + public void enterRefineAnyxmlStatements(GeneratedYangParser.RefineAnyxmlStatementsContext ctx) {
1041 - // TODO: implement the method. 1066 + // do nothing.
1042 } 1067 }
1043 1068
1044 @Override 1069 @Override
1045 - public void exitUsesAugmentStatement(GeneratedYangParser.UsesAugmentStatementContext ctx) { 1070 + public void exitRefineAnyxmlStatements(GeneratedYangParser.RefineAnyxmlStatementsContext ctx) {
1046 - // TODO: implement the method. 1071 + // do nothing.
1047 } 1072 }
1048 1073
1049 @Override 1074 @Override
...@@ -1058,12 +1083,12 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -1058,12 +1083,12 @@ public class TreeWalkListener implements GeneratedYangListener {
1058 1083
1059 @Override 1084 @Override
1060 public void enterWhenStatement(GeneratedYangParser.WhenStatementContext ctx) { 1085 public void enterWhenStatement(GeneratedYangParser.WhenStatementContext ctx) {
1061 - // TODO: implement the method. 1086 + // TODO: to be implemented
1062 } 1087 }
1063 1088
1064 @Override 1089 @Override
1065 public void exitWhenStatement(GeneratedYangParser.WhenStatementContext ctx) { 1090 public void exitWhenStatement(GeneratedYangParser.WhenStatementContext ctx) {
1066 - // TODO: implement the method. 1091 + // TODO: to be implemented
1067 } 1092 }
1068 1093
1069 @Override 1094 @Override
...@@ -1108,271 +1133,291 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -1108,271 +1133,291 @@ public class TreeWalkListener implements GeneratedYangListener {
1108 1133
1109 @Override 1134 @Override
1110 public void enterDeviationStatement(GeneratedYangParser.DeviationStatementContext ctx) { 1135 public void enterDeviationStatement(GeneratedYangParser.DeviationStatementContext ctx) {
1111 - // TODO: implement the method. 1136 + handleUnsupportedYangConstruct(YangConstructType.DEVIATION_DATA, ctx, UNSUPPORTED_YANG_CONSTRUCT);
1112 } 1137 }
1113 1138
1114 @Override 1139 @Override
1115 public void exitDeviationStatement(GeneratedYangParser.DeviationStatementContext ctx) { 1140 public void exitDeviationStatement(GeneratedYangParser.DeviationStatementContext ctx) {
1116 - // TODO: implement the method. 1141 + // do nothing.
1117 } 1142 }
1118 1143
1119 @Override 1144 @Override
1120 public void enterDeviateNotSupportedStatement(GeneratedYangParser.DeviateNotSupportedStatementContext ctx) { 1145 public void enterDeviateNotSupportedStatement(GeneratedYangParser.DeviateNotSupportedStatementContext ctx) {
1121 - // TODO: implement the method. 1146 + // do nothing.
1122 } 1147 }
1123 1148
1124 @Override 1149 @Override
1125 public void exitDeviateNotSupportedStatement(GeneratedYangParser.DeviateNotSupportedStatementContext ctx) { 1150 public void exitDeviateNotSupportedStatement(GeneratedYangParser.DeviateNotSupportedStatementContext ctx) {
1126 - // TODO: implement the method. 1151 + // do nothing.
1127 } 1152 }
1128 1153
1129 @Override 1154 @Override
1130 public void enterDeviateAddStatement(GeneratedYangParser.DeviateAddStatementContext ctx) { 1155 public void enterDeviateAddStatement(GeneratedYangParser.DeviateAddStatementContext ctx) {
1131 - // TODO: implement the method. 1156 + // do nothing.
1132 } 1157 }
1133 1158
1134 @Override 1159 @Override
1135 public void exitDeviateAddStatement(GeneratedYangParser.DeviateAddStatementContext ctx) { 1160 public void exitDeviateAddStatement(GeneratedYangParser.DeviateAddStatementContext ctx) {
1136 - // TODO: implement the method. 1161 + // do nothing.
1137 } 1162 }
1138 1163
1139 @Override 1164 @Override
1140 public void enterDeviateDeleteStatement(GeneratedYangParser.DeviateDeleteStatementContext ctx) { 1165 public void enterDeviateDeleteStatement(GeneratedYangParser.DeviateDeleteStatementContext ctx) {
1141 - // TODO: implement the method. 1166 + // do nothing.
1142 } 1167 }
1143 1168
1144 @Override 1169 @Override
1145 public void exitDeviateDeleteStatement(GeneratedYangParser.DeviateDeleteStatementContext ctx) { 1170 public void exitDeviateDeleteStatement(GeneratedYangParser.DeviateDeleteStatementContext ctx) {
1146 - // TODO: implement the method. 1171 + // do nothing.
1147 } 1172 }
1148 1173
1149 @Override 1174 @Override
1150 public void enterDeviateReplaceStatement(GeneratedYangParser.DeviateReplaceStatementContext ctx) { 1175 public void enterDeviateReplaceStatement(GeneratedYangParser.DeviateReplaceStatementContext ctx) {
1151 - // TODO: implement the method. 1176 + // do nothing.
1152 } 1177 }
1153 1178
1154 @Override 1179 @Override
1155 public void exitDeviateReplaceStatement(GeneratedYangParser.DeviateReplaceStatementContext ctx) { 1180 public void exitDeviateReplaceStatement(GeneratedYangParser.DeviateReplaceStatementContext ctx) {
1156 - // TODO: implement the method. 1181 + // do nothing.
1157 } 1182 }
1158 1183
1159 @Override 1184 @Override
1160 public void enterString(GeneratedYangParser.StringContext ctx) { 1185 public void enterString(GeneratedYangParser.StringContext ctx) {
1161 - // TODO: implement the method. 1186 + // do nothing.
1162 } 1187 }
1163 1188
1164 @Override 1189 @Override
1165 public void exitString(GeneratedYangParser.StringContext ctx) { 1190 public void exitString(GeneratedYangParser.StringContext ctx) {
1166 - // TODO: implement the method. 1191 + // do nothing.
1167 } 1192 }
1168 1193
1169 @Override 1194 @Override
1170 public void enterIdentifier(GeneratedYangParser.IdentifierContext ctx) { 1195 public void enterIdentifier(GeneratedYangParser.IdentifierContext ctx) {
1171 - // TODO: implement the method. 1196 + // do nothing.
1172 } 1197 }
1173 1198
1174 @Override 1199 @Override
1175 public void exitIdentifier(GeneratedYangParser.IdentifierContext ctx) { 1200 public void exitIdentifier(GeneratedYangParser.IdentifierContext ctx) {
1176 - // TODO: implement the method. 1201 + // do nothing.
1177 } 1202 }
1178 1203
1179 @Override 1204 @Override
1180 public void enterDateArgumentString(GeneratedYangParser.DateArgumentStringContext ctx) { 1205 public void enterDateArgumentString(GeneratedYangParser.DateArgumentStringContext ctx) {
1181 - // TODO: implement the method. 1206 + // do nothing.
1182 } 1207 }
1183 1208
1184 @Override 1209 @Override
1185 public void exitDateArgumentString(GeneratedYangParser.DateArgumentStringContext ctx) { 1210 public void exitDateArgumentString(GeneratedYangParser.DateArgumentStringContext ctx) {
1186 - // TODO: implement the method. 1211 + // do nothing.
1187 } 1212 }
1188 1213
1189 @Override 1214 @Override
1190 public void enterRange(GeneratedYangParser.RangeContext ctx) { 1215 public void enterRange(GeneratedYangParser.RangeContext ctx) {
1191 - // TODO: implement the method. 1216 + // do nothing.
1192 } 1217 }
1193 1218
1194 @Override 1219 @Override
1195 public void exitRange(GeneratedYangParser.RangeContext ctx) { 1220 public void exitRange(GeneratedYangParser.RangeContext ctx) {
1196 - // TODO: implement the method. 1221 + // do nothing.
1197 } 1222 }
1198 1223
1199 @Override 1224 @Override
1200 public void enterLength(GeneratedYangParser.LengthContext ctx) { 1225 public void enterLength(GeneratedYangParser.LengthContext ctx) {
1201 - // TODO: implement the method. 1226 + // do nothing.
1202 } 1227 }
1203 1228
1204 @Override 1229 @Override
1205 public void exitLength(GeneratedYangParser.LengthContext ctx) { 1230 public void exitLength(GeneratedYangParser.LengthContext ctx) {
1206 - // TODO: implement the method. 1231 + // do nothing.
1207 } 1232 }
1208 1233
1209 @Override 1234 @Override
1210 public void enterPath(GeneratedYangParser.PathContext ctx) { 1235 public void enterPath(GeneratedYangParser.PathContext ctx) {
1211 - // TODO: implement the method. 1236 + // do nothing.
1212 } 1237 }
1213 1238
1214 @Override 1239 @Override
1215 public void exitPath(GeneratedYangParser.PathContext ctx) { 1240 public void exitPath(GeneratedYangParser.PathContext ctx) {
1216 - // TODO: implement the method. 1241 + // do nothing.
1217 } 1242 }
1218 1243
1219 @Override 1244 @Override
1220 public void enterPosition(GeneratedYangParser.PositionContext ctx) { 1245 public void enterPosition(GeneratedYangParser.PositionContext ctx) {
1221 - // TODO: implement the method. 1246 + // do nothing.
1222 } 1247 }
1223 1248
1224 @Override 1249 @Override
1225 public void exitPosition(GeneratedYangParser.PositionContext ctx) { 1250 public void exitPosition(GeneratedYangParser.PositionContext ctx) {
1226 - // TODO: implement the method. 1251 + // do nothing.
1227 } 1252 }
1228 1253
1229 @Override 1254 @Override
1230 public void enterStatus(GeneratedYangParser.StatusContext ctx) { 1255 public void enterStatus(GeneratedYangParser.StatusContext ctx) {
1231 - // TODO: implement the method. 1256 + // do nothing.
1232 } 1257 }
1233 1258
1234 @Override 1259 @Override
1235 public void exitStatus(GeneratedYangParser.StatusContext ctx) { 1260 public void exitStatus(GeneratedYangParser.StatusContext ctx) {
1236 - // TODO: implement the method. 1261 + // do nothing.
1237 } 1262 }
1238 1263
1239 @Override 1264 @Override
1240 public void enterConfig(GeneratedYangParser.ConfigContext ctx) { 1265 public void enterConfig(GeneratedYangParser.ConfigContext ctx) {
1241 - // TODO: implement the method. 1266 + // do nothing.
1242 } 1267 }
1243 1268
1244 @Override 1269 @Override
1245 public void exitConfig(GeneratedYangParser.ConfigContext ctx) { 1270 public void exitConfig(GeneratedYangParser.ConfigContext ctx) {
1246 - // TODO: implement the method. 1271 + // do nothing.
1247 } 1272 }
1248 1273
1249 @Override 1274 @Override
1250 public void enterMandatory(GeneratedYangParser.MandatoryContext ctx) { 1275 public void enterMandatory(GeneratedYangParser.MandatoryContext ctx) {
1251 - // TODO: implement the method. 1276 + // do nothing.
1252 } 1277 }
1253 1278
1254 @Override 1279 @Override
1255 public void exitMandatory(GeneratedYangParser.MandatoryContext ctx) { 1280 public void exitMandatory(GeneratedYangParser.MandatoryContext ctx) {
1256 - // TODO: implement the method. 1281 + // do nothing.
1257 } 1282 }
1258 1283
1259 @Override 1284 @Override
1260 public void enterOrderedBy(GeneratedYangParser.OrderedByContext ctx) { 1285 public void enterOrderedBy(GeneratedYangParser.OrderedByContext ctx) {
1261 - // TODO: implement the method. 1286 + // do nothing.
1262 } 1287 }
1263 1288
1264 @Override 1289 @Override
1265 public void exitOrderedBy(GeneratedYangParser.OrderedByContext ctx) { 1290 public void exitOrderedBy(GeneratedYangParser.OrderedByContext ctx) {
1266 - // TODO: implement the method. 1291 + // do nothing.
1267 } 1292 }
1268 1293
1269 @Override 1294 @Override
1270 public void enterMinValue(GeneratedYangParser.MinValueContext ctx) { 1295 public void enterMinValue(GeneratedYangParser.MinValueContext ctx) {
1271 - // TODO: implement the method. 1296 + // do nothing.
1272 } 1297 }
1273 1298
1274 @Override 1299 @Override
1275 public void exitMinValue(GeneratedYangParser.MinValueContext ctx) { 1300 public void exitMinValue(GeneratedYangParser.MinValueContext ctx) {
1276 - // TODO: implement the method. 1301 + // do nothing.
1277 } 1302 }
1278 1303
1279 @Override 1304 @Override
1280 public void enterMaxValue(GeneratedYangParser.MaxValueContext ctx) { 1305 public void enterMaxValue(GeneratedYangParser.MaxValueContext ctx) {
1281 - // TODO: implement the method. 1306 + // do nothing.
1282 } 1307 }
1283 1308
1284 @Override 1309 @Override
1285 public void exitMaxValue(GeneratedYangParser.MaxValueContext ctx) { 1310 public void exitMaxValue(GeneratedYangParser.MaxValueContext ctx) {
1286 - // TODO: implement the method. 1311 + // do nothing.
1287 } 1312 }
1288 1313
1289 @Override 1314 @Override
1290 public void enterKey(GeneratedYangParser.KeyContext ctx) { 1315 public void enterKey(GeneratedYangParser.KeyContext ctx) {
1291 - // TODO: implement the method. 1316 + // do nothing.
1292 } 1317 }
1293 1318
1294 @Override 1319 @Override
1295 public void exitKey(GeneratedYangParser.KeyContext ctx) { 1320 public void exitKey(GeneratedYangParser.KeyContext ctx) {
1296 - // TODO: implement the method. 1321 + // do nothing.
1297 } 1322 }
1298 1323
1299 @Override 1324 @Override
1300 public void enterUnique(GeneratedYangParser.UniqueContext ctx) { 1325 public void enterUnique(GeneratedYangParser.UniqueContext ctx) {
1301 - // TODO: implement the method. 1326 + // do nothing.
1302 } 1327 }
1303 1328
1304 @Override 1329 @Override
1305 public void exitUnique(GeneratedYangParser.UniqueContext ctx) { 1330 public void exitUnique(GeneratedYangParser.UniqueContext ctx) {
1306 - // TODO: implement the method. 1331 + // do nothing.
1307 } 1332 }
1308 1333
1309 @Override 1334 @Override
1310 public void enterRefine(GeneratedYangParser.RefineContext ctx) { 1335 public void enterRefine(GeneratedYangParser.RefineContext ctx) {
1311 - // TODO: implement the method. 1336 + // do nothing.
1312 } 1337 }
1313 1338
1314 @Override 1339 @Override
1315 public void exitRefine(GeneratedYangParser.RefineContext ctx) { 1340 public void exitRefine(GeneratedYangParser.RefineContext ctx) {
1316 - // TODO: implement the method. 1341 + // do nothing.
1317 } 1342 }
1318 1343
1319 @Override 1344 @Override
1320 public void enterAugment(GeneratedYangParser.AugmentContext ctx) { 1345 public void enterAugment(GeneratedYangParser.AugmentContext ctx) {
1321 - // TODO: implement the method. 1346 + // do nothing.
1322 } 1347 }
1323 1348
1324 @Override 1349 @Override
1325 public void exitAugment(GeneratedYangParser.AugmentContext ctx) { 1350 public void exitAugment(GeneratedYangParser.AugmentContext ctx) {
1326 - // TODO: implement the method. 1351 + // do nothing.
1327 } 1352 }
1328 1353
1329 @Override 1354 @Override
1330 public void enterDeviation(GeneratedYangParser.DeviationContext ctx) { 1355 public void enterDeviation(GeneratedYangParser.DeviationContext ctx) {
1331 - // TODO: implement the method. 1356 + // do nothing.
1332 } 1357 }
1333 1358
1334 @Override 1359 @Override
1335 public void exitDeviation(GeneratedYangParser.DeviationContext ctx) { 1360 public void exitDeviation(GeneratedYangParser.DeviationContext ctx) {
1336 - // TODO: implement the method. 1361 + // do nothing.
1337 } 1362 }
1338 1363
1339 @Override 1364 @Override
1340 public void enterYangConstruct(GeneratedYangParser.YangConstructContext ctx) { 1365 public void enterYangConstruct(GeneratedYangParser.YangConstructContext ctx) {
1341 - // TODO: implement the method. 1366 + // do nothing.
1342 } 1367 }
1343 1368
1344 @Override 1369 @Override
1345 public void exitYangConstruct(GeneratedYangParser.YangConstructContext ctx) { 1370 public void exitYangConstruct(GeneratedYangParser.YangConstructContext ctx) {
1346 - // TODO: implement the method. 1371 + // do nothing.
1347 } 1372 }
1348 1373
1349 @Override 1374 @Override
1350 public void enterVersion(GeneratedYangParser.VersionContext ctx) { 1375 public void enterVersion(GeneratedYangParser.VersionContext ctx) {
1351 - // TODO: implement the method. 1376 + // do nothing.
1352 } 1377 }
1353 1378
1354 @Override 1379 @Override
1355 public void exitVersion(GeneratedYangParser.VersionContext ctx) { 1380 public void exitVersion(GeneratedYangParser.VersionContext ctx) {
1381 + // do nothing.
1382 + }
1383 +
1384 + @Override
1385 + public void enterValue(GeneratedYangParser.ValueContext ctx) {
1386 + // do nothing.
1387 + }
1388 +
1389 + @Override
1390 + public void exitValue(GeneratedYangParser.ValueContext ctx) {
1391 + // do nothing.
1392 + }
1393 +
1394 + @Override
1395 + public void enterFraction(GeneratedYangParser.FractionContext ctx) {
1356 // TODO: implement the method. 1396 // TODO: implement the method.
1357 } 1397 }
1358 1398
1359 @Override 1399 @Override
1360 - public void visitTerminal(TerminalNode terminalNode) { 1400 + public void exitFraction(GeneratedYangParser.FractionContext ctx) {
1361 // TODO: implement the method. 1401 // TODO: implement the method.
1362 } 1402 }
1363 1403
1364 @Override 1404 @Override
1405 + public void visitTerminal(TerminalNode terminalNode) {
1406 + // do nothing.
1407 + }
1408 +
1409 + @Override
1365 public void visitErrorNode(ErrorNode errorNode) { 1410 public void visitErrorNode(ErrorNode errorNode) {
1366 - // TODO: implement the method. 1411 + // do nothing.
1367 } 1412 }
1368 1413
1369 @Override 1414 @Override
1370 public void enterEveryRule(ParserRuleContext parserRuleContext) { 1415 public void enterEveryRule(ParserRuleContext parserRuleContext) {
1371 - // TODO: implement the method. 1416 + // do nothing.
1372 } 1417 }
1373 1418
1374 @Override 1419 @Override
1375 public void exitEveryRule(ParserRuleContext parserRuleContext) { 1420 public void exitEveryRule(ParserRuleContext parserRuleContext) {
1376 - // TODO: implement the method. 1421 + // do nothing.
1377 } 1422 }
1378 } 1423 }
......
...@@ -26,6 +26,7 @@ import org.onosproject.yangutils.datamodel.YangModule; ...@@ -26,6 +26,7 @@ import org.onosproject.yangutils.datamodel.YangModule;
26 import org.onosproject.yangutils.datamodel.YangNode; 26 import org.onosproject.yangutils.datamodel.YangNode;
27 import org.onosproject.yangutils.datamodel.YangNotification; 27 import org.onosproject.yangutils.datamodel.YangNotification;
28 import org.onosproject.yangutils.datamodel.YangOutput; 28 import org.onosproject.yangutils.datamodel.YangOutput;
29 +import org.onosproject.yangutils.datamodel.YangSubModule;
29 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 30 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
30 import org.onosproject.yangutils.parser.Parsable; 31 import org.onosproject.yangutils.parser.Parsable;
31 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 32 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
...@@ -133,12 +134,11 @@ public final class ContainerListener { ...@@ -133,12 +134,11 @@ public final class ContainerListener {
133 } 134 }
134 135
135 Parsable curData = listener.getParsedDataStack().peek(); 136 Parsable curData = listener.getParsedDataStack().peek();
136 - if (curData instanceof YangModule || curData instanceof YangContainer 137 + if (curData instanceof YangModule || curData instanceof YangSubModule
137 - || curData instanceof YangList || curData instanceof YangCase 138 + || curData instanceof YangContainer || curData instanceof YangList
138 - || curData instanceof YangNotification 139 + || curData instanceof YangCase || curData instanceof YangNotification
139 || curData instanceof YangInput || curData instanceof YangOutput 140 || curData instanceof YangInput || curData instanceof YangOutput
140 - || curData instanceof YangAugment 141 + || curData instanceof YangAugment || curData instanceof YangGrouping) {
141 - || curData instanceof YangGrouping) {
142 YangNode curNode = (YangNode) curData; 142 YangNode curNode = (YangNode) curData;
143 try { 143 try {
144 curNode.addChild(container); 144 curNode.addChild(container);
......
...@@ -39,6 +39,8 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -39,6 +39,8 @@ package org.onosproject.yangutils.parser.impl.listeners;
39 * defaultStatement : DEFAULT_KEYWORD string STMTEND; 39 * defaultStatement : DEFAULT_KEYWORD string STMTEND;
40 */ 40 */
41 41
42 +import org.onosproject.yangutils.datamodel.YangChoice;
43 +import org.onosproject.yangutils.datamodel.YangLeaf;
42 import org.onosproject.yangutils.datamodel.YangTypeDef; 44 import org.onosproject.yangutils.datamodel.YangTypeDef;
43 import org.onosproject.yangutils.parser.Parsable; 45 import org.onosproject.yangutils.parser.Parsable;
44 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 46 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
...@@ -83,6 +85,16 @@ public final class DefaultListener { ...@@ -83,6 +85,16 @@ public final class DefaultListener {
83 typeDef.setDefaultValueInString(ctx.string().getText()); 85 typeDef.setDefaultValueInString(ctx.string().getText());
84 break; 86 break;
85 } 87 }
88 + case LEAF_DATA: {
89 + YangLeaf leaf = (YangLeaf) tmpNode;
90 + leaf.setDefaultValueInString(ctx.string().getText());
91 + break;
92 + }
93 + case CHOICE_DATA: {
94 + YangChoice choice = (YangChoice) tmpNode;
95 + choice.setDefaultValueInString(ctx.string().getText());
96 + break;
97 + }
86 default: 98 default:
87 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, 99 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER,
88 DEFAULT_DATA, ctx.string().getText(), ENTRY)); 100 DEFAULT_DATA, ctx.string().getText(), ENTRY));
......
...@@ -146,7 +146,14 @@ public final class EnumListener { ...@@ -146,7 +146,14 @@ public final class EnumListener {
146 boolean isValuePresent = false; 146 boolean isValuePresent = false;
147 147
148 for (YangEnum curEnum : yangEnumeration.getEnumSet()) { 148 for (YangEnum curEnum : yangEnumeration.getEnumSet()) {
149 - if (maxValue <= curEnum.getValue()) { 149 + if (curEnum.getValue() == Integer.MAX_VALUE) {
150 + ParserException parserException = new ParserException("YANG file error : "
151 + + "An enum value MUST be specified for enum substatements following the one"
152 + + "with the current highest value");
153 + parserException.setLine(ctx.getStart().getLine());
154 + parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
155 + throw parserException;
156 + } else if (maxValue <= curEnum.getValue()) {
150 maxValue = curEnum.getValue(); 157 maxValue = curEnum.getValue();
151 isValuePresent = true; 158 isValuePresent = true;
152 } 159 }
...@@ -161,8 +168,8 @@ public final class EnumListener { ...@@ -161,8 +168,8 @@ public final class EnumListener {
161 } catch (DataModelException e) { 168 } catch (DataModelException e) {
162 ParserException parserException = new ParserException(constructExtendedListenerErrorMessage( 169 ParserException parserException = new ParserException(constructExtendedListenerErrorMessage(
163 DUPLICATE_ENTRY, ENUM_DATA, ctx.string().getText(), EXIT, e.getMessage())); 170 DUPLICATE_ENTRY, ENUM_DATA, ctx.string().getText(), EXIT, e.getMessage()));
164 - parserException.setLine(ctx.string().STRING(0).getSymbol().getLine()); 171 + parserException.setLine(ctx.getStart().getLine());
165 - parserException.setCharPosition(ctx.string().STRING(0).getSymbol().getCharPositionInLine()); 172 + parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
166 throw parserException; 173 throw parserException;
167 } 174 }
168 break; 175 break;
...@@ -173,8 +180,7 @@ public final class EnumListener { ...@@ -173,8 +180,7 @@ public final class EnumListener {
173 } 180 }
174 } else { 181 } else {
175 throw new ParserException( 182 throw new ParserException(
176 - constructListenerErrorMessage(MISSING_CURRENT_HOLDER, ENUM_DATA, ctx.string().getText(), 183 + constructListenerErrorMessage(MISSING_CURRENT_HOLDER, ENUM_DATA, ctx.string().getText(), EXIT));
177 - EXIT));
178 } 184 }
179 } 185 }
180 } 186 }
......
...@@ -29,8 +29,10 @@ import org.onosproject.yangutils.utils.YangConstructType; ...@@ -29,8 +29,10 @@ import org.onosproject.yangutils.utils.YangConstructType;
29 29
30 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; 30 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
35 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 36 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
35 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; 37 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
36 import static org.onosproject.yangutils.utils.RestrictionResolver.processLengthRestriction; 38 import static org.onosproject.yangutils.utils.RestrictionResolver.processLengthRestriction;
...@@ -86,7 +88,7 @@ public final class LengthRestrictionListener { ...@@ -86,7 +88,7 @@ public final class LengthRestrictionListener {
86 Parsable tmpData = listener.getParsedDataStack().peek(); 88 Parsable tmpData = listener.getParsedDataStack().peek();
87 if (tmpData.getYangConstructType() == TYPE_DATA) { 89 if (tmpData.getYangConstructType() == TYPE_DATA) {
88 YangType type = (YangType) tmpData; 90 YangType type = (YangType) tmpData;
89 - setLengthRestriction(type, ctx); 91 + setLengthRestriction(listener, type, ctx);
90 } else { 92 } else {
91 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LENGTH_DATA, 93 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LENGTH_DATA,
92 ctx.length().getText(), ENTRY)); 94 ctx.length().getText(), ENTRY));
...@@ -96,10 +98,11 @@ public final class LengthRestrictionListener { ...@@ -96,10 +98,11 @@ public final class LengthRestrictionListener {
96 /** 98 /**
97 * Sets the length restriction to type. 99 * Sets the length restriction to type.
98 * 100 *
101 + * @param listener listener's object
99 * @param type Yang type for which length restriction to be set 102 * @param type Yang type for which length restriction to be set
100 * @param ctx context object of the grammar rule 103 * @param ctx context object of the grammar rule
101 */ 104 */
102 - private static void setLengthRestriction(YangType type, 105 + private static void setLengthRestriction(TreeWalkListener listener, YangType type,
103 GeneratedYangParser.LengthStatementContext ctx) { 106 GeneratedYangParser.LengthStatementContext ctx) {
104 107
105 if (type.getDataType() == DERIVED) { 108 if (type.getDataType() == DERIVED) {
...@@ -132,5 +135,31 @@ public final class LengthRestrictionListener { ...@@ -132,5 +135,31 @@ public final class LengthRestrictionListener {
132 } 135 }
133 136
134 stringRestriction.setLengthRestriction(lengthRestriction); 137 stringRestriction.setLengthRestriction(lengthRestriction);
138 + listener.getParsedDataStack().push(lengthRestriction);
139 + }
140 +
141 + /**
142 + * Performs validation and updates the data model tree.
143 + * It is called when parser exits from grammar rule (length).
144 + *
145 + * @param listener listener's object
146 + * @param ctx context object of the grammar rule
147 + */
148 + public static void processLengthRestrictionExit(TreeWalkListener listener,
149 + GeneratedYangParser.LengthStatementContext ctx) {
150 +
151 + // Check for stack to be non empty.
152 + checkStackIsNotEmpty(listener, MISSING_HOLDER, LENGTH_DATA, ctx.length().getText(), EXIT);
153 +
154 + Parsable tmpData = listener.getParsedDataStack().peek();
155 + if (tmpData instanceof YangRangeRestriction) {
156 + listener.getParsedDataStack().pop();
157 + } else if (tmpData instanceof YangType
158 + && ((YangType) tmpData).getDataType() == DERIVED) {
159 + // TODO : need to handle in linker
160 + } else {
161 + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LENGTH_DATA,
162 + ctx.length().getText(), EXIT));
163 + }
135 } 164 }
136 } 165 }
......
...@@ -26,6 +26,7 @@ import org.onosproject.yangutils.datamodel.YangModule; ...@@ -26,6 +26,7 @@ import org.onosproject.yangutils.datamodel.YangModule;
26 import org.onosproject.yangutils.datamodel.YangNode; 26 import org.onosproject.yangutils.datamodel.YangNode;
27 import org.onosproject.yangutils.datamodel.YangNotification; 27 import org.onosproject.yangutils.datamodel.YangNotification;
28 import org.onosproject.yangutils.datamodel.YangOutput; 28 import org.onosproject.yangutils.datamodel.YangOutput;
29 +import org.onosproject.yangutils.datamodel.YangSubModule;
29 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 30 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
30 import org.onosproject.yangutils.parser.Parsable; 31 import org.onosproject.yangutils.parser.Parsable;
31 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 32 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
...@@ -141,7 +142,8 @@ public final class ListListener { ...@@ -141,7 +142,8 @@ public final class ListListener {
141 if (curData instanceof YangModule || curData instanceof YangContainer 142 if (curData instanceof YangModule || curData instanceof YangContainer
142 || curData instanceof YangList || curData instanceof YangCase 143 || curData instanceof YangList || curData instanceof YangCase
143 || curData instanceof YangNotification || curData instanceof YangInput 144 || curData instanceof YangNotification || curData instanceof YangInput
144 - || curData instanceof YangOutput || curData instanceof YangAugment || curData instanceof YangGrouping) { 145 + || curData instanceof YangOutput || curData instanceof YangAugment
146 + || curData instanceof YangGrouping || curData instanceof YangSubModule) {
145 curNode = (YangNode) curData; 147 curNode = (YangNode) curData;
146 try { 148 try {
147 curNode.addChild(yangList); 149 curNode.addChild(yangList);
......
...@@ -27,9 +27,12 @@ import org.onosproject.yangutils.parser.exceptions.ParserException; ...@@ -27,9 +27,12 @@ import org.onosproject.yangutils.parser.exceptions.ParserException;
27 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 27 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
28 import org.onosproject.yangutils.utils.YangConstructType; 28 import org.onosproject.yangutils.utils.YangConstructType;
29 29
30 +import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
35 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 36 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; 37 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
35 import static org.onosproject.yangutils.utils.YangConstructType.PATTERN_DATA; 38 import static org.onosproject.yangutils.utils.YangConstructType.PATTERN_DATA;
...@@ -84,7 +87,7 @@ public final class PatternRestrictionListener { ...@@ -84,7 +87,7 @@ public final class PatternRestrictionListener {
84 Parsable tmpData = listener.getParsedDataStack().peek(); 87 Parsable tmpData = listener.getParsedDataStack().peek();
85 if (tmpData.getYangConstructType() == TYPE_DATA) { 88 if (tmpData.getYangConstructType() == TYPE_DATA) {
86 YangType type = (YangType) tmpData; 89 YangType type = (YangType) tmpData;
87 - setPatternRestriction(type, ctx); 90 + setPatternRestriction(listener, type, ctx);
88 } else { 91 } else {
89 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, PATTERN_DATA, 92 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, PATTERN_DATA,
90 ctx.string().getText(), ENTRY)); 93 ctx.string().getText(), ENTRY));
...@@ -94,10 +97,11 @@ public final class PatternRestrictionListener { ...@@ -94,10 +97,11 @@ public final class PatternRestrictionListener {
94 /** 97 /**
95 * Sets the pattern restriction to type. 98 * Sets the pattern restriction to type.
96 * 99 *
100 + * @param listener listener's object
97 * @param type Yang type for which pattern restriction to be set 101 * @param type Yang type for which pattern restriction to be set
98 * @param ctx context object of the grammar rule 102 * @param ctx context object of the grammar rule
99 */ 103 */
100 - private static void setPatternRestriction(YangType type, 104 + private static void setPatternRestriction(TreeWalkListener listener, YangType type,
101 GeneratedYangParser.PatternStatementContext ctx) { 105 GeneratedYangParser.PatternStatementContext ctx) {
102 106
103 if (type.getDataType() != YangDataTypes.STRING && type.getDataType() != YangDataTypes.DERIVED) { 107 if (type.getDataType() != YangDataTypes.STRING && type.getDataType() != YangDataTypes.DERIVED) {
...@@ -121,6 +125,7 @@ public final class PatternRestrictionListener { ...@@ -121,6 +125,7 @@ public final class PatternRestrictionListener {
121 } else { 125 } else {
122 stringRestriction.addPattern(patternArgument); 126 stringRestriction.addPattern(patternArgument);
123 } 127 }
128 + listener.getParsedDataStack().push(stringRestriction);
124 } else { 129 } else {
125 YangPatternRestriction patternRestriction = (YangPatternRestriction) ((YangDerivedInfo<?>) type 130 YangPatternRestriction patternRestriction = (YangPatternRestriction) ((YangDerivedInfo<?>) type
126 .getDataTypeExtendedInfo()).getPatternRestriction(); 131 .getDataTypeExtendedInfo()).getPatternRestriction();
...@@ -134,4 +139,29 @@ public final class PatternRestrictionListener { ...@@ -134,4 +139,29 @@ public final class PatternRestrictionListener {
134 } 139 }
135 } 140 }
136 } 141 }
142 +
143 + /**
144 + * Performs validation and updates the data model tree.
145 + * It is called when parser exits from grammar rule (pattern).
146 + *
147 + * @param listener listener's object
148 + * @param ctx context object of the grammar rule
149 + */
150 + public static void processPatternRestrictionExit(TreeWalkListener listener,
151 + GeneratedYangParser.PatternStatementContext ctx) {
152 +
153 + // Check for stack to be non empty.
154 + checkStackIsNotEmpty(listener, MISSING_HOLDER, PATTERN_DATA, ctx.string().getText(), EXIT);
155 +
156 + Parsable tmpData = listener.getParsedDataStack().peek();
157 + if (tmpData instanceof YangStringRestriction) {
158 + listener.getParsedDataStack().pop();
159 + } else if (tmpData instanceof YangType
160 + && ((YangType) tmpData).getDataType() == DERIVED) {
161 + // TODO : need to handle in linker
162 + } else {
163 + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, PATTERN_DATA,
164 + ctx.string().getText(), EXIT));
165 + }
166 + }
137 } 167 }
......
...@@ -26,8 +26,10 @@ import org.onosproject.yangutils.parser.impl.TreeWalkListener; ...@@ -26,8 +26,10 @@ import org.onosproject.yangutils.parser.impl.TreeWalkListener;
26 26
27 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; 27 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
28 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 28 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
29 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
29 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; 34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
33 import static org.onosproject.yangutils.utils.RestrictionResolver.isOfRangeRestrictedType; 35 import static org.onosproject.yangutils.utils.RestrictionResolver.isOfRangeRestrictedType;
...@@ -82,7 +84,7 @@ public final class RangeRestrictionListener { ...@@ -82,7 +84,7 @@ public final class RangeRestrictionListener {
82 Parsable tmpData = listener.getParsedDataStack().peek(); 84 Parsable tmpData = listener.getParsedDataStack().peek();
83 if (tmpData.getYangConstructType() == TYPE_DATA) { 85 if (tmpData.getYangConstructType() == TYPE_DATA) {
84 YangType type = (YangType) tmpData; 86 YangType type = (YangType) tmpData;
85 - setRangeRestriction(type, ctx); 87 + setRangeRestriction(listener, type, ctx);
86 } else { 88 } else {
87 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, RANGE_DATA, 89 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, RANGE_DATA,
88 ctx.range().getText(), ENTRY)); 90 ctx.range().getText(), ENTRY));
...@@ -92,10 +94,11 @@ public final class RangeRestrictionListener { ...@@ -92,10 +94,11 @@ public final class RangeRestrictionListener {
92 /** 94 /**
93 * Sets the range restriction to type. 95 * Sets the range restriction to type.
94 * 96 *
97 + * @param listener listener's object
95 * @param type YANG type for which range restriction to be added 98 * @param type YANG type for which range restriction to be added
96 * @param ctx context object of the grammar rule 99 * @param ctx context object of the grammar rule
97 */ 100 */
98 - private static void setRangeRestriction(YangType type, 101 + private static void setRangeRestriction(TreeWalkListener listener, YangType type,
99 GeneratedYangParser.RangeStatementContext ctx) { 102 GeneratedYangParser.RangeStatementContext ctx) {
100 103
101 if (type.getDataType() == DERIVED) { 104 if (type.getDataType() == DERIVED) {
...@@ -122,5 +125,31 @@ public final class RangeRestrictionListener { ...@@ -122,5 +125,31 @@ public final class RangeRestrictionListener {
122 if (rangeRestriction != null) { 125 if (rangeRestriction != null) {
123 type.setDataTypeExtendedInfo(rangeRestriction); 126 type.setDataTypeExtendedInfo(rangeRestriction);
124 } 127 }
128 + listener.getParsedDataStack().push(rangeRestriction);
129 + }
130 +
131 + /**
132 + * Performs validation and updates the data model tree.
133 + * It is called when parser exits from grammar rule (range).
134 + *
135 + * @param listener listener's object
136 + * @param ctx context object of the grammar rule
137 + */
138 + public static void processRangeRestrictionExit(TreeWalkListener listener,
139 + GeneratedYangParser.RangeStatementContext ctx) {
140 +
141 + // Check for stack to be non empty.
142 + checkStackIsNotEmpty(listener, MISSING_HOLDER, RANGE_DATA, ctx.range().getText(), EXIT);
143 +
144 + Parsable tmpData = listener.getParsedDataStack().peek();
145 + if (tmpData instanceof YangRangeRestriction) {
146 + listener.getParsedDataStack().pop();
147 + } else if (tmpData instanceof YangType
148 + && ((YangType) tmpData).getDataType() == DERIVED) {
149 + // TODO : need to handle in linker
150 + } else {
151 + throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, RANGE_DATA,
152 + ctx.range().getText(), EXIT));
153 + }
125 } 154 }
126 } 155 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -38,6 +38,7 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMes ...@@ -38,6 +38,7 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMes
38 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 38 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
39 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 39 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
40 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; 40 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
41 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIntegerValue;
41 import static org.onosproject.yangutils.utils.YangConstructType.VALUE_DATA; 42 import static org.onosproject.yangutils.utils.YangConstructType.VALUE_DATA;
42 43
43 /** 44 /**
...@@ -62,25 +63,28 @@ public final class ValueListener { ...@@ -62,25 +63,28 @@ public final class ValueListener {
62 public static void processValueEntry(TreeWalkListener listener, GeneratedYangParser.ValueStatementContext ctx) { 63 public static void processValueEntry(TreeWalkListener listener, GeneratedYangParser.ValueStatementContext ctx) {
63 64
64 // Check for stack to be non empty. 65 // Check for stack to be non empty.
65 - checkStackIsNotEmpty(listener, MISSING_HOLDER, VALUE_DATA, ctx.INTEGER().getText(), ENTRY); 66 + checkStackIsNotEmpty(listener, MISSING_HOLDER, VALUE_DATA, ctx.value().getText(), ENTRY);
67 +
68 + // Validate value
69 + int value = getValidIntegerValue(ctx.value().getText(), VALUE_DATA, ctx);
66 70
67 // Obtain the node of the stack. 71 // Obtain the node of the stack.
68 Parsable tmpNode = listener.getParsedDataStack().peek(); 72 Parsable tmpNode = listener.getParsedDataStack().peek();
69 switch (tmpNode.getYangConstructType()) { 73 switch (tmpNode.getYangConstructType()) {
70 case ENUM_DATA: { 74 case ENUM_DATA: {
71 YangEnum enumNode = (YangEnum) tmpNode; 75 YangEnum enumNode = (YangEnum) tmpNode;
72 - if (!isEnumValueValid(listener, ctx)) { 76 + if (!isEnumValueValid(listener, ctx, value)) {
73 ParserException parserException = new ParserException("Duplicate Value Entry"); 77 ParserException parserException = new ParserException("Duplicate Value Entry");
74 - parserException.setLine(ctx.INTEGER().getSymbol().getLine()); 78 + parserException.setLine(ctx.getStart().getLine());
75 - parserException.setCharPosition(ctx.INTEGER().getSymbol().getCharPositionInLine()); 79 + parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
76 throw parserException; 80 throw parserException;
77 } 81 }
78 - enumNode.setValue(Integer.valueOf(ctx.INTEGER().getText())); 82 + enumNode.setValue(value);
79 break; 83 break;
80 } 84 }
81 default: 85 default:
82 throw new ParserException( 86 throw new ParserException(
83 - constructListenerErrorMessage(INVALID_HOLDER, VALUE_DATA, ctx.INTEGER().getText(), ENTRY)); 87 + constructListenerErrorMessage(INVALID_HOLDER, VALUE_DATA, ctx.value().getText(), ENTRY));
84 } 88 }
85 } 89 }
86 90
...@@ -89,20 +93,22 @@ public final class ValueListener { ...@@ -89,20 +93,22 @@ public final class ValueListener {
89 * 93 *
90 * @param listener Listener's object 94 * @param listener Listener's object
91 * @param ctx context object of the grammar rule 95 * @param ctx context object of the grammar rule
96 + * @param value enum value
92 * @return validation result 97 * @return validation result
93 */ 98 */
94 - private static boolean isEnumValueValid(TreeWalkListener listener, GeneratedYangParser.ValueStatementContext ctx) { 99 + private static boolean isEnumValueValid(TreeWalkListener listener, GeneratedYangParser.ValueStatementContext ctx,
100 + int value) {
95 Parsable enumNode = listener.getParsedDataStack().pop(); 101 Parsable enumNode = listener.getParsedDataStack().pop();
96 102
97 // Check for stack to be non empty. 103 // Check for stack to be non empty.
98 - checkStackIsNotEmpty(listener, MISSING_HOLDER, VALUE_DATA, ctx.INTEGER().getText(), ENTRY); 104 + checkStackIsNotEmpty(listener, MISSING_HOLDER, VALUE_DATA, ctx.value().getText(), ENTRY);
99 105
100 Parsable tmpNode = listener.getParsedDataStack().peek(); 106 Parsable tmpNode = listener.getParsedDataStack().peek();
101 switch (tmpNode.getYangConstructType()) { 107 switch (tmpNode.getYangConstructType()) {
102 case ENUMERATION_DATA: { 108 case ENUMERATION_DATA: {
103 YangEnumeration yangEnumeration = (YangEnumeration) tmpNode; 109 YangEnumeration yangEnumeration = (YangEnumeration) tmpNode;
104 for (YangEnum curEnum : yangEnumeration.getEnumSet()) { 110 for (YangEnum curEnum : yangEnumeration.getEnumSet()) {
105 - if (Integer.valueOf(ctx.INTEGER().getText()) == curEnum.getValue()) { 111 + if (value == curEnum.getValue()) {
106 listener.getParsedDataStack().push(enumNode); 112 listener.getParsedDataStack().push(enumNode);
107 return false; 113 return false;
108 } 114 }
...@@ -113,7 +119,7 @@ public final class ValueListener { ...@@ -113,7 +119,7 @@ public final class ValueListener {
113 default: 119 default:
114 listener.getParsedDataStack().push(enumNode); 120 listener.getParsedDataStack().push(enumNode);
115 throw new ParserException( 121 throw new ParserException(
116 - constructListenerErrorMessage(INVALID_HOLDER, VALUE_DATA, ctx.INTEGER().getText(), ENTRY)); 122 + constructListenerErrorMessage(INVALID_HOLDER, VALUE_DATA, ctx.value().getText(), ENTRY));
117 } 123 }
118 } 124 }
119 } 125 }
......
...@@ -29,6 +29,18 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; ...@@ -29,6 +29,18 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
29 import org.onosproject.yangutils.parser.exceptions.ParserException; 29 import org.onosproject.yangutils.parser.exceptions.ParserException;
30 import org.onosproject.yangutils.utils.YangConstructType; 30 import org.onosproject.yangutils.utils.YangConstructType;
31 31
32 +import static org.onosproject.yangutils.utils.UtilConstants.ADD;
33 +import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
34 +import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
35 +import static org.onosproject.yangutils.utils.UtilConstants.COLON;
36 +import static org.onosproject.yangutils.utils.UtilConstants.CARET;
37 +import static org.onosproject.yangutils.utils.UtilConstants.QUOTES;
38 +import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN;
39 +import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
40 +import static org.onosproject.yangutils.utils.UtilConstants.TRUE;
41 +import static org.onosproject.yangutils.utils.UtilConstants.FALSE;
42 +import static org.onosproject.yangutils.utils.UtilConstants.YANG_FILE_ERROR;
43 +
32 /** 44 /**
33 * Represents an utility for listener. 45 * Represents an utility for listener.
34 */ 46 */
...@@ -37,18 +49,10 @@ public final class ListenerUtil { ...@@ -37,18 +49,10 @@ public final class ListenerUtil {
37 private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("[a-zA-Z_][a-zA-Z0-9_.-]*"); 49 private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("[a-zA-Z_][a-zA-Z0-9_.-]*");
38 private static final String DATE_PATTERN = "[0-9]{4}-([0-9]{2}|[0-9])-([0-9]{2}|[0-9])"; 50 private static final String DATE_PATTERN = "[0-9]{4}-([0-9]{2}|[0-9])-([0-9]{2}|[0-9])";
39 private static final String NON_NEGATIVE_INTEGER_PATTERN = "[0-9]+"; 51 private static final String NON_NEGATIVE_INTEGER_PATTERN = "[0-9]+";
40 - private static final String PLUS = "+"; 52 + private static final Pattern INTEGER_PATTERN = Pattern.compile("[-][0-9]+|[0-9]+");
41 private static final String ONE = "1"; 53 private static final String ONE = "1";
42 - private static final String TRUE_KEYWORD = "true";
43 - private static final String FALSE_KEYWORD = "false";
44 private static final int IDENTIFIER_LENGTH = 64; 54 private static final int IDENTIFIER_LENGTH = 64;
45 private static final String DATE_FORMAT = "yyyy-MM-dd"; 55 private static final String DATE_FORMAT = "yyyy-MM-dd";
46 - private static final String EMPTY_STRING = "";
47 - private static final String HYPHEN = "-";
48 - private static final String SLASH = "/";
49 - private static final String SPACE = " ";
50 - private static final String COLON = ":";
51 - private static final String CARET = "^";
52 56
53 /** 57 /**
54 * Creates a new listener util. 58 * Creates a new listener util.
...@@ -65,7 +69,7 @@ public final class ListenerUtil { ...@@ -65,7 +69,7 @@ public final class ListenerUtil {
65 public static String removeQuotesAndHandleConcat(String yangStringData) { 69 public static String removeQuotesAndHandleConcat(String yangStringData) {
66 70
67 yangStringData = yangStringData.replace("\"", EMPTY_STRING); 71 yangStringData = yangStringData.replace("\"", EMPTY_STRING);
68 - String[] tmpData = yangStringData.split(Pattern.quote(PLUS)); 72 + String[] tmpData = yangStringData.split(Pattern.quote(ADD));
69 StringBuilder builder = new StringBuilder(); 73 StringBuilder builder = new StringBuilder();
70 for (String yangString : tmpData) { 74 for (String yangString : tmpData) {
71 builder.append(yangString); 75 builder.append(yangString);
...@@ -171,6 +175,41 @@ public final class ListenerUtil { ...@@ -171,6 +175,41 @@ public final class ListenerUtil {
171 } 175 }
172 176
173 /** 177 /**
178 + * Validates integer value.
179 + *
180 + * @param integerValue integer to be validated
181 + * @param yangConstruct yang construct for creating error message
182 + * @param ctx context object of the grammar rule
183 + * @return valid integer value
184 + */
185 + public static int getValidIntegerValue(String integerValue, YangConstructType yangConstruct,
186 + ParserRuleContext ctx) {
187 +
188 + String value = removeQuotesAndHandleConcat(integerValue);
189 + if (!INTEGER_PATTERN.matcher(value).matches()) {
190 + ParserException parserException = new ParserException("YANG file error : " +
191 + YangConstructType.getYangConstructType(yangConstruct) + " value " + value + " is not " +
192 + "valid.");
193 + parserException.setLine(ctx.getStart().getLine());
194 + parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
195 + throw parserException;
196 + }
197 +
198 + int valueInInteger;
199 + try {
200 + valueInInteger = Integer.parseInt(value);
201 + } catch (NumberFormatException e) {
202 + ParserException parserException = new ParserException("YANG file error : " +
203 + YangConstructType.getYangConstructType(yangConstruct) + " value " + value + " is not " +
204 + "valid.");
205 + parserException.setLine(ctx.getStart().getLine());
206 + parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
207 + throw parserException;
208 + }
209 + return valueInInteger;
210 + }
211 +
212 + /**
174 * Validates boolean value. 213 * Validates boolean value.
175 * 214 *
176 * @param booleanValue value to be validated 215 * @param booleanValue value to be validated
...@@ -182,9 +221,9 @@ public final class ListenerUtil { ...@@ -182,9 +221,9 @@ public final class ListenerUtil {
182 ParserRuleContext ctx) { 221 ParserRuleContext ctx) {
183 222
184 String value = removeQuotesAndHandleConcat(booleanValue); 223 String value = removeQuotesAndHandleConcat(booleanValue);
185 - if (value.equals(TRUE_KEYWORD)) { 224 + if (value.equals(TRUE)) {
186 return true; 225 return true;
187 - } else if (value.equals(FALSE_KEYWORD)) { 226 + } else if (value.equals(FALSE)) {
188 return false; 227 return false;
189 } else { 228 } else {
190 ParserException parserException = new ParserException("YANG file error : " + 229 ParserException parserException = new ParserException("YANG file error : " +
...@@ -272,4 +311,21 @@ public final class ListenerUtil { ...@@ -272,4 +311,21 @@ public final class ListenerUtil {
272 } 311 }
273 return targetNodes; 312 return targetNodes;
274 } 313 }
314 +
315 + /**
316 + * Throws parser exception for unsupported YANG constructs.
317 + *
318 + * @param yangConstructType yang construct for creating error message
319 + * @param ctx yang construct's context to get the line number and character position
320 + * @param errorInfo error information
321 + */
322 + public static void handleUnsupportedYangConstruct(YangConstructType yangConstructType,
323 + ParserRuleContext ctx, String errorInfo) {
324 + ParserException parserException = new ParserException(YANG_FILE_ERROR
325 + + QUOTES + YangConstructType.getYangConstructType(yangConstructType) + QUOTES
326 + + errorInfo);
327 + parserException.setLine(ctx.getStart().getLine());
328 + parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
329 + throw parserException;
330 + }
275 } 331 }
...\ No newline at end of file ...\ No newline at end of file
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.plugin.manager;
18 +
19 +import org.onosproject.yangutils.datamodel.YangNode;
20 +
21 +/**
22 + * Represents YANG file information.
23 + */
24 +public class YangFileInfo {
25 +
26 + /**
27 + * YANG file name.
28 + */
29 + private String yangFileName;
30 +
31 + /**
32 + * Data model node after parsing YANG file.
33 + */
34 + private YangNode rootNode;
35 +
36 + /**
37 + * Returns data model node for YANG file.
38 + *
39 + * @return data model node for YANG file
40 + */
41 + public YangNode getRootNode() {
42 + return rootNode;
43 + }
44 +
45 + /**
46 + * Sets data model node for YANG file.
47 + *
48 + * @param rootNode of the Yang file
49 + */
50 + public void setRootNode(YangNode rootNode) {
51 + this.rootNode = rootNode;
52 + }
53 +
54 + /**
55 + * Returns YANG file name.
56 + *
57 + * @return yangFileName YANG file name
58 + */
59 + public String getYangFileName() {
60 + return yangFileName;
61 + }
62 +
63 + /**
64 + * Sets YANG file name.
65 + *
66 + * @param yangFileName YANG file name
67 + */
68 + public void setYangFileName(String yangFileName) {
69 + this.yangFileName = yangFileName;
70 + }
71 +}
...@@ -28,6 +28,8 @@ import org.apache.maven.plugins.annotations.Mojo; ...@@ -28,6 +28,8 @@ import org.apache.maven.plugins.annotations.Mojo;
28 import org.apache.maven.plugins.annotations.Parameter; 28 import org.apache.maven.plugins.annotations.Parameter;
29 import org.apache.maven.project.MavenProject; 29 import org.apache.maven.project.MavenProject;
30 import org.onosproject.yangutils.datamodel.YangNode; 30 import org.onosproject.yangutils.datamodel.YangNode;
31 +import org.onosproject.yangutils.datamodel.YangSubModule;
32 +import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
31 import org.onosproject.yangutils.parser.YangUtilsParser; 33 import org.onosproject.yangutils.parser.YangUtilsParser;
32 import org.onosproject.yangutils.parser.exceptions.ParserException; 34 import org.onosproject.yangutils.parser.exceptions.ParserException;
33 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 35 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
...@@ -49,6 +51,7 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addToSource; ...@@ -49,6 +51,7 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addToSource;
49 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; 51 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
50 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.copyYangFilesToTarget; 52 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.copyYangFilesToTarget;
51 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getDirectory; 53 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getDirectory;
54 +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.findBelongsToModuleNode;
52 55
53 /** 56 /**
54 * Represents ONOS YANG utility maven plugin. 57 * Represents ONOS YANG utility maven plugin.
...@@ -137,17 +140,22 @@ public class YangUtilManager extends AbstractMojo { ...@@ -137,17 +140,22 @@ public class YangUtilManager extends AbstractMojo {
137 conflictResolver.setReplacementForPeriod(replacementForPeriod); 140 conflictResolver.setReplacementForPeriod(replacementForPeriod);
138 conflictResolver.setReplacementForHyphen(replacementForHyphen); 141 conflictResolver.setReplacementForHyphen(replacementForHyphen);
139 conflictResolver.setReplacementForUnderscore(replacementForUnderscore); 142 conflictResolver.setReplacementForUnderscore(replacementForUnderscore);
140 - List<String> yangFiles = YangFileScanner.getYangFiles(searchDir); 143 + List<YangFileInfo> yangFileInfo = YangFileScanner.getYangFiles(searchDir);
144 + if (yangFileInfo == null || yangFileInfo.isEmpty()) {
145 + // no files to translate
146 + return;
147 + }
141 YangPluginConfig yangPlugin = new YangPluginConfig(); 148 YangPluginConfig yangPlugin = new YangPluginConfig();
142 yangPlugin.setCodeGenDir(codeGenDir); 149 yangPlugin.setCodeGenDir(codeGenDir);
143 yangPlugin.setConflictResolver(conflictResolver); 150 yangPlugin.setConflictResolver(conflictResolver);
144 - Iterator<String> yangFileIterator = yangFiles.iterator(); 151 +
152 + Iterator<YangFileInfo> yangFileIterator = yangFileInfo.iterator();
145 while (yangFileIterator.hasNext()) { 153 while (yangFileIterator.hasNext()) {
146 - String yangFile = yangFileIterator.next(); 154 + YangFileInfo yangFile = yangFileIterator.next();
147 try { 155 try {
148 - YangNode yangNode = yangUtilsParser.getDataModel(yangFile); 156 + YangNode yangNode = yangUtilsParser.getDataModel(yangFile.getYangFileName());
157 + yangFile.setRootNode(yangNode);
149 setRootNode(yangNode); 158 setRootNode(yangNode);
150 - generateJavaCode(yangNode, yangPlugin, yangFile);
151 } catch (ParserException e) { 159 } catch (ParserException e) {
152 String logInfo = "Error in file: " + e.getFileName(); 160 String logInfo = "Error in file: " + e.getFileName();
153 if (e.getLineNumber() != 0) { 161 if (e.getLineNumber() != 0) {
...@@ -163,8 +171,12 @@ public class YangUtilManager extends AbstractMojo { ...@@ -163,8 +171,12 @@ public class YangUtilManager extends AbstractMojo {
163 } 171 }
164 } 172 }
165 173
174 + resolveLinkingForSubModule(yangFileInfo);
175 +
176 + translateToJava(yangFileInfo, yangPlugin);
177 +
166 addToSource(getDirectory(baseDir, genFilesDir) + DEFAULT_PKG, project, context); 178 addToSource(getDirectory(baseDir, genFilesDir) + DEFAULT_PKG, project, context);
167 - copyYangFilesToTarget(yangFiles, getDirectory(baseDir, outputDirectory), project); 179 + copyYangFilesToTarget(yangFileInfo, getDirectory(baseDir, outputDirectory), project);
168 } catch (Exception e) { 180 } catch (Exception e) {
169 String fileName = ""; 181 String fileName = "";
170 if (e instanceof TranslatorException) { 182 if (e instanceof TranslatorException) {
...@@ -220,4 +232,40 @@ public class YangUtilManager extends AbstractMojo { ...@@ -220,4 +232,40 @@ public class YangUtilManager extends AbstractMojo {
220 this.rootNode = rootNode; 232 this.rootNode = rootNode;
221 } 233 }
222 234
235 + /**
236 + * Translates to java code corresponding to the YANG schema.
237 + *
238 + * @param yangFileInfo YANG file information
239 + * @param yangPlugin YANG plugin config
240 + * @throws IOException when fails to generate java code file the current
241 + * node
242 + */
243 + public static void translateToJava(List<YangFileInfo> yangFileInfo, YangPluginConfig yangPlugin)
244 + throws IOException {
245 + Iterator<YangFileInfo> yangFileIterator = yangFileInfo.iterator();
246 + while (yangFileIterator.hasNext()) {
247 + YangFileInfo yangFile = yangFileIterator.next();
248 + generateJavaCode(yangFile.getRootNode(), yangPlugin, yangFile.getYangFileName());
249 + }
250 + }
251 +
252 + /**
253 + * Resolves sub-module linking.
254 + *
255 + * @param yangFileInfo YANG file information
256 + * @throws DataModelException when belongs-to module node is not found
257 + */
258 + public static void resolveLinkingForSubModule(List<YangFileInfo> yangFileInfo) throws DataModelException {
259 + Iterator<YangFileInfo> yangFileIterator = yangFileInfo.iterator();
260 + while (yangFileIterator.hasNext()) {
261 + YangFileInfo yangFile = yangFileIterator.next();
262 + YangNode yangNode = yangFile.getRootNode();
263 + if (yangNode instanceof YangSubModule) {
264 + String belongsToModuleName = ((YangSubModule) yangNode).getBelongsTo()
265 + .getBelongsToModuleName();
266 + YangNode moduleNode = findBelongsToModuleNode(yangFileInfo, belongsToModuleName);
267 + ((YangSubModule) yangNode).getBelongsTo().setModuleNode(moduleNode);
268 + }
269 + }
270 + }
223 } 271 }
......
...@@ -18,6 +18,7 @@ package org.onosproject.yangutils.translator.tojava.javamodel; ...@@ -18,6 +18,7 @@ package org.onosproject.yangutils.translator.tojava.javamodel;
18 import java.io.IOException; 18 import java.io.IOException;
19 19
20 import org.onosproject.yangutils.datamodel.YangBelongsTo; 20 import org.onosproject.yangutils.datamodel.YangBelongsTo;
21 +import org.onosproject.yangutils.datamodel.YangModule;
21 import org.onosproject.yangutils.datamodel.YangSubModule; 22 import org.onosproject.yangutils.datamodel.YangSubModule;
22 import org.onosproject.yangutils.translator.exception.TranslatorException; 23 import org.onosproject.yangutils.translator.exception.TranslatorException;
23 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; 24 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
...@@ -108,8 +109,7 @@ public class YangJavaSubModule ...@@ -108,8 +109,7 @@ public class YangJavaSubModule
108 * @return the name space string of the module. 109 * @return the name space string of the module.
109 */ 110 */
110 private String getNameSpaceFromModule(YangBelongsTo belongsToInfo) { 111 private String getNameSpaceFromModule(YangBelongsTo belongsToInfo) {
111 - // TODO Auto-generated method stub 112 + return ((YangModule) belongsToInfo.getModuleNode()).getNameSpace().getUri();
112 - return "";
113 } 113 }
114 114
115 /** 115 /**
......
...@@ -257,6 +257,16 @@ public final class UtilConstants { ...@@ -257,6 +257,16 @@ public final class UtilConstants {
257 public static final String LISTENER_PKG = "org.onosproject.event"; 257 public static final String LISTENER_PKG = "org.onosproject.event";
258 258
259 /** 259 /**
260 + * Static attribute for colon.
261 + */
262 + public static final String COLON = ":";
263 +
264 + /**
265 + * Static attribute for caret.
266 + */
267 + public static final String CARET = "^";
268 +
269 + /**
260 * Static attribute for input string. 270 * Static attribute for input string.
261 */ 271 */
262 public static final String INPUT = "input"; 272 public static final String INPUT = "input";
...@@ -932,6 +942,22 @@ public final class UtilConstants { ...@@ -932,6 +942,22 @@ public final class UtilConstants {
932 public static final String YANG_UTILS_TODO = "//TODO: YANG utils generated code"; 942 public static final String YANG_UTILS_TODO = "//TODO: YANG utils generated code";
933 943
934 /** 944 /**
945 + * Static attribute for YANG file error.
946 + */
947 + public static final String YANG_FILE_ERROR = "YANG file error : ";
948 +
949 + /**
950 + * Static attribute for unsupported error information.
951 + */
952 + public static final String UNSUPPORTED_YANG_CONSTRUCT = " is not supported.";
953 +
954 + /**
955 + * Static attribute for currently unsupported error information.
956 + */
957 + public static final String CURRENTLY_UNSUPPORTED = " is not supported in current version, please check wiki" +
958 + " for YANG utils road map.";
959 +
960 + /**
935 * Creates an instance of util constants. 961 * Creates an instance of util constants.
936 */ 962 */
937 private UtilConstants() { 963 private UtilConstants() {
......
...@@ -287,7 +287,77 @@ public enum YangConstructType { ...@@ -287,7 +287,77 @@ public enum YangConstructType {
287 /** 287 /**
288 * Identifies the YANG pattern element parsed data. 288 * Identifies the YANG pattern element parsed data.
289 */ 289 */
290 - PATTERN_DATA; 290 + PATTERN_DATA,
291 +
292 + /**
293 + * Identifies the YANG extension element parsed data.
294 + */
295 + EXTENSION_DATA,
296 +
297 + /**
298 + * Identifies the YANG identity element parsed data.
299 + */
300 + IDENTITY_DATA,
301 +
302 + /**
303 + * Identifies the YANG base element parsed data.
304 + */
305 + BASE_DATA,
306 +
307 + /**
308 + * Identifies the YANG feature element parsed data.
309 + */
310 + FEATURE_DATA,
311 +
312 + /**
313 + * Identifies the YANG if-feature element parsed data.
314 + */
315 + IF_FEATURE_DATA,
316 +
317 + /**
318 + * Identifies the YANG path element parsed data.
319 + */
320 + PATH_DATA,
321 +
322 + /**
323 + * Identifies the YANG require-instance element parsed data.
324 + */
325 + REQUIRE_INSTANCE_DATA,
326 +
327 + /**
328 + * Identifies the YANG ordered-by element parsed data.
329 + */
330 + ORDERED_BY_DATA,
331 +
332 + /**
333 + * Identifies the YANG error-message element parsed data.
334 + */
335 + ERROR_MESSAGE_DATA,
336 +
337 + /**
338 + * Identifies the YANG error-app-tag element parsed data.
339 + */
340 + ERROR_APP_TAG_DATA,
341 +
342 + /**
343 + * Identifies the YANG unique element parsed data.
344 + */
345 + UNIQUE_DATA,
346 +
347 + /**
348 + * Identifies the YANG refine element parsed data.
349 + */
350 + REFINE_DATA,
351 +
352 + /**
353 + * Identifies the YANG deviation element parsed data.
354 + */
355 + DEVIATION_DATA,
356 +
357 + /**
358 + * Identifies the YANG anyxml element parsed data.
359 + */
360 + ANYXML_DATA;
291 361
292 /** 362 /**
293 * Returns the YANG construct keyword corresponding to enum values. 363 * Returns the YANG construct keyword corresponding to enum values.
...@@ -406,6 +476,34 @@ public enum YangConstructType { ...@@ -406,6 +476,34 @@ public enum YangConstructType {
406 return "length"; 476 return "length";
407 case PATTERN_DATA: 477 case PATTERN_DATA:
408 return "pattern"; 478 return "pattern";
479 + case EXTENSION_DATA:
480 + return "extension";
481 + case IDENTITY_DATA:
482 + return "identity";
483 + case BASE_DATA:
484 + return "base";
485 + case FEATURE_DATA:
486 + return "feature";
487 + case IF_FEATURE_DATA:
488 + return "if-feature";
489 + case PATH_DATA:
490 + return "path";
491 + case REQUIRE_INSTANCE_DATA:
492 + return "require-instance";
493 + case ORDERED_BY_DATA:
494 + return "ordered-by";
495 + case ERROR_MESSAGE_DATA:
496 + return "error-message";
497 + case ERROR_APP_TAG_DATA:
498 + return "error-app-tag";
499 + case UNIQUE_DATA:
500 + return "unique";
501 + case REFINE_DATA:
502 + return "refine";
503 + case DEVIATION_DATA:
504 + return "deviation";
505 + case ANYXML_DATA:
506 + return "anyxml";
409 default: 507 default:
410 return "yang"; 508 return "yang";
411 } 509 }
......
...@@ -21,6 +21,7 @@ import java.io.IOException; ...@@ -21,6 +21,7 @@ import java.io.IOException;
21 import java.util.LinkedList; 21 import java.util.LinkedList;
22 import java.util.List; 22 import java.util.List;
23 import java.util.Stack; 23 import java.util.Stack;
24 +import org.onosproject.yangutils.plugin.manager.YangFileInfo;
24 25
25 /** 26 /**
26 * Represents utility for searching the files in a directory. 27 * Represents utility for searching the files in a directory.
...@@ -51,17 +52,23 @@ public final class YangFileScanner { ...@@ -51,17 +52,23 @@ public final class YangFileScanner {
51 } 52 }
52 53
53 /** 54 /**
54 - * Returns the list of YANG files. 55 + * Returns the list of YANG file information.
55 * 56 *
56 * @param root specified directory 57 * @param root specified directory
57 - * @return list of YANG files 58 + * @return list of YANG file information
58 * @throws NullPointerException when no files are there 59 * @throws NullPointerException when no files are there
59 * @throws IOException when files get deleted while performing the 60 * @throws IOException when files get deleted while performing the
60 * operations 61 * operations
61 */ 62 */
62 - public static List<String> getYangFiles(String root) throws IOException { 63 + public static List<YangFileInfo> getYangFiles(String root) throws IOException {
63 - 64 + List<String> yangFiles = getFiles(root, YANG_FILE_EXTENTION);
64 - return getFiles(root, YANG_FILE_EXTENTION); 65 + List<YangFileInfo> fileInfo = new LinkedList<>();
66 + for (String yangFile : yangFiles) {
67 + YangFileInfo yangFileInfo = new YangFileInfo();
68 + yangFileInfo.setYangFileName(yangFile);
69 + fileInfo.add(yangFileInfo);
70 + }
71 + return fileInfo;
65 } 72 }
66 73
67 /** 74 /**
......
...@@ -24,6 +24,7 @@ import java.nio.file.Files; ...@@ -24,6 +24,7 @@ import java.nio.file.Files;
24 import java.nio.file.StandardCopyOption; 24 import java.nio.file.StandardCopyOption;
25 import java.util.ArrayList; 25 import java.util.ArrayList;
26 import java.util.LinkedList; 26 import java.util.LinkedList;
27 +import java.util.Iterator;
27 import java.util.List; 28 import java.util.List;
28 import java.util.Stack; 29 import java.util.Stack;
29 30
...@@ -33,6 +34,7 @@ import org.apache.maven.project.MavenProject; ...@@ -33,6 +34,7 @@ import org.apache.maven.project.MavenProject;
33 import org.slf4j.Logger; 34 import org.slf4j.Logger;
34 import org.sonatype.plexus.build.incremental.BuildContext; 35 import org.sonatype.plexus.build.incremental.BuildContext;
35 36
37 +import org.onosproject.yangutils.plugin.manager.YangFileInfo;
36 import static org.onosproject.yangutils.utils.UtilConstants.COMMA; 38 import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
37 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 39 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
38 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 40 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
...@@ -245,15 +247,15 @@ public final class YangIoUtils { ...@@ -245,15 +247,15 @@ public final class YangIoUtils {
245 /** 247 /**
246 * Copies YANG files to the current project's output directory. 248 * Copies YANG files to the current project's output directory.
247 * 249 *
248 - * @param yangFiles list of YANG files 250 + * @param yangFileInfo list of YANG files
249 * @param outputDir project's output directory 251 * @param outputDir project's output directory
250 * @param project maven project 252 * @param project maven project
251 * @throws IOException when fails to copy files to destination resource directory 253 * @throws IOException when fails to copy files to destination resource directory
252 */ 254 */
253 - public static void copyYangFilesToTarget(List<String> yangFiles, String outputDir, MavenProject project) 255 + public static void copyYangFilesToTarget(List<YangFileInfo> yangFileInfo, String outputDir, MavenProject project)
254 throws IOException { 256 throws IOException {
255 257
256 - List<File> files = getListOfFile(yangFiles); 258 + List<File> files = getListOfFile(yangFileInfo);
257 259
258 String path = outputDir + TARGET_RESOURCE_PATH; 260 String path = outputDir + TARGET_RESOURCE_PATH;
259 File targetDir = new File(path); 261 File targetDir = new File(path);
...@@ -272,13 +274,15 @@ public final class YangIoUtils { ...@@ -272,13 +274,15 @@ public final class YangIoUtils {
272 /** 274 /**
273 * Provides a list of files from list of strings. 275 * Provides a list of files from list of strings.
274 * 276 *
275 - * @param strings list of strings 277 + * @param yangFileInfo list of yang file information
276 * @return list of files 278 * @return list of files
277 */ 279 */
278 - private static List<File> getListOfFile(List<String> strings) { 280 + private static List<File> getListOfFile(List<YangFileInfo> yangFileInfo) {
279 List<File> files = new ArrayList<>(); 281 List<File> files = new ArrayList<>();
280 - for (String file : strings) { 282 + Iterator<YangFileInfo> yangFileIterator = yangFileInfo.iterator();
281 - files.add(new File(file)); 283 + while (yangFileIterator.hasNext()) {
284 + YangFileInfo yangFile = yangFileIterator.next();
285 + files.add(new File(yangFile.getYangFileName()));
282 } 286 }
283 return files; 287 return files;
284 } 288 }
......
...@@ -380,6 +380,7 @@ package org.onosproject.yangutils.parser.antlrgencode; ...@@ -380,6 +380,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
380 | leafListStatement 380 | leafListStatement
381 | listStatement 381 | listStatement
382 | choiceStatement 382 | choiceStatement
383 + | anyxmlStatement
383 | usesStatement; 384 | usesStatement;
384 385
385 /** 386 /**
...@@ -429,13 +430,26 @@ package org.onosproject.yangutils.parser.antlrgencode; ...@@ -429,13 +430,26 @@ package org.onosproject.yangutils.parser.antlrgencode;
429 * instance-identifier-specification / 430 * instance-identifier-specification /
430 * bits-specification / 431 * bits-specification /
431 * union-specification 432 * union-specification
432 - * TODO : decimal64-specification to be added 433 + *
433 */ 434 */
434 - typeBodyStatements : numericalRestrictions | stringRestrictions | enumSpecification 435 + typeBodyStatements : numericalRestrictions | decimal64Specification | stringRestrictions | enumSpecification
435 | leafrefSpecification | identityrefSpecification | instanceIdentifierSpecification 436 | leafrefSpecification | identityrefSpecification | instanceIdentifierSpecification
436 | bitsSpecification | unionSpecification; 437 | bitsSpecification | unionSpecification;
437 438
438 /** 439 /**
440 + * fraction-digits-stmt = fraction-digits-keyword sep
441 + * fraction-digits-arg-str stmtend
442 + *
443 + * fraction-digits-arg-str = < a string that matches the rule
444 + * fraction-digits-arg >
445 + *
446 + * fraction-digits-arg = ("1" ["0" / "1" / "2" / "3" / "4" /
447 + * "5" / "6" / "7" / "8"])
448 + * / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9"
449 + */
450 + decimal64Specification : FRACTION_DIGITS_KEYWORD fraction STMTEND;
451 +
452 + /**
439 * numerical-restrictions = range-stmt stmtsep 453 * numerical-restrictions = range-stmt stmtsep
440 */ 454 */
441 numericalRestrictions : rangeStatement; 455 numericalRestrictions : rangeStatement;
...@@ -746,7 +760,7 @@ package org.onosproject.yangutils.parser.antlrgencode; ...@@ -746,7 +760,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
746 /** 760 /**
747 * value-stmt = value-keyword sep integer-value stmtend 761 * value-stmt = value-keyword sep integer-value stmtend
748 */ 762 */
749 - valueStatement : VALUE_KEYWORD ((MINUS INTEGER) | INTEGER) STMTEND; 763 + valueStatement : VALUE_KEYWORD value STMTEND;
750 764
751 /** 765 /**
752 * grouping-stmt = grouping-keyword sep identifier-arg-str optsep 766 * grouping-stmt = grouping-keyword sep identifier-arg-str optsep
...@@ -899,7 +913,7 @@ package org.onosproject.yangutils.parser.antlrgencode; ...@@ -899,7 +913,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
899 * list-stmt / 913 * list-stmt /
900 * anyxml-stmt 914 * anyxml-stmt
901 */ 915 */
902 - shortCaseStatement : containerStatement | leafStatement | leafListStatement | listStatement; 916 + shortCaseStatement : containerStatement | leafStatement | leafListStatement | listStatement | anyxmlStatement;
903 917
904 /** 918 /**
905 * case-stmt = case-keyword sep identifier-arg-str optsep 919 * case-stmt = case-keyword sep identifier-arg-str optsep
...@@ -919,6 +933,25 @@ package org.onosproject.yangutils.parser.antlrgencode; ...@@ -919,6 +933,25 @@ package org.onosproject.yangutils.parser.antlrgencode;
919 | descriptionStatement | referenceStatement | dataDefStatement)* RIGHT_CURLY_BRACE); 933 | descriptionStatement | referenceStatement | dataDefStatement)* RIGHT_CURLY_BRACE);
920 934
921 /** 935 /**
936 + * anyxml-stmt = anyxml-keyword sep identifier-arg-str optsep
937 + * (";" /
938 + * "{" stmtsep
939 + * ;; these stmts can appear in any order
940 + * [when-stmt stmtsep]
941 + * *(if-feature-stmt stmtsep)
942 + * *(must-stmt stmtsep)
943 + * [config-stmt stmtsep]
944 + * [mandatory-stmt stmtsep]
945 + * [status-stmt stmtsep]
946 + * [description-stmt stmtsep]
947 + * [reference-stmt stmtsep]
948 + * "}")
949 + */
950 + anyxmlStatement : ANYXML_KEYWORD identifier (STMTEND | LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement
951 + | mustStatement | configStatement | mandatoryStatement | statusStatement | descriptionStatement
952 + | referenceStatement)* RIGHT_CURLY_BRACE);
953 +
954 + /**
922 * uses-stmt = uses-keyword sep identifier-ref-arg-str optsep 955 * uses-stmt = uses-keyword sep identifier-ref-arg-str optsep
923 * (";" / 956 * (";" /
924 * "{" stmtsep 957 * "{" stmtsep
...@@ -934,7 +967,7 @@ package org.onosproject.yangutils.parser.antlrgencode; ...@@ -934,7 +967,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
934 * TODO : 0..1 occurance to be checked in listener 967 * TODO : 0..1 occurance to be checked in listener
935 */ 968 */
936 usesStatement : USES_KEYWORD string (STMTEND | LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | statusStatement 969 usesStatement : USES_KEYWORD string (STMTEND | LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | statusStatement
937 - | descriptionStatement | referenceStatement | refineStatement | usesAugmentStatement)* RIGHT_CURLY_BRACE); 970 + | descriptionStatement | referenceStatement | refineStatement | augmentStatement)* RIGHT_CURLY_BRACE);
938 971
939 /** 972 /**
940 * refine-stmt = refine-keyword sep refine-arg-str optsep 973 * refine-stmt = refine-keyword sep refine-arg-str optsep
...@@ -951,7 +984,7 @@ package org.onosproject.yangutils.parser.antlrgencode; ...@@ -951,7 +984,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
951 */ 984 */
952 refineStatement : REFINE_KEYWORD refine (STMTEND | LEFT_CURLY_BRACE (refineContainerStatements 985 refineStatement : REFINE_KEYWORD refine (STMTEND | LEFT_CURLY_BRACE (refineContainerStatements
953 | refineLeafStatements | refineLeafListStatements | refineListStatements | refineChoiceStatements 986 | refineLeafStatements | refineLeafListStatements | refineListStatements | refineChoiceStatements
954 - | refineCaseStatements) RIGHT_CURLY_BRACE); 987 + | refineCaseStatements | refineAnyxmlStatements) RIGHT_CURLY_BRACE);
955 988
956 /** 989 /**
957 * refine-container-stmts = 990 * refine-container-stmts =
...@@ -1024,22 +1057,15 @@ package org.onosproject.yangutils.parser.antlrgencode; ...@@ -1024,22 +1057,15 @@ package org.onosproject.yangutils.parser.antlrgencode;
1024 refineCaseStatements : (descriptionStatement | referenceStatement)? | (referenceStatement | descriptionStatement)?; 1057 refineCaseStatements : (descriptionStatement | referenceStatement)? | (referenceStatement | descriptionStatement)?;
1025 1058
1026 /** 1059 /**
1027 - * uses-augment-stmt = augment-keyword sep uses-augment-arg-str optsep 1060 + * refine-anyxml-stmts = ;; these stmts can appear in any order
1028 - * "{" stmtsep 1061 + * *(must-stmt stmtsep)
1029 - * ;; these stmts can appear in any order 1062 + * [config-stmt stmtsep]
1030 - * [when-stmt stmtsep] 1063 + * [mandatory-stmt stmtsep]
1031 - * *(if-feature-stmt stmtsep)
1032 - * [status-stmt stmtsep]
1033 * [description-stmt stmtsep] 1064 * [description-stmt stmtsep]
1034 * [reference-stmt stmtsep] 1065 * [reference-stmt stmtsep]
1035 - * 1*((data-def-stmt stmtsep) /
1036 - * (case-stmt stmtsep))
1037 - * "}"
1038 - * TODO : 0..1 occurance to be checked in listener
1039 */ 1066 */
1040 - usesAugmentStatement : AUGMENT_KEYWORD augment LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement 1067 + refineAnyxmlStatements : (mustStatement | configStatement | mandatoryStatement | descriptionStatement
1041 - | statusStatement | descriptionStatement | referenceStatement | dataDefStatement 1068 + | referenceStatement)*;
1042 - | caseStatement)* RIGHT_CURLY_BRACE;
1043 1069
1044 /** 1070 /**
1045 * augment-stmt = augment-keyword sep augment-arg-str optsep 1071 * augment-stmt = augment-keyword sep augment-arg-str optsep
...@@ -1251,6 +1277,10 @@ package org.onosproject.yangutils.parser.antlrgencode; ...@@ -1251,6 +1277,10 @@ package org.onosproject.yangutils.parser.antlrgencode;
1251 1277
1252 deviation : string; 1278 deviation : string;
1253 1279
1280 + value : string;
1281 +
1282 + fraction : string;
1283 +
1254 yangConstruct : ANYXML_KEYWORD | ARGUMENT_KEYWORD | AUGMENT_KEYWORD | BASE_KEYWORD | BELONGS_TO_KEYWORD 1284 yangConstruct : ANYXML_KEYWORD | ARGUMENT_KEYWORD | AUGMENT_KEYWORD | BASE_KEYWORD | BELONGS_TO_KEYWORD
1255 | BIT_KEYWORD | CASE_KEYWORD | CHOICE_KEYWORD | CONFIG_KEYWORD | CONTACT_KEYWORD | CONTAINER_KEYWORD 1285 | BIT_KEYWORD | CASE_KEYWORD | CHOICE_KEYWORD | CONFIG_KEYWORD | CONTACT_KEYWORD | CONTAINER_KEYWORD
1256 | DEFAULT_KEYWORD | DESCRIPTION_KEYWORD | ENUM_KEYWORD ERROR_APP_TAG_KEYWORD | ERROR_MESSAGE_KEYWORD 1286 | DEFAULT_KEYWORD | DESCRIPTION_KEYWORD | ENUM_KEYWORD ERROR_APP_TAG_KEYWORD | ERROR_MESSAGE_KEYWORD
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl;
18 +
19 +import java.io.IOException;
20 +
21 +import org.junit.Rule;
22 +import org.junit.Test;
23 +import org.junit.rules.ExpectedException;
24 +import org.onosproject.yangutils.parser.exceptions.ParserException;
25 +
26 +/**
27 + * Test cases for testing tree walk listener functionality.
28 + */
29 +public class TreeWalkListenerTest {
30 +
31 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
32 +
33 + @Rule
34 + public ExpectedException thrown = ExpectedException.none();
35 + /**
36 + * Checks whether exception is thrown for ordered statement.
37 + */
38 + @Test
39 + public void processOrderedByStatement() throws IOException, ParserException {
40 + thrown.expect(ParserException.class);
41 + thrown.expectMessage("YANG file error : \"ordered-by\" is not supported in current version, please check wiki" +
42 + " for YANG utils road map.");
43 + manager.getDataModel("src/test/resources/OrderedByStatement.yang");
44 + }
45 +
46 + /**
47 + * Checks whether exception is thrown for anyxml statement.
48 + */
49 + @Test
50 + public void processAnyXmlStatement() throws IOException, ParserException {
51 + thrown.expect(ParserException.class);
52 + thrown.expectMessage("YANG file error : \"anyxml\" is not supported.");
53 + manager.getDataModel("src/test/resources/AnyxmlStatement.yang");
54 + }
55 +}
...@@ -134,9 +134,9 @@ public class ConfigListenerTest { ...@@ -134,9 +134,9 @@ public class ConfigListenerTest {
134 @Test 134 @Test
135 public void processModuleSubStatementConfig() throws IOException, ParserException { 135 public void processModuleSubStatementConfig() throws IOException, ParserException {
136 thrown.expect(ParserException.class); 136 thrown.expect(ParserException.class);
137 - thrown.expectMessage("mismatched input 'config' expecting {'augment', 'choice', 'contact', 'container'," 137 + thrown.expectMessage("mismatched input 'config' expecting {'anyxml', 'augment', 'choice', 'contact', "
138 - + " 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include', " 138 + + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import',"
139 - + "'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference'," 139 + + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference',"
140 + " 'revision', 'rpc', 'typedef', 'uses', '}'}"); 140 + " 'revision', 'rpc', 'typedef', 'uses', '}'}");
141 YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementConfig.yang"); 141 YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementConfig.yang");
142 } 142 }
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import java.io.IOException;
20 +import java.util.ListIterator;
21 +
22 +import org.junit.Test;
23 +import org.onosproject.yangutils.datamodel.YangNode;
24 +import org.onosproject.yangutils.datamodel.YangModule;
25 +import org.onosproject.yangutils.datamodel.YangLeaf;
26 +import org.onosproject.yangutils.datamodel.YangChoice;
27 +import org.onosproject.yangutils.datamodel.YangContainer;
28 +import org.onosproject.yangutils.datamodel.YangNodeType;
29 +import org.onosproject.yangutils.parser.exceptions.ParserException;
30 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
31 +
32 +import static org.hamcrest.core.Is.is;
33 +import static org.junit.Assert.assertThat;
34 +
35 +/**
36 + * Test cases for testing default listener functionality.
37 + */
38 +public class DefaultListenerTest {
39 +
40 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
41 +
42 + /**
43 + * Checks if default value is set correctly.
44 + */
45 + @Test
46 + public void processLeafSubStatementDefault() throws IOException, ParserException {
47 +
48 + YangNode node = manager.getDataModel("src/test/resources/LeafSubStatementDefault.yang");
49 + // Check whether the data model tree returned is of type module.
50 + assertThat((node instanceof YangModule), is(true));
51 +
52 + // Check whether the node type is set properly to module.
53 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
54 +
55 + // Check whether the module name is set correctly.
56 + YangModule yangNode = (YangModule) node;
57 + assertThat(yangNode.getName(), is("Test"));
58 +
59 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
60 + YangLeaf leafInfo = leafIterator.next();
61 +
62 + assertThat(leafInfo.getName(), is("invalid-interval"));
63 + assertThat(leafInfo.getDefaultValueInString(), is("\"1\""));
64 + }
65 +
66 + /**
67 + * Checks if default value is set correctly.
68 + */
69 + @Test
70 + public void processChoiceSubStatementDefault() throws IOException, ParserException {
71 +
72 + YangNode node = manager.getDataModel("src/test/resources/ChoiceSubStatementDefault.yang");
73 + // Check whether the data model tree returned is of type module.
74 + assertThat((node instanceof YangModule), is(true));
75 +
76 + // Check whether the node type is set properly to module.
77 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
78 +
79 + // Check whether the module name is set correctly.
80 + YangModule yangNode = (YangModule) node;
81 + assertThat(yangNode.getName(), is("Test"));
82 +
83 + YangContainer yangContainer = (YangContainer) yangNode.getChild();
84 + assertThat(yangContainer.getName(), is("food"));
85 +
86 + YangChoice yangChoice = (YangChoice) yangContainer.getChild();
87 + assertThat(yangChoice.getName(), is("snack"));
88 + assertThat(yangChoice.getDefaultValueInString(), is("\"hello\""));
89 + }
90 +}
...@@ -18,7 +18,10 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -18,7 +18,10 @@ package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 import static org.hamcrest.MatcherAssert.assertThat; 19 import static org.hamcrest.MatcherAssert.assertThat;
20 import static org.hamcrest.core.Is.is; 20 import static org.hamcrest.core.Is.is;
21 +
22 +import org.junit.Rule;
21 import org.junit.Test; 23 import org.junit.Test;
24 +import org.junit.rules.ExpectedException;
22 import org.onosproject.yangutils.datamodel.YangDataTypes; 25 import org.onosproject.yangutils.datamodel.YangDataTypes;
23 import org.onosproject.yangutils.datamodel.YangEnum; 26 import org.onosproject.yangutils.datamodel.YangEnum;
24 import org.onosproject.yangutils.datamodel.YangEnumeration; 27 import org.onosproject.yangutils.datamodel.YangEnumeration;
...@@ -38,6 +41,9 @@ import java.util.Set; ...@@ -38,6 +41,9 @@ import java.util.Set;
38 */ 41 */
39 public class EnumListenerTest { 42 public class EnumListenerTest {
40 43
44 + @Rule
45 + public ExpectedException thrown = ExpectedException.none();
46 +
41 private final YangUtilsParserManager manager = new YangUtilsParserManager(); 47 private final YangUtilsParserManager manager = new YangUtilsParserManager();
42 48
43 /** 49 /**
...@@ -84,7 +90,28 @@ public class EnumListenerTest { ...@@ -84,7 +90,28 @@ public class EnumListenerTest {
84 */ 90 */
85 @Test(expected = ParserException.class) 91 @Test(expected = ParserException.class)
86 public void processEnumWithDuplicateName() throws IOException, ParserException { 92 public void processEnumWithDuplicateName() throws IOException, ParserException {
87 -
88 YangNode node = manager.getDataModel("src/test/resources/EnumWithDuplicateName.yang"); 93 YangNode node = manager.getDataModel("src/test/resources/EnumWithDuplicateName.yang");
89 } 94 }
95 +
96 + /**
97 + * Checks enum boundary value.
98 + */
99 + @Test
100 + public void processEnumBoundaryValue() throws IOException, ParserException {
101 + thrown.expect(ParserException.class);
102 + thrown.expectMessage("YANG file error : value value 21474836472147483647 is not valid.");
103 + YangNode node = manager.getDataModel("src/test/resources/EnumBoundaryValue.yang");
104 + }
105 +
106 + /**
107 + * Checks whether exception is thrown if value is not specified following max enum value.
108 + */
109 + @Test
110 + public void processEnumMaxNextValue() throws IOException, ParserException {
111 + thrown.expect(ParserException.class);
112 + thrown.expectMessage("YANG file error : "
113 + + "An enum value MUST be specified for enum substatements following the one"
114 + + "with the current highest value");
115 + YangNode node = manager.getDataModel("src/test/resources/EnumMaxNextValue.yang");
116 + }
90 } 117 }
......
...@@ -203,12 +203,32 @@ public class KeyListenerTest { ...@@ -203,12 +203,32 @@ public class KeyListenerTest {
203 } 203 }
204 204
205 /** 205 /**
206 + * Checks key values are set correctly.
207 + */
208 + @Test
209 + public void processKeyWithUsesInList() throws IOException, ParserException {
210 + YangNode node = manager.getDataModel("src/test/resources/KeyWithUsesInList.yang");
211 +
212 + assertThat((node instanceof YangModule), is(true));
213 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
214 + YangModule yangNode = (YangModule) node;
215 + assertThat(yangNode.getName(), is("Test"));
216 +
217 + // Check whether the list is child of module
218 + YangList yangList = (YangList) yangNode.getChild().getNextSibling();
219 + assertThat(yangList.getName(), is("valid"));
220 +
221 + ListIterator<String> keyList = yangList.getKeyList().listIterator();
222 + assertThat(keyList.next(), is("invalid-interval"));
223 + }
224 +
225 + /**
206 * Checks whether exception is thrown when key leaf identifier is not found in list. 226 * Checks whether exception is thrown when key leaf identifier is not found in list.
207 */ 227 */
208 @Test 228 @Test
209 public void processInvalidLeafIdentifier() throws IOException, ParserException { 229 public void processInvalidLeafIdentifier() throws IOException, ParserException {
210 thrown.expect(ParserException.class); 230 thrown.expect(ParserException.class);
211 - thrown.expectMessage("Leaf identifier must refer to a child leaf of the list"); 231 + thrown.expectMessage("An identifier, in key, must refer to a child leaf of the list");
212 YangNode node = manager.getDataModel("src/test/resources/InvalidLeafIdentifier.yang"); 232 YangNode node = manager.getDataModel("src/test/resources/InvalidLeafIdentifier.yang");
213 } 233 }
214 234
...@@ -218,7 +238,7 @@ public class KeyListenerTest { ...@@ -218,7 +238,7 @@ public class KeyListenerTest {
218 @Test 238 @Test
219 public void processInvalidLeafListIdentifier() throws IOException, ParserException { 239 public void processInvalidLeafListIdentifier() throws IOException, ParserException {
220 thrown.expect(ParserException.class); 240 thrown.expect(ParserException.class);
221 - thrown.expectMessage("Leaf-list identifier must refer to a child leaf of the list"); 241 + thrown.expectMessage("An identifier, in key, must refer to a child leaf of the list");
222 YangNode node = manager.getDataModel("src/test/resources/InvalidLeafListIdentifier.yang"); 242 YangNode node = manager.getDataModel("src/test/resources/InvalidLeafListIdentifier.yang");
223 } 243 }
224 244
......
...@@ -94,9 +94,9 @@ public class LeafListListenerTest { ...@@ -94,9 +94,9 @@ public class LeafListListenerTest {
94 @Test 94 @Test
95 public void processLeafListInvalidStatement() throws IOException, ParserException { 95 public void processLeafListInvalidStatement() throws IOException, ParserException {
96 thrown.expect(ParserException.class); 96 thrown.expect(ParserException.class);
97 - thrown.expectMessage("mismatched input 'leaflist' expecting {'augment', 'choice', 'contact', 'container'," 97 + thrown.expectMessage("mismatched input 'leaflist' expecting {'anyxml', 'augment', 'choice', 'contact', "
98 - + " 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include'," 98 + + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import',"
99 - + " 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference'," 99 + + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference',"
100 + " 'revision', 'rpc', 'typedef', 'uses', '}'}"); 100 + " 'revision', 'rpc', 'typedef', 'uses', '}'}");
101 YangNode node = manager.getDataModel("src/test/resources/LeafListInvalidStatement.yang"); 101 YangNode node = manager.getDataModel("src/test/resources/LeafListInvalidStatement.yang");
102 } 102 }
......
...@@ -95,9 +95,9 @@ public class LeafListenerTest { ...@@ -95,9 +95,9 @@ public class LeafListenerTest {
95 @Test 95 @Test
96 public void processLeafInvalidStatement() throws IOException, ParserException { 96 public void processLeafInvalidStatement() throws IOException, ParserException {
97 thrown.expect(ParserException.class); 97 thrown.expect(ParserException.class);
98 - thrown.expectMessage("mismatched input 'leafs' expecting {'augment', 'choice', 'contact', 'container'," 98 + thrown.expectMessage("mismatched input 'leafs' expecting {'anyxml', 'augment', 'choice', 'contact', "
99 - + " 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include'," 99 + + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import',"
100 - + " 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference'," 100 + + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference',"
101 + " 'revision', 'rpc', 'typedef', 'uses', '}'}"); 101 + " 'revision', 'rpc', 'typedef', 'uses', '}'}");
102 YangNode node = manager.getDataModel("src/test/resources/LeafInvalidStatement.yang"); 102 YangNode node = manager.getDataModel("src/test/resources/LeafInvalidStatement.yang");
103 } 103 }
......
...@@ -232,4 +232,39 @@ public class LengthRestrictionListenerTest { ...@@ -232,4 +232,39 @@ public class LengthRestrictionListenerTest {
232 " 18446744073709551615."); 232 " 18446744073709551615.");
233 YangNode node = manager.getDataModel("src/test/resources/LengthWithInvalidInterval.yang"); 233 YangNode node = manager.getDataModel("src/test/resources/LengthWithInvalidInterval.yang");
234 } 234 }
235 +
236 + /**
237 + * Checks valid length substatements.
238 + */
239 + @Test
240 + public void processLengthSubStatements() throws IOException, ParserException {
241 +
242 + YangNode node = manager.getDataModel("src/test/resources/LengthSubStatements.yang");
243 +
244 + assertThat((node instanceof YangModule), is(true));
245 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
246 + YangModule yangNode = (YangModule) node;
247 + assertThat(yangNode.getName(), is("Test"));
248 +
249 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
250 + YangLeaf leafInfo = leafIterator.next();
251 +
252 + assertThat(leafInfo.getName(), is("invalid-interval"));
253 + assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
254 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
255 + YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo
256 + .getDataType().getDataTypeExtendedInfo();
257 + YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
258 +
259 + assertThat(lengthRestriction.getDescription(), is("\"length description\""));
260 + assertThat(lengthRestriction.getReference(), is("\"length reference\""));
261 +
262 + ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
263 + .listIterator();
264 +
265 + YangRangeInterval rangeInterval = lengthListIterator.next();
266 +
267 + assertThat(((YangUint64) rangeInterval.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
268 + assertThat(((YangUint64) rangeInterval.getEndValue()).getValue(), is(BigInteger.valueOf(100)));
269 + }
235 } 270 }
......
...@@ -148,9 +148,9 @@ public class MandatoryListenerTest { ...@@ -148,9 +148,9 @@ public class MandatoryListenerTest {
148 @Test 148 @Test
149 public void processModuleSubStatementMandatory() throws IOException, ParserException { 149 public void processModuleSubStatementMandatory() throws IOException, ParserException {
150 thrown.expect(ParserException.class); 150 thrown.expect(ParserException.class);
151 - thrown.expectMessage("mismatched input 'mandatory' expecting {'augment', 'choice', 'contact', 'container'," 151 + thrown.expectMessage("mismatched input 'mandatory' expecting {'anyxml', 'augment', 'choice', 'contact',"
152 - + " 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include'," 152 + + " 'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import',"
153 - + " 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference'," 153 + + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference',"
154 + " 'revision', 'rpc', 'typedef', 'uses', '}'}"); 154 + " 'revision', 'rpc', 'typedef', 'uses', '}'}");
155 YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementMandatory.yang"); 155 YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementMandatory.yang");
156 } 156 }
......
...@@ -166,4 +166,32 @@ public class PatternRestrictionListenerTest { ...@@ -166,4 +166,32 @@ public class PatternRestrictionListenerTest {
166 .getPatternList().listIterator(); 166 .getPatternList().listIterator();
167 assertThat(patternListIterator.next(), is("-[0-9]+|[0-9]+")); 167 assertThat(patternListIterator.next(), is("-[0-9]+|[0-9]+"));
168 } 168 }
169 +
170 + /**
171 + * Checks valid pattern substatement.
172 + */
173 + @Test
174 + public void processPatternSubStatements() throws IOException, ParserException {
175 +
176 + YangNode node = manager.getDataModel("src/test/resources/PatternSubStatements.yang");
177 +
178 + assertThat((node instanceof YangModule), is(true));
179 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
180 + YangModule yangNode = (YangModule) node;
181 + assertThat(yangNode.getName(), is("Test"));
182 +
183 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
184 + YangLeaf leafInfo = leafIterator.next();
185 +
186 + assertThat(leafInfo.getName(), is("invalid-interval"));
187 + assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
188 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
189 + YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo
190 + .getDataType().getDataTypeExtendedInfo();
191 + assertThat(stringRestriction.getDescription(), is("\"pattern description\""));
192 + assertThat(stringRestriction.getReference(), is("\"pattern reference\""));
193 + ListIterator<String> patternListIterator = stringRestriction.getPatternRestriction()
194 + .getPatternList().listIterator();
195 + assertThat(patternListIterator.next(), is("[a-zA-Z]"));
196 + }
169 } 197 }
......
...@@ -174,4 +174,37 @@ public class RangeRestrictionListenerTest { ...@@ -174,4 +174,37 @@ public class RangeRestrictionListenerTest {
174 thrown.expectMessage("YANG file error : Input value \"a\" is not a valid int32."); 174 thrown.expectMessage("YANG file error : Input value \"a\" is not a valid int32.");
175 YangNode node = manager.getDataModel("src/test/resources/RangeWithInvalidIntegerPattern.yang"); 175 YangNode node = manager.getDataModel("src/test/resources/RangeWithInvalidIntegerPattern.yang");
176 } 176 }
177 +
178 + /**
179 + * Checks valid range statement with description.
180 + */
181 + @Test
182 + public void processRangeSubStatements() throws IOException, ParserException {
183 +
184 + YangNode node = manager.getDataModel("src/test/resources/RangeSubStatements.yang");
185 +
186 + assertThat((node instanceof YangModule), is(true));
187 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
188 + YangModule yangNode = (YangModule) node;
189 + assertThat(yangNode.getName(), is("Test"));
190 +
191 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
192 + YangLeaf leafInfo = leafIterator.next();
193 +
194 + assertThat(leafInfo.getName(), is("invalid-interval"));
195 + assertThat(leafInfo.getDataType().getDataTypeName(), is("int32"));
196 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
197 + YangRangeRestriction rangeRestriction = (YangRangeRestriction) leafInfo
198 + .getDataType().getDataTypeExtendedInfo();
199 +
200 + assertThat(rangeRestriction.getDescription(), is("\"range description\""));
201 + assertThat(rangeRestriction.getReference(), is("\"range reference\""));
202 +
203 + ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
204 + .listIterator();
205 + YangRangeInterval rangeInterval = rangeListIterator.next();
206 + assertThat(((YangInt32) rangeInterval.getStartValue()).getValue(), is(1));
207 + assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4));
208 + assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4));
209 + }
177 } 210 }
......
...@@ -150,9 +150,9 @@ public class StatusListenerTest { ...@@ -150,9 +150,9 @@ public class StatusListenerTest {
150 @Test 150 @Test
151 public void processModuleSubStatementStatus() throws IOException, ParserException { 151 public void processModuleSubStatementStatus() throws IOException, ParserException {
152 thrown.expect(ParserException.class); 152 thrown.expect(ParserException.class);
153 - thrown.expectMessage("mismatched input 'status' expecting {'augment', 'choice', 'contact', 'container', " 153 + thrown.expectMessage("mismatched input 'status' expecting {'anyxml', 'augment', 'choice', 'contact', "
154 - + "'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include'," 154 + + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import',"
155 - + " 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference', " 155 + + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference', "
156 + "'revision', 'rpc', 'typedef', 'uses', '}'}"); 156 + "'revision', 'rpc', 'typedef', 'uses', '}'}");
157 YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementStatus.yang"); 157 YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementStatus.yang");
158 } 158 }
......
...@@ -76,9 +76,9 @@ public class UnitsListenerTest { ...@@ -76,9 +76,9 @@ public class UnitsListenerTest {
76 @Test 76 @Test
77 public void processModuleSubStatementUnits() throws IOException, ParserException { 77 public void processModuleSubStatementUnits() throws IOException, ParserException {
78 thrown.expect(ParserException.class); 78 thrown.expect(ParserException.class);
79 - thrown.expectMessage("mismatched input 'type' expecting {'augment', 'choice', 'contact', 'container', " 79 + thrown.expectMessage("mismatched input 'type' expecting {'anyxml', 'augment', 'choice', 'contact', "
80 - + "'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', " 80 + + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity',"
81 - + "'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', " 81 + + " 'import', 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', "
82 + "'reference', 'revision', 'rpc', 'typedef', 'uses', '}'}"); 82 + "'reference', 'revision', 'rpc', 'typedef', 'uses', '}'}");
83 YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementUnits.yang"); 83 YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementUnits.yang");
84 } 84 }
......
...@@ -80,6 +80,84 @@ public class ValueListenerTest { ...@@ -80,6 +80,84 @@ public class ValueListenerTest {
80 } 80 }
81 81
82 /** 82 /**
83 + * Checks explicitly configured negative value.
84 + */
85 + @Test
86 + public void processValueStatementWithNegativeValue() throws IOException, ParserException {
87 +
88 + YangNode node = manager.getDataModel("src/test/resources/ValueStatementWithNegativeValue.yang");
89 +
90 + // Check whether the data model tree returned is of type module.
91 + assertThat((node instanceof YangModule), is(true));
92 +
93 + // Check whether the node type is set properly to module.
94 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
95 +
96 + // Check whether the module name is set correctly.
97 + YangModule yangNode = (YangModule) node;
98 + assertThat(yangNode.getName(), is("Test"));
99 +
100 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
101 + YangLeaf leafInfo = leafIterator.next();
102 +
103 + assertThat(leafInfo.getName(), is("speed"));
104 + assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration"));
105 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION));
106 + assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(),
107 + is("speed_enum"));
108 +
109 + Set<YangEnum> enumSet = ((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumSet();
110 + for (YangEnum tmp : enumSet) {
111 + if (tmp.getNamedValue().equals("10m")) {
112 + assertThat(tmp.getValue(), is(-2));
113 + } else if (tmp.getNamedValue().equals("100m")) {
114 + assertThat(tmp.getValue(), is(-1));
115 + } else if (tmp.getNamedValue().equals("auto")) {
116 + assertThat(tmp.getValue(), is(0));
117 + }
118 + }
119 + }
120 +
121 + /**
122 + * Checks explicitly configured value with double quotes.
123 + */
124 + @Test
125 + public void processValueStatementWithQuotes() throws IOException, ParserException {
126 +
127 + YangNode node = manager.getDataModel("src/test/resources/ValueStatementWithQuotes.yang");
128 +
129 + // Check whether the data model tree returned is of type module.
130 + assertThat((node instanceof YangModule), is(true));
131 +
132 + // Check whether the node type is set properly to module.
133 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
134 +
135 + // Check whether the module name is set correctly.
136 + YangModule yangNode = (YangModule) node;
137 + assertThat(yangNode.getName(), is("Test"));
138 +
139 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
140 + YangLeaf leafInfo = leafIterator.next();
141 +
142 + assertThat(leafInfo.getName(), is("speed"));
143 + assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration"));
144 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION));
145 + assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(),
146 + is("speed_enum"));
147 +
148 + Set<YangEnum> enumSet = ((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumSet();
149 + for (YangEnum tmp : enumSet) {
150 + if (tmp.getNamedValue().equals("10m")) {
151 + assertThat(tmp.getValue(), is(10));
152 + } else if (tmp.getNamedValue().equals("100m")) {
153 + assertThat(tmp.getValue(), is(100));
154 + } else if (tmp.getNamedValue().equals("auto")) {
155 + assertThat(tmp.getValue(), is(1000));
156 + }
157 + }
158 + }
159 +
160 + /**
83 * Checks explicit value and auto generated value. 161 * Checks explicit value and auto generated value.
84 */ 162 */
85 @Test 163 @Test
......
...@@ -26,6 +26,7 @@ import java.util.List; ...@@ -26,6 +26,7 @@ import java.util.List;
26 import org.junit.Rule; 26 import org.junit.Rule;
27 import org.junit.Test; 27 import org.junit.Test;
28 import org.junit.rules.ExpectedException; 28 import org.junit.rules.ExpectedException;
29 +import org.onosproject.yangutils.plugin.manager.YangFileInfo;
29 30
30 import static org.hamcrest.core.Is.is; 31 import static org.hamcrest.core.Is.is;
31 import static org.hamcrest.core.IsNot.not; 32 import static org.hamcrest.core.IsNot.not;
...@@ -135,7 +136,7 @@ public final class YangFileScannerTest { ...@@ -135,7 +136,7 @@ public final class YangFileScannerTest {
135 136
136 String emptyYangDir = baseDir + separator + "scanner1"; 137 String emptyYangDir = baseDir + separator + "scanner1";
137 File path = createDirectory(emptyYangDir); 138 File path = createDirectory(emptyYangDir);
138 - List<String> emptyDirContents = getYangFiles(path.toString()); 139 + List<YangFileInfo> emptyDirContents = getYangFiles(path.toString());
139 List<String> expectedContents = new LinkedList<>(); 140 List<String> expectedContents = new LinkedList<>();
140 assertThat(true, is(emptyDirContents.equals(expectedContents))); 141 assertThat(true, is(emptyDirContents.equals(expectedContents)));
141 } 142 }
......
1 +module event {
2 +
3 + namespace "http://example.com/event";
4 + prefix "ev";
5 +
6 + notification event {
7 + leaf event-class {
8 + type string;
9 + }
10 + anyxml reporting-entity;
11 + leaf severity {
12 + type string;
13 + }
14 + }
15 +}
16 +
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container food {
6 + choice snack {
7 + case sports-arena {
8 + leaf pretzel {
9 + type string;
10 + }
11 + leaf beer {
12 + type string;
13 + }
14 + }
15 + case late-night {
16 + leaf chocolate {
17 + type string;
18 + }
19 + }
20 + default "hello";
21 + }
22 + }
23 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf ifType {
6 + type enumeration {
7 + enum "unbounded";
8 + enum ZERO;
9 + enum two;
10 + enum four;
11 + enum seven {
12 + value 21474836472147483647;
13 + }
14 + }
15 + }
16 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf ifType {
6 + type enumeration {
7 + enum "unbounded";
8 + enum ZERO;
9 + enum two;
10 + enum four;
11 + enum seven {
12 + value 2147483647;
13 + }
14 + enum five;
15 +
16 + }
17 + }
18 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + grouping network {
6 + leaf invalid-interval {
7 + type "string";
8 + units "seconds";
9 + status current;
10 + reference "RFC 6020";
11 + }
12 + }
13 + list valid {
14 + key "invalid-interval";
15 + leaf invalid {
16 + type "string";
17 + units "seconds";
18 + status current;
19 + reference "RFC 6020";
20 + }
21 + uses "network";
22 + }
23 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + default "1";
9 + description "Interval before a route is declared invalid";
10 + config true;
11 + mandatory true;
12 + status current;
13 + reference "RFC 6020";
14 + }
15 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type string {
7 + length "0..100" {
8 + description "length description";
9 + reference "length reference";
10 + }
11 + }
12 + }
13 +}
1 +module rock {
2 + namespace "http://example.net/rock";
3 + prefix "rock";
4 + leaf-list cipher {
5 + type string;
6 + ordered-by user;
7 + description "A list of ciphers";
8 + }
9 +}
10 +
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type string {
7 + pattern "[a-zA-Z]" {
8 + description "pattern description";
9 + reference "pattern reference";
10 + }
11 + }
12 + }
13 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type int32 {
7 + range "1..4 | 10..20" {
8 + description "range description";
9 + reference "range reference";
10 + }
11 + }
12 + }
13 +}
14 +
...@@ -10,7 +10,6 @@ module Test { ...@@ -10,7 +10,6 @@ module Test {
10 prefix "P"; 10 prefix "P";
11 } 11 }
12 augment "/if:interfaces/if:ifEntry" { 12 augment "/if:interfaces/if:ifEntry" {
13 - when "if:ifType='ds0'";
14 leaf ds0ChannelNumber { 13 leaf ds0ChannelNumber {
15 type P:ChannelNumber; 14 type P:ChannelNumber;
16 } 15 }
......
...@@ -14,9 +14,7 @@ module rock { ...@@ -14,9 +14,7 @@ module rock {
14 type int32; 14 type int32;
15 } 15 }
16 leaf if-name { 16 leaf if-name {
17 - type leafref { 17 + type leafref;
18 - path "/interface/name";
19 - }
20 } 18 }
21 leaf if-admin-status { 19 leaf if-admin-status {
22 type P:admin-status; 20 type P:admin-status;
......
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf speed {
6 + type enumeration {
7 + enum 10m {
8 + value -2;
9 + }
10 + enum 100m {
11 + value "-1";
12 + }
13 + enum auto {
14 + value 0;
15 + }
16 + }
17 + }
18 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf speed {
6 + type enumeration {
7 + enum 10m {
8 + value "10";
9 + }
10 + enum 100m {
11 + value "100";
12 + }
13 + enum auto {
14 + value "1000";
15 + }
16 + }
17 + }
18 +}