[YANGTOOLS-537] Yang parsing succeeds with missing '}' in leaf Created: 27/Oct/15 Updated: 10/Apr/22 Resolved: 31/Oct/15 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Tom Pantelis | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| Issue Links: |
|
||||||||
| External issue ID: | 4539 | ||||||||
| Description |
|
If you omit the ending '}' for a leaf statement, parsing succeeds and code is generated, or at least some of it as in some cases Java compilation may fail. Example: in the mdsal project, go to mdsal/model/ietf/ietf-restconf and do mvn clean. Open src/main/yang/ietf-restconf@2013-10-19.yang. On line 189, remove the ending '}': leaf edit-id { type string; description "Arbitrary string index for the edit. Error messages returned by the server pertaining to a specific edit will be identified by this value."; }--> line 189 Run mvn and you should see yang parsing succeed and files generated but a Java compilation error. |
| Comments |
| Comment by Robert Varga [ 28/Oct/15 ] |
|
There is also a report of the following: 2) line 124:13 extraneous input ',' expecting {'}', SEP, IDENTIFIER} line 93:0 extraneous input '}' expecting {<EOF>, SEP} line 124:13 extraneous input ',' expecting {'}', SEP, IDENTIFIER}opendaylight-user@root>line 124:13 extraneous input ',' expecting {'} ', SEP, IDENTIFIER} Which seems to be related. |
| Comment by Tom Pantelis [ 28/Oct/15 ] |
|
With the old parser you get: [ERROR] Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:0.7.2-SNAPSHOT:generate-sources (default) on project ietf-restconf: yang-to-sources: Unable to parse yang files from /home/mininet/ODL/lithium/yangtools/model/ietf/ietf-restconf/src/main/yang: Failed to parse yang data: extraneous input 'leaf' expecting {'}', 'when', 'units', 'type', 'status', 'reference', 'must', 'mandatory', 'if-feature', 'description', 'default', 'config', IDENTIFIER} |
| Comment by Robert Varga [ 31/Oct/15 ] |
| Comment by Tom Pantelis [ 31/Oct/15 ] |
|
I tried ietf-restconf syntax error example again and I see the error reported by the syntax paerser: [ERROR] no viable alternative at input '<EOF>' in module ietf-restconf on line 690 character 2 However I also see this exception afterwards: [ERROR] yang-to-sources: Unable to parse yang files from /home/mininet/ODL/mdsal/model/ietf/ietf-restconf/src/main/yang The NPE is what is reported in the summary by maven: [ERROR] Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:0.8.0-SNAPSHOT:generate-sources (binding) on project ietf-restconf: yang-to-sources: Unable to parse yang files from /home/mininet/ODL/mdsal/model/ietf/ietf-restconf/src/main/yang: NullPointerException -> [Help 1] Even though the parser failed the invalid syntax, an NPE should not occur - it looks sloppy. |