corenova / yang-js

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

Issue with importing Yang file with Extensions #137

Open k-jay-c opened 3 years ago

k-jay-c commented 3 years ago

@sekur

I am trying to import some Yang files which are part of an application that contains various extension.

When trying to import, I'm getting the following error:

unable to parse '/Volume/Samsung/yangTest/tailf-common.yang' YANG module from '/Volume/Samsung/yangTest/tailf-common.yang'
/Volumes/Samsung/code/node_modules/yang-js/lib/node.js:223
          throw e;
          ^

Error [ExpressionError]: [extension(export)/tailf:use-in(module)] encountered unknown extension 'tailf:use-in'
    at Function.error (/Volumes/Samsung/code/node_modules/yang-js/lib/element.js:74:17)
    at Function.error (/Volumes/Samsung/code/node_modules/yang-js/lib/expression.js:149:21)
    at Function.compile (/Volumes/Samsung/code/node_modules/yang-js/lib/yang.js:166:22)
    at /Volumes/Samsung/code/node_modules/yang-js/lib/expression.js:66:20
    at Array.forEach (<anonymous>)
    at Function.compile (/Volumes/Samsung/code/node_modules/yang-js/lib/expression.js:65:20)
    at Function.compile (/Volumes/Samsung/code/node_modules/yang-js/lib/yang.js:168:22)
    at Function.parse (/Volumes/Samsung/code/node_modules/yang-js/lib/yang.js:103:16)
    at /Volumes/Samsung/code/node_modules/yang-js/lib/yang.js:87:23
    at Array.map (<anonymous>) {
  uri: 'extension(export)/tailf:use-in(module)',
  src: <ref *1> [Function: evaluate] Yang {
    parent: <ref *2> [Function: evaluate] Yang {
      'tailf:use-in': [ [Circular *1] ],
      'tailf:occurence': [
        [Function: evaluate] Yang {
          parent: [Circular *2],
          [Symbol(element:index)]: 1
        }
      ],
      description: [Function: evaluate] Yang {
        parent: [Circular *2],
        [Symbol(element:index)]: 2
      },
      [Symbol(element:cache)]: [
        [Circular *1],
        [Function: evaluate] Yang {
          parent: [Circular *2],
          [Symbol(element:index)]: 1
        },
        [Function: evaluate] Yang {
          parent: [Circular *2],
          [Symbol(element:index)]: 2
        }
      ]
    },
    [Symbol(element:index)]: 0
  },
  ctx: undefined
}

[Done] exited with code=1 in 0.236 seconds

The script I'm executing is as follows:

const Yang = require('yang-js');

const imp = Yang.import('/Volume/Samsung/yangTest/tailf-common.yang');

Attached are the following yang files within the zip yang.zip : tailf-common.yang, tailf-cli-extensions.yang and tailf-meta-extensions.yang

Any help you can provide in understanding or enabling importing of the yang files will be of great help.

Kind Regards, Jay.

Verten commented 1 year ago

The same error i have met, how do you solve it?