corenova / yang-js

YANG parser and composer
Apache License 2.0
56 stars 18 forks source link

Alternate choice syntax doesn't compile #100

Closed jcourington closed 5 years ago

jcourington commented 5 years ago

From RFC6020 - the following 2 should be equivalent but the first version without the 'case' gives an error - see Error below

choice interface-type {
    container ethernet { ... }
}

is equivalent to:

choice interface-type {
    case ethernet {
        container ethernet { ... }
    }
}
ExpressionError: cannot contain more than one non-case data node statement
    at Function.Element.error (/home/src/node_modules/yang-js/lib/element.js:60:15)
    at Function.Expression.error (/home/src/node_modules/yang-js/lib/expression.js:191:40)
    at Function.resolve (/home/src/node_modules/yang-js/lib/lang/extensions.js:296:22)
    at Function.Expression.compile (/home/src/node_modules/yang-js/lib/expression.js:83:15)
    at /home/src/node_modules/yang-js/lib/expression.js:98:18
    at Array.forEach (<anonymous>)
    at Function.Expression.compile (/home/src/node_modules/yang-js/lib/expression.js:97:18)
    at /home/src/node_modules/yang-js/lib/expression.js:98:18
    at Array.forEach (<anonymous>)
    at Function.Expression.compile (/home/src/node_modules/yang-js/lib/expression.js:97:18)
sekur commented 5 years ago

Thanks for reporting the issue, I’ll investigate and let you know what I find.