shexSpec / shex

ShEx language issues, including new features for e.g. ShEx2.1
24 stars 8 forks source link

multi-line comments #82

Closed ericprud closed 6 years ago

ericprud commented 6 years ago

It's frequently useful to comment a multi-line block of ShEx. I find c-style comments / archaic, tedious, a throw-back to old computing practices, */ quite handy when commenting or debugging large schemas. In this [expressivity example](http://rawgit.com/shexSpec/shex.js/master/doc/shex-simple.html?schema=%3CS%3E%20%7B%0A%20%20%3Cp1%3E%20%20%20%20%5B1%5D%20%3B%0A%20%20%3Cp2%3E%20%2F%20%5B2%5D%20%3B%0A%20%20%3Cp3%3E%20%20%20%20%5B3%5D%20%3B%20%2F%20escaped%20embedded%20comment%20%5C%2F%0A%20%20%3Cp4%3E%20%2F%20%5B4%5D%20%3B%0A%7D&data=%3Cs%3E%0A%20%20%3Cp1%3E%201%3B%0A%20%20%3Cp2%3E%204.&manifestURL=..%2Fexamples%2Fmanifest.json&shape-map=%3Cs%3E%40%3CS%3E&interface=human&regexpEngine=threaded-val-nerr), everything between the / */s is ignored, including the nested comment whose closing delimiter is escaped with a \/:

<S> {
  <p1>    [1] ;
  <p2> /* [2] ;
  <p3>    [3] ; /* escaped embedded comment *\/
  <p4> */ [4] ;
}

The resulting shape is:

<S> {
  <p1>    [1] ;
  <p2>    [4] ;
}

The implementor impact is minimal, just the addition of a comment rule:

 COMMENT                 '#' [^\u000a\u000d]*
+                      | "/*" ([^*] | '*' ('\\/' | [^/]))* "*/"

a "/" followed by n (non-'*' or '*' followed by a "\/" or a non-'/')s terminated with a "\/".

jimkont commented 6 years ago

support for multiline comments by @labra, @emulatingkat, @andrawaag, @ericprud, @hsolbrig, @tombaker, and @jimkont

before acceptance needs confirmation by @hsolbrig for the grammar parser

hsolbrig commented 6 years ago

Looks good. ShExDoc.g4 has been updated to support this. Will update the ShExC parser accordingly

ericprud commented 6 years ago

updated shexTest and spec