corenova / yang-js

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

Unable to import o-ran-compression-factors.yang #131

Open brchiu opened 3 years ago

brchiu commented 3 years ago

o-ran-compression-factors.yang.txt

var Yang = require('yang-js')

Yang.import('./o-ran-compression-factors.yang')

According to RFC6020, subscription is a valid sub-statement for case statement.

description_is_a_valid_substatement_for_case_statement

However, it fails when parsing the following excerpt.

    choice compression-format {
      description
        "Choice of compression format for particular element";

      case no-compresison {
        description "Compression for beam weights is not supported.";
      }
.     ...
   }

Error log is below :

$ node test2.js
unable to parse '../ORAN-MP-V3/o-ran-compression-factors.yang' YANG module from '/home/brchiu/Projects/ORAN-MP-V3/o-ran-compression-factors.yang'
/home/brchiu/Projects/learn_yangjs/node_modules/yang-js/lib/node.js:223
          throw e;
          ^

Error [ExpressionError]: [module(o-ran-compression-factors)/grouping(compression-params)/choice(compression-format)/case(no-compresison)] cannot have an empty case statement
    at Function.error (/home/brchiu/Projects/learn_yangjs/node_modules/yang-js/lib/element.js:74:17)
    at Function.error (/home/brchiu/Projects/learn_yangjs/node_modules/yang-js/lib/expression.js:149:21)
    at EventEmitter.<anonymous> (/home/brchiu/Projects/learn_yangjs/node_modules/yang-js/lib/lang/extensions.js:298:24)
    at Object.onceWrapper (events.js:421:28)
    at EventEmitter.emit (events.js:315:20)
    at Function.emit (/home/brchiu/Projects/learn_yangjs/node_modules/yang-js/lib/yang.js:152:22)
    at Function.compile (/home/brchiu/Projects/learn_yangjs/node_modules/yang-js/lib/expression.js:69:14)
    at Function.compile (/home/brchiu/Projects/learn_yangjs/node_modules/yang-js/lib/yang.js:168:22)
    at /home/brchiu/Projects/learn_yangjs/node_modules/yang-js/lib/expression.js:66:20
    at Array.forEach (<anonymous>) {
  uri: 'module(o-ran-compression-factors)/grouping(compression-params)/choice(compression-format)/case(no-compresison)',
  src: <ref *1> [Function: evaluate] Yang {
    description: [Function: evaluate] Yang {
      parent: [Circular *1],
      [Symbol(element:index)]: 0,
      [Symbol(element:cache)]: []
    },
    parent: <ref *2> [Function: evaluate] Yang {
      description: [Function: evaluate] Yang {
        parent: [Circular *2],
        [Symbol(element:index)]: 0,
        [Symbol(element:cache)]: []
      },
      case: [
        [Circular *1],
        <ref *3> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *3],
            [Symbol(element:index)]: 0
          },
          leaf: [ [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 2
        },
        <ref *4> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *4],
            [Symbol(element:index)]: 0
          },
          leaf: [ [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 3
        },
        <ref *5> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *5],
            [Symbol(element:index)]: 0
          },
          leaf: [ [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 4
        },
        <ref *6> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *6],
            [Symbol(element:index)]: 0
          },
          leaf: [ [Yang], [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 5
        },
        <ref *7> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *7],
            [Symbol(element:index)]: 0
          },
          'leaf-list': [ [Yang] ],
          leaf: [ [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 6
        },
        <ref *8> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *8],
            [Symbol(element:index)]: 0
          },
          leaf: [ [Yang], [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 7
        },
        <ref *9> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *9],
            [Symbol(element:index)]: 0
          },
          leaf: [ [Yang], [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 8
        }
      ],
      parent: <ref *10> [Function: evaluate] Yang {
        leaf: [
          [Function: evaluate] Yang {
            type: [Yang],
            mandatory: [Yang],
            description: [Yang],
            parent: [Circular *10],
            [Symbol(element:cache)]: [Array],
            [Symbol(element:index)]: 0
          },
          [Function: evaluate] Yang {
            when: [Yang],
            type: [Yang],
            status: [Yang],
            description: [Yang],
            parent: [Circular *10],
            [Symbol(element:cache)]: [Array],
            [Symbol(element:index)]: 1
          }
        ],
        choice: [ [Circular *2] ],
        parent: <ref *11> [Function: evaluate] Yang {
          'yang-version': [Function: evaluate] Yang {
            parent: [Circular *11],
            [Symbol(element:index)]: 0,
            [Symbol(element:cache)]: []
          },
          namespace: [Function: evaluate] Yang {
            parent: [Circular *11],
            [Symbol(element:index)]: 1,
            [Symbol(element:cache)]: []
          },
          prefix: [Function: evaluate] Yang {
            parent: [Circular *11],
            [Symbol(element:index)]: 2,
            [Symbol(element:cache)]: []
          },
          organization: [Function: evaluate] Yang {
            parent: [Circular *11],
            [Symbol(element:index)]: 3,
            [Symbol(element:cache)]: []
          },
          contact: [Function: evaluate] Yang {
            parent: [Circular *11],
            [Symbol(element:index)]: 4,
            [Symbol(element:cache)]: []
          },
          description: [Function: evaluate] Yang {
            parent: [Circular *11],
            [Symbol(element:index)]: 5,
            [Symbol(element:cache)]: []
          },
          revision: [ [Yang], [Yang], [Yang] ],
          grouping: [ [Circular *10], [Yang] ],
          [Symbol(element:cache)]: [
            [Yang], [Yang],
            [Yang], [Yang],
            [Yang], [Yang],
            [Yang], [Yang],
            [Yang], [Circular *10],
            [Yang]
          ]
        },
        [Symbol(element:cache)]: [
          [Function: evaluate] Yang {
            type: [Yang],
            mandatory: [Yang],
            description: [Yang],
            parent: [Circular *10],
            [Symbol(element:cache)]: [Array],
            [Symbol(element:index)]: 0
          },
          [Function: evaluate] Yang {
            when: [Yang],
            type: [Yang],
            status: [Yang],
            description: [Yang],
            parent: [Circular *10],
            [Symbol(element:cache)]: [Array],
            [Symbol(element:index)]: 1
          },
          [Circular *2]
        ],
        [Symbol(element:index)]: 9
      },
      [Symbol(element:cache)]: [
        [Function: evaluate] Yang {
          parent: [Circular *2],
          [Symbol(element:index)]: 0,
          [Symbol(element:cache)]: []
        },
        [Circular *1],
        <ref *3> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *3],
            [Symbol(element:index)]: 0
          },
          leaf: [ [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 2
        },
        <ref *4> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *4],
            [Symbol(element:index)]: 0
          },
          leaf: [ [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 3
        },
        <ref *5> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *5],
            [Symbol(element:index)]: 0
          },
          leaf: [ [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 4
        },
        <ref *6> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *6],
            [Symbol(element:index)]: 0
          },
          leaf: [ [Yang], [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 5
        },
        <ref *7> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *7],
            [Symbol(element:index)]: 0
          },
          'leaf-list': [ [Yang] ],
          leaf: [ [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 6
        },
        <ref *8> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *8],
            [Symbol(element:index)]: 0
          },
          leaf: [ [Yang], [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 7
        },
        <ref *9> [Function: evaluate] Yang {
          description: [Function: evaluate] Yang {
            parent: [Circular *9],
            [Symbol(element:index)]: 0
          },
          leaf: [ [Yang], [Yang] ],
          parent: [Circular *2],
          [Symbol(element:cache)]: null,
          [Symbol(element:index)]: 8
        }
      ],
      [Symbol(element:index)]: 2
    },
    [Symbol(element:cache)]: [
      [Function: evaluate] Yang {
        parent: [Circular *1],
        [Symbol(element:index)]: 0,
        [Symbol(element:cache)]: []
      }
    ],
    [Symbol(element:index)]: 1
  },
  ctx: undefined
}
sekur commented 3 years ago

Hi @brchiu, I'm not sure what the functional intent would be of having a case statement with only a description sub-statement. That case statement cannot be used to match/validate anything? The RFC is vague about whether a data node identifier must be present under a case statement but I'm unclear on the use case for this.

brchiu commented 3 years ago

@sekur, now I know that it's reasonable to have no data node under this case statement because it indicates an option of no compression of compression-format that do not have any parameters.

brchiu commented 3 years ago

@sekur, before you clarify whether a case statement with only a description sub-statement is valid or not, could you advice how I can workaround with it temporarily or locally by modifying any specific code excerpt on my side for further processing O-RAN yang modules ? Thank you very much.