mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
530 stars 343 forks source link

single vs. double quotes in -f yang output #785

Closed alicerusso closed 2 years ago

alicerusso commented 2 years ago

Question regarding the formatted output (from pyang -f yang --keep-comments). From discussion with authors of RFC-to-be 9166 -- see ietf-igmp-mld-snooping@2021-12-20.yang in Section 4 of that document.

Essentially: Is the pyang formatted output correct? The author notes that a when statement typically uses single quotes; however, in the case of a when statement that contains a line break, it uses double quotes.

For example, at line 884:

leaf-list static-bridge-mrouter-interface {
 when 'derived-from-or-self(../l2-service-type,"ims:bridge")';

but at line 1112:

   leaf-list bridge-outgoing-interface {
      when "derived-from-or-self(../../l2-service-type,
           \"ims:bridge\")"; 

(FWIW, the same usage of double quotes is in Section 3 of RFC 9093.)

mbj4668 commented 2 years ago

Technically, this is correct.

The algorithm used for "when" is: unless the argument contains single quotes or newlines, use single quotes. Otherwise use double quotes.