stevedlawrence commented on code in PR #799:
URL: https://github.com/apache/daffodil/pull/799#discussion_r889194876
##########
daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala:
##########
@@ -2364,6 +2358,35 @@ sealed abstract class DocumentPart(part: Node, parent:
Document) {
}
}.trim.toUpperCase()
+ /*
+ * Allow "//" and "/* */" (inline) to act as comments.
+ * Any characters not explicitly allowed are also considered comments and are
removed.
+ */
+ def removeComments(validCharactersSet : String, userData : String ) : String
= {
+ lazy val doubleForwardPattern = "//.*".r
+ lazy val openClosePattern = "/[*].*[*]/".r
+
+ //Remove the comments (//) and (/* */)
+ lazy val noCommentsForward = doubleForwardPattern.replaceAllIn(userData,"")
+ lazy val noCommentsBothFormats =
openClosePattern.replaceAllIn(noCommentsForward,"")
+
+ //Throw exception if /* or */ still found. This means user input was not
formatted correctly.
+ if(noCommentsBothFormats.contains("/*") ||
noCommentsBothFormats.contains("*/")){
+ throw TDMLException("Improper formatting of /* */ style comment", None)
+ }
+
+ //Remove the new lines - concatenate after
+ lazy val noCommentsString = noCommentsBothFormats.split('\n').mkString
Review Comment:
Is it possible for `\r` to also exist in documentParts, like if running on
windows? Or does it all get canonicalized to `\n`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]