TypeFox / yang-lsp

A Language Server for YANG
http://www.yang-central.org
Apache License 2.0
51 stars 13 forks source link

Pyang validation of serialized pattern statements fails for (some) unquoted regexps #220

Closed andreasjakobik closed 2 years ago

andreasjakobik commented 2 years ago

Hello,

When creating a Yang module programatically including pattern statements, some of them gets serialized with wrapping single quotes, and some don't. This is fine most of the time, but for the following particular pattern string pyang validation fails:

$ cat test.yang
...
    typedef my-dt {
        type string {
            pattern (/.*/i?);  // line 736
        }
    }
...
$ pyang test.yang 
test.yang:736: error: unterminated statement definition for keyword "pattern", looking at *

If on the other hand the pattern statement is wrapped there is no error:

pattern '(/.*/i?)';

Would it be possible to update the serializer to always wrap the patterns? This is actually an internal design rule we have defined.

Thanks, Andreas

dhuebner commented 2 years ago

released